getRow() public method

Returns a database row from the entities table.
See also: entity_row_to_elggstar()
public getRow ( integer $guid, integer $user_guid = null ) : stdClas\stdClass | false
$guid integer The GUID of the object to extract
$user_guid integer GUID of the user accessing the row Defaults to logged in user if null Builds an access query for a logged out user if 0
return stdClas\stdClass | false
コード例 #1
0
ファイル: AccessCollections.php プロジェクト: elgg/elgg
 /**
  * Can a user access an entity.
  *
  * @warning If a logged in user doesn't have access to an entity, the
  * core engine will not load that entity.
  *
  * @tip This is mostly useful for checking if a user other than the logged in
  * user has access to an entity that is currently loaded.
  *
  * @todo This function would be much more useful if we could pass the guid of the
  * entity to test access for. We need to be able to tell whether the entity exists
  * and whether the user has access to the entity.
  *
  * @param ElggEntity $entity The entity to check access for.
  * @param ElggUser   $user   Optionally user to check access for. Defaults to
  *                           logged in user (which is a useless default).
  *
  * @return bool
  */
 public function hasAccessToEntity($entity, $user = null)
 {
     if (!$entity instanceof \ElggEntity) {
         return false;
     }
     if ($entity->access_id == ACCESS_PUBLIC) {
         // Public entities are always accessible
         return true;
     }
     // See #7159. Must not allow ignore access to affect query
     $ia = elgg_set_ignore_access(false);
     $user_guid = isset($user) ? (int) $user->guid : elgg_get_logged_in_user_guid();
     if ($user_guid && $user_guid == $entity->owner_guid) {
         // Owners have access to their own content
         return true;
     }
     if ($user_guid && $entity->access_id == ACCESS_LOGGED_IN) {
         // Existing users have access to entities with logged in access
         return true;
     }
     $row = $this->entities->getRow($entity->guid, $user_guid);
     elgg_set_ignore_access($ia);
     return !empty($row);
 }