Example #1
0
 public function __construct()
 {
     parent::__construct('formEditEvent', 'Edit Event');
     $event = $this->getEvent();
     $isAdmin = Session::getUser()->hasPriv('MODERATE_EVENTS');
     $isOwner = Session::getUser()->getData('organization') == $event['organizer'];
     if (!$isAdmin && !$isOwner) {
         throw new Exception('You do not have the privs for this.');
     } else {
         if ($isAdmin) {
             $el = FormHelpers::getOrganizerList(true);
             $el->setValue($event['organizer']);
             $this->addElement($el);
         }
     }
     $this->addElement(Element::factory('hidden', 'id', 'event id', $event['id']));
     $this->addElement(Element::factory('text', 'title', 'Title', $event['title']));
     if ($isAdmin) {
         $this->addElement(FormHelpers::getVenueListElement(null, true));
     } else {
         $this->addElement(FormHelpers::getVenueListElement(Session::getUser()->getData('organization'), true));
     }
     $this->getElement('venue')->setValue($event['venue']);
     $this->addElement(Element::factory('text', 'dateStart', 'Start', $event['dateStart']));
     $this->addElement(Element::factory('text', 'dateFinish', 'Finish', $event['dateFinish']));
     $this->addScript('$("#formEditEvent-dateStart").datetime({"firstDay": 1 })');
     $this->addScript('$("#formEditEvent-dateFinish").datetime({"firstDay": 2 })');
     $this->addElement(Element::factory('numeric', 'priceOnDoor', 'Ticket price on the door', $event['priceOnDoor']));
     $this->addElement(Element::factory('numeric', 'priceInAdv', 'Ticket price in advance', $event['priceInAdv']));
     $this->addElement($this->getElementCurrency($event['currency']));
     $this->addElement(Element::factory('text', 'website', 'Event website', $event['website']));
     $this->addElement(Element::factory('checkbox', 'showers', 'Showers', $event['showers']));
     $this->addElement($this->getElementSleeping($event['sleeping']));
     $this->addElement(Element::factory('checkbox', 'alcohol', 'Bring your own alcohol?', $event['alcohol']));
     $this->addElement(Element::factory('checkbox', 'smoking', 'Smoking area?', $event['smoking']));
     $this->addElement(Element::factory('numeric', 'networkMbps', 'Network (mbps)', $event['networkMbps']));
     $this->getElement('networkMbps')->addSuggestedValue('100', 'Old 100 meg network');
     $this->getElement('networkMbps')->addSuggestedValue('1000', 'Shiny Gigabit network');
     $this->addElement(Element::factory('numeric', 'internetMbps', 'Internet (mbps)', $event['internetMbps'], 'If you have an internet connection, what speed is it? Enter 0 for no connection.'));
     $this->getElement('internetMbps')->addSuggestedValue('0', 'No internet!');
     $this->getElement('internetMbps')->addSuggestedValue('2', '2mbps');
     $this->getElement('internetMbps')->addSuggestedValue('8', '8mbps');
     $this->addElement(Element::factory('numeric', 'numberOfSeats', 'Number of seats', $event['numberOfSeats']));
     $this->addElement(Element::factory('textarea', 'blurb', 'Additional blurb', htmlify($event['blurb'])));
     $this->addButtons(Form::BTN_SUBMIT);
 }
Example #2
0
 public function __construct()
 {
     parent::__construct('formNewEvent', 'New Event');
     if (Session::getUser()->hasPriv('CREATE_EVENTS')) {
         $this->addElement(Element::factory('html', 'msg', null, 'Hi superuser.'));
         if (isset($_REQUEST['formNewEvent-organizer'])) {
             $organizerId = intval($_REQUEST['formNewEvent-organizer']);
             $this->addElement(Element::factory('hidden', 'organizer', 'Organizer', $organizerId));
             $this->addElement(FormHelpers::getVenueListElement($organizerId));
         } else {
             $this->addElement(FormHelpers::getOrganizerList(true));
             $this->addElement(FormHelpers::getVenueListElement());
         }
     } else {
         if (Session::getUser()->getData('organization')) {
             $organizer = fetchOrganizer(Session::getUser()->getData('organization'));
             if ($organizer['published']) {
                 $this->addElement(Element::factory('html', 'msg', null, 'You are authorized to create public events for your organization.'));
             } else {
                 $this->addElement(Element::factory('html', 'msg', null, 'Your event will be linked to your organization, but will not be public until your organization has been approved.'));
             }
             try {
                 $this->addElement(FormHelpers::getVenueListElement(Session::getUser()->getData('organization')));
             } catch (Exception $e) {
                 redirect('account.php', 'Create a venue first!');
             }
         } else {
             $this->addElement(Element::factory('html', 'msg', null, 'You can create events, but they will not appear in public lists until approved.'));
         }
     }
     $this->addElement(Element::factory('text', 'title', 'Title', null, 'eg: MyLan 2011'));
     $this->addElement(Element::factory('text', 'eventWebsite', 'Event specific URL', null, 'A URL to the event webpage on the organizer website would be useful.'));
     $this->getElement('eventWebsite')->setMinMaxLengths(0, 256);
     $this->addElement(Element::factory('text', 'dateStart', 'Start date'));
     $this->addElement(Element::factory('text', 'dateFinish', 'Finish date'));
     $this->addElement(Element::factory('html', 'protip', null, '<strong style = "text-decoration: blink; color: red;">Protip:</strong> You can edit this event and add much more detail after you have created it. '));
     $this->addScript('$("#formNewEvent-dateStart").datetime({chainTo: "#formNewEvent-dateFinish", stepMins: 15, first: 3})');
     $this->addButtons(Form::BTN_SUBMIT);
     $this->requireFields(array('title'));
 }