/** * Delete specific category * * @access public * @param void * @return null */ function delete_category() { $category = ProjectCategories::findById(get_id()); if (!$category instanceof ProjectCategory) { flash_error(lang('category dnx')); $this->redirectTo('tickets', 'categories'); } // if if (!$category->canDelete(logged_user())) { flash_error(lang('no access permissions')); $this->redirectToReferer(get_url('tickets', 'categories')); } // if try { DB::beginWork(); $category->delete(); ApplicationLogs::createLog($category, $category->getProject(), ApplicationLogs::ACTION_DELETE); DB::commit(); flash_success(lang('success deleted category', $category->getName())); } catch (Exception $e) { DB::rollback(); flash_error(lang('error delete category')); } // try $this->redirectTo('tickets', 'categories'); }
/** * Return owner user or company * * @access public * @param void * @return ApplicationDataObject */ function getCategory() { if ($this->getCategoryId() > 0) { return ProjectCategories::findById($this->getCategoryId()); } else { return null; } // if }