public static function getResponse($object) { $r = PermissionCache::getResponse($object); if (is_object($r)) { return $r; } if (method_exists($object, 'getPermissionObjectPermissionKeyCategoryHandle')) { $objectClass = Loader::helper('text')->camelcase($object->getPermissionObjectPermissionKeyCategoryHandle()); $handle = $object->getPermissionObjectPermissionKeyCategoryHandle(); } else { $objectClass = get_class($object); $handle = Loader::helper('text')->uncamelcase($objectClass); } $category = PermissionKeyCategory::getByHandle($handle); $c1 = $objectClass . 'PermissionResponse'; if (!is_object($category)) { if ($object instanceof Page) { $category = PermissionKeyCategory::getByHandle('page'); $c1 = 'PagePermissionResponse'; } else { if ($object instanceof Area) { $category = PermissionKeyCategory::getByHandle('area'); $c1 = 'AreaPermissionResponse'; } } } $pr = new $c1(); $pr->setPermissionObject($object); $pr->setPermissionCategoryObject($category); PermissionCache::addResponse($object, $pr); return $pr; }
public function install() { $pkg = parent::install(); $cat = PermissionKeyCategory::getByHandle('page'); $type = PermissionAccessEntityType::add('parent_page_owner', 'Parent Page Owner', $pkg); $cat->associateAccessEntityType($type); }
/** * @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'); } } } }
public function getPermissionKeyToolsURL($task = false) { if (!$task) { $task = 'save_permission'; } $uh = Loader::helper('concrete/urls'); $class = substr(get_class($this), 0, strrpos(get_class($this), 'PermissionAssignment')); $handle = Loader::helper('text')->uncamelcase($class); if ($handle) { $akc = PermissionKeyCategory::getByHandle($handle); } else { $akc = PermissionKeyCategory::getByID($this->pk->getPermissionKeyCategoryID()); } $url = $uh->getToolsURL('permissions/categories/' . $akc->getPermissionKeyCategoryHandle(), $akc->getPackageHandle()); $token = Loader::helper('validation/token')->getParameter($task); $url .= '?' . $token . '&task=' . $task . '&pkID=' . $this->pk->getPermissionKeyID(); return $url; }
public static function getResponse($object) { $r = PermissionCache::getResponse($object); if (is_object($r)) { return $r; } $category = PermissionKeyCategory::getByHandle(Loader::helper('text')->uncamelcase(get_class($object))); if (!is_object($category) && $object instanceof Page) { $category = PermissionKeyCategory::getByHandle('page'); } $txt = Loader::helper('text'); $c1 = get_class($object) . 'PermissionResponse'; if (!class_exists($c1)) { $c1 = 'PagePermissionResponse'; } $pr = new $c1(); $pr->setPermissionObject($object); $pr->setPermissionCategoryObject($category); PermissionCache::addResponse($object, $pr); return $pr; }
<?php defined('C5_EXECUTE') or die("Access Denied."); ?> <?php $cat = PermissionKeyCategory::getByHandle('basic_workflow'); ?> <table class="ccm-permission-grid"> <?php $permissions = PermissionKey::getList('basic_workflow'); foreach ($permissions as $pk) { $pk->setPermissionObject($workflow); ?> <tr> <td class="ccm-permission-grid-name" id="ccm-permission-grid-name-<?php echo $pk->getPermissionKeyID(); ?> "><strong><?php if ($enablePermissions) { ?> <a dialog-title="<?php echo $pk->getPermissionKeyDisplayName(); ?> " data-pkID="<?php echo $pk->getPermissionKeyID(); ?> " data-paID="<?php echo $pk->getPermissionAccessID(); ?>
<?php } ?> </div> <?php } ?> <?php echo Loader::element('permission/help'); ?> <?php $cat = PermissionKeyCategory::getByHandle($handle); ?> <form method="post" id="ccm-permission-list-form" action="<?php echo $cat->getToolsURL("save_permission_assignments"); ?> &treeNodeID=<?php echo $node->getTreeNodeID(); ?> "> <table class="ccm-permission-grid table table-striped"> <?php $permissions = PermissionKey::getList($handle); foreach ($permissions as $pk) { $pk->setPermissionObject($node);
protected function installPermissionsAndWorkflow() { $sx = simplexml_load_file(DIR_BASE_CORE . '/config/install/base/permissions.xml'); foreach ($sx->permissioncategories->category as $pkc) { $handle = (string) $pkc['handle']; $pkca = PermissionKeyCategory::getByHandle($handle); if (!is_object($pkca)) { $pkx = PermissionKeyCategory::add((string) $pkc['handle']); } } foreach ($sx->workflowprogresscategories->category as $pkc) { $handle = (string) $pkc['handle']; $pkca = WorkflowProgressCategory::getByHandle($handle); if (!is_object($pkca)) { $pkx = WorkflowProgressCategory::add((string) $pkc['handle']); } } foreach ($sx->workflowtypes->workflowtype as $wt) { $handle = (string) $wt['handle']; $name = (string) $wt['name']; $wtt = WorkflowType::getByHandle($handle); if (!is_object($wtt)) { $pkx = WorkflowType::add($handle, $name); } } if (isset($sx->permissionaccessentitytypes)) { foreach ($sx->permissionaccessentitytypes->permissionaccessentitytype as $pt) { $name = $pt['name']; if (!$name) { $name = Loader::helper('text')->unhandle($pt['handle']); } $handle = (string) $pt['handle']; $patt = PermissionAccessEntityType::getByHandle($handle); if (!is_object($patt)) { $type = PermissionAccessEntityType::add((string) $pt['handle'], $name); if (isset($pt->categories)) { foreach ($pt->categories->children() as $cat) { $catobj = PermissionKeyCategory::getByHandle((string) $cat['handle']); $catobj->associateAccessEntityType($type); } } } } } $txt = Loader::helper('text'); foreach ($sx->permissionkeys->permissionkey as $pk) { $pkc = PermissionKeyCategory::getByHandle((string) $pk['category']); $className = $txt->camelcase($pkc->getPermissionKeyCategoryHandle()); $c1 = $className . 'PermissionKey'; $handle = (string) $pk['handle']; $pka = PermissionKey::getByHandle($handle); if (!is_object($pka)) { $pkx = call_user_func(array($c1, 'import'), $pk); } } }
<?php defined('C5_EXECUTE') or die("Access Denied."); ?> <?php $cat = PermissionKeyCategory::getByHandle('file_set'); ?> <table class="ccm-permission-grid table table-striped"> <?php $permissions = PermissionKey::getList('file_set'); foreach ($permissions as $pk) { $pk->setPermissionObject($fs); ?> <tr> <td class="ccm-permission-grid-name" id="ccm-permission-grid-name-<?php echo $pk->getPermissionKeyID(); ?> "><strong><a dialog-title="<?php echo $pk->getPermissionKeyDisplayName(); ?> " data-pkID="<?php echo $pk->getPermissionKeyID(); ?> " data-paID="<?php echo $pk->getPermissionAccessID(); ?> " onclick="ccm_permissionLaunchDialog(this)" href="javascript:void(0)"><?php echo $pk->getPermissionKeyDisplayName(); ?>
?> </a> </div> <?php } } } ?> <?php echo Loader::element('permission/help'); ?> <?php $cat = PermissionKeyCategory::getByHandle('area'); ?> <form method="post" id="ccm-permission-list-form" action="<?php echo $cat->getToolsURL("save_permission_assignments"); ?> &cID=<?php echo $c->getCollectionID(); ?> &arHandle=<?php echo urlencode($a->getAreaHandle()); ?> "> <table class="ccm-permission-grid table table-striped"> <?php
echo t('Revert to Area Permissions'); ?> </a> </div> <?php } ?> <?php echo Loader::element('permission/help'); ?> <?php $cat = PermissionKeyCategory::getByHandle('block'); ?> <form method="post" id="ccm-permission-list-form" action="<?php echo $cat->getToolsURL("save_permission_assignments"); ?> &cID=<?php echo $c->getCollectionID(); ?> &arHandle=<?php echo urlencode($b->getAreaHandle()); ?> &cvID=<?php echo $c->getVersionID(); ?> &bID=<?php echo $b->getBlockID();
/** * Adds an permission key. */ public function add($pkCategoryHandle, $pkHandle, $pkName, $pkDescription, $pkCanTriggerWorkflow, $pkHasCustomClass, $pkg = false) { $vn = Loader::helper('validation/numbers'); $txt = Loader::helper('text'); $pkgID = 0; $db = Loader::db(); if (is_object($pkg)) { $pkgID = $pkg->getPackageID(); } if ($pkCanTriggerWorkflow) { $pkCanTriggerWorkflow = 1; } else { $pkCanTriggerWorkflow = 0; } if ($pkHasCustomClass) { $pkHasCustomClass = 1; } else { $$pkHasCustomClass = 0; } $pkCategoryID = $db->GetOne("select pkCategoryID from PermissionKeyCategories where pkCategoryHandle = ?", $pkCategoryHandle); $a = array($pkHandle, $pkName, $pkDescription, $pkCategoryID, $pkCanTriggerWorkflow, $pkHasCustomClass, $pkgID); $r = $db->query("insert into PermissionKeys (pkHandle, pkName, pkDescription, pkCategoryID, pkCanTriggerWorkflow, pkHasCustomClass, pkgID) values (?, ?, ?, ?, ?, ?, ?)", $a); $category = PermissionKeyCategory::getByID($pkCategoryID); if ($r) { $pkID = $db->Insert_ID(); $ak = self::load($pkID); return $ak; } }
/** * Returns an array of package items (e.g. blocks, themes) */ public function getPackageItems() { $items = array(); Loader::model('single_page'); Loader::library('mail/importer'); Loader::model('job'); Loader::model('collection_types'); Loader::model('system/captcha/library'); Loader::model('system/antispam/library'); $items['attribute_categories'] = AttributeKeyCategory::getListByPackage($this); $items['permission_categories'] = PermissionKeyCategory::getListByPackage($this); $items['permission_access_entity_types'] = PermissionAccessEntityType::getListByPackage($this); $items['attribute_keys'] = AttributeKey::getListByPackage($this); $items['attribute_sets'] = AttributeSet::getListByPackage($this); $items['group_sets'] = GroupSet::getListByPackage($this); $items['page_types'] = CollectionType::getListByPackage($this); $items['mail_importers'] = MailImporter::getListByPackage($this); $items['configuration_values'] = Config::getListByPackage($this); $items['block_types'] = BlockTypeList::getByPackage($this); $items['page_themes'] = PageTheme::getListByPackage($this); $items['permissions'] = PermissionKey::getListByPackage($this); $items['single_pages'] = SinglePage::getListByPackage($this); $items['attribute_types'] = AttributeType::getListByPackage($this); $items['captcha_libraries'] = SystemCaptchaLibrary::getListByPackage($this); $items['antispam_libraries'] = SystemAntispamLibrary::getListByPackage($this); $items['jobs'] = Job::getListByPackage($this); $items['workflow_types'] = WorkflowType::getListByPackage($this); ksort($items); return $items; }
</div> <?php if (!is_object($pae)) { ?> <div class="btn-group"> <a class="btn btn-default dropdown-toggle" data-toggle="dropdown" href="#"> <i class="icon-plus-sign"></i> <?php echo t('Select'); ?> <span class="caret"></span> </a> <ul class="dropdown-menu"> <?php $category = PermissionKeyCategory::getByHandle($_REQUEST['pkCategoryHandle']); $entitytypes = PermissionAccessEntityType::getList($category); foreach ($entitytypes as $type) { ?> <li><?php echo $type->getAccessEntityTypeLinkHTML(); ?> </li> <?php } ?> </ul> </div> <br/><br/> <?php
/** * Note, this queries both the pkgID found on the PermissionKeys table AND any permission keys of a special type * installed by that package, and any in categories by that package. */ public static function getListByPackage($pkg) { $db = Loader::db(); $kina[] = '-1'; $kinb = $db->GetCol('select pkCategoryID from PermissionKeyCategories where pkgID = ?', $pkg->getPackageID()); if (is_array($kinb)) { $kina = array_merge($kina, $kinb); } $kinstr = implode(',', $kina); $r = $db->Execute('select pkID, pkCategoryID from PermissionKeys where (pkgID = ? or pkCategoryID in (' . $kinstr . ')) order by pkID asc', array($pkg->getPackageID())); while ($row = $r->FetchRow()) { $pkc = PermissionKeyCategory::getByID($row['pkCategoryID']); $pk = $pkc->getPermissionKeyByID($row['pkID']); $list[] = $pk; } $r->Close(); return $list; }
<?php defined('C5_EXECUTE') or die("Access Denied."); ?> <?php $cat = PermissionKeyCategory::getByHandle('conversation'); ?> <table class="ccm-permission-grid table table-striped"> <?php $cnvID = 0; if (is_object($conversation)) { $cnvID = $conversation->getConversationID(); } $permissions = PermissionKey::getList('conversation'); foreach ($permissions as $pk) { $pk->setPermissionObject($conversation); ?> <tr> <td class="ccm-permission-grid-name" id="ccm-permission-grid-name-<?php echo $pk->getPermissionKeyID(); ?> "><strong><a dialog-title="<?php echo $pk->getPermissionKeyDisplayName(); ?> " data-pkID="<?php echo $pk->getPermissionKeyID(); ?> " data-paID="<?php echo $pk->getPermissionAccessID();
public static function add($pkCategoryHandle, $pkg = false) { $db = Loader::db(); if (is_object($pkg)) { $pkgID = $pkg->getPackageID(); } $db->Execute('insert into PermissionKeyCategories (pkCategoryHandle, pkgID) values (?, ?)', array($pkCategoryHandle, $pkgID)); $id = $db->Insert_ID(); Cache::delete('permission_key_categories', false); return PermissionKeyCategory::getByID($id); }
protected function importPermissions(SimpleXMLElement $sx) { if (isset($sx->permissionkeys)) { foreach($sx->permissionkeys->permissionkey as $pk) { $pkc = PermissionKeyCategory::getByHandle((string) $pk['category']); $pkg = ContentImporter::getPackageObject($pk['package']); $txt = Loader::helper('text'); $className = $txt->camelcase($pkc->getPermissionKeyCategoryHandle()); $c1 = $className . 'PermissionKey'; $pkx = call_user_func(array($c1, 'import'), $pk); if (isset($pk->access)) { foreach($pk->access->children() as $ch) { if ($ch->getName() == 'group') { $g = Group::getByName($ch['name']); if (!is_object($g)) { $g = Group::add($g['name'], $g['description']); } $pae = GroupPermissionAccessEntity::getOrCreate($g); $pa = PermissionAccess::create($pkx); $pa->addListItem($pae); $pt = $pkx->getPermissionAssignmentObject(); $pt->assignPermissionAccess($pa); } } } } } }
</div> </form> <br/> <?php if ($permissionsInherit == 'OVERRIDE') { ?> <?php echo Loader::element('permission/help'); ?> <?php $cat = PermissionKeyCategory::getByHandle('page'); ?> <form method="post" id="ccm-permission-list-form" action="<?php echo $cat->getToolsURL("save_permission_assignments"); echo $cIDStr; ?> "> <table class="ccm-permission-grid"> <?php $permissions = PermissionKey::getList('page'); foreach ($permissions as $pk) { $pk->setPermissionObject($c); ?> <tr> <td class="ccm-permission-grid-name" id="ccm-permission-grid-name-<?php
</p> <br/> <a href="javascript:void(0)" class="btn small" onclick="ccm_revertToGlobalFilePermissions()"><?php echo t('Revert to File Set and Global Permissions'); ?> </a> </div> <? } ?> <?php echo Loader::element('permission/help'); ?> <? $cat = PermissionKeyCategory::getByHandle('file');?> <form method="post" id="ccm-permission-list-form" action="<?php echo $cat->getToolsURL("save_permission_assignments"); ?> &fID=<?php echo $f->getFileID(); ?> "> <table class="ccm-permission-grid"> <? $permissions = PermissionKey::getList('file'); foreach($permissions as $pk) { $pk->setPermissionObject($f); ?>