Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
en:modifications:googlecalendersync [2014/10/31 20:26] swarnat |
en:modifications:googlecalendersync [2014/11/01 11:15] (current) swarnat |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Google Calendar Sync ====== | + | ====== Custom Google Calendar Sync ====== |
- | mod61.01 | + | Tested with VtigerCRM 6.0 and 6.1! |
- | ALTER TABLE `vtiger_google_oauth` ADD `additional` TEXT NOT NULL AFTER `userid`; | + | To setup the Vtiger Google Calendar sync with another calendar than the default one, you could apply this modifications. |
+ | At first install latest version of my [[en:extensions:vtigercrm_tools|Vtiger Tools.]] **This is absolutely necessary,** because I use this module to implement to management logic. | ||
- | /* modified by swarnat - mod61.01 */ | + | You need to press the "initialize" button on the management view of Vtiger Tools in the section "Google Calendar" |
- | At first install latest version of my [[en:extensions:vtigercrm_tools|Vtiger Tools.]] This is absolutely necessary, because I use this module to implement to logic. | + | ===== 1. File: /modules/Google/connectors/Calendar.php ===== |
- | ===== File: /modules/Google/connectors/Calendar.php ===== | + | === 1.1 Search === |
- | + | ||
- | === Search: === | + | |
<code php> | <code php> | ||
$query = $calendars->newEventQuery($query); | $query = $calendars->newEventQuery($query); | ||
</code> | </code> | ||
- | Insert After: | + | === Insert after === |
<code php> | <code php> | ||
/* modified by swarnat - mod61.01 */ | /* modified by swarnat - mod61.01 */ | ||
Line 26: | Line 25: | ||
</code> | </code> | ||
- | Search: | + | === 1.2 Search === |
<code php> | <code php> | ||
$createdEntry = $gContact->insertEvent($entity); | $createdEntry = $gContact->insertEvent($entity); | ||
</code> | </code> | ||
- | Replace this line with: | + | === Replace this line with === |
<code php> | <code php> | ||
/* modified by swarnat - mod61.01 */ | /* modified by swarnat - mod61.01 */ | ||
Line 45: | Line 45: | ||
</code> | </code> | ||
- | Search: (The end of this file) | + | === 1.3 Search (The end of this file) === |
<code php> | <code php> | ||
} | } | ||
Line 51: | Line 52: | ||
</code> | </code> | ||
- | Insert before: | + | === Insert before === |
<code php> | <code php> | ||
Line 70: | Line 71: | ||
/* modified by swarnat - mod61.01 */ | /* modified by swarnat - mod61.01 */ | ||
+ | </code> | ||
+ | |||
+ | ===== 2. File: /modules/Google/controllers/Calendar.php ===== | ||
+ | |||
+ | === 2.1 Search === | ||
+ | <code php> | ||
+ | public function getSourceType() { | ||
+ | return 'Events'; | ||
+ | } | ||
+ | </code> | ||
+ | === Insert after === | ||
+ | <code php> | ||
+ | /* modified by swarnat - mod61.01 */ | ||
+ | public function getCalendarId() { | ||
+ | $adb = \PearDatabase::getInstance(); | ||
+ | $sql = 'SELECT calendar_id FROM vtiger_gcal_sync WHERE user_id = ?'; | ||
+ | $result = $adb->pquery($sql, array($this->user->id)); | ||
+ | if($adb->num_rows($result) == 0) { | ||
+ | return null; | ||
+ | } | ||
+ | |||
+ | return $adb->query_result($result, 0, 'calendar_id'); | ||
+ | } | ||
+ | |||
+ | public function getCalendarList() { | ||
+ | return $this->targetConnector->getCalendarList(); | ||
+ | } | ||
+ | public function setCalendarId($calendarId) { | ||
+ | $this->targetConnector->setCalendarId($calendarId); | ||
+ | } | ||
+ | /* modified by swarnat - mod61.01 */ | ||
+ | </code> | ||
+ | |||
+ | ===== 3. File: /modules/Google/models/Module.php ===== | ||
+ | This file only exist in vtigerCRM 6.1, becaus 6.0 don't support remove of Sync. | ||
+ | |||
+ | === 3.1 Search === | ||
+ | <code php> | ||
+ | $db->pquery($query, array($module, $id)); | ||
+ | </code> | ||
+ | |||
+ | === Insert after === | ||
+ | <code php> | ||
+ | |||
+ | /* modified by swarnat - mod61.01 */ | ||
+ | $query = "DELETE FROM vtiger_gcal_sync WHERE user_id = ?"; | ||
+ | $db->pquery($query, array($id)); | ||
+ | /* modified by swarnat - mod61.01 */ | ||
+ | </code> | ||
+ | |||
+ | ===== 4. File: /modules/Google/views/List.php ===== | ||
+ | |||
+ | === 4.1 Search === | ||
+ | <code php> | ||
+ | $controller = new Google_Calendar_Controller($user); | ||
+ | </code> | ||
+ | |||
+ | === Insert After === | ||
+ | <code php> | ||
+ | /* modified by swarnat - mod61.01 */ | ||
+ | $calId = $controller->getCalendarId(); | ||
+ | if(empty($calId)) { | ||
+ | $list = $controller->getCalendarList(); | ||
+ | $this->viewer->assign('calendars', $list); | ||
+ | $this->viewer->view('GCalChooser.tpl', 'SwVtTools'); | ||
+ | |||
+ | return; | ||
+ | } | ||
+ | $controller->setCalendarId($calId); | ||
+ | /* modified by swarnat - mod61.01 */ | ||
</code> | </code> |