/** * Set page state * * @return void */ public function setStateTask($state = 1, $status = 'published') { //get request vars $moduleid = Request::getInt('moduleid', 0, 'get'); // load page model $module = new Module($moduleid); // make sure its out page if (!$module->belongsToGroup($this->group)) { App::abort(403, Lang::txt('COM_GROUPS_ERROR_NOT_AUTH')); } // make sure state is a valid state if (!in_array($state, array(0, 1, 2))) { $state = 1; } // set the page state $module->set('state', $state); // save if (!$module->store(false)) { $this->setNotification($module->getError(), 'error'); $this->displayTask(); return; } //inform user & redirect $url = Route::url('index.php?option=' . $this->_option . '&cn=' . $this->group->get('cn') . '&controller=modules'); if ($return = Request::getVar('return', '', 'get')) { $url = base64_decode($return); } App::redirect($url, Lang::txt('COM_GROUPS_PAGES_MODULE_STATE_CHANGE', $status), 'passed'); }
/** * 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'); }
/** * Set page state * * @param integer $state * @param string $status * @return void */ public function setStateTask($state = 1, $status = 'published') { //get request vars $moduleid = Request::getInt('moduleid', 0, 'get'); // load page model $module = new Module($moduleid); // make sure its out page if (!$module->belongsToGroup($this->group)) { App::abort(403, Lang::txt('COM_GROUPS_ERROR_NOT_AUTH')); } // make sure state is a valid state if (!in_array($state, array(0, 1, 2))) { $state = 1; } // set the page state $module->set('state', $state); // save if (!$module->store(false)) { $this->setNotification($module->getError(), 'error'); $this->displayTask(); return; } //inform user & redirect $url = Route::url('index.php?option=' . $this->_option . '&cn=' . $this->group->get('cn') . '&controller=modules'); if ($return = Request::getVar('return', '', 'get')) { $url = base64_decode($return); } // Log activity $recipients = array(['group', $this->group->get('gidNumber')], ['user', User::get('id')]); foreach ($this->group->get('managers') as $recipient) { $recipients[] = ['user', $recipient]; } Event::trigger('system.logActivity', ['activity' => ['action' => $state == 2 ? 'deleted' : 'updated', 'scope' => 'group.module', 'scope_id' => $module->get('id'), 'description' => Lang::txt('COM_GROUPS_ACTIVITY_MODULE_' . ($state == 2 ? 'DELETED' : ($state == 1 ? 'PUBLISHED' : 'UNPUBLISHED')), $module->get('title'), '<a href="' . $url . '">' . $this->group->get('description') . '</a>'), 'details' => array('title' => $module->get('title'), 'url' => $url, 'gidNumber' => $this->group->get('gidNumber'))], 'recipients' => $recipients]); App::redirect($url, Lang::txt('COM_GROUPS_PAGES_MODULE_STATE_CHANGE', $status), 'passed'); }