本文整理汇总了PHP中ACL类的典型用法代码示例。如果您正苦于以下问题:PHP ACL类的具体用法?PHP ACL怎么用?PHP ACL使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ACL类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doResetRightsOnCollection
/**
* Resets admin rights on a collection.
*
* @param \ACL $acl
* @param \collection $collection
*/
private function doResetRightsOnCollection(\ACL $acl, \collection $collection)
{
$baseId = $collection->get_base_id();
$acl->set_limits($baseId, false);
$acl->remove_quotas_on_base($baseId);
$acl->set_masks_on_base($baseId, '0', '0', '0', '0');
$acl->update_rights_to_base($baseId, ['canputinalbum' => '1', 'candwnldhd' => '1', 'candwnldsubdef' => '1', 'nowatermark' => '1', 'candwnldpreview' => '1', 'cancmd' => '1', 'canadmin' => '1', 'canreport' => '1', 'canpush' => '1', 'creationdate' => '1', 'canaddrecord' => '1', 'canmodifrecord' => '1', 'candeleterecord' => '1', 'chgstatus' => '1', 'imgtools' => '1', 'manage' => '1', 'modify_struct' => '1', 'bas_modify_struct' => '1']);
}
示例2: getACL
protected function getACL()
{
$acl = new ACL();
$logger = new \Monolog\Logger('ACL');
$logger->pushHandler(new \Monolog\Handler\SyslogHandler('ACL Tests'));
$acl->setLogger($logger);
return $acl;
}
示例3: test_join_test
function test_join_test()
{
ACL::add('dummy', 'blog:posts', 'add');
$acl = new ACL();
$this->assertTrue($acl->grant('dummy', 'blog:posts', 'add'));
$this->assertFalse($acl->grant('dummy', 'blog:posts', 'edit'));
ACL::remove('dummy', 'blog:posts', 'add');
$this->assertFalse($acl->grant('dummy', 'blog:posts', 'add'));
}
示例4: signup_form
function signup_form($data)
{
$user = new User();
if ($data) {
foreach ($data as $key => $value) {
$field_name = ucwords(str_replace('_', ' ', $key));
switch ($key) {
case 'first_name':
case 'last_name':
case 'username':
if (trim($value) == '') {
$error[] = 'Field ' . $field_name . ' is required!';
}
break;
case 'email':
if (!filter_var($value, FILTER_VALIDATE_EMAIL)) {
$error[] = 'Invalid format for ' . $field_name . ', please insert a valid email!';
}
break;
}
}
// Verify Username
$user->byUsername($data['username']);
if ($data['username'] = $user->username) {
$error[] = 'Username already taken. Please select another one.';
}
if ($data['password'] != $data['password2']) {
$error[] = 'Password does not match.';
}
// Adding values
if ($data['password']) {
$user->password = $data['password'];
$gen_pass = false;
} else {
$gen_pass = true;
}
if (!$error) {
$res = $user->create(false, $gen_pass, $data);
if ($res) {
session_start();
$ACL = new ACL();
$ACL->username = $res->username;
$ACL->password = $res->temp_password;
$ACL->login();
header("Location: /dashboard.php");
} else {
$error[] = 'Ops, We could not create the user at this time. Try again later.';
}
}
}
global $twig;
// Twig Base
$template = $twig->loadTemplate('signup-content.html');
$template->display(array('project_title' => TITLE, 'path_to_theme' => '../../' . THEME_PATH, 'company' => NATURAL_COMPANY, 'page' => 'signup', 'data' => $data, 'errors' => $error));
}
示例5: processAclRequest
private function processAclRequest()
{
$dom = $this->xmlDom;
$headerNode = $dom->getElementsByTagName('SIF_Header')->item(0);
$originalMsgId = $headerNode->getElementsByTagName('SIF_MsgId')->item(0)->nodeValue;
$originalSourceId = $headerNode->getElementsByTagName('SIF_SourceId')->item(0)->nodeValue;
$acl = new ACL($dom);
$timestamp = Utility::createTimestamp();
$msgId = Utility::createMessageId();
XmlHelper::buildSuccessMessage($msgId, $timestamp, $originalSourceId, $originalMsgId, 0, $originalMsg = $acl->BuildACL(), $desc = null);
}
示例6: getAllForUser
/**
* Returns all the feeds a user can access.
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getAllForUser(\ACL $userACL)
{
$base_ids = array_keys($userACL->get_granted_base());
$qb = $this->createQueryBuilder('f');
$qb->where($qb->expr()->isNull('f.baseId'))->orWhere('f.public = true');
if (count($base_ids) > 0) {
$qb->orWhere($qb->expr()->in('f.baseId', $base_ids));
}
$qb->orderBy('f.updatedOn', 'DESC');
return $qb->getQuery()->getResult();
}
示例7: permissions
public function permissions()
{
$this->form_validation->set_rules('resource', 'resource', 'required');
return Validation::validate($this, 'user', 'read', function ($token, $output) {
$resource = $this->input->post('resource');
$acl = new ACL();
$permissions = $acl->userPermissions($token->id, $resource);
$output['status'] = true;
$output['resource'] = $resource;
$output['permissions'] = $permissions;
return $output;
});
}
示例8: action_plugin_deactivation
public function action_plugin_deactivation($file)
{
if ($file == str_replace('\\', '/', $this->get_file())) {
# delete default access token
ACL::destroy_token('manage_cronjobs');
}
}
示例9: render_item
protected function render_item(&$next_id, $name, $cfg, $parent)
{
$menu = '';
if ($parent == -1) {
$menu .= Ext::menu_begin($name);
}
if (is_array($cfg)) {
$cur_id = $next_id;
$cur_menu = '';
if ($parent != -1) {
$cur_menu .= Ext::menu_row($next_id, $name, NULL, $parent);
}
$next_id++;
$cur_menu_subitems = '';
foreach ($cfg as $subname => $subcfg) {
$cur_menu_subitems .= $this->render_item($next_id, $subname, $subcfg, $cur_id);
}
if (!empty($cur_menu_subitems)) {
$menu .= $cur_menu . $cur_menu_subitems;
}
} else {
if (ACL::is_route_allowed($cfg)) {
$menu .= Ext::menu_row($next_id, $name, $cfg, $parent);
if ($this->is_route_active($cfg)) {
$this->_active_id = $next_id;
}
}
$next_id++;
}
if ($parent == -1) {
$menu .= Ext::menu_end($this->_active_id);
}
return $menu;
}
示例10: action_user
public function action_user()
{
$id = (int) $this->request->param('id', 0);
$post = ORM::factory('user', $id);
if (!$post->loaded() or $id === 1) {
Message::error(__("User doesn't exists!"));
Log::error('Attempt to access non-existent user.');
$this->request->redirect(Route::get('admin/user')->uri(array('action' => 'list')), 404);
}
$this->title = __(':user Permissions', array(":user" => $post->name));
$action = Route::get('admin/permission')->uri(array('action' => 'user', 'id' => isset($post->id) ? $post->id : 0));
$view = View::factory('admin/permission/user')->set('post', $post)->set('oldperms', $post->perms())->set('permissions', ACL::all())->set('action', $action)->bind('errors', $this->_errors);
if ($this->valid_post('permissions')) {
$perms = array_filter($_POST['perms']);
$post->data = array('permissions' => $perms);
try {
$post->save();
Message::success(__('Permissions: saved successful!'));
$this->request->redirect(Route::get('admin/permission')->uri(array('action' => 'user', 'id' => $post->id)));
} catch (ORM_Validation_Exception $e) {
Message::error(__('Permissions save failed!'));
$this->_errors = $e->errors('models', TRUE);
} catch (Exception $e) {
Message::error(__('Permissions save failed!'));
$this->_errors = array($e->getMessage());
}
}
$this->response->body($view);
}
示例11: before
/**
* The before() method is called before controller action
*
* @uses ACL::required
*/
public function before()
{
ACL::required('access comment');
// Disable sidebars on comments page
$this->_sidebars = FALSE;
parent::before();
}
示例12: action_plugin_deactivation
public function action_plugin_deactivation($file)
{
if (realpath($file) == __FILE__) {
CronTab::delete_cronjob('pbem_check_accounts');
ACL::destroy_token('PBEM');
}
}
示例13: setUp
public function setUp()
{
parent::setUp();
$model = new TestDocument();
$model->createDatabaseTable(true);
Helper::dbFixture(SITEMAP_TABLE, []);
\ACL::create(SitemapModel::PermissionName);
Configure::write('Sitemap', ['Menu' => ['title' => self::Title, 'depth' => 3]]);
Helper::setupUsers([['login' => self::AdminUser, 'rights' => [SitemapModel::PermissionName => true]], ['login' => self::GuestUser]]);
$documents = [['name' => 'first', 'sitemap' => ['count' => 1]], ['name' => 'second'], ['name' => 'third', 'sitemap' => ['parent' => 1]]];
foreach ($documents as $key => $row) {
$documents[$key] = new TestDocument($row);
$documents[$key]->insert();
$sitemapModel = new SitemapModel();
$sitemapModel->name = $row['name'];
$sitemapModel->full_url = $row['name'];
$sitemapModel->linkToModel($documents[$key]);
if (isset($row['sitemap'])) {
foreach ($row['sitemap'] as $key => $value) {
$sitemapModel->{$key} = $value;
}
}
$sitemapModel->insert();
}
}
示例14: instance
/**
* @return ACL
*/
public static function instance()
{
if (is_null(self::$_instance)) {
self::$_instance = new self();
}
return self::$_instance;
}
示例15: loadAccess
/**
* Загрузка информации о правах пользователя.
*/
private function loadAccess()
{
if (null === $this->access) {
$this->access = ACL::getTypeAccess($this->getGroups());
}
return $this->access;
}