public function checkSSL() { if ($this->requireSSL == 1) { global $c; $cp = new Permissions($c); if (isset($cp)) { if (!$cp->canWrite() && !$cp->canAddSubContent() && !$cp->canAdminPage() && !$cp->canApproveCollection()) { if ($_SERVER['HTTPS'] != "on") { $redirect = "https://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; header("Location:{$redirect}"); } } } } }
} else { $error = false; } } if (!$error) { if ($_REQUEST['ctask']) { if ($valt->validate()) { switch($_REQUEST['ctask']) { case "ALIAS": $ncID = $oc->addCollectionAlias($dc); $successMessage = '"' . $oc->getCollectionName() . '" '.t('was successfully aliased beneath').' "' . $dc->getCollectionName() . '"'; $newCID = $ncID; break; case "COPY": if ($_REQUEST['copyAll'] && $dcp->canAdminPage()) { $nc2 = $oc->duplicateAll($dc); // new collection is passed back if (is_object($nc2)) { $successMessage = '"' . $oc->getCollectionName() . '" '.t('and all its children were successfully copied beneath').' "' . $dc->getCollectionName() . '"'; } } else { $nc2 = $oc->duplicate($dc); if (is_object($nc2)) { $successMessage = '"' . $oc->getCollectionName() . '" '.t('was successfully copied beneath').' "' . $dc->getCollectionName() . '"'; } } if (!is_object($nc2)) { $error = t("An error occurred while attempting the copy operation."); } else { $newCID = $nc2->getCollectionID(); }
<? defined('C5_EXECUTE') or die("Access Denied."); Loader::model('collection_types'); $stringHelper=Loader::helper('text'); $tArray = PageTheme::getGlobalList(); $tArray2 = PageTheme::getLocalList(); $tArray = array_merge($tArray, $tArray2); $ctArray = CollectionType::getList($c->getAllowedSubCollections()); $cp = new Permissions($c); if ($c->getCollectionID() > 1) { $parent = Page::getByID($c->getCollectionParentID()); $parentCP = new Permissions($parent); } if (!$cp->canAdminPage()) { die(t('Access Denied')); } $cnt = 0; for ($i = 0; $i < count($ctArray); $i++) { $ct = $ctArray[$i]; if ($c->getCollectionID() == 1 || $parentCP->canAddSubCollection($ct)) { $cnt++; } } $plID = $c->getCollectionThemeID(); $ctID = $c->getCollectionTypeID(); if ($plID == 0) { $pl = PageTheme::getSiteTheme();
$pendingAction = $c->getPendingAction(); if ($pendingAction == 'MOVE') { $statusMessage .= $statusMessage ? " | " : ""; $statusMessage .= t("This page is being moved."); if ($cp->canApproveCollection() && (!$c->isCheckedOut() || $c->isCheckedOut() && $c->isEditMode())) { $statusMessage .= "<br/><a href='" . DIR_REL . "/" . DISPATCHER_FILENAME . "?cID=" . $c->getCollectionID() . "&ctask=approve_pending_action'>" . t('Approve Move') . "</a> | <a href='" . DIR_REL . "/" . DISPATCHER_FILENAME . "?cID=" . $c->getCollectionID() . "&ctask=clear_pending_action" . $token . "'>" . t('Cancel') . "</a>"; } } else { if ($pendingAction == 'DELETE') { $statusMessage .= $statusMessage ? "<br/>" : ""; $statusMessage .= t("This page is marked for removal."); $children = $c->getNumChildren(); if ($children > 0) { $pages = $children + 1; $statusMessage .= " " . t('This will remove %s pages.', $pages); if ($cp->canAdminPage()) { $statusMessage .= " <a href='" . DIR_REL . "/" . DISPATCHER_FILENAME . "?cID=" . $c->getCollectionID() . "&ctask=approve_pending_action" . $token . "'>" . t('Approve Delete') . "</a> | <a href='" . DIR_REL . "/" . DISPATCHER_FILENAME . "?cID=" . $c->getCollectionID() . "&ctask=clear_pending_action" . $token . "'>" . t('Cancel') . "</a>"; } else { $statusMessage .= " " . t('Only administrators can approve a multi-page delete operation.'); } } else { if ($children == 0 && $cp->canApproveCollection() && (!$c->isCheckedOut() || $c->isCheckedOut() && $c->isEditMode())) { $statusMessage .= " <a href='" . DIR_REL . "/" . DISPATCHER_FILENAME . "?cID=" . $c->getCollectionID() . "&ctask=approve_pending_action" . $token . "'>" . t('Approve Delete') . "</a> | <a href='" . DIR_REL . "/" . DISPATCHER_FILENAME . "?cID=" . $c->getCollectionID() . "&ctask=clear_pending_action" . $token . "'>" . t('Cancel') . "</a>"; } } } } } if ($c->isMasterCollection()) { $statusMessage .= $statusMessage ? "<br/>" : ""; $statusMessage .= t('Page Defaults for') . ' "' . $c->getCollectionTypeName() . '" ' . t("page type");
$c = Page::getByID($_GET['cID'], 'RECENT'); $cp = new Permissions($c); $canViewPane = false; $additionalArgs = array(); switch ($_GET['ctask']) { case 'edit_metadata': $toolSection = "collection_metadata"; $canViewPane = $cp->canWrite(); break; case 'edit_permissions': if (PERMISSIONS_MODEL == 'simple') { $toolSection = 'collection_permissions_simple'; } else { $toolSection = "collection_permissions"; } $canViewPane = $cp->canAdminPage(); break; case 'edit_permissions_composer': $toolSection = "collection_permissions"; $canViewPane = $cp->canAdminPage(); $additionalArgs['isComposer'] = true; break; case 'mcd': $toolSection = "collection_mcd"; $canViewPane = $cp->canWrite(); $divID = "ccm-collection-mcd"; break; case 'set_theme': $toolSection = "collection_theme"; $divID = 'ccm-edit-collection-design'; $canViewPane = $cp->canWrite();
/** * render takes one argument - the item being rendered - and it can either be a path or a page object * @access public * @param string $view * @param array $args * @return void */ public function render($view, $args = null) { try { if (is_array($args)) { extract($args); } // strip off a slash if there is one at the end if (is_string($view)) { if (substr($view, strlen($view) - 1) == '/') { $view = substr($view, 0, strlen($view) - 1); } } $wrapTemplateInTheme = false; Events::fire('on_start', $this); // Extract controller information from the view, and put it in the current context if (!isset($this->controller)) { $this->controller = Loader::controller($view); $this->controller->setupAndRun(); } if ($this->controller->getRenderOverride() != '') { $view = $this->controller->getRenderOverride(); } // Determine which inner item to load, load it, and stick it in $innerContent $content = false; ob_start(); if ($view instanceof Page) { $viewPath = $view->getCollectionPath(); $this->viewPath = $viewPath; $cFilename = $view->getCollectionFilename(); $ctHandle = $view->getCollectionTypeHandle(); $editMode = $view->isEditMode(); $c = $view; $this->c = $c; // $view is a page. It can either be a SinglePage or just a Page, but we're not sure at this point, unfortunately if ($view->getCollectionTypeID() == 0 && $cFilename) { $wrapTemplateInTheme = true; if (file_exists(DIR_FILES_CONTENT. "{$cFilename}")) { $content = DIR_FILES_CONTENT. "{$cFilename}"; } else if ($view->getPackageID() > 0) { $file1 = DIR_PACKAGES . '/' . $view->getPackageHandle() . '/'. DIRNAME_PAGES . $cFilename; $file2 = DIR_PACKAGES_CORE . '/' . $view->getPackageHandle() . '/'. DIRNAME_PAGES . $cFilename; if (file_exists($file1)) { $content = $file1; } else if (file_exists($file2)) { $content = $file2; } } else if (file_exists(DIR_FILES_CONTENT_REQUIRED . "{$cFilename}")) { $content = DIR_FILES_CONTENT_REQUIRED. "{$cFilename}"; } $themeFilename = $c->getCollectionHandle() . '.php'; } else { if (file_exists(DIR_BASE . '/' . DIRNAME_PAGE_TYPES . '/' . $ctHandle . '.php')) { $content = DIR_BASE . '/' . DIRNAME_PAGE_TYPES . '/' . $ctHandle . '.php'; $wrapTemplateInTheme = true; } else if (file_exists(DIR_BASE_CORE. '/' . DIRNAME_PAGE_TYPES . '/' . $ctHandle . '.php')) { $content = DIR_BASE_CORE . '/' . DIRNAME_PAGE_TYPES . '/' . $ctHandle . '.php'; $wrapTemplateInTheme = true; } else if ($view->getPackageID() > 0) { $file1 = DIR_PACKAGES . '/' . $view->getPackageHandle() . '/'. DIRNAME_PAGE_TYPES . '/' . $ctHandle . '.php'; $file2 = DIR_PACKAGES_CORE . '/' . $view->getPackageHandle() . '/'. DIRNAME_PAGE_TYPES . '/' . $ctHandle . '.php'; if (file_exists($file1)) { $content = $file1; $wrapTemplateInTheme = true; } else if (file_exists($file2)) { $content = $file2; $wrapTemplateInTheme = true; } } $themeFilename = $ctHandle . '.php'; } } else if (is_string($view)) { // if we're passing a view but our render override is not null, that means that we're passing // a new view from within a controller. If that's the case, then we DON'T override the viewPath, we want to keep it // In order to enable editable 404 pages, other editable pages that we render without actually visiting if (defined('DB_DATABASE') && $view == '/page_not_found') { $pp = Page::getByPath($view); if (!$pp->isError()) { $this->c = $pp; } } $viewPath = $view; if ($this->controller->getRenderOverride() != '' && $this->getCollectionObject() != null) { // we are INSIDE a collection renderring a view. Which means we want to keep the viewPath that of the collection $this->viewPath = $this->getCollectionObject()->getCollectionPath(); } // we're just passing something like "/login" or whatever. This will typically just be // internal Concrete stuff, but we also prepare for potentially having something in DIR_FILES_CONTENT (ie: the webroot) if (file_exists(DIR_FILES_CONTENT . "/{$view}/" . FILENAME_COLLECTION_VIEW)) { $content = DIR_FILES_CONTENT . "/{$view}/" . FILENAME_COLLECTION_VIEW; } else if (file_exists(DIR_FILES_CONTENT . "/{$view}.php")) { $content = DIR_FILES_CONTENT . "/{$view}.php"; } else if (file_exists(DIR_FILES_CONTENT_REQUIRED . "/{$view}/" . FILENAME_COLLECTION_VIEW)) { $content = DIR_FILES_CONTENT_REQUIRED . "/{$view}/" . FILENAME_COLLECTION_VIEW; } else if (file_exists(DIR_FILES_CONTENT_REQUIRED . "/{$view}.php")) { $content = DIR_FILES_CONTENT_REQUIRED . "/{$view}.php"; } else if ($this->getCollectionObject() != null && $this->getCollectionObject()->isGeneratedCollection() && $this->getCollectionObject()->getPackageID() > 0) { //This is a single_page associated with a package, so check the package views as well $pagePkgPath = Package::getByID($this->getCollectionObject()->getPackageID())->getPackagePath(); if (file_exists($pagePkgPath . "/single_pages/{$view}/" . FILENAME_COLLECTION_VIEW)) { $content = $pagePkgPath . "/single_pages/{$view}/" . FILENAME_COLLECTION_VIEW; } else if (file_exists($pagePkgPath . "/single_pages/{$view}.php")) { $content = $pagePkgPath . "/single_pages/{$view}.php"; } } $wrapTemplateInTheme = true; $themeFilename = $view . '.php'; } if (is_object($this->c)) { $c = $this->c; if (defined('DB_DATABASE') && $view == '/page_not_found') { $view = $c; $req = Request::get(); $req->setCurrentPage($c); } } // Determine which outer item/theme to load // obtain theme information for this collection if (isset($this->themeOverride)) { $theme = $this->themeOverride; } else if ($this->controller->theme != false) { $theme = $this->controller->theme; } else if (($tmpTheme = $this->getThemeFromPath($viewPath)) != false) { $theme = $tmpTheme; } else if (is_object($this->c) && ($tmpTheme = $this->c->getCollectionThemeObject()) != false) { $theme = $tmpTheme; } else { $theme = FILENAME_COLLECTION_DEFAULT_THEME; } $this->setThemeForView($theme, $themeFilename, $wrapTemplateInTheme); // Now, if we're on an actual page, we retrieve all the blocks on the page // and store their view states in the local cache (for the page). That way // we can add header items and have them show up in the header BEFORE // the block itself is actually loaded if ($view instanceof Page) { $_pageBlocks = $view->getBlocks(); $_pageBlocksGlobal = $view->getGlobalBlocks(); $_pageBlocks = array_merge($_pageBlocks, $_pageBlocksGlobal); if ($view->supportsPageCache($_pageBlocks, $this->controller)) { $pageContent = $view->getFromPageCache(); if ($pageContent != false) { Events::fire('on_before_render', $this); if (defined('APP_CHARSET')) { header("Content-Type: text/html; charset=" . APP_CHARSET); } print($pageContent); Events::fire('on_render_complete', $this); if (ob_get_level() == OB_INITIAL_LEVEL) { require(DIR_BASE_CORE . '/startup/shutdown.php'); exit; } return; } } foreach($_pageBlocks as $b1) { $btc = $b1->getInstance(); // now we inject any custom template CSS and JavaScript into the header if('Controller' != get_class($btc)){ $btc->outputAutoHeaderItems(); } $btc->runTask('on_page_view', array($view)); } // do we have any custom menu plugins? $cp = new Permissions($view); if ($cp->canWrite() || $cp->canAddSubContent() || $cp->canAdminPage() || $cp->canApproveCollection()) { $ih = Loader::helper('concrete/interface/menu'); $_interfaceItems = $ih->getPageHeaderMenuItems(); foreach($_interfaceItems as $_im) { $_controller = $_im->getController(); $_controller->outputAutoHeaderItems(); } unset($_interfaceItems); unset($_im); unset($_controller); } unset($_interfaceItems); unset($_im); unset($_controller); // now, we output all the custom style records for the design tab in blocks/areas on the page $c = $this->getCollectionObject(); $view->outputCustomStyleHeaderItems(); } // finally, we include the theme (which was set by setTheme and will automatically include innerContent) // disconnect from our db and exit $this->controller->on_before_render(); extract($this->controller->getSets()); extract($this->controller->getHelperObjects()); if ($content != false) { include($content); } $innerContent = ob_get_contents(); if (ob_get_level() > OB_INITIAL_LEVEL) { ob_end_clean(); } Events::fire('on_before_render', $this); if (defined('APP_CHARSET')) { header("Content-Type: text/html; charset=" . APP_CHARSET); } if (file_exists($this->theme)) { ob_start(); include($this->theme); $pageContent = ob_get_contents(); ob_end_clean(); $ret = Events::fire('on_page_output', $pageContent); if($ret != '') { print $ret; } else { print $pageContent; } if ($view instanceof Page) { if ($view->supportsPageCache($_pageBlocks, $this->controller)) { $view->addToPageCache($pageContent); } } } else { throw new Exception(t('File %s not found. All themes need default.php and view.php files in them. Consult concrete5 documentation on how to create these files.', $this->theme)); } Events::fire('on_render_complete', $this); if (ob_get_level() == OB_INITIAL_LEVEL) { require(DIR_BASE_CORE . '/startup/shutdown.php'); exit; } } catch(ADODB_Exception $e) { // if it's a database exception we go here. if (Config::get('SITE_DEBUG_LEVEL') == DEBUG_DISPLAY_ERRORS) { $this->renderError(t('An unexpected error occurred.'), $e->getMessage(), $e); } else { $this->renderError(t('An unexpected error occurred.'), t('A database error occurred while processing this request.'), $e); } // log if setup to do so if (ENABLE_LOG_ERRORS) { $l = new Log(LOG_TYPE_EXCEPTIONS, true, true); $l->write(t('Exception Occurred: ') . $e->getMessage()); $l->write($e->getTraceAsString()); $l->close(); } } catch (Exception $e) { $this->renderError(t('An unexpected error occurred.'), $e->getMessage(), $e); // log if setup to do so if (ENABLE_LOG_ERRORS) { $l = new Log(LOG_TYPE_EXCEPTIONS, true, true); $l->write(t('Exception Occurred: ') . $e->getMessage()); $l->write($e->getTraceAsString()); $l->close(); } } }
function canAdminBlock() { $oObj = $this->getOriginalObject(); $c = is_a($oObj, 'Area') ? $oObj->getAreaCollectionObject() : $oObj->getBlockCollectionObject(); $c->loadVersionObject('RECENT'); $cp = new Permissions($c); return $cp->canAdminPage(); }
public function copy_tree() { set_time_limit(0); if (Loader::helper('validation/token')->validate('copy_tree')) { if ($this->post('copyTreeFrom') && $this->post('copyTreeTo') && $this->post('copyTreeFrom') != $this->post('copyTreeTo')) { $dc = Page::getByID($this->post('copyTreeTo')); $oc = Page::getByID($this->post('copyTreeFrom')); $dcp = new Permissions($dc); $ocp = new Permissions($oc); if (!$dcp->canAdminPage()) { $this->error->add(t('You must have admin privileges on the destination page to perform this action.')); } if (!$ocp->canRead()) { $this->error->add(t('You cannot read the original page.')); } if (!$this->error->has()) { // duplicate all into the new node $ms = MultilingualSection::getByID($this->post('copyTreeTo')); $this->populateCopyArray($oc); $aliases = array(); $created = array(); foreach ($this->pagesToCopy as $cc) { $trcID = $ms->getTranslatedPageID($cc); if (!$trcID) { // this page doesn't exist in the new tree. So we need to duplicate it over there // find where this page is going $ccp = Page::getByID($cc->getCollectionParentID(), 'RECENT'); $trpcID = $ms->getTranslatedPageID($ccp); $dest = Page::getByID($trpcID); if ($cc->isAlias()) { $aliases[] = array($cc->getCollectionID(), $dest->getCollectionID()); } else { $newPage = $cc->duplicate($dest); $ceated[$cc->getCollectionID()] = $newPage->getCollectionID(); } } else { if ($cc->isAlias()) { $aliases[] = array($cc->getCollectionID(), false); } else { $created[$cc->getCollectionID()] = $trcID; } } } foreach ($aliases as $data) { list($cID, $dest) = $data; $cc = Page::getByID($cID); if ($dest === false) { $ccp = Page::getByID($cc->getCollectionParentID(), 'RECENT'); $dest = $ms->getTranslatedPageID($ccp); } if (isset($created[$cID])) { $dest = $created[$cID]; } $aliasID = $cc->addCollectionAlias(Page::getByID($dest)); } $this->redirect('/dashboard/multilingual/setup', 'tree_copied'); } } else { $this->error->add(t('You must choose two separate, valid language sections.')); } } else { $this->error->add(Loader::helper('validation/token')->getErrorMessage()); } $this->view(); }
<?php defined('C5_EXECUTE') or die("Access Denied."); ?> </div> <?php Loader::element('footer_required'); ?> <!-- Show hide the concrete5 toolbar --> <?php $cp = new Permissions($c); if ($cp->canWrite() || $cp->canAddSubContent() || $cp->canAdminPage()) { ?> <script> var isBarVisible = false; $(document).ready(function() { $("#ccm-page-controls-wrapper").stop(true, true).hide(); $("body").append("<div style='padding:5px;text-align:center;background-color:#335B8A; position:fixed;top:82px;right:50px;color:white; border-bottom-left-radius: 4px; border-top-left-radius: 4px; border-bottom-right-radius: 4px; border-top-right-radius: 4px; z-index: 900; '><a style='padding:0;margin:0;line-height:100%;' href='javascript:;' id='c5showhidebarr'><span class='fa fa-pencil' style='color:white;' id='c5showhidebarrtxt'>Show edit bar</span></a>"); $("#c5showhidebarr").click(function() { if(isBarVisible){ $("#ccm-page-controls-wrapper").stop(true, true).hide(200); $("#c5showhidebarrtxt").text("Show edit bar"); } else{ $("#ccm-page-controls-wrapper").stop(true, true).show(200); $("#c5showhidebarrtxt").text("Hide edit bar"); } isBarVisible = !isBarVisible;
<div> <strong class="important"><?php echo t('DELETION')?></strong> <?php echo t('(Marked by: <strong>%s</strong> on <strong>%s</strong>)',$ud->getUserName(), date(DATE_APP_PAGE_VERSIONS, strtotime($c->getPendingActionDateTime())))?> </div> <?php if ($cp->canApproveCollection()) { ?> <?php if ($children == 0) { ?> <div class="ccm-buttons"> <a href="<?php echo REL_DIR_FILES_TOOLS_REQUIRED?>/versions.php?cID=<?php echo $cID?>&ctask=approve_pending_action<?php echo $token?>" class="ccm-button-right accept" onclick="return ccm_runAction(this)"><span><?php echo t('Approve')?></span></a> <a href="<?php echo REL_DIR_FILES_TOOLS_REQUIRED?>/versions.php?cID=<?php echo $cID?>&ctask=clear_pending_action<?php echo $token?>" class="ccm-button-left cancel" onclick="return ccm_runAction(this)"><span><em class="ccm-button-close"><?php echo t('Deny')?></em></span></a> </div> <?php } else if ($children > 0) { ?> <?php echo t('This will remove %s pages.',$pages)?> <?php if (!$cp->canAdminPage()) { ?> <?php echo t('Only the super user may remove multiple pages.')?><br> <div class="ccm-buttons"> <a href="<?php echo REL_DIR_FILES_TOOLS_REQUIRED?>/versions.php?cID=<?php echo $cID?>&ctask=clear_pending_action<?php echo $token?>" class="ccm-button-left cancel" onclick="return ccm_runAction(this)"><span><em class="ccm-button-close"><?php echo t('Deny')?></em></span></a> </div> <?php } else { ?> <div class="ccm-buttons"> <a href="<?php echo REL_DIR_FILES_TOOLS_REQUIRED?>/versions.php?cID=<?php echo $cID?>&ctask=approve_pending_action<?php echo $token?>" class="ccm-button-right accept" onclick="return ccm_runAction(this)"><span><?php echo t('Approve')?></span></a> <a href="<?php echo REL_DIR_FILES_TOOLS_REQUIRED?>/versions.php?cID=<?php echo $cID?>&ctask=clear_pending_action<?php echo $token?>" class="ccm-button-left cancel" onclick="return ccm_runAction(this)"><span><em class="ccm-button-close"><?php echo t('Deny')?></em></span></a> </div> <?php } ?> <?php } ?> <?php } ?>
echo t('Version History'); ?> " href="<?php echo REL_DIR_FILES_TOOLS_REQUIRED; ?> /versions.php?rel=SITEMAP&cID=<?php echo $stack->getCollectionID(); ?> "><?php echo t('Version History'); ?> </a> <? $cpc = new Permissions($stack); ?> <? if ($cpc->canAdminPage() && PERMISSIONS_MODEL == 'advanced') { ?> <a class="btn small ccm-main-nav-edit-option" dialog-width="580" dialog-append-buttons="true" dialog-height="420" dialog-title="<?php echo t('Stack Permissions'); ?> " id="stackPermissions" href="<?php echo REL_DIR_FILES_TOOLS_REQUIRED; ?> /edit_area_popup.php?cID=<?php echo $stack->getCollectionID(); ?> &arHandle=Main&atask=groups"><?php echo t('Permissions'); ?> </a> <? } ?>
$u = new User(); $form = Loader::helper('form'); $sh = Loader::helper('concrete/dashboard/sitemap'); if (!$sh->canRead()) { die(t('Access Denied')); } if ($_POST['task'] == 'delete_pages') { $json['error'] = false; if (is_array($_POST['cID'])) { foreach($_POST['cID'] as $cID) { $c = Page::getByID($cID); $cp = new Permissions($c); $children = $c->getNumChildren(); if ($children == 0 || $cp->canAdminPage()) { $c->markPendingAction('DELETE'); if ($cp->canApproveCollection()) { $c->delete(); } } else { $json['error'] = t('Unable to delete one or more pages.'); } } } $js = Loader::helper('json'); print $js->encode($json); exit; }