本文整理汇总了PHP中UserGroup::get_by_name方法的典型用法代码示例。如果您正苦于以下问题:PHP UserGroup::get_by_name方法的具体用法?PHP UserGroup::get_by_name怎么用?PHP UserGroup::get_by_name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserGroup
的用法示例。
在下文中一共展示了UserGroup::get_by_name方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: install
/**
* Set up needed stuff for the plugin
**/
public function install()
{
Post::add_new_type('project');
// Give anonymous users access
$group = UserGroup::get_by_name('anonymous');
$group->grant('post_project', 'read');
}
示例2: 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);
}
}
示例3: action_plugin_activation
/**
* Register content type
**/
public function action_plugin_activation($plugin_file)
{
// add the content type.
Post::add_new_type('event');
// Give anonymous users access
$group = UserGroup::get_by_name('anonymous');
$group->grant('post_event', 'read');
}
示例4: install
/**
* install:
* - post type
* - permissions
*/
public static function install()
{
Post::add_new_type('event');
Post::activate_post_type('event');
// Give anonymous users access
$group = UserGroup::get_by_name('anonymous');
$group->grant('post_event', 'read');
}
示例5: 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);
}
}
示例6: 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');
}
示例7: install
/**
* install various stuff we need
*/
public static function install()
{
/**
* Register content type
**/
Post::add_new_type('report');
// Give anonymous users access
$group = UserGroup::get_by_name('anonymous');
$group->grant('post_report', 'read');
}
示例8: 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');
}
示例9: install
/**
* install various stuff we need
*/
public static function install()
{
Post::add_new_type('link');
// Give anonymous users access
$group = UserGroup::get_by_name('anonymous');
$group->grant('post_link', 'read');
// Set default settings
Options::set('linkblog__original', '<p><a href="{permalink}">Permalink</a></p>');
Options::set('linkblog__atom_permalink', false);
self::database();
}
示例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');
}
}
示例11: test_admin_access
/**
* function test_admin_access
*
**/
public function test_admin_access()
{
// Add acl-alice to the admin group
//(which has been granted admin priviliges in installhandler).
$this->acl_user_alice->add_to_group('admin');
$admin_group = UserGroup::get_by_name('admin');
if ($admin_group instanceof UserGroup) {
$admin_group->update();
}
$this->assert_true($this->acl_user_alice->can('admin'), 'Admin user does not have admin permission.');
$this->assert_false($this->acl_user_bob->can('admin'), 'Unpriviliged user has admin permission.');
}
示例12: create
/**
* Create a new UserGroup object and save it to the database
* @param array $paramarray An associative array of UserGroup fields
* @return UserGroup the UserGroup that was created
* @todo Make this function accept only a name, since you can't set an id into an autoincrement field, and we don't try.
*/
public static function create($paramarray)
{
$usergroup = new UserGroup($paramarray);
if ($usergroup->insert()) {
return $usergroup;
} else {
// Does the group already exist?
if (isset($paramarray['name'])) {
$exists = DB::get_value('SELECT count(1) FROM {groups} WHERE name = ?', array($paramarray['name']));
if ($exists) {
return UserGroup::get_by_name($paramarray['name']);
}
}
return false;
}
}
示例13: 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';
}
示例14: action_plugin_activation
/**
* Run activation routines, and setup default options.
*/
public function action_plugin_activation()
{
if (!CronTab::get_cronjob('blogroll:update')) {
CronTab::add_hourly_cron('blogroll:update', 'blogroll_update_cron', 'Updates the blog updated timestamp from weblogs.com');
}
Options::set('blogroll__api_version', self::API_VERSION);
Options::set('blogroll__use_updated', true);
Options::set('blogroll__max_links', '10');
Options::set('blogroll__sort_by', 'id');
Options::set('blogroll__direction', 'ASC');
Options::set('blogroll__list_title', 'Blogroll');
Post::add_new_type(self::CONTENT_TYPE);
// Give anonymous users access, if the group exists
$group = UserGroup::get_by_name('anonymous');
if ($group) {
$group->grant(self::CONTENT_TYPE, 'read');
}
}
示例15: action_plugin_activation
public function action_plugin_activation($plugin_file)
{
Post::add_new_type('urlbounce');
$group = UserGroup::get_by_name('anonymous');
$group->grant('post_urlbounce', 'read');
}