Пример #1
0
 /**
  * Remove one or more categories
  *
  * @return     void
  */
 public function removeTask()
 {
     // Check for request forgeries
     Request::checkToken();
     // Incoming
     $ids = Request::getVar('id', array());
     if (!is_array($ids)) {
         $ids = array();
     }
     // Make sure we have an ID
     if (empty($ids)) {
         App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false));
         return;
     }
     $cids = array();
     if (count($ids) > 0) {
         // Loop through each category ID
         foreach ($ids as $id) {
             // Load the category
             $cat = new Category($this->database);
             $cat->load($id);
             // Check its count of items in it
             if ($cat->count > 0) {
                 // Category is NOT empty
                 $cids[] = $cat->name;
             } else {
                 // Empty category, go ahead and delete
                 $cat->delete($id);
             }
         }
     }
     if (count($cids)) {
         App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), Lang::txt('COM_EVENTS_CAL_LANG_CATEGORY_NOTEMPTY', implode("\\', \\'", $cids)), 'warning');
         return;
     }
     // Redirect
     App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), Lang::txt('COM_EVENTS_CAL_LANG_CATEGORY_REMOVED'));
 }