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

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

Access colletions allow plugins and users to create granular access for entities. Triggers plugin hook 'access:collections:addcollection', 'collection'
public create ( string $name, integer $owner_guid ) : integer | false
$name string The name of the collection.
$owner_guid integer The GUID of the owner (default: currently logged in user).
Результат integer | false The collection ID if successful and false on failure.
    function create($name, $owner_guid = 0)
    {
        $name = trim($name);
        if (empty($name)) {
            return false;
        }
        if ($owner_guid == 0) {
            $owner_guid = $this->session->getLoggedInUserGuid();
        }
        $db = $this->db;
        $prefix = $db->prefix;
        $name = $db->sanitizeString($name);
        $q = "INSERT INTO {$prefix}access_collections\n\t\t\tSET name = '{$name}',\n\t\t\t\towner_guid = {$owner_guid}";
        $id = $db->insertData($q);
        if (!$id) {
            return false;
        }
        $params = array('collection_id' => $id);
        if (!$this->hooks->trigger('access:collections:addcollection', 'collection', $params, true)) {
            return false;
        }
        return $id;
    }