/** * Create a new category * * @post /course/:course_id/forum_categories */ public function createForumCategory($course_id) { if (!\ForumPerm::has("add_category", $course_id)) { $this->error(401); } if (!isset($this->data['name']) || !strlen($name = trim($this->data['name']))) { $this->error(400, 'Category name required.'); } $category_id = \ForumCat::add($course_id, $name); if (!$category_id) { $this->error(500, 'Error creating the forum category.'); } $this->redirect('forum_category/' . $category_id, 201, 'ok'); }
/** * Add submitted category to current course */ function add_category_action() { ForumPerm::check('add_category', $this->getId()); $category_id = ForumCat::add($this->getId(), Request::get('category')); ForumPerm::checkCategoryId($this->getId(), $category_id); $this->redirect(PluginEngine::getLink('coreforum/index#cat_' . $category_id)); }