Esempio n. 1
0
	public function action_post() {
		// happens through ajax
		$pagetype = PageType::getByID($this->ptID);
		if (is_object($pagetype) && $this->enableNewTopics) {
			$ccp = new Permissions($pagetype);
			if ($ccp->canAddPageType()) {
				$pagetypes = $pagetype->getPageTypeComposerPageTypeObjects();
				$ctTopic = $pagetypes[0];
				$c = Page::getCurrentPage();
				$e = $pagetype->validatePublishRequest($ctTopic, $c);
				$r = new PageTypePublishResponse($e);
				if (!$e->has()) {
					$d = $pagetype->createDraft($ctTopic);
					$d->setPageDraftTargetParentPageID($c->getCollectionID());
					$d->saveForm();
					$d->publish();
					$nc = Page::getByID($d->getCollectionID(), 'RECENT');
					$link = Loader::helper('navigation')->getLinkToCollection($nc, true);
					$r->setRedirectURL($link);
				}
				$r->outputJSON();
			}
		}
		exit;
	}
Esempio n. 2
0
 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();
 }
Esempio n. 3
0
 public function add_composer($ptComposerFormLayoutSetControlID, $action)
 {
     $setControl = FormLayoutSetControl::getByID($ptComposerFormLayoutSetControlID);
     if (is_object($setControl)) {
         $formControl = $setControl->getPageTypeComposerControlObject();
         if ($formControl instanceof BlockControl) {
             $set = $setControl->getPageTypeComposerFormLayoutSetObject();
             $type = $set->getPageTypeObject();
             $pp = new \Permissions($type);
             if ($pp->canAddPageType()) {
                 $controller = $formControl->getBlockTypeObject()->getController();
                 return $this->deliverResponse($controller, $action);
             }
         }
     }
     $response = new Response(t('Access Denied'));
     return $response;
 }
Esempio n. 4
0
 protected function loadblogSections()
 {
     $blogSectionList = new ProBlogList();
     $blogSectionList->filterByBlogSection(1);
     $blogSectionList->sortBy('cvName', 'asc');
     $tmpSections = $blogSectionList->get();
     $sections = array();
     foreach ($tmpSections as $_c) {
         $pt = CollectionType::getByID($_c->getCollectionTypeID());
         $cmp = new \Permissions($pt);
         $pp = $cmp->canAddPageType();
         if ($pp) {
             $this->pt = $pt;
             $sections[$_c->getCollectionID()] = $_c->getCollectionName();
         }
     }
     $this->sections = $sections;
     $this->set('sections', $this->sections);
 }
Esempio n. 5
0
 public function validateComposerAddBlockPassThruAction(Type $type)
 {
     $pp = new \Permissions($type);
     return $pp->canAddPageType();
 }
Esempio n. 6
0
 /**
  * render Add Blog dialog
  */
 public function render()
 {
     $this->requireAsset('redactor');
     $this->requireAsset('core/file-manager');
     $blogify = Loader::helper('blogify');
     $settings = $blogify->getBlogSettings();
     $blogSectionList = new PageList();
     $blogSectionList->filter(false, "ak_blog_section = 1");
     $blogSectionList->sortBy('cvName', 'asc');
     $tmpSections = $blogSectionList->get();
     $sections = array();
     foreach ($tmpSections as $_c) {
         $pt = CollectionType::getByID($_c->getCollectionTypeID());
         $cmp = new \Permissions($pt);
         $pp = $cmp->canAddPageType();
         if ($pp) {
             $sections[$_c->getCollectionID()] = $_c->getCollectionName();
         }
     }
     $ctArray = PageTemplate::getList('');
     $pageTemplates = array();
     foreach ($ctArray as $ct) {
         $pms = new AddSubpagePageKey($ct);
         $pp = $pms->validate();
         if ($pp) {
             $pageTemplates[$ct->getPageTemplateID()] = $ct->getPageTemplateName();
         }
     }
     if ($_REQUEST['postID']) {
         $keys = array_keys($sections);
         $keys[] = -1;
         $current_page = Page::getByID($_REQUEST['postID']);
         $date = $current_page->getCollectionDatePublic();
         $canonical_parent_id = $blogify->getCanonicalParent($date, $current_page);
         $cParentID = $canonical_parent_id;
         if (in_array($canonical_parent_id, $keys)) {
             $this->blog = $current_page;
         }
     }
     if (is_object($this->blog)) {
         $blogTitle = $this->blog->getCollectionName();
         $blogDescription = $this->blog->getCollectionDescription();
         $blogDate = $this->blog->getCollectionDatePublic();
         $ptID = $this->blog->getPageTemplateID();
         $blogBody = '';
         $eb = $this->blog->getBlocks('Main');
         foreach ($eb as $b) {
             if ($b->getBlockTypeHandle() == 'content' || $b->getBlockTypeHandle() == 'core_page_type_composer_control_output') {
                 $blogBody = $b->getInstance()->getContent();
             }
         }
         echo "<div class=\"alert alert-success\"><span class=\"tooltip icon edit\"></span> " . t('You are now editing') . " <b><u>{$blogTitle}</u></b></div>";
         $task = 'editthis';
         $buttonText = t('Update Blog Entry');
         $title = 'Update';
     } else {
         $task = 'addthis';
         $buttonText = t('Add Blog Entry');
         $title = 'Add';
     }
     Loader::PackageElement('tools/add_blog', 'problog', array('blog' => $this->blog, 'blogTitle' => $blogTitle, 'blogDescription' => $blogDescription, 'blogBody' => $blogBody, 'sections' => $sections, 'pageTemplates' => $pageTemplates, 'buttonText' => $buttonText, 'ptID' => $ptID, 'settings' => $settings));
 }