本文整理汇总了PHP中Permissions::canAddSubCollection方法的典型用法代码示例。如果您正苦于以下问题:PHP Permissions::canAddSubCollection方法的具体用法?PHP Permissions::canAddSubCollection怎么用?PHP Permissions::canAddSubCollection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Permissions
的用法示例。
在下文中一共展示了Permissions::canAddSubCollection方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validatePublishLocationRequest
public function validatePublishLocationRequest(Page $target = null)
{
$e = Core::make('error');
if (!is_object($target) || $target->isError()) {
$e->add(t('You must choose a page to publish this page beneath.'));
} else {
$ppc = new \Permissions($target);
if (!$ppc->canAddSubCollection($this->getPageTypeObject())) {
$e->add(t('You do not have permission to publish a page in this location.'));
}
}
return $e;
}
示例2: create_new
public function create_new()
{
$pr = new PageEditResponse();
$ms = Section::getByID($this->request->request->get('section'));
// we get the related parent id
$cParentID = $this->page->getCollectionParentID();
$cParent = \Page::getByID($cParentID);
$cParentRelatedID = $ms->getTranslatedPageID($cParent);
if ($cParentRelatedID > 0) {
// we copy the page underneath it and store it
$newParent = \Page::getByID($cParentRelatedID);
$ct = \PageType::getByID($this->page->getPageTypeID());
$cp = new \Permissions($newParent);
if ($cp->canAddSubCollection($ct) && $this->page->canMoveCopyTo($newParent)) {
$newPage = $this->page->duplicate($newParent);
if (is_object($newPage)) {
// grab the approved version and unapprove it
$v = Version::get($newPage, 'ACTIVE');
if (is_object($v)) {
$v->deny();
$pkr = new ApprovePageRequest();
$pkr->setRequestedPage($newPage);
$u = new \User();
$pkr->setRequestedVersionID($v->getVersionID());
$pkr->setRequesterUserID($u->getUserID());
$response = $pkr->trigger();
if (!$response instanceof Response) {
// we are deferred
$pr->setMessage(t('<strong>Request Saved.</strong> You must complete the workflow before this change is active.'));
} else {
$ih = Core::make('multilingual/interface/flag');
$icon = $ih->getSectionFlagIcon($ms);
$pr->setAdditionalDataAttribute('name', $newPage->getCollectionName());
$pr->setAdditionalDataAttribute('link', $newPage->getCollectionLink());
$pr->setAdditionalDataAttribute('icon', $icon);
$pr->setMessage(t('Page created.'));
}
}
}
} else {
throw new \Exception(t('You do not have permission to add this page to this section of the tree.'));
}
}
$pr->outputJSON();
}
示例3: Permissions
}
$ctArray = CollectionType::getList();
$cp = new Permissions($c);
if ($c->getCollectionID() > 1) {
$parent = Page::getByID($c->getCollectionParentID());
$parentCP = new Permissions($parent);
}
if (!$cp->canEditPageType() && !$cp->canEditPageTheme()) {
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();
$plID = $pl->getThemeID();
}
?>
<div class="ccm-ui">
<form method="post" name="ccmThemeForm" action="<?php
echo $c->getCollectionAction();
示例4: array
if ($cp->canEditPageTheme() && $cp->canEditPageType()) {
$pcnt++;
}
}
if ($pcnt > 0) {
// i realize there are a lot of loops through this, but the logic here is a bit tough to follow if you don't do it this way.
// first we determine which page types to show, if any
$notAllowedPageTypes = array();
$allowedPageTypes = array();
$ctArray = CollectionType::getList();
foreach ($ctArray as $ct) {
foreach ($pages as $c) {
if ($c->getCollectionID() != HOME_CID) {
$parentC = Page::getByID($c->getCollectionParentID());
$parentCP = new Permissions($parentC);
if (!$parentCP->canAddSubCollection($ct)) {
$notAllowedPageTypes[] = $ct;
}
}
}
}
foreach ($ctArray as $ct) {
if (!in_array($ct, $notAllowedPageTypes)) {
$allowedPageTypes[] = $ct;
}
}
$cnt = count($allowedPageTypes);
// next we determine which page type to select, if any
$ctID = -1;
foreach ($pages as $c) {
if ($c->getCollectionTypeID() != $ctID && $ctID != -1) {
示例5: Permissions
break;
case 'set_theme':
$toolSection = "collection_theme";
$divID = 'ccm-edit-collection-design';
$canViewPane = $cp->canEditPageTheme() || $cp->canEditPageType();
break;
case 'add':
$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;
示例6: select_publish_target
public function select_publish_target() {
$parent = Page::getByID($this->post('cPublishParentID'));
$str = '';
if (!is_object($parent) || $parent->isError()) {
print t('Invalid parent page.');
exit;
} else {
$entry = ComposerPage::getByID($this->post('entryID'));
if (!is_object($entry) || (!$entry->isComposerDraft())) {
print t('Invalid composer draft.');
exit;
}
$ct = CollectionType::getByID($entry->getCollectionTypeID());
$cp = new Permissions($parent);
if (!$cp->canAddSubCollection($ct)) {
print t('You do not have permissions to add this page type in that location.');
exit;
}
}
$entry->setComposerDraftPublishParentID($this->post('cPublishParentID'));
print $this->getComposerDraftPublishText($entry);
exit;
}
示例7: Permissions
$c = Page::getByID($_REQUEST['cID']);
if (is_object($c) && !$c->isError()) {
$cp = new Permissions($c);
if ($c->getPendingActionTargetCollectionID()) {
$target = Page::getByID($c->getPendingActionTargetCollectionID());
if (!is_object($target) || $target->isError()) {
$target = Page::getByID(HOME_CID);
}
}
$doAdd = false;
if ($c->getCollectionTypeID() > 0) {
$ct = CollectionType::getByID($c->getCollectionTypeID());
$ncp = new Permissions($target);
if ($ncp->canAddSubCollection($ct)) {
$doAdd = true;
}
} else if ($u->isSuperUser()) {
$doAdd = true;
}
$obj = new stdClass;
if ($doAdd) {
$c->clearPendingAction();
$c->activate();
$c->move($target);
$obj->message = t("Page Restored");
$obj->targetCID = $target->getCollectionID();
} else {
示例8: create_page
public function create_page()
{
Loader::model('section', 'multilingual');
if (Loader::helper('validation/token')->validate('create_page', $_POST['token'])) {
$ms = MultilingualSection::getByLocale($_POST['locale']);
$page = Page::getByID($_POST['sourceID']);
if (is_object($page) && !$page->isError()) {
// we get the related parent id
$cParentID = $page->getCollectionParentID();
$cParent = Page::getByID($cParentID);
$cParentRelatedID = $ms->getTranslatedPageID($cParent);
if ($cParentRelatedID > 0) {
// we copy the page underneath it and store it
$newParent = Page::getByID($cParentRelatedID);
$ct = CollectionType::getByID($page->getCollectionTypeID());
$cp = new Permissions($newParent);
if ($cp->canAddSubCollection($ct) && $page->canMoveCopyTo($newParent)) {
$newPage = $page->duplicate($newParent);
if (is_object($newPage)) {
print '<a href="' . Loader::helper("navigation")->getLinkToCollection($newPage) . '">' . $newPage->getCollectionName() . '</a>';
}
} else {
print '<span class="ccm-error">' . t("Insufficient permissions.") . '</span>';
}
}
}
}
exit;
}
示例9: array
$siteMapParentID = $configuredTarget->getStartingPointPageID();
}
$ps = Loader::helper('form/page_selector');
echo $ps->selectFromSitemap('cParentID', $cParentID, $siteMapParentID, array('ptID' => $configuredTarget->getPageTypeID()));
} else {
$pl = new PageList();
$pl->sortByName();
$pl->filterByPageTypeID($configuredTarget->getPageTypeID());
$pl->sortByName();
$pages = $pl->get();
if (count($pages) > 1) {
$navigation = \Core::make('helper/navigation');
$options = array();
foreach ($pages as $p) {
$pp = new Permissions($p);
if ($pp->canAddSubCollection($pagetype)) {
$label = '';
$trail = $navigation->getTrailToCollection($p);
if (is_array($trail)) {
$trail = array_reverse($trail);
for ($i = 0; $i < count($trail); $i++) {
$label .= $trail[$i]->getCollectionName() . ' > ';
}
}
$label .= $p->getCollectionName();
$options[$p->getCollectionID()] = $label;
}
}
echo $form->select('cParentID', $options, $cParentID);
} elseif (count($pages) == 1) {
$p = $pages[0];
示例10: validate
protected function validate()
{
$vt = Loader::helper('validation/strings');
$vn = Loader::Helper('validation/numbers');
$dt = Loader::helper("form/date_time");
if (!$vn->integer($this->post('cParentID'))) {
$this->error->add(t('You must choose a parent page for this News entry.'));
}
if (!$vn->integer($this->post('ctID'))) {
$this->error->add(t('You must choose a page type for this News entry.'));
}
if (!$vt->notempty($this->post('newsTitle'))) {
$this->error->add(t('Title is required'));
}
if (!$this->error->has()) {
Loader::model('collection_types');
$ct = CollectionType::getByID($this->post('ctID'));
$parent = Page::getByID($this->post('cParentID'));
$parentPermissions = new Permissions($parent);
if (!$parentPermissions->canAddSubCollection($ct)) {
$this->error->add(t('You do not have permission to add a page of that type to that area of the site.'));
}
}
}
示例11: create_new
public function create_new()
{
$pr = new PageEditResponse();
$ms = Section::getByID($this->request->request->get('section'));
// we get the related parent id
if ($this->page->isPageDraft()) {
$cParentID = $this->page->getPageDraftTargetParentPageID();
} else {
$cParentID = $this->page->getCollectionParentID();
}
$cParent = \Page::getByID($cParentID);
$cParentRelatedID = $ms->getTranslatedPageID($cParent);
if ($cParentRelatedID > 0) {
// we copy the page underneath it and store it
$ct = \PageType::getByID($this->page->getPageTypeID());
if ($this->page->isPageDraft()) {
$ptp = new \Permissions($ct);
if (!$ptp->canAddPageType()) {
throw new \Exception(t('You do not have permission to add a page of this type.'));
}
}
$newParent = \Page::getByID($cParentRelatedID);
$cp = new \Permissions($newParent);
if ($cp->canAddSubCollection($ct)) {
if ($this->page->isPageDraft()) {
$targetParent = \Page::getByPath(\Config::get('concrete.paths.drafts'));
} else {
$targetParent = $newParent;
}
$newPage = $this->page->duplicate($targetParent);
if (is_object($newPage)) {
if ($this->page->isPageDraft()) {
$newPage->setPageDraftTargetParentPageID($newParent->getCollectionID());
Section::relatePage($this->page, $newPage, $ms->getLocale());
$pr->setMessage(t('New draft created.'));
} else {
// grab the approved version and unapprove it
$v = Version::get($newPage, 'ACTIVE');
if (is_object($v)) {
$v->deny();
}
$pr->setMessage(t('Unapproved page created. You must publish this page before it is live.'));
}
$ih = Core::make('multilingual/interface/flag');
$icon = (string) $ih->getSectionFlagIcon($ms);
$pr->setAdditionalDataAttribute('name', $newPage->getCollectionName());
$pr->setAdditionalDataAttribute('link', $newPage->getCollectionLink());
$pr->setAdditionalDataAttribute('icon', $icon);
}
} else {
throw new \Exception(t('You do not have permission to add this page to this section of the tree.'));
}
}
$pr->outputJSON();
}