Exemplo n.º 1
0
 /**
  * shows the homepage
  *
  */
 public function indexAction()
 {
     $get = Zend_Registry::get('getFilter');
     if (isset($get->shelf)) {
         $this->view->hideFeature = true;
     }
     $event = new Event();
     $upcoming = $event->getEvents(null, null, null, time(), null, 'open', 5)->toArray();
     $workshop = new Workshop();
     foreach ($upcoming as &$u) {
         $u['workshop'] = $workshop->find($u['workshopId'])->toArray();
         if (Zend_Auth::getInstance()->hasIdentity()) {
             $u['status'] = $event->getStatusOfUserForEvent(Zend_Auth::getInstance()->getIdentity()->accountId, $u['eventId']);
         } else {
             $u['status'] = '';
         }
     }
     $this->view->upcoming = $upcoming;
     $searchTerm = new Search_Term();
     $this->view->popularSearchTerms = $searchTerm->getTopSearchTerms(5)->toArray();
     if (Zend_Auth::getInstance()->hasIdentity()) {
         $this->view->loggedIn = true;
         $myEvents = $event->getEventsForUser(Zend_Auth::getInstance()->getIdentity()->accountId);
         $this->view->myEvents = $myEvents['currentEvents'];
         $this->view->account = Zend_Auth::getInstance()->getIdentity()->toArray();
     }
     $this->_helper->layout->setLayout('homepage');
     $this->view->messages = $this->_helper->flashMessenger->getMessages();
 }
Exemplo n.º 2
0
 /**
  * Allows a user to view the details of a workshop
  *
  */
 public function detailsAction()
 {
     $get = Zend_Registry::get('getFilter');
     if (!isset($get->workshopId)) {
         throw new Ot_Exception_Input('msg-error-workshopIdNotSet');
     }
     $workshop = new Workshop();
     $thisWorkshop = $workshop->find($get->workshopId);
     if (is_null($thisWorkshop)) {
         throw new Ot_Exception_Data('msg-error-noWorkshop');
     }
     $document = new Workshop_Document();
     $this->view->documents = $document->getDocumentsForWorkshop($thisWorkshop->workshopId);
     $tag = new Tag();
     $this->view->tags = $tag->getTagsForAttribute('workshopId', $thisWorkshop->workshopId);
     $event = new Event();
     $events = $event->getEvents($thisWorkshop->workshopId, null, null, time(), null, 'open')->toArray();
     $auth = Zend_Auth::getInstance();
     foreach ($events as &$e) {
         if ($auth->hasIdentity()) {
             $e['status'] = $event->getStatusOfUserForEvent($auth->getIdentity()->accountId, $e['eventId']);
         } else {
             $e['status'] = '';
         }
         $e['workshop'] = $thisWorkshop->toArray();
     }
     $this->view->events = $events;
     $wl = new Workshop_Link();
     $this->view->links = $wl->getLinksForWorkshop($thisWorkshop->workshopId)->toArray();
     $location = new Location();
     $locations = $location->fetchAll();
     $locs = array();
     foreach ($locations as $l) {
         $locs[$l->locationId] = $l->toArray();
     }
     $this->view->locations = $locs;
     $we = new Workshop_Editor();
     $isEditor = false;
     if ($this->_helper->hasAccess('edit-all-workshops')) {
         $isEditor = true;
     } elseif ($auth->hasIdentity()) {
         $isEditor = $we->isEditor($thisWorkshop->workshopId, $auth->getIdentity()->accountId);
     }
     $this->view->acl = array('edit' => $isEditor, 'addDocuments' => $isEditor, 'editDocument' => $isEditor, 'deleteDocument' => $isEditor, 'addLink' => $isEditor, 'deleteLink' => $isEditor, 'editLink' => $isEditor, 'reorderLink' => $isEditor, 'addEvent' => $this->_helper->hasAccess('index', 'workshop_schedule'), 'options' => $this->_helper->hasAccess('options'));
     if ($this->view->acl['edit']) {
         $we = new Workshop_Editor();
         $where = $we->getAdapter()->quoteInto('workshopId = ?', $thisWorkshop->workshopId);
         $results = $we->fetchAll($where);
         $currentEditors = array();
         foreach ($results as $r) {
             $currentEditors[] = $r->accountId;
         }
         if (count($currentEditors) != 0) {
             $account = new Ot_Account();
             $accounts = $account->fetchAll($account->getAdapter()->quoteInto('accountId IN (?)', $currentEditors), array('lastName', 'firstName'));
             $currentEditors = $accounts->toArray();
         }
         $this->view->editors = $currentEditors;
     }
     $category = new Category();
     $thisCategory = $category->find($thisWorkshop->categoryId);
     $this->view->layout()->setLayout('twocolumn');
     $this->view->layout()->rightContent = $this->view->render('index/right.phtml');
     $this->view->messages = $this->_helper->flashMessenger->getMessages();
     $this->view->title = $thisWorkshop->title;
     $this->view->workshop = $thisWorkshop->toArray();
     $this->view->category = $thisCategory;
 }
Exemplo n.º 3
0
 /**
  * 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');
 }
Exemplo n.º 4
0
 /**
  * Called by the Javascript frontend to get the details about an event
  *
  */
 public function eventDetailsAction()
 {
     $get = Zend_Registry::get('getFilter');
     if (!isset($get->eventId)) {
         throw new Ot_Exception_Input('msg-error-eventIdNotSet');
     }
     $event = new Event();
     if (!Zend_Auth::getInstance()->hasIdentity()) {
         $userEventStatus = false;
     } else {
         $userEventStatus = $event->getStatusOfUserForEvent(Zend_Auth::getInstance()->getIdentity()->accountId, $get->eventId);
     }
     $i = new Event_Instructor();
     $where = $i->getAdapter()->quoteInto('eventId = ?', $get->eventId);
     $results = $i->fetchAll($where);
     $currentInstructors = array();
     foreach ($results as $r) {
         $currentInstructors[] = $r->accountId;
     }
     $this->view->acl = array('editEvent' => $this->_helper->hasAccess('edit-event'), 'cancelEvent' => $this->_helper->hasAccess('cancel-event'), 'signup' => $this->_helper->hasAccess('signup', 'workshop_signup'), 'viewAllInstructorPages' => $this->_helper->hasAccess('view-all-instructor-pages', 'workshop_instructor'), 'userEventStatus' => $userEventStatus);
     $this->view->reservationCancelable = $event->isReservationCancelable($get->eventId);
     // shortened display when an ajax call version)
     $short = false;
     if ($this->_request->isXmlHttpRequest()) {
         $this->_helper->layout->disableLayout();
         $short = true;
     }
     $this->view->shortDisplay = $short;
     $workshop = new Workshop();
     $location = new Location();
     $thisEvent = $event->find($get->eventId);
     if (is_null($thisEvent)) {
         throw new Ot_Exception_Data('msg-error-noEvent');
     }
     $i = new Event_Instructor();
     $currentInstructors = $i->getInstructorsForEvent($get->eventId);
     $instructor = array();
     foreach ($currentInstructors as $r) {
         $instructor[] = $r['firstName'] . ' ' . $r['lastName'];
     }
     $this->view->instructors = $instructor;
     $thisEvent = $thisEvent->toArray();
     $thisEvent['startTime'] = strftime('%l:%M %p', strtotime($thisEvent['startTime']));
     $thisEvent['endTime'] = strftime('%l:%M %p', strtotime($thisEvent['endTime']));
     $this->view->location = $location->find($thisEvent['locationId'])->toArray();
     $this->view->workshop = $workshop->find($thisEvent['workshopId'])->toArray();
     $this->view->event = $thisEvent;
 }
Exemplo n.º 5
0
 /**
  * Allows a user to contact all the people in their event.
  *
  */
 public function contactAction()
 {
     if ($this->_request->isXmlHttpRequest()) {
         $this->_helper->layout->disableLayout();
     } else {
         $this->_helper->pageTitle('workshop-instructor-contact:title');
     }
     $get = Zend_Registry::get('getFilter');
     if (!isset($get->eventId)) {
         throw new Ot_Exception_Input('msg-error-eventIdNotSet');
     }
     $messages = array();
     $event = new Event();
     $eventId = $get->eventId;
     $thisEvent = $event->find($eventId);
     if (is_null($thisEvent)) {
         throw new Ot_Exception_Data('msg-error-noEvent');
     }
     $otAccount = new Ot_Account();
     $thisAccount = $otAccount->find(Zend_Auth::getInstance()->getIdentity()->accountId);
     $status = $event->getStatusOfUserForEvent($thisAccount->accountId, $eventId);
     if ($status != 'instructor' && !$this->_helper->hasAccess('view-all-instructor-pages')) {
         throw new Ot_Exception_Access('msg-error-notInstructor');
     }
     $form = $event->contactForm(array('eventId' => $eventId));
     if ($this->_request->isPost()) {
         if ($form->isValid($_POST)) {
             $recipients = array();
             $attendees = new Event_Attendee();
             $recipients = $attendees->getAttendeesForEvent($thisEvent->eventId, $form->getValue('recipients'));
             if ($form->getValue('emailInstructors')) {
                 $instructor = new Event_Instructor();
                 $instructorList = $instructor->getInstructorsForEvent($thisEvent->eventId);
                 $recipients = array_merge($recipients, $instructorList);
             }
             $this->_checkValidViewer($instructorList);
             $mail = new Zend_Mail();
             $mail->setFrom($thisAccount->emailAddress, $thisAccount->firstName . ' ' . $thisAccount->lastName);
             $mail->setSubject($form->getValue('subject'));
             $mail->setBodyText($form->getValue('message'));
             $mail->addTo($thisAccount->emailAddress);
             foreach ($recipients as $r) {
                 $mail->addBcc($r['emailAddress']);
             }
             $eq = new Ot_Email_Queue();
             $data = array('attributeName' => 'eventId', 'attributeId' => $thisEvent->eventId, 'zendMailObject' => $mail);
             $eq->queueEmail($data);
             //$mail->send();
             $this->_helper->flashMessenger->addMessage('msg-info-emailQueued');
             $this->_redirect('/workshop/instructor/?eventId=' . $thisEvent->eventId);
         } else {
             $messages[] = "msg-error-formSubmitProblem";
         }
     }
     $this->view->messages = $messages;
     $this->view->thisAccount = $thisAccount;
     $this->view->form = $form;
 }
Exemplo n.º 6
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;
 }
Exemplo n.º 7
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');
 }