示例#1
0
 public function delete_stack()
 {
     if (Loader::helper('validation/token')->validate('delete_stack')) {
         $s = Stack::getByID($_REQUEST['stackID']);
         if (is_object($s)) {
             $sps = new Permissions($s);
             if ($sps->canDeletePage()) {
                 $u = new User();
                 $pkr = new DeletePageRequest();
                 $pkr->setRequestedPage($s);
                 $pkr->setRequesterUserID($u->getUserID());
                 $response = $pkr->trigger();
                 if ($response instanceof \Concrete\Core\Workflow\Progress\Response) {
                     // we only get this response if we have skipped workflows and jumped straight in to an approve() step.
                     $this->redirect('/dashboard/blocks/stacks', 'stack_deleted');
                 } else {
                     $this->redirect('/dashboard/blocks/stacks', 'view_details', $s->cID, 'delete_saved');
                 }
             } else {
                 $this->error->add(t('You do not have access to delete this stack.'));
             }
         } else {
             $this->error->add(t('Invalid stack'));
         }
     } else {
         $this->error->add(Loader::helper('validation/token')->getErrorMessage());
     }
 }
示例#2
0
 public function submit()
 {
     if ($this->validateAction()) {
         $c = $this->page;
         $cp = $this->permissions;
         $u = new User();
         if ($cp->canDeletePage() && $c->getCollectionID() != HOME_CID && !$c->isMasterCollection()) {
             $children = $c->getNumChildren();
             if ($children == 0 || $u->isSuperUser()) {
                 if ($c->isExternalLink()) {
                     $c->delete();
                 } else {
                     $pkr = new DeletePagePageWorkflowRequest();
                     $pkr->setRequestedPage($c);
                     $pkr->setRequesterUserID($u->getUserID());
                     $u->unloadCollectionEdit($c);
                     $response = $pkr->trigger();
                     $pr = new PageEditResponse();
                     $pr->setPage($c);
                     $parent = Page::getByID($c->getCollectionParentID(), 'ACTIVE');
                     if ($response instanceof WorkflowProgressResponse) {
                         // we only get this response if we have skipped workflows and jumped straight in to an approve() step.
                         $pr->setMessage(t('Page deleted successfully.'));
                         if (!$this->request->request->get('sitemap')) {
                             $pr->setRedirectURL($parent->getCollectionLink(true));
                         }
                     } else {
                         $pr->setMessage(t('Page deletion request saved. This action will have to be approved before the page is deleted.'));
                     }
                     $pr->outputJSON();
                 }
             }
         }
     }
 }