Пример #1
0
 /**
  * Removes class(es)
  *
  * @return  void
  */
 public function deleteTask()
 {
     // Check for request forgeries
     Request::checkToken();
     // Incoming
     $ids = Request::getVar('id', array());
     $ids = !is_array($ids) ? array($ids) : $ids;
     // Do we have any IDs?
     if (!empty($ids)) {
         // Loop through each ID and delete the necessary items
         foreach ($ids as $id) {
             $id = intval($id);
             $row = new Tables\SessionClass($this->database);
             $row->load($id);
             if ($row->alias == 'default') {
                 // Output message and redirect
                 App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller . '&task=classes', false), Lang::txt('COM_TOOLS_SESSION_CLASS_DONT_DELETE_DEFAULT'), 'warning');
                 return;
             }
             // Remove the record
             $row->delete($id);
             $prefs = new Tables\Preferences($this->database);
             $prefs->restoreDefaultClass($id);
         }
     } else {
         // Output message and redirect
         App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller . '&task=classes', false), Lang::txt('COM_TOOLS_SESSION_CLASS_DELETE_NO_ROWS'), 'warning');
     }
     // Output messsage and redirect
     App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller . '&task=classes', false), Lang::txt('COM_TOOLS_SESSION_CLASS_DELETE_SUCCESSFUL'));
 }
Пример #2
0
 /**
  * Restore member to default quota class
  *
  * @return  void
  */
 public function restoreDefaultTask()
 {
     // Check for request forgeries
     Request::checkToken();
     // Incoming
     $ids = Request::getVar('id', array());
     $ids = !is_array($ids) ? array($ids) : $ids;
     // Do we have any IDs?
     if (!empty($ids)) {
         // Loop through each ID and restore
         foreach ($ids as $id) {
             $id = intval($id);
             $row = new Tables\Preferences($this->database);
             $row->load($id);
             $class = new Tables\SessionClass($this->database);
             $class->load(array('alias' => 'default'));
             if (!$class->id) {
                 // Output message and redirect
                 App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), Lang::txt('COM_TOOLS_USER_PREFS_MISSING_DEFAULT_CLASS'), 'error');
                 return;
             }
             $row->set('class_id', $class->id);
             $row->set('jobs', $class->jobs);
             $row->store();
         }
     } else {
         // Output message and redirect
         App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), Lang::txt('COM_TOOLS_USER_PREFS_DELETE_NO_ROWS'), 'warning');
     }
     // Output messsage and redirect
     App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), Lang::txt('COM_TOOLS_USER_PREFS_SET_TO_DEFAULT'));
 }