Ejemplo n.º 1
0
 public function removeAction()
 {
     $this->view->disable();
     if ($this->request->isPost()) {
         $category_id = $this->request->get('category_id');
     }
     $status = 1;
     // Cannot delete a category that has children
     if ($has_children = PCategory::count("_parent={$category_id}")) {
         $status = 0;
     }
     if ($cats = PCategory::find("category_id={$category_id}")) {
         foreach ($cats as $cat) {
             if (!$cat->delete()) {
                 $status = 0;
             }
         }
     }
     echo $status;
 }