Esempio n. 1
0
 public function getAttendeesForEvent($eventId, $status = 'all', $attended = false)
 {
     $where = $this->getAdapter()->quoteInto('eventId = ?', $eventId);
     if ($status != 'all') {
         $where .= ' AND ' . $this->getAdapter()->quoteInto('status = ?', $status);
     }
     if ($attended) {
         $where .= ' AND ' . $this->getAdapter()->quoteInto('attended = ?', $attended);
     }
     $result = $this->fetchAll($where, 'timestamp ASC')->toArray();
     $accountIds = array();
     foreach ($result as $r) {
         $accountIds[] = $r['accountId'];
     }
     if (count($accountIds) == 0) {
         return array();
     }
     $account = new Ot_Account();
     $where = $account->getAdapter()->quoteInto('accountId IN (?)', $accountIds);
     $accounts = $account->fetchAll($where, array('lastName', 'firstName'))->toArray();
     $accountMap = array();
     foreach ($accounts as $a) {
         $accountMap[$a['accountId']] = $a;
     }
     foreach ($result as &$r) {
         if (!isset($accountMap[$r['accountId']])) {
             $accountMap[$r['accountId']] = array('firstName' => 'Unavailable', 'lastName' => 'Unavailable', 'username' => 'Unavailable');
         }
         $r = array_merge($r, $accountMap[$r['accountId']]);
     }
     return $result;
 }
Esempio n. 2
0
 public function historyAction()
 {
     $account = new Ot_Account();
     $thisAccount = Zend_Auth::getInstance()->getIdentity();
     $get = Zend_Registry::get('getFilter');
     if (isset($get->accountId)) {
         if ($this->_helper->hasAccess('edit-all-reservations', 'workshop_signup')) {
             $thisAccount = $account->find($get->accountId);
         }
         if (is_null($thisAccount)) {
             throw new Ot_Exception_Data('msg-error-accountNotFound');
         }
     }
     if (is_null($thisAccount)) {
         throw new Ot_Exception_Data('msg-error-notLoggedIn');
     }
     $this->view->acl = array('editAllReservations' => $this->_helper->hasAccess('edit-all-reservations', 'workshop_signup'));
     $form = new Zend_Form();
     $form->setAttrib('id', 'accountForm')->setMethod(Zend_Form::METHOD_GET)->setDecorators(array('FormElements', array('HtmlTag', array('tag' => 'div', 'class' => 'filterForm')), 'Form'));
     $accountSelect = $form->createElement('select', 'accountId', array('label' => 'default-index-history:viewReservations'));
     $accountSelect->setRequired(false);
     $account = new Ot_Account();
     $accounts = $account->fetchAll(null, array('lastName', 'firstName'));
     foreach ($accounts as $a) {
         $accountSelect->addMultiOption($a->accountId, $a->firstName . ' ' . $a->lastName . ' (' . $a->username . ')');
     }
     $submit = $form->createElement('submit', 'submitButton', array('label' => 'default-index-history:lookup'));
     $submit->setDecorators(array(array('ViewHelper', array('helper' => 'formSubmit'))));
     $form->addElements(array($accountSelect));
     $form->setElementDecorators(array('ViewHelper', 'Errors', array('HtmlTag', array('tag' => 'div', 'class' => 'elm')), array('Label', array('tag' => 'span'))))->addElements(array($submit));
     $this->view->form = $form;
     $event = new Event();
     $myEvents = $event->getEventsForUser($thisAccount->accountId);
     $this->view->myEvents = $myEvents['currentEvents'];
     $this->view->myPastEvents = $myEvents['pastEvents'];
     $this->view->account = $thisAccount->toArray();
     $this->view->hideFeature = true;
     $this->_helper->layout->setLayout('my');
     $this->view->messages = $this->_helper->flashMessenger->getMessages();
     $this->view->headScript()->appendFile($this->view->baseUrl() . '/scripts/jquery.autocomplete.js');
     $this->view->headLink()->appendStylesheet($this->view->baseUrl() . '/css/jquery.autocomplete.css');
 }
 public function testAddAction()
 {
     // @todo - load example table
     //$this->markTestSkipped('Skip this test so it doesn\'t spam my email');
     $this->login();
     $postData = array('username' => 'GEORGE', 'realm' => 'local', 'firstName' => 'GE', 'lastName' => 'OGRE', 'emailAddress' => '*****@*****.**', 'timezone' => 'America/New_York', 'roleSelect' => 1, 'submit' => array('Save', 'asdf'));
     $this->request->setMethod('POST')->setPost($postData);
     $this->dispatch('/ot/account/add/realm/local');
     $this->getResponse();
     $this->assertResponseCode(302);
     $this->assertRedirectTo('/account/all');
     $this->assertModule('ot');
     $this->assertController('account');
     $this->assertAction('add');
     $account = new Ot_Account();
     $accounts = $account->fetchAll();
     $this->assertObjectHasAttribute('password', $accounts[0]);
     $this->assertObjectHasAttribute('password', $accounts[1]);
     // after checking that password does exist, change it since we can't know what it was set at
     $accounts[1]->password = '******';
     $matchAgainst = array((object) array('accountId' => '1', 'username' => 'admin', 'realm' => 'local', 'password' => '21232f297a57a5a743894a0e4a801fc3', 'apiCode' => '21232f297a57a5a743894a0e4a801fc3', 'emailAddress' => '*****@*****.**', 'firstName' => 'Admin', 'lastName' => 'Mcadmin', 'timezone' => 'America/New_York', 'lastLogin' => '0', 'role' => array('3')), (object) array('accountId' => '2', 'username' => 'GEORGE', 'realm' => 'local', 'password' => '21232f297a57a5a743894a0e4a801fc3', 'apiCode' => '', 'emailAddress' => '*****@*****.**', 'firstName' => 'Ge', 'lastName' => 'Ogre', 'timezone' => 'America/New_York', 'lastLogin' => '0', 'role' => array('1')));
     $this->assertEquals($matchAgainst, $accounts);
 }
Esempio n. 4
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;
 }
Esempio n. 5
0
 public function addAttendeeForm($values = array())
 {
     if (!isset($values['eventId'])) {
         throw new Ot_Exception_Input('The event ID must be provided.');
     }
     $form = new Zend_Form();
     $form->setAttrib('id', 'locationForm')->setDecorators(array('FormElements', array('HtmlTag', array('tag' => 'div', 'class' => 'zend_form')), 'Form'));
     $eventId = $form->createElement('hidden', 'eventId');
     $eventId->setValue($values['eventId']);
     $eventId->setDecorators(array(array('ViewHelper', array('helper' => 'formHidden'))));
     $form->addElement($eventId);
     $type = $form->createElement('select', 'type', array('label' => 'How to Add:'));
     $type->addMultiOption('firstAvailable', 'First Available Spot')->addMultiOption('attending', 'Add To Attending List')->setValue(isset($values['type']) ? $values['type'] : '');
     // get all the users available for the instructor list
     $otAccount = new Ot_Account();
     $accounts = $otAccount->fetchAll(null, array('lastName', 'firstName'))->toArray();
     $userList = array();
     foreach ($accounts as $a) {
         $userList[$a['accountId']] = $a['lastName'] . ", " . $a['firstName'];
     }
     // remove anyone who's either in the attendee list, waitlist, or an instructor
     // for this event so they can't be added to the list
     $attendee = new Event_Attendee();
     $attendeeList = $attendee->getAttendeesForEvent($values['eventId'], 'attending');
     $waitlist = $attendee->getAttendeesForEvent($values['eventId'], 'waitlist');
     $instructors = $this->getInstructorsForEvent($values['eventId']);
     foreach ($attendeeList as $a) {
         unset($userList[$a['accountId']]);
     }
     foreach ($waitlist as $w) {
         unset($userList[$w['accountId']]);
     }
     foreach ($instructors as $i) {
         unset($userList[$i['accountId']]);
     }
     $users = $form->createElement('multiselect', 'users', array('label' => 'User Search:'));
     $users->setMultiOptions($userList)->setAttrib('size', 10)->setValue(isset($values['accountIds']) ? $values['accountIds'] : '');
     $submit = $form->createElement('submit', 'submitButton', array('label' => 'Submit'));
     $submit->setDecorators(array(array('ViewHelper', array('helper' => 'formSubmit'))));
     $cancel = $form->createElement('button', 'cancel', array('label' => 'Cancel'));
     $cancel->setAttrib('id', 'cancel');
     $cancel->setDecorators(array(array('ViewHelper', array('helper' => 'formButton'))));
     $form->addElements(array($type, $users));
     $form->setElementDecorators(array('ViewHelper', 'Errors', array('HtmlTag', array('tag' => 'div', 'class' => 'elm')), array('Label', array('tag' => 'span'))))->addElements(array($submit, $cancel));
     return $form;
 }
 /**
  * The main scheduler page.  This allows a user to view and edit the schedule.  Users
  * will almost certainly need access to this entire controller to make the
  * scheduler work properly and look right.
  *
  */
 public function indexAction()
 {
     $this->view->acl = array('addEvent' => $this->_helper->hasAccess('add-event'));
     $get = Zend_Registry::get('getFilter');
     if (isset($get->workshopId)) {
         $workshopId = $get->workshopId;
         $this->view->workshopId = $workshopId;
         $this->view->startInAddMode = 1;
     }
     if (isset($get->startYear)) {
         $this->view->startYear = $get->startYear;
     } else {
         $this->view->startYear = date('Y');
     }
     if (isset($get->startMonth)) {
         $this->view->startMonth = $get->startMonth;
     } else {
         $this->view->startMonth = date('m');
     }
     $eventId = null;
     if (isset($get->eventId)) {
         $eventId = $get->eventId;
         $this->view->eventId = $eventId;
         $this->view->startInEditMode = 1;
         $e = new Event();
         $thisEvent = $e->find($eventId)->toArray();
         $this->view->locationId = $thisEvent['locationId'];
     }
     $zd = new Zend_Date();
     $this->view->workshopLength = mktime(1, 0, 0, 1, 1, 1970);
     $this->view->startTime = mktime(0, 0, 0, 1, 1, 1970);
     $this->view->endTime = mktime(23, 30, 0, 1, 1, 1970);
     $this->view->baseTime = mktime(0, 0, 0, 1, 1, 1970);
     $this->view->today = $zd->get(Zend_Date::MONTH) . "/" . $zd->get(Zend_Date::DAY) . "/" . $zd->get(Zend_Date::YEAR);
     $this->view->thisYear = $zd->get(Zend_Date::YEAR);
     $this->view->thisWeek = $zd->get(Zend_Date::WEEK);
     if (!is_null($eventId)) {
         $tmpDate = explode('-', $thisEvent['date']);
         $zd->setYear($tmpDate[0]);
         $zd->setMonth($tmpDate[1]);
         $zd->setDay($tmpDate[2]);
     }
     $this->view->year = $zd->get(Zend_Date::YEAR);
     $this->view->week = $zd->get(Zend_Date::WEEK);
     $this->_helper->pageTitle('workshop-schedule-index:title');
     $workshop = new Workshop();
     $where = $workshop->getAdapter()->quoteInto('status = ?', 'enabled');
     $workshops = $workshop->fetchAll($where, 'title');
     $workshopList = array();
     $workshopList[0] = "";
     foreach ($workshops as $w) {
         $workshopList[$w->workshopId] = $w->title;
     }
     $this->view->workshops = $workshopList;
     $location = new Location();
     $where = $location->getAdapter()->quoteInto('status = ?', 'enabled');
     $locations = $location->fetchAll($where, 'name');
     if (count($locations) == 0) {
         $this->_helper->redirector->gotoUrl('/workshop/schedule/noLocationsFound');
     }
     foreach ($locations as $l) {
         $locationList[$l->locationId] = $l->name;
     }
     $this->view->locationList = $locationList;
     //get all the users available for the instructor list
     $profile = new Ot_Account();
     $profiles = $profile->fetchAll(null, array('lastName', 'firstName'))->toArray();
     $instructors = array();
     foreach ($profiles as $p) {
         $instructors[$p['username']] = $p['lastName'] . ", " . $p['firstName'];
     }
     $this->view->messages = $this->_helper->flashMessenger->getMessages();
     $this->view->instructors = $instructors;
     $this->view->headScript()->appendFile($this->view->baseUrl() . '/public/scripts/jMonthCalendar-1.1.0.js');
     //$this->view->headScript()->appendFile($this->view->baseUrl() . '/scripts/jMonthCalendar-1.2.2.js');
     $this->view->headScript()->appendFile($this->view->baseUrl() . '/public/scripts/jquery.bt.min.js');
 }
Esempio n. 7
0
 public function form($values = array())
 {
     $config = Zend_Registry::get('config');
     $form = new Zend_Form();
     $form->setAttrib('id', 'eventForm')->setDecorators(array('FormElements', array('HtmlTag', array('tag' => 'div', 'class' => 'zend_form')), 'Form'));
     $workshop = new Workshop();
     $where = $workshop->getAdapter()->quoteInto('status = ?', 'enabled');
     $workshops = $workshop->fetchAll($where, 'title');
     $workshopList = array();
     foreach ($workshops as $w) {
         $workshopList[$w->workshopId] = $w->title;
     }
     $workshopElement = $form->createElement('select', 'workshop', array('label' => 'Workshop:'));
     $workshopElement->setMultiOptions($workshopList)->setValue(isset($values['workshopId']) ? $values['workshopId'] : '');
     $location = new Location();
     $where = $location->getAdapter()->quoteInto('status = ?', 'enabled');
     $locations = $location->fetchAll($where, 'name');
     $locationList = array();
     $locationCapacity = array();
     foreach ($locations as $l) {
         $locationList[$l->locationId] = $l->name;
         $locationCapacity['loc_' . $l->locationId] = $l->capacity;
     }
     $locationIds = array_keys($locationList);
     // add the location capacities to the page in js so we can process it as a json object for the "live" max size changing with location selection
     Zend_Layout::getMvcInstance()->getView()->headScript()->appendScript('var locationCapacitiesString = ' . Zend_Json::encode($locationCapacity) . ';');
     $locationElement = $form->createElement('select', 'location', array('label' => 'Location:'));
     $locationElement->setMultiOptions($locationList)->setValue(isset($values['locationId']) ? $values['locationId'] : $locationCapacity['loc_' . $locationIds[0]]);
     $date = $form->createElement('text', 'date', array('label' => 'Date:'));
     $date->setRequired(true)->addFilter('StringTrim')->addFilter('StripTags')->setAttrib('maxlength', '128')->setAttrib('style', 'width: 200px')->setValue(isset($values['date']) ? strftime('%A, %B %e, %Y', strtotime($values['date'])) : '');
     $password = $form->createElement('text', 'password', array('label' => 'Event Password:'******'StringTrim')->addFilter('StripTags')->setAttrib('maxlength', '100')->setValue(isset($values['password']) ? $values['password'] : '');
     // add the start time selector
     $startTimeSub = new Zend_Form_SubForm();
     $startTimeSub->setDecorators(array('FormElements', array('HtmlTag', array('tag' => 'div', 'class' => 'zend_form'))));
     $startTimeSub->setAttrib('class', 'sub');
     $startTimeHour = $startTimeSub->createElement('select', 'hour', array('label' => 'Start Time:'));
     for ($i = 1; $i <= 12; $i++) {
         $startTimeHour->addMultiOption($i, $i);
     }
     $startTimeHour->setDecorators(array(array('ViewHelper', array('helper' => 'formSelect')), array('Label')));
     $startTimeHour->setValue(isset($values['startTime']) ? date('g', strtotime($values['startTime'])) : date('g'));
     $startTimeMinute = $startTimeSub->createElement('select', 'minute');
     for ($i = 0; $i < 60; $i += 5) {
         $startTimeMinute->addMultiOption(str_pad($i, 2, '0', STR_PAD_LEFT), str_pad($i, 2, '0', STR_PAD_LEFT));
     }
     $startTimeMinute->setDecorators(array(array('ViewHelper', array('helper' => 'formSelect'))));
     $startTimeMinute->setValue(isset($values['startTime']) ? date('i', strtotime($values['startTime'])) : date('i'));
     $startTimeMeridian = $startTimeSub->createElement('select', 'meridian');
     $startTimeMeridian->addMultiOption('am', 'AM')->addMultiOption('pm', 'PM')->setDecorators(array(array('ViewHelper', array('helper' => 'formSelect'))));
     $startTimeMeridian->setValue(isset($values['startTime']) ? date('a', strtotime($values['startTime'])) : date('a'));
     $startTimeSub->addElements(array($startTimeHour, $startTimeMinute, $startTimeMeridian));
     // add the end time selector
     $endTimeSub = new Zend_Form_SubForm();
     $endTimeSub->setDecorators(array('FormElements', array('HtmlTag', array('tag' => 'div', 'class' => 'zend_form'))));
     $endTimeSub->setAttrib('class', 'sub');
     $endTimeHour = $endTimeSub->createElement('select', 'hour', array('label' => 'End Time:'));
     for ($i = 1; $i <= 12; $i++) {
         $endTimeHour->addMultiOption($i, $i);
     }
     $endTimeHour->setDecorators(array(array('ViewHelper', array('helper' => 'formSelect')), array('Label')));
     $endTimeHour->setValue(isset($values['endTime']) ? date('g', strtotime($values['endTime'])) : date('g'));
     $endTimeMinute = $endTimeSub->createElement('select', 'minute');
     for ($i = 0; $i < 60; $i += 5) {
         $endTimeMinute->addMultiOption(str_pad($i, 2, '0', STR_PAD_LEFT), str_pad($i, 2, '0', STR_PAD_LEFT));
     }
     $endTimeMinute->setDecorators(array(array('ViewHelper', array('helper' => 'formSelect'))));
     $endTimeMinute->setValue(isset($values['endTime']) ? date('i', strtotime($values['endTime'])) : date('i'));
     $endTimeMeridian = $endTimeSub->createElement('select', 'meridian');
     $endTimeMeridian->addMultiOption('am', 'AM')->addMultiOption('pm', 'PM')->setDecorators(array(array('ViewHelper', array('helper' => 'formSelect'))));
     $endTimeMeridian->setValue(isset($values['endTime']) ? date('a', strtotime($values['endTime'])) : date('a'));
     $endTimeSub->addElements(array($endTimeHour, $endTimeMinute, $endTimeMeridian));
     // get all the users available for the instructor list
     $otAccount = new Ot_Account();
     $accounts = $otAccount->fetchAll(null, array('lastName', 'firstName'))->toArray();
     $instructorList = array();
     foreach ($accounts as $a) {
         $instructorList[$a['accountId']] = $a['lastName'] . ", " . $a['firstName'];
     }
     $instructorElement = $form->createElement('multiselect', 'instructors', array('label' => 'Instructor(s):'));
     $instructorElement->setMultiOptions($instructorList)->setAttrib('size', 10)->setValue(isset($values['instructorIds']) ? $values['instructorIds'] : '');
     $minSize = $form->createElement('text', 'minSize', array('label' => 'Min Size:'));
     $minSize->setRequired(true)->addFilter('StringTrim')->addFilter('StripTags')->setAttrib('maxlength', '64')->setAttrib('style', 'width: 50px;')->setValue(isset($values['minSize']) ? $values['minSize'] : $config->user->defaultMinWorkshopSize->val);
     $maxSize = $form->createElement('text', 'maxSize', array('label' => 'Max Size:'));
     $maxSize->setRequired(true)->addFilter('StringTrim')->addFilter('StripTags')->setAttrib('maxlength', '64')->setAttrib('style', 'width: 50px;')->setValue(isset($values['maxSize']) ? $values['maxSize'] : $locationElement->getValue());
     $waitlistSize = $form->createElement('text', 'waitlistSize', array('label' => 'Waitlist Size:'));
     $waitlistSize->setRequired(true)->addFilter('StringTrim')->addFilter('StripTags')->setAttrib('maxlength', '64')->setAttrib('style', 'width: 50px;')->setValue(isset($values['waitlistSize']) ? $values['waitlistSize'] : $config->user->defaultWorkshopWaitlistSize->val);
     $evaluationType = $form->createElement('select', 'evaluationType', array('label' => 'Evaluation Type:'));
     $evaluationType->setMultiOptions(array('default' => 'Default', 'google' => 'Google Form'))->setRequired(true)->setValue(isset($values['evaluationType']) ? $values['evaluationType'] : 'default');
     $formKey = $form->createElement('textarea', 'formKey', array('label' => 'Google Form Question Key:'));
     $formKey->setAttribs(array('cols' => '10', 'rows' => '5', 'style' => 'width : 250px;'))->addDecorators(array('ViewHelper', 'Errors', 'HtmlTag', array('Label', array('tag' => 'span')), array(array('elementDiv' => 'HtmlTag'), array('tag' => 'div', 'id' => 'formKey', 'class' => 'elm'))))->setValue(isset($values['formKey']) ? $values['formKey'] : '');
     $answerKey = $form->createElement('textarea', 'answerKey', array('label' => 'Google Form Answer Key:'));
     $answerKey->addFilter('StringTrim')->addFilter('StripTags')->setAttribs(array('cols' => '10', 'rows' => '3', 'style' => 'width : 250px;'))->addDecorators(array('ViewHelper', 'Errors', 'HtmlTag', array('Label', array('tag' => 'span')), array(array('elementDiv' => 'HtmlTag'), array('tag' => 'div', 'id' => 'answerKey', 'class' => 'elm'))))->setValue(isset($values['answerKey']) ? $values['answerKey'] : '');
     $submit = $form->createElement('submit', 'submitButton', array('label' => 'Submit'));
     $submit->setDecorators(array(array('ViewHelper', array('helper' => 'formSubmit'))));
     $cancel = $form->createElement('button', 'cancel', array('label' => 'Cancel'));
     $cancel->setAttrib('id', 'cancel');
     $cancel->setDecorators(array(array('ViewHelper', array('helper' => 'formButton'))));
     $form->addElements(array($workshopElement, $locationElement, $password, $date, $evaluationType))->addSubForms(array('startTime' => $startTimeSub, 'endTime' => $endTimeSub))->addElements(array($minSize, $maxSize, $waitlistSize, $instructorElement));
     $form->addDisplayGroup(array('instructors'), 'instructors-group', array('legend' => 'Instructors'));
     $form->addDisplayGroup(array('workshop', 'password', 'location', 'minSize', 'maxSize', 'waitlistSize'), 'generalInformation', array('legend' => 'General Information'));
     $form->setElementDecorators(array('ViewHelper', 'Errors', array('HtmlTag', array('tag' => 'div', 'class' => 'elm')), array('Label', array('tag' => 'span'))))->addElements(array($submit, $cancel));
     $form->addElements(array($evaluationType, $formKey, $answerKey));
     $form->addDisplayGroup(array('evaluationType', 'formKey', 'answerKey'), 'evaluationTypes', array('legend' => 'Evaluations'));
     $form->addDisplayGroup(array('submitButton', 'cancel'), 'buttons');
     $form->setDisplayGroupDecorators(array('FormElements', array('HtmlTag', array('tag' => 'div', 'class' => 'widget-content')), array(array('elementDiv' => 'HtmlTag'), array('tag' => 'div', 'class' => array('widget-footer', 'ui-corner-bottom'), 'placement' => Zend_Form_Decorator_Abstract::APPEND)), array('FieldSet', array('class' => 'formField'))));
     $buttons = $form->getDisplayGroup('buttons');
     $buttons->setDecorators(array('FormElements', array('HtmlTag', array('tag' => 'div', 'style' => 'clear : both;'))));
     if (isset($values['eventId'])) {
         $eventId = $form->createElement('hidden', 'eventId');
         $eventId->setValue($values['eventId']);
         $eventId->setDecorators(array(array('ViewHelper', array('helper' => 'formHidden'))));
         $form->addElement($eventId);
     }
     return $form;
 }
Esempio n. 8
0
 /**
  * Gets the form for adding and editing a location
  *
  * @param array $values
  * @return Zend_Form
  */
 public function form($values = array())
 {
     require_once APPLICATION_PATH . '/models/Workshop/Category.php';
     $form = new Zend_Form();
     $form->setAttrib('id', 'workshopForm')->setDecorators(array('FormElements', array('HtmlTag', array('tag' => 'div', 'class' => 'zend_form')), 'Form'));
     $title = $form->createElement('text', 'title', array('label' => 'Workshop Title:'));
     $title->setRequired(true)->addFilter('StringTrim')->addFilter('StripTags')->setAttrib('maxlength', '255')->setValue(isset($values['title']) ? $values['title'] : '');
     $group = $form->createElement('select', 'group', array('label' => 'Offered By:'));
     $group->addMultiOption('groupId1', 'Test Group1');
     $group->addMultiOption('groupId2', 'Test Group2');
     $group->setValue(isset($values['group']) ? $values['group'] : null);
     //TODO: change this to add all the enabled groups in the database
     $tags = $form->createElement('text', 'tags', array('label' => 'Tags:'));
     $tags->setRequired(false)->addFilter('StringTrim')->addFilter('StripTags')->setValue(isset($values['tags']) ? implode(', ', $values['tags']) : '');
     $status = $form->createElement('select', 'status', array('label' => 'Status:'));
     $status->addMultiOption('enabled', 'Enabled');
     $status->addMultiOption('disabled', 'Disabled');
     $status->setValue(isset($values['status']) ? $values['status'] : 'enabled');
     $category = new Category();
     $categoryList = $category->fetchAll(null, 'name');
     $categories = $form->createElement('select', 'categoryId', array('label' => 'Worshop Category: '));
     $categories->setRequired(true);
     foreach ($categoryList as $category) {
         $categories->addMultiOption($category->categoryId, $category->name);
     }
     $categories->setValue(isset($values['categoryId']) ? $values['categoryId'] : '');
     $prerequisites = $form->createElement('textarea', 'prerequisites', array('label' => 'workshop-index-add:preRequisites'));
     $prerequisites->setRequired(false)->addFilter('StringTrim')->setAttrib('style', 'width: 95%; height: 200px;')->setValue(isset($values['prerequisites']) ? $values['prerequisites'] : '');
     $featured = $form->createElement('checkbox', 'features', array('label' => 'Featured?'));
     $featured->setValue(isset($values['featured']) ? $values['featured'] : null);
     $description = $form->createElement('textarea', 'description', array('label' => 'Description:'));
     $description->setRequired(false)->addFilter('StringTrim')->setAttrib('style', 'width: 95%; height: 200px;')->setValue(isset($values['description']) ? $values['description'] : '');
     $editors = $form->createElement('multiselect', 'editors', array('label' => 'Workshop Editors:'));
     $editors->setRequired(false)->setAttrib('size', '10');
     $account = new Ot_Account();
     $accounts = $account->fetchAll(null, array('lastName', 'firstName'));
     foreach ($accounts as $a) {
         $editors->addMultiOption($a->accountId, $a->firstName . ' ' . $a->lastName . ' (' . $a->username . ')');
     }
     $editors->setValue(isset($values['editors']) ? $values['editors'] : '');
     $submit = $form->createElement('submit', 'submitButton', array('label' => 'Submit'));
     $submit->setDecorators(array(array('ViewHelper', array('helper' => 'formSubmit'))));
     $cancel = $form->createElement('button', 'cancel', array('label' => 'Cancel'));
     $cancel->setAttrib('id', 'cancel');
     $cancel->setDecorators(array(array('ViewHelper', array('helper' => 'formButton'))));
     $form->addElements(array($status, $title, $categories, $group, $tags, $description, $prerequisites, $editors));
     $form->setElementDecorators(array('ViewHelper', 'Errors', array('HtmlTag', array('tag' => 'div', 'class' => 'elm')), array('Label', array('tag' => 'span'))))->addElements(array($submit, $cancel));
     if (isset($values['workshopId'])) {
         $workshopId = $form->createElement('hidden', 'workshopId');
         $workshopId->setValue($values['workshopId']);
         $workshopId->setDecorators(array(array('ViewHelper', array('helper' => 'formHidden'))));
         $form->addElement($workshopId);
     }
     return $form;
 }