In this chapter you'll find out how to keep Scheduler and Google Calendar in sync.
Note that the sync is 2-way, i.e. any changes you make to events in either Scheduler or Google Calendar will be reflected in both applications.
If you alter the same event in both applications, the latest update will sync between Scheduler and Google Calendar.
If you delete an event in one of the calendars, this event will be deleted from both applications.
You sync Scheduler with the primary Google Calendar. Events from the secondary calendars won't be synced.
Note, you sync all the events containing in both Google Calendar and Scheduler at once. You can't sync just some specific part of events.
By default, Scheduler takes the text and duration (start and end times) of the Google Calendar event. If you need you can get additional information of the event. See the details .
First of all, to start sync, check whether the extension php_curl.dll is enabled.
If it's not, activate it by removing a semicolon from the following line in the php.ini file used by your web server:
;extension=php_curl.dll
Once you were sure that the needed extension is enabled you can move to setup.
To sync Scheduler with Google Calendar you should:
Download the 'gCal_proxy_v2' package.
Unzip the package into the root directory of your web server.
Server-side:
Open the
'01_proxy.php' file placed at
[rootFolder]\gCal_proxy\server\ in notepad.
The file contains the standard proxy initialization code:
<?php
$email = "";
$pass = "";
$cal = "";
include('google_proxy.php');
$calendar = new GoogleCalendarProxy($email, $pass, $cal);
//$calendar->map("location", "details");
$calendar->connect();
?>
Set values for 3 variables and leave the rest of the code as it is.
Variables that you should set values for:
$email - the user name of your Gmail account;
$pass - the password of your Gmail account;
$cal - the name of your Google Calendar.
Be sure that you wrote the correct values. For example, if the name of your calendar is test@googlemail.com, the value test@gmail.com results in an error.
Save the changes and close the file.
Client-side:
Open the
HTML file containing the initialized scheduler. If you don't have any scheduler initialized, create a new
HTML file in the root folder of your web server.
-
Load events of Google Calendar to Scheduler through the
load() method. Set its parameter to the path to the '
01_proxy.php' file which you modified some time ago.
scheduler.load("../gCal_proxy/server/01_proxy.php");
-
Include one more file.
<script src="../gCal_proxy/sample/codebase/dhtmlxdataprocessor.js" type="text/javascript" charset="utf-8"></script>
Take the path to the same php file '
01_proxy.php' as the parameter of the constructor.
var dp = new dataProcessor("../gCal_proxy/server/01_proxy.php");
dp.init(scheduler);//'scheduler' is the name of the scheduler instance.
The sync is finished. You can find the ready-to-use example 'sample.html' at [rootFolder]\gCal_proxy\sample\.
To export events from Google Calendar to your database, just follow these steps:
Open the '03_export.php' file placed at [rootFolder]\gCal_proxy\server\ in notepad.
Set values for the variables and leave the rest of the code as is.
Variables that you should set values for:
$email - the user name of your Gmail account;
$pass - the password of your Gmail account;
$cal - the name of your Google Calendar;
$db_host - the name of your MySQL server host or IP-address;
$db_user - the username of your MySQL account;
$db_pass - the password of your MySQL account;
$db_name - the name of your MySQL database;
$db_table - the name of the database table;
Save changes and close the file.
Run the '03_export.php'.
Once the file has been run, events from Google Calendar will be saved to the appropriate database table.
The function 'export()' returns a number of records that have been exported from Google Calendar
To import events from your database to Google calendar, just follow these steps:
Open the '02_import.php' file placed at [rootFolder]\gCal_proxy\server\ in notepad.
Set values for the variables and leave the rest of the code as is. Variables that you should set values for are the same as in case of exporting.
Save changes and close the file.
Run the '02_import.php'.
Once the file has been run, events from the database will be moved to the Google Calendar.
The function 'import()' returns a number of records that have been imported to Google Calendar
Google Calendar has one set of fields and Scheduler has the other. So, to sync (import or export) the event information correctly you should set mapping between the related fields of the calendars.
By default, there is the following mapping between Google Calendar and Scheduler:
Google Calendar ↔ Scheduler
id ↔ id
title ↔ text
startTime ↔ start_date
endTime ↔ end_date
Additionally, you can pass information of the following Google Calendar fields:
Field | Description |
canEdit | defines whether the logged-in user can edit the current event. Possible values: '0' or '1' |
created | the event creation date in gcal format |
details | the event details |
updated | the last update date of the event in gcal format |
location | the location where the event takes place in |
status | shows the current status of the event: cancelled (the event is canceled), confirmed (the event is confirmed), tentative (the event is tentatively scheduled) |
To pass some additional info, follow the steps below:
Server-side:
According to the desired action, open in notepad the appropriate file placed at [rootFolder]\gCal_proxy\server\: to sync - '01_proxy.php', to import - '02_import.php', to export - '03_export.php'.
Map the desired fields by using the method
map(). For example, if you want to get the location of the event (in addition to the text, start and end times) you should write the following line:
$calendar->map("location", "place");
Save changes and close the file.
Client-side:
Open the
HTML file containing the initialized scheduler.
Add to the definition of the scheduler:
the lightbox section:
scheduler.config.lightbox.sections=[
...
{name:"placeField", height:50, map_to:"place", type:"textarea"}
];
where the map_to parameter must be set to the value specified on server-side (see above).
the label of the newly added section:
scheduler.locale.labels.section_placeField = 'Place';
where after the underscore you should specify the name of the related section.
Save changes and close the file.