コード例 #1
0
/**
* Create a calendar event using Google Calendar API
* @return Google_Event
*/
function createCalendarEvent($_service) {	
	try	{		
		//create an event
		$event = new Google_Event();

		//event name
		$event->setSummary(argsToString());
		
		//actual date
		$datetime = new DateTime('now');		

		//set start event date
		$start = new Google_EventDateTime();
		$start->setDateTime($datetime->format("Y-m-d\TH:i:s"));
		$start->setTimeZone('Europe/Paris');			
		$event->setStart($start);								
		
		//set stop event date
		$end = new Google_EventDateTime();
		$end->setDateTime($datetime->format("Y-m-d\TH:i:s"));
		$end->setTimeZone('Europe/Paris');
		$event->setEnd($end);

        //insert event in calendar
		$eventCreated = $_service->events->insert(SolrSafeOperatorHelper::clusterIni('ConfigCalendar', 'CalendarId', 'calendar.ini'), $event);

		$cli = eZCLI::instance();
		$cli->output('Event id : ' . $eventCreated->getId() . ' created');	

		return $eventCreated;
	} catch (Exception $e) {
		$cli = eZCLI::instance();
		$cli->output($e->getMessage());		
	}
}
コード例 #2
0
ファイル: GoogleCalendar.php プロジェクト: balrok/aiajaya
 protected function createGoogleEventFromTermin($termin, $event = null)
 {
     // 'id' => '761',
     // 'datum' => '10.10.2012',
     // 'titel' => 'Dynamische Meditation',
     // 'untertitel' => 'mit Milam Horn --Anm: 0175-86 57 233',
     // 'zeit' => '06:00 Uhr',
     // 'url' => '',
     // 'from' => '1349848800',
     // 'to' => '1349848801',
     // 'gId' => '',
     if (!$event) {
         $event = new Google_Event();
     }
     $event->setSummary($termin->titel);
     $untertitel = str_replace('--', '<br/>', $termin->untertitel);
     $untertitel .= '<hr/>' . str_replace('--', '<br/>', $termin->datum) . ' ' . str_replace('--', '<br/>', $termin->zeit);
     if ($termin->url) {
         $untertitel .= '<hr/><a href="' . $termin->url . '">Weitere Informationen</a>';
     }
     $event->setDescription($untertitel);
     $to = $termin->to;
     $from = $termin->from;
     $days = 1;
     while ($to - $from > 60 * 60 * 24) {
         $to -= 60 * 60 * 24;
         $days++;
     }
     $start = new Google_EventDateTime();
     $start->setDateTime(date('Y-m-d\\TH:i:s', $from));
     $start->setTimezone('Europe/Berlin');
     $event->setStart($start);
     $end = new Google_EventDateTime();
     $end->setDateTime(date('Y-m-d\\TH:i:s', $to));
     $end->setTimezone('Europe/Berlin');
     $event->setEnd($end);
     if ($days > 1) {
         $freq = "RRULE:FREQ=DAILY;COUNT=" . $days;
         $event->setRecurrence(array($freq));
     }
     return $event;
 }
コード例 #3
0
 public function test()
 {
     $this->client = new Google_Client();
     $this->client->setApplicationName('Hangout Schedule');
     $this->client->setClientId('191072902750-o87q963i0t05pkb96mvfusb3gsutpsmv.apps.googleusercontent.com');
     $this->client->setClientSecret('KfLw32e9BM9GxfaGjUAOL3I2');
     $this->client->setRedirectUri('http://local.youniqueproducts.com/api/oauth2/responseFrom/Google');
     $this->client->setScopes("https://www.googleapis.com/auth/calendar");
     $service = new Google_Service_Calendar($this->client);
     $this->getAccessToken();
     $this->setTestData();
     $event = new Google_Event();
     $event->setSummary($this->testData['summary']);
     $event->setLocation('Younique Virtual Party!');
     $start = new Google_EventDateTime();
     $start->setDateTime($this->testData['start']['dateTime'] . '.000-00:00');
     $event->setStart($start);
     $end = new Google_EventDateTime();
     $end->setDateTime($this->testData['end']['dateTime'] . '.000-00:00');
     $event->setEnd($end);
     //        $attendee1 = new Google_EventAttendee();
     //        $attendee1->setEmail('*****@*****.**');
     //        $attendees = array($attendee1);
     //        $event->attendees = $attendees;
     $createdEvent = $service->events->insert('primary', $event);
     var_dump($createdEvent);
 }
コード例 #4
0
 public function AddActivitat($id, $timestamp_inici, $timestamp_fi, $organitzador, $email, $titol, $link, $location, $summary, $description, $calendarid, $color_id, $idS)
 {
     date_default_timezone_set('Europe/Madrid');
     //echo date(DateTime::RFC3339,mktime(17,30,00,1,14,2013));
     $E = new Google_Event();
     $O = new Google_EventOrganizer();
     $O->setDisplayName($titol);
     $O->setEmail($email);
     $E->setOrganizer($O);
     $E->setSummary($titol);
     $E->setHtmlLink($link);
     $E->setLocation($location);
     $E->setDescription(html_entity_decode(strip_tags($description)));
     $start = new Google_EventDateTime();
     $start->setDateTime(date(DateTime::RFC3339, $timestamp_inici));
     $E->setStart($start);
     $end = new Google_EventDateTime();
     $end->setDateTime(date(DateTime::RFC3339, $timestamp_fi));
     $E->setEnd($end);
     $E->setColorId($color_id);
     $this->cal->events->insert(OptionsPeer::getString('GOOGLE_CALENDAR_ID', $idS), $E);
 }
コード例 #5
0
ファイル: Event.php プロジェクト: Rademade/MedOptima
 private function _process(Google_Event $event)
 {
     $event->setSummary($this->_getReservationSummary());
     $event->setDescription($this->_getReservationDescription());
     $timeBegin = DateTime::createFromTimestamp($this->_reservation->getFinalVisitTime());
     $timeEnd = DateTime::createFromTimestamp($this->_reservation->getVisitEndTime());
     $timeEventBegin = new Google_EventDateTime();
     $timeEventEnd = new Google_EventDateTime();
     $timeEventBegin->setDateTime($timeBegin->getGoogleApiDatetime());
     $timeEventEnd->setDateTime($timeEnd->getGoogleApiDatetime());
     $event->setStart($timeEventBegin);
     $event->setEnd($timeEventEnd);
     return $event;
 }
コード例 #6
0
 /**
  * Add unavailable period event to Google Calendar.
  * 
  * @param array $provider Contains the provider record data.
  * @param array $unavailable Contains unavailable period's data.
  * @return Google_Event Returns the google event's object.
  */
 public function add_unavailable($provider, $unavailable)
 {
     $this->CI->load->helper('general');
     $event = new Google_Event();
     $event->setSummary('Unavailable');
     $event->setDescription($unavailable['notes']);
     $start = new Google_EventDateTime();
     $start->setDateTime(date3339(strtotime($unavailable['start_datetime'])));
     $event->setStart($start);
     $end = new Google_EventDateTime();
     $end->setDateTime(date3339(strtotime($unavailable['end_datetime'])));
     $event->setEnd($end);
     // Add the new event to the google calendar.
     $created_event = $this->service->events->insert($provider['settings']['google_calendar'], $event);
     return $created_event;
 }
コード例 #7
0
function insertGoogleCalendarEvent($resrvation_id)
{
    if ($resrvation_id) {
        try {
            $resrvation_details = getReservationDetailFromId($resrvation_id);
            $calendar_id = getCalendarIdFromProperty($resrvation_details['PropertyID']);
            $row_credential = getGoogleCredential();
            $eventstartdate = date('Y-m-d', strtotime($resrvation_details['ArrivalDate']));
            $eventenddate = date('Y-m-d', strtotime($resrvation_details['DepartureDate']) + 86400);
            $esd = $eventstartdate . ' 00:00:00';
            $eed = $eventenddate . ' 10:00:00';
            $pst = new DateTimeZone('America/Los_Angeles');
            $gmt = new DateTimeZone('GMT');
            $dates = new DateTime($esd, $pst);
            $dates->setTimezone($gmt);
            $eventstartdate = $dates->format('Y-m-d') . 'T' . $dates->format('H:i:s') . 'Z';
            $datee = new DateTime($eed, $pst);
            $datee->setTimezone($gmt);
            $eventenddate = $datee->format('Y-m-d') . 'T' . $datee->format('H:i:s') . 'Z';
            //change as per client requirement to display full period from checkin to checkout on google calender
            //$eventenddate = date('Y-m-d',(strtotime($resrvation_details['DepartureDate']) + 172800)); // 86400 122400
            $tenantname = stripslashes($resrvation_details['FirstName']);
            if ($resrvation_details['MiddleName']) {
                $tenantname .= ' ' . stripslashes($resrvation_details['MiddleName']);
            }
            $tenantname .= ' ' . stripslashes($resrvation_details['LastName']);
            $tenantemail = stripslashes($resrvation_details['Email']);
            $tenantphone = stripslashes($resrvation_details['TelephoneNumber']);
            $tenantdayphone = stripslashes($resrvation_details['DaytimePhone']);
            $tenantstaypurpose = stripslashes($resrvation_details['StayPurpose']);
            //Event Summery i.e. Event Title
            $summery = 'Reservation Period - ' . $tenantname;
            //Event Description
            $description = "Tenant Details:\n\r Name: {$tenantname}\n\r Email: {$tenantemail}\n\r Phone: {$tenantphone}\n\r Day Phone: {$tenantdayphone}\n\r Stay Purpose: {$tenantstaypurpose}";
            include_once 'src/Google_Client.php';
            include_once 'src/contrib/Google_CalendarService.php';
            $client = new Google_Client();
            $client->setClientId($row_credential['ClientId']);
            $client->setClientSecret($row_credential['ClientSecret']);
            $client->setRedirectUri($row_credential['RedirectUri']);
            $client->setDeveloperKey($row_credential['DeveloperKey']);
            $cal = new Google_CalendarService($client);
            $client->setAccessToken($row_credential['AccessToken']);
            if ($client->getAccessToken()) {
                $eventendtime = new Google_EventDateTime();
                $eventendtime->setDateTime($eventenddate);
                $eventstarttime = new Google_EventDateTime();
                $eventstarttime->setDateTime($eventstartdate);
                $addevent = new Google_Event();
                $addevent->setEnd($eventendtime);
                $addevent->setStart($eventstarttime);
                $addevent->setDescription($description);
                $addevent->setSummary($summery);
                $eventadresp = $cal->events->insert($calendar_id, $addevent);
                updateEventId($resrvation_id, $eventadresp['id']);
            }
        } catch (Exception $e) {
            /* echo '<pre>';
            			print_r($e);
            			echo '</pre>';
            			exit; */
            //log error for debbug
            $response = json_encode($e);
            $insert_errsql = "INSERT INTO debug_calendarerr SET Response='" . mysql_real_escape_string($response) . "', ReservePropertyId='" . $resrvation_id . "'";
            $result_errsql = mysql_query($insert_errsql);
        }
    }
}
コード例 #8
0
ファイル: Profile.php プロジェクト: keyeMyria/CRM
 public function updateGoogleCalendarEvent($action)
 {
     try {
         // catch google exceptions so the whole app doesn't crash if google has a problem syncing
         $admin = Yii::app()->settings;
         if ($admin->googleIntegration) {
             if (isset($this->syncGoogleCalendarId) && $this->syncGoogleCalendarId) {
                 //                    // Google Calendar Libraries
                 //                    $timezone = date_default_timezone_get();
                 //                    require_once "protected/extensions/google-api-php-client/src/Google_Client.php";
                 //                    require_once "protected/extensions/google-api-php-client/src/contrib/Google_CalendarService.php";
                 //                    date_default_timezone_set($timezone);
                 //
                 //                    $client = new Google_Client();
                 //                    $client->setClientId($admin->googleClientId);
                 //                    $client->setClientSecret($admin->googleClientSecret);
                 //                    //$client->setDeveloperKey($admin->googleAPIKey);
                 //                    $client->setAccessToken($this->syncGoogleCalendarAccessToken);
                 //                    $client->setUseObjects(true); // return objects instead of arrays
                 //                    $googleCalendar = new Google_CalendarService($client);
                 $auth = new GoogleAuthenticator();
                 $googleCalendar = $auth->getCalendarService();
                 // check if the access token needs to be refreshed
                 // note that the google library automatically refreshes the access token if we need a new one,
                 // we just need to check if this happend by calling a google api function that requires authorization,
                 // and, if the access token has changed, save this new access token
                 $testCal = $googleCalendar->calendars->get($this->syncGoogleCalendarId);
                 //                    if($this->syncGoogleCalendarAccessToken != $client->getAccessToken()){
                 //                        $this->syncGoogleCalendarAccessToken = $client->getAccessToken();
                 //                        $this->update(array('syncGoogleCalendarAccessToken'));
                 //                    }
                 $summary = $action->actionDescription;
                 if ($action->associationType == 'contacts' || $action->associationType == 'contact') {
                     $summary = $action->associationName . ' - ' . $action->actionDescription;
                 }
                 $event = $googleCalendar->events->get($this->syncGoogleCalendarId, $action->syncGoogleCalendarEventId);
                 if (is_array($event)) {
                     $event = new Google_Event($event);
                 }
                 $event->setSummary($summary);
                 if (empty($action->dueDate)) {
                     $action->dueDate = time();
                 }
                 if ($action->allDay) {
                     $start = new Google_EventDateTime();
                     $start->setDate(date('Y-m-d', $action->dueDate));
                     $event->setStart($start);
                     if (!$action->completeDate) {
                         $action->completeDate = $action->dueDate;
                     }
                     $end = new Google_EventDateTime();
                     $end->setDate(date('Y-m-d', $action->completeDate + 86400));
                     $event->setEnd($end);
                 } else {
                     $start = new Google_EventDateTime();
                     $start->setDateTime(date('c', $action->dueDate));
                     $event->setStart($start);
                     if (!$action->completeDate) {
                         $action->completeDate = $action->dueDate;
                     }
                     // if no end time specified, make event 1 hour long
                     $end = new Google_EventDateTime();
                     $end->setDateTime(date('c', $action->completeDate));
                     $event->setEnd($end);
                 }
                 if ($action->color && $action->color != '#3366CC') {
                     $colorTable = array(10 => 'Green', 11 => 'Red', 6 => 'Orange', 8 => 'Black');
                     if (($key = array_search($action->color, $colorTable)) != false) {
                         $event->setColorId($key);
                     }
                 }
                 $newEvent = $googleCalendar->events->update($this->syncGoogleCalendarId, $action->syncGoogleCalendarEventId, $event);
             }
         }
     } catch (Exception $e) {
     }
 }
コード例 #9
0
function cloud_scrivi_calendar($evento_descr, $evento_start, $evento_durata = '+2 hours', $evento_location = '', $event_id = null)
{
    $evento_descr = $evento_descr;
    $evento_start1 = strtotime($evento_start);
    $evento_end1 = strtotime($evento_start . $evento_durata);
    $evento_location = $evento_location;
    /*************** DA QUI IN GIU NON TOCCHEREI PIU NULLA...  ******************/
    $app_name = 'allarrembaggio';
    $client_id = '1034795448812-gghclbbghnvnmotg6as7524fraeojfnh.apps.googleusercontent.com';
    $email_address = '*****@*****.**';
    $key_file = plugin_dir_path(__FILE__) . 'google-api-php-client/allarrembaggio-85318f0a4e9d.p12';
    $calendar_id = '*****@*****.**';
    $evento_start = gmdate('Y-m-d\\TH:i:s', $evento_start1);
    $evento_end = gmdate('Y-m-d\\TH:i:s', $evento_end1);
    require_once "google-api-php-client/src/Google_Client.php";
    require_once "google-api-php-client/src/contrib/Google_CalendarService.php";
    $client = new Google_Client();
    $client->setUseObjects(true);
    $client->setApplicationName($app_name);
    $client->setClientId($client_id);
    $client->setAssertionCredentials(new Google_AssertionCredentials($email_address, array("https://www.googleapis.com/auth/calendar"), file_get_contents($key_file)));
    //setAssertionCredentials
    $service = new Google_CalendarService($client);
    $event = new Google_Event();
    $event->setSummary($evento_descr);
    $event->setLocation($evento_location);
    $start = new Google_EventDateTime();
    $start->setDateTime($evento_start);
    $start->setTimeZone('Europe/Rome');
    $event->setStart($start);
    $end = new Google_EventDateTime();
    $end->setDateTime($evento_end);
    $end->setTimeZone('Europe/Rome');
    $event->setEnd($end);
    //--prima di crearlo, elimino eventuali eventi
    if ($event_id != null) {
        $service->events->delete($calendar_id, $event_id);
    }
    //--creo l'evento
    $new_event = null;
    try {
        $new_event = $service->events->insert($calendar_id, $event);
        $new_event_id = $new_event->getId();
    } catch (Google_ServiceException $e) {
        syslog(LOG_ERR, $e->getMessage());
    }
    $output = null;
    $output = $service->events->get($calendar_id, $new_event->getId());
    $output = $output->getId();
    return $output;
}
コード例 #10
0
ファイル: googlecal.php プロジェクト: hoalangoc/ftf
 $event_id = $_GET['event_id'];
 if (!is_numeric($event_id)) {
     $_SESSION['google_calendar_message'] = Zend_Registry::get("Zend_Translate")->_("This event is not existed!");
     $url = $view->url(array('id' => $event_id), 'event_profile', true);
     header('location: ' . $url);
     exit;
 }
 $seevent = Engine_Api::_()->getItem('event', $event_id);
 if (is_null($seevent)) {
     $_SESSION['google_calendar_message'] = Zend_Registry::get("Zend_Translate")->_("This event is not existed!");
     $url = $view->url(array('id' => $event_id), 'event_profile', true);
     header('location: ' . $url);
     exit;
 }
 #Create Google Event
 $event = new Google_Event();
 #Set Summary
 $event->setSummary(html_entity_decode($seevent->getTitle(), ENT_QUOTES, 'UTF-8'));
 #Set Description
 $sDescription = strip_tags(html_entity_decode($seevent->description, ENT_QUOTES, 'UTF-8'));
 $sEventUrl = $seevent->getHref();
 $event->setDescription($sDescription);
 #Set Location
 $sLocation = html_entity_decode($seevent->location, ENT_QUOTES, 'UTF-8');
 if ($seevent->address != '') {
     $sLocation .= ', ' . html_entity_decode($seevent->address, ENT_QUOTES, 'UTF-8');
 }
 if ($seevent->city != '') {
     $sLocation .= ', ' . html_entity_decode($seevent->city, ENT_QUOTES, 'UTF-8');
 }
 $event->setLocation($sLocation);
コード例 #11
0
ファイル: requests.php プロジェクト: jrgsf/giggity
function saveToCalendar($gig, $calendartype = 'private')
{
    // print_r($gig_details = getGigTextDescription($gig, 'calendar')); exit();
    // return; //FIXME
    global $calendars;
    extract($calendars[$calendartype]);
    if ($calendartype == 'public' && !$gig['public_description']) {
        return;
    }
    $cal = getGoogleClient();
    $event = new Google_Event();
    $gig_details = "";
    $title = $gig['title'];
    if ($calendartype == 'private') {
        if ($gig['type'] == 'gig') {
            $prefix = 'Proposed';
            if ($gig['approved'] == 1) {
                $prefix = 'Gig';
            } else {
                if ($gig['approved'] == -1) {
                    $prefix = 'Declined';
                }
            }
            $title = "{$prefix}: {$title}";
        } else {
            if ($gig['tactical']) {
                $members = gigs_fetchMembers();
                $title .= ": " . $members[$gig['tactical']]['name'];
            }
        }
        $gig_details = getGigTextDescription($gig, 'calendar');
        if (!$gig[$start_field]) {
            $start_field = 'band_start';
        }
    } else {
        $gig_details = $gig['public_description'];
    }
    $event->setSummary($title);
    $event->setLocation($gig['location']);
    $event->setStart(newDateTime($gig['date'], $gig[$start_field]));
    $event->setEnd(newDateTime($gig['date'], $gig[$end_field]));
    $event->setDescription($gig_details);
    $createdEvent = '';
    try {
        if ($gig[$id_field]) {
            $event->setSequence(time());
            $createdEvent = $cal->events->update($calendar_id, $gig[$id_field], $event);
        } else {
            $createdEvent = $cal->events->insert($calendar_id, $event);
            $google_gig_id = $createdEvent->getId();
            dbwrite("update gigs set {$id_field} = '" . dbEscape($google_gig_id) . "' where gig_id = {$gig['gig_id']}");
        }
    } catch (Exception $e) {
        //trigger_error('Error creating google calendar entry: '.$e->getMessage(), E_USER_ERROR);
    }
    if (!$createdEvent) {
        //trigger_error('Error creating google calendar entry', E_USER_ERROR);
    }
}
コード例 #12
0
ファイル: Main.php プロジェクト: kokkez/shineisp
 /**
  * Execute the upload of the file to the calendar service
  * 
  * @param string $sourcefile
  * @return boolean
  */
 public static function newEvent($summary, $location, $description = null, $datestart = null, $dateend = null)
 {
     try {
         if (empty($datestart)) {
             $datestart = date('Y-m-d');
         }
         if (empty($dateend)) {
             $dateend = date('Y-m-d');
         }
         $calendar = Settings::findbyParam('calendar_calendarid');
         if ($calendar) {
             $cal = self::$calendar;
             if (is_object($cal) && !empty($cal)) {
                 $event = new Google_Event();
                 $event->setSummary($summary);
                 // Event name
                 $event->setLocation($location);
                 // Event location
                 $start = new Google_EventDateTime();
                 $start->setDate($datestart);
                 $event->setStart($start);
                 $end = new Google_EventDateTime();
                 $end->setDate($dateend);
                 $event->setEnd($end);
                 $event->setDescription($description);
                 $createdEvent = $cal->events->insert($calendar, $event);
                 Shineisp_Commons_Utilities::log("The Event has been created!", "plugin_calendar.log");
                 return true;
             }
         }
         return false;
     } catch (Exception $e) {
         return $e->getMessage();
     }
 }