public function handleRequest($command, $date = NULL)
 {
     $events = Event::find($command, $date);
     if (empty($events)) {
         throw new Exception("Nothing found");
     }
     $formattedEvents = Event::format($events);
     render('event', array('events' => $formattedEvents));
 }
 public function destroy($id)
 {
     // delete
     $event = Event::find($id);
     $event->delete();
     // redirect
     Session::flash('message', 'Successfully deleted the event!');
     return Redirect::to('events');
 }
    function index() {
        $recent_events = Event::find()->where(array('created_at >= NOW() - INTERVAL 1 WEEK'))->order('created_at DESC')->all();

        $find_news = News::find()
            ->order(array('weight ASC', 'updated_at DESC'))
            ->limit(5);

        $this->render(array(
            'recent_events' => $recent_events,
            'news' => $find_news->all(),
        ));
    }
Example #4
0
 function create()
 {
     $types = Event::getTypes();
     RoutingEngine::getSmarty()->assign("event_types", $types);
     if (isset($_GET["eid"])) {
         $eid = $_GET["eid"];
         $event = Event::find($eid);
         if ($event->uid == User::$current_user->uid) {
             RoutingEngine::getSmarty()->assign("event", $event);
         }
     }
 }
 function show($params) {
     $char = Character::find()->where(array('guid' => $params['guid']))->realm($params['rid'])->first();
     $events = Event::find()->where(array('target_class' => 'Character', 'target_dbid' => $params['rid'], 'target_id' => $params['guid']));
     $cheats = CheatLogEntry::find()->realm($params['rid'])->where(array('guid' => $params['guid']));
     if ($char->guid == $params['guid']) {
         $this->render(array(
             'character' => $char,
             'events_count' => $events->count(),
             'cheats_count' => $cheats->count()
         ));
     } else {
         $this->render_error('404');
     }
 }
 function sync_dbid(){
     Event::$per_page = null;
     $events = Event::find()->all();
     foreach($events as $event){
         $target = unserialize($event->target_obj);
         if($target->realm != null && $target->realm->id != $event->target_dbid){
             $event->target_dbid = $target->realm->id;
             echo "missing dbid in event " . $event->id . " - actual: " . $event->target_dbid . " correct: " . $target->realm->id;
             if($event->save())
                 echo " - currected <br>\n";
             else
                 echo " - can't correct <br>\n";
         }
     }
 }
 public function test_belongs_to_returns_null_when_no_record()
 {
     $event = Event::find(6);
     $this->assert_null($event->venue);
 }
 /**
  * Allows a user to cancel an event 
  * 
  */
 public function cancelEventAction()
 {
     $get = Zend_Registry::get('getFilter');
     if (!isset($get->eventId)) {
         throw new Ot_Exception_Input('msg-error-eventIdNotSet');
     }
     $workshop = new Workshop();
     $event = new Event();
     $location = new Location();
     $thisEvent = $event->find($get->eventId);
     if (is_null($thisEvent)) {
         throw new Ot_Exception_Data('msg-error-noEvent');
     }
     $i = new Event_Instructor();
     $where = $i->getAdapter()->quoteInto('eventId = ?', $get->eventId);
     $results = $i->fetchAll($where);
     $currentInstructors = array();
     foreach ($results as $r) {
         $currentInstructors[] = $r->accountId;
     }
     if (!$this->_helper->hasAccess('view-all-instructor-pages') && !in_array(Zend_Auth::getInstance()->getIdentity()->accountId, $currentInstructors)) {
         throw new Ot_Exception_Access('msg-error-noWorkshopAccess');
     }
     $thisEvent = $thisEvent->toArray();
     $thisEvent['startTime'] = strftime('%l:%M %p', strtotime($thisEvent['startTime']));
     $thisEvent['endTime'] = strftime('%l:%M %p', strtotime($thisEvent['endTime']));
     $thisEvent['location'] = $location->find($thisEvent['locationId'])->toArray();
     $thisEvent['workshop'] = $workshop->find($thisEvent['workshopId'])->toArray();
     $this->view->event = $thisEvent;
     $form = Ot_Form_Template::delete('eventDelete', 'workshop-schedule-cancelEvent:cancel');
     if ($this->_request->isPost() && $form->isValid($_POST)) {
         $dba = $event->getAdapter();
         $dba->beginTransaction();
         $where = $dba->quoteInto('eventId = ?', $get->eventId);
         $data = array('status' => 'canceled');
         try {
             $result = $event->update($data, $where);
         } catch (Exception $e) {
             $dba->rollback();
             throw $e;
         }
         $attendee = new Event_Attendee();
         try {
             $attendee->update($data, $where);
         } catch (Exception $e) {
             $dba->rollback();
             throw $e;
         }
         $dba->commit();
         $this->_helper->flashMessenger->addMessage('msg-info-eventCanceled');
         $date = explode('-', $thisEvent['date']);
         $this->_helper->redirector->gotoUrl('/workshop/schedule?startYear=' . $date[0] . '&startMonth=' . (int) $date[1]);
     }
     $this->_helper->pageTitle('workshop-schedule-cancelEvent:title');
     $this->view->form = $form;
 }
 public function v152()
 {
     // Regenerate cache
     Cache::clear(false);
     // Timezone
     $this->Setting->setOption('timezone', 'Europe/Paris');
     // Update events registration end date
     App::uses('Event', 'Model');
     $EventModel = new Event();
     $params = array();
     $params['recursive'] = -1;
     $params['fields'] = array('id', 'time_start', 'time_inscription');
     $params['conditions']['time_inscription'] = null;
     if ($events = $EventModel->find('all', $params)) {
         foreach ($events as $event) {
             $EventModel->query("UPDATE " . $EventModel->tablePrefix . "events SET time_inscription='" . $event['Event']['time_start'] . "' WHERE id = " . $event['Event']['id']);
         }
     }
 }
 public function test_eager_loading_clones_related_objects()
 {
     $events = Event::find(array(2, 3), array('include' => array('venue')));
     $venue = $events[0]->venue;
     $venue->name = "new name";
     $this->assert_equals($venue->id, $events[1]->venue->id);
     $this->assert_not_equals($venue->name, $events[1]->venue->name);
     $this->assert_not_equals(spl_object_hash($venue), spl_object_hash($events[1]->venue));
 }
 public function award()
 {
     if ($this->post) {
         $achievement = $this->load_achievement($this->PostData('achievement_id'));
         $user_temp = $this->PostData('users');
         if (!is_array($user_temp)) {
             $user_temp = explode(',', $user_temp);
         }
         $error_on = array();
         $success = 0;
         foreach ($user_temp as $name_temp) {
             $user_id = mysql_real_escape_string($name_temp);
             $user = User::find_by_id($user_id);
             if ($user) {
                 if ($achievement->award($user, $this->PostData("category_id"))) {
                     $success++;
                 } else {
                     $error_on[] = $name;
                 }
             } else {
                 $error_on[] = $name;
             }
         }
         if (count($user_temp) == 1) {
             if ($success == 1) {
                 Site::InstantFlash("notice", "{$user->nickname} has been awarded {$achievement->name}");
             } else {
                 Site::InstantFlash("error", "Unable to award achievement");
             }
         } else {
             if ($success == 0) {
                 Site::InstantFlash("error", "Unable to award achievements to any of the users listed");
             } elseif (count($error_on) > 0) {
                 Site::InstantFlash("error", "Awarded achievement to {$success} user" . ($success != 1 ? "s" : "") . ", failed to award to " . implode(", ", $error_on));
             } else {
                 Site::InstantFlash("notice", "Awarded achievements to all users listed.");
             }
         }
     }
     $filters = array();
     $pageQuery = '';
     if ($this->GetData('query')) {
         $pageQuery = $this->GetData('query');
         $query = mysql_real_escape_string($this->GetData('query'));
         $filters[] = "users.nickname LIKE '%{$query}%'";
     }
     $filter = implode('AND', $filters);
     $achievement_id = null;
     if ($this->GetData('achievement_id')) {
         $achievement_id = $this->GetData('achievement_id');
     }
     $page = 1;
     if ($this->GetData('page')) {
         $page = $this->GetData('page');
     }
     $users = User::paginate($filter, 'users.nickname ASC', $page, 50);
     $achievements = Achievement::find_all("", "achievements.created_at ASC");
     $achlist = array();
     foreach ($achievements as $ach) {
         $achlist[$ach->id] = "{$ach->id}. {$ach->name}";
     }
     // Yay - Magic Numbers!
     $category_id = 11;
     $categories = array();
     $all_categories = array();
     $all_categories = AchievementCategory::find_all();
     foreach ($all_categories as $category) {
         $event = Event::find("achievement_category_id={$category->id}");
         if (!$event || $event->check_user(Site::CurrentUser()) && $event->display_achievements) {
             $categories[$category->id] = $category->category_name;
             if ($category->default_category) {
                 $category_id = $category->id;
             }
         }
     }
     if ($this->GetData('category_id')) {
         $category_id = $this->GetData('category_id');
     }
     $this->assign("achievements", $achlist);
     $this->assign("categories", $categories);
     $this->assign("category_id", $category_id);
     $this->assign("achievement_id", $achievement_id);
     $this->assign("users", $users);
     $this->assign('pagequery', $pageQuery);
     $this->title = "Award Achievement";
     $this->render("achievement/award.tpl");
 }
Example #12
0
         $row = Group::find($id);
         $row->delete();
     } else {
         // Set error.
         $error = "CantDeleteGroup";
         $message = "The group could not be deleted since they are persons that belong to them";
         $statusCode = 422;
     }
 }
 // Event.
 if ($type == "event") {
     // Verify if the event is used by assistances.
     $count = Assistance::count(array('conditions' => 'event_id = ' . $id));
     if ($count <= 0) {
         // Delete event.
         $row = Event::find($id);
         $row->delete();
     } else {
         // Set error.
         $error = "CantDeleteEvent";
         $message = "The event could not be deleted since some assistance lists are linked to him";
         $statusCode = 422;
     }
 }
 // Person.
 if ($type == "person") {
     // Verify if the person is used by assistances.
     $count = Assistance::count(array('conditions' => 'person_id = ' . $id));
     if ($count <= 0) {
         // Delete person.
         $row = Person::find($id);
Example #13
0
<?php

$res->currentPage = isset($currentPage) ? $currentPage : 1;
$res->limit = $args['limit'] = isset($limit) ? $limit : 20;
$args['offset'] = ($res->currentPage - 1) * $args['limit'];
$args['order'] = isset($order) ? $order : 'updated_at desc';
if (isset($event) && is_numeric($event) && Event::find($event)->user_id == $res->membre->id) {
    $res->events = array(Event::find($event));
} else {
    $res->events = $res->membre->id == $res->user->id ? $res->membre->getEvents(true, $args) : $res->membre->getEvents(false, $args);
    $res->total = $res->membre->id == $res->user->id ? $res->membre->getEvents(true)->count : $res->membre->getEvents(false)->count;
}
$res->useTemplate();
Example #14
0
 /**
  * Allows a user to cancel their reservation for an event.
  *
  */
 public function cancelAction()
 {
     $get = Zend_Registry::get('getFilter');
     if (!isset($get->eventId)) {
         throw new Ot_Exception_Input('msg-error-eventIdNotSet');
     }
     $event = new Event();
     $location = new Location();
     $workshop = new Workshop();
     $instructor = new Event_Instructor();
     $attendee = new Event_Attendee();
     $thisEvent = $event->find($get->eventId);
     if (is_null($thisEvent)) {
         throw new Ot_Exception_Data('msg-error-noEvent');
     }
     $this->view->event = $thisEvent->toArray();
     $status = $event->getStatusOfUserForEvent(Zend_Auth::getInstance()->getIdentity()->accountId, $thisEvent->eventId);
     if ($status != 'waitlist' && $status != 'attending') {
         throw new Ot_Exception_Data('msg-error-notAttending');
     }
     $this->view->status = $status;
     $this->view->reservationCancelable = $event->isReservationCancelable($thisEvent->eventId);
     $thisLocation = $location->find($thisEvent->locationId);
     if (is_null($thisLocation)) {
         throw new Ot_Exception_Data('msg-error-noLocation');
     }
     $this->view->location = $thisLocation->toArray();
     $thisWorkshop = $workshop->find($thisEvent->workshopId);
     if (is_null($thisWorkshop)) {
         throw new Ot_Exception_Data('msg-error-noWorkshop');
     }
     $this->view->workshop = $thisWorkshop->toArray();
     $instructors = $instructor->getInstructorsForEvent($thisEvent->eventId);
     $inst = array();
     foreach ($instructors as $i) {
         $inst[] = $i['firstName'] . ' ' . $i['lastName'];
     }
     $this->view->instructors = $inst;
     $events = $event->getEvents($thisWorkshop->workshopId, null, null, time(), null, 'open')->toArray();
     $newEvents = array();
     foreach ($events as $e) {
         if ($e['eventId'] != $thisEvent->eventId) {
             $e['status'] = $event->getStatusOfUserForEvent(Zend_Auth::getInstance()->getIdentity()->accountId, $e['eventId']);
             $e['workshop'] = $thisWorkshop->toArray();
             $newEvents[] = $e;
         }
     }
     $this->view->events = $newEvents;
     $form = Ot_Form_Template::delete('cancelReservation', 'workshop-signup-cancel:cancel', 'workshop-signup-cancel:keep');
     if ($this->_request->isPost() && $form->isValid($_POST)) {
         $instructorNames = array();
         $instructorEmails = array();
         foreach ($instructors as $i) {
             $instructorNames[] = $i['firstName'] . ' ' . $i['lastName'];
             $instructorEmails[] = $i['emailAddress'];
         }
         $attendee->cancelReservation(Zend_Auth::getInstance()->getIdentity()->accountId, $thisEvent->eventId);
         $startDt = strtotime($thisEvent->date . ' ' . $thisEvent->startTime);
         $endDt = strtotime($thisEvent->date . ' ' . $thisEvent->endTime);
         $data = array('workshopName' => $thisWorkshop->title, 'workshopDate' => date('m/d/Y', $startDt), 'workshopStartTime' => date('g:i a', $startDt), 'workshopEndTime' => date('g:i a', $endDt), 'workshopMinimumEnrollment' => $thisEvent->minSize, 'locationName' => $thisLocation->name, 'locationAddress' => $thisLocation->address, 'instructorNames' => implode(', ', $instructorNames), 'instructorEmails' => implode(', ', $instructorEmails), 'studentEmail' => Zend_Auth::getInstance()->getIdentity()->emailAddress, 'studentName' => Zend_Auth::getInstance()->getIdentity()->firstName . ' ' . Zend_Auth::getInstance()->getIdentity()->lastName, 'studentUsername' => Zend_Auth::getInstance()->getIdentity()->username);
         $this->_helper->flashMessenger->addMessage($this->view->translate('msg-info-canceled', $thisWorkshop->title));
         $trigger = new Ot_Trigger();
         $trigger->setVariables($data);
         $trigger->dispatch('Event_Cancel_Reservation');
         $account = new Ot_Account();
         if ($status != 'waitlist') {
             $waiting = $attendee->getAttendeesForEvent($thisEvent->eventId, 'waitlist');
             if (count($waiting) != 0) {
                 $newAccount = $account->find($waiting[0]['accountId']);
                 if (!is_null($newAccount)) {
                     $attendee->makeReservation($newAccount->accountId, $thisEvent->eventId);
                     $data['studentEmail'] = $newAccount->emailAddress;
                     $data['studentName'] = $newAccount->firstName . ' ' . $newAccount->lastName;
                     $data['studentUsername'] = $newAccount->username;
                     $trigger = new Ot_Trigger();
                     $trigger->setVariables($data);
                     $trigger->dispatch('Event_Waitlist_To_Attending');
                 }
             }
         }
         $this->_redirect('/');
     }
     $this->view->form = $form;
     $this->view->layout()->setLayout('twocolumn');
     $this->view->layout()->rightContent = $this->view->render('signup/right.phtml');
 }
Example #15
0
 public function afterSave($created, $options)
 {
     // Mark the user as absent in all his games
     // Get characters, so we can also have the game list
     App::uses('Character', 'Model');
     $Character = new Character();
     $params = array();
     $params['recursive'] = -1;
     $params['fields'] = array('Character.id', 'Character.game_id', 'Character.level', 'Character.default_role_id');
     $params['group'] = 'game_id';
     $params['conditions']['user_id'] = $this->data['Availability']['user_id'];
     $params['conditions']['main'] = 1;
     if ($characters = $Character->find('all', $params)) {
         App::uses('Event', 'Model');
         $Event = new Event();
         $Event->Behaviors->detach('Commentable');
         App::uses('EventsCharacter', 'Model');
         $EventsCharacter = new EventsCharacter();
         foreach ($characters as $character) {
             // Get events for this period
             $params = array();
             $params['recursive'] = -1;
             $params['fields'] = array('Event.id');
             $params['conditions']['game_id'] = $character['Character']['game_id'];
             $params['conditions']['character_level <='] = $character['Character']['level'];
             $params['conditions']['time_start >='] = $this->data['Availability']['start'] . ' 00:00:00';
             $params['conditions']['time_start <='] = $this->data['Availability']['end'] . ' 23:59:59';
             if ($events = $Event->find('all', $params)) {
                 foreach ($events as $event) {
                     // If already registered to this event, update it
                     $paramsEventsCharacter = array();
                     $paramsEventsCharacter['recursive'] = -1;
                     $paramsEventsCharacter['fields'] = array('id');
                     $paramsEventsCharacter['conditions']['event_id'] = $event['Event']['id'];
                     $paramsEventsCharacter['conditions']['user_id'] = $this->data['Availability']['user_id'];
                     if ($eventCharacter = $EventsCharacter->find('first', $paramsEventsCharacter)) {
                         $eventCharacter['EventsCharacter']['status'] = 0;
                         $EventsCharacter->save($eventCharacter['EventsCharacter']);
                     } else {
                         $toSave = array();
                         $toSave['event_id'] = $event['Event']['id'];
                         $toSave['user_id'] = $this->data['Availability']['user_id'];
                         $toSave['character_id'] = $character['Character']['id'];
                         $toSave['raids_role_id'] = $character['Character']['default_role_id'];
                         $toSave['comment'] = $this->data['Availability']['comment'];
                         $toSave['status'] = 0;
                         $EventsCharacter->__add($toSave);
                     }
                 }
             }
         }
     }
     return true;
 }
Example #16
0
     echo 'Missing event ID.';
 } else {
     if (!isUserLoggedIn()) {
         http_response_code(403);
         echo 'You need to login to edit this event.';
     } else {
         if (!validateCSRFToken($_POST["csrf_token"])) {
             http_response_code(403);
             echo 'Invalid CSRF token.';
         } else {
             $event_id = $_POST["id"];
             if (!canSeeEvent(getUserID(), $event_id)) {
                 http_response_code(403);
                 echo 'You do not have access to edit this event.';
             } else {
                 $event = Event::find($event_id);
                 if (isset($_POST['name'])) {
                     $event->setName($_POST['name']);
                 }
                 if (isset($_POST['date'])) {
                     $event->setDate($_POST['date']);
                 }
                 if (isset($_POST['description'])) {
                     $event->setDescription($_POST['description']);
                 }
                 if (isset($_POST['public'])) {
                     $event->setPublic($_POST['public']);
                 }
                 $event->update();
                 header('Content-Type: application/json');
                 echo json_encode($event->expose());
Example #17
0
<?php 
include 'includes/header.php';
$allEvents = Event::find('all');
?>
<div class="col-sm-9  col-md-10">
	<?php 
if (isset($_SESSION['event'])) {
    ?>
		<?php 
    $thisEvent = Event::find_by_eventid($_SESSION['event']);
    ?>
		<h2>Now managing: <?php 
    echo $thisEvent->name;
    ?>
 </h2>
		<h2>Change Event:</h2>
		<form action="/includes/modules/eventManagement/events.php?selectEvent" class="form-horizontal" method="POST">
	  	<select class="form-control" name="eventID" required>
	  		<option value>Please Select</option>
	  		<?php 
    foreach ($allEvents as $thisEvent) {
        echo '<option value="' . $thisEvent->eventid . '">' . $thisEvent->name . '</option>';
    }
    ?>
	  	</select>
	    <button type="submit" name="action" class="btn btn-primary">Select</button>
    </form>
	<?php 
} else {
    ?>
 public static function edit($id)
 {
     self::check_logged_in();
     $Event = Event::find($id);
     View::make('Event/edit.html', array('attributes' => $Event));
 }
 private function sendStats()
 {
     $stats = array();
     // Website
     $stats['Website']['url'] = Router::url('/', true);
     $stats['Website']['version'] = Configure::read('mushraider.version');
     $stats['Website']['php'] = phpversion();
     $stats['Website']['lang'] = Configure::read('Settings.language');
     // Events
     App::uses('Event', 'Model');
     $EventModel = new Event();
     $params = array();
     $params['recursive'] = -1;
     $params['order'] = array('time_start ASC');
     if ($firstEvent = $EventModel->find('first', $params)) {
         $stats['Event']['first'] = $firstEvent['Event']['time_start'];
     } else {
         $stats['Event']['first'] = null;
     }
     $params['conditions']['time_start <='] = date('Y-m-d');
     $params['order'] = array('time_start DESC');
     if ($lastEvent = $EventModel->find('first', $params)) {
         $stats['Event']['last'] = $lastEvent['Event']['time_start'];
     } else {
         $stats['Event']['last'] = null;
     }
     $params = array();
     $params['recursive'] = -1;
     $params['conditions']['time_start <='] = date('Y-m-d');
     $countEvents = $EventModel->find('count', $params);
     $stats['Event']['total'] = $countEvents;
     // Reports
     App::uses('Report', 'Model');
     $ReportModel = new Report();
     $params = array();
     $params['recursive'] = -1;
     $countReports = $ReportModel->find('count', $params);
     $stats['Report']['total'] = $countReports;
     // Users
     App::uses('User', 'Model');
     $UserModel = new User();
     $params = array();
     $params['recursive'] = -1;
     $countUsers = $UserModel->find('count', $params);
     $stats['User']['total'] = $countUsers;
     // Characters
     App::uses('Character', 'Model');
     $CharacterModel = new Character();
     $params = array();
     $params['recursive'] = -1;
     $countCharacters = $CharacterModel->find('count', $params);
     $stats['Character']['total'] = $countCharacters;
     // Games
     App::uses('Game', 'Model');
     $GameModel = new Game();
     $params = array();
     $params['recursive'] = -1;
     if ($games = $GameModel->find('all', $params)) {
         foreach ($games as $game) {
             $stats['Game'][$game['Game']['slug']]['title'] = $game['Game']['title'];
             $stats['Game'][$game['Game']['slug']]['imported'] = $game['Game']['import_modified'] > 0 ? 1 : 0;
             $params = array();
             $params['recursive'] = -1;
             $params['conditions']['game_id'] = $game['Game']['id'];
             $params['group'] = array('user_id');
             $countCharacters = $CharacterModel->find('count', $params);
             $stats['Game'][$game['Game']['slug']]['players'] = $countCharacters;
         }
     }
     // Bridge
     $bridgeSetting = json_decode($this->SettingModel->getOption('bridge'));
     $stats['Bridge']['enabled'] = !empty($bridgeSetting) && $bridgeSetting->enabled ? 1 : 0;
     // Widgets
     App::uses('Widget', 'Model');
     $WidgetModel = new Widget();
     $params = array();
     $params['recursive'] = -1;
     if ($widgets = $WidgetModel->find('all', $params)) {
         foreach ($widgets as $widget) {
             if (!isset($stats['Widget'][$widget['Widget']['controller']])) {
                 $stats['Widget'][$widget['Widget']['controller']]['total'] = 1;
             } else {
                 $stats['Widget'][$widget['Widget']['controller']]['total']++;
             }
         }
     }
     App::uses('HttpSocket', 'Network/Http');
     $this->http = new HttpSocket();
     $this->http->post('http://stats.mushraider.com/acquire', $stats);
 }
 /**
  * Displays the results of an evaluation as long as the user requesting the
  * page is an instructor of the event.
  *
  */
 public function evaluationResultsAction()
 {
     $get = Zend_Registry::get('getFilter');
     if (!isset($get->eventId)) {
         throw new Ot_Exception_Input('msg-error-eventIdNotSet');
     }
     $event = new Event();
     $thisEvent = $event->find($get->eventId);
     if (is_null($thisEvent)) {
         throw new Ot_Exception_Data('msg-error-noEvent');
     }
     $this->view->event = $thisEvent->toArray();
     $workshop = new Workshop();
     $thisWorkshop = $workshop->find($thisEvent->workshopId);
     if (is_null($thisWorkshop)) {
         throw new Ot_Exception_Data('msg-error-noWorkshop');
     }
     $this->view->workshop = $thisWorkshop->toArray();
     $location = new Location();
     $thisLocation = $location->find($thisEvent->locationId);
     if (is_null($thisLocation)) {
         throw new Ot_Exception_Data('msg-error-noLocation');
     }
     $this->view->location = $thisLocation->toArray();
     $instructor = new Event_Instructor();
     $instructors = $instructor->getInstructorsForEvent($thisEvent->eventId);
     $instructorList = array();
     foreach ($instructors as $i) {
         $instructorList[] = $i['firstName'] . ' ' . $i['lastName'];
     }
     $this->view->instructors = $instructorList;
     $this->_checkValidViewer($instructors);
     if ($thisEvent['evaluationType'] == 'custom') {
         // get the evaluationId from the eventId
         $evaluation = new Evaluation();
         $where = $evaluation->getAdapter()->quoteInto('eventId = ?', $thisEvent->eventId);
         $evaluations = $evaluation->fetchAll($where);
         if ($evaluations->count() == 0) {
             $this->view->noEvaluationsYet = true;
         }
         $this->view->totalEvaluations = $evaluations->count();
         $ca = new Ot_Custom();
         $questions = $ca->getAttributesForObject('evaluations');
         foreach ($questions as &$q) {
             $q['options'] = $ca->convertOptionsToArray($q['options']);
             $answers = array();
             foreach ($evaluations as $e) {
                 $tmpAnswers = $ca->getData($q['objectId'], $e->evaluationId);
                 $tmp = array();
                 foreach ($tmpAnswers as $ta) {
                     $tmp[$ta['attribute']['attributeId']] = $ta['value'];
                 }
                 $answers[] = $tmp;
             }
             if ($q['type'] == 'ranking' || $q['type'] == 'select' || $q['type'] == 'radio') {
                 foreach ($q['options'] as $value) {
                     $answerCount = 0;
                     foreach ($answers as $a) {
                         if ($a[$q['attributeId']] == $value) {
                             $answerCount++;
                         }
                     }
                     $q['results'][] = array('answerLabel' => $value, 'answerCount' => $answerCount);
                 }
             } else {
                 foreach ($answers as $a) {
                     $q['results'][] = $a[$q['attributeId']];
                 }
             }
         }
         $this->view->evaluationResults = $questions;
     } elseif ($thisEvent['evaluationType'] == 'google') {
         $evaluationKeys = new Evaluation_Key();
         $keys = $evaluationKeys->find($get->eventId);
         if (is_null($keys)) {
             throw new Ot_Exception_Data('msg-error-noFormKey');
         }
         $this->view->keys = $keys->toArray();
     }
     $this->view->headScript()->appendFile($this->view->baseUrl() . '/scripts/jquery.gchart.min.js');
 }
Example #21
0
 public function cancelReservation($accountId, $eventId)
 {
     $event = new Event();
     $status = $event->getStatusOfUserForEvent($accountId, $eventId);
     if ($status == 'restricted') {
         throw new Ot_Exception_Data('Reservation not made because class is restricted');
     }
     if ($status == 'instructor') {
         throw new Ot_Exception_Data('Reservation not made because user is an instructor for this class');
     }
     if ($status == '') {
         throw new Ot_Exception_Data('User is not on the role for this class');
     }
     $thisEvent = $event->find($eventId);
     $eventTime = strtotime($thisEvent->date . ' ' . $thisEvent->startTime);
     if ($eventTime < time()) {
         throw new Ot_Exception_Data('The signup for this class is closed');
     }
     $dba = $this->getAdapter();
     $inTransaction = false;
     try {
         $dba->beginTransaction();
     } catch (Exception $e) {
         $inTransaction = true;
     }
     $data = array('eventId' => $eventId, 'accountId' => $accountId, 'status' => 'canceled');
     try {
         $this->update($data, null);
     } catch (Exception $e) {
         if (!$inTransaction) {
             $dba->rollBack();
         }
         throw $e;
     }
     $data = array('eventId' => $eventId);
     if ($status == 'attending') {
         $data['roleSize'] = $thisEvent->roleSize - 1;
     } else {
         $data['waitlistTotal'] = $thisEvent->waitlistTotal - 1;
     }
     try {
         $event->update($data, null);
     } catch (Exception $e) {
         if (!$inTransaction) {
             $dba->rollBack();
         }
         throw $e;
     }
     if (!$inTransaction) {
         $dba->commit();
     }
     return $status;
 }
 public function testGh40RelationshipsWithJoinsAliasesTableNameInConditions()
 {
     $event = Event::find(1, array('joins' => array('venue')));
     $this->assertEquals($event->id, $event->venue->id);
 }
Example #23
0
 public function registerUser($id)
 {
     $user = Auth::user();
     if (!$user->eventsAttending->contains($id)) {
         $user->eventsAttending()->attach($id);
         $event = Event::find($id);
         $notification = new Notification();
         $notification->notification_type = 'registered';
         $notification->notified_id = $event->user_id;
         $notification->notifier_id = Auth::id();
         $event->notification()->save($notification);
     }
     Flash::message('You a now registered for this event');
     return Redirect::action('EventsController@show', $id);
 }
Example #24
0
 public function delete($id)
 {
     $event = Event::find($id);
     $event->delete();
 }
Example #25
0
 function read()
 {
     return $this->render(["event" => Event::find($this->params["id"])]);
 }
 public function test_save_resets_changed_attributes()
 {
     $event = Event::find(1);
     $event->type = "Groovy Music";
     $event->save();
     $changed_attributes = $event->changed_attributes();
     $this->assert_true(empty($changed_attributes));
 }
 /**
  * Handles the evaluation for an event.  Shows the user the evaluation and
  * saves the data from the evaluation.
  *
  */
 public function indexAction()
 {
     $get = Zend_Registry::get('getFilter');
     if (!isset($get->eventId)) {
         throw new Ot_Exception_Input('msg-error-eventIdNotSet');
     }
     $event = new Event();
     $eu = new Evaluation_User();
     $evaluation = new Evaluation();
     $thisEvent = $event->find($get->eventId);
     if (is_null($thisEvent)) {
         throw new Ot_Exception_Data('msg-error-noEvent');
     }
     $this->view->event = $thisEvent->toArray();
     $thisAccount = Zend_Auth::getInstance()->getIdentity();
     $status = $event->getStatusOfUserForEvent($thisAccount->accountId, $thisEvent->eventId);
     if ($status == "instructor") {
         throw new Ot_Exception_Access('msg-error-cannotEval');
     }
     if ($status != "attending") {
         throw new Ot_Exception_Access('msg-error-notAttended');
     }
     $config = Zend_Registry::get('config');
     $endDt = strtotime($thisEvent->date . " " . $thisEvent->endTime);
     if (time() > $endDt + $config->user->numHoursEvaluationAvailability->val * 3600) {
         throw new Ot_Exception_Access('msg-error-evalEnded');
     }
     if ($eu->hasCompleted($thisAccount->accountId, $thisEvent->eventId)) {
         throw new Ot_Exception_Access('msg-error-alreadyEval');
     }
     $workshop = new Workshop();
     $thisWorkshop = $workshop->find($thisEvent->workshopId);
     if (is_null($thisWorkshop)) {
         throw new Ot_Exception_Data('msg-error-noWorkshop');
     }
     $this->view->workshop = $thisWorkshop->toArray();
     $instructor = new Event_Instructor();
     $instructors = $instructor->getInstructorsForEvent($thisEvent->eventId);
     $inst = array();
     foreach ($instructors as $i) {
         $inst[] = $i['firstName'] . ' ' . $i['lastName'];
     }
     $this->view->instructors = $inst;
     // lookup the location of the event
     $location = new Location();
     $thisLocation = $location->find($thisEvent->locationId);
     if (is_null($thisLocation)) {
         throw new Ot_Exception_Data('msg-error-noLocation');
     }
     $this->view->location = $thisLocation->toArray();
     if ($thisEvent->evaluationType == 'custom') {
         $form = $evaluation->form();
         $this->view->form = $form;
     }
     if ($this->_request->isPost()) {
         if ($thisEvent->evaluationType == 'custom') {
             if ($form->isValid($_POST)) {
                 $custom = new Ot_Custom();
                 $attributes = $custom->getAttributesForObject('evaluations');
                 $data = array();
                 foreach ($attributes as $a) {
                     $data[$a['attributeId']] = is_null($form->getValue('custom_' . $a['attributeId'])) ? '' : $form->getValue('custom_' . $a['attributeId']);
                 }
                 // custom attributes is the custom array that will be save by the CustomAttributes model
                 $evaluation->saveEvaluation($thisEvent->eventId, $thisAccount->accountId, $data);
                 $this->_helper->flashMessenger->addMessage('msg-info-evalThanks');
                 $this->_redirect('/');
             }
         } elseif ($thisEvent->evaluationType == 'google' && isset($_POST['googleSubmit'])) {
             $eu = new Evaluation_User();
             $dba = $eu->getAdapter();
             $dba->beginTransaction();
             $data = array('eventId' => $get->eventId, 'accountId' => $thisAccount->accountId);
             try {
                 $eu->insert($data);
             } catch (Exception $e) {
                 $dba->rollBack();
                 throw $e;
             }
             $dba->commit();
             $this->_helper->flashMessenger->addMessage('msg-info-evalThanks');
             $this->_redirect('/');
         }
     }
     if ($thisEvent->evaluationType == 'google') {
         $evaluationKeys = new Evaluation_Key();
         $keys = $evaluationKeys->find($get->eventId);
         if (is_null($keys)) {
             throw new Ot_Exception_Data('msg-error-noFormKey');
         }
         $this->view->keys = $keys->toArray();
     }
     $this->_helper->pageTitle('workshop-evaluate-index:title');
 }
 public function test_gh_40_relationships_with_joins_aliases_table_name_in_conditions()
 {
     $event = Event::find(1, array('joins' => array('venue')));
     $this->assert_equals($event->id, $event->venue->id);
 }
Example #29
0
        } else {
            // Return error message.
            ApiUtils::returnError($app, 'UserNotLogged');
        }
    } catch (Exception $e) {
        // An exception ocurred. Return an error message.
        ApiUtils::handleException($app, $e);
    }
});
// Service for get all persons from a group.
$app->get('/assistanceList/:groupId/:eventId/:date', function ($groupId, $eventId, $date) use($app) {
    try {
        // Verify that the user is logged.
        if (isset($_SESSION['user'])) {
            // Get list of persons in the group.
            $now = new DateTime();
            $rows = ApiUtils::rowsToMaps(Assistance::find_by_sql("select * from get_assistance(" . $_SESSION['user']['id'] . "," . $groupId . "," . $eventId . "," . "'" . ($date !== 'today' ? $date : $now->format('Y-m-d')) . "')"));
            // Get name of event and group.
            $event = ApiUtils::rowToMap(Event::find($eventId));
            $group = ApiUtils::rowToMap(Group::find($groupId));
            // Return result.
            echo json_encode(array("rows" => $rows, "date" => $date !== 'today' ? $date : $now->format('Y-m-d'), "event" => $event, "group" => $group, "error" => null));
        } else {
            // Return error message.
            ApiUtils::returnError($app, 'UserNotLogged');
        }
    } catch (Exception $e) {
        // An exception ocurred. Return an error message.
        ApiUtils::handleException($app, $e);
    }
});