Exemplo n.º 1
0
 /**
  * Saves changes to a course or saves a new entry if creating
  *
  * @return  void
  */
 public function saveTask()
 {
     // Check for request forgeries
     Request::checkToken();
     // Incoming
     $fields = Request::getVar('fields', array(), 'post', 'none', 2);
     $fields = array_map('trim', $fields);
     // Initiate extended database class
     $row = new \Components\Courses\Models\Course(0);
     if (!$row->bind($fields)) {
         $this->setError($row->getError());
         $this->editTask($row);
         return;
     }
     // Store content
     if (!$row->store(true)) {
         $this->setError($row->getError());
         $this->editTask($row);
         return;
     }
     $tags = Request::getVar('tags', '', 'post');
     $row->tag($tags, User::get('id'));
     if ($this->_task == 'apply') {
         return $this->editTask($row);
     }
     // Output messsage and redirect
     App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), Lang::txt('COM_COURSES_ITEM_SAVED'));
 }