Example #1
0
 public function post(\Request $request)
 {
     $factory = new Factory();
     $view = new \View\JsonView(array('success' => true));
     if (!$request->isVar('command')) {
         throw new \Exception('Bad command');
     }
     switch ($request->getVar('command')) {
         case 'ban':
             $factory->ban($request->getVar('id'), $request->getVar('reason'));
             break;
         case 'unban':
             $factory->unban($request->getVar('id'));
             break;
         case 'ineligible':
             $factory->ineligible($request->getVar('id'), $request->getVar('reason'));
             break;
         case 'eligible':
             $factory->eligible($request->getVar('id'));
             break;
         case 'delete':
             $factory->delete($request->getVar('id'));
             break;
         case 'assign':
             if (!$this->assign()) {
                 $view = new \View\JsonView(array('success' => false));
             }
             break;
         default:
             throw new \Exception('Bad command:' . $request->getVar('command'));
     }
     $response = new \Response($view);
     return $response;
 }
Example #2
0
 public function post(\Request $request)
 {
     $factory = new Factory();
     $view = new \View\JsonView(array('success' => true));
     if (!$request->isVar('command')) {
         throw new \Exception('Bad command');
     }
     switch ($request->getVar('command')) {
         case 'chooseWinners':
             $view = $this->chooseWinners();
             break;
         case 'complete':
             $factory->completeGame();
             break;
         case 'notify':
             $view = $view = new \View\JsonView(array('sent' => $factory->notify()));
             break;
         case 'completeLottery':
             $factory->completeLottery();
             break;
         case 'pickup':
             $this->postPickUp();
             break;
         default:
             throw new \Exception('Bad command:' . $request->getVar('command'));
     }
     $response = new \Response($view);
     return $response;
 }
Example #3
0
 public function post(\Request $request)
 {
     $factory = new Factory();
     $view = new \View\JsonView(array('success' => true));
     if (!$request->isVar('command')) {
         throw new \Exception('Bad command');
     }
     switch ($request->getVar('command')) {
         case 'add':
             $factory->postNew();
             break;
         case 'updateSignupStart':
             $view = new \View\JsonView($this->updateSignupStart());
             break;
         case 'updateSignupEnd':
             $view = new \View\JsonView($this->updateSignupEnd());
             break;
         case 'updatePickupDeadline':
             $view = new \View\JsonView($this->updatePickupDeadline());
             break;
         case 'updateKickoff':
             $view = new \View\JsonView($this->updateKickoff());
             break;
         case 'complete':
             $this->completeGame();
             break;
         default:
             throw new \Exception('Bad command:' . $request->getVar('command'));
     }
     $response = new \Response($view);
     return $response;
 }
Example #4
0
 public function post(\Request $request)
 {
     $factory = new Factory();
     $view = new \View\JsonView(array('success' => true));
     $response = new \Response($view);
     if (!$request->isVar('command')) {
         throw new \Exception('Bad command');
     }
     switch ($request->getVar('command')) {
         case 'add':
             $factory->postNew();
             break;
         case 'deactivate':
             $this->deactivate($factory, filter_input(INPUT_POST, 'lotId', FILTER_SANITIZE_NUMBER_INT));
             break;
         case 'activate':
             $this->activate($factory, filter_input(INPUT_POST, 'lotId', FILTER_SANITIZE_NUMBER_INT));
             break;
         case 'delete':
             Factory::delete(filter_input(INPUT_POST, 'lotId', FILTER_SANITIZE_NUMBER_INT));
             break;
         default:
             throw new \Exception('Bad command:' . $request->getVar('command'));
     }
     return $response;
 }
Example #5
0
 public static function runSchedules(\Request $request)
 {
     if ($request->isVar('hash')) {
         $schedule_hash = $request->getVar('hash');
         if (preg_match('/\\W/', $schedule_hash)) {
             throw new Exception\PulseException('Improper schedule hash');
         }
         $schedule = PulseFactory::pullReadyScheduleByHash($schedule_hash);
         if (empty($schedule)) {
             throw new Exception\PulseException('Schedule hash not found: ' . $schedule_hash);
         } else {
             $schedules[] = $schedule;
         }
     } elseif ($request->isVar('schedule_module')) {
         if ($request->isVar('name')) {
             $schedule_name = $request->getVar('name');
         } else {
             $schedule_name = null;
         }
         $schedule_module = $request->getVar('schedule_module');
         $schedules = PulseFactory::pullReadySchedulesByModule($schedule_module, $schedule_name);
     } elseif ($request->isVar('name')) {
         $schedule_name = $request->getVar('name');
         $schedules = PulseFactory::pullReadySchedulesByName($schedule_name);
     } else {
         $schedules = PulseFactory::pullReadySchedules();
     }
     if (empty($schedules)) {
         exit("No schedules run.\n");
     }
     $completed = PulseFactory::walkSchedules($schedules);
     if (!empty($completed)) {
         foreach ($completed as $sch_id) {
             echo "Schedule #{$sch_id} completed.\n";
         }
     }
     exit;
 }
Example #6
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;
 }
Example #7
0
 public function post(\Request $request)
 {
     $factory = new Factory();
     $view = new \View\JsonView(array('success' => true));
     $response = new \Response($view);
     if (!$request->isVar('command')) {
         throw new \Exception('Bad command');
     }
     switch ($request->getVar('command')) {
         case 'save':
             $factory->postSettings();
             break;
     }
     \PHPWS_Core::reroute('tailgate/Admin/');
 }
Example #8
0
 public function post(\Request $request)
 {
     if (!$request->isVar('command')) {
         throw new \Exception('Unknown Election command');
     }
     $command = $request->getVar('command');
     switch ($command) {
         case 'save':
             $this->save($request);
             break;
     }
     $view = new \View\JsonView(array('success' => true));
     $response = new \Response($view);
     return $response;
 }
Example #9
0
 public function post(\Request $request)
 {
     $factory = new Factory();
     $view = new \View\JsonView(array('success' => true));
     $response = new \Response($view);
     if (!$request->isVar('command')) {
         throw new \Exception('Bad command');
     }
     switch ($request->getVar('command')) {
         case 'createNewAccount':
             $factory->postNewStudent(\Current_User::getId());
             \PHPWS_Core::reroute('tailgate/');
             break;
     }
     return $response;
 }
Example #10
0
 protected function getJsonView($data, \Request $request)
 {
     if (!$request->isVar('command')) {
         throw new \Exception('Unknown Election command');
     }
     $command = $request->getVar('command');
     switch ($command) {
         case 'list':
             $json = self::getVotingData();
             break;
         case 'message':
             $json['message'] = \PHPWS_Settings::get('election', 'postVoteMessage');
             break;
     }
     $view = new \View\JsonView($json);
     return $view;
 }
Example #11
0
 public function post(\Request $request)
 {
     if (!$request->isVar('command')) {
         throw new \Exception('Unknown Vote command');
     }
     $command = $request->getVar('command');
     switch ($command) {
         case 'save':
             $json = Factory::post($this->student);
             break;
         default:
             throw new \Exception('Unknown Vote command');
     }
     $view = new \View\JsonView($json);
     $response = new \Response($view);
     return $response;
 }
Example #12
0
 public function post(\Request $request)
 {
     $factory = new Factory();
     $view = new \View\JsonView(array('success' => true));
     $response = new \Response($view);
     if (!$request->isVar('command')) {
         throw new \Exception('Bad command');
     }
     switch ($request->getVar('command')) {
         case 'reserve':
             $factory->reserve(filter_input(INPUT_POST, 'id', FILTER_SANITIZE_NUMBER_INT), filter_input(INPUT_POST, 'reserved', FILTER_SANITIZE_NUMBER_INT));
             break;
         case 'sober':
             $factory->sober(filter_input(INPUT_POST, 'id', FILTER_SANITIZE_NUMBER_INT), filter_input(INPUT_POST, 'sober', FILTER_SANITIZE_NUMBER_INT));
             break;
     }
     return $response;
 }
Example #13
0
 protected function getJsonView($data, \Request $request)
 {
     if (!$request->isVar('command')) {
         throw new \Exception('Unknown Candidate command');
     }
     $json = array('success' => true);
     $command = $request->getVar('command');
     switch ($command) {
         case 'ticketList':
             $json = Factory::getTicketList(Factory::pullGetInteger('ticketId'));
             break;
         case 'candidateList':
             $json = Factory::getCandidateList(Factory::pullGetInteger('multipleId'));
             break;
     }
     $view = new \View\JsonView($json);
     return $view;
 }
Example #14
0
 public function getHtmlView($data, \Request $request)
 {
     \Layout::addStyle('election', 'style.css');
     if (!$request->isVar('command')) {
         $command = 'show';
     } else {
         $command = $request->getVar('command');
     }
     switch ($command) {
         case 'show':
             $content = $this->showResults(Factory::pullGetInteger('electionId'));
             break;
         default:
             throw new \Http\NotAcceptableException('Unknown Report command');
             break;
     }
     $view = new \View\HtmlView($content);
     return $view;
 }
Example #15
0
 public function post(\Request $request)
 {
     if (!$request->isVar('command')) {
         throw new \Exception('Unknown Ticket command');
     }
     $command = $request->getVar('command');
     switch ($command) {
         case 'save':
             Factory::post();
             break;
         case 'delete':
             Factory::delete(Factory::pullPostInteger('ticketId'));
             break;
         default:
             throw new \Exception('Unknown Ticket command');
     }
     $view = new \View\JsonView(array('success' => true));
     $response = new \Response($view);
     return $response;
 }
Example #16
0
 public function getHtmlView($data, \Request $request)
 {
     if (!$request->isVar('command')) {
         throw new \Exception('Bad command');
     }
     $command = $request->getVar('command');
     switch ($command) {
         case 'pickup':
             $content = Factory::pickup(GameFactory::getCurrentId());
             break;
         case 'winners':
             $content = Factory::winners(GameFactory::getCurrentId());
             break;
         case 'spotReport':
             $content = Factory::spotReport(GameFactory::getCurrentId());
             break;
         default:
             throw new \Exception('Unknown report command');
     }
     $view = new \View\HtmlView($content);
     return $view;
 }
Example #17
0
 public function post(\Request $request)
 {
     $factory = new Factory();
     $view = new \View\JsonView(array('success' => true));
     $response = new \Response($view);
     if (!$request->isVar('command')) {
         throw new \Exception('Bad command');
     }
     switch ($request->getVar('command')) {
         case 'add':
             $factory->postNew();
             break;
         case 'deactivate':
             $factory->deactivate($request->getVar('visitor_id'));
             break;
         case 'update':
             $this->update();
             break;
         default:
             throw new \Exception('Bad command:' . $request->getVar('command'));
     }
     return $response;
 }
Example #18
0
 protected function getJsonView($data, \Request $request)
 {
     if (!$request->isVar('command')) {
         throw new \Exception('Unknown Election command');
     }
     $json = array('success' => true);
     $command = $request->getVar('command');
     switch ($command) {
         case 'list':
             $json = Factory::getList();
             break;
         case 'getElection':
             $json = $this->getElection($request->getVar('electionId'));
             break;
         case 'getElectionTypes':
             echo Factory::getFilterTypes();
             exit;
             break;
         case 'checkConflict':
             $json = Factory::checkForConflict(Factory::pullGetInteger('startDate'), Factory::pullGetInteger('endDate'), Factory::pullGetInteger('electionId'));
             break;
         case 'findVote':
             $json = Factory::getStudentVoteInformation(Factory::pullGetInteger('electionId'), Factory::pullGetInteger('searchFor'));
             break;
     }
     $view = new \View\JsonView($json);
     return $view;
 }
Example #19
0
 private function moveMenu(\Request $request)
 {
     $move_id = $request->getVar('move_id');
     $move_menu = new Menu_Item($move_id);
     if ($request->isVar('next_id')) {
         $next_id = $request->getVar('next_id');
         $next_menu = new Menu_Item($next_id);
     } else {
         $next_id = 0;
     }
     if ($request->isVar('prev_id')) {
         $prev_id = $request->getVar('prev_id');
         $prev_menu = new Menu_Item($prev_id);
     } else {
         $prev_id = 0;
     }
     $db = \Database::newDB();
     $tbl = $db->addTable('menus');
     $queue = $tbl->getField('queue');
     if ($next_id == 0) {
         // moved to end of list
         $exp = $db->getExpression('max(' . $queue . ')', 'max_queue');
         $tbl->addField($exp);
         $last_queue = $db->selectColumn();
         $tbl->addValue('queue', $db->getExpression($queue . ' - 1'));
         $tbl->addFieldConditional('queue', $move_menu->queue, '>');
         $db->update();
         $move_menu->queue = $last_queue;
     } elseif ($prev_id == 0) {
         // moved to beginning of list
         $tbl->addValue('queue', $db->getExpression($queue . ' + 1'));
         $tbl->addFieldConditional('queue', $move_menu->queue, '<');
         $db->update();
         $move_menu->queue = 1;
     } else {
         // moved in the middle of list
         if ($move_menu->queue < $next_menu->queue) {
             $tbl->addValue('queue', $db->getExpression($queue . ' - 1'));
             $tbl->addFieldConditional('queue', $move_menu->queue, '>=');
             $tbl->addFieldConditional('queue', $next_menu->queue, '<');
             $move_menu->queue = $prev_menu->queue;
         } else {
             $tbl->addValue('queue', $db->getExpression($queue . ' + 1'));
             $tbl->addFieldConditional('queue', $next_menu->queue, '>=');
             $tbl->addFieldConditional('queue', $move_menu->queue, '<');
             $move_menu->queue = $next_menu->queue;
         }
         $db->update();
     }
     $move_menu->save();
 }