Elgg\UserCapabilities::canWriteToContainer PHP Метод

canWriteToContainer() публичный Метод

Can a user add an entity to this container
См. также: elgg_set_ignore_access()
public canWriteToContainer ( ElggEntity $entity, integer $user_guid, string $type = 'all', string $subtype = 'all' ) : boolean
$entity ElggEntity Container entity
$user_guid integer The GUID of the user creating the entity (0 for logged in user).
$type string The type of entity we're looking to write
$subtype string The subtype of the entity we're looking to write
Результат boolean
    public function canWriteToContainer(ElggEntity $entity, $user_guid = 0, $type = 'all', $subtype = 'all')
    {
        try {
            $user = $this->entities->getUserForPermissionsCheck($user_guid);
        } catch (UserFetchFailureException $e) {
            return false;
        }
        if ($user) {
            $user_guid = $user->guid;
        }
        $params = ['container' => $entity, 'user' => $user, 'subtype' => $subtype];
        // Unlike permissions, logic check can be used to prevent certain entity
        // types from being contained by other entity types,
        // e.g. discussion reply objects can only be contained by discussion objects.
        // This hook can also be used to apply status logic, e.g. to disallow
        // new replies in closed discussions.
        // We do not take a stand hence the return is null. This can be used by
        // handlers to check if another hook has modified the value.
        $logic_check = $this->hooks->trigger('container_logic_check', $type, $params);
        if ($logic_check === false) {
            return false;
        }
        $return = false;
        if ($entity) {
            // If the user can edit the container, they can also write to it
            if ($entity->canEdit($user_guid)) {
                $return = true;
            }
        }
        // Container permissions can prevent users from writing to an entity.
        // For instance, these permissions can prevent non-group members from writing
        // content to the group.
        return $this->hooks->trigger('container_permissions_check', $type, $params, $return);
    }