示例#1
0
 /**
  * Set the approval state for a revision
  *
  * @return  void
  */
 public function approveTask()
 {
     // Check for request forgeries
     Request::checkToken('get');
     // Incoming
     $pageid = Request::getInt('pageid', 0);
     $id = Request::getInt('id', 0);
     if ($id) {
         // Load the revision, approve it, and save
         $revision = new Revision($id);
         $revision->set('approved', Request::getInt('approve', 0));
         if (!$revision->store()) {
             App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller . '&pageid=' . $pageid, false), $revision->getError(), 'error');
             return;
         }
     }
     App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller . '&pageid=' . $pageid, false));
 }
示例#2
0
 /**
  * Approve a revision
  *
  * @return     void
  */
 public function approveTask()
 {
     // Check if they are logged in
     if (User::isGuest()) {
         $url = Request::getVar('REQUEST_URI', '', 'server');
         App::redirect(Route::url('index.php?option=com_users&view=login&return=' . base64_encode($url)));
         return;
     }
     // Incoming
     $id = Request::getInt('oldid', 0);
     if (!$id || !$this->page->access('manage')) {
         App::redirect(Route::url($this->page->link()));
         return;
     }
     // Load the revision, approve it, and save
     $revision = new Revision($id);
     $revision->set('approved', 1);
     if (!$revision->store()) {
         throw new Exception($revision->getError(), 500);
     }
     // Get the most recent revision and compare to the set "current" version
     $this->page->revisions('list', array(), true)->last();
     if ($this->page->revisions()->current()->get('id') == $revision->get('id')) {
         // The newly approved revision is now the most current
         // So, we need to update the page's version_id
         $this->page->set('version_id', $this->page->revisions()->current()->get('id'));
         $this->page->store(false, 'revision_approved');
     } else {
         $this->page->log('revision_approved');
     }
     App::redirect(Route::url($this->page->link()));
 }