コード例 #1
0
 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);
     }
 }
コード例 #2
0
 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);
     }
 }
コード例 #3
0
ファイル: test_usergroup.php プロジェクト: rick-c/tests
	function test_creategroup()
	{
		$user = User::create( array( 'username' => 'testcaseuser', 'email' => '*****@*****.**', '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.'
		);

	}
コード例 #4
0
	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' );
	}
コード例 #5
0
ファイル: hpm.plugin.php プロジェクト: habari-extras/hpm
 /**
  * @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);
 }
コード例 #6
0
 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);
     }
 }
コード例 #7
0
 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');
     }
 }
コード例 #8
0
 /**
  * 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');
 }
コード例 #9
0
 /**
  * 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');
 }
コード例 #10
0
 /**
  * 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');
     }
 }
コード例 #11
0
ファイル: test_acl.php プロジェクト: habari/tests
 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');
 }
コード例 #12
0
 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'));
     }
 }
コード例 #13
0
 /**
  * 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');
 }
コード例 #14
0
ファイル: pbem.plugin.php プロジェクト: habari-extras/pbem
 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');
             }
         }
     }
 }
コード例 #15
0
 /**
  * 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';
 }
コード例 #16
0
 /**
  *  Action: plugin activation 
  *
  * Sets up this plugin when activated, including:
  *
  * - Creates the ACL token for admin users
  * - Creates plugin options with initial values of 0 (off)
  *
  * @return void
  */
 public function action_plugin_activation($file)
 {
     if ($file == str_replace('\\', '/', $this->get_file())) {
         ACL::create_token('manage_options', _t('Manage Options'), 'Options', FALSE);
         $group = UserGroup::get_by_name('admin');
         $group->grant('manage_options');
     }
     Options::set(strtolower(get_class($this)) . '__allow_delete_core', 0);
     Options::set(strtolower(get_class($this)) . '__allow_delete_other', 0);
 }
コード例 #17
0
ファイル: installhandler.php プロジェクト: anupom/my-blog
 private function upgrade_db_post_3158()
 {
     // delete own_post_typeX tokens rather than rebuild the whole default token set
     foreach (Post::list_active_post_types() as $name => $posttype) {
         ACL::destroy_token('own_post_' . Utils::slugify($name));
     }
     ACL::destroy_token('own_posts_any');
     ACL::create_token('own_posts', _t('Permissions on one\'s own posts'), 'Content', true);
 }
コード例 #18
0
 public function action_plugin_activation($file)
 {
     DB::register_table('macro');
     /*
      * Create the database table, or upgrade it
      */
     $dbms = DB::get_driver_name();
     $sql = 'CREATE TABLE ' . DB::table('macro') . ' ' . '(';
     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 .= 'name VARCHAR(255), ' . 'enabled INTEGER DEFAULT 1, ' . 'modified INTEGER, ' . 'description TEXT, ' . 'definition TEXT NOT NULL, ' . 'container INTEGER DEFAULT 0, ' . 'nargs INTEGER DEFAULT 0, ' . 'eval INTEGER DEFAULT 0' . ')';
     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 Macros plugin'), 'Category', false);
         $group = UserGroup::get_by_name('admin');
         $group->grant(self::PLUGIN_TOKEN);
     }
 }
コード例 #19
0
ファイル: test_usergroup.php プロジェクト: habari/tests
 public function setup_acl()
 {
     ACL::create_token('test permission', 'A permission for test cases', 'Administration');
     ACL::create_token('test deny permission', 'A permission for test cases', 'Administration');
     $this->group->add('alice');
     $this->group->grant('test permission');
     $this->group->deny('test deny permission');
 }
コード例 #20
0
ファイル: s3silo.plugin.php プロジェクト: ringmaster/s3silo
 public function action_plugin_activation($file)
 {
     // Create required tokens
     ACL::create_token('upload_s3_media', _t('Upload files to s3 silos'), 'Administration');
     ACL::create_token('delete_s3_media', _t('Delete files from s3 silos'), 'Administration');
 }
コード例 #21
0
 /**
  * Set up needed permissions
  */
 private static function install()
 {
     // Create post types
     Post::add_new_type('forum');
     Post::add_new_type('thread');
     Post::add_new_type('reply');
     // Create vocabulary
     $params = array('name' => self::$vocab, 'description' => 'A vocabulary for describing relationships between threads', 'features' => array('hierarchical'));
     $vocabulary = new Vocabulary($params);
     $vocabulary->insert();
     // Create tokens
     ACL::create_token('forum_see_private', _t('See Private Threads'), 'Forum', false);
     ACL::create_token('forum_close_thread', _t('Close Threads'), 'Forum', false);
     // Grant tokens
     $group = UserGroup::get_by_name('admin');
     $group->grant('forum_close_thread');
     $group->grant('forum_see_private');
 }
コード例 #22
0
 /**
  * add ACL tokens when this plugin is activated
  **/
 public function action_plugin_activation($file)
 {
     if (Plugins::id_from_file($file) == Plugins::id_from_file(__FILE__)) {
         ACL::create_token('LiveHelp', 'Access the #habari IRC channel via the LiveHelp plugin', 'livehelp');
     }
 }
コード例 #23
0
ファイル: installhandler.php プロジェクト: habari/system
 private function upgrade_db_post_4770()
 {
     // Add CRUD access tokens for other users' unpublished posts
     ACL::create_token('post_unpublished', _t("Permissions to other users' unpublished posts"), _t('Content'), true);
     // If a group doesn't have super_user permission, deny access to post_unpublished
     $groups = UserGroups::get_all();
     foreach ($groups as $group) {
         if (!ACL::group_can($group->id, 'super_user', 'read')) {
             $group->deny('post_unpublished');
         }
     }
 }
コード例 #24
0
 /**
  * add ACL tokens when this plugin is activated
  **/
 public function action_plugin_activation($file)
 {
     ACL::create_token('Rewriter', 'Create custom rewrite rules', 'rewriter');
 }
コード例 #25
0
 private function upgrade_db_post_3701()
 {
     ACL::create_token('manage_dash_modules', _t('Manage dashboard modules'), 'Administration');
 }
コード例 #26
0
ファイル: post.php プロジェクト: rynodivino/system
	/**
	 * inserts a new post type into the database, if it doesn't exist
	 * @param string The name of the new post type
	 * @param bool Whether the new post type is active or not
	 * @return none
	 */
	public static function add_new_type( $type, $active = true )
	{
		// refresh the cache from the DB, just to be sure
		$types = self::list_all_post_types( true );

		if ( ! array_key_exists( $type, $types ) ) {
			// Doesn't exist in DB.. add it and activate it.
			DB::query( 'INSERT INTO {posttype} (name, active) VALUES (?, ?)', array( $type, $active ) );
		}
		elseif ( $types[$type]['active'] == 0 ) {
			// Isn't active so we activate it
			self::activate_post_type( $type );
		}
		ACL::create_token( 'post_' . Utils::slugify( $type ), _t( 'Permissions to posts of type "%s"', array( $type ) ), _t( 'Content' ), true );

		// now force a refresh of the caches, so the new/activated type
		// is available for immediate use
		$types = self::list_active_post_types( true );
		$types = self::list_all_post_types( true );
	}
コード例 #27
0
 /**
  * Add tokens to the tokens table
  * @param integer $num number of tokens to add, or configured value if null.
  */
 private function populate_tokens_add($num = null)
 {
     if (!isset($num)) {
         $num = Options::get('populate__tokens');
     }
     // Add all these tokens.
     $count = 0;
     while ($count++ < $num) {
         // Create an ACL token.
         ACL::create_token('populate_token_' . strtolower($this->helper_random_name(9)), 'Populate ' . $this->helper_random_name(), 'Administration', rand(0, 1));
     }
     return;
 }