Example #1
0
 /**
  * Set the access level of an article
  *
  * @return  void
  */
 public function accessTask()
 {
     // Check for request forgeries
     Request::checkToken(['get', 'post']);
     // Incoming
     $id = Request::getInt('id', 0);
     // Make sure we have an ID to work with
     if (!$id) {
         App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), Lang::txt('COM_WISHLIST_NO_ID'), 'error');
         return;
     }
     switch ($this->getTask()) {
         case 'accesspublic':
             $access = 0;
             break;
         case 'accessregistered':
             $access = 1;
             break;
         case 'accessspecial':
             $access = 2;
             break;
     }
     // Load the article
     $row = new Wish($this->database);
     $row->load($id);
     $row->private = $access;
     // Check and store the changes
     if (!$row->check()) {
         App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), $row->getError(), 'error');
         return;
     }
     if (!$row->store()) {
         App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), $row->getError(), 'error');
         return;
     }
     // Set the redirect
     App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false));
 }
Example #2
0
 /**
  * Set the access level of an article
  *
  * @return  void
  */
 public function accessTask()
 {
     // Check for request forgeries
     Request::checkToken(['get', 'post']);
     if (!User::authorise('core.edit.state', $this->_option)) {
         App::abort(403, Lang::txt('JERROR_ALERTNOAUTHOR'));
     }
     // Incoming
     $id = Request::getInt('id', 0);
     // Make sure we have an ID to work with
     if (!$id) {
         Notify::error(Lang::txt('COM_WISHLIST_NO_ID'));
         return $this->cancelTask();
     }
     switch ($this->getTask()) {
         case 'accesspublic':
             $access = 0;
             break;
         case 'accessregistered':
             $access = 1;
             break;
         case 'accessspecial':
             $access = 2;
             break;
     }
     // Load the article
     $row = new Wish($this->database);
     $row->load($id);
     $row->private = $access;
     // Check and store the changes
     if (!$row->check()) {
         Notify::error($row->getError());
         return $this->cancelTask();
     }
     if (!$row->store()) {
         Notify::error($row->getError());
         return $this->cancelTask();
     }
     // Set the redirect
     $this->cancelTask();
 }