本文整理汇总了PHP中PermissionKey类的典型用法代码示例。如果您正苦于以下问题:PHP PermissionKey类的具体用法?PHP PermissionKey怎么用?PHP PermissionKey使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PermissionKey类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: copyFromDefaultsToGathering
public function copyFromDefaultsToGathering(PermissionKey $pk)
{
$db = Loader::db();
$paID = $pk->getPermissionAccessID();
if ($paID) {
$db = Loader::db();
$db->Replace('GatheringPermissionAssignments', array('gaID' => $this->permissionObject->getGatheringID(), 'paID' => $paID, 'pkID' => $this->getPermissionKeyID()), array('gaID', 'pkID'), true);
}
}
示例2: addValidate
public static function addValidate(PermissionKey $pk, $valid) {
$cl = CacheLocal::get();
if ($cl->enabled) {
$object = $pk->getPermissionObject();
if (is_object($object)) {
$identifier = 'pk:' . $pk->getPermissionKeyHandle() . ':' . $object->getPermissionObjectIdentifier();
} else {
$identifier = 'pk:' . $pk->getPermissionKeyHandle();
}
$cl->cache[$identifier] = $valid;
}
}
示例3: getPermissionAccessObject
public function getPermissionAccessObject()
{
$db = Loader::db();
if ($this->permissionObjectToCheck instanceof Block) {
$co = $this->permissionObjectToCheck->getBlockCollectionObject();
$arHandle = $this->permissionObjectToCheck->getAreaHandle();
$paID = $db->GetOne('select paID from BlockPermissionAssignments where cID = ? and cvID = ? and bID = ? and pkID = ? ' . $filterString, array($co->getCollectionID(), $co->getVersionID(), $this->permissionObject->getBlockID(), $this->pk->getPermissionKeyID()));
if ($paID) {
$pae = PermissionAccess::getByID($paID, $this->pk, false);
}
} else {
if ($this->permissionObjectToCheck instanceof Area && isset($this->inheritedAreaPermissions[$this->pk->getPermissionKeyHandle()])) {
$pk = PermissionKey::getByHandle($this->inheritedAreaPermissions[$this->pk->getPermissionKeyHandle()]);
$pk->setPermissionObject($this->permissionObjectToCheck);
$pae = $pk->getPermissionAccessObject();
} else {
if ($this->permissionObjectToCheck instanceof Page && isset($this->inheritedPagePermissions[$this->pk->getPermissionKeyHandle()])) {
$pk = PermissionKey::getByHandle($this->inheritedPagePermissions[$this->pk->getPermissionKeyHandle()]);
$pk->setPermissionObject($this->permissionObjectToCheck);
$pae = $pk->getPermissionAccessObject();
}
}
}
return $pae;
}
示例4: getPermissionAccessObject
public function getPermissionAccessObject()
{
$db = Loader::db();
if ($this->permissionObjectToCheck instanceof Area) {
$r = $db->GetOne('select paID from AreaPermissionAssignments where cID = ? and arHandle = ? and pkID = ? ' . $filterString, array($this->permissionObjectToCheck->getCollectionID(), $this->permissionObjectToCheck->getAreaHandle(), $this->pk->getPermissionKeyID()));
if ($r) {
return PermissionAccess::getByID($r, $this->pk, false);
}
} else {
if (isset($this->inheritedPermissions[$this->pk->getPermissionKeyHandle()])) {
// this is a page
$pk = PermissionKey::getByHandle($this->inheritedPermissions[$this->pk->getPermissionKeyHandle()]);
$pk->setPermissionObject($this->permissionObjectToCheck);
$pae = $pk->getPermissionAccessObject();
return $pae;
} else {
if (isset($this->blockTypeInheritedPermissions[$this->pk->getPermissionKeyHandle()])) {
$pk = PermissionKey::getByHandle($this->blockTypeInheritedPermissions[$this->pk->getPermissionKeyHandle()]);
$pae = $pk->getPermissionAccessObject();
return $pae;
}
}
}
return false;
}
示例5: __call
/**
* We take any permissions function run on the permissions class and send it into the category
* object
*/
public function __call($f, $a)
{
if (!is_object($this->response)) {
// handles task permissions
$permission = Loader::helper('text')->uncamelcase($f);
}
if (count($a) > 0) {
if (is_object($this->response)) {
$r = call_user_func_array(array($this->response, $f), $a);
} else {
$pk = PermissionKey::getByHandle($permission);
$r = call_user_func_array(array($pk, $f), $a);
}
} else {
if (is_object($this->response)) {
$r = $this->response->{$f}();
} else {
$pk = PermissionKey::getByHandle($permission);
if (is_object($pk)) {
$r = $pk->validate();
} else {
throw new Exception(t('Unable to get permission key for %s', $permission));
}
}
}
if (is_array($r) || is_object($r)) {
return $r;
} else {
if ($r) {
return 1;
} else {
return 0;
}
}
}
示例6: trigger
public function trigger()
{
$page = Page::getByID($this->cID);
$pk = PermissionKey::getByID($this->pkID);
$pk->setPermissionObject($page);
return parent::trigger($pk);
}
示例7: save
public function save()
{
if (Loader::helper('validation/token')->validate('save_permissions')) {
$fs = FileSet::getGlobal();
$tp = new TaskPermission();
if ($tp->canAccessTaskPermissions()) {
$permissions = PermissionKey::getList('file_set');
foreach ($permissions as $pk) {
$pk->setPermissionObject($fs);
$paID = $_POST['pkID'][$pk->getPermissionKeyID()];
$pt = $pk->getPermissionAssignmentObject();
$pt->clearPermissionAssignment();
if ($paID > 0) {
$pa = PermissionAccess::getByID($paID, $pk);
if (is_object($pa)) {
$pt->assignPermissionAccess($pa);
}
}
}
$this->redirect('/dashboard/system/permissions/files', 'updated');
}
} else {
$this->error->add(Loader::helper("validation/token")->getErrorMessage());
}
}
示例8: save
public function save()
{
if (Loader::helper('validation/token')->validate('save_permissions')) {
$tp = new TaskPermission();
if ($tp->canAccessTaskPermissions()) {
$permissions = PermissionKey::getList('sitemap');
$permissions = array_merge($permissions, PermissionKey::getList('marketplace_newsflow'));
$permissions = array_merge($permissions, PermissionKey::getList('admin'));
foreach ($permissions as $pk) {
$paID = $_POST['pkID'][$pk->getPermissionKeyID()];
$pt = $pk->getPermissionAssignmentObject();
$pt->clearPermissionAssignment();
if ($paID > 0) {
$pa = PermissionAccess::getByID($paID, $pk);
if (is_object($pa)) {
$pt->assignPermissionAccess($pa);
}
}
}
$this->redirect('/dashboard/system/permissions/tasks', 'updated');
}
} else {
$this->error->add(Loader::helper("validation/token")->getErrorMessage());
}
}
示例9: run
/** Executes the job.
* @return string Returns a string describing the job result in case of success.
* @throws Exception Throws an exception in case of errors.
*/
public function run() {
Cache::disableCache();
Cache::disableLocalCache();
try {
$db = Loader::db();
$instances = array(
'navigation' => Loader::helper('navigation'),
'dashboard' => Loader::helper('concrete/dashboard'),
'view_page' => PermissionKey::getByHandle('view_page')
);
$rsPages = $db->query('SELECT cID FROM Pages WHERE (cID > 1) ORDER BY cID');
$relName = ltrim(SITEMAPXML_FILE, '\\/');
$osName = rtrim(DIR_BASE, '\\/') . '/' . $relName;
$urlName = rtrim(BASE_URL . DIR_REL, '\\/') . '/' . $relName;
if(!file_exists($osName)) {
@touch($osName);
}
if(!is_writable($osName)) {
throw new Exception(t('The file %s is not writable', $osName));
}
if(!$hFile = fopen($osName, 'w')) {
throw new Exception(t('Cannot open file %s', $osName));
}
if(!@fprintf($hFile, '<?xml version="1.0" encoding="%s"?>' . self::EOL . '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">', APP_CHARSET)) {
throw new Exception(t('Error writing header of %s', $osName));
}
$addedPages = 0;
if(self::AddPage($hFile, 1, $instances)) {
$addedPages++;
}
while($rowPage = $rsPages->FetchRow()) {
if(self::AddPage($hFile, intval($rowPage['cID']), $instances)) {
$addedPages++;
}
}
$rsPages->Close();
unset($rsPages);
if(!@fwrite($hFile, self::EOL . '</urlset>')) {
throw new Exception(t('Error writing footer of %s', $osName));
}
@fflush($hFile);
@fclose($hFile);
unset($hFile);
return t('%1$s file saved (%2$d pages).', $urlName, $addedPages);
}
catch(Exception $x) {
if(isset($rsPages) && $rsPages) {
$rsPages->Close();
$rsPages = null;
}
if(isset($hFile) && $hFile) {
@fflush($hFile);
@ftruncate($hFile, 0);
@fclose($hFile);
$hFile = null;
}
throw $x;
}
}
示例10: triggerRequest
/**
* Triggers a workflow request, queries a permission key to see what workflows are attached to it
* and initiates them.
*
* @param \PermissionKey $pk
*
* @return optional WorkflowProgress
*/
protected function triggerRequest(\PermissionKey $pk)
{
if (!$this->wrID) {
$this->save();
}
if (!$pk->canPermissionKeyTriggerWorkflow()) {
throw new Exception(t('This permission key cannot start a workflow.'));
}
$pa = $pk->getPermissionAccessObject();
$workflows = array();
$workflowsStarted = 0;
if (is_object($pa)) {
$workflows = $pa->getWorkflows();
foreach ($workflows as $wf) {
if ($wf->validateTrigger($this)) {
$this->addWorkflowProgress($wf);
++$workflowsStarted;
}
}
}
if ($workflowsStarted == 0) {
$defaultWorkflow = new EmptyWorkflow();
$wp = $this->addWorkflowProgress($defaultWorkflow);
return $wp->getWorkflowProgressResponseObject();
}
}
示例11: parseManual
/**
* @see \C5TL\Parser\DynamicItem::parseManual()
*/
public function parseManual(\Gettext\Translations $translations, $concrete5version)
{
if (class_exists('\\PermissionKeyCategory', true) && method_exists('\\PermissionKeyCategory', 'getList')) {
foreach (\PermissionKeyCategory::getList() as $pkc) {
$pkcHandle = $pkc->getPermissionKeyCategoryHandle();
foreach (\PermissionKey::getList($pkcHandle) as $pk) {
$this->addTranslation($translations, $pk->getPermissionKeyName(), 'PermissionKeyName');
$this->addTranslation($translations, $pk->getPermissionKeyDescription(), 'PermissionKeyDescription');
}
}
}
}
示例12: run
public function run()
{
$this->x = new SimpleXMLElement("<concrete5-cif></concrete5-cif>");
$this->x->addAttribute('version', '1.0');
// First, attribute categories
AttributeKeyCategory::exportList($this->x);
// attribute types
AttributeType::exportList($this->x);
// then block types
BlockTypeList::exportList($this->x);
// now attribute keys (including user)
AttributeKey::exportList($this->x);
// now attribute keys (including user)
AttributeSet::exportList($this->x);
// now theme
PageTheme::exportList($this->x);
// now packages
PackageList::export($this->x);
// permission access entity types
PermissionAccessEntityType::exportList($this->x);
// now task permissions
PermissionKey::exportList($this->x);
// workflow types
WorkflowType::exportList($this->x);
// now jobs
Loader::model('job');
Job::exportList($this->x);
// now single pages
$singlepages = $this->x->addChild("singlepages");
$db = Loader::db();
$r = $db->Execute('select cID from Pages where cFilename is not null and cFilename <> "" and cID not in (select cID from Stacks) order by cID asc');
while ($row = $r->FetchRow()) {
$pc = Page::getByID($row['cID'], 'RECENT');
$pc->export($singlepages);
}
// now page types
CollectionType::exportList($this->x);
// now stacks/global areas
Loader::model('stack/list');
StackList::export($this->x);
// now content pages
$pages = $this->x->addChild("pages");
$db = Loader::db();
$r = $db->Execute('select Pages.cID from Pages left join ComposerDrafts on Pages.cID = ComposerDrafts.cID where ComposerDrafts.cID is null and cIsTemplate = 0 and cFilename is null or cFilename = "" order by cID asc');
while ($row = $r->FetchRow()) {
$pc = Page::getByID($row['cID'], 'RECENT');
$pc->export($pages);
}
Loader::model("system/captcha/library");
SystemCaptchaLibrary::exportList($this->x);
Config::exportList($this->x);
}
示例13: remove_tree
public function remove_tree()
{
if ($this->token->validate('remove_tree')) {
$tree = Tree::getByID(Loader::helper('security')->sanitizeInt($_REQUEST['treeID']));
$treeType = $tree->getTreeTypeObject();
if (is_object($treeType)) {
$treeTypeHandle = $treeType->getTreeTypeHandle();
}
if (is_object($tree) && $treeTypeHandle == 'topic') {
if (\PermissionKey::getByHandle('remove_topic_tree')->validate()) {
$tree->delete();
$this->redirect('/dashboard/system/attributes/topics', 'tree_deleted');
}
}
}
}
示例14: run
/** Executes the job.
* @return string Returns a string describing the job result in case of success.
* @throws Exception Throws an exception in case of errors.
*/
public function run()
{
Cache::disableCache();
Cache::disableLocalCache();
try {
$db = Loader::db();
$instances = array('navigation' => Loader::helper('navigation'), 'dashboard' => Loader::helper('concrete/dashboard'), 'view_page' => PermissionKey::getByHandle('view_page'), 'guestGroup' => Group::getByID(GUEST_GROUP_ID), 'now' => new DateTime('now'), 'ak_exclude_sitemapxml' => CollectionAttributeKey::getByHandle('exclude_sitemapxml'), 'ak_sitemap_changefreq' => CollectionAttributeKey::getByHandle('sitemap_changefreq'), 'ak_sitemap_priority' => CollectionAttributeKey::getByHandle('sitemap_priority'));
$instances['guestGroupAE'] = array(GroupPermissionAccessEntity::getOrCreate($instances['guestGroup']));
$xmlDoc = new SimpleXMLElement('<' . '?xml version="1.0" encoding="' . APP_CHARSET . '"?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" />');
$rs = Loader::db()->Query('SELECT cID FROM Pages');
while ($row = $rs->FetchRow()) {
self::addPage($xmlDoc, intval($row['cID']), $instances);
}
$rs->Close();
Events::fire('on_sitemap_xml_ready', $xmlDoc);
$dom = dom_import_simplexml($xmlDoc)->ownerDocument;
$dom->formatOutput = true;
$addedPages = count($xmlDoc->url);
$relName = ltrim(SITEMAPXML_FILE, '\\/');
$osName = rtrim(DIR_BASE, '\\/') . '/' . $relName;
$urlName = rtrim(BASE_URL . DIR_REL, '\\/') . '/' . $relName;
if (!file_exists($osName)) {
@touch($osName);
}
if (!is_writable($osName)) {
throw new Exception(t('The file %s is not writable', $osName));
}
if (!($hFile = @fopen($osName, 'w'))) {
throw new Exception(t('Cannot open file %s', $osName));
}
if (!@fwrite($hFile, $dom->saveXML())) {
throw new Exception(t('Error writing to file %s', $osName));
}
@fflush($hFile);
@fclose($hFile);
unset($hFile);
return t('%1$s file saved (%2$d pages).', sprintf('<a href="%s" target="_blank">%s</a>', $urlName, preg_replace('/^https?:\\/\\//i', '', $urlName)), $addedPages);
} catch (Exception $x) {
if (isset($hFile) && $hFile) {
@fflush($hFile);
@ftruncate($hFile, 0);
@fclose($hFile);
$hFile = null;
}
throw $x;
}
}
示例15: canGuestsViewThisBlock
public function canGuestsViewThisBlock()
{
$pk = PermissionKey::getByHandle('view_block');
$pk->setPermissionObject($this->getPermissionObject());
$gg = GroupPermissionAccessEntity::getOrCreate(Group::getByID(GUEST_GROUP_ID));
$accessEntities = array($gg);
$valid = false;
$list = $pk->getAccessListItems(PermissionKey::ACCESS_TYPE_ALL, $accessEntities);
foreach ($list as $l) {
if ($l->getAccessType() == PermissionKey::ACCESS_TYPE_INCLUDE) {
$valid = true;
}
if ($l->getAccessType() == PermissionKey::ACCESS_TYPE_EXCLUDE) {
$valid = false;
}
}
return $valid;
}