Esempio n. 1
0
 public function delete($cID = false, $token = false)
 {
     if (Loader::helper('validation/token')->validate('delete', $token)) {
         $s = Stack::getByID($cID);
         if (is_object($s)) {
             $sps = new Permissions($s);
             if ($sps->canDeletePage()) {
                 $u = new User();
                 $pkr = new DeletePagePageWorkflowRequest();
                 $pkr->setRequestedPage($s);
                 $pkr->setRequesterUserID($u->getUserID());
                 $response = $pkr->trigger();
                 if ($response instanceof WorkflowProgressResponse) {
                     // 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', $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());
     }
 }
Esempio n. 2
0
	$q = Queue::get('delete_page_request');

	if ($_POST['process']) {
		$obj = new stdClass;
		$js = Loader::helper('json');
		$messages = $q->receive(DELETE_PAGES_LIMIT);
		foreach($messages as $key => $p) {
			// delete the page here
			$page = unserialize($p->body);
			$c = Page::getByID($page['cID']);
			if ($c->getCollectionID() > 1) {
				$pkr = new DeletePagePageWorkflowRequest();
				$pkr->setRequestedPage($c);
				$pkr->setRequesterUserID($u->getUserID());
				$u->unloadCollectionEdit($c);
				$pkr->trigger();
			}
			$q->deleteMessage($p);
		}
		$obj->totalItems = $q->count();	
		if ($q->count() == 0) {
			$q->deleteQueue('delete_page_request');
		}
		print $js->encode($obj);
		exit;
	} else if ($q->count() == 0) {
		if (is_array($_POST['cID'])) {
			foreach($_POST['cID'] as $cID) {
				$c = Page::getByID($cID);
				$cp = new Permissions($c);
				$children = $c->getNumChildren();
if ($_REQUEST['ctask'] && $valt->validate()) {
    switch ($_REQUEST['ctask']) {
        case 'delete':
            if ($cp->canDeletePage() && $c->getCollectionID() != '1' && !$c->isMasterCollection()) {
                $children = $c->getNumChildren();
                if ($children == 0 || $cp->canApprovePageVersions()) {
                    $obj = new stdClass();
                    if ($c->isExternalLink()) {
                        $c->delete();
                    } else {
                        $obj->refreshCID = $c->getCollectionID();
                        $pkr = new DeletePagePageWorkflowRequest();
                        $pkr->setRequestedPage($c);
                        $pkr->setRequesterUserID($u->getUserID());
                        $u->unloadCollectionEdit($c);
                        $response = $pkr->trigger();
                        $obj->deferred = true;
                        if ($response instanceof WorkflowProgressResponse) {
                            // we only get this response if we have skipped workflows and jumped straight in to an approve() step.
                            $obj->refreshCID = $c->getCollectionParentID();
                            $obj->deferred = false;
                        }
                    }
                }
                $cParentID = $c->getCollectionParentID();
                $obj->rel = $_REQUEST['rel'];
                $obj->cParentID = $cParentID;
                $obj->cID = $c->getCollectionID();
                $obj->display_mode = $_REQUEST['display_mode'];
                $obj->select_mode = $_REQUEST['select_mode'];
                $obj->instance_id = $_REQUEST['instance_id'];