Esempio n. 1
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;
 }
Esempio n. 2
0
 /**
  * Saves an entry and redirects to listing
  *
  * @return  void
  */
 public function saveTask()
 {
     // Check for request forgeries
     Request::checkToken();
     \User::setState('com_forum.edit.section.data', null);
     // Incoming
     $fields = Request::getVar('fields', array(), 'post');
     $fields = array_map('trim', $fields);
     // Bind the rules.
     $data = Request::getVar('jform', array(), 'post');
     if (isset($data['rules']) && is_array($data['rules'])) {
         $model = new AdminSection();
         $form = $model->getForm($data, false);
         $validData = $model->validate($form, $data);
         $fields['rules'] = $validData['rules'];
     }
     // Initiate extended database class
     $row = new Section($fields['id']);
     if (!$row->bind($fields)) {
         Notify::error($row->getError());
         return $this->editTask($row);
     }
     // Store content
     if (!$row->store(true)) {
         Notify::error($row->getError());
         return $this->editTask($row);
     }
     Notify::success(Lang::txt('COM_FORUM_SECTION_SAVED'));
     if ($this->_task == 'apply') {
         return $this->editTask($row);
     }
     // Redirect
     App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false));
 }
Esempio n. 3
0
 /**
  * Saves a section and redirects to main page afterward
  *
  * @return     void
  */
 public function saveTask()
 {
     // Check for request forgeries
     Request::checkToken();
     // Incoming posted data
     $fields = Request::getVar('fields', array(), 'post');
     $fields = array_map('trim', $fields);
     // Instantiate a new table row and bind the incoming data
     $section = new Section($fields['id']);
     if (!$section->bind($fields)) {
         App::redirect(Route::url('index.php?option=' . $this->_option), $section->getError(), 'error');
         return;
     }
     // Store new content
     if (!$section->store(true)) {
         App::redirect(Route::url('index.php?option=' . $this->_option), $section->getError(), 'error');
         return;
     }
     // Set the redirect
     App::redirect(Route::url('index.php?option=' . $this->_option));
 }