public function canDeletePage() { if ($this->object->isExternalLink()) { // then whether the person can delete/write to this page ACTUALLY dependent on whether the PARENT collection // is writable $cParentCollection = Page::getByID($this->object->getCollectionParentID(), "RECENT"); $cp2 = new Permissions($cParentCollection); return $cp2->canAddExternalLink(); } return $this->validate('delete_page'); }
function getNode($cItem, $level = 0, $autoOpenNodes = true) { if (!is_object($cItem)) { $cID = $cItem; $c = Page::getByID($cID, 'RECENT'); } else { $cID = $cItem->getCollectionID(); $c = $cItem; } $cp = new Permissions($c); $canEditPageProperties = $cp->canEditPageProperties(); $canEditPageSpeedSettings = $cp->canEditPageSpeedSettings(); $canEditPagePermissions = $cp->canEditPagePermissions(); $canEditPageDesign = $cp->canEditPageTheme() || $cp->canEditPageType(); $canViewPageVersions = $cp->canViewPageVersions(); $canDeletePage = $cp->canDeletePage(); $canAddSubpages = $cp->canAddSubpage(); $canAddExternalLinks = $cp->canAddExternalLink(); $nodeOpen = false; if (is_array($_SESSION['dsbSitemapNodes'])) { if (in_array($cID, $_SESSION['dsbSitemapNodes'])) { $nodeOpen = true; } } $status = ''; $cls = $c->getNumChildren() > 0 ? "folder" : "file"; $leaf = $c->getNumChildren() > 0 ? false : true; $numSubpages = $c->getNumChildren() > 0 ? $c->getNumChildren() : ''; $cvName = $c->getCollectionName() ? $c->getCollectionName() : '(No Title)'; $cvName = $c->isSystemPage() ? t($cvName) : $cvName; $selected = ConcreteDashboardSitemapHelper::isOneTimeActiveNode($cID) ? true : false; $ct = CollectionType::getByID($c->getCollectionTypeID()); $isInTrash = $c->isInTrash(); $canCompose = false; if (is_object($ct)) { if ($ct->isCollectionTypeIncludedInComposer()) { $h = Loader::helper('concrete/dashboard'); if ($cp->canEditPageProperties() && $h->canAccessComposer()) { $canCompose = true; } } } $isTrash = $c->getCollectionPath() == TRASH_PAGE_PATH; if ($isTrash || $isInTrash) { $pk = PermissionKey::getByHandle('empty_trash'); if (!$pk->validate()) { return false; } } $cIcon = $c->getCollectionIcon(); $cAlias = $c->isAlias(); $cPointerID = $c->getCollectionPointerID(); if ($cAlias) { if ($cPointerID > 0) { $cIcon = ASSETS_URL_IMAGES . '/icons/alias.png'; $cAlias = 'POINTER'; $cID = $c->getCollectionPointerOriginalID(); } else { $cIcon = ASSETS_URL_IMAGES . '/icons/alias_external.png'; $cAlias = 'LINK'; } } $node = array('cvName' => $cvName, 'cIcon' => $cIcon, 'cAlias' => $cAlias, 'isInTrash' => $isInTrash, 'isTrash' => $isTrash, 'numSubpages' => $numSubpages, 'status' => $status, 'canEditPageProperties' => $canEditPageProperties, 'canEditPageSpeedSettings' => $canEditPageSpeedSettings, 'canEditPagePermissions' => $canEditPagePermissions, 'canEditPageDesign' => $canEditPageDesign, 'canViewPageVersions' => $canViewPageVersions, 'canDeletePage' => $canDeletePage, 'canAddSubpages' => $canAddSubpages, 'canAddExternalLinks' => $canAddExternalLinks, 'canCompose' => $canCompose, 'id' => $cID, 'selected' => $selected); if ($cID == 1 || $nodeOpen && $autoOpenNodes) { // We open another level $node['subnodes'] = $this->getSubNodes($cID, $level, false, $autoOpenNodes); } return $node; }
$cpobj = new Permissions($cobj); if (!isset($striped) || $striped == 'ccm-list-record-alt') { $striped = ''; } else { if ($striped == '') { $striped = 'ccm-list-record-alt'; } } $canEditPageProperties = $cpobj->canEditPageProperties(); $canEditPageSpeedSettings = $cpobj->canEditPageSpeedSettings(); $canEditPagePermissions = $cpobj->canEditPagePermissions(); $canEditPageDesign = $cpobj->canEditPageTheme() || $cpobj->canEditPageType(); $canViewPageVersions = $cpobj->canViewPageVersions(); $canDeletePage = $cpobj->canDeletePage(); $canAddSubpages = $cpobj->canAddSubpage(); $canAddExternalLinks = $cpobj->canAddExternalLink(); $permissionArray = array('canEditPageProperties' => $canEditPageProperties, 'canEditPageSpeedSettings' => $canEditPageSpeedSettings, 'canEditPagePermissions' => $canEditPagePermissions, 'canEditPageDesign' => $canEditPageDesign, 'canViewPageVersions' => $canViewPageVersions, 'canDeletePage' => $canDeletePage, 'canAddSubpages' => $canAddSubpages, 'canAddExternalLinks' => $canAddExternalLinks); $canCompose = false; $ct = CollectionType::getByID($cobj->getCollectionTypeID()); if (is_object($ct)) { if ($ct->isCollectionTypeIncludedInComposer()) { if ($canEditPageProperties && $h->canAccessComposer()) { $canCompose = 1; } } } ?> <tr class="ccm-list-record <?php echo $striped; ?> "
$toolSection = "collection_add"; $divID = 'ccm-edit-collection-design'; $canViewPane = $cp->canAddSubpage(); if ($_REQUEST['ctID']) { $ct = CollectionType::getByID($_REQUEST['ctID']); if (!is_object($ct)) { $canViewPane = false; } else { $canViewPane = $cp->canAddSubCollection($ct); } } break; case 'add_external': $toolSection = "collection_add_external"; $divID = 'ccm-edit-collection-external'; $canViewPane = $cp->canAddExternalLink(); break; case 'delete_external': $toolSection = "collection_delete_external"; $divID = 'ccm-delete-collection-external'; $cparent = Page::getByID($c->getCollectionParentID(), "RECENT"); $cparentP = new Permissions($cparent); $canViewPane = $cparentP->canWrite(); break; case 'edit_external': $toolSection = "collection_edit_external"; $divID = 'ccm-edit-collection-external'; $canViewPane = $cp->canEditPageProperties(); break; } if (!isset($divID)) {
$pkr->setRequestedVersionID($v->getVersionID()); $pkr->setRequesterUserID($u->getUserID()); $u->unloadCollectionEdit($c); $response = $pkr->trigger(); $obj->rel = $_POST['rel']; $obj->name = $v->getVersionName(); } $obj->cID = $c->getCollectionID(); print Loader::helper('json')->encode($obj); exit; } } else { if ($_POST['update_external']) { $parent = Page::getByID($c->getCollectionParentID()); $parentP = new Permissions($parent); if ($parentP->canAddExternalLink()) { $ncID = $c->updateCollectionAliasExternal($_POST['cName'], $_POST['cExternalLink'], $_POST['cExternalLinkNewWindow']); header('Location: ' . URL_SITEMAP); exit; } } else { if ($_POST['update_permissions']) { // updating a collection if ($cp->canEditPagePermissions() && PERMISSIONS_MODEL == 'simple') { $obj = new stdClass(); $c->setPermissionsToManualOverride(); $pk = PermissionKey::getByHandle('view_page'); $pk->setPermissionObject($c); $pt = $pk->getPermissionAssignmentObject(); $pt->clearPermissionAssignment(); $pa = PermissionAccess::create($pk);