Esempio n. 1
0
 /**
  * Save an entry
  *
  * @return     void
  */
 public function saveTask()
 {
     // Check for request forgeries
     Request::checkToken();
     $fields = Request::getVar('fields', array(), 'post');
     $fields = array_map('trim', $fields);
     $model = new Category($fields['id']);
     if (!$model->bind($fields)) {
         Notify::error($model->getError());
         $this->editTask($model);
         return;
     }
     $this->_authorize('category', $model->get('id'));
     if (!$this->config->get('access-edit-category')) {
         // Set the redirect
         App::redirect(Route::url('index.php?option=' . $this->_option));
     }
     $model->set('closed', isset($fields['closed']) && $fields['closed'] ? 1 : 0);
     // Store new content
     if (!$model->store(true)) {
         Notify::error($model->getError());
         $this->editTask($model);
         return;
     }
     // Set the redirect
     App::redirect(Route::url('index.php?option=' . $this->_option));
 }
Esempio n. 2
0
 /**
  * Populate the forum with defaulta section and category
  *
  * @return  boolean
  */
 public function setup()
 {
     // Create a default section
     $section = new Section(0, $this->get('scope'), $this->get('scope_id'));
     $section->bind(array('title' => Lang::txt('COM_FORUM_SECTION_DEFAULT'), 'scope' => $this->get('scope'), 'scope_id' => $this->get('scope_id'), 'state' => 1));
     if (!$section->store(true)) {
         $this->setError($section->getError());
         return false;
     }
     // Create a default category
     $category = new Category(0);
     $category->bind(array('title' => Lang::txt('COM_FORUM_CATEGORY_DEFAULT'), 'description' => Lang::txt('COM_FORUM_CATEGORY_DEFAULT_DESCRIPTION'), 'section_id' => $section->get('id'), 'scope' => $this->get('scope'), 'scope_id' => $this->get('scope_id'), 'state' => 1));
     if (!$category->store(true)) {
         $this->setError($category->getError());
         return false;
     }
     $this->_cache['sections'] = new ItemList(array($section));
     return true;
 }