public function save(Default_Model_Pastebin $pastebin)
 {
     $shortId = $pastebin->getShortId();
     if (empty($shortId)) {
         $shortId = $this->_getShortId();
         $pastebin->setShortId($shortId);
     }
     $name = $pastebin->getName();
     $expiresTime = $pastebin->getExpires();
     $expires = null;
     if ($expiresTime != 'never') {
         $expires = new Zend_Date();
         if ($expiresTime == 'hour') {
             $expires->addHour(1);
         }
         if ($expiresTime == 'day') {
             $expires->addDay(1);
         }
         if ($expiresTime == 'week') {
             $expires->addWeek(1);
         }
         if ($expiresTime == 'month') {
             $expires->addMonth(1);
         }
         $expires = $expires->get('yyyy-MM-dd HH:mm:ss');
     }
     $data = array('short_id' => $shortId, 'name' => !empty($name) ? $name : 'Anonymous', 'code' => $pastebin->getCode(), 'language' => $pastebin->getLanguage(), 'expires' => $expires, 'ip_address' => $_SERVER['REMOTE_ADDR'], 'created' => date('Y-m-d H:i:s'));
     if (null === ($id = $pastebin->getId())) {
         unset($data['id']);
         $this->getDbTable()->insert($data);
     } else {
         $this->getDbTable()->update($data, array('id = ?' => $id));
     }
     return $shortId;
 }
 public function execute($lastRunDt = null)
 {
     $config = Zend_Registry::get('config');
     $checkDtStart = new Zend_Date($this->_lastRunDt);
     $checkDtStart->subHour($config->user->numHoursEvaluationReminder->val);
     $checkDtEnd = new Zend_Date();
     $checkDtEnd->subHour($config->user->numHoursEvaluationReminder->val);
     $event = new Event();
     $events = $event->getEvents(null, null, null, $checkDtStart->getTimestamp(), $checkDtEnd->getTimestamp(), 'open');
     $location = new Location();
     $workshop = new Workshop();
     $instructor = new Event_Instructor();
     $attendee = new Event_Attendee();
     $eu = new Evaluation_User();
     foreach ($events as $e) {
         $startDt = strtotime($e->date . ' ' . $e->startTime);
         $endDt = strtotime($e->date . ' ' . $e->endTime);
         if ($checkDtStart->getTimestamp() < $endDt && $checkDtEnd->getTimestamp() >= $endDt) {
             $evalAvailableDt = new Zend_Date($endDt);
             $evalAvailableDt->addHour($config->user->numHoursEvaluationAvailability->val);
             if ($evalAvailableDt->getTimestamp() > time()) {
                 $taken = $eu->getCompleted($e->eventId);
                 $thisLocation = $location->find($e->locationId);
                 if (is_null($thisLocation)) {
                     throw new Ot_Exception_Data('msg-error-noLocation');
                 }
                 $thisWorkshop = $workshop->find($e->workshopId);
                 if (is_null($thisWorkshop)) {
                     throw new Ot_Exception_Data('msg-error-noWorkshop');
                 }
                 $instructors = $instructor->getInstructorsForEvent($e->eventId);
                 $instructorNames = array();
                 $instructorEmails = array();
                 foreach ($instructors as $i) {
                     $instructorNames[] = $i['firstName'] . ' ' . $i['lastName'];
                     $instructorEmails[] = $i['emailAddress'];
                 }
                 $data = array('workshopName' => $thisWorkshop->title, 'workshopDate' => date('m/d/Y', $startDt), 'workshopStartTime' => date('g:i a', $startDt), 'workshopEndTime' => date('g:i a', $endDt), 'workshopMinimumEnrollment' => $e->minSize, 'workshopCurrentEnrollment' => $e->roleSize, 'locationName' => $thisLocation->name, 'locationAddress' => $thisLocation->address, 'instructorNames' => implode(', ', $instructorNames), 'instructorEmails' => implode(', ', $instructorEmails));
                 $attending = $attendee->getAttendeesForEvent($e->eventId, 'attending');
                 foreach ($attending as $a) {
                     if ($a['attended'] == 1 && !in_array($a['accountId'], $taken)) {
                         $trigger = new Ot_Trigger();
                         $trigger->setVariables($data);
                         $trigger->accountId = $a['accountId'];
                         $trigger->studentEmail = $a['emailAddress'];
                         $trigger->studentName = $a['firstName'] . ' ' . $a['lastName'];
                         $trigger->studentUsername = $a['username'];
                         $trigger->dispatch('Event_Evaluation_Reminder');
                     }
                 }
             }
         }
     }
 }
Exemple #3
0
 protected function _getDate($timeAmount, Zend_Date $date)
 {
     $nowDate = new Zend_Date();
     $dateWithTimeAmount = $date->addHour($timeAmount);
     if ($timeAmount == 0) {
         $date = $date->addMinute(1);
     } elseif ($timeAmount < 0 && $nowDate->isLater($dateWithTimeAmount)) {
         $date = $nowDate->addMinute(1);
     } else {
         $date = $dateWithTimeAmount;
     }
     return $date;
 }
 public function getDateRange($range, $customStart, $customEnd, $returnObjects = false)
 {
     $dateEnd = new Zend_Date(Mage::getModel('core/date')->gmtTimestamp());
     $dateStart = clone $dateEnd;
     // go to the end of a day
     $dateEnd->setHour(23);
     $dateEnd->setMinute(59);
     $dateEnd->setSecond(59);
     $dateStart->setHour(0);
     $dateStart->setMinute(0);
     $dateStart->setSecond(0);
     switch ($range) {
         case '24h':
             $dateEnd = new Zend_Date(Mage::getModel('core/date')->gmtTimestamp());
             $dateEnd->addHour(1);
             $dateStart = clone $dateEnd;
             $dateStart->subDay(1);
             break;
         case '7d':
             // substract 6 days we need to include
             // only today and not hte last one from range
             $dateStart->subDay(6);
             break;
         case '1m':
             $dateStart->setDay(Mage::getStoreConfig('reports/dashboard/mtd_start'));
             break;
         case 'custom':
             $dateStart = $customStart ? $customStart : $dateEnd;
             $dateEnd = $customEnd ? $customEnd : $dateEnd;
             break;
         case '1y':
         case '2y':
             $startMonthDay = explode(',', Mage::getStoreConfig('reports/dashboard/ytd_start'));
             $startMonth = isset($startMonthDay[0]) ? (int) $startMonthDay[0] : 1;
             $startDay = isset($startMonthDay[1]) ? (int) $startMonthDay[1] : 1;
             $dateStart->setMonth($startMonth);
             $dateStart->setDay($startDay);
             if ($range == '2y') {
                 $dateStart->subYear(1);
             }
             break;
     }
     if ($returnObjects) {
         return array($dateStart, $dateEnd);
     } else {
         return array('from' => $dateStart, 'to' => $dateEnd, 'datetime' => true);
     }
 }
 public function getDateRange($range, $customStart, $customEnd, $returnObjects = false)
 {
     $dateEnd = new Zend_Date(Mage::getModel('core/date')->gmtTimestamp());
     $dateStart = clone $dateEnd;
     // go to the end of a day
     $dateEnd->setHour(23);
     $dateEnd->setMinute(59);
     $dateEnd->setSecond(59);
     $dateStart->setHour(0);
     $dateStart->setMinute(0);
     $dateStart->setSecond(0);
     switch ($range) {
         case '24h':
             $dateEnd = new Zend_Date(Mage::getModel('core/date')->gmtTimestamp());
             $dateEnd->addHour(1);
             $dateStart = clone $dateEnd;
             $dateStart->subDay(1);
             break;
         case '7d':
             // substract 6 days we need to include
             // only today and not hte last one from range
             $dateStart->subDay(6);
             break;
         case '1m':
             $dateStart->setDay(1);
             break;
         case 'custom':
             $dateStart = $customStart ? $customStart : $dateEnd;
             $dateEnd = $customEnd ? $customEnd : $dateEnd;
             break;
         case '1y':
             $dateStart->setMonth(1);
             $dateStart->setDay(1);
             break;
         case '2y':
             $dateStart->setMonth(1);
             $dateStart->setDay(1);
             $dateStart->subYear(1);
             break;
     }
     if ($returnObjects) {
         return array($dateStart, $dateEnd);
     } else {
         return array('from' => $dateStart, 'to' => $dateEnd, 'datetime' => true);
     }
 }
 public function execute($lastRunDt = null)
 {
     $config = Zend_Registry::get('config');
     $event = new Event();
     $events = $event->getEvents(null, null, null, time(), null, 'open');
     $location = new Location();
     $workshop = new Workshop();
     $instructor = new Event_Instructor();
     $checkDt = new Zend_Date($this->_lastRunDt);
     $checkDt->addHour($config->user->numHoursLowAttendanceNotification->val);
     foreach ($events as $e) {
         if ($e->roleSize < $e->minSize) {
             $startDt = strtotime($e->date . ' ' . $e->startTime);
             $endDt = strtotime($e->date . ' ' . $e->endTime);
             if ($checkDt->getTimestamp() > $startDt && $this->_lastRunDt < $startDt) {
                 $thisLocation = $location->find($e->locationId);
                 if (is_null($thisLocation)) {
                     throw new Ot_Exception_Data('msg-error-noLocation');
                 }
                 $thisWorkshop = $workshop->find($e->workshopId);
                 if (is_null($thisWorkshop)) {
                     throw new Ot_Exception_Data('msg-error-noWorkshop');
                 }
                 $instructors = $instructor->getInstructorsForEvent($e->eventId);
                 $instructorNames = array();
                 $instructorEmails = array();
                 foreach ($instructors as $i) {
                     $instructorNames[] = $i['firstName'] . ' ' . $i['lastName'];
                     $instructorEmails[] = $i['emailAddress'];
                 }
                 $data = array('workshopName' => $thisWorkshop->title, 'workshopDate' => date('m/d/Y', $startDt), 'workshopStartTime' => date('g:i a', $startDt), 'workshopEndTime' => date('g:i a', $endDt), 'workshopMinimumEnrollment' => $e->minSize, 'workshopCurrentEnrollment' => $e->roleSize, 'locationName' => $thisLocation->name, 'locationAddress' => $thisLocation->address, 'instructorNames' => implode(', ', $instructorNames), 'instructorEmails' => implode(', ', $instructorEmails));
                 $trigger = new Ot_Trigger();
                 $trigger->setVariables($data);
                 $trigger->dispatch('Event_LowAttendance');
             }
         }
     }
 }
Exemple #7
0
 /**
  * test looseBehaviour
  */
 public function testLoose()
 {
     $date = new Zend_Date(0, 'de_DE');
     try {
         $date->set(null, Zend_Date::YEAR);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     $date->set(10, 'de_DE');
     $this->assertEquals(10, $date->getTimestamp());
     try {
         $date->add(null, Zend_Date::YEAR);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     $date->add(10, 'de_DE');
     $this->assertEquals(20, $date->getTimestamp());
     try {
         $date->sub(null, Zend_Date::YEAR);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     $date->sub(10, 'de_DE');
     $this->assertEquals(10, $date->getTimestamp());
     try {
         $date->compare(null, Zend_Date::YEAR);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->equals(null, Zend_Date::YEAR);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->isEarlier(null, Zend_Date::YEAR);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->isLater(null, Zend_Date::YEAR);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->setTime(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->addTime(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->subTime(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->compareTime(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->setDate(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->addDate(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->subDate(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->compareDate(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->setIso(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->addIso(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->subIso(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->compareIso(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->setArpa(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->addArpa(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->subArpa(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->compareArpa(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->setYear(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->addYear(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->subYear(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->compareYear(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->setMonth(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->addMonth(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->subMonth(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->compareMonth(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->setDay(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->addDay(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->subDay(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->compareDay(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->setWeekday(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->addWeekday(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->subWeekday(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->compareWeekday(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->setDayOfYear(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->addDayOfYear(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->subDayOfYear(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->compareDayOfYear(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->setHour(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->addHour(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->subHour(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->compareHour(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->setMinute(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->addMinute(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->subMinute(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->compareMinute(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->setSecond(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->addSecond(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->subSecond(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->compareSecond(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->setWeek(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->addWeek(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->subWeek(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->compareWeek(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
 }
Exemple #8
0
 public function baseInit()
 {
     $dict = new Base_Dictionary();
     $date = new Zend_Date();
     $user = Zend_Auth::getInstance()->getIdentity();
     $client = Logic_Client::getInstance();
     $wsServiceSet = $client->getGroupListAsDict(Wsclient::GROUP_SERVICE_SET);
     $config = Zend_Registry::get('config');
     $this->addElement('text', 'name', array('required' => true, 'label' => 'Nazwa wysyłki'));
     $this->datee(false, "send_start", "Początek wysyłki");
     $this->send_start->setValue($date->getDate()->toString('YYYY-MM-dd'))->addValidator('Callback', false, array('callback' => function ($value) {
         $date = new Zend_Date();
         $date2 = clone $date;
         return $date->getTimestamp() <= $date2->setDate($value, 'YYYY-MM-dd')->getTimestamp();
     }));
     $this->timee(false, "time_send_start", "Okno czasowe od");
     $this->time_send_start->setValue('8:00');
     $this->timee(false, "time_send_end", "Okno czasowe do");
     $this->time_send_end->setValue('20:00');
     $this->time_send_end->addValidator('Callback', false, array('callback' => function ($value) {
         return strtotime($value) > strtotime($this->time_send_start->getValue());
     }));
     $this->datetimee(false, 'expiry_date', "Ważność wiadomości", false, array('value' => ''));
     $this->expiry_date->addValidator('Callback', false, array('callback' => function ($value) {
         $date = new Zend_Date();
         $date2 = clone $date;
         $date2->setDate($value, 'YYYY-MM-dd HH:mm');
         $date->setDate($this->send_start->getValue(), 'YYYY-MM-dd HH:mm');
         return $date->getTimestamp() <= $date2->getTimestamp() && $date->addHour(72)->getTimestamp() >= $date2->getTimestamp();
     }));
     $this->expiry_date->getValidator('Callback')->setMessages(array(Zend_Validate_Callback::INVALID_VALUE => "Data ważności wiadmości może wynosić maksymalnie 72 godziny"));
     $this->addElement('checkbox', 'repeat_message', array('label' => 'Powtarzaj tą wiadomość', 'attribs' => array('onchange' => 'checkPackageOptions();')));
     $this->repeat_message->addValidator('Callback', false, array('callback' => function ($value) {
         if ($value) {
             $this->repeat_interval->setRequired(true);
             $this->repeat_count->setRequired(true);
             $this->repeat_end->setRequired(true);
         }
         return true;
     }));
     $this->addElement('radio', 'repeat_interval', array('MultiOptions' => $dict->setSource('package_repeat')->getDictionary(), 'attribs' => array('disable' => 'disable'), 'attribs' => array('onchange' => 'checkPackageOptions();')));
     $this->repeat_interval->addValidator('Callback', false, array('callback' => function ($value) {
         if ($value == 5) {
             $this->repeat_days->setRequired(true);
         } elseif ($value == 4) {
             $this->repeat_day_interval->setRequired(true);
         }
         return true;
     }));
     $this->addElement('multiselect', 'repeat_days', array('MultiOptions' => $dict->setSource('day_of_week')->getDictionary(), 'attribs' => array('disable' => 'disable')));
     $this->addElement('text', 'repeat_day_interval', array('label' => 'Powtarzań wiadomość co (liczba dni)', 'attribs' => array('disable' => 'disable')));
     $this->addElement('text', 'repeat_count', array('label' => 'Ilość powtórzeń wiadomości', 'attribs' => array('disable' => 'disable')));
     $this->datetimee(false, "repeat_end", "Powtarzań do", false, array('value' => '', 'attribs' => array('disabled' => 'disabled')));
     $this->repeat_end->addValidator('Callback', false, array('callback' => function ($value) {
         $date = new Zend_Date();
         $date2 = clone $date;
         $date->setDate($value, 'YYYY-MM-dd HH:mm');
         $date2->setDate($this->send_start->getValue(), 'YYYY-MM-dd HH:mm');
         return $date->getTimestamp() <= $date2->setDate($value, 'YYYY-MM-dd HH:mm')->getTimestamp();
     }));
     $this->addElement('select', 'ws_service_set_id', array('label' => 'Wysyłka', 'required' => true, 'MultiOptions' => $this->addClearStart($wsServiceSet), 'attribs' => array('onchange' => 'getServiceSetOptions();')));
     $this->addElement('select', 'file_type', array('required' => true, 'label' => 'Typ wysyłki:', 'multioptions' => $this->addClearStart($dict->setSource('service_import_file_type')->getDictionary())));
     $this->addElement('file', 'addressbook_import_csv', array('label' => 'CSV z listą kontaktów do zaimportowania', 'decorators' => $this->_fileDecorator, 'validators' => array(array('Extension', false, 'csv'), array('Size', false, $config['uploads']['maxfilesize']))));
     $this->addElement('select', 'delimeter', array('label' => "Separator pola", 'MultiOptions' => $this->addClearStart($dict->setSource('csv_delimeter')->getDictionary())));
     $this->addElement('select', 'phone_heders', array('label' => "Kolumna z kontaktami"));
     $this->addElement('select', 'ws_addressbook_id', array('label' => 'Adresy', 'MultiOptions' => $this->addClearStart($dict->setSource(new Addressbook(), array('created_by =' . (int) $user->id, 'ghost=false'), 'id', 'id', array('addressbook_name'))->getDictionary())));
     $this->addDisplayGroup(array($this->addressbook_import_csv, $this->delimeter, $this->phone_heders), 'tags_import');
     $this->addElement('select', 'message_heders', array('label' => "Kolumna z wiadomością"));
     $this->submit(false, 'save_send', 'Wyślij');
     $this->submit();
     $this->cancel();
 }
Exemple #9
0
 public function getEventsForUser($accountId)
 {
     $config = Zend_Registry::get('config');
     $attendee = new Event_Attendee();
     $instructor = new Event_Instructor();
     $location = new Location();
     $document = new Workshop_Document();
     $account = new Ot_Account();
     $eu = new Evaluation_User();
     $stayOpen = new Zend_Date();
     $stayOpen->subHour($config->user->numHoursEvaluationAvailability->val);
     $locationCache = array();
     $reservations = $attendee->getEventsForAttendee($accountId);
     $time = time();
     foreach ($reservations as &$r) {
         $r['active'] = false;
         // we determine if the class is open
         $startDt = new Zend_Date(strtotime($r['date'] . ' ' . $r['startTime']));
         $endDt = new Zend_Date(strtotime($r['date'] . ' ' . $r['endTime']));
         $endDt->addHour($config->user->numHoursEvaluationAvailability->val);
         $r['evaluatable'] = $this->isEvaluatable($r['eventId']);
         // checks to see if its possible that the class is open for evaluation
         if ($r['evaluatable'] && !$eu->hasCompleted($accountId, $r['eventId'])) {
             $r['active'] = true;
         } elseif ($startDt->getTimestamp() > $time) {
             $r['active'] = true;
         }
         $r = array_merge(array('startDt' => $startDt->getTimestamp()), $r);
         $r['hasHandouts'] = false;
         $documents = $document->getDocumentsForWorkshop($r['workshopId']);
         if (count($documents) > 0) {
             $r['hasHandouts'] = true;
         }
         $r['cancelable'] = false;
         if ($r['active']) {
             $startDt->subHour($config->user->numHoursEventCancel->val);
             $r['cancelable'] = $startDt->getTimestamp() > $time;
             if ($r['status'] == 'waitlist') {
                 $waiting = $attendee->getAttendeesForEvent($r['eventId'], 'waitlist');
                 $position = 1;
                 foreach ($waiting as $w) {
                     if ($accountId == $w['accountId']) {
                         break;
                     }
                     $position++;
                 }
                 $r['waitlistPosition'] = $position;
             }
         }
     }
     // Get presently taught classes
     $teaching = $instructor->getEventsForInstructor($accountId);
     foreach ($teaching as &$t) {
         $startDt = new Zend_Date(strtotime($t['date'] . ' ' . $t['startTime']));
         $endDt = new Zend_Date(strtotime($t['date'] . ' ' . $t['endTime']));
         $endDt->addHour($config->user->numHoursEvaluationAvailability->val);
         $t = array_merge(array('startDt' => $startDt->getTimestamp()), $t);
         $t['active'] = false;
         // checks to see if its possible that the class is open for evaluation
         if ($endDt->getTimestamp() > $time) {
             $t['active'] = true;
         }
         $t['status'] = 'instructor';
     }
     $events = array_merge($reservations, $teaching);
     // sort by event order
     $eDates = array();
     foreach ($events as $key => $value) {
         $eDates[$key] = $value['startDt'];
     }
     asort($eDates);
     $newEvents = array();
     foreach (array_keys($eDates) as $key) {
         $newEvents[] = $events[$key];
     }
     $events = $newEvents;
     $currentEvents = array();
     $pastEvents = array();
     foreach ($events as $e) {
         $where = $instructor->getAdapter()->quoteInto('eventId = ?', $e['eventId']);
         $instructors = $instructor->fetchAll($where);
         $instructorIds = array();
         foreach ($instructors as $i) {
             $instructorIds[] = $i->accountId;
         }
         if (count($instructorIds) != 0) {
             $accounts = $account->fetchAll($account->getAdapter()->quoteInto('accountId IN (?)', $instructorIds), array('lastName', 'firstName'));
             foreach ($accounts as $a) {
                 $e['instructors'][] = $a->firstName . ' ' . $a->lastName;
             }
         }
         if (isset($locationCache[$e['locationId']])) {
             $e['location'] = $locationCache[$e['locationId']];
         } else {
             $thisLocation = $location->find($e['locationId']);
             if (is_null($thisLocation)) {
                 throw new Ot_Exception_Data('Location not found');
             }
             $e['location'] = $thisLocation->toArray();
             $locationCache[$e['locationId']] = $e['location'];
         }
         if ($e['active']) {
             $currentEvents[] = $e;
         } else {
             if ($e['status'] != 'waitlist') {
                 $pastEvents[] = $e;
             }
         }
     }
     $ret = array('currentEvents' => $currentEvents, 'pastEvents' => array_reverse($pastEvents));
     return $ret;
 }