PHP code example of arc / grants
1. Go to this page and download the library: Download arc/grants library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
arc / grants example snippets
\arc\grants::cd('/foo/')->setForUser('public', 'read');
$hasReadAccess = \arc\grants::cd('/foo/bar/')->checkForUser('public', 'read'); // returns true
\arc\grants::setForUser('public', 'read add edit delete');
\arc\grants::cd('/foo/bar/')->setForUser('public', 'none');
\arc\grants::switchUser('admin');
\arc\grants::set('read add edit >delete');
$hasReadAccess = \arc\grants::check('read');
\arc\grants::cd('/foo/');
\arc\grants::switchUser('admin', ['administrators','public']);
$hasReadAccess = \arc\grants::check('read');
\arc\grants::setForGroup('administrators', 'read add edit delete');
$hasReadAccess = \arc\grants::switchUser('admin', ['administrators','public'])->check('read');
\arc\grants::cd('/')
->setForUser('mike', 'read edit')
->setForGroup('editors', 'read add edit >delete')
->cd('/foo/')
->setForGroup('editors', 'read');
$hasEditAccess = \arc\grants::switchUser('mike', ['editors'])->cd('/foo/')->check('edit'); // => true
$hasAddAccess = \arc\grants::switchUser('mike', ['editors'])->cd('/')->check('add'); // => false
$hasAddAccess = \arc\grants::switchUser('mike', ['editors'])->cd('/foo/')->check('add'); // => false
$userGrantsList = \arc\grants::cd('/foo/')->grantsForAllUsers();
$groupGrantsList = \arc\grants::grantsForAllGroups();