deleteCategoryAllowed() public static method

Checks if it is allowed to delete the a category
public static deleteCategoryAllowed ( integer $id ) : boolean
$id integer The id of the category.
return boolean
Beispiel #1
0
 /**
  * Execute the action
  */
 public function execute()
 {
     $this->id = $this->getParameter('id', 'int');
     // does the item exist
     if ($this->id !== null && BackendBlogModel::existsCategory($this->id)) {
         // get data
         $this->record = (array) BackendBlogModel::getCategory($this->id);
         // allowed to delete the category?
         if (BackendBlogModel::deleteCategoryAllowed($this->id)) {
             // call parent, this will probably add some general CSS/JS or other required files
             parent::execute();
             // delete item
             BackendBlogModel::deleteCategory($this->id);
             // trigger event
             BackendModel::triggerEvent($this->getModule(), 'after_delete_category', array('id' => $this->id));
             // category was deleted, so redirect
             $this->redirect(BackendModel::createURLForAction('Categories') . '&report=deleted-category&var=' . rawurlencode($this->record['title']));
         } else {
             $this->redirect(BackendModel::createURLForAction('Categories') . '&error=delete-category-not-allowed&var=' . rawurlencode($this->record['title']));
         }
     } else {
         // something went wrong
         $this->redirect(BackendModel::createURLForAction('Categories') . '&error=non-existing');
     }
 }
Beispiel #2
0
 /**
  * Parse the form
  */
 protected function parse()
 {
     parent::parse();
     $this->tpl->assign('item', $this->record);
     // delete allowed?
     $this->tpl->assign('showBlogDeleteCategory', BackendBlogModel::deleteCategoryAllowed($this->id) && BackendModel::createURLForAction('DeleteCategory'));
 }