public function calendar($society_id)
 {
     $events = $this->eventsForSociety($society_id)['events'];
     $vCalendar = new \Eluceo\iCal\Component\Calendar('lowdown.netsoc.co');
     foreach ($events as $event) {
         $vEvent = new \Eluceo\iCal\Component\Event();
         $eventTime = new DateTime($event->time);
         $endTime = $eventTime;
         $endTime->add(new DateInterval('PT1H'));
         $eventSummary = $event->society()->first()->name . ' Society: ' . $event->title;
         $vEvent->setDtStart($eventTime)->setDtEnd($endTime)->setSummary($eventSummary);
         if ($event->location) {
             $vEvent->setLocation($event->location);
         }
         $vCalendar->addComponent($vEvent);
     }
     header('Content-Type: text/calendar; charset=utf-8');
     header('Content-Disposition: attachment; filename="cal.ics"');
     echo $vCalendar->render();
 }
 /**
  * Renders an ical file for a specific group
  */
 public function group(Group $group)
 {
     // 1. Create new calendar
     $vCalendar = new \Eluceo\iCal\Component\Calendar(config('app.url'));
     $vCalendar->setName(config('mobilizator.name') . ' : ' . $group->name);
     $vCalendar->setDescription(summary($group->body, 500));
     // returns actions started the last 60 days
     $actions = $group->actions()->where('start', '>=', Carbon::now()->subDays(60))->get();
     foreach ($actions as $action) {
         // 2. Create an event
         $vEvent = new \Eluceo\iCal\Component\Event();
         $vEvent->setDtStart($action->start);
         $vEvent->setDtEnd($action->stop);
         $vEvent->setSummary($action->name);
         $vEvent->setDescription(summary($action->body), 1000);
         $vEvent->setLocation($action->location);
         $vEvent->setUrl(action('ActionController@show', [$action->group->id, $action->id]));
         $vEvent->setUseUtc(false);
         //TODO fixme
         $vCalendar->addComponent($vEvent);
     }
     return response($vCalendar->render())->header('Content-Type', 'text/calendar; charset=utf-8')->header('Content-Disposition', 'attachment; filename="cal.ics"');
 }
<?php

// use composer autoloader
require_once __DIR__ . '/../vendor/autoload.php';
// set default timezone (PHP 5.4)
date_default_timezone_set('Europe/Berlin');
// 1. Create new calendar
$vCalendar = new \Eluceo\iCal\Component\Calendar('www.example.com');
// 2. Create an event
$vEvent = new \Eluceo\iCal\Component\Event();
$vEvent->setDtStart(new \DateTime('2012-12-24'));
$vEvent->setDtEnd(new \DateTime('2012-12-24'));
$vEvent->setNoTime(true);
$vEvent->setSummary('Christmas');
$vEvent->setDescription('Happy Christmas!');
$vEvent->setDescriptionHTML('<b>Happy Christmas!</b>');
// add some location information for apple devices
$vEvent->setLocation("Infinite Loop\nCupertino CA 95014", 'Infinite Loop', '37.332095,-122.030743');
// 3. Add event to calendar
$vCalendar->addComponent($vEvent);
// 4. Set headers
header('Content-Type: text/calendar; charset=utf-8');
header('Content-Disposition: attachment; filename="cal.ics"');
// 5. Output
echo $vCalendar->render();
function makeICalendar($row)
{
    $vEvent = new \Eluceo\iCal\Component\Event();
    $vEvent->setDtStart(new \DateTime($row['startDate']));
    $vEvent->setDtEnd(new \DateTime($row['endDate']));
    $vEvent->setNoTime(false);
    $vEvent->setSummary($row['name'] . " 2016 New Years Levee");
    $vEvent->setLocation($row['location_name'] . "\n" . $row['location_address'], $row['location_name'], $row['latitude'] . "," . $row['longitude']);
    $vEvent->setUseTimezone(true);
    return $vEvent;
}
 public function ExportEventToICS(SS_HTTPRequest $request)
 {
     try {
         $event_ids = $request->getVar('events_id');
         if (is_null($event_ids)) {
             return $this->validationError("missing events_id param");
         }
         $event_ids = explode(',', $event_ids);
         // https://www.ietf.org/rfc/rfc2445.txt
         $vCalendar = new Calendar('www.openstack.org');
         foreach ($event_ids as $event_id) {
             $event = $this->summitevent_repository->getById($event_id);
             if (is_null($event)) {
                 throw new NotFoundEntityException('SummitEvent', sprintf(' id %s', $event_id));
             }
             if (!$event->isPublished()) {
                 throw new EntityValidationException(sprintf("event id %s does not belongs to schedule!", $event->getIdentifier()));
             }
             $vEvent = new \Eluceo\iCal\Component\Event(md5(uniqid(mt_rand(), true)) . "event");
             $vEvent->setCreated(new \DateTime())->setDtStart(new \DateTime($event->getStartDateUTC()))->setDtEnd(new \DateTime($event->getEndDateUTC()))->setNoTime(false)->setSummary($event->Title)->setDescription(strip_tags($event->ShortDescription))->setDescriptionHTML($event->ShortDescription);
             if ($location = $event->getLocation()) {
                 $venue = $location;
                 $geo = null;
                 if ($location->getTypeName() == SummitVenueRoom::TypeName) {
                     $venue = $location->getVenue();
                 }
                 if (is_a($venue, 'SummitGeoLocatedLocation')) {
                     $geo = sprintf("%s;%s", $venue->getLat(), $venue->getLng());
                 }
                 $vEvent->setLocation($location->getFullName(), $location->getFullName(), $geo);
             }
             $vCalendar->addComponent($vEvent);
         }
         $response = new SS_HTTPResponse($vCalendar->render(), 200);
         $response->addHeader("Content-type", "text/calendar; charset=utf-8");
         $response->addHeader("Content-Disposition", "inline; filename=event-" . implode('-', $event_ids) . ".ics");
         return $response;
     } catch (EntityValidationException $ex1) {
         SS_Log::log($ex1, SS_Log::WARN);
         return $this->validationError($ex1->getMessages());
     } catch (NotFoundEntityException $ex2) {
         SS_Log::log($ex2, SS_Log::WARN);
         return $this->notFound($ex2->getMessage());
     } catch (Exception $ex) {
         SS_Log::log($ex, SS_Log::ERR);
         return $this->serverError();
     }
 }
Exemple #6
0
 public function calendar($user_id)
 {
     $user_id = Crypt::decrypt($user_id);
     $soc_ids = DB::table('subscriptions')->where('user_id', $user_id)->lists('society_id');
     $events = Event::where('time', '>', date('Y-m-d H:i:s'))->whereIn('society_id', $soc_ids)->get();
     $vCalendar = new \Eluceo\iCal\Component\Calendar('lowdown.netsoc.co');
     foreach ($events as $event) {
         $vEvent = new \Eluceo\iCal\Component\Event();
         $eventTime = new DateTime($event->time);
         $endTime = $eventTime;
         $endTime->add(new DateInterval('PT1H'));
         $eventSummary = $event->society()->first()->name . ' Society: ' . $event->title;
         $vEvent->setDtStart($eventTime)->setDtEnd($endTime)->setSummary($eventSummary);
         if ($event->location) {
             $vEvent->setLocation($event->location);
         }
         $vCalendar->addComponent($vEvent);
     }
     header('Content-Type: text/calendar; charset=utf-8');
     header('Content-Disposition: attachment; filename="cal.ics"');
     echo $vCalendar->render();
 }
 public function generateIcal()
 {
     // set default timezone (PHP 5.4)
     date_default_timezone_set('Europe/Berlin');
     $ical_name = 'HSG Wesel - Gesamtspielplan';
     $ical_calid = 'hsg_wesel_1516_total';
     $ics_file_name = 'hsg_wesel_1516_total.ics';
     $team_info = $this->getTeamInfo();
     if (is_array($team_info)) {
         $ical_name = 'HSG Wesel - Saison 2015/16 - ' . $team_info['team'];
         $ical_calid = 'hsg_wesel_1516_' . $team_info['liga_id'];
         $ics_file_name = 'hsg_wesel_1516_' . $this->getTeam() . '.ics';
     } else {
         switch ($this->art) {
             case '188':
                 $ical_name = 'HSG Wesel - Saison 2015/16 - Spielplan Heim';
                 $ical_calid = 'hsg_wesel_1516_1330105011_heim';
                 $ics_file_name = 'hsg_wesel_1516_spielplan_heim' . '.ics';
                 break;
             case '199':
                 $ical_name = 'HSG Wesel - Saison 2015/16 - Spielplan Auswärts';
                 $ical_calid = 'hsg_wesel_1516_1330105011_auswaerts';
                 $ics_file_name = 'hsg_wesel_1516_auswaerts' . '.ics';
                 break;
         }
     }
     // 1. Create new calendar
     $vCalendar = new \Eluceo\iCal\Component\Calendar('HSG Wesel SIS-Handball ICS-Generator');
     $vCalendar->setName($ical_name);
     $vCalendar->setDescription('HSG Wesel / photominister.de');
     $vCalendar->setCalId($ical_calid);
     $vCalendar->setMethod('PUBLISH');
     // 2. Create an event
     // $this->framework->dump($this->art);
     if (count($this->xml->Spiel) > 0) {
         foreach ($this->xml->Spiel as $spiel) {
             $element = $this->getHash($spiel);
             $show_heim = substr($spiel->Heim, 0, 9) == 'HSG Wesel';
             $show_gast = substr($spiel->Gast, 0, 9) == 'HSG Wesel';
             switch ($this->art) {
                 case '188':
                     $cond = $show_heim;
                     break;
                 case '199':
                     $cond = $show_gast;
                     break;
                 default:
                     $cond = $show_heim || $show_gast;
                     break;
             }
             if ($cond) {
                 $description = $spiel->LigaName . '..... www.hsg-wesel.de ..... www.handballinwesel.de ..... www.facebook.com/hsgwesel';
                 $description = str_replace("\r\n", "\\n", $description);
                 $vEvent = new \Eluceo\iCal\Component\Event();
                 $vEvent->setDtStart(new \DateTime($spiel->SpielVon));
                 $vEvent->setDtEnd(new \DateTime($spiel->SpielBis));
                 $vEvent->setSummary($spiel->Heim . ' - ' . $spiel->Gast);
                 $vEvent->setDescription($description);
                 $vEvent->setLocation($spiel->HallenName . ', ' . $spiel->HallenStrasse . ', ' . $spiel->HallenOrt);
                 $vEvent->setUseTimezone(TRUE);
                 // 3. Add event to calendar
                 $vCalendar->addComponent($vEvent);
                 unset($vEvent);
             }
         }
     }
     // 4. Set headers
     header('Content-Type: text/calendar; charset=utf-8');
     header('Content-Disposition: attachment; filename="' . $ics_file_name . '"');
     // 5. Output
     echo $vCalendar->render();
     exit;
 }
 /**
  *
  */
 public function exportIcalAction()
 {
     require_once Mage::getBaseDir() . '/lib/iCal/Eluceo/iCal/Component.php';
     require_once Mage::getBaseDir() . '/lib/iCal/Eluceo/iCal/PropertyBag.php';
     require_once Mage::getBaseDir() . '/lib/iCal/Eluceo/iCal/Property.php';
     require_once Mage::getBaseDir() . '/lib/iCal/Eluceo/iCal/Component/Calendar.php';
     require_once Mage::getBaseDir() . '/lib/iCal/Eluceo/iCal/Component/Event.php';
     //date_default_timezone_set('Europe/Berlin');
     $vCalendar = new \Eluceo\iCal\Component\Calendar(Mage::app()->getStore()->getName());
     $coll = Mage::getModel('payperrentals/reservationorders')->getCollection()->groupByOrderId();
     if (urldecode($this->getRequest()->getParam('store'))) {
         $coll->getSelect()->joinLeft(array('so' => Mage::getSingleton('core/resource')->getTableName('sales_flat_order')), 'main_table.order_id = ' . 'so.entity_id', array('so.store_id as store_id'));
         $coll->getSelect()->where('so.store_id=?', $this->getRequest()->getParam('store'));
     }
     foreach ($coll as $item) {
         $_order = Mage::getModel('sales/order')->load($item->getOrderId());
         $_address = $_order->getShippingAddress();
         $vEvent = new \Eluceo\iCal\Component\Event();
         $vEvent->setDtStart(new \DateTime($item->getStartDate()));
         $vEvent->setDtEnd(new \DateTime($item->getEndDate()));
         $vEvent->setDescription($_order->getCustomerFirstname() . ' ' . $_order->getCustomerLastname());
         $_addressString = '';
         if ($_address instanceof Mage_Sales_Model_Order_Address) {
             $_addressString .= implode(' ', $_address->getStreet()) . ', ' . $_address->getPostcode() . ', ' . $_address->getCity();
         }
         $vEvent->setLocation($_order->getCustomerFirstname() . ' ' . $_order->getCustomerLastname() . ($_addressString != '' ? ', ' . $_addressString : ''));
         //$vEvent->setNoTime(true);
         $vEvent->setSummary($item->getOrderId());
         //$vEvent->setUseTimezone(true);
         $vCalendar->addEvent($vEvent);
     }
     header('Content-Type: text/calendar; charset=utf-8');
     header('Content-Disposition: attachment; filename="cal.ics"');
     echo $vCalendar->render();
 }
 /**
  * _getCalendarEvent
  * @param Cake\Entity $entity passed
  * @param array $options with extra settings
  * @return \Eluceo\iCal\Component\Event $vEvent
  */
 protected function _getCalendarEvent($entity, $options = [])
 {
     $vEvent = new \Eluceo\iCal\Component\Event();
     $vOrganizer = new \Eluceo\iCal\Property\Event\Organizer($options['organizer'], ['MAILTO' => $options['organizer']]);
     $vEvent->setOrganizer($vOrganizer);
     $vEvent->setSummary($options['subject']);
     if ($entity->description) {
         $vEvent->setDescription($entity->description);
     }
     $dates = $this->_getEventTime($entity, $options);
     $vEvent->setDtStart($dates['start']);
     $vEvent->setDtEnd($dates['end']);
     if ($entity->location) {
         $vEvent->setLocation($entity->location, "Location:");
     }
     return $vEvent;
 }