Exemplo n.º 1
0
 protected function createEvent()
 {
     $event = new Event();
     $event->setTitle('Test Event #1');
     $event->setStartDate('2010-06-01');
     return $event;
 }
Exemplo n.º 2
0
    public function testTitle()
    {
        $event = new Event();

        $this->assertNull($event->getTitle());

        $event->setTitle('Do absolutely nothing');
        $this->assertEquals('Do absolutely nothing', $event->getTitle());
    }
Exemplo n.º 3
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;
 }
Exemplo n.º 4
0
 public function getEvents($location, DateTime $date)
 {
     $c = curl_init();
     curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($c, CURLOPT_HTTPHEADER, array('Accept: application/json', 'Content-Type: application/json'));
     curl_setopt($c, CURLOPT_FOLLOWLOCATION, TRUE);
     // using Nette\Web\Uri for escaping GET parameters
     $uri = new Uri('http://api.eventful.com/rest/events/search');
     $uri->setQuery(array('user' => $this->user, 'password' => $this->password, 'app_key' => $this->key, 'location' => $location, 'within' => '10', 'units' => 'km'));
     curl_setopt($c, CURLOPT_URL, (string) $uri);
     $result = curl_exec($c);
     curl_close($c);
     $xml = @simplexml_load_string($result, 'SimpleXMLElement', LIBXML_NOCDATA);
     if ($xml == FALSE) {
         throw new InvalidStateException('Malformed XML response.');
     }
     $events = array();
     foreach ($xml->events->event as $xmlEvent) {
         $event = new Event();
         $event->setTitle((string) $xmlEvent->title)->setUrl((string) $xmlEvent->url)->setDescription((string) $xmlEvent->description)->setDate(DateTime::createFromFormat('Y-m-d H:i:s', (string) $xmlEvent->start_time))->setVenue(new Venue((string) $xmlEvent->venue_name, (string) $xmlEvent->venue_url))->setLatitude((string) $xmlEvent->latitude)->setLongitude((string) $xmlEvent->longitude);
         $events[] = $event;
     }
     return $events;
 }
Exemplo n.º 5
0
 /**
  * Create a Event from the submitted data.<br/>
  *
  * @ApiDoc(
  *   resource = true,
  *   description = "Creates a new event from the submitted data.",
  *   statusCodes = {
  *     201 = "Returned when successful",
  *     400 = "Returned when the form has errors"
  *   }
  * )
  *
  * @param int $id id
  *
  * @param ParamFetcher $paramFetcher Paramfetcher
  *
  * @RequestParam(name="title", nullable=false, strict=true, description="Title.")
  * @RequestParam(name="description", nullable=false, strict=true, description="Description.")
  * @RequestParam(name="startDateTime", nullable=false, strict=true, description="Date de début.")
  * @RequestParam(name="endDateTime", nullable=false, strict=true, description="Date de fin.")
  *
  * @return View
  */
 public function postProjectEventAction($id, ParamFetcher $paramFetcher)
 {
     $eventRepository = $this->getDoctrine()->getRepository('ReservationBundle:Event');
     $projectRepository = $this->getDoctrine()->getRepository('CustomFosUserBundle:Project');
     $project = $projectRepository->find($id);
     $event = new Event();
     $event->setTitle($paramFetcher->get('title'));
     $event->setDescription($paramFetcher->get('description'));
     $event->setUser($this->getUser());
     $event->setCreationDateTime();
     $event->setStartDateTime($paramFetcher->get('startDateTime'));
     $event->setEndDateTime($paramFetcher->get('endDateTime'));
     $event->setProject($project);
     $view = View::create();
     $errors = $this->get('validator')->validate($event, array('Registration'));
     if (count($errors) == 0) {
         $em = $this->getDoctrine()->getManager();
         $em->persist($event);
         $em->flush();
         $view->setData($event)->setStatusCode(201);
         return $view;
     } else {
         $view = $this->getErrorsView($errors);
         return $view;
     }
 }
Exemplo n.º 6
0
 public function testPopulateReverseOneToOne()
 {
     $event = new Event();
     $event->setTitle('Test Event');
     $event->setStartDate('today');
     $event->populateEventSlot();
     $event->populateEventDetail();
     $event->store();
 }
Exemplo n.º 7
0
 public function testDeleteForceCascadeManyToMany()
 {
     $event = new Event();
     $event->setTitle('Delete Restrict Event');
     $event->setStartDate(new fDate());
     $event->associateArtists(array(1));
     $event->store();
     $event->delete(TRUE);
     $this->assertEquals(FALSE, $event->exists());
 }
 }
 if (isset($_POST["end_time"])) {
     $end_time = htmlspecialchars($_POST["end_time"]);
 }
 if (isset($_POST["location"])) {
     $location = htmlspecialchars($_POST["location"]);
 }
 if (isset($_POST["description"])) {
     $description = htmlspecialchars($_POST["description"]);
 }
 if (isset($_POST["max_attendance"])) {
     $max_attendance = htmlspecialchars($_POST["max_attendance"]);
 }
 // set up event object
 $event = new Event();
 $event->setTitle($title);
 $event->setDate($date);
 $event->setStartTime($start_time);
 $event->setEndTime($end_time);
 $event->setLocation($location);
 $event->setDescription($description);
 $event->setMaxAttendance($max_attendance);
 $event->setCreatorUserId($_SESSION['uid']);
 $failure_messages = array();
 if (!$event->validate()) {
     foreach ($event->getValidationFailures() as $failure) {
         $message = '<p><strong>Error in ' . $failure->getPropertyPath() . ' field!</strong> ' . $failure->getMessage() . '</p>';
         array_push($failure_messages, $message);
         // clear out the bad data
         $_POST[$failure->getPropertyPath()] = '';
     }
 /**
  * Run method with main page logic
  * 
  * Populate template and display form for creating a new event entry. Regular users are allowed to create events but an
  * admin must approve them before they are visible on the site. Trusted users are allowed to create
  * events that will immediately be visible on the event calendar. For POST request,
  * validate form data and save information to database. Available to members only
  * @access public
  */
 public function run()
 {
     $session = Session::getInstance();
     $user = $session->getUser();
     //if (!$user || !$user->isAdmin ()) {
     if (!$user || !$user->validUser()) {
         $session->setMessage("Do not have permission to access", Session::MESSAGE_ERROR);
         header("Location: " . BASE_URL);
         return;
     }
     $form_errors = array();
     $form_values = array("title" => "", "description" => "", "sanctioned" => "", "status" => "", "date" => "", "platform" => "");
     $eventDAO = EventDAO::getInstance();
     //$event_array = $eventDAO->all ();
     if (!empty($_POST)) {
         $form_values["title"] = isset($_POST["title"]) ? trim($_POST["title"]) : "";
         $form_values["description"] = isset($_POST["description"]) ? trim($_POST["description"]) : "";
         $form_values["platform"] = isset($_POST["platform"]) ? trim($_POST["platform"]) : "";
         $form_values["sanctioned"] = isset($_POST["sanctioned"]) ? trim($_POST["sanctioned"]) : "";
         $form_values["status"] = isset($_POST["status"]) ? trim($_POST["status"]) : "";
         $form_values["date"] = isset($_POST["date"]) ? trim($_POST["date"]) : "";
         if (empty($form_values["title"])) {
             $form_errors["title"] = "No title specified";
         }
         if (empty($form_values["description"])) {
             $form_errors["description"] = "No description specified";
         }
         if (empty($form_values["platform"])) {
             $form_errors["platform"] = "No platform specified";
         } else {
             if (!is_numeric($form_values["platform"])) {
                 $form_errors["platform"] = "Platform choice must be an integer value";
             } else {
                 $platform = intval($form_values["platform"]);
                 $tmp = new Event();
                 try {
                     $tmp->setPlatformId($platform);
                 } catch (Exception $e) {
                     $form_errors["platform"] = "Invalid value for platform";
                 }
             }
         }
         if ($user->isAdmin() && empty($form_values["sanctioned"])) {
             $form_errors["sanctioned"] = "No sanctioned flag specified";
         } else {
             if ($user->isAdmin() && strcmp($form_values["sanctioned"], "true") != 0 && strcmp($form_values["sanctioned"], "false") != 0) {
                 $form_errors["sanctioned"] = "sanctioned flag must be a boolean value";
             }
         }
         if ($user->isAdmin() && empty($form_values["status"])) {
             $form_errors["status"] = "No status flag specified";
         } else {
             if ($user->isAdmin() && !is_numeric($form_values["status"])) {
                 $form_errors["status"] = "Status flag must be an integer value";
             } else {
                 if ($user->isAdmin()) {
                     $status = intval($form_values["status"]);
                     $tmp = new Event();
                     try {
                         $tmp->setStatus($status);
                     } catch (Exception $e) {
                         $form_errors["status"] = "Invalid value for status";
                     }
                 }
             }
         }
         if (empty($form_values["date"])) {
             $form_errors["date"] = "No date specified";
         } else {
             if (strtotime($_POST["date"]) == 0) {
                 $form_errors["date"] = "An invalid date was specified";
                 $form_values["date"] = "";
             }
         }
         if (empty($form_errors)) {
             $event = new Event();
             $event->setTitle($form_values["title"]);
             $event->setDescription($form_values["description"]);
             $event->setPlatformId(intval($form_values["platform"]));
             if ($user->isAdmin() || $user->validUser() && $user->getUserType() == User::TRUSTED_TYPE) {
                 $sanctioned_value = strcmp($form_values["sanctioned"], "true") == 0 ? true : false;
                 $event->setSanctioned($sanctioned_value);
                 $event->setStatus($form_values["status"]);
             } else {
                 if ($user->validUser()) {
                     $event->setSanctioned(false);
                     $event->setStatus(Event::PENDING_STATUS);
                 }
             }
             $pubtimestamp = strtotime($_POST["date"]);
             $event->setDate($pubtimestamp);
             $event->setUserId($user->id);
             //print_r ($event);
             if ($eventDAO->insert($event)) {
                 $session->setMessage("Event details saved");
                 header("Location: edit_event.php?id={$event->id}");
                 return;
             } else {
                 $session->setMessage("Event details could not be saved", Session::MESSAGE_ERROR);
             }
         }
     }
     $platformDAO = PlatformDAO::getInstance();
     $platform_array = $platformDAO->all();
     $this->template->render(array("title" => "Create Event", "extra_header" => joinPath("headers", "jscal_header_tpl.php"), "main_page" => "create_event_tpl.php", "session" => $session, "form_errors" => $form_errors, "form_values" => $form_values, "platform_array" => $platform_array));
 }
Exemplo n.º 10
0
 function parse($syncId, &$nbEvents = 0, $enableCache = true, $forceFeed = false)
 {
     $nbEvents = 0;
     assert('is_int($syncId) && $syncId>0');
     if (empty($this->id) || 0 == $this->id) {
         /* Le flux ne dispose pas pas d'id !. Ça arrive si on appelle
            parse() sans avoir appelé save() pour un nouveau flux.
            @TODO: un create() pour un nouveau flux ? */
         $msg = 'Empty or null id for a feed! ' . 'See ' . __FILE__ . ' on line ' . __LINE__;
         error_log($msg, E_USER_ERROR);
         die($msg);
         // Arrêt, sinon création événements sans flux associé.
     }
     $feed = new SimplePie();
     $feed->enable_cache($enableCache);
     $feed->force_feed($forceFeed);
     $feed->set_feed_url($this->url);
     $feed->set_useragent('Mozilla/4.0 Leed (LightFeed Aggregator) ' . VERSION_NAME . ' by idleman http://projet.idleman.fr/leed');
     if (!$feed->init()) {
         $this->error = $feed->error;
         $this->lastupdate = $_SERVER['REQUEST_TIME'];
         $this->save();
         return false;
     }
     $feed->handle_content_type();
     // UTF-8 par défaut pour SimplePie
     if ($this->name == '') {
         $this->name = $feed->get_title();
     }
     if ($this->name == '') {
         $this->name = $this->url;
     }
     $this->website = $feed->get_link();
     $this->description = $feed->get_description();
     $items = $feed->get_items();
     $eventManager = new Event();
     $events = array();
     $iEvents = 0;
     foreach ($items as $item) {
         // Ne retient que les 100 premiers éléments de flux.
         if ($iEvents++ >= 100) {
             break;
         }
         // Si le guid existe déjà, on évite de le reparcourir.
         $alreadyParsed = $eventManager->load(array('guid' => $item->get_id(), 'feed' => $this->id));
         if (isset($alreadyParsed) && $alreadyParsed != false) {
             $events[] = $alreadyParsed->getId();
             continue;
         }
         // Initialisation des informations de l'événement (élt. de flux)
         $event = new Event();
         $event->setSyncId($syncId);
         $event->setGuid($item->get_id());
         $event->setTitle($item->get_title());
         $event->setPubdate($item->get_date());
         $event->setCreator('' == $item->get_author() ? '' : $item->get_author()->name);
         $event->setLink($item->get_permalink());
         $event->setFeed($this->id);
         $event->setUnread(1);
         // inexistant, donc non-lu
         //Gestion de la balise enclosure pour les podcasts et autre cochonneries :)
         $enclosure = $item->get_enclosure();
         if ($enclosure != null && $enclosure->link != '') {
             $enclosureName = substr($enclosure->link, strrpos($enclosure->link, '/') + 1, strlen($enclosure->link));
             $enclosureArgs = strpos($enclosureName, '?');
             if ($enclosureArgs !== false) {
                 $enclosureName = substr($enclosureName, 0, $enclosureArgs);
             }
             $enclosureFormat = isset($enclosure->handler) ? $enclosure->handler : substr($enclosureName, strrpos($enclosureName, '.') + 1);
             $enclosure = '<div class="enclosure"><h1>Fichier média :</h1><a href="' . $enclosure->link . '"> ' . $enclosureName . '</a> <span>(Format ' . strtoupper($enclosureFormat) . ', ' . Functions::convertFileSize($enclosure->length) . ')</span></div>';
         } else {
             $enclosure = '';
         }
         $event->setContent($item->get_content() . $enclosure);
         $event->setDescription($item->get_description() . $enclosure);
         if (trim($event->getDescription()) == '') {
             $event->setDescription(substr($event->getContent(), 0, 300) . '…<br><a href="' . $event->getLink() . '">Lire la suite de l\'article</a>');
         }
         if (trim($event->getContent()) == '') {
             $event->setContent($event->getDescription());
         }
         $event->setCategory($item->get_category());
         $event->save();
         $nbEvents++;
     }
     $listid = "";
     foreach ($events as $item) {
         $listid .= ',' . $item;
     }
     $query = 'UPDATE `' . MYSQL_PREFIX . 'event` SET syncId=' . $syncId . ' WHERE id in (0' . $listid . ');';
     $myQuery = $this->customQuery($query);
     $this->lastupdate = $_SERVER['REQUEST_TIME'];
     $this->save();
     return true;
 }
Exemplo n.º 11
0
 if (!$user->id()) {
     $errors[] = "Je bent niet ingelogd.";
 }
 // In case of multiple authors who can proofread, amend: don't update unless empty.
 if (!$event->userId()) {
     $event->setUserId($user->id());
 }
 list($date, $time) = explode(" ", $_POST['start']);
 list($day, $month, $year) = explode("-", $date);
 $start = "{$year}-{$month}-{$day} {$time}";
 $event->setStart($start);
 list($date, $time) = explode(" ", $_POST['end']);
 list($day, $month, $year) = explode("-", $date);
 $end = "{$year}-{$month}-{$day} {$time}";
 $event->setEnd($end);
 $event->setTitle($_POST['title']);
 $event->setDescription($_POST['description']);
 $event->setLocation($_POST['location']);
 $event->setFeatured(isset($_POST['featured']) && $_POST['featured'] == 'on' ? 1 : 0);
 $event->setVisible(isset($_POST['visible']) && $_POST['visible'] == 'on' ? 1 : 0);
 $event->setHashtags(isset($_POST['hashtags']) ? $_POST['hashtags'] : null);
 $event->setAlbumId(isset($_POST['albumId']) ? $_POST['albumId'] : null);
 if (!$event->title()) {
     $errors[] = "Je kunt geen event zonder titel opslaan!";
 }
 Log::debug($errors);
 if (!sizeof($errors)) {
     // Save event prior to publishing to create cname.
     $event->save();
     // Publish event.
     if (isset($_POST['connections'])) {
Exemplo n.º 12
0
 public function executeCreate()
 {
     if ($this->getRequest()->getMethod() != sfRequest::POST) {
         $this->event = new Event();
         $this->etime = new Etime();
         $this->forward404Unless($this->event);
         $this->forward404Unless($this->etime);
     } else {
         $event = new Event();
         $etime = new Etime();
         $event->setTitle($this->getRequestParameter('title'));
         $event->setStatusId($this->getRequestParameter('status_id') ? $this->getRequestParameter('status_id') : null);
         $event->setCategoryId($this->getRequestParameter('category_id') ? $this->getRequestParameter('category_id') : null);
         $event->setPublished($this->getRequestParameter('published', 0));
         $event->setMediaPotential($this->getRequestParameter('media_potential', 0));
         $event->setDescription($this->getRequestParameter('description'));
         $event->setNotes($this->getRequestParameter('notes'));
         $event->setImageUrl($this->getRequestParameter('image_url'));
         //      $event->setOrganiser($this->getRequestParameter('organiser'));
         //      $event->setInterestedParties($this->getRequestParameter('interested_parties'));
         $event->save();
         $etime->setEventId($event->getId());
         $etime->setTitle($this->getRequestParameter('etime_title'));
         $etime->setStartDate(strtotime($this->getRequestParameter('start_date') . ' ' . $this->getRequestParameter('start_date_time')));
         $etime->setEndDate(strtotime($this->getRequestParameter('end_date') . ' ' . $this->getRequestParameter('end_date_time')));
         $etime->setAllDay($this->getRequestParameter('all_day') ? $this->getRequestParameter('all_day') : false);
         $etime->setLocation($this->getRequestParameter('location'));
         $etime->setDescription($this->getRequestParameter('etime_description'));
         $etime->setNotes($this->getRequestParameter('etime_notes'));
         $etime->setCapacity($this->getRequestParameter('capacity') ? $this->getRequestParameter('capacity') : null);
         $etime->setAdditionalGuests($this->getRequestParameter('additional_guests') ? $this->getRequestParameter('additional_guests') : 0);
         $etime->setHasFee($this->getRequestParameter('has_fee') ? $this->getRequestParameter('has_fee') : false);
         $etime->setAudioVisualSupport($this->getRequestParameter('audio_visual_support') ? $this->getRequestParameter('audio_visual_support') : false);
         //      $etime->setOrganiser($this->getRequestParameter('etime_organiser'));
         //      $etime->setInterestedParties($this->getRequestParameter('etime_interested_parties'));
         $etime->save();
         // Update many-to-many for "etime_rsvp"
         $c = new Criteria();
         $c->add(EtimeRsvpPeer::ETIME_ID, $etime->getPrimaryKey());
         EtimeRsvpPeer::doDelete($c);
         $ids = $this->getRequestParameter('associated_etime_rsvp');
         if (is_array($ids)) {
             foreach ($ids as $id) {
                 $EtimeRsvp = new EtimeRsvp();
                 $EtimeRsvp->setEtime($etime);
                 $EtimeRsvp->setRsvpId($id);
                 $EtimeRsvp->save();
             }
         }
         // Update many-to-many for "etime_audience"
         $c = new Criteria();
         $c->add(EtimeAudiencePeer::ETIME_ID, $etime->getPrimaryKey());
         EtimeAudiencePeer::doDelete($c);
         $ids = $this->getRequestParameter('associated_etime_audience');
         if (is_array($ids)) {
             foreach ($ids as $id) {
                 $EtimeAudience = new EtimeAudience();
                 $EtimeAudience->setEtime($etime);
                 $EtimeAudience->setAudienceId($id);
                 $EtimeAudience->save();
             }
         }
         if ($this->getRequestParameter('tag_string')) {
             TagTools::recordTags($this->getRequestParameter('tag_string'), "event", $event);
         }
         if ($this->getRequestParameter('etime_tag_string')) {
             TagTools::recordTags($this->getRequestParameter('etime_tag_string'), "etime", $etime);
         }
         return $this->redirect('@show_event?slug=' . $event->getSlug());
     }
     return sfView::SUCCESS;
 }