From 6369da0893f30dce26b02b8ea05751601e0f355f Mon Sep 17 00:00:00 2001
From: "alextselegidis@gmail.com"
Date: Wed, 12 Jun 2013 15:31:16 +0000
Subject: [PATCH] =?UTF-8?q?-=20=CE=A4=CF=81=CE=BF=CF=80=CE=BF=CF=80=CE=BF?=
=?UTF-8?q?=CE=B9=CE=AE=CF=83=CE=B5=CE=B9=CF=82=20=CF=83=CF=84=CE=B1=20?=
=?UTF-8?q?=CE=B1=CF=81=CF=87=CE=B5=CE=AF=CE=B1=20=CE=BA=CE=B1=CE=B9=20?=
=?UTF-8?q?=CF=84=CE=B7=CE=BD=20=CE=B4=CE=BF=CE=BC=CE=AE=20=CF=84=CE=BF?=
=?UTF-8?q?=CF=85=20=CE=BA=CF=8E=CE=B4=CE=B9=CE=BA=CE=B1=20-=20=CE=A5?=
=?UTF-8?q?=CE=BB=CE=BF=CF=80=CE=BF=CE=AF=CE=B7=CF=83=CE=B7=20=CF=84=CE=B7?=
=?UTF-8?q?=CF=82=20=CF=80=CF=81=CF=8E=CF=84=CE=B7=CF=82=20=CF=83=CE=B5?=
=?UTF-8?q?=CE=BB=CE=AF=CE=B4=CE=B1=CF=82=20=CF=84=CE=BF=CF=85=20backend?=
=?UTF-8?q?=20=CF=84=CE=B7=CF=82=20=CE=B5=CF=86=CE=B1=CF=81=CE=BC=CE=BF?=
=?UTF-8?q?=CE=B3=CE=AE=CF=82.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/application/controllers/appointments.php | 28 +-
src/application/controllers/backend.php | 48 ++
src/application/libraries/google_sync.php | 25 +-
src/application/views/appointments/book.php | 25 +-
.../views/appointments/book_success.php | 6 +-
src/application/views/appointments/cancel.php | 3 +-
src/application/views/backend/calendar.php | 46 ++
src/application/views/backend/footer.php | 10 +
src/application/views/backend/header.php | 106 ++++
src/assets/css/backend.css | 57 ++
src/assets/css/{style.css => frontend.css} | 0
src/assets/css/libs/jquery/fullcalendar.css | 579 ++++++++++++++++++
.../css/libs/jquery/fullcalendar.print.css | 32 +
src/assets/images/favicon.ico | Bin 1150 -> 1150 bytes
src/assets/images/logo.png | Bin 22029 -> 7147 bytes
src/assets/js/backend.js | 27 +
src/assets/js/backend_calendar.js | 66 ++
.../book_appointment.js => frontend_book.js} | 48 +-
src/assets/js/libs/jquery/fullcalendar.min.js | 7 +
src/assets/js/libs/jquery/gcal.js | 107 ++++
20 files changed, 1155 insertions(+), 65 deletions(-)
create mode 100644 src/application/controllers/backend.php
create mode 100644 src/application/views/backend/calendar.php
create mode 100644 src/application/views/backend/footer.php
create mode 100644 src/application/views/backend/header.php
create mode 100644 src/assets/css/backend.css
rename src/assets/css/{style.css => frontend.css} (100%)
create mode 100644 src/assets/css/libs/jquery/fullcalendar.css
create mode 100644 src/assets/css/libs/jquery/fullcalendar.print.css
create mode 100644 src/assets/js/backend.js
create mode 100644 src/assets/js/backend_calendar.js
rename src/assets/js/{frontend/book_appointment.js => frontend_book.js} (92%)
create mode 100644 src/assets/js/libs/jquery/fullcalendar.min.js
create mode 100644 src/assets/js/libs/jquery/gcal.js
diff --git a/src/application/controllers/appointments.php b/src/application/controllers/appointments.php
index 529cdb2f..903e4945 100644
--- a/src/application/controllers/appointments.php
+++ b/src/application/controllers/appointments.php
@@ -102,16 +102,18 @@ class Appointments extends CI_Controller {
// Synchronize the appointment with the providers plan, if the
// google sync option is enabled.
- $this->load->library('google_sync');
$google_sync = $this->Providers_Model->get_setting('google_sync',
$appointment_data['id_users_provider']);
if ($google_sync == TRUE) {
$google_token = $this->Providers_Model->get_setting('google_token',
$appointment_data['id_users_provider']);
- // Validate the token. If it isn't valid, the sync operation cannot
+
+ // Authenticate the token. If it isn't valid, the sync operation cannot
// be completed.
- if ($this->google_sync->validate_token($google_token) === TRUE) {
+ $this->load->library('google_sync');
+
+ if ($this->google_sync->authenticate($google_token) === TRUE) {
if ($manage_mode === FALSE) {
// Add appointment to Google Calendar.
$this->google_sync->add_appointment($appointment_data['id']);
@@ -122,7 +124,7 @@ class Appointments extends CI_Controller {
}
}
- // Load the book appointment view.
+ // Load the book success view.
$service_data = $this->Services_Model->get_row($appointment_data['id_services']);
$provider_data = $this->Providers_Model->get_row($appointment_data['id_users_provider']);
$company_name = $this->Settings_Model->get_setting('company_name');
@@ -180,10 +182,22 @@ class Appointments extends CI_Controller {
// Delete the appointment from Google Calendar, if it is synced.
if ($appointment_data['id_google_calendar'] != NULL) {
- $this->load->library('google_sync');
- $this->google_sync->delete_appointment($appointment_data['id']);
+ $google_sync = $this->Providers_Model->get_setting('google_sync',
+ $appointment_data['id_users_provider']);
+
+ if ($google_sync == TRUE) {
+ $this->load->library('google_sync');
+
+ // Get the provider's refresh token and try to authenticate the
+ // Google Calendar API usage.
+ $google_token = $this->Providers_Model->get_setting('google_token',
+ $appointment_data['id_users_provider']);
+
+ if ($this->google_sync->authendicate($google_token) === TRUE) {
+ $this->google_sync->delete_appointment($appointment_data['id']);
+ }
+ }
}
-
} catch(Exception $exc) {
// Display the error message to the customer.
$view_data['error_message'] = $exc->getMessage();
diff --git a/src/application/controllers/backend.php b/src/application/controllers/backend.php
new file mode 100644
index 00000000..897049c5
--- /dev/null
+++ b/src/application/controllers/backend.php
@@ -0,0 +1,48 @@
+load->model('Providers_Model');
+ $this->load->model('Services_Model');
+ $this->load->model('Settings_Model');
+
+ // Display the main backend page.
+ $view_data['base_url'] = $this->config->item('base_url');
+ $view_data['company_name'] = $this->Settings_Model->get_setting('company_name');
+ $view_data['available_providers'] = $this->Providers_Model->get_available_providers();
+ $view_data['available_services'] = $this->Services_Model->get_available_services();
+
+ $this->load->view('backend/header', $view_data);
+ $this->load->view('backend/calendar', $view_data);
+ $this->load->view('backend/footer', $view_data);
+ }
+
+ public function customers() {
+
+ }
+
+ public function services() {
+
+ }
+
+ public function providers() {
+
+ }
+
+ public function settings() {
+
+ }
+}
+
+/* End of file backend.php */
+/* Location: ./application/controllers/backend.php */
\ No newline at end of file
diff --git a/src/application/libraries/google_sync.php b/src/application/libraries/google_sync.php
index a1d3b091..a5f3b364 100644
--- a/src/application/libraries/google_sync.php
+++ b/src/application/libraries/google_sync.php
@@ -37,22 +37,21 @@ class Google_Sync {
}
/**
- * Validate the Google API access token of a provider.
+ * Authenticate the Google API usage.
*
- * In order to manage a Google user's data, one need a valid access token.
- * This token is provided when the user grants the permission to a system
- * to access his Google account data. So before making any action we need
- * to make sure that the available token is still valid.
+ * 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.
*
- * IMPORTANT! Always use this method before anything else
- * in order to make sure that the token is being set and still valid.
- *
- * @param string $access_token This token is normally stored in the database.
- * @return bool Returns the validation result.
+ * @param string $refresh_token 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.
+ * @return bool Returns the authenticate operation result.
*/
- public function validate_token($access_token) {
- $this->client->setAccessToken($access_token);
- return $this->client->isAccessTokenExpired();
+ public function authenticate($refresh_token) {
+
}
/**
diff --git a/src/application/views/appointments/book.php b/src/application/views/appointments/book.php
index 4c8f8317..05956e81 100644
--- a/src/application/views/appointments/book.php
+++ b/src/application/views/appointments/book.php
@@ -26,7 +26,7 @@
+ href="config->base_url(); ?>assets/css/frontend.css">
+ src="config->base_url(); ?>assets/js/libs/jquery/jquery.min.js">
+ src="config->base_url(); ?>assets/js/libs/jquery/jquery-ui.min.js">
+ src="config->base_url(); ?>assets/js/libs/jquery/jquery.qtip.min.js">
+ src="config->base_url(); ?>assets/js/libs/bootstrap/bootstrap.min.js">
+ src="config->base_url(); ?>assets/js/libs/date.js">
+ src="config->base_url(); ?>assets/js/frontend_book.js">
+ src="config->base_url(); ?>assets/js/general_functions.js">
diff --git a/src/application/views/appointments/book_success.php b/src/application/views/appointments/book_success.php
index 9f946617..4c7c6fee 100644
--- a/src/application/views/appointments/book_success.php
+++ b/src/application/views/appointments/book_success.php
@@ -149,16 +149,16 @@
'Your appointment has successfully been added to ' +
'your Google Calendar account. ' +
'' +
- 'Appointment Link' +
+ 'Click here to view your appoinmtent on Google ' +
+ 'Calendar.' +
'' +
'
\ No newline at end of file
diff --git a/src/application/views/backend/footer.php b/src/application/views/backend/footer.php
new file mode 100644
index 00000000..8217b821
--- /dev/null
+++ b/src/application/views/backend/footer.php
@@ -0,0 +1,10 @@
+
+