示例#1
0
 /**
  * Preview Group Page
  *
  * @return void
  */
 public function previewTask()
 {
     // make sure we are approvers
     if (!Helpers\Pages::isPageApprover()) {
         App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller . '&gid=' . $this->gid, false), Lang::txt('COM_GROUPS_PAGES_MUST_BE_AUTHORIZED'), 'error');
         return;
     }
     // get reqest vars
     $pageid = Request::getInt('pageid', 0, 'get');
     $version = Request::getInt('version', 0, 'get');
     // page object
     $page = new Page($pageid);
     // make sure page belongs to this group
     if (!$page->belongsToGroup($this->group)) {
         App::abort(403, Lang::txt('COM_GROUPS_PAGES_NOT_AUTH'));
     }
     // get preview
     echo Helpers\Pages::generatePreview($page, $version);
     exit;
 }
示例#2
0
 /**
  * Approve a group page
  *
  * @return void
  */
 public function approveTask()
 {
     // make sure we are approvers
     if (!Helpers\Pages::isPageApprover()) {
         App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller . '&gid=' . $this->gid, false), Lang::txt('COM_GROUPS_MODULES_AUTHORIZED_APPROVERS_ONLY'), 'error');
         return;
     }
     // get request vars
     $id = Request::getInt('id', 0);
     // load page
     $module = new Module($id);
     // make sure version is unapproved
     if ($module->get('approved') == 1) {
         //inform user & redirect
         App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller . '&gid=' . $this->gid, false), Lang::txt('COM_GROUPS_MODULES_ALREADY_APPROVED'), 'warning');
         return;
     }
     // set approved and approved date and approver
     $module->set('approved', 1);
     $module->set('approved_on', Date::toSql());
     $module->set('approved_by', User::get('id'));
     if (!is_object($this->group->params)) {
         $this->group->params = new \Hubzero\Config\Registry($this->group->params);
     }
     $module->set('page_trusted', $this->group->params->get('page_trusted', 0));
     // DONT RUN CHECK ON STORE METHOD (pass false as first arg to store() method)
     $module->store(false, $this->group->isSuperGroup());
     // send approved notifcation
     Helpers\Pages::sendApprovedNotification('module', $module);
     // log change
     Log::log(array('gidNumber' => $this->group->get('gidNumber'), 'action' => 'group_modules_approved', 'comments' => array($module->get('id'))));
     // inform user and redirect
     App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller . '&gid=' . $this->gid, false), Lang::txt('COM_GROUPS_MODULES_APPROVED'), 'passed');
 }