Exemplo n.º 1
0
 public function submit()
 {
     $r = new PageEditResponse();
     if ($this->validateAction()) {
         $oc = $this->page;
         $successMessage = false;
         $ocp = new Permissions($oc);
         if ($oc->getCollectionParentID() != $_POST['cParentID']) {
             $dc = Page::getByID($_POST['cParentID'], 'RECENT');
             if (!is_object($dc) || $dc->isError()) {
                 throw new Exception('Invalid parent page.');
             }
             $dcp = new Permissions($dc);
             $ct = PageType::getByID($this->page->getPageTypeID());
             if (!$dcp->canAddSubpage($ct)) {
                 throw new Exception('You do not have permission to add this subpage here.');
             }
             if (!$oc->canMoveCopyTo($dc)) {
                 throw new Exception('You cannot add a page beneath itself.');
             }
             if ($oc->isPageDraft()) {
                 $oc->setPageDraftTargetParentPageID($dc->getCollectionID());
             } else {
                 $u = new User();
                 $pkr = new MovePagePageWorkflowRequest();
                 $pkr->setRequestedPage($oc);
                 $pkr->setRequestedTargetPage($dc);
                 $pkr->setSaveOldPagePath(false);
                 $pkr->setRequesterUserID($u->getUserID());
                 $u->unloadCollectionEdit($oc);
                 $response = $pkr->trigger();
                 if ($response instanceof WorkflowProgressResponse) {
                     $nc = Page::getByID($oc->getCollectionID());
                     $r->setRedirectURL(Loader::helper('navigation')->getLinkToCollection($nc));
                 }
             }
         }
         // now we do additional page URLs
         $oc->clearAdditionalPagePaths();
         $req = Request::getInstance();
         if ($req->request->has('additionalPath')) {
             $additionalPath = (array) $req->request->get('additionalPath');
             foreach ($additionalPath as $path) {
                 $oc->addAdditionalPagePath($path, false);
             }
         }
         Database::get()->getEntityManager()->flush();
         $r->setTitle(t('Page Updated'));
         $r->setMessage(t('Page location information saved successfully.'));
         $r->setPage($this->page);
         $nc = Page::getByID($this->page->getCollectionID(), 'ACTIVE');
         $r->outputJSON();
     }
 }
Exemplo n.º 2
0
 public function submit()
 {
     $r = new PageEditResponse();
     if ($this->validateAction()) {
         $oc = $this->page;
         if ($oc->getCollectionParentID() != $_POST['cParentID']) {
             if ($this->page->getCollectionID() == HOME_CID) {
                 throw new Exception('You cannot move the homepage.');
             }
             $dc = Page::getByID($_POST['cParentID'], 'RECENT');
             if (!is_object($dc) || $dc->isError()) {
                 throw new Exception('Invalid parent page.');
             }
             $dcp = new Permissions($dc);
             $ct = PageType::getByID($this->page->getPageTypeID());
             if (!$dcp->canAddSubpage($ct)) {
                 throw new Exception('You do not have permission to add this subpage here.');
             }
             if (!$oc->canMoveCopyTo($dc)) {
                 throw new Exception('You cannot add a page beneath itself.');
             }
             if ($oc->isPageDraft()) {
                 $oc->setPageDraftTargetParentPageID($dc->getCollectionID());
             } else {
                 $u = new User();
                 $pkr = new MovePagePageWorkflowRequest();
                 $pkr->setRequestedPage($oc);
                 $pkr->setRequestedTargetPage($dc);
                 $pkr->setSaveOldPagePath(false);
                 $pkr->setRequesterUserID($u->getUserID());
                 $u->unloadCollectionEdit($oc);
                 $response = $pkr->trigger();
                 if ($response instanceof WorkflowProgressResponse && !$this->request->request->get('sitemap')) {
                     $nc = Page::getByID($oc->getCollectionID());
                     $r->setRedirectURL(Loader::helper('navigation')->getLinkToCollection($nc));
                 }
             }
         }
         // now we do additional page URLs
         $req = Request::getInstance();
         $oc->clearPagePaths();
         $canonical = $req->request->get('canonical');
         $pathArray = $req->request->get('path');
         if (isset($canonical) && $this->page->getCollectionID() == HOME_CID) {
             throw new Exception('You cannot change the canonical path of the home page.');
         }
         if (is_array($pathArray)) {
             foreach ($pathArray as $i => $path) {
                 $p = new PagePath();
                 $p->setPagePath($path);
                 $p->setPageObject($this->page);
                 if ($canonical == $i) {
                     $p->setPagePathIsCanonical(true);
                 }
                 \ORM::entityManager()->persist($p);
             }
         }
         \ORM::entityManager()->flush();
         $r->setTitle(t('Page Updated'));
         $r->setMessage(t('Page location information saved successfully.'));
         $r->setPage($this->page);
         $nc = Page::getByID($this->page->getCollectionID(), 'ACTIVE');
         $r->outputJSON();
     }
 }
Exemplo n.º 3
0
                 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();
         }
         break;
     case "MOVE":
         foreach ($originalPages as $oc) {
             $ocp = new Permissions($oc);
             Session::set('movePageSaveOldPagePath', $_REQUEST['saveOldPagePath']);
             $pkr = new MovePagePageWorkflowRequest();
             $pkr->setRequestedPage($oc);
             $pkr->setRequestedTargetPage($dc);
             $pkr->setSaveOldPagePath($_REQUEST['saveOldPagePath']);
             $pkr->setRequesterUserID($u->getUserID());
             $u->unloadCollectionEdit($oc);
             $r = $pkr->trigger();
             if ($r instanceof \Concrete\Core\Workflow\Progress\Response) {
                 $successMessage .= '"' . $oc->getCollectionName() . '" ' . t('was moved beneath') . ' "' . $dc->getCollectionName() . '." ';
             } else {
                 $successMessage .= t("Your request to move \"%s\" beneath \"%s\" has been stored. Someone with approval rights will have to activate the change.\n", $oc->getCollectionName(), $dc->getCollectionName());
             }
         }
         $newCID[] = $oc->getCollectionID();
         break;
 }