Example #1
0
 /**
  * reindexes the selected search index
  *
  */
 public function reindexAction()
 {
     $form = Ot_Form_Template::delete('reindex', 'search-index-reindex:reindex');
     if ($this->_request->isPost() && $form->isValid($_POST)) {
         set_time_limit(0);
         $workshop = new Workshop();
         $workshops = $workshop->fetchAll();
         foreach ($workshops as $w) {
             $workshop->index($w);
         }
         $this->_helper->flashMessenger->addMessage('msg-info-reindexed');
         $this->_redirect('/');
     }
     $this->view->form = $form;
     $this->_helper->pageTitle('search-index-reindex:title');
 }
 /**
  * Allows a user to delete a location type
  *
  */
 public function deleteAction()
 {
     $get = Zend_Registry::get('getFilter');
     if (!isset($get->typeId)) {
         throw new Ot_Exception_Input('msg-error-typeIdNotSet');
     }
     $locationType = new LocationType();
     $thisLocationType = $locationType->find($get->typeId);
     if (is_null($thisLocationType)) {
         throw new Ot_Exception_Data('msg-error-noLocationType');
     }
     $this->view->locationType = $thisLocationType;
     $form = Ot_Form_Template::delete('deleteForm');
     if ($this->_request->isPost() && $form->isValid($_POST)) {
         $where = $locationType->getAdapter()->quoteInto('typeId = ?', $get->typeId);
         $locationType->delete($where);
         $this->_helper->flashMessenger->addMessage('msg-info-locationTypeDeleted');
         $this->_helper->redirector->gotoUrl('/workshop/locationType/index');
     }
     $this->_helper->pageTitle('workshop-location-type-delete:title');
     $this->view->form = $form;
 }
 /**
  * Allows a user to delete a workshop category
  *
  */
 public function deleteAction()
 {
     $get = Zend_Registry::get('getFilter');
     if (!isset($get->categoryId)) {
         throw new Ot_Exception_Input('msg-error-categoryIdNotSet');
     }
     $category = new Category();
     $thisCategory = $category->find($get->categoryId);
     if (is_null($thisCategory)) {
         throw new Ot_Exception_Data('msg-error-category');
     }
     $this->view->category = $thisCategory;
     $form = Ot_Form_Template::delete('deleteForm');
     if ($this->_request->isPost() && $form->isValid($_POST)) {
         $where = $category->getAdapter()->quoteInto('categoryId = ?', $get->categoryId);
         $category->delete($where);
         $this->_helper->flashMessenger->addMessage('msg-info-categoryDeleted');
         $this->_helper->redirector->gotoUrl('/workshop/category/index');
     }
     $this->_helper->pageTitle('workshop-category-delete:title');
     $this->view->form = $form;
 }
Example #4
0
 public function deleteLinkAction()
 {
     if ($this->_request->isXmlHttpRequest()) {
         $this->view->layout()->disableLayout();
     } else {
         $this->_helper->pageTitle('workshop-index-deleteLink:title');
     }
     $get = Zend_Registry::get('getFilter');
     if (!isset($get->workshopLinkId)) {
         throw new Ot_Exception_Input('msg-error-workshopLinkIdNotSet');
     }
     $workshop = new Workshop();
     $link = new Workshop_Link();
     $thisLink = $link->find($get->workshopLinkId);
     if (is_null($thisLink)) {
         throw new Ot_Exception_Data('msg-error-noLink');
     }
     $thisWorkshop = $workshop->find($thisLink->workshopId);
     if (is_null($thisWorkshop)) {
         throw new Ot_Exception_Data('msg-error-noWorkshop');
     }
     $we = new Workshop_Editor();
     if (!$this->_helper->hasAccess('edit-all-workshops') && !$we->isEditor($thisWorkshop->workshopId, Zend_Auth::getInstance()->getIdentity()->accountId)) {
         throw new Ot_Exception_Access('msg-error-noAccess');
     }
     $form = Ot_Form_Template::delete('deleteLink');
     $form->setAction($this->view->baseUrl() . '/workshop/index/delete-link/?workshopLinkId=' . $thisLink->workshopLinkId);
     if ($this->_request->isPost() && $form->isValid($_POST)) {
         $link->delete($link->getAdapter()->quoteInto('workshopLinkId = ?', $thisLink->workshopLinkId));
         $logOptions = array('attributeName' => 'workshopId', 'attributeId' => $thisWorkshop->workshopId);
         $this->_helper->log(Zend_Log::INFO, 'Link was deleted', $logOptions);
         $this->_helper->flashMessenger->addMessage('msg-info-linkDeleted');
         $this->_helper->redirector->gotoUrl('/workshop/index/details/?workshopId=' . $thisWorkshop->workshopId);
     }
     $this->view->form = $form;
 }
 /**
  * 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;
 }
 /**
  * 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');
 }