Index: modules/Calendar/DetailView.php =================================================================== --- modules/Calendar/DetailView.php (revisión: 1679) +++ modules/Calendar/DetailView.php (copia de trabajo) @@ -353,6 +353,11 @@ $custom_fields_data = getCalendarCustomFields($tabid,'detail_view',$focus->column_fields); $smarty->assign("CUSTOM_FIELDS_DATA", $custom_fields_data); +// Google Calendar Integration +require_once('modules/Calendar/VtigerGoogleCalendar.php'); +$smarty->assign("VtigerGoogleCalendarLogin", (VtigerGoogleCalendar::isInSession()? 'true' : 'false')); +// END + $smarty->display("ActivityDetailView.tpl"); ?> \ No newline at end of file Index: modules/Calendar/Calendar.js =================================================================== --- modules/Calendar/Calendar.js (revisión: 1679) +++ modules/Calendar/Calendar.js (copia de trabajo) @@ -96,4 +96,64 @@ document.frmOpenLstView.submit(); } +/* Google Calendar Integration */ +var vtigergcal_login_required = true; +function vtigergcal_indicator(show) { + if(show) $("vtigergcal_indicator").style.display = "inline"; + else $("vtigergcal_indicator").style.display = "none"; +} +function vtigergcal_updateEvent(record, haslogin) { + if(!haslogin && vtigergcal_login_required) { + vtigergcal_loginForm(true); + } else { + vtigergcal_updateEventNow(record); + } +} +function vtigergcal_updateEventNow(record, loginform) { + var loginParams = ''; + if(loginform) { + loginParams = "&g_name=" + encodeURIComponent(loginform.g_name.value) + + "&g_pass=" + encodeURIComponent(loginform.g_pass.value) + + "&g_remember=" + encodeURIComponent(loginform.g_remember.checked); + } + + vtigergcal_loginForm(false); + vtigergcal_indicator(true); + new Ajax.Request("index.php", + { queue:{position:"end", scope:"command"}, method:"post", + postBody:"module=Calendar&action=CalendarAjax&ajax=true&file=VtigerGoogleCalendarAjax&record=" + record + loginParams, + onComplete:function (response) {vtigergcal_updateEventCallback(response.responseText);}}); +} +function vtigergcal_updateEventCallback(responseText) { + vtigergcal_indicator(false); + responseText = trim(responseText); + + var loginreq = vtigergcal_response2map(responseText)['LOGINREQ']; + if(loginreq) loginreq = loginreq.toUpperCase(); + + if(vtigergcal_response2map(responseText)['LOGINREQ'] == 'FALSE') { + vtigergcal_login_required = false; + } +} +function vtigergcal_response2map(responseText) { + var keyvalmap = {}; + var keyvals = responseText.split(':#:'); + for(var index = 0; index < keyvals.length; index += 2) { + keyvalmap[keyvals[index]] = keyvals[index+1]; + } + return keyvalmap; +} + +function vtigergcal_loginForm(show) { + if($('vtigergcal_loginform_lay')) { + if(show) { + $('vtigergcal_loginform_lay').style.display = 'block'; + $('VtigerGoogleCalendarLoginForm').g_name.focus(); + } + else $('vtigergcal_loginform_lay').style.display = 'none'; + } +} +/* END */ + + Index: Smarty/templates/ActivityDetailView.tpl =================================================================== --- Smarty/templates/ActivityDetailView.tpl (revisión: 1679) +++ Smarty/templates/ActivityDetailView.tpl (copia de trabajo) @@ -101,6 +101,12 @@ +{* Vtiger Google Calendar Integration *} +{if $VtigerGoogleCalendarLogin eq 'false'} + {include file='VtigerGoogleCalendarLogin.tpl'} +{/if} +{* END *} +