Example #1
0
 public function showDelete(PageModuleWrapper $wrapper, $backend)
 {
     if ($wrapper->isInherited() && !$this->pagePermission[PageAccessPeer::PERM_MODULES]) {
         $backend->addMessage('You do not have permission to delete inherited modules.', AbstractBackend::MSG_ERROR);
         return;
     }
     if (!$this->pagePermission[PageAccessPeer::PERM_CREATE_MODULE]) {
         $backend->addMessage('You do not have permission to delete modules.', AbstractBackend::MSG_ERROR);
         return;
     }
     $form = new Curry_Form(array('action' => url('', $_GET), 'elements' => array('delete' => array('submit', array('label' => 'Delete')))));
     if (isPost() && $form->isValid($_POST)) {
         $pageModule = $wrapper->getPageModule();
         $pk = $pageModule->getPrimaryKey();
         $revisionModule = RevisionModuleQuery::create()->findPk(array($pageModule->getPageModuleId(), $wrapper->getOriginPage()->getWorkingPageRevisionId()));
         if (!$revisionModule) {
             throw new Exception('Unable to find RevisionModule to delete.');
         }
         $revisionModule->delete();
         $backend->addMessage('The module has been deleted!', AbstractBackend::MSG_SUCCESS);
         $backend->createModelUpdateEvent('PageModule', $pk, 'delete');
         $backend->addBodyClass('live-edit-close');
     } else {
         $msg = 'Do you really want to delete this module?';
         $originPage = $wrapper->getOriginPage();
         $dependencies = $originPage->getDependantPages();
         if ($wrapper->isInherited()) {
             $backend->addMessage('This module is inherited and will be removed from ' . $originPage . '. It will also be removed from the following subpages: ' . join(", ", $dependencies), AbstractBackend::MSG_WARNING);
         } else {
             if (count($dependencies)) {
                 $backend->addMessage('This module is inherited to subpages and will ' . 'also be removed from the following subpages: ' . join(", ", $dependencies), AbstractBackend::MSG_WARNING);
             }
         }
         $backend->addMessage($msg);
         $backend->addMainContent($form);
     }
 }