Skip to content
Snippets Groups Projects
Commit 9526c9be authored by Satish's avatar Satish
Browse files

Email Templates and google issues fixed

parent 23169e3f
No related branches found
No related tags found
No related merge requests found
......@@ -163,11 +163,11 @@
</div>
{/if}
{if $SCHEDULEDREPORTS->get('next_trigger_time')}
<div class="col-lg-12">
<div class="col-lg-12" style="padding:5px 0px 10px 0px;">
<div class='col-lg-3'>
<span class=''>{vtranslate('LBL_NEXT_TRIGGER_TIME', $MODULE)}</span>
</div>
<div class='span'>
<div class='col-lg-5'>
{$SCHEDULEDREPORTS->getNextTriggerTimeInUserFormat()}<span>&nbsp;({$CURRENT_USER->time_zone})</span>
</div>
</div>
......
No preview for this file type
No preview for this file type
......@@ -21,21 +21,6 @@
<center>
<table border="0" cellpadding="0" cellspacing="0" class="borderGrey" width="600px">
<tbody>
<tr>
<td colspan="6"><!-- Begin Pre header -->
<table border="0" cellpadding="5" cellspacing="0" height="52" style="font-family: Helvetica,Verdana,sans-serif; font-size: 10px; color: rgb(102, 102, 102); background-color: rgb(232, 245, 254);" width="597">
<tbody>
<tr>
<td>
<div>Use this area to offer a short teaser of your email&#39;s content. Text here will show in the preview area<br />
of some email clients.</div>
</td>
<td><a href="{$VIEW_IN_BROWSER_TAG}" target="_blank">View in browser</a></td>
</tr>
</tbody>
</table>
<!-- // End Pre header \ --></td>
</tr>
<tr style="height:50px;">
<td colspan="6" style="border-top: 1px solid #ddd; font-family: Helvetica,Verdana,sans-serif"></td>
</tr>
......@@ -54,7 +39,7 @@
<tr>
<td valign="top" width="350px">
<center>
<div><em>Copyright &copy; 2014 {if !(empty($WEBSITE_URL))}<a href="{$WEBSITE_URL}" target="_blank">{$WEBSITE_URL}</a>{else}your company.com{/if}, All rights reserved.</em></div>
<div><em>Copyright &copy; {date('Y')} {if !(empty($WEBSITE_URL))}<a href="{$WEBSITE_URL}" target="_blank">{$WEBSITE_URL}</a>{else}your company.com{/if}, All rights reserved.</em></div>
</center>
</td>
</tr>
......
......@@ -31,6 +31,8 @@ class Google_Oauth_Connector {
protected $_oauthOptions = array(
'requestScheme' => Zend_Oauth::REQUEST_SCHEME_HEADER,
'version' => '1.0',
'consumerKey' => '639253257022.apps.googleusercontent.com',
'consumerSecret' => 'CxnOsnYx_RNyTWVfzTIenmhQ',
'signatureMethod' => 'HMAC-SHA1',
'requestTokenUrl' => 'https://www.google.com/accounts/OAuthGetRequestToken',
'userAuthorizationUrl' => 'https://www.google.com/accounts/OAuthAuthorizeToken',
......@@ -45,8 +47,6 @@ class Google_Oauth_Connector {
self::initializeSchema();
$this->userId = $userId;
$this->_oauthOptions['callbackUrl'] = $callbackUrl;
$this->_oauthOptions['consumerKey'] = VtigerConfig::getOD('GOOGLESYNC_CONSUMER_KEY');
$this->_oauthOptions['consumerSecret'] = VtigerConfig::getOD('GOOGLESYNC_CONSUMER_SECRET');
$this->db = PearDatabase::getInstance();
}
......@@ -77,15 +77,15 @@ class Google_Oauth_Connector {
$this->userId = Users_Record_Model::getCurrentUserModel()->getId();
if (!$accessToken && !$requestToken){
$query = "SELECT 1 FROM vtiger_app_oauth1 WHERE userid=? and service=?";
$query = "SELECT 1 FROM vtiger_google_oauth WHERE userid=? and service=?";
$params = array($this->userId, $service);
}
else if ($accessToken){
$query = "SELECT access_token FROM vtiger_app_oauth1 WHERE userid=? and service=? AND access_token<>? AND access_token IS NOT NULL";
$query = "SELECT access_token FROM vtiger_google_oauth WHERE userid=? and service=? AND access_token<>? AND access_token IS NOT NULL";
$params = array($this->userId, $service, '');
}
else if ($requestToken){
$query = "SELECT request_token FROM vtiger_app_oauth1 WHERE userid=? and service=? AND request_token<>? AND request_token IS NOT NULL";
$query = "SELECT request_token FROM vtiger_google_oauth WHERE userid=? and service=? AND request_token<>? AND request_token IS NOT NULL";
$params = array($this->userId, $service, '');
}
$result = $this->db->pquery($query, $params);
......@@ -103,10 +103,10 @@ class Google_Oauth_Connector {
*/
protected function storeAccessToken($service, $token) {
$user = Users_Record_Model::getCurrentUserModel();
$query = "INSERT INTO vtiger_app_oauth1(service,access_token,userid) VALUES(?,?,?)";
$query = "INSERT INTO vtiger_google_oauth(service,access_token,userid) VALUES(?,?,?)";
$params = array($service, base64_encode(serialize($token)), $user->getid());
if (self::hasStoredToken($service, false, true)) {
$query = "UPDATE vtiger_app_oauth1 SET access_token=? WHERE userid=? AND service=?";
$query = "UPDATE vtiger_google_oauth SET access_token=? WHERE userid=? AND service=?";
$params = array(base64_encode(serialize($token)), $user->getId(), $service);
}
......@@ -117,7 +117,7 @@ class Google_Oauth_Connector {
if(!$this->userId)
$this->userId = Users_Record_Model::getCurrentUserModel()->getId();
$query = "SELECT access_token FROM vtiger_app_oauth1 WHERE userid=? AND service =?";
$query = "SELECT access_token FROM vtiger_google_oauth WHERE userid=? AND service =?";
$params = array($this->userId, $service);
$result = $this->db->pquery($query, $params);
......@@ -128,10 +128,10 @@ class Google_Oauth_Connector {
protected function storeRequestToken($service, $token) {
$user = Users_Record_Model::getCurrentUserModel();
$query = "DELETE FROM vtiger_app_oauth1 where service=? and userid=?";
$query = "DELETE FROM vtiger_google_oauth where service=? and userid=?";
$this->db->pquery($query, array($service, $user->getId()));
$query = "INSERT INTO vtiger_app_oauth1(service,request_token,userid) values(?,?,?)";
$query = "INSERT INTO vtiger_google_oauth(service,request_token,userid) values(?,?,?)";
$this->db->pquery($query, array($service, base64_encode(serialize($token)), $user->getId()));
}
......@@ -139,7 +139,7 @@ class Google_Oauth_Connector {
protected function retrieveRequestToken($service) {
$user = Users_Record_Model::getCurrentUserModel();
$query = "SELECT request_token FROM vtiger_app_oauth1 WHERE userid=? AND service =?";
$query = "SELECT request_token FROM vtiger_google_oauth WHERE userid=? AND service =?";
$params = array($user->getId(), $service);
$result = $this->db->pquery($query, $params);
......@@ -180,9 +180,9 @@ class Google_Oauth_Connector {
public static function initializeSchema(){
if(!Vtiger_Utils::CheckTable('vtiger_app_oauth1')) {
Vtiger_Utils::CreateTable('vtiger_app_oauth1',
'(service varchar(64),request_token text,access_token text,userid int, serviceid varchar(255), name varchar(255))',true);
if(!Vtiger_Utils::CheckTable('vtiger_google_oauth')) {
Vtiger_Utils::CreateTable('vtiger_google_oauth',
'(service varchar(64),request_token text,access_token text,userid int)',true);
}
}
......
......@@ -54,13 +54,14 @@ class Google_Oauth2_Connector {
const OAUTH2_REVOKE_URI = 'https://accounts.google.com/o/oauth2/revoke';
public function __construct($module,$userId=false) {
global $site_URL;
$this->source_module = $module;
if($userId) $this->user_id = $userId;
$this->service_name = $this->service_provider . $module;
$this->client_id = VtigerConfig::getOD('GOOGLE_SYNC_CLIENT_ID');
$this->client_secret = VtigerConfig::getOD('GOOGLE_SYNC_CLIENT_SECRET');
$this->redirect_uri = VtigerConfig::getOD('OAUTH_SERVER_URL');
$this->scope = 'https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile https://www.google.com/m8/feeds https://www.googleapis.com/auth/calendar';
$this->client_id = Google_Config_Connector::$clientId;
$this->client_secret = Google_Config_Connector::$clientSecret;
$this->redirect_uri = rtrim($site_URL, '/').'/index.php?module=Google&view=List&operation=sync&sourcemodule='.$this->source_module.'&service='.$this->service_name;
$this->scope = $this->scopes[$this->source_module];
}
public function getClientId() {
......@@ -100,9 +101,6 @@ class Google_Oauth2_Connector {
'access_type=' . urlencode($this->access_type),
'approval_prompt=' . urlencode($this->approval_prompt),
);
if (isset($this->state)) {
$params[] = 'state=' . urlencode($this->state);
}
$queryString = implode('&', $params);
return self::OAUTH2_AUTH_URL . "?$queryString";
}
......@@ -119,8 +117,8 @@ class Google_Oauth2_Connector {
public function getState($source) {
global $site_URL;
$callbackUri = $site_URL . '/index.php?module=Google&view=List&operation=sync&sourcemodule=' .
$this->source_module . '&service=' . $source.'&_ignoreOnBoardCompletion=true';
$callbackUri = rtrim($site_URL, '/') . '/index.php?module=Google&view=List&operation=sync&sourcemodule=' .
$this->source_module . '&service=' . $source;
$stateDetails['url'] = $callbackUri;
$parse = parse_url($site_URL);
$ipAddr = getHostByName($parse['host']);
......@@ -183,11 +181,11 @@ class Google_Oauth2_Connector {
$modulesSupported = array('Contacts', 'Calendar');
foreach($modulesSupported as $moduleName) {
$params = array($this->service_provider.$moduleName,$accessToken,$refresh_token,$this->user_id);
$sql = 'INSERT INTO ' . $this->table_name . ' VALUES (' . generateQuestionMarks($params) . ')';
$this->db->pquery($sql,$params);
}
$sql = 'INSERT INTO ' . $this->table_name . ' VALUES (' . generateQuestionMarks($params) . ')';
$this->db->pquery($sql,$params);
}
}
protected function retreiveToken() {
if(!$this->user_id) $this->user_id = Users_Record_Model::getCurrentUserModel()->getId();
$query = 'SELECT access_token,refresh_token FROM ' . $this->table_name . ' WHERE userid=? AND service =?';
......@@ -232,12 +230,12 @@ class Google_Oauth2_Connector {
$encodedToken = $this->fireRequest(self::OAUTH2_TOKEN_URI,array(),$params);
$decodedToken = json_decode($encodedToken,true);
if(!isset($decodedToken['error'])) {
$decodedToken['created'] = time();
$token['access_token'] = $decodedToken;
$token['refresh_token'] = $this->token['refresh_token'];
$this->updateAccessToken(json_encode($decodedToken),$token['refresh_token']);
$this->setToken($token);
}
$decodedToken['created'] = time();
$token['access_token'] = $decodedToken;
$token['refresh_token'] = $this->token['refresh_token'];
$this->updateAccessToken(json_encode($decodedToken),$token['refresh_token']);
$this->setToken($token);
}
}
public function authorize() {
......
......@@ -92,7 +92,7 @@ class Google_Utils_Helper {
static function getCallbackUrl($request, $options = array()) {
global $site_URL;
$callback = $site_URL . "/index.php?module=" . $request['module'] . "&view=List&sourcemodule=" . $request['sourcemodule'];
$callback = rtrim($site_URL, '/') . "/index.php?module=".$request['module']."&view=List&sourcemodule=".$request['sourcemodule'];
foreach ($options as $key => $value) {
$callback.="&" . $key . "=" . $value;
}
......
......@@ -195,6 +195,7 @@ class Google_Contacts_Model extends WSAPP_SyncRecordModel {
$recordModel->set('mode', '');
$recordModel->set('accountname', $orgName);
$recordModel->set('assigned_user_id', $userId);
$recordModel->set('source', 'GOOGLE');
if($description) {
$recordModel->set('description', $description);
}
......
......@@ -11,7 +11,7 @@ class Google_Module_Model extends Vtiger_Module_Model {
public static function removeSync($module, $id) {
$db = PearDatabase::getInstance();
$query = "DELETE FROM vtiger_app_oauth1 WHERE service = ? AND userid = ?";
$query = "DELETE FROM vtiger_google_oauth WHERE service = ? AND userid = ?";
$db->pquery($query, array($module, $id));
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment