示例#1
0
 /**
  * Saves an entry
  *
  * @return  void
  */
 public function saveTask()
 {
     // Check for request forgeries
     Request::checkToken();
     if (!User::authorise('core.edit', $this->_option) && !User::authorise('core.create', $this->_option)) {
         App::abort(403, Lang::txt('JERROR_ALERTNOAUTHOR'));
     }
     User::setState('com_forum.edit.section.data', null);
     // Incoming
     $fields = Request::getVar('fields', array(), 'post');
     $fields = array_map('trim', $fields);
     // Initiate extended database class
     $section = Section::oneOrNew($fields['id'])->set($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);
         $section->assetRules = new \JAccessRules($validData['rules']);
     }
     if (!$section->save()) {
         Notify::error($section->getError());
         return $this->editTask($section);
     }
     Notify::success(Lang::txt('COM_FORUM_SECTION_SAVED'));
     if ($this->getTask() == 'apply') {
         return $this->editTask($section);
     }
     // Redirect
     $this->cancelTask();
 }
示例#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));
 }