/** * Reviewers actions (sensitive data, sponsored research) * * @return void */ public function processTask() { // Incoming $reviewer = Request::getWord('reviewer', ''); $action = Request::getVar('action', ''); $comment = Request::getVar('comment', ''); $approve = Request::getInt('approve', 0); $filterby = Request::getVar('filterby', 'pending'); $notify = Request::getVar('notify', 0, 'post'); // Cannot proceed without project id/alias if (!$this->model->exists() || $this->model->isDeleted()) { throw new Exception(Lang::txt('COM_PROJECTS_PROJECT_NOT_FOUND'), 404); return; } // Authorize if (!$this->model->reviewerAccess($reviewer)) { throw new Exception(Lang::txt('ALERTNOTAUTH'), 403); return; } // Set the pathway $this->_buildPathway(); // Set the page title $this->_buildTitle(); // Get project params $params = $this->model->params; if ($action == 'save' && !$this->getError()) { $cbase = $this->model->get('admin_notes'); // Meta data for comment $meta = '<meta>' . Date::of('now')->toLocal('M d, Y') . ' - ' . User::get('name') . '</meta>'; // Save approval if ($reviewer == 'sensitive') { $approve = $approve == 1 && $this->model->get('state') == 5 ? 1 : 0; // can only approve pending project $state = $approve ? 1 : $this->model->get('state'); $this->model->set('state', $state); } elseif ($reviewer == 'sponsored') { $grant_agency = Request::getVar('grant_agency', ''); $grant_title = Request::getVar('grant_title', ''); $grant_PI = Request::getVar('grant_PI', ''); $grant_budget = Request::getVar('grant_budget', ''); $grant_approval = Request::getVar('grant_approval', ''); $rejected = Request::getVar('rejected', 0); // New approval if (trim($params->get('grant_approval')) == '' && trim($grant_approval) != '' && $params->get('grant_status') != 1 && $rejected != 1) { // Increase $approve = 1; // Bump up quota $premiumQuota = Helpers\Html::convertSize(floatval($this->config->get('premiumQuota', '30')), 'GB', 'b'); $this->model->saveParam('quota', $premiumQuota); // Bump up publication quota $premiumPubQuota = Helpers\Html::convertSize(floatval($this->config->get('premiumPubQuota', '10')), 'GB', 'b'); $this->model->saveParam('pubQuota', $premiumPubQuota); } // Reject if ($rejected == 1 && $params->get('grant_status') != 2) { $approve = 2; } $this->model->saveParam('grant_budget', $grant_budget); $this->model->saveParam('grant_agency', $grant_agency); $this->model->saveParam('grant_title', $grant_title); $this->model->saveParam('grant_PI', $grant_PI); $this->model->saveParam('grant_approval', $grant_approval); if ($approve) { $this->model->saveParam('grant_status', $approve); } } // Save comment if (trim($comment) != '') { $comment = \Hubzero\Utility\String::truncate($comment, 500); $comment = \Hubzero\Utility\Sanitize::stripAll($comment); if (!$approve) { $cbase .= '<nb:' . $reviewer . '>' . $comment . $meta . '</nb:' . $reviewer . '>'; } } if ($approve) { if ($reviewer == 'sensitive') { $cbase .= '<nb:' . $reviewer . '>' . Lang::txt('COM_PROJECTS_PROJECT_APPROVED_HIPAA'); $cbase .= trim($comment) != '' ? ' ' . $comment : ''; $cbase .= $meta . '</nb:' . $reviewer . '>'; } if ($reviewer == 'sponsored') { if ($approve == 1) { $cbase .= '<nb:' . $reviewer . '>' . Lang::txt('COM_PROJECTS_PROJECT_APPROVED_SPS') . ' ' . ucfirst(Lang::txt('COM_PROJECTS_APPROVAL_CODE')) . ': ' . $grant_approval; $cbase .= trim($comment) != '' ? '. ' . $comment : ''; $cbase .= $meta . '</nb:' . $reviewer . '>'; } elseif ($approve == 2) { $cbase .= '<nb:' . $reviewer . '>' . Lang::txt('COM_PROJECTS_PROJECT_REJECTED_SPS'); $cbase .= trim($comment) != '' ? ' ' . $comment : ''; $cbase .= $meta . '</nb:' . $reviewer . '>'; } } } $this->model->set('admin_notes', $cbase); // Save changes if ($approve || $comment) { if (!$this->model->store()) { $this->setError($this->model->getError()); } $admingroup = $reviewer == 'sensitive' ? $this->config->get('sdata_group', '') : $this->config->get('ginfo_group', ''); if (\Hubzero\User\Group::getInstance($admingroup)) { $admins = Helpers\Html::getGroupMembers($admingroup); $admincomment = $comment ? User::get('name') . ' ' . Lang::txt('COM_PROJECTS_SAID') . ': ' . $comment : ''; // Send out email to admins if (!empty($admins)) { Helpers\Html::sendHUBMessage($this->_option, $this->model, $admins, Lang::txt('COM_PROJECTS_EMAIL_ADMIN_REVIEWER_NOTIFICATION'), 'projects_new_project_admin', 'admin', $admincomment, $reviewer); } } } // Pass success or error message if ($this->getError()) { $this->_setNotification($this->getError(), 'error'); } else { if ($approve) { if ($reviewer == 'sensitive') { $this->_setNotification(Lang::txt('COM_PROJECTS_PROJECT_APPROVED_HIPAA_MSG')); // Send out emails to team members $this->_notifyTeam(); } if ($reviewer == 'sponsored') { $notification = $approve == 2 ? Lang::txt('COM_PROJECTS_PROJECT_REJECTED_SPS_MSG') : Lang::txt('COM_PROJECTS_PROJECT_APPROVED_SPS_MSG'); $this->_setNotification($notification); } } elseif ($comment) { $this->_setNotification(Lang::txt('COM_PROJECTS_REVIEWER_COMMENT_POSTED')); } // Add to project activity feed if ($notify) { $activity = ''; if ($approve && $reviewer == 'sponsored') { $activity = $approve == 2 ? Lang::txt('COM_PROJECTS_PROJECT_REJECTED_SPS_ACTIVITY') : Lang::txt('COM_PROJECTS_PROJECT_APPROVED_SPS_ACTIVITY'); } elseif ($comment) { $activity = Lang::txt('COM_PROJECTS_PROJECT_REVIEWER_COMMENTED'); } if ($activity) { $aid = $this->model->recordActivity($activity, $this->model->get('id'), '', '', 'admin', 0, 1, 1); // Append comment to activity if ($comment && $aid) { $objC = new Tables\Comment($this->database); $cid = $objC->addComment($aid, 'activity', $comment, User::get('id'), $aid, 1); if ($cid) { $caid = $this->model->recordActivity(Lang::txt('COM_PROJECTS_COMMENTED') . ' ' . Lang::txt('COM_PROJECTS_ON') . ' ' . Lang::txt('COM_PROJECTS_AN_ACTIVITY'), $cid, '', '', 'quote', 0, 1, 1); if ($caid) { $objC->storeCommentActivityId($cid, $caid); } } } } } } // Go back to project listing App::redirect(Route::url('index.php?option=' . $this->_option . '&task=browse&reviewer=' . $reviewer . '&filterby=' . $filterby)); return; } else { // Instantiate a new view $this->view->setLayout('review'); // Output HTML $this->view->reviewer = $reviewer; $this->view->ajax = Request::getInt('ajax', 0); $this->view->title = $this->title; $this->view->option = $this->_option; $this->view->model = $this->model; $this->view->params = $params; $this->view->config = $this->config; $this->view->database = $this->database; $this->view->action = $action; $this->view->filterby = $filterby; $this->view->uid = User::get('id'); $this->view->msg = $this->_getNotifications('success'); if ($this->getError()) { $this->view->setError($this->getError()); } $this->view->display(); } }