本文整理汇总了PHP中identity::groups方法的典型用法代码示例。如果您正苦于以下问题:PHP identity::groups方法的具体用法?PHP identity::groups怎么用?PHP identity::groups使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类identity
的用法示例。
在下文中一共展示了identity::groups方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _get_form
private function _get_form($item)
{
$view = new View("permissions_form.html");
$view->item = $item;
$view->groups = identity::groups();
$view->permissions = ORM::factory("permission")->find_all();
return $view;
}
示例2: upgrade
static function upgrade($version)
{
$db = Database::instance();
if ($version == 1) {
module::set_var("gallery", "date_format", "Y-M-d");
module::set_var("gallery", "date_time_format", "Y-M-d H:i:s");
module::set_var("gallery", "time_format", "H:i:s");
module::set_version("gallery", $version = 2);
}
if ($version == 2) {
module::set_var("gallery", "show_credits", 1);
module::set_version("gallery", $version = 3);
}
if ($version == 3) {
$db->query("CREATE TABLE {caches} (\n `id` varchar(255) NOT NULL,\n `tags` varchar(255),\n `expiration` int(9) NOT NULL,\n `cache` text,\n PRIMARY KEY (`id`),\n KEY (`tags`))\n DEFAULT CHARSET=utf8;");
module::set_version("gallery", $version = 4);
}
if ($version == 4) {
Cache::instance()->delete_all();
$db->query("ALTER TABLE {caches} MODIFY COLUMN `cache` LONGBLOB");
module::set_version("gallery", $version = 5);
}
if ($version == 5) {
Cache::instance()->delete_all();
$db->query("ALTER TABLE {caches} DROP COLUMN `id`");
$db->query("ALTER TABLE {caches} ADD COLUMN `key` varchar(255) NOT NULL");
$db->query("ALTER TABLE {caches} ADD COLUMN `id` int(9) NOT NULL auto_increment PRIMARY KEY");
module::set_version("gallery", $version = 6);
}
if ($version == 6) {
module::clear_var("gallery", "version");
module::set_version("gallery", $version = 7);
}
if ($version == 7) {
$groups = identity::groups();
$permissions = ORM::factory("permission")->find_all();
foreach ($groups as $group) {
foreach ($permissions as $permission) {
// Update access intents
$db->query("ALTER TABLE {access_intents} MODIFY COLUMN {$permission->name}_{$group->id} BINARY(1) DEFAULT NULL");
// Update access cache
if ($permission->name === "view") {
$db->query("ALTER TABLE {items} MODIFY COLUMN {$permission->name}_{$group->id} BINARY(1) DEFAULT FALSE");
} else {
$db->query("ALTER TABLE {access_caches} MODIFY COLUMN {$permission->name}_{$group->id} BINARY(1) NOT NULL DEFAULT FALSE");
}
}
}
module::set_version("gallery", $version = 8);
}
if ($version == 8) {
$db->query("ALTER TABLE {items} CHANGE COLUMN `left` `left_ptr` INT(9) NOT NULL;");
$db->query("ALTER TABLE {items} CHANGE COLUMN `right` `right_ptr` INT(9) NOT NULL;");
module::set_version("gallery", $version = 9);
}
if ($version == 9) {
$db->query("ALTER TABLE {items} ADD KEY `weight` (`weight` DESC);");
module::set_version("gallery", $version = 10);
}
if ($version == 10) {
module::set_var("gallery", "image_sharpen", 15);
module::set_version("gallery", $version = 11);
}
if ($version == 11) {
$db->query("ALTER TABLE {items} ADD COLUMN `relative_url_cache` varchar(255) DEFAULT NULL");
$db->query("ALTER TABLE {items} ADD COLUMN `slug` varchar(255) DEFAULT NULL");
// This is imperfect since some of the slugs may contain invalid characters, but it'll do
// for now because we don't want a lengthy operation here.
$db->query("UPDATE {items} SET `slug` = `name`");
// Flush all path caches becuase we're going to start urlencoding them.
$db->query("UPDATE {items} SET `relative_url_cache` = NULL, `relative_path_cache` = NULL");
module::set_version("gallery", $version = 12);
}
if ($version == 12) {
if (module::get_var("gallery", "active_site_theme") == "default") {
module::set_var("gallery", "active_site_theme", "wind");
}
if (module::get_var("gallery", "active_admin_theme") == "admin_default") {
module::set_var("gallery", "active_admin_theme", "admin_wind");
}
module::set_version("gallery", $version = 13);
}
if ($version == 13) {
// Add rules for generating our thumbnails and resizes
Database::instance()->query("UPDATE {graphics_rules} SET `operation` = CONCAT('gallery_graphics::', `operation`);");
module::set_version("gallery", $version = 14);
}
if ($version == 14) {
$sidebar_blocks = block_manager::get_active("site_sidebar");
if (empty($sidebar_blocks)) {
$available_blocks = block_manager::get_available_site_blocks();
foreach (array_keys(block_manager::get_available_site_blocks()) as $id) {
$sidebar_blocks[] = explode(":", $id);
}
block_manager::set_active("site_sidebar", $sidebar_blocks);
}
module::set_version("gallery", $version = 15);
}
if ($version == 15) {
module::set_var("gallery", "identity_provider", "user");
//.........这里部分代码省略.........
示例3: upgrade
static function upgrade($version)
{
$db = Database::instance();
if ($version == 1) {
module::set_var("gallery", "date_format", "Y-M-d");
module::set_var("gallery", "date_time_format", "Y-M-d H:i:s");
module::set_var("gallery", "time_format", "H:i:s");
module::set_version("gallery", $version = 2);
}
if ($version == 2) {
module::set_var("gallery", "show_credits", 1);
module::set_version("gallery", $version = 3);
}
if ($version == 3) {
$db->query("CREATE TABLE {caches} (\n `id` varchar(255) NOT NULL,\n `tags` varchar(255),\n `expiration` int(9) NOT NULL,\n `cache` text,\n PRIMARY KEY (`id`),\n KEY (`tags`))\n DEFAULT CHARSET=utf8;");
module::set_version("gallery", $version = 4);
}
if ($version == 4) {
Cache::instance()->delete_all();
$db->query("ALTER TABLE {caches} MODIFY COLUMN `cache` LONGBLOB");
module::set_version("gallery", $version = 5);
}
if ($version == 5) {
Cache::instance()->delete_all();
$db->query("ALTER TABLE {caches} DROP COLUMN `id`");
$db->query("ALTER TABLE {caches} ADD COLUMN `key` varchar(255) NOT NULL");
$db->query("ALTER TABLE {caches} ADD COLUMN `id` int(9) NOT NULL auto_increment PRIMARY KEY");
module::set_version("gallery", $version = 6);
}
if ($version == 6) {
module::clear_var("gallery", "version");
module::set_version("gallery", $version = 7);
}
if ($version == 7) {
$groups = identity::groups();
$permissions = ORM::factory("permission")->find_all();
foreach ($groups as $group) {
foreach ($permissions as $permission) {
// Update access intents
$db->query("ALTER TABLE {access_intents} MODIFY COLUMN {$permission->name}_{$group->id} BINARY(1) DEFAULT NULL");
// Update access cache
if ($permission->name === "view") {
$db->query("ALTER TABLE {items} MODIFY COLUMN {$permission->name}_{$group->id} BINARY(1) DEFAULT FALSE");
} else {
$db->query("ALTER TABLE {access_caches} MODIFY COLUMN {$permission->name}_{$group->id} BINARY(1) NOT NULL DEFAULT FALSE");
}
}
}
module::set_version("gallery", $version = 8);
}
if ($version == 8) {
$db->query("ALTER TABLE {items} CHANGE COLUMN `left` `left_ptr` INT(9) NOT NULL;");
$db->query("ALTER TABLE {items} CHANGE COLUMN `right` `right_ptr` INT(9) NOT NULL;");
module::set_version("gallery", $version = 9);
}
if ($version == 9) {
$db->query("ALTER TABLE {items} ADD KEY `weight` (`weight` DESC);");
module::set_version("gallery", $version = 10);
}
if ($version == 10) {
module::set_var("gallery", "image_sharpen", 15);
module::set_version("gallery", $version = 11);
}
if ($version == 11) {
$db->query("ALTER TABLE {items} ADD COLUMN `relative_url_cache` varchar(255) DEFAULT NULL");
$db->query("ALTER TABLE {items} ADD COLUMN `slug` varchar(255) DEFAULT NULL");
// This is imperfect since some of the slugs may contain invalid characters, but it'll do
// for now because we don't want a lengthy operation here.
$db->query("UPDATE {items} SET `slug` = `name`");
// Flush all path caches because we're going to start urlencoding them.
$db->query("UPDATE {items} SET `relative_url_cache` = NULL, `relative_path_cache` = NULL");
module::set_version("gallery", $version = 12);
}
if ($version == 12) {
if (module::get_var("gallery", "active_site_theme") == "default") {
module::set_var("gallery", "active_site_theme", "wind");
}
if (module::get_var("gallery", "active_admin_theme") == "admin_default") {
module::set_var("gallery", "active_admin_theme", "admin_wind");
}
module::set_version("gallery", $version = 13);
}
if ($version == 13) {
// Add rules for generating our thumbnails and resizes
Database::instance()->query("UPDATE {graphics_rules} SET `operation` = CONCAT('gallery_graphics::', `operation`);");
module::set_version("gallery", $version = 14);
}
if ($version == 14) {
$sidebar_blocks = block_manager::get_active("site_sidebar");
if (empty($sidebar_blocks)) {
$available_blocks = block_manager::get_available_site_blocks();
foreach (array_keys(block_manager::get_available_site_blocks()) as $id) {
$sidebar_blocks[] = explode(":", $id);
}
block_manager::set_active("site_sidebar", $sidebar_blocks);
}
module::set_version("gallery", $version = 15);
}
if ($version == 15) {
module::set_var("gallery", "identity_provider", "user");
//.........这里部分代码省略.........
示例4: upgrade
static function upgrade($version)
{
$db = Database::instance();
if ($version == 1) {
module::set_var("gallery", "date_format", "Y-M-d");
module::set_var("gallery", "date_time_format", "Y-M-d H:i:s");
module::set_var("gallery", "time_format", "H:i:s");
module::set_version("gallery", $version = 2);
}
if ($version == 2) {
module::set_var("gallery", "show_credits", 1);
module::set_version("gallery", $version = 3);
}
if ($version == 3) {
$db->query("CREATE TABLE {caches} (\n `id` varchar(255) NOT NULL,\n `tags` varchar(255),\n `expiration` int(9) NOT NULL,\n `cache` text,\n PRIMARY KEY (`id`),\n KEY (`tags`))\n DEFAULT CHARSET=utf8;");
module::set_version("gallery", $version = 4);
}
if ($version == 4) {
Cache::instance()->delete_all();
$db->query("ALTER TABLE {caches} MODIFY COLUMN `cache` LONGBLOB");
module::set_version("gallery", $version = 5);
}
if ($version == 5) {
Cache::instance()->delete_all();
$db->query("ALTER TABLE {caches} DROP COLUMN `id`");
$db->query("ALTER TABLE {caches} ADD COLUMN `key` varchar(255) NOT NULL");
$db->query("ALTER TABLE {caches} ADD COLUMN `id` int(9) NOT NULL auto_increment PRIMARY KEY");
module::set_version("gallery", $version = 6);
}
if ($version == 6) {
module::clear_var("gallery", "version");
module::set_version("gallery", $version = 7);
}
if ($version == 7) {
$groups = identity::groups();
$permissions = ORM::factory("permission")->find_all();
foreach ($groups as $group) {
foreach ($permissions as $permission) {
// Update access intents
$db->query("ALTER TABLE {access_intents} MODIFY COLUMN {$permission->name}_{$group->id} BINARY(1) DEFAULT NULL");
// Update access cache
if ($permission->name === "view") {
$db->query("ALTER TABLE {items} MODIFY COLUMN {$permission->name}_{$group->id} BINARY(1) DEFAULT FALSE");
} else {
$db->query("ALTER TABLE {access_caches} MODIFY COLUMN {$permission->name}_{$group->id} BINARY(1) NOT NULL DEFAULT FALSE");
}
}
}
module::set_version("gallery", $version = 8);
}
if ($version == 8) {
$db->query("ALTER TABLE {items} CHANGE COLUMN `left` `left_ptr` INT(9) NOT NULL;");
$db->query("ALTER TABLE {items} CHANGE COLUMN `right` `right_ptr` INT(9) NOT NULL;");
module::set_version("gallery", $version = 9);
}
if ($version == 9) {
$db->query("ALTER TABLE {items} ADD KEY `weight` (`weight` DESC);");
module::set_version("gallery", $version = 10);
}
if ($version == 10) {
module::set_var("gallery", "image_sharpen", 15);
module::set_version("gallery", $version = 11);
}
if ($version == 11) {
$db->query("ALTER TABLE {items} ADD COLUMN `relative_url_cache` varchar(255) DEFAULT NULL");
$db->query("ALTER TABLE {items} ADD COLUMN `slug` varchar(255) DEFAULT NULL");
// This is imperfect since some of the slugs may contain invalid characters, but it'll do
// for now because we don't want a lengthy operation here.
$db->query("UPDATE {items} SET `slug` = `name`");
// Flush all path caches becuase we're going to start urlencoding them.
$db->query("UPDATE {items} SET `relative_url_cache` = NULL, `relative_path_cache` = NULL");
module::set_version("gallery", $version = 12);
}
if ($version == 12) {
if (module::get_var("gallery", "active_site_theme") == "default") {
module::set_var("gallery", "active_site_theme", "wind");
}
if (module::get_var("gallery", "active_admin_theme") == "admin_default") {
module::set_var("gallery", "active_admin_theme", "admin_wind");
}
module::set_version("gallery", $version = 13);
}
if ($version == 13) {
// Add rules for generating our thumbnails and resizes
Database::instance()->query("UPDATE {graphics_rules} SET `operation` = CONCAT('gallery_graphics::', `operation`);");
module::set_version("gallery", $version = 14);
}
if ($version == 14) {
$sidebar_blocks = block_manager::get_active("site_sidebar");
if (empty($sidebar_blocks)) {
$available_blocks = block_manager::get_available_site_blocks();
foreach (array_keys(block_manager::get_available_site_blocks()) as $id) {
$sidebar_blocks[] = explode(":", $id);
}
block_manager::set_active("site_sidebar", $sidebar_blocks);
}
module::set_version("gallery", $version = 15);
}
if ($version == 15) {
module::set_var("gallery", "identity_provider", "user");
//.........这里部分代码省略.........
示例5: _get_admin_view
private function _get_admin_view($form, $errors)
{
$v = new Admin_View("admin.html");
$v->page_title = t("User registration");
$v->content = new View("admin_register.html");
$v->content->action = "admin/register/update";
$v->content->policy_list = array("admin_only" => t("Only site administrators can create new user accounts."), "visitor" => t("Visitors can create accounts and no administrator approval is required."), "admin_approval" => t("Visitors can create accounts but administrator approval is required."));
$admin = identity::admin_user();
$v->content->disable_email = empty($admin->email) || $form["policy"] == "admin_only" ? "disabled" : "";
if (empty($admin->email)) {
module::set_var("registration", "email_verification", false);
}
// below lines added Shad Laws, v2
$v->content->disable_admin_notify = empty($admin->email) || $form["policy"] !== "admin_approval" ? "disabled" : "";
if (empty($admin->email)) {
module::set_var("registration", "admin_notify", false);
}
$v->content->group_list = array();
foreach (identity::groups() as $group) {
if ($group->id != identity::everybody()->id && $group->id != identity::registered_users()->id) {
$v->content->group_list[$group->id] = $group->name;
}
}
$hidden = array("name" => "csrf", "value" => access::csrf_token());
if (count($v->content->group_list)) {
$v->content->group_list = array("" => t("Choose the default group")) + $v->content->group_list;
} else {
$hidden["group"] = "";
}
$v->content->hidden = $hidden;
$v->content->pending = ORM::factory("pending_user")->find_all();
$v->content->activate = "admin/register/activate";
$v->content->form = $form;
$v->content->errors = $errors;
return $v;
}
示例6: _import_permissions
/**
* Imports G2 permissions, mapping G2's permission model to G3's
* much simplified permissions.
*
* - Ignores user permissions, G3 only supports group permissions.
* - Ignores item permissions, G3 only supports album permissions.
*
* G2 permission -> G3 permission
* ---------------------------------
* core.view view
* core.viewSource view_full
* core.edit edit
* core.addDataItem add
* core.addAlbumItem add
* core.viewResizes <ignored>
* core.delete <ignored>
* comment.* <ignored>
*/
private static function _import_permissions($g2_album, $g3_album)
{
// No need to do anything if this album has the same G2 ACL as its parent.
if ($g2_album->getParentId() != null && g2(GalleryCoreApi::fetchAccessListId($g2_album->getId())) == g2(GalleryCoreApi::fetchAccessListId($g2_album->getParentId()))) {
return;
}
$granted_permissions = self::_map_permissions($g2_album->getId());
if ($g2_album->getParentId() == null) {
// Compare to current permissions, and change them if necessary.
$g3_parent_album = item::root();
} else {
$g3_parent_album = $g3_album->parent();
}
$granted_parent_permissions = array();
$perm_ids = array_unique(array_values(self::$_permission_map));
foreach (identity::groups() as $group) {
$granted_parent_permissions[$group->id] = array();
foreach ($perm_ids as $perm_id) {
if (access::group_can($group, $perm_id, $g3_parent_album)) {
$granted_parent_permissions[$group->id][$perm_id] = 1;
}
}
}
// Note: Only registering permissions if they're not the same as
// the inherited ones.
foreach ($granted_permissions as $group_id => $permissions) {
if (!isset($granted_parent_permissions[$group_id])) {
foreach (array_keys($permissions) as $perm_id) {
access::allow(identity::lookup_group($group_id), $perm_id, $g3_album);
}
} else {
if ($permissions != $granted_parent_permissions[$group_id]) {
$parent_permissions = $granted_parent_permissions[$group_id];
// @todo Probably worth caching the group instances.
$group = identity::lookup_group($group_id);
// Note: Cannot use array_diff_key.
foreach (array_keys($permissions) as $perm_id) {
if (!isset($parent_permissions[$perm_id])) {
access::allow($group, $perm_id, $g3_album);
}
}
foreach (array_keys($parent_permissions) as $perm_id) {
if (!isset($permissions[$perm_id])) {
access::deny($group, $perm_id, $g3_album);
}
}
}
}
}
foreach ($granted_parent_permissions as $group_id => $parent_permissions) {
if (isset($granted_permissions[$group_id])) {
continue;
// handled above
}
$group = identity::lookup_group($group_id);
foreach (array_keys($parent_permissions) as $perm_id) {
access::deny($group, $perm_id, $g3_album);
}
}
}
示例7: _get_all_groups
/**
* Internal method to get all available groups.
*
* @return ORM_Iterator
*/
private static function _get_all_groups()
{
// When we build the gallery package, it's possible that there is no identity provider
// installed yet. This is ok at packaging time, so work around it.
if (module::is_active(module::get_var("gallery", "identity_provider", "user"))) {
return identity::groups();
} else {
return array();
}
}
示例8: upgrade
static function upgrade($version)
{
$db = Database::instance();
if ($version == 1) {
module::set_var("gallery", "date_format", "Y-M-d");
module::set_var("gallery", "date_time_format", "Y-M-d H:i:s");
module::set_var("gallery", "time_format", "H:i:s");
module::set_version("gallery", $version = 2);
}
if ($version == 2) {
module::set_var("gallery", "show_credits", 1);
module::set_version("gallery", $version = 3);
}
if ($version == 3) {
$db->query("CREATE TABLE {caches} (\n `id` varchar(255) NOT NULL,\n `tags` varchar(255),\n `expiration` int(9) NOT NULL,\n `cache` text,\n PRIMARY KEY (`id`),\n KEY (`tags`))\n DEFAULT CHARSET=utf8;");
module::set_version("gallery", $version = 4);
}
if ($version == 4) {
Cache::instance()->delete_all();
$db->query("ALTER TABLE {caches} MODIFY COLUMN `cache` LONGBLOB");
module::set_version("gallery", $version = 5);
}
if ($version == 5) {
Cache::instance()->delete_all();
$db->query("ALTER TABLE {caches} DROP COLUMN `id`");
$db->query("ALTER TABLE {caches} ADD COLUMN `key` varchar(255) NOT NULL");
$db->query("ALTER TABLE {caches} ADD COLUMN `id` int(9) NOT NULL auto_increment PRIMARY KEY");
module::set_version("gallery", $version = 6);
}
if ($version == 6) {
module::clear_var("gallery", "version");
module::set_version("gallery", $version = 7);
}
if ($version == 7) {
$groups = identity::groups();
$permissions = ORM::factory("permission")->find_all();
foreach ($groups as $group) {
foreach ($permissions as $permission) {
// Update access intents
$db->query("ALTER TABLE {access_intents} MODIFY COLUMN {$permission->name}_{$group->id} BINARY(1) DEFAULT NULL");
// Update access cache
if ($permission->name === "view") {
$db->query("ALTER TABLE {items} MODIFY COLUMN {$permission->name}_{$group->id} BINARY(1) DEFAULT FALSE");
} else {
$db->query("ALTER TABLE {access_caches} MODIFY COLUMN {$permission->name}_{$group->id} BINARY(1) NOT NULL DEFAULT FALSE");
}
}
}
module::set_version("gallery", $version = 8);
}
if ($version == 8) {
$db->query("ALTER TABLE {items} CHANGE COLUMN `left` `left_ptr` INT(9) NOT NULL;");
$db->query("ALTER TABLE {items} CHANGE COLUMN `right` `right_ptr` INT(9) NOT NULL;");
module::set_version("gallery", $version = 9);
}
if ($version == 9) {
$db->query("ALTER TABLE {items} ADD KEY `weight` (`weight` DESC);");
module::set_version("gallery", $version = 10);
}
if ($version == 10) {
module::set_var("gallery", "image_sharpen", 15);
module::set_version("gallery", $version = 11);
}
if ($version == 11) {
$db->query("ALTER TABLE {items} ADD COLUMN `relative_url_cache` varchar(255) DEFAULT NULL");
$db->query("ALTER TABLE {items} ADD COLUMN `slug` varchar(255) DEFAULT NULL");
// This is imperfect since some of the slugs may contain invalid characters, but it'll do
// for now because we don't want a lengthy operation here.
$db->query("UPDATE {items} SET `slug` = `name`");
// Flush all path caches becuase we're going to start urlencoding them.
$db->query("UPDATE {items} SET `relative_url_cache` = NULL, `relative_path_cache` = NULL");
module::set_version("gallery", $version = 12);
}
if ($version == 12) {
if (module::get_var("gallery", "active_site_theme") == "default") {
module::set_var("gallery", "active_site_theme", "wind");
}
if (module::get_var("gallery", "active_admin_theme") == "admin_default") {
module::set_var("gallery", "active_admin_theme", "admin_wind");
}
module::set_version("gallery", $version = 13);
}
if ($version == 13) {
// Add rules for generating our thumbnails and resizes
Database::instance()->query("UPDATE {graphics_rules} SET `operation` = CONCAT('gallery_graphics::', `operation`);");
module::set_version("gallery", $version = 14);
}
if ($version == 14) {
$sidebar_blocks = block_manager::get_active("site_sidebar");
if (empty($sidebar_blocks)) {
$available_blocks = block_manager::get_available_site_blocks();
foreach (array_keys(block_manager::get_available_site_blocks()) as $id) {
$sidebar_blocks[] = explode(":", $id);
}
block_manager::set_active("site_sidebar", $sidebar_blocks);
}
module::set_version("gallery", $version = 15);
}
if ($version == 15) {
module::set_var("gallery", "identity_provider", "user");
//.........这里部分代码省略.........