Файл: concrete5.7.5.6/concrete/controllers/dialog/page/delete.php
Строк: 76
<?php
namespace ConcreteControllerDialogPage;
use ConcreteControllerBackendUserInterfacePage as BackendInterfacePageController;
use ConcreteCoreWorkflowRequestDeletePageRequest as DeletePagePageWorkflowRequest;
use ConcreteCorePageEditResponse as PageEditResponse;
use ConcreteCoreWorkflowProgressResponse as WorkflowProgressResponse;
use User;
use Loader;
use Page;
class Delete extends BackendInterfacePageController {
protected $viewPath = '/dialogs/page/delete';
protected $controllerActionPath = '/ccm/system/dialogs/page/delete';
protected function canAccess() {
return $this->permissions->canDeletePage();
}
public function view() {
$this->set('numChildren', $this->page->getNumChildren());
}
public function viewFromSitemap() {
$this->set('numChildren', $this->page->getNumChildren());
$this->set('sitemap', true);
}
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();
}
}
}
}
}
}