pquery("SELECT stateencodedvalues FROM vtiger_wsapp_sync_state WHERE name IN (". generateQuestionMarks($names).")", array($names)); $resultRows = $db->num_rows($result); $appKey = array(); for($i=0; $i<$resultRows; $i++) { $stateValuesJson = $db->query_result($result, $i, 'stateencodedvalues'); $stateValues = Zend_Json::decode(decode_html($stateValuesJson)); $appKey[] = $stateValues['synctrackerid']; } if(!empty($appKey)) { $sql = 'UPDATE vtiger_wsapp SET name = ? WHERE appkey IN ('. generateQuestionMarks($appKey).')'; $res = Migration_Index_View::ExecuteQuery($sql, array('Google_vtigerSyncHandler', $appKey)); } //Ends 141 //Google Calendar sync changes /** * Please refer this trac (http://trac.vtiger.com/cgi-bin/trac.cgi/ticket/8354#comment:3) * for configuration of vtiger to Google OAuth2 */ global $adb; if(!Vtiger_Utils::CheckTable('vtiger_google_oauth2')) { Vtiger_Utils::CreateTable('vtiger_google_oauth2', '(service varchar(20),access_token varchar(500),refresh_token varchar(500),userid int(19))',true); echo '
vtiger_google_oauth2 table created
'; } //(start)Migrating GoogleCalendar ClientIds in wsapp_recordmapping to support v3 $syncTrackerIds = array(); if(Vtiger_Utils::CheckTable('vtiger_wsapp_sync_state')) { $sql = 'SELECT stateencodedvalues from vtiger_wsapp_sync_state WHERE name = ?'; $result = $db->pquery($sql,array('Vtiger_GoogleCalendar')); $num_of_rows = $adb->num_rows($result); for($i=0;$i<$num_of_rows;$i++) { $stateEncodedValues = $adb->query_result($result,$i,'stateencodedvalues'); $htmlDecodedStateEncodedValue = decode_html($stateEncodedValues); $stateDecodedValues = json_decode($htmlDecodedStateEncodedValue,true); if(is_array($stateDecodedValues) && isset($stateDecodedValues['synctrackerid'])) { $syncTrackerIds[] = $stateDecodedValues['synctrackerid']; } } } //$syncTrackerIds - list of all Calendar sync trackerIds $appIds = array(); if(count($syncTrackerIds)) { $sql = 'SELECT appid FROM vtiger_wsapp WHERE appkey IN (' . generateQuestionMarks($syncTrackerIds) . ')'; $result = Migration_Index_View::ExecuteQuery($sql,$syncTrackerIds); $num_of_rows = $adb->num_rows($result); for($i=0;$i<$num_of_rows;$i++) { $appId = $adb->query_result($result,$i,'appid'); if($appId) $appIds[] = $appId; } } //$appIds - list of all Calendarsync appids if(count($appIds)) { $sql = 'SELECT id,clientid FROM vtiger_wsapp_recordmapping WHERE appid IN (' . generateQuestionMarks($appIds) . ')'; $result = Migration_Index_View::ExecuteQuery($sql,$appIds); $num_of_rows = $adb->num_rows($result); for($i=0;$i<$num_of_rows;$i++) { $id = $adb->query_result($result,$i,'id'); $clientid = $adb->query_result($result,$i,'clientid'); $parts = explode('/', $clientid); $newClientId = end($parts); Migration_Index_View::ExecuteQuery('UPDATE vtiger_wsapp_recordmapping SET clientid = ? WHERE id = ?',array($newClientId,$id)); } echo '
vtiger_wsapp_recordmapping clientid migration completed for CalendarSync'; } //(end) //Google Calendar sync changes ends here //Google migration : Create Sync setting table $sql = 'CREATE TABLE vtiger_google_sync_settings (user int(11) DEFAULT NULL, module varchar(50) DEFAULT NULL , clientgroup varchar(255) DEFAULT NULL, direction varchar(50) DEFAULT NULL)'; $db->pquery($sql,array()); $sql = 'CREATE TABLE vtiger_google_sync_fieldmapping ( vtiger_field varchar(255) DEFAULT NULL, google_field varchar(255) DEFAULT NULL, google_field_type varchar(255) DEFAULT NULL, google_custom_label varchar(255) DEFAULT NULL, user int(11) DEFAULT NULL)'; $db->pquery($sql,array()); echo '
Google sync setting and mapping table added
';