当前位置: 首页>>代码示例>>PHP>>正文


PHP ACL::create_token方法代码示例

本文整理汇总了PHP中ACL::create_token方法的典型用法代码示例。如果您正苦于以下问题:PHP ACL::create_token方法的具体用法?PHP ACL::create_token怎么用?PHP ACL::create_token使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ACL的用法示例。


在下文中一共展示了ACL::create_token方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: action_plugin_activation

 public function action_plugin_activation($file)
 {
     DB::register_table('abbrev');
     /*
      * Create the database table, or upgrade it
      */
     $dbms = DB::get_driver_name();
     $sql = 'CREATE TABLE ' . DB::table('abbrev') . ' ' . '(';
     if ($dbms == 'sqlite') {
         $sql .= 'xid INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,';
     } else {
         if ($dbms == 'mysql') {
             $sql .= 'xid INT(9) NOT NULL AUTO_INCREMENT,' . 'UNIQUE KEY xid (xid),';
         } else {
             $sql .= 'xid INT(9) NOT NULL AUTO_INCREMENT,' . 'UNIQUE KEY xid (xid),';
         }
     }
     $sql .= 'abbrev VARCHAR(255),' . 'caseful INTEGER DEFAULT 0,' . "prefix VARCHAR(16) DEFAULT '\\b'," . "postfix VARCHAR(16) DEFAULT '\\b'," . 'priority INTEGER DEFAULT 100,' . 'definition VARCHAR(255)' . ')';
     if (!DB::dbdelta($sql)) {
         Utils::debug(DB::get_errors());
     }
     if ($file == str_replace('\\', '/', $this->get_file())) {
         ACL::create_token(self::PLUGIN_TOKEN, _t('Allow use of Abbrev plugin'), 'Category', false);
         $group = UserGroup::get_by_name('admin');
         $group->grant(self::PLUGIN_TOKEN);
     }
 }
开发者ID:habari-extras,项目名称:abbrev,代码行数:27,代码来源:abbrev.plugin.php

示例2: action_plugin_activation

 public function action_plugin_activation($file)
 {
     if ($file == str_replace('\\', '/', $this->get_file())) {
         # create default access token
         ACL::create_token('manage_cronjobs', _t('Manage CronJobs', 'crontabmanager'), 'Crontab', false);
     }
 }
开发者ID:habari-extras,项目名称:crontabmanager,代码行数:7,代码来源:crontabmanager.plugin.php

示例3: test_creategroup

	function test_creategroup()
	{
		$user = User::create( array( 'username' => 'testcaseuser', 'email' => 'test@example.com', 'password' => 'test') );
		$this->assert_true(
			$user instanceof User,
			'Could not create test user.'
		);

		$group = UserGroup::create( array( 'name' => 'new test group' ) );
		$this->assert_true(
			$group instanceof UserGroup,
			'Could not create a new group named "new test group".'
		);

		ACL::create_token( 'test permission', 'A permission for test cases', 'Administration' );
		ACL::create_token( 'test deny permission', 'A permission for test cases', 'Administration' );

		$this->assert_true(
			ACL::token_exists('test permission'),
			'The test permission was not created.'
		);
		$this->assert_true(
			ACL::token_exists(' test  PeRmission '),
			'Permission names are not normalized.'
		);

		$group->add( 'testcaseuser' );
		$group->grant( 'test permission' );
		$group->deny( 'test  deny permisSion' );
		$group->update();

		$newgroup = UserGroup::get( 'new test group' );

		$this->assert_true(
			in_array( $user->id, $newgroup->members ),
			'The created user is not a member of the new group.'
		);

		$this->assert_true(
			in_array( ACL::token_id( 'test permission' ), array_keys( $newgroup->permissions ) ),
			'The group does not have the new permission.'
		);

		$this->assert_true(
			ACL::group_can( 'new test group', 'test permission' ),
			'The group does not have the new permission.'
		);

		$this->assert_false(
			ACL::group_can( 'new test group', 'test deny permission' ),
			'The group has a denied permission.'
		);

		$this->assert_true(
			$user->can( 'test permission' ),
			'The user does not have a permission his group has been granted.'
		);

	}
开发者ID:rick-c,项目名称:tests,代码行数:59,代码来源:test_usergroup.php

示例4: action_plugin_activation

	public function action_plugin_activation( $file )
	{
		// Create required tokens
		ACL::create_token( 'create_directories', _t( 'Create media silo directories' ), 'Administration' );
		ACL::create_token( 'delete_directories', _t( 'Delete media silo directories' ), 'Administration' );
		ACL::create_token( 'upload_media', _t( 'Upload files to media silos' ), 'Administration' );
		ACL::create_token( 'delete_media', _t( 'Delete files from media silos' ), 'Administration' );
	}
开发者ID:nerdfiles,项目名称:habari_boilerplate,代码行数:8,代码来源:habarisilo.plugin.php

示例5: action_plugin_activation

 /**
  * @todo fix the tokens
  */
 public function action_plugin_activation()
 {
     # create default access tokens for: 'system', 'plugin', 'theme', 'class'
     ACL::create_token('install_new_system', _t('Install System Updates', 'hpm'), 'hpm', false);
     ACL::create_token('install_new_plugin', _t('Install New Plugins', 'hpm'), 'hpm', false);
     ACL::create_token('install_new_theme', _t('Install New Themes', 'hpm'), 'hpm', false);
     ACL::create_token('install_new_class', _t('Install New Classes', 'hpm'), 'hpm', false);
 }
开发者ID:habari-extras,项目名称:hpm,代码行数:11,代码来源:hpm.plugin.php

示例6: action_plugin_activation

 public function action_plugin_activation($file)
 {
     if ($file == str_replace('\\', '/', $this->get_file())) {
         ACL::create_token(self::PLUGIN_TOKEN, _t('Allow use of AtomIcon plugin'), 'Category', false);
         $group = UserGroup::get_by_name('admin');
         $group->grant(self::PLUGIN_TOKEN);
     }
 }
开发者ID:habari-extras,项目名称:atomicon,代码行数:8,代码来源:atomicon.plugin.php

示例7: action_plugin_activation

 public function action_plugin_activation()
 {
     ACL::create_token('private', 'Permission to read posts marked as "private"', 'Private Posts');
     // Deny the anonymous group access to the private token, if the group hasn't been removed (why would you remove it ??)
     $anon = UserGroup::get('anonymous');
     if (false != $anon) {
         $anon->deny('private');
     }
 }
开发者ID:psaintlaurent,项目名称:Habari,代码行数:9,代码来源:simple_private_posts.plugin.php

示例8: action_plugin_activation

 /**
  * Add the category vocabulary and create the admin token
  *
  **/
 public function action_plugin_activation($file)
 {
     $params = array('name' => self::$vocabulary, 'description' => 'A vocabulary for describing Categories', 'features' => array('multiple', 'hierarchical'));
     Vocabulary::create($params);
     // create default access token
     ACL::create_token('manage_categories', _t('Manage categories'), 'Administration', false);
     $group = UserGroup::get_by_name('admin');
     $group->grant('manage_categories');
 }
开发者ID:habari-extras,项目名称:simplecategories,代码行数:13,代码来源:simplecategories.plugin.php

示例9: action_plugin_activation

 /**
  * Create an admin token for editing menus
  **/
 public function action_plugin_activation($file)
 {
     // create default access token
     ACL::create_token('manage_menus', _t('Manage menus', 'termmenus'), 'Administration', false);
     $group = UserGroup::get_by_name('admin');
     $group->grant('manage_menus');
     // register menu types
     Vocabulary::add_object_type('menu_link');
     Vocabulary::add_object_type('menu_spacer');
 }
开发者ID:habari-extras,项目名称:termmenus,代码行数:13,代码来源:termmenus.plugin.php

示例10: action_plugin_activation

 /**
  * Add the shelf vocabulary and create the admin token
  *
  **/
 public function action_plugin_activation($file)
 {
     if (Plugins::id_from_file($file) == Plugins::id_from_file(__FILE__)) {
         $params = array('name' => self::$vocabulary, 'description' => 'A vocabulary for describing Shelves', 'features' => array('hierarchical'));
         Vocabulary::create($params);
         // create default access token
         ACL::create_token('manage_shelves', _t('Manage ') . Options::get('shelves__plural', _t('shelves', 'shelves')), 'Administration', false);
         $group = UserGroup::get_by_name('admin');
         $group->grant('manage_shelves');
     }
 }
开发者ID:habari-extras,项目名称:shelves,代码行数:15,代码来源:shelves.plugin.php

示例11: test_user_permissions

 public function test_user_permissions()
 {
     ACL::create_token('acltest', 'A test ACL permission', 'Administration');
     $this->acl_user_alice->grant('acltest', 'full');
     $this->assert_true($this->acl_user_alice->can('acltest', 'full'), 'Could not grant acltest permission to user.');
     $this->acl_user_alice->revoke('acltest');
     // check that members of a group inherit that group's permissions
     $this->acl_group->grant('acltest', 'full');
     $this->assert_true($this->acl_user_alice->can('acltest', 'full'), 'User did not inherit group permissions.');
     ACL::destroy_token('acltest');
 }
开发者ID:habari,项目名称:tests,代码行数:11,代码来源:test_acl.php

示例12: action_plugin_activation

 public function action_plugin_activation($file = '')
 {
     if (Plugins::id_from_file($file) == Plugins::id_from_file(__FILE__)) {
         ACL::create_token('snapshot', 'Manage Database Snapshots', 'Export', true);
         // save the default options
         Options::set('exportsnapshot__frequency', 'manually');
         Options::set('exportsnapshot__type', 'blogml');
         // add the module
         Modules::add(_t('Snapshots', 'exportsnapshot'));
     }
 }
开发者ID:habari-extras,项目名称:exportsnapshot,代码行数:11,代码来源:exportsnapshot.plugin.php

示例13: action_plugin_activation

 /**
  * Don't bother loading if the gd library isn't active
  */
 public function action_plugin_activation($file)
 {
     if (!function_exists('imagecreatefromjpeg')) {
         Session::error(_t("Habari Silo activation failed. PHP has not loaded the gd imaging library."));
         Plugins::deactivate_plugin(__FILE__);
     }
     // Create required tokens
     ACL::create_token('create_directories', _t('Create media silo directories'), 'Administration');
     ACL::create_token('delete_directories', _t('Delete media silo directories'), 'Administration');
     ACL::create_token('upload_media', _t('Upload files to media silos'), 'Administration');
     ACL::create_token('delete_media', _t('Delete files from media silos'), 'Administration');
 }
开发者ID:psaintlaurent,项目名称:Habari,代码行数:15,代码来源:habarisilo.plugin.php

示例14: action_plugin_activation

 public function action_plugin_activation($file)
 {
     if (realpath($file) == __FILE__) {
         CronTab::add_cron(array('name' => 'pbem_check_accounts', 'callback' => array(__CLASS__, 'check_accounts'), 'increment' => 600, 'description' => 'Check for new PBEM mail every 600 seconds.'));
         ACL::create_token('PBEM', 'Directly administer posts from the PBEM plugin', 'pbem');
         $dir = Site::get_dir('user') . '/files/PBEM';
         if (!is_dir($dir)) {
             if (!mkdir($dir, 0755)) {
                 EventLog::log('PBEM temporary storage directory ' . $dir . ' could not be created. Attachment processing will not work.', 'info', 'plugin', 'pbem');
                 Session::error('PBEM temporary storage directory ' . $dir . ' could not be created. Attachment processing will not work.');
             } else {
                 EventLog::log('PBEM temporary storage directory ' . $dir . ' created.', 'info', 'plugin', 'pbem');
             }
         }
     }
 }
开发者ID:habari-extras,项目名称:pbem,代码行数:16,代码来源:pbem.plugin.php

示例15: action_plugin_activation

 /**
  * Hook on activation of this plugin
  */
 public function action_plugin_activation()
 {
     // add the new content types
     Post::add_new_type('addon');
     // allow reading the new content types
     UserGroup::get_by_name('anonymous')->grant('post_addon', 'read');
     // create a permissions token
     ACL::create_token('manage_versions', _t('Manage Addon Versions', 'addon_catalog'), 'Addon Catalog', false);
     // create the addon vocabulary (type)
     Vocabulary::add_object_type('addon');
     // create the addon vocabulary
     $params = array('name' => self::CATALOG_VOCABULARY, 'description' => _t('A vocabulary for addon versions in the addons catalog', 'addon_catalog'));
     $vocabulary = Vocabulary::create($params);
     // @TODO: notification/log of some sort?
     // create the default content
     include 'create_core_addons.php';
 }
开发者ID:habari-extras,项目名称:addon_catalog,代码行数:20,代码来源:addon_catalog.plugin.php


注:本文中的ACL::create_token方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。