本文整理汇总了PHP中PermissionKey::add方法的典型用法代码示例。如果您正苦于以下问题:PHP PermissionKey::add方法的具体用法?PHP PermissionKey::add怎么用?PHP PermissionKey::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PermissionKey
的用法示例。
在下文中一共展示了PermissionKey::add方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run() {
$j = Job::getByHandle('index_search_all');
if (!is_object($j)) {
Job::installByHandle('index_search_all');
}
$js = JobSet::getByName('Default');
if (!is_object($js)) {
$js = JobSet::add('Default');
}
$js->clearJobs();
$jobs = Job::getList();
foreach($jobs as $j) {
if (!$j->supportsQueue()) {
$js->addJob($j);
}
}
// create the view page in sitemap permission
$rpk = PermissionKey::getByHandle('view_page');
$vpk = PermissionKey::getByHandle('view_page_in_sitemap');
if (!is_object($vpk)) {
$vpk = PermissionKey::add('page', 'view_page_in_sitemap', 'View Page in Sitemap', 'View Page in Sitemap and Intelligent Search.', false, false);
}
// now we have to get a list of all pages in the site that have their own permissions set.
$db = Loader::db();
$r = $db->Execute('select cID from Pages where cInheritPermissionsFrom = "OVERRIDE" order by cID asc');
while ($row = $r->Fetchrow()) {
$c = Page::getByID($row['cID']);
if (is_object($c) && !$c->isError()) {
$rpk->setPermissionObject($c);
$vpk->setPermissionObject($c);
$rpa = $rpk->getPermissionAccessObject();
if (is_object($rpa)) {
$pt = $vpk->getPermissionAssignmentObject();
if (is_object($pt)) {
$pt->clearPermissionAssignment();
$pt->assignPermissionAccess($rpa);
}
}
}
}
}
示例2: run
public function run()
{
$bt = BlockType::getByHandle('guestbook');
if (is_object($bt)) {
$bt->refresh();
}
// add user export users task permission
$pk = PermissionKey::getByHandle('access_user_search_export');
if (!$pk instanceof PermissionKey) {
$pk = PermissionKey::add('user', 'access_user_search_export', 'Export Site Users', 'Controls whether a user can export site users or not', false, false);
$pa = $pk->getPermissionAccessObject();
if (!is_object($pa)) {
$pa = PermissionAccess::create($pk);
}
$adminGroup = Group::getByID(ADMIN_GROUP_ID);
//Make sure "Adminstrators" group still exists
if ($adminGroup) {
$adminGroupEntity = GroupPermissionAccessEntity::getOrCreate($adminGroup);
$pa->addListItem($adminGroupEntity);
$pt = $pk->getPermissionAssignmentObject();
$pt->assignPermissionAccess($pa);
}
}
if (!Config::get('SECURITY_TOKEN_JOBS')) {
Config::save('SECURITY_TOKEN_JOBS', Loader::helper('validation/identifier')->getString(64));
}
if (!Config::get('SECURITY_TOKEN_ENCRYPTION')) {
Config::save('SECURITY_TOKEN_ENCRYPTION', Loader::helper('validation/identifier')->getString(64));
}
if (!Config::get('SECURITY_TOKEN_VALIDATION')) {
Config::save('SECURITY_TOKEN_VALIDATION', Loader::helper('validation/identifier')->getString(64));
}
$sp = Page::getByPath('/dashboard/system/mail/method/test_settings');
if (!is_object($sp) || $sp->isError()) {
$sp = SinglePage::add('/dashboard/system/mail/method/test_settings');
$sp->update(array('cName' => t('Test Mail Settings')));
$sp->setAttribute('meta_keywords', 'test smtp, test mail');
}
}