예제 #1
0
 /**
  * Save quota class
  *
  * @param   integer  $redirect  Whether or not to redirect after save
  * @return  void
  */
 public function saveTask()
 {
     // Check for request forgeries
     Request::checkToken();
     // Incoming fields
     $fields = Request::getVar('fields', array(), 'post');
     // Load the profile
     $row = new Tables\SessionClass($this->database);
     $row->load($fields['id']);
     $old = $row->jobs;
     // Try to save
     if (!$row->save($fields)) {
         Notify::error($row->getError());
         return $this->editTask($row);
     }
     // Save class/access-group association
     if (isset($fields['groups'])) {
         if (!$row->setGroupIds($fields['groups'])) {
             Notify::error($row->getError());
             return $this->editTask($row);
         }
     }
     // If changing, update members referencing this class
     if ($old != $row->jobs) {
         $prefs = new Tables\Preferences($this->database);
         $prefs->updateUsersByClassId($row->id);
     }
     Notify::success(Lang::txt('COM_TOOLS_SESSION_CLASS_SAVE_SUCCESSFUL'));
     // Redirect
     if ($this->_task == 'apply') {
         return $this->editTask($row);
     }
     // Redirect
     App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller . '&task=classes', false));
 }