Пример #1
0
 /**
  * Makes one license default
  * Redirects to license listing
  *
  * @return  void
  */
 public function makedefaultTask()
 {
     // Check for request forgeries
     Request::checkToken();
     // Incoming
     $id = Request::getVar('id', array(0), '', 'array');
     if (count($id) > 1) {
         App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), Lang::txt('COM_PUBLICATIONS_LICENSE_SELECT_ONE'), 'error');
         return;
     }
     // Initialize
     $row = new \Components\Publications\Tables\License($this->database);
     $id = intval($id[0]);
     // Load row
     $row->loadLicense($id);
     // Make default
     $row->main = 1;
     // Save
     if (!$row->store()) {
         App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), $row->getError(), 'error');
         return;
     }
     // Fix up all other licenses
     $row->undefault($id);
     // Redirect
     App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), Lang::txt('COM_PUBLICATIONS_SUCCESS_LICENSE_MADE_DEFAULT'));
 }