Checks if a record is owned by an user.

Example:
<code>
$posts->isOwnedBy(2, 4);
</code>
it checks if the posts with ID 2 belongs to the user with ID 4.
@param int $recordId Record ID
@param int $userId User ID
@return bool
335304
public function isOwnedBy($recordId, $userId = null)
    {
        return (bool)$this->find()
            ->where(['id' => $recordId, 'user_id' => $userId])
            ->first();
    }
934005
public function login(string $userID): bool
    {
        $data = Internal\Server::call('login', ['userID' => $userID], true);
        if (isset($data['result'])) {
            return $data['result'] === 'ok';
        }
        return false;
    }
217498
public function checkUserExist($userId, $conversationId)
    {
        $thread = $this->find($conversationId);

        if ($thread) {
            if (($thread->first_user_id == $userId) || ($thread->second_user_id == $userId)) {
                return true;
            }
        }

        return false;
    }
236804
public static function is_user_in_conversation(int $userid, int $conversationid) : bool {
        global $DB;

        return $DB->record_exists('message_conversation_members', ['conversationid' => $conversationid,
            'userid' => $userid]);
    }
999560
protected static function get_records($userid) {
        global $DB;

        $sql = "SELECT *
                  FROM {user_info_data} uda
                  JOIN {user_info_field} uif ON uda.fieldid = uif.id
                 WHERE uda.userid = :userid
                       AND uif.datatype = :datatype";
        $params = [
            'userid' => $userid,
            'datatype' => 'checkbox'
        ];

        return $DB->get_records_sql($sql, $params);
    }
1048739
public function isCountryAllowedForUser($userId, $country)
    {

        $query = $this->createQueryBuilder('p')
            ->select('p')
            ->where('p.user = :userId')
            ->setParameter('userId', $userId)
            ->getQuery();

        $data = $query->getResult();
        $return = false;

        foreach ($data as $availableCountries) {
            /** @var \PServerCore\Entity\AvailableCountries $availableCountries */
            if ($availableCountries->getCntry() == $country) {
                $return = true;
                break;
            }
        }
        return $return;
    }
152356
public function assignUser($userGroupId, $userId = [])
    {
        $this->groupId = $userGroupId;

        $this->getLogger()->info('Assigning User IDs ' . json_encode($userId) . ' To User Group ID ' . $this->groupId);
        $response = $this->doPost('/group/members/assign/' . $userGroupId, [
            'userId' => $userId
        ]);

        /** @var XiboUserGroup $userGroup */
        $userGroup = $this->hydrate($response);

        return $userGroup;
    }
1056551
public function get_from_user_id_and_post_ids(int $userid, array $postids) {
        $alias = $this->get_table_alias();
        [$postidinsql, $params] = $this->get_db()->get_in_or_equal($postids);
        $params[] = $userid;

        $wheresql = "{$alias}.postid {$postidinsql}";
        $wheresql .= " AND {$alias}.userid = ?";
        $sql = $this->generate_get_records_sql($wheresql);
        $records = $this->get_db()->get_records_sql($sql, $params);

        return $this->transform_db_records_to_entities($records);
    }
242150
public function findUser ($userId) {
    $query = $this->database->pdo->prepare('SELECT username, points FROM users WHERE userId = :userId');
    $query->bindParam(':userId', $userId);

    $query->execute();
    return (object) $query->fetch(PDO::FETCH_ASSOC);
  }
30734
protected function getUser4Id($userId): ?UserInterface
    {
        /** @var \PServerCore\Entity\Repository\User $userRepository */
        $userRepository = $this->entityManager->getRepository($this->entityOptions->getUser());

        return $userRepository->getUser4Id($userId);
    }
1055663
public function exists($userid)
	{
		$query = $this->_db->getQuery(true)
			->select('COUNT(userid)')
			->from($this->_db->quoteName($this->_tbl))
			->where($this->_db->quoteName('userid') . ' = ' . $this->_db->quote($userid));
		$this->_db->setQuery($query);

		if (!$result = $this->_db->loadResult())
		{
			$this->setError($this->_db->stderr());

			return false;
		}

		return (boolean) $result;
	}
1027480
public function updateRecord(int $recordID, array $data)
    {
        foreach ($this->getRecords() as $key => $record) {
            if ($recordID == $record[$this->primaryKey]) {
                foreach ($data as $dataKey => $dataValue) {
                    if (isset($record[$dataKey])) {
                        $record[$dataKey] = $dataValue;
                    }
                }

                $this->database->getReference()
                    ->getChild($this->table)
                    ->getChild($key)
                    ->set($record);
            }
        }

        return $this->getRecord($recordID);
    }
1275672
public function liked($userId=null)
	{
		if(is_null($userId)) {
			$userId = $this->loggedInUserId();
		}
		
		return (bool) $this->likes()
			->where('user_id', '=', $userId)
			->count();
	}
879716
public function canDelete($user_id)
    {
        if ($this->isSuperadmin($user_id)) {
            return false;
        }

        $result = $this->db->fetchColumn('SELECT * FROM orders WHERE user_id=?', array($user_id));
        return empty($result);
    }
1013229
public function loadPoliciesByUserId($userId)
    {
        try {
            return $this->innerGateway->loadPoliciesByUserId($userId);
        } catch (DBALException $e) {
            throw new RuntimeException('Database error', 0, $e);
        } catch (PDOException $e) {
            throw new RuntimeException('Database error', 0, $e);
        }
    }
491111
protected function is_graded($userid) {
        $grade = $this->get_user_grade($userid, false);
        if ($grade) {
            return ($grade->grade !== null && $grade->grade >= 0);
        }
        return false;
    }
281353
public function getById($userid)
    {
        $filter = new IteratorFilter();
        $filter->addRelation($this->getUserDefinition()->getUserid(), Relation::EQUAL, $userid);
        return $this->getUser($filter);
    }