Example #1
0
 private function getVotingData()
 {
     $election = Factory::getCurrent();
     // If there's no election going on, then return empty data
     if (empty($election)) {
         return array('hasVoted' => false, 'election' => null, 'single' => array(), 'multiple' => array(), 'referendum' => array(), 'unqualified' => array());
     }
     // Check if student has voted already
     $hasVoted = $this->student->hasVoted($election['id']);
     // If already voted, return minimal voting info
     if ($hasVoted) {
         return array('hasVoted' => true, 'election' => $election, 'single' => array(), 'multiple' => array(), 'referendum' => array(), 'unqualified' => array());
     }
     // Assemble the voting data
     $single = \election\Factory\Single::getListWithTickets($election['id']);
     $multiple = \election\Factory\Multiple::getListWithCandidates($election['id']);
     if (!empty($multiple)) {
         $unqualified = \election\Factory\Multiple::filter($multiple, $this->student);
     } else {
         $unqualified = array();
     }
     $referendum = \election\Factory\Referendum::getList($election['id']);
     $voting_data = array('hasVoted' => false, 'election' => $election, 'single' => $single, 'multiple' => $multiple, 'referendum' => $referendum, 'unqualified' => $unqualified, 'supportLink' => \PHPWS_Settings::get('election', 'supportLink'));
     return $voting_data;
 }
Example #2
0
 protected function getJsonView($data, \Request $request)
 {
     if (!$request->isVar('command')) {
         throw new \Exception('Unknown Single ballot command');
     }
     $json = array('success' => true);
     $command = $request->getVar('command');
     switch ($command) {
         case 'list':
             $json = Factory::getList(Factory::pullGetInteger('electionId'));
             break;
     }
     $view = new \View\JsonView($json);
     return $view;
 }