Пример #1
0
 /**
  * @return null
  */
 public function on($name, $handler)
 {
     $event = new Event();
     $event->setName($name);
     $event->setHandler($handler);
     $this->addEvent($event);
 }
Пример #2
0
 /**
  * Create an event
  * @return void
  */
 private function createEvent()
 {
     // if post data is set, we are creating an event
     if (isset($_POST) && count($_POST) > 0) {
         require_once FRAMEWORK_PATH . 'models/event.php';
         $event = new Event($this->registry, 0);
         $event->setName($this->registry->getObject('db')->sanitizeData($_POST['name']));
         $event->setDescription($this->registry->getObject('db')->sanitizeData($_POST['description']));
         $event->setDate($this->registry->getObject('db')->sanitizeData($_POST['date']), false);
         $event->setStartTime($this->registry->getObject('db')->sanitizeData($_POST['start_time']));
         $event->setEndTime($this->registry->getObject('db')->sanitizeData($_POST['end_time']));
         $event->setCreator($this->registry->getObject('authenticate')->getUser()->getID());
         $event->setType($this->registry->getObject('db')->sanitizeData($_POST['type']));
         if (isset($_POST['invitees']) && is_array($_POST['invitees']) && count($_POST['invitees']) > 0) {
             // assumes invitees are added to a table using javascript, with a hidden field with name invitees[] for the ID of invitee
             $is = array();
             foreach ($_POST['invitees'] as $i) {
                 $is[] = intval($i);
             }
             $event->setInvitees($is);
         }
         $event->save();
         $this->registry->redirectUser($this->registry->buildURL(array('event', 'view', $event->getID()), '', false), 'Event created', 'Thanks, the event has been created', false);
     } else {
         $this->registry->getObject('template')->buildFromTemplates('header.tpl.php', 'events/create.tpl.php', 'footer.tpl.php');
     }
 }
Пример #3
0
 public function load(ObjectManager $manager)
 {
     $testEvent = new Event();
     $testEvent->setStartDate(date("d/m/Y"));
     $testEvent->setName('TestEvent');
     //$testEvent->setOwner('James');
     $manager->persist($testEvent);
     $manager->flush();
     $this->addReference('test-event', $testEvent);
 }
Пример #4
0
 /**
  * {@inheritdoc}
  */
 public function dispatch($eventName, Event $event = null)
 {
     if (null === $event) {
         $event = new Event();
     }
     $event->setDispatcher($this);
     $event->setName($eventName);
     if ($listeners = $this->getListeners($eventName)) {
         $this->doDispatch($listeners, $eventName, $event);
     }
     return $event;
 }
Пример #5
0
 /**
  * @see EventDispatcherInterface::dispatch
  *
  * @api
  */
 public function dispatch($eventName, Event $event = null)
 {
     if (!isset($this->listeners[$eventName])) {
         return;
     }
     if (null === $event) {
         $event = new Event();
     }
     $event->setDispatcher($this);
     $event->setName($eventName);
     $this->doDispatch($this->getListeners($eventName), $eventName, $event);
 }
 /**
  * @see IDispatcher::dispatch
  *
  * @api
  */
 public function dispatch($eventName, \Flywheel\Event\Event $event = null)
 {
     if (null === $event) {
         $event = new Event();
     }
     $event->setDispatcher($this);
     $event->setName($eventName);
     if (!isset($this->_listeners[$eventName])) {
         return $event;
     }
     $this->doDispatch($this->getListeners($eventName), $eventName, $event);
     return $event;
 }
Пример #7
0
 public static function find($id)
 {
     $event_query = getEvent($id);
     $event = new Event();
     $event->setId($event_query["id"]);
     $event->setDate($event_query["date"]);
     $event->setDescription($event_query["description"]);
     $event->setName($event_query["name"]);
     $event->setPublic($event_query["public"]);
     $event->setOwner($event_query["owner"]);
     $event->setImagePath($event_query["imagePath"]);
     return $event;
 }
Пример #8
0
 public static function fromArray($input)
 {
     $event = null;
     if (array_key_exists('id', $input)) {
         try {
             // get event by id
             $event = new Event($input['id']);
         } catch (fExpectedException $e) {
         }
     }
     if ($event == null) {
         $event = new Event();
         $event->generateSecret();
         $event->setHidden(1);
     }
     // These are marked as required
     $event->setTitle(get($input['title'], 'Title missing'));
     $event->setLocname(get($input['venue'], 'Venue missing'));
     $event->setAddress(get($input['address'], 'Address missing'));
     $event->setName(get($input['organizer'], 'Organizer missing'));
     $event->setEmail(get($input['email'], 'Email missing'));
     // These are optional
     $event->setHideemail(get($input['hideemail'], 0));
     $event->setPhone(get($input['phone'], ''));
     $event->setHidephone(get($input['hidephone'], 0));
     $event->setContact(get($input['contact'], ''));
     $event->setHidecontact(get($input['hidecontact'], 0));
     $event->setDescr(get($input['details'], ''));
     $event->setEventtime(get($input['time'], ''));
     $event->setHighlight(0);
     $event->setTimedetails(get($input['timedetails'], ''));
     $event->setLocdetails(get($input['locdetails'], ''));
     $event->setEventduration(get($input['eventduration'], 0));
     $event->setWeburl(get($input['weburl'], ''));
     $event->setWebname(get($input['webname'], ''));
     $event->setAudience(get($input['audience'], ''));
     $event->setTinytitle(get($input['tinytitle'], ''));
     $event->setPrintdescr(get($input['printdescr'], ''));
     $event->setDates(get($input['datestring'], ''));
     // string field 'dates' needed for legacy admin calendar
     $event->setDatestype(get($input['datestype'], 'O'));
     $event->setArea(get($input['area'], 'P'));
     // default to 'P'ortland
     //$event->setPrintcontact(get($input['printcontact'], ''));
     // Length
     return $event;
 }
Пример #9
0
 /**
  * Dispatches an event by dispatching arguments to all listeners that handle the event.
  *
  * @param   string         $name  The event name
  * @param   object|array   $event An array, a ObjectConfig or a Event object
  * @return  Event
  */
 public function dispatchEvent($name, $event = array())
 {
     $result = array();
     //Make sure we have an event object
     if (!$event instanceof Event) {
         $event = new Event($event);
     }
     $event->setName($name)->setDispatcher($this);
     //Notify the listeners
     $listeners = $this->getListeners($name);
     foreach ($listeners as $listener) {
         call_user_func($listener, $event);
         if (!$event->canPropagate()) {
             break;
         }
     }
     return $event;
 }
Пример #10
0
 /**
  * {@inheritDoc}
  */
 public function dispatch($eventName, EventInterface $event = null)
 {
     if ($event === null) {
         $event = new Event();
     }
     $event->setName($eventName);
     $event->setDispatcher($this);
     if (isset($this->listeners[$eventName])) {
         foreach ($this->listeners[$eventName] as $priority => $listeners) {
             foreach ($listeners as $key => $listener) {
                 $listener->notify($event);
                 if ($event->isPropagationStopped()) {
                     break;
                 }
             }
             if ($event->isPropagationStopped()) {
                 break;
             }
         }
     }
     return $event;
 }
Пример #11
0
 /**
  * The file contents is looked at and events are created here.
  * @param string $fileContents
  * @return integer The number of events saved.
  */
 public function setEventsFromICal($fullDir, $fullFileName, $personId)
 {
     //start parse of local file
     $v = new vcalendar();
     // set directory
     $v->setConfig('directory', $fullDir);
     // set file name
     $v->setConfig('filename', $fullFileName);
     $v->parse();
     $count = 0;
     foreach ($v->components as $component => $info) {
         # get first vevent
         $comp = $v->getComponent("VEVENT");
         $summary_array = $comp->getProperty("summary", 1, TRUE);
         //echo "Event: ", $summary_array["value"], "\n";
         $dtstart_array = $comp->getProperty("dtstart", 1, TRUE);
         $dtstart = $dtstart_array["value"];
         $startDate = "{$dtstart["year"]}-{$dtstart["month"]}-{$dtstart["day"]}";
         $startTime = "{$dtstart["hour"]}:{$dtstart["min"]}:{$dtstart["sec"]}";
         $dtend_array = $comp->getProperty("dtend", 1, TRUE);
         $dtend = $dtend_array["value"];
         $endDate = "{$dtend["year"]}-{$dtend["month"]}-{$dtend["day"]}";
         $endTime = "{$dtend["hour"]}:{$dtend["min"]}:{$dtend["sec"]}";
         //echo "start: ",  $startDate,"T",$startTime, "\n";
         //echo "end: ",  $endDate,"T",$endTime, "\n";
         $location_array = $comp->getProperty("location", 1, TRUE);
         //echo "Location: ", $location_array["value"], "\n <br>";
         //TODO: Check that this event does not already exist.
         $event = new Event();
         $event->setPersonId($personId);
         $event->setName($summary_array["value"]);
         $event->setStartTime($startDate . "T" . $startTime);
         $event->setEndTime($endDate . "T" . $endTime);
         $event->setLocation($location_array["value"]);
         $event->save();
         $count++;
     }
     return $count;
 }
Пример #12
0
 /**
  * Dispatch all listeners of a given event until one returns a non null value.
  *
  * @param  Event $event A Event instance
  *
  * @return Event The Event instance
  */
 public function dispatchUntil($eventName, Event $event)
 {
     // skip dispatching because event is already dispatched
     if ($event->isProcessed()) {
         return $event;
     }
     // skip dispatching because event hasn't listeners
     if (!$this->hasListeners($eventName)) {
         return $event;
     }
     $event->setName($eventName);
     foreach ($this->getListeners($event->getName()) as $listener) {
         if (call_user_func($listener, $event)) {
             $event->setProcessed(true);
             break;
         }
     }
     return $event;
 }
Пример #13
0
            $status = 200;
            $response["code"] = $status;
            $response["error"] = 1;
            $response["error_message"] = "Some error occured while updating contingent {$contingent->getId()}.";
        }
    } else {
        $response["error"] = 1;
        $response["error_message"] = "Invalid ID,Expecting numeric ID";
    }
    print json_encode($response);
});
$app->put('/event/:id', function ($id) use($app, $eventMapper) {
    verifyRequiredParams(array('id', 'logo'));
    $event = new Event();
    $event->setId($id);
    $event->setName($app->request()->put('name'));
    $event->setDetails($app->request()->put('details'));
    $event->setSlogan($app->request()->put('slogan'));
    $event->setCategory($app->request()->put('type'));
    $event->setRules($app->request()->put('rules'));
    $event->setStartDate($app->request()->put('start_date'));
    $event->setEndDate($app->request()->put('end_date'));
    $event->setStartTime($app->request()->put('start_time'));
    $event->setEndTime($app->request()->put('end_time'));
    $event->setGroupSize($app->request()->put('group_size'));
    $event->setLogo($app->request()->put('logo'));
    # --Getting the put vars and typecasting to int. Blehhh. Can't help, its PHP xD
    $feeHome = $app->request()->put('fee_home');
    settype($feeHome, "integer");
    $feeRemote = $app->request()->put('fee_remote');
    settype($feeRemote, "integer");
Пример #14
0
 /**
  * set non-string name
  *
  * @covers Phossa\Event\Event::setName
  * @expectedExceptionCode Phossa\Event\Message\Message::INVALID_EVENT_NAME
  * @expectedException Phossa\Event\Exception\InvalidArgumentException
  */
 public function testSetName3()
 {
     $newname = 100;
     $this->object->setName($newname);
     $this->assertTrue($newname === $this->object->getName());
 }
Пример #15
0
Файл: app.php Проект: avelrd/bam
$app->get('/events', function () use($app, $em) {
    $events = $em->getRepository('Event')->findAll();
    $encoded = [];
    foreach ($events as $event) {
        $encoded[] = json_encode_event($event);
    }
    return new JsonResponse($encoded);
});
$app->post('/events/add', function (Request $request) use($app, $em) {
    $event = new Event();
    $event->setStartdate($request->get('startdate', null));
    $event->setEnddate($request->get('enddate', null));
    $event->setUsers($request->get('users', []));
    $event->setLocation($request->get('location', ''));
    $event->setDescription($request->get('description', ''));
    $event->setName($request->get('name', null));
    $event->setHosts($request->get('hosts', []));
    $event->setTags($request->get('tags', []));
    if ($event->getName() === null) {
        return new JsonResponse(['error' => 'No name set'], 500);
    }
    $em->persist($event);
    $em->flush();
    return new JsonResponse(['success' => 'Event stored']);
});
//$app->get('/events/get/{id}', function ($id) use ($app, $em) {
//
//    $event = $em->getRepository('Event')->find($id);
//    return new JsonResponse(json_encode_event($event));
//
//});
Пример #16
0
 protected function processForm(sfWebRequest $request, sfForm $form)
 {
     //var_dump($request->getParameter('event[start_time]'));
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($form->isValid()) {
         //$event = $form->save();
         $name = $form->getValue('name');
         $venue = $form->getValue('venue');
         $description = $form->getValue('description');
         $price = $form->getValue('price');
         $c_ids = $form->getValue('category_ids');
         $event_url = $form->getValue('event_url');
         $start_time = $form->getValue('start_time');
         $end_time = $form->getValue('end_time');
         $date = $form->getValue('date');
         $o_id = $form->getValue('organizer_id');
         $event = null;
         if (!$form->getObject()->isNew()) {
             $event = $form->getObject();
             //Delete previous relations to genres
             Doctrine_Core::getTable('EventCategory')->createQuery()->delete()->where('event_id = ?', $event->getId())->execute();
         } else {
             $event = new Event();
         }
         if ($event === null) {
             $event = new Event();
         }
         //$event = new Event();
         //$event->setCategoryId($c_id);
         $event->setName($name);
         $event->setDescription($description);
         $event->setPrice($price);
         $event->setVenue($venue);
         $event->setEventUrl($event_url);
         $event->setStartTime($start_time);
         $event->setEndTime($end_time);
         $event->setOrganizerId($o_id);
         $sql_date = date("Y-m-d", strtotime($date));
         $event->setDate($sql_date);
         $event->save();
         foreach ($c_ids as $cid) {
             $ec = new EventCategory();
             $ec->setEventId($event->getId());
             $ec->setCategoryId($cid);
             $ec->save();
         }
         $this->getUser()->setAttribute('m', 1);
         $this->redirect('organize/edit?id=' . $event->getId() . '&m=1');
     }
 }
Пример #17
0
 /**
  */
 public function testGetName()
 {
     $event = new Event();
     $event->setName('test');
     $this->assertEquals('test', $event->getName());
 }