示例#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();
 }
示例#2
0
function test_addAll($db)
{
    //Insert X events per user
    $result = true;
    $count = 0;
    $t1 = microtime(true);
    for ($i = 0; $i < TOTAL_USERS; $i++) {
        $events = Event::getEvents(EVENTS_PER_USER);
        foreach ($events as $event) {
            $userid = $i + 1;
            if ($db->insert("calendar", $userid, $event) == false) {
                $result = false;
            } else {
                $count++;
            }
        }
    }
    $t2 = microtime(true);
    $diff = $t2 - $t1 . "s";
    if ($result) {
        echo "Insert {$count} records ({$diff})<br>";
    } else {
        echo "Failed addAll";
    }
    return $result;
}
 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');
                     }
                 }
             }
         }
     }
 }
示例#4
0
 public function getReportCsv($fromDate, $toDate)
 {
     $event = new Event();
     $workshop = new Workshop();
     $location = new Location();
     $attendee = new Event_Attendee();
     // go ahead and get all the workshops so we don't have to do loads of DB queries
     $workshopList = $workshop->fetchAll();
     $workshops = array();
     foreach ($workshopList as $w) {
         $workshops[$w->workshopId] = $w->toArray();
     }
     // go ahead and get all the locations so we don't have to do loads of DB queries
     $locationList = $location->fetchAll();
     $locations = array();
     foreach ($locationList as $l) {
         $locations[$l->locationId] = $l->toArray();
     }
     $events = $event->getEvents(null, null, null, $fromDate, $toDate)->toArray();
     $fileName = 'report-' . date('Ymd-B') . '.csv';
     $tmpName = tempnam('/tmp', $fileName);
     $fp = fopen($tmpName, 'w');
     $columnNames = array('eventId' => 'eventId', 'workshopId' => 'workshopId', 'workshopTitle' => 'workshopTitle', 'locationId' => 'locationId', 'locationName' => 'locationName', 'eventDate' => 'eventDate', 'startTime' => 'startTime', 'endTime' => 'endTime', 'accountId' => 'accountId', 'username' => 'username', 'firstName' => 'firstName', 'lastName' => 'lastName', 'status' => 'status', 'attended' => 'attended');
     $ret = fputcsv($fp, $columnNames, ',', '"');
     if ($ret === false) {
         throw new Ot_Exception_Data('Error writing backup CSV file');
     }
     foreach ($events as &$e) {
         $e['workshop'] = $workshops[$e['workshopId']];
         $e['location'] = $locations[$e['locationId']];
         $e['attendees'] = $attendee->getAttendeesForEvent($e['eventId']);
         foreach ($e['attendees'] as $a) {
             $data = array();
             $data = array('eventId' => $e['eventId'], 'workshopId' => $e['workshopId'], 'workshopTitle' => $e['workshop']['title'], 'locationId' => $e['locationId'], 'locationName' => $e['location']['name'], 'eventDate' => $e['date'], 'startTime' => $e['startTime'], 'endTime' => $e['endTime'], 'accountId' => $a['accountId'], 'username' => $a['username'], 'firstName' => $a['firstName'], 'lastName' => $a['lastName'], 'status' => $a['status'], 'attended' => $a['attended']);
             $ret = fputcsv($fp, $data, ',', '"');
             if ($ret === false) {
                 throw new Ot_Exception_Data('Error writing backup CSV file');
             }
         }
     }
     fclose($fp);
     file_get_contents($tmpName);
     header('Content-Description: File Transfer');
     header('Content-Type: application/octet-stream');
     header('Content-Length: ' . filesize($tmpName));
     header("Content-Disposition: attachment; filename={$fileName}");
     readfile($tmpName);
     unlink($tmpName);
 }
示例#5
0
 public function getEventsForInstructor($accountId, $startDt = null, $endDt = null)
 {
     $dba = $this->getAdapter();
     $where = $dba->quoteInto('accountId = ?', $accountId);
     $result = $this->fetchAll($where);
     $eventIds = array();
     foreach ($result as $r) {
         $eventIds[] = $r->eventId;
     }
     if (count($eventIds) == 0) {
         return array();
     }
     $event = new Event();
     $workshop = new Workshop();
     $events = $event->getEvents(null, $eventIds, null, $startDt, $endDt, 'open')->toArray();
     foreach ($events as &$e) {
         $e['workshop'] = $workshop->find($e['workshopId']);
         //->toArray();
     }
     return $events;
 }
 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');
             }
         }
     }
 }
示例#7
0
文件: calendar.php 项目: ununik/tiary
        break;
    default:
        $today = strtotime(date('Y-m-01', $today));
        $firstday_num = date('w', $today);
        $plus = "next months";
        $nextDate = "next months";
        $previousDate = "last month";
        $num = cal_days_in_month(CAL_GREGORIAN, date('m', $today), date('Y'));
        $term = "month";
        break;
}
$next = strtotime($plus, $today);
$nextDate = strtotime($nextDate, $today);
$previousDate = strtotime($previousDate, $today);
$events = new Event();
$eventsAll = $events->getEvents($today, $next);
$calendar_term = "<div class='calendar_term'><a href='index.php?page=calendar&term=day&date={$today}' class='button'>Den</a>\n             <a href='index.php?page=calendar&term=week&date={$today}' class='button'>Týden</a>\n             <a href='index.php?page=calendar&term=month&date={$today}' class='button'>Měsíc</a></div>";
for ($i = 0; $i < $num; $i++) {
    $days[$i]['name'] = $daysname[date("w", $today)];
    $days[$i]['date'] = date("j. n. Y", $today);
    $days[$i]['day'] = date("j", $today);
    $days[$i]['timestamp'] = $today;
    foreach ($eventsAll as $event) {
        if ($event['timestamp1'] >= $today && $event['timestamp1'] < strtotime('+1 day', $today)) {
            $days[$i]['events'][] = "<a href='index.php?page=calendar_event&id={$event['id']}'>{$event['title']}</a>";
        }
    }
    $days[$i]['events'][] = "<a href='index.php?page=calendar_new_event&timestamp={$today}' class='calendar_add_new'>+</a>";
    $today = strtotime('+1 day', $today);
}
$calendar = (include_once "views/calendar/{$term}.php");
示例#8
0
if ($action == 'none') {
    $types = array('Addition Event', 'Change Event', 'Deletion Event', 'Other Events');
    for ($i = 0; $i < count($types); $i++) {
        ?>
        <h3><?php 
        echo $types[$i];
        ?>
</h3>
        <table class="table table-hover">
            <tr>
                <th>ID</th>
                <th>Message</th>
                <th>Time</th>
            </tr>
            <?php 
        $events = Event::getEvents($i + 1);
        foreach ($events as $event) {
            ?>
                <tr>
                    <td><a onclick="load('events', 'view', 'none', {id:'<?php 
            echo $event->getID();
            ?>
'})"><?php 
            echo $event->getID();
            ?>
</a></td>
                    <td><?php 
            echo $event->getMessage();
            ?>
</td>
                    <td><?php 
 /**
  *
  */
 public static function setLang($controllerID)
 {
     static::getLanguages();
     if ($lang = \App::storage('website.languages.' . $controllerID)) {
         $event = \Event::getEvents('website');
         if (is_array($event) && ptc_array_get($event, 'setlang', false)) {
             ptc_fire('website.setlang', array($controllerID, &$lang));
         }
         \App::storage('website.current_lang', $lang);
         $fallback_key = static::$_fallbackLang;
         $fallback_lang = $fallback_key && $fallback_key != $controllerID ? \App::storage('website.languages.' . $fallback_key) : null;
         \App::storage('website.fallback_lang', $fallback_lang);
         return true;
     }
     return false;
 }
 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();
     $attendees = new Event_Attendee();
     $lastRunDt = new Zend_Date($this->_lastRunDt);
     $currentDt = new Zend_Date();
     foreach ($events as $e) {
         $startDt = strtotime($e->date . ' ' . $e->startTime);
         $endDt = strtotime($e->date . ' ' . $e->endTime);
         $firstDt = new Zend_Date($startDt);
         $firstDt->subHour($config->user->numHoursFirstReminder->val);
         $finalDt = new Zend_Date($startDt);
         $finalDt->subHour($config->user->numHoursFinalReminder->val);
         $notification = null;
         if ($firstDt->getTimestamp() > $lastRunDt->getTimestamp() && $firstDt->getTimestamp() < $currentDt->getTimestamp()) {
             $notification = 'first';
         }
         if ($finalDt->getTimestamp() > $lastRunDt->getTimestamp() && $finalDt->getTimestamp() < $currentDt->getTimestamp()) {
             $notification = 'final';
         }
         if (!is_null($notification)) {
             $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 = $attendees->getAttendeesForEvent($e->eventId, 'attending');
             foreach ($attending as $a) {
                 $trigger = new Ot_Trigger();
                 $trigger->setVariables($data);
                 $trigger->accountId = $a['accountId'];
                 $trigger->studentEmail = $a['emailAddress'];
                 $trigger->studentName = $a['firstName'] . ' ' . $a['lastName'];
                 if ($notification == 'final') {
                     $trigger->dispatch('Event_Attendee_Final_Reminder');
                 } else {
                     $trigger->dispatch('Event_Attendee_First_Reminder');
                 }
             }
             $trigger = new Ot_Trigger();
             $trigger->setVariables($data);
             if ($notification == 'final') {
                 $trigger->dispatch('Event_Instructor_Final_Reminder');
             } else {
                 $trigger->dispatch('Event_Instructor_First_Reminder');
             }
         }
     }
 }
示例#11
0
 public static function setEvents($orderID, $eventType, $isLog = true)
 {
     if (!isset(self::$eventType[$eventType])) {
         return false;
     }
     $eventModel = new Event();
     $eventModel->event_type = $eventType;
     $eventModel->order_id = $orderID;
     $events = $eventModel->getEvents();
     if ($events) {
         foreach ($events as $event) {
             $content = array('smtp_id' => $event['smtp_id'], 'body_subject' => $event['body_subject'], 'body_html' => $event['body_html'], 'body_plain' => $event['body_plain'], 'fname' => $event['fname'], 'lname' => $event['lname'], 'email' => $event['email']);
             $jobModel = new Job();
             $jobModel->order_id = $orderID;
             $jobModel->job_type = 'mail';
             $jobModel->job_status = 'new';
             $jobModel->content = serialize($content);
             $jobModel->setIsLog($isLog);
             $jobModel->save();
             unset($jobModel, $content);
         }
     }
 }
示例#12
0
 /**
  *
  */
 protected static function _getBlock($page, $blockID, $type)
 {
     if (!static::_initialize()) {
         return false;
     }
     $block = static::$_xml->xpath("//block[@id='" . $blockID . "']");
     if (!$block) {
         trigger_error('Block id "' . $blockID . '" not found in xml config file!', E_USER_ERROR);
         return false;
     }
     $children = $block[0]->{$type};
     $string = null;
     if (isset($children->resource)) {
         for ($i = 0; $i < count($children); $i++) {
             $items = array();
             for ($a = 0; $a < count($children->{$i}->resource); $a++) {
                 $resource_id = (string) $children->{$i}->resource->{$a};
                 $items[] = $resource_id;
             }
             if ($comment = $children->{$i}->attributes()) {
                 $comment = $comment->type;
             }
             $string .= static::_build($items, $type, $comment);
         }
     }
     if ($listener = $block[0]->listener) {
         for ($b = 0; $b < count($listener); $b++) {
             $listener_type = (string) $listener->{$b}->attributes()->type;
             if ($type === $listener_type || 'any' === $listener_type) {
                 $params = array($page, &$string, $type);
                 if (false === ptc_fire('website.' . (string) $listener->{$b}[0], $params)) {
                     static::$_fireEvent = false;
                 }
             }
         }
     }
     $event = \Event::getEvents('website');
     if ($page && static::$_fireEvent && is_array($event) && ptc_array_get($event, 'resources', false)) {
         ptc_fire('website.resources', array($page, &$string, $type, $blockID));
     }
     if ($raw = $block[0]->{$type}->raw) {
         $string .= 'js' === $type ? '<script>' . "\n" : '<style>' . "\n";
         for ($c = 0; $c < count($raw); $c++) {
             $string .= "\t" . $raw->{$c} . (';' !== substr(trim($raw->{$c}), -1) ? ';' : null) . "\n";
         }
         $string .= 'js' === $type ? '</script>' . "\n" : '</style>' . "\n";
     }
     return $string;
 }
示例#13
0
文件: view.php 项目: kar2905/regwiz
<?php 
include_once 'header.php';
?>
</div>
<div id="sidebaar">
<?php 
include_once 'class.inc.php';
include_once 'sidebar.php';
?>
</div>
<div id="content">
<?php 
$view = $_GET['view'];
if ($view == "e") {
    $event = new Event();
    $res = $event->getEvents();
    echo "<table border='1'>\n\t\t\t<tr><td>Event Name</td><td>Partcipants</td></tr>\n\t\t";
    foreach ($res as $r) {
        echo "<tr><td>" . $r['Ename'] . "</td><td>" . $r['TCount'] . "</td></tr>";
    }
}
if ($view == "c") {
    $cat = new Category();
    $res = $cat->getCatSummary();
    echo "<table border='1'>\n\t\t\t<tr><td>Category Name</td><td>Partcipants</td></tr>\n\t\t";
    foreach ($res as $r) {
        echo "<tr><td>" . $r['Cname'] . "</td><td>" . $r['TCount'] . "</td></tr>";
    }
}
if ($view == 'd') {
    $del = new Delegate();
示例#14
0
 /**
  * Gets the events for a given month.  Used in the scheduler as an AJAX call
  */
 public function getEventsAction()
 {
     $this->_helper->viewRenderer->setNeverRender();
     $this->_helper->layout->disableLayout();
     $get = Zend_Registry::get('getFilter');
     if (isset($get->date)) {
         if (!empty($get->date)) {
             $date = new Zend_Date($get->date);
         } else {
             $date = new Zend_Date();
         }
     } else {
         $date = new Zend_Date();
     }
     $locationId = null;
     if (isset($get->locationId) && !empty($get->locationId)) {
         $locationId = $get->locationId;
     }
     $startDate = clone $date;
     $endDate = clone $date;
     $startDate->setHour(0)->setMinute(0)->setSecond(0);
     $startDate->setDay(1);
     $startDate->subDay($startDate->get(Zend_Date::WEEKDAY_DIGIT));
     $endDate->setHour(23)->setMinute(59)->setSecond(59);
     $endDate->setDay($endDate->get(Zend_Date::MONTH_DAYS));
     $endDate->addDay(6 - $endDate->get(Zend_Date::WEEKDAY_DIGIT));
     $event = new Event();
     $events = $event->getEvents(null, null, $locationId, $startDate->getTimestamp(), $endDate->getTimestamp(), array('open', 'closed'), null)->toArray();
     $workshop = new Workshop();
     foreach ($events as &$e) {
         $e['startTime'] = strftime('%l:%M %p', strtotime($e['startTime']));
         $e['endTime'] = strftime('%l:%M %p', strtotime($e['endTime']));
         $e['workshop'] = $workshop->find($e['workshopId'])->toArray();
     }
     echo Zend_Json::encode($events);
 }
示例#15
0
 public function getEventsForAttendee($accountId, $startDt = null, $endDt = null, $status = 'all')
 {
     $dba = $this->getAdapter();
     $where = $dba->quoteInto('accountId = ?', $accountId);
     if ($status == 'all') {
         $where .= ' AND ' . $dba->quoteInto('status != ?', 'canceled');
     } else {
         $where .= ' AND ' . $dba->quoteInto('status = ?', $status);
     }
     $result = $this->fetchAll($where);
     $eventIds = array();
     foreach ($result as $r) {
         $eventIds[$r->eventId] = array('status' => $r->status, 'attended' => $r->attended);
     }
     if (count($eventIds) == 0) {
         return array();
     }
     $event = new Event();
     $workshop = new Workshop();
     $events = $event->getEvents(null, array_keys($eventIds), null, $startDt, $endDt, 'open')->toArray();
     foreach ($events as &$e) {
         $e['workshop'] = $workshop->find($e['workshopId'])->toArray();
         $e['status'] = $eventIds[$e['eventId']]['status'];
         $e['attended'] = $eventIds[$e['eventId']]['attended'];
     }
     return $events;
 }
示例#16
0
/**
 * Fonction pour afficher tous les évenements et les contrôles pour ses events
 */
function controller_event_all()
{
    $events = Event::getEvents();
    render("events.php", array('events' => $events));
}
示例#17
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;
 }
示例#18
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');
 }