private function createNewEvent($email, $password, $title, $venue, $privacy, $fees, $currency_country = "")
 {
     $response = array();
     $response["success"] = 0;
     //verify if the user exists
     $trycheck = new TryUserLogin($email, $password);
     if ($trycheck->isExists()) {
         $tryfetch = new TryFetchUser();
         $user = $tryfetch->fetch($email);
         if ($user != null) {
             $user_json = json_encode($user);
             $user_php = json_decode($user_json);
             $event = new Event($user_php->ID, $title, $venue, $privacy);
             $event->setCreateDate(Validator::Now());
             $event->setDuration("");
             $event->setStartDate("");
             $event->setDescription("");
             $event->setFees($fees);
             $event->setCurrencyCountry($currency_country);
             // $event->setSearchableKeywords($searchable);
             //validate the events
             if ($this->validate($event)) {
                 $response = $this->commit($event);
             } else {
                 $response["error_message"] = $this->__message;
             }
         }
     } else {
         $response["success"] = 0;
         $response["error_message"] = "relogin into your account , user session expired";
     }
     $jsonView = new JsonViewer();
     $jsonView->setContent($response);
     return $jsonView;
 }
Beispiel #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');
     }
 }
Beispiel #3
0
    public function testDescription()
    {
        $event = new Event();

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

        $event->setDescription('...Or try the sun');
        $this->assertEquals('...Or try the sun', $event->getDescription());
    }
Beispiel #4
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;
 }
Beispiel #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;
     }
 }
Beispiel #6
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');
     }
 }
 private function parserEventJson($jsonevent)
 {
     $event = null;
     //convert to php object
     $php_object = json_decode($jsonevent);
     if ($php_object != null) {
         $event = new Event($php_object->CreatorId, $php_object->Title, $php_object->Venue, $php_object->privacy);
         $event->setCurrencyCountry($php_object->current_country);
         $event->setSearchableKeywords($php_object->search_keywords);
         $event->setFees($php_object->fees);
         $event->setCurrencyCountry($php_object->current_country);
         $event->setCurrencyCountry($php_object->current_country);
         $event->setDescription($php_object->Description);
         $event->setStartDate($php_object->StartDate);
         $event->setGoing($php_object->going);
     }
     return $event;
 }
     $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()] = '';
     }
     unset($message);
 } else {
     // validate date fields
     //$now = new DateTime('now');
     $st = DateTime::createFromFormat("m/d/Y H:i A", $date . " " . $start_time);
$usageEvent1->setMerchantEventId("eventID-1-" . $testId);
// unique Id
$usageEvent1->setEventDate('2015-03-27T06:29:34-07:00');
$usageEvent1->setDescription("Service usage");
$usageEvent1->setMerchantAutoBillId("subscriptionID101");
// CashBox will automatically identify which AutoBill item the event should be
// applied to if there are no more than one item with same product. If the
// subscription
$usageEvent1->setMerchantProductId("ratedPriceProduct");
$usageEvent1->setAmount(14902);
// Separate event related to another subscription can be reported in a single call
$usageEvent2 = new Event();
$usageEvent2->setMerchantEventId("eventID-2-" . $testId);
// unique Id
$usageEvent2->setEventDate('2015-03-28T23:59:00-07:00');
$usageEvent2->setDescription("Service usage");
$usageEvent2->setMerchantAutoBillId("subscriptionID102");
$usageEvent2->setMerchantProductId("regular-product");
$usageEvent2->setAmount(159002);
// Now let's record the two events with CashBox
$rp = new RatePlan();
// This is the SOAP interface that supports the recordEvent call
$response = $rp->recordEvent(array($usageEvent1, $usageEvent2));
// up to 50 events can be put in the array
print_r($response);
if ($response['returnCode'] == 200) {
    print "Successfully reported events. Call SOAP ID" . $response['data']->return->soapId . "\n";
} else {
    print "Events could not be reported";
    print "Return code: " . $response['returnCode'] . " Return string: " . $response['returnString'] . " Call SOAP ID: " . $response['data']->return->soapId . "\n";
}
Beispiel #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;
 }
Beispiel #11
0
 public function executeAjaxSaveEvent(sfWebRequest $request, $xhr = true)
 {
     $reservation_id = $request->getParameter('id');
     $event_id = $request->getParameter('event_id');
     $event_designation = $request->getParameter('event_designation');
     $event_description = $request->getParameter('event_description');
     // ajout d'un event
     if ($event_id == "") {
         $event = new Event();
         $event->setDesignation($event_designation);
         $event->setDescription($event_description);
         $event->setReservationId($reservation_id);
         $event->save();
     } else {
         $event = Doctrine::getTable('Event')->find(array($event_id));
         $event->setDesignation($event_designation);
         $event->setDescription($event_description);
         $event->save();
     }
     $this->executeAjaxDetailedReservation($request, $xhr);
 }
Beispiel #12
0
     $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'])) {
         foreach ($_POST['connections'] as $id => $value) {
Beispiel #13
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;
 }
Beispiel #14
0
}
$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));
//
 /**
  * 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));
 }
Beispiel #16
0
        $enddt = date('Y-m-d', strtotime($_POST['start_time'])) . '23:59:59';
    } else {
        $enddt = date('Y-m-d', strtotime($_POST['start_time'])) . ' ' . trim($_POST['end_time']);
    }
    if (strtotime($enddt) < strtotime($_POST['start_time']) && $err == '') {
        $err = 'End time is not filled in, or, happens before the start time!';
    }
    $all_day = '0';
    if (isset($_POST['allday'])) {
        $all_day = '1';
    }
    if ($err == '') {
        print_r($_POST);
        $event = new Event();
        $event->setUserId(Authentication::get_user());
        $event->setDescription($_POST['event_name']);
        $event->setStartDateTime($_POST['start_time']);
        $event->setEndDateTime($enddt);
        $event->setRemindMeTime($_POST['remind_time']);
        $event->setAllDay($all_day);
        $event->save();
    }
}
?>

<!DOCTYPE html>
<html lang="en">
<?php 
head();
$viewing_by_day = false;
if (isset($_GET['view'])) {
 public static function findEvents($entityManager, $date)
 {
     error_log("date: " . $date->format('Y-m-d'));
     $query = $entityManager->createQuery('SELECT count(e) FROM Event e WHERE e.date LIKE :date');
     $query->setParameter("date", "%" . $date->format('m-d'));
     $eventNumber = $query->getSingleScalarResult();
     if ($eventNumber) {
         error_log("events for " . $date->format('Y-m-d') . " already exist.");
         return "1";
     }
     $dim = new \ThisDayIn\Music($date->format('j'), $date->format('F'));
     $evs = $dim->getEvents();
     foreach ($evs as $ev) {
         $date = new \DateTime($ev['date']);
         if ($ev['type'] === 'Death') {
             $ev['description'] = sprintf('%s, %s', $ev['name'], $ev['description']);
         }
         //unlike the death events, the birth events do not include enough information in the description.
         if ($ev['type'] === 'Birth') {
             $ev['description'] = sprintf('%s, %s was born', $ev['name'], $ev['description']);
         }
         //must find artist name for these kind of events
         if ($ev['type'] == 'Event') {
             $artist = self::findEventArtist($ev['description']);
             $ev['name'] = $artist['name'];
             if (isset($artist['spotifyId'])) {
                 $ev['spotifyId'] = $artist['spotifyId'];
             }
         }
         #TODO: find artist spotify id for the other event types
         //set current event
         $event = new \Event();
         $event->setDate($date);
         $event->setDescription($ev['description']);
         $event->setType($ev['type']);
         $event->setSource($dim->getSource());
         //connects the event to an artist
         if ($ev['name']) {
             $artist = $entityManager->getRepository('Artist')->findBy(array('name' => $ev['name']));
             $artist = array_shift($artist);
             if (!$artist) {
                 $artist = new \Artist();
                 $artist->setName($ev['name']);
                 if (isset($ev['spotifyId'])) {
                     $artist->setSpotifyId($ev['spotifyId']);
                 }
             }
             error_log("artist name: " . $artist->getName());
             $event->setArtist($artist);
             $entityManager->persist($event);
             $artist->assignToEvent($event);
             $entityManager->persist($artist);
             #one must save here so it copes for repeated artist in the event list
             $entityManager->flush();
         }
         $entityManager->persist($event);
     }
     //insert all events to db
     if (count($evs)) {
         $entityManager->flush();
     }
     return 0;
 }