MaketRandevu/doc/code/php/class-Google_Sync.html

715 lines
20 KiB
HTML
Raw Normal View History

2015-01-29 00:56:57 +02:00
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Class Google_Sync</title>
<link rel="stylesheet" href="resources/bootstrap.min.css?08b23951ef4599ca9cbf1f902d0e8290c9653ddd">
<link rel="stylesheet" href="resources/style.css?062e9e59e0b8c44fbaaded5b7ffc21f907b78669">
</head>
<body>
<div id="navigation" class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a href="index.html" class="brand">Overview</a>
<div class="nav-collapse">
<ul class="nav">
<li class="active">
<span>Class</span> </li>
<li class="divider-vertical"></li>
<li>
<a href="tree.html" title="Tree view of classes, interfaces, traits and exceptions"><span>Tree</span></a>
</li>
<li>
<a href="todo.html" title="Todo list"><span>Todo</span></a>
</li>
</ul>
</div>
</div>
</div>
</div>
<div id="left">
<div id="menu">
<form id="search" class="form-search">
<input type="hidden" name="cx" value="">
<input type="hidden" name="ie" value="UTF-8">
<input type="text" name="q" class="search-query" placeholder="Search">
</form>
<div id="groups">
</div>
<div id="elements">
<h3>Classes</h3>
<ul>
<li><a href="class-Admins_Model.html">Admins_Model</a></li>
<li><a href="class-Appointments.html">Appointments</a></li>
<li><a href="class-Appointments_Model.html">Appointments_Model</a></li>
<li><a href="class-Backend.html">Backend</a></li>
<li><a href="class-Backend_api.html">Backend_api</a></li>
<li><a href="class-Customers_Model.html">Customers_Model</a></li>
<li><a href="class-Errors.html">Errors</a></li>
<li><a href="class-Google.html">Google</a></li>
<li class="active"><a href="class-Google_Sync.html">Google_Sync</a></li>
<li><a href="class-Notifications.html">Notifications</a></li>
<li><a href="class-Providers_Model.html">Providers_Model</a></li>
<li><a href="class-Roles_Model.html">Roles_Model</a></li>
<li><a href="class-Secretaries_Model.html">Secretaries_Model</a></li>
<li><a href="class-Services_Model.html">Services_Model</a></li>
<li><a href="class-Settings_Model.html">Settings_Model</a></li>
<li><a href="class-Test.html">Test</a></li>
<li><a href="class-Unit_tests.html">Unit_tests</a></li>
<li><a href="class-Unit_tests_admins_model.html">Unit_tests_admins_model</a></li>
<li><a href="class-Unit_tests_appointments_model.html">Unit_tests_appointments_model</a></li>
<li><a href="class-Unit_tests_customers_model.html">Unit_tests_customers_model</a></li>
<li><a href="class-Unit_tests_providers_model.html">Unit_tests_providers_model</a></li>
<li><a href="class-Unit_tests_secretaries_model.html">Unit_tests_secretaries_model</a></li>
<li><a href="class-Unit_tests_services_model.html">Unit_tests_services_model</a></li>
<li><a href="class-Unit_tests_settings_model.html">Unit_tests_settings_model</a></li>
<li><a href="class-User.html">User</a></li>
<li><a href="class-User_Model.html">User_Model</a></li>
</ul>
<h3>Interfaces</h3>
<ul>
<li><a href="class-Admins_Model.html">Admins_Model</a></li>
<li><a href="class-Appointments.html">Appointments</a></li>
<li><a href="class-Appointments_Model.html">Appointments_Model</a></li>
<li><a href="class-Backend.html">Backend</a></li>
<li><a href="class-Backend_api.html">Backend_api</a></li>
<li><a href="class-Customers_Model.html">Customers_Model</a></li>
<li><a href="class-Errors.html">Errors</a></li>
<li><a href="class-Google.html">Google</a></li>
<li class="active"><a href="class-Google_Sync.html">Google_Sync</a></li>
<li><a href="class-Notifications.html">Notifications</a></li>
<li><a href="class-Providers_Model.html">Providers_Model</a></li>
<li><a href="class-Roles_Model.html">Roles_Model</a></li>
<li><a href="class-Secretaries_Model.html">Secretaries_Model</a></li>
<li><a href="class-Services_Model.html">Services_Model</a></li>
<li><a href="class-Settings_Model.html">Settings_Model</a></li>
<li><a href="class-Test.html">Test</a></li>
<li><a href="class-Unit_tests.html">Unit_tests</a></li>
<li><a href="class-Unit_tests_admins_model.html">Unit_tests_admins_model</a></li>
<li><a href="class-Unit_tests_appointments_model.html">Unit_tests_appointments_model</a></li>
<li><a href="class-Unit_tests_customers_model.html">Unit_tests_customers_model</a></li>
<li><a href="class-Unit_tests_providers_model.html">Unit_tests_providers_model</a></li>
<li><a href="class-Unit_tests_secretaries_model.html">Unit_tests_secretaries_model</a></li>
<li><a href="class-Unit_tests_services_model.html">Unit_tests_services_model</a></li>
<li><a href="class-Unit_tests_settings_model.html">Unit_tests_settings_model</a></li>
<li><a href="class-User.html">User</a></li>
<li><a href="class-User_Model.html">User_Model</a></li>
</ul>
</div>
</div>
</div>
<div id="splitter"></div>
<div id="right">
<div id="rightInner">
<div id="content" class="class">
<h1>Class Google_Sync</h1>
<div class="description">
<p>Google Synchronization Class</p>
<p>This class implements all the core synchronization between the Google Calendar
and the Easy!Appointments system. Do not place any model handling inside this
library.</p>
</div>
<div class="alert alert-info">
<b>Located at</b> <a href="source-class-Google_Sync.html#8-325" title="Go to source code">google_sync.php</a>
<br>
</div>
<h2>Methods summary</h2>
<table class="summary table table-bordered table-striped methods" id="methods">
<tr data-order="__construct" id="___construct">
<td class="attributes"><code>
public
</code>
</td>
<td class="name"><div>
<a class="anchor" href="#___construct">#</a>
<code><a href="source-class-Google_Sync.html#20-44" title="Go to source code">__construct</a>( )</code>
<div class="description short">
<p>Class Constructor</p>
</div>
<div class="description detailed hidden">
<p>Class Constructor</p>
<p>This method initializes the Google client class and the Calendar service
class so that they can be used by the other methods.</p>
</div>
</div></td>
</tr>
<tr data-order="get_auth_url" id="_get_auth_url">
<td class="attributes"><code>
public
</code>
</td>
<td class="name"><div>
<a class="anchor" href="#_get_auth_url">#</a>
<code><a href="source-class-Google_Sync.html#46-56" title="Go to source code">get_auth_url</a>( )</code>
<div class="description short">
<p>Get Google OAuth authorization url.</p>
</div>
<div class="description detailed hidden">
<p>Get Google OAuth authorization url.</p>
<p>This url must be used to redirect the user to the Google user consent page,
where the user grants access to his data for the Easy!Appointments app.</p>
</div>
</div></td>
</tr>
<tr data-order="authenticate" id="_authenticate">
<td class="attributes"><code>
public
</code>
</td>
<td class="name"><div>
<a class="anchor" href="#_authenticate">#</a>
<code><a href="source-class-Google_Sync.html#58-71" title="Go to source code">authenticate</a>( <span> <var>$auth_code</var></span> )</code>
<div class="description short">
<p>Authenticate the Google API usage.</p>
</div>
<div class="description detailed hidden">
<p>Authenticate the Google API usage.</p>
<p>When the user grants consent for his data usage, google is going to redirect
the browser back to the given redirect url. There a authentication code is
provided. Using this code, we can authenticate the API usage and store the
token information to the database.</p>
<h4>See</h4>
<div class="list">
Google Controller<br>
</div>
</div>
</div></td>
</tr>
<tr data-order="refresh_token" id="_refresh_token">
<td class="attributes"><code>
public
</code>
</td>
<td class="name"><div>
<a class="anchor" href="#_refresh_token">#</a>
<code><a href="source-class-Google_Sync.html#73-88" title="Go to source code">refresh_token</a>( <span>string <var>$refresh_token</var></span> )</code>
<div class="description short">
<p>Refresh the Google Client access token.</p>
</div>
<div class="description detailed hidden">
<p>Refresh the Google Client access token.</p>
<p>This method must be executed every time we need to make actions on a
provider's Google Calendar account. A new token is necessary and the
only way to get it is to use the stored refresh token that was provided
when the provider granted consent to Easy!Appointments for use his
Google Calendar account.</p>
<h4>Parameters</h4>
<div class="list"><dl>
<dt><var>$refresh_token</var></dt>
<dd><p>The provider's refresh token. This value is
stored in the database and used every time we need to make actions to his
Google Caledar account.</p></dd>
</dl></div>
</div>
</div></td>
</tr>
<tr data-order="add_appointment" id="_add_appointment">
<td class="attributes"><code>
public
Google_Event
</code>
</td>
<td class="name"><div>
<a class="anchor" href="#_add_appointment">#</a>
<code><a href="source-class-Google_Sync.html#90-142" title="Go to source code">add_appointment</a>( <span>array <var>$appointment</var></span>, <span>array <var>$provider</var></span>, <span>array <var>$service</var></span>, <span>array <var>$customer</var></span>, <span> <var>$company_settings</var></span> )</code>
<div class="description short">
<p>Add an appointment record to its providers Google Calendar account.</p>
</div>
<div class="description detailed hidden">
<p>Add an appointment record to its providers Google Calendar account.</p>
<p>This method checks whether the appointment's provider has enabled the Google
Sync utility of Easy!Appointments and the stored access token is still valid.
If yes, the selected appointment record is going to be added to the Google
Calendar account.</p>
<h4>Parameters</h4>
<div class="list"><dl>
<dt><var>$appointment</var></dt>
<dd>Contains the appointment record data.</dd>
<dt><var>$provider</var></dt>
<dd>Contains the provider record data.</dd>
<dt><var>$service</var></dt>
<dd>Contains the service record data.</dd>
<dt><var>$customer</var></dt>
<dd>Contains the customer recod data.</dd>
<dt><var>$company_settings</var></dt>
<dd></dd>
</dl></div>
<h4>Returns</h4>
<div class="list">
Google_Event<br>Returns the Google_Event class object.
</div>
<h4>Parma</h4>
<div class="list">
<p>array $company_settings Contains some company settings that are used
by this method. By the time the following values must be in the array:
'company_name'.</p><br>
</div>
</div>
</div></td>
</tr>
<tr data-order="update_appointment" id="_update_appointment">
<td class="attributes"><code>
public
Google_Event
</code>
</td>
<td class="name"><div>
<a class="anchor" href="#_update_appointment">#</a>
<code><a href="source-class-Google_Sync.html#144-195" title="Go to source code">update_appointment</a>( <span>array <var>$appointment</var></span>, <span>array <var>$provider</var></span>, <span>array <var>$service</var></span>, <span>array <var>$customer</var></span>, <span> <var>$company_settings</var></span> )</code>
<div class="description short">
<p>Update an existing appointment that is already synced with Google Calendar.</p>
</div>
<div class="description detailed hidden">
<p>Update an existing appointment that is already synced with Google Calendar.</p>
<p>This method updates the google calendar event item that is connected with the
provided appointment record of Easy!Appointments.</p>
<h4>Parameters</h4>
<div class="list"><dl>
<dt><var>$appointment</var></dt>
<dd>Contains the appointment record data.</dd>
<dt><var>$provider</var></dt>
<dd>Contains the provider record data.</dd>
<dt><var>$service</var></dt>
<dd>Contains the service record data.</dd>
<dt><var>$customer</var></dt>
<dd>Contains the customer recod data.</dd>
<dt><var>$company_settings</var></dt>
<dd></dd>
</dl></div>
<h4>Returns</h4>
<div class="list">
Google_Event<br>Returns the Google_Event class object.
</div>
<h4>Parma</h4>
<div class="list">
<p>array $company_settings Contains some company settings that are used
by this method. By the time the following values must be in the array:
'company_name'.</p><br>
</div>
</div>
</div></td>
</tr>
<tr data-order="delete_appointment" id="_delete_appointment">
<td class="attributes"><code>
public
</code>
</td>
<td class="name"><div>
<a class="anchor" href="#_delete_appointment">#</a>
<code><a href="source-class-Google_Sync.html#197-206" title="Go to source code">delete_appointment</a>( <span>array <var>$provider</var></span>, <span>string <var>$google_event_id</var></span> )</code>
<div class="description short">
<p>Delete an existing appointment from Google Calendar.</p>
</div>
<div class="description detailed hidden">
<p>Delete an existing appointment from Google Calendar.</p>
<h4>Parameters</h4>
<div class="list"><dl>
<dt><var>$provider</var></dt>
<dd>Contains the provider record data.</dd>
<dt><var>$google_event_id</var></dt>
<dd><p>The Google Calendar event id to
be deleted.</p></dd>
</dl></div>
</div>
</div></td>
</tr>
<tr data-order="add_unavailable" id="_add_unavailable">
<td class="attributes"><code>
public
Google_Event
</code>
</td>
<td class="name"><div>
<a class="anchor" href="#_add_unavailable">#</a>
<code><a href="source-class-Google_Sync.html#208-235" title="Go to source code">add_unavailable</a>( <span>array <var>$provider</var></span>, <span>array <var>$unavailable</var></span> )</code>
<div class="description short">
<p>Add unavailable period event to Google Calendar.</p>
</div>
<div class="description detailed hidden">
<p>Add unavailable period event to Google Calendar.</p>
<h4>Parameters</h4>
<div class="list"><dl>
<dt><var>$provider</var></dt>
<dd>Contains the provider record data.</dd>
<dt><var>$unavailable</var></dt>
<dd>Contains unavailable period's data.</dd>
</dl></div>
<h4>Returns</h4>
<div class="list">
Google_Event<br>Returns the google event's object.
</div>
</div>
</div></td>
</tr>
<tr data-order="update_unavailable" id="_update_unavailable">
<td class="attributes"><code>
public
Google_Event
</code>
</td>
<td class="name"><div>
<a class="anchor" href="#_update_unavailable">#</a>
<code><a href="source-class-Google_Sync.html#237-262" title="Go to source code">update_unavailable</a>( <span>array <var>$provider</var></span>, <span>array <var>$unavailable</var></span> )</code>
<div class="description short">
<p>Update Google Calendar unavailable period event.</p>
</div>
<div class="description detailed hidden">
<p>Update Google Calendar unavailable period event.</p>
<h4>Parameters</h4>
<div class="list"><dl>
<dt><var>$provider</var></dt>
<dd>Contains the provider record data.</dd>
<dt><var>$unavailable</var></dt>
<dd>Contains the unavailable period data.</dd>
</dl></div>
<h4>Returns</h4>
<div class="list">
Google_Event<br>Returns the Google_Event object.
</div>
</div>
</div></td>
</tr>
<tr data-order="delete_unavailable" id="_delete_unavailable">
<td class="attributes"><code>
public
</code>
</td>
<td class="name"><div>
<a class="anchor" href="#_delete_unavailable">#</a>
<code><a href="source-class-Google_Sync.html#264-272" title="Go to source code">delete_unavailable</a>( <span>array <var>$provider</var></span>, <span>string <var>$google_event_id</var></span> )</code>
<div class="description short">
<p>Delete unavailable period event from Google Calendar.</p>
</div>
<div class="description detailed hidden">
<p>Delete unavailable period event from Google Calendar.</p>
<h4>Parameters</h4>
<div class="list"><dl>
<dt><var>$provider</var></dt>
<dd>Contains the provider record data.</dd>
<dt><var>$google_event_id</var></dt>
<dd>Google Calendar event id to be deleted.</dd>
</dl></div>
</div>
</div></td>
</tr>
<tr data-order="get_event" id="_get_event">
<td class="attributes"><code>
public
Google_Event
</code>
</td>
<td class="name"><div>
<a class="anchor" href="#_get_event">#</a>
<code><a href="source-class-Google_Sync.html#274-283" title="Go to source code">get_event</a>( <span>array <var>$provider</var></span>, <span>string <var>$google_event_id</var></span> )</code>
<div class="description short">
<p>Get an event object from gcal</p>
</div>
<div class="description detailed hidden">
<p>Get an event object from gcal</p>
<h4>Parameters</h4>
<div class="list"><dl>
<dt><var>$provider</var></dt>
<dd>Contains the provider record data.</dd>
<dt><var>$google_event_id</var></dt>
<dd>Id of the google calendar event</dd>
</dl></div>
<h4>Returns</h4>
<div class="list">
Google_Event<br>Returns the google event object.
</div>
</div>
</div></td>
</tr>
<tr data-order="get_sync_events" id="_get_sync_events">
<td class="attributes"><code>
public
object
</code>
</td>
<td class="name"><div>
<a class="anchor" href="#_get_sync_events">#</a>
<code><a href="source-class-Google_Sync.html#285-303" title="Go to source code">get_sync_events</a>( <span>string <var>$google_calendar</var></span>, <span>date <var>$start</var></span>, <span>date <var>$end</var></span> )</code>
<div class="description short">
<p>Get all the events between the sync period.</p>
</div>
<div class="description detailed hidden">
<p>Get all the events between the sync period.</p>
<h4>Parameters</h4>
<div class="list"><dl>
<dt><var>$google_calendar</var></dt>
<dd>The name of the google calendar to be used.</dd>
<dt><var>$start</var></dt>
<dd>The start date of sync period.</dd>
<dt><var>$end</var></dt>
<dd>The end date of sync period.</dd>
</dl></div>
<h4>Returns</h4>
<div class="list">
object<br><p>Returns an array with Google_Event objects that belong on the given
sync period (start, end).</p>
</div>
</div>
</div></td>
</tr>
<tr data-order="get_google_calendars" id="_get_google_calendars">
<td class="attributes"><code>
public
array
</code>
</td>
<td class="name"><div>
<a class="anchor" href="#_get_google_calendars">#</a>
<code><a href="source-class-Google_Sync.html#305-324" title="Go to source code">get_google_calendars</a>( <span>string <var>$google_token</var>,…</span> )</code>
<div class="description short">
<p>Return available google calendars for specific user.</p>
</div>
<div class="description detailed hidden">
<p>Return available google calendars for specific user.</p>
<p>The given user's token must already exist in db in order to get access to his
Google Calendar account.</p>
<h4>Parameters</h4>
<div class="list"><dl>
<dt><var>$google_token</var>,…</dt>
<dd>The user's token will be used to grant access to google calendar.</dd>
</dl></div>
<h4>Returns</h4>
<div class="list">
array<br>Returns an array with the available calendars.
</div>
</div>
</div></td>
</tr>
</table>
<h3>Magic methods summary</h3>
</div>
</div>
<div id="footer">
API documentation generated by <a href="http://apigen.org">ApiGen</a>
</div>
</div>
<script src="resources/combined.js"></script>
<script src="elementlist.js"></script>
</body>
</html>