Example #1
0
 public function publish()
 {
     if ($this->validateAction()) {
         $r = $this->save();
         $ptr = $r[0];
         $pagetype = $r[1];
         $outputControls = $r[2];
         $c = $this->page;
         $e = $ptr->error;
         $validator = $pagetype->getPageTypeValidatorObject();
         if ($this->page->isPageDraft()) {
             $target = \Page::getByID($this->page->getPageDraftTargetParentPageID());
         } else {
             $target = \Page::getByID($this->page->getCollectionParentID());
         }
         $e->add($validator->validatePublishLocationRequest($target));
         $e->add($validator->validatePublishDraftRequest($c));
         $ptr->setError($e);
         if (!$e->has()) {
             $publishDateTime = false;
             if ($this->request->request->get('action') == 'schedule') {
                 $dateTime = new DateTime();
                 $publishDateTime = $dateTime->translate('check-in-scheduler');
             }
             $pagetype->publish($c, $publishDateTime);
             $ptr->setRedirectURL(Loader::helper('navigation')->getLinkToCollection($c));
         }
         $ptr->outputJSON();
     } else {
         throw new \Exception(t('Access Denied.'));
     }
 }
Example #2
0
 public function submit()
 {
     $e = $this->app->make('error');
     $pagetype = Type::getByID($this->request->request->get('ptID'));
     if (is_object($pagetype)) {
         $configuredTarget = $pagetype->getPageTypePublishTargetObject();
         $cParentID = $configuredTarget->getPageTypePublishTargetConfiguredTargetParentPageID();
         if (!$cParentID) {
             $cParentID = $this->request->request->get('cParentID');
         }
     }
     $parent = Page::getByID($cParentID);
     $template = null;
     if ($this->request->request->get('ptComposerPageTemplateID')) {
         $template = Template::getByID($this->request->request->get('ptComposerPageTemplateID'));
     }
     if (!is_object($template)) {
         $template = $pagetype->getPageTypeDefaultPageTemplateObject();
     }
     if (is_object($pagetype)) {
         $validator = $pagetype->getPageTypeValidatorObject();
         $e->add($validator->validateCreateDraftRequest($template));
         $e->add($validator->validatePublishLocationRequest($parent));
         if ($this->request->request('addPageComposeAction') == 'publish') {
             $e->add($validator->validatePublishDraftRequest());
         }
     }
     $pr = new EditResponse();
     $pr->setError($e);
     if (!$e->has()) {
         $d = $pagetype->createDraft($template);
         $d->setPageDraftTargetParentPageID($cParentID);
         $saver = $pagetype->getPageTypeSaverObject();
         $saver->saveForm($d);
         if ($this->request->request('addPageComposeAction') == 'publish' || $this->request->request('addPageComposeAction') == 'schedule') {
             $publishDateTime = false;
             if ($this->request->request->get('addPageComposeAction') == 'schedule') {
                 $dateTime = new DateTime();
                 $publishDateTime = $dateTime->translate('check-in-scheduler');
             }
             $pagetype->publish($d, $publishDateTime);
             $pr->setAdditionalDataAttribute('cParentID', $cParentID);
             $pr->setMessage(t('Page Added Successfully.'));
         } else {
             $pr->setRedirectURL($d->getCollectionLink(true));
         }
     }
     $pr->outputJSON();
 }
Example #3
0
 public function submit()
 {
     if ($this->validateAction()) {
         $comments = $this->request->request('comments');
         $comments = is_string($comments) ? trim($comments) : '';
         if ($comments === '' && $this->app->make('config')->get('concrete.misc.require_version_comments')) {
             return Response::create(t('Please specify the version comments'), 400);
         }
         $c = $this->page;
         $u = new User();
         $v = CollectionVersion::get($c, "RECENT");
         $v->setComment($_REQUEST['comments']);
         $pr = new PageEditResponse();
         if (($this->request->request->get('action') == 'publish' || $this->request->request->get('action') == 'schedule') && $this->permissions->canApprovePageVersions()) {
             $e = $this->checkForPublishing();
             $pr->setError($e);
             if (!$e->has()) {
                 $pkr = new ApprovePagePageWorkflowRequest();
                 $pkr->setRequestedPage($c);
                 $pkr->setRequestedVersionID($v->getVersionID());
                 $pkr->setRequesterUserID($u->getUserID());
                 $u->unloadCollectionEdit($c);
                 if ($this->request->request->get('action') == 'schedule') {
                     $dateTime = new DateTime();
                     $publishDateTime = $dateTime->translate('check-in-scheduler');
                     $pkr->scheduleVersion($publishDateTime);
                 }
                 if ($c->isPageDraft()) {
                     $pagetype = $c->getPageTypeObject();
                     $pagetype->publish($c, $pkr);
                 } else {
                     $pkr->trigger();
                 }
             }
         } else {
             if ($this->request->request->get('action') == 'discard') {
                 if ($c->isPageDraft() && $this->permissions->canDeletePage()) {
                     $u = new User();
                     $cID = $u->getPreviousFrontendPageID();
                     $this->page->delete();
                     $pr->setRedirectURL(DIR_REL . '/' . DISPATCHER_FILENAME . '?cID=' . $cID);
                     $pr->outputJSON();
                 } else {
                     if ($v->canDiscard()) {
                         $v->discard();
                     }
                 }
             } else {
                 $v->removeNewStatus();
             }
         }
         $nc = Page::getByID($c->getCollectionID(), $v->getVersionID());
         $u->unloadCollectionEdit();
         $pr->setRedirectURL(Loader::helper('navigation')->getLinkToCollection($nc, true));
         $pr->outputJSON();
     }
 }