Example #1
0
        function _GoogleCalendarTests()
        {
            $calendar = new GoogleCalendar();
			
			if (!$_SESSION["GoogleAuthToken"])
			{
				// Try login to system
				$login = $calendar->Authenticate("*****@*****.**", "GhNjkdFtg4", "cl");
				$this->assertTrue($login, "Success login to google system");
			}
			
			$event = new GoogleCalendarEvent("Test event", "Test Description", time());
			$res = $calendar->AddEvent($event);
			$this->assertTrue($res, "Event successfully added");
        }
Example #2
0
 public static function getInstance()
 {
     if (!self::$instance) {
         if (Yii::app()->user->isGuest || !Yii::app()->getModule('event')->calendarEnabled) {
             self::$instance = new GoogleCalendarVoid();
         } else {
             self::$instance = new GoogleCalendar();
         }
     }
     return self::$instance;
 }
/****************************************************************/
/**
 * This file is used to associate/dissociate user's Google account
 * with ATutor Calendar module.
 * If request is for association then first this page will 
 * display a login screen, after login is successful or 
 * user is already logged in then a consent screen is displaed. 
 * After user gives consent, the pop-up window closes.
 * If the request is for dissociation then user's entry in the 
 * database is removed and session token is invalidated. 
 */
$_user_location = 'public';
require_once 'includes/classes/googlecalendar.class.php';
define('AT_INCLUDE_PATH', '../../../include/');
require AT_INCLUDE_PATH . 'vitals.inc.php';
$gcalobj = new GoogleCalendar();
if (isset($_GET['logout'])) {
    //request is for dissociation
    //removed entry from database
    $query = "DELETE FROM %scalendar_google_sync WHERE userid=%d";
    queryDB($query, array(TABLE_PREFIX, $_SESSION['member_id']));
    //invalidate session token
    $gcalobj->logout();
} else {
    //request is for association
    if (!isset($_GET['token'])) {
        //redirect to login page/consent page
        $query = "DELETE FROM %scalendar_google_sync WHERE userid=%d";
        queryDB($query, array(TABLE_PREFIX, $_SESSION['member_id']));
        unset($_SESSION['sessionToken']);
        $authSubUrl = $gcalobj->getAuthSubUrl();
/*                                                              */
/* This module provides standard calendar features in ATutor.   */
/*                                                              */
/* Author: Anurup Raveendran, Herat Gandhi                      */
/* This program is free software. You can redistribute it and/or*/
/* modify it under the terms of the GNU General Public License  */
/* as published by the Free Software Foundation.                */
/****************************************************************/
/**
 * This file is used to reflect changes from ATutor to Google Calendar.
 */
$_user_location = 'public';
require_once 'includes/classes/googlecalendar.class.php';
define('AT_INCLUDE_PATH', '../../../include/');
require AT_INCLUDE_PATH . 'vitals.inc.php';
$gcalobj = new GoogleCalendar();
$client = $gcalobj->getAuthSubHttpClient();
$gdata_cal = new Zend_Gdata_Calendar($client);
$event_url = $_GET['id'];
$command = $_GET['cmd'];
try {
    //Get the event object from its id.
    $event = $gdata_cal->getCalendarEventEntry($event_url);
    if (strcmp($command, 'delete') == 0) {
        //If event is deleted then call delete method.
        $event->delete();
    } else {
        if (strcmp($command, 'update') == 0) {
            //Update event attributes and then save it in Google Calendar.
            $event->title = $gdata_cal->newTitle($_GET['title']);
            $when = $gdata_cal->newWhen();
Example #5
0
	/**
	* GoogleCalendarAdd
	* Uses the Google Calendar API to add an event to Google Calendar
	*
	* @param Array $data An array containing username, password, what, where, description, datefrom, timefrom, dateto, timeto, and allday
	* @param Boolean $test_auth Set to true to test authentication details only. This will throw an exception if authentication fails or will return true
	*
	* @throws Exception If an error occurs this function will throw an exception.
	*
	* @return Void Returns nothing
	*/
	function GoogleCalendarAdd($data,$test_auth = false)
	{
		if (!class_exists('GoogleCalendar', false)) {
			require_once(SENDSTUDIO_LIB_DIRECTORY . "/googlecalendar/googlecalendar.php");
		}

		$googlecalendar = new GoogleCalendar($data['username'],$data['password']);

		if ($test_auth) {
			return;
		}

		// Populate the event with the desired information
		$event['title'] = $data['what'];
		if (isset($data['where'])) {
			$event['where'] = $data['where'];
		}
		if (isset($data['description'])) {
			$event['text'] = $data['description'];
		}

		$user = GetUser();

		$allday = false;
		if (isset($data['allday'])) {
			$allday = true;
		}

		$event['when'] = array();
		$event['when']['from'] = $this->GoogleCalendarDate($data['datefrom'],$data['timefrom'],$allday,false);
		$event['when']['to'] = $this->GoogleCalendarDate($data['dateto'],$data['timeto'],$allday,true);

		if ($event['when']['from'] == $event['when']['to'] && $allday) {
			unset($event['when']['to']);
		}

		$newEvent = $googlecalendar->addSimpleEvent($event);
	}
/*                                                              */
/* Author: Anurup Raveendran, Herat Gandhi                      */
/* This program is free software. You can redistribute it and/or*/
/* modify it under the terms of the GNU General Public License  */
/* as published by the Free Software Foundation.                */
/****************************************************************/
/**
 * This file returns events from Google Calendar in JSON format.
 */
$_user_location = 'public';
require_once 'includes/classes/googlecalendar.class.php';
define('AT_INCLUDE_PATH', '../../../include/');
require AT_INCLUDE_PATH . 'vitals.inc.php';
//Default values
define('CALENDAR_DEF_COLOR', '#3399FF');
$gcalobj = new GoogleCalendar();
$qry = "SELECT * FROM %scalendar_google_sync WHERE userid=%d";
$row = queryDB($qry, array(TABLE_PREFIX, $_SESSION['member_id']), TRUE);
if (count($row) > 0) {
    $_SESSION['sessionToken'] = $row['token'];
    if ($gcalobj->isvalidtoken($_SESSION['sessionToken'])) {
        $client = $gcalobj->getAuthSubHttpClient();
        $query = "SELECT * FROM %scalendar_google_sync WHERE userid= %d";
        $rowval = queryDB($query, array(TABLE_PREFIX, $_SESSION['member_id']), TRUE);
        $prevval = $rowval['calids'];
        outputCalendarByDateRange($client, $_GET['start'], $_GET['end'], $prevval, $gcalobj);
    }
}
/**
 * Iterate through all the Google Calendars and create a JSON encoded array of events.
 *
/* https://atutorcalendar.wordpresults.com/                     */
/*                                                              */
/* This module provides standard calendar featuresult in ATutor.*/
/*                                                              */
/* Author: Anurup Raveendran, Herat Gandhi                      */
/* This program is free software. You can redistribute it and/or*/
/* modify it under the terms of the GNU General Public License  */
/* as published by the Free Software Foundation.                */
/****************************************************************/
/**
 * This file is used to display all the available
 * calendars in Google Account of the user.
 */
$_user_location = 'public';
require_once 'includes/classes/googlecalendar.class.php';
$gcalobj = new GoogleCalendar();
$query = "SELECT * FROM %scalendar_google_sync WHERE userid=%d";
$row = queryDB($query, array(TABLE_PREFIX, $_SESSION['member_id']), TRUE);
//Check if user has associated his/her Google account or not
if (count($row) > 0) {
    /**
     * User has already associated his/her Google account. 
     * So get the session token from database.
     */
    $_SESSION['sessionToken'] = $row['token'];
    //Verify token
    if ($gcalobj->isvalidtoken($_SESSION['sessionToken'])) {
        $client = $gcalobj->getAuthSubHttpClient();
        //Output calendar list in the right side panel
        $gcalobj->outputCalendarList($client);
    }