Elgg\Database\AccessCollections::getReadableAccessLevel PHP Метод

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

Ownership requirement prevents us from exposing names of access collections that current user has been added to by other members and may contain sensitive classification of the current user (e.g. close friends vs acquaintances). Returns a string in the language of the user for global access levels, e.g.'Public, 'Friends', 'Logged in', 'Private'; or a name of the owned access collection, e.g. 'My work colleagues'; or a name of the group or other access collection, e.g. 'Group: Elgg technical support'; or 'Limited' if the user access is restricted to read-only, e.g. a friends collection the user was added to
С версии: 1.11
public getReadableAccessLevel ( integer $entity_access_id ) : string
$entity_access_id integer The entity's access id
Результат string
    function getReadableAccessLevel($entity_access_id)
    {
        $access = (int) $entity_access_id;
        $translator = $this->translator;
        // Check if entity access id is a defined global constant
        $access_array = array(ACCESS_PRIVATE => $translator->translate("PRIVATE"), ACCESS_FRIENDS => $translator->translate("access:friends:label"), ACCESS_LOGGED_IN => $translator->translate("LOGGED_IN"), ACCESS_PUBLIC => $translator->translate("PUBLIC"));
        if (array_key_exists($access, $access_array)) {
            return $access_array[$access];
        }
        $user_guid = $this->session->getLoggedInUserGuid();
        if (!$user_guid) {
            // return 'Limited' if there is no logged in user
            return $translator->translate('access:limited:label');
        }
        // Entity access id is probably a custom access collection
        // Check if the user has write access to it and can see it's label
        // Admins should always be able to see the readable version
        $collection = $this->get($access);
        if ($collection) {
            if ($collection->owner_guid == $user_guid || $this->session->isAdminLoggedIn()) {
                return $collection->name;
            }
        }
        // return 'Limited' if the user does not have access to the access collection
        return $translator->translate('access:limited:label');
    }