This works. It does not integrate the token yet. I am not sure how to do that. I will need to educate myself. I am sure it would make the process more secure but for now this will work:
I created three levels of syncronization, one that is a full sync by button (slow, for me about 1:30 to cover 61 days of a full calendar), one that will just sync the appointment (fast, the one Alex started with), and one that will sync all providers for the automatic CLI cron job. I am also making that 61 days (slow) but I am keeping it flexible. I choose 61 because it is one day beyond the view for my clients. If there is an error in my server then I have a day of padding.
The following changes were necessary:
To allow for CLI to talk to the server, modify /system/core/Input.php line 351
$_SERVER['REMOTE_ADDR'] with $this->server('remote_addr').
In /assets/js/backend_calendar.js I changed this portion of code to sync with sync2 instead of sync, for example:
$('#google-sync').click(function() {
var getUrl = GlobalVariables.baseUrl + '/index.php/google/sync2/' + $('#select-filter-item').val();
In /application/libraries/google_sync.php
Under: $params = array(
Add: 'singleEvents' => true, //allows recurring appointments to show up as individual appointments
I added a function to providers_model.php
function get_all_provider_ids() {
$results = array('id' =>
$this->db->select('id as id')
->from('ea_users')
->where('id_roles', 2)
->get()
->row()
->id
);
return $results;
}
I have made significant changes to /application/controllers/google.php. I am attaching that file.
To launch by command line:
php /<path to EA installation>/index.php google/sync3
in crontab (which for me is at /etc/crontab) you will add the following line for auto sync at 11:30 pm: It can sync every hour if you like.
30 23 * * * php /<path to EA installation>/index.php google/sync3
Things left to be done:
adding a secret token for security
As it is, the worst that could happen is that someone could make it sync more often. So, as is I can deal with this.