Skip to content
This repository was archived by the owner on Feb 12, 2025. It is now read-only.

Commit c61b949

Browse files
committed
Merge pull request #12 from irontec/recode_login
Changed login process to avoid session refresh timer #10
2 parents 35227de + 7ff9119 commit c61b949

11 files changed

+69
-116
lines changed

com_irontec_zsugar.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# zSugar zimlet properties
22
zsugar_name = zsugar
33
zsugar_title = zsugar: Zimbra-SugarCRM Integration
4-
zsugar_version = 1.4.13
4+
zsugar_version = 1.4.14
55
zsugar_tooltip = SugarCRM Integration Zimlet
66
zsugar_powered = http://www.irontec.com
77

@@ -35,7 +35,7 @@ zsugar_notconnected = Not authenticated in SugarCRM
3535
zsugar_connected = Your session is authenticated.
3636

3737

38-
zsugar_aboutText = <p class='big center'>zSugar 1.4.13</p><p class='med center'>Sugar CRM Integration Zimlet</p><p id='zsuguar_ilogo'>Copyright 2009 Irontec SL<br /><a href='http://www.irontec.com'>http://www.irontec.com</a></p><p id='zsugar_logo'>Project funded by the Department of Culture (Vice-Ministry for Language Policy)</p>
38+
zsugar_aboutText = <p class='big center'>zSugar 1.4.14</p><p class='med center'>Sugar CRM Integration Zimlet</p><p id='zsuguar_ilogo'>Copyright 2009 Irontec SL<br /><a href='http://www.irontec.com'>http://www.irontec.com</a></p><p id='zsugar_logo'>Project funded by the Department of Culture (Vice-Ministry for Language Policy)</p>
3939

4040
zsugar_errorInsertingEmail = An error has occurried while saving email.
4141
zsugar_errorAttachingFile = An error has occurried while saving attachment.

com_irontec_zsugar.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<zimlet name="com_irontec_zsugar" version="1.4.13" description="SugarCRM integration">
1+
<zimlet name="com_irontec_zsugar" version="1.4.14" description="SugarCRM integration">
22
<include>md5.js</include>
33
<include>sugarrestapi.js</include>
44
<include>zsugar.js</include>

com_irontec_zsugar_es.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# zSugar zimlet properties
22
zsugar_name = zsugar
33
zsugar_title = zsugar: Integración Zimbra-SugarCRM
4-
zsugar_version = 1.4.13
4+
zsugar_version = 1.4.14
55
zsugar_tooltip = SugarCRM Integration Zimlet
66
zsugar_powered = http://www.irontec.com
77

@@ -35,7 +35,7 @@ zsugar_notconnected = No se encuentra autenticado en el SugarCRM
3535
zsugar_connected = Su sessión esta autenticada.
3636

3737

38-
zsugar_aboutText = <p class='big center'>zSugar 1.4.13</p><p class='med center'>Sugar CRM Integration Zimlet</p><p id='zsuguar_ilogo'>Copyright 2009 Irontec SL<br /><a href='http://www.irontec.com'>http://www.irontec.com</a></p><p id='zsugar_logo'>Proyecto subvencionado por el departamento de cultura (Viceconsejería de Política Lingüística)</p>
38+
zsugar_aboutText = <p class='big center'>zSugar 1.4.14</p><p class='med center'>Sugar CRM Integration Zimlet</p><p id='zsuguar_ilogo'>Copyright 2009 Irontec SL<br /><a href='http://www.irontec.com'>http://www.irontec.com</a></p><p id='zsugar_logo'>Proyecto subvencionado por el departamento de cultura (Viceconsejería de Política Lingüística)</p>
3939

4040
zsugar_errorInsertingEmail = Algún error guardando el email.
4141
zsugar_errorAttachingFile = Algún error guardando el adjunto.

com_irontec_zsugar_eu.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# zSugar zimlet properties
22
zsugar_name = zsugar
33
zsugar_title = zsugar: Zimbra-SugarCRM integrazioa
4-
zsugar_version = 1.4.13
4+
zsugar_version = 1.4.14
55
zsugar_tooltip = SugarCRM Integrazio Zimlet-a
66
zsugar_powered = http://www.irontec.com
77

@@ -35,7 +35,7 @@ zsugar_connected = Zure saioa autentifikatuta dago.
3535

3636

3737

38-
zsugar_aboutText = <p class='big center'>zSugar 1.4.13</p><p class='med center'>Sugar CRM Integrazio Zimlet-a</p><p id='zsuguar_ilogo'>Copyright 2009 Irontec SL<br /><a href='http://www.irontec.com'>http://www.irontec.com</a></p><p id='zsugar_logo'>Kultura Sailak (Hizkuntza Politikarako Sailburuordetzak) diruz lagundutako egitasmoa.</p>
38+
zsugar_aboutText = <p class='big center'>zSugar 1.4.14</p><p class='med center'>Sugar CRM Integrazio Zimlet-a</p><p id='zsuguar_ilogo'>Copyright 2009 Irontec SL<br /><a href='http://www.irontec.com'>http://www.irontec.com</a></p><p id='zsugar_logo'>Kultura Sailak (Hizkuntza Politikarako Sailburuordetzak) diruz lagundutako egitasmoa.</p>
3939

4040
zsugar_errorInsertingEmail = Arazoren bat email-a gordetzen.
4141

com_irontec_zsugar_pl.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# zSugar zimlet properties
22
zsugar_name = zsugar
33
zsugar_title = zsugar: Integracja Zimbra i SugarCRM
4-
zsugar_version = 1.4.13
4+
zsugar_version = 1.4.14
55
zsugar_tooltip = Zimlet integracji z SugarCRM
66
zsugar_powered = http://www.irontec.com
77

@@ -35,7 +35,7 @@ zsugar_notconnected = Nie zalogowano do SugarCRM
3535
zsugar_connected = Zalogowano do SugarCRM.
3636

3737

38-
zsugar_aboutText = <p class='big center'>zSugar 1.4.13</p><p class='med center'>Zimlet integracji z SugarCRM</p><p id='zsuguar_ilogo'>Copyright 2009 Irontec SL<br /><a href='http://www.irontec.com'>http://www.irontec.com</a></p><p id='zsugar_logo'>Project funded by the Department of Culture (Vice-Ministry for Language Policy)</p>
38+
zsugar_aboutText = <p class='big center'>zSugar 1.4.14</p><p class='med center'>Zimlet integracji z SugarCRM</p><p id='zsuguar_ilogo'>Copyright 2009 Irontec SL<br /><a href='http://www.irontec.com'>http://www.irontec.com</a></p><p id='zsugar_logo'>Project funded by the Department of Culture (Vice-Ministry for Language Policy)</p>
3939

4040
zsugar_errorInsertingEmail = Podczas zapisu email wystąpił błąd.
4141
zsugar_errorAttachingFile = Podczas zapisu pliku załącznika wystąpił błąd.

com_irontec_zsugar_ru.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# zSugar zimlet properties
22
zsugar_name = zsugar
33
zsugar_title = zsugar: Zimbra-SugarCRM \u0418\u043D\u0442\u0435\u0433\u0440\u0430\u0442\u043E\u0440
4-
zsugar_version = 1.4.13
4+
zsugar_version = 1.4.14
55
zsugar_tooltip = SugarCRM \u0418\u043D\u0442\u0435\u0433\u0440\u0430\u0442\u043E\u0440 Zimlet
66
zsugar_powered = http://www.irontec.com
77

@@ -34,7 +34,7 @@ zsugar_notconnected = \u041D\u0435 \u0430\u0432\u0442\u043E\u0440\u0438\u0437\u0
3434
zsugar_connected = \u0410\u0432\u0442\u043E\u0440\u0438\u0437\u0438\u0440\u043E\u0432\u0430\u043D.
3535

3636

37-
zsugar_aboutText = <p class=\'big center\'>zSugar 1.4.13</p><p class=\'med center\'>Sugar CRM Integration Zimlet</p><p id=\'zsuguar_ilogo\'>Copyright 2009 Irontec SL<br /><a href=\'http://www.irontec.com\'>http://www.irontec.com</a></p><p id=\'zsugar_logo\'>Project funded by the Department of Culture (Vice-Ministry for Language Policy)</p>
37+
zsugar_aboutText = <p class=\'big center\'>zSugar 1.4.14</p><p class=\'med center\'>Sugar CRM Integration Zimlet</p><p id=\'zsuguar_ilogo\'>Copyright 2009 Irontec SL<br /><a href=\'http://www.irontec.com\'>http://www.irontec.com</a></p><p id=\'zsugar_logo\'>Project funded by the Department of Culture (Vice-Ministry for Language Policy)</p>
3838

3939
zsugar_errorInsertingEmail = \u041E\u0448\u0438\u0431\u043A\u0430 \u043F\u0440\u0438 \u0441\u043E\u0445\u0440\u0430\u043D\u0435\u043D\u0438\u0438 \u043F\u043E\u0447\u0442\u044B.
4040
zsugar_errorAttachingFile = \u041E\u0448\u0438\u0431\u043A\u0430 \u043F\u0440\u0438 \u0441\u043E\u0445\u0440\u0430\u043D\u0435\u043D\u0438\u0438 \u0432\u043B\u043E\u0436\u0435\u043D\u0438\u044F.

doc/INSTALL

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
zSugar 1.4.13
1+
zSugar 1.4.14
22
SugarCRM integration into Zimbra
33

44
================================

doc/LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
zSugar 1.4.13
1+
zSugar 1.4.14
22

33
SugarCRM integration into Zimbra
44
================================

doc/README

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
zSugar 1.4.13
1+
zSugar 1.4.14
22
SugarCRM integration into Zimbra
33

44
================================

sugarrestapi.js

Lines changed: 23 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,8 @@ function ironsugar(url,u,p,obj) {
3737
this.pass = p;
3838
this.application = "ironsugar zimlet";
3939
this.userData = [];
40-
4140
this.sessid = false;
42-
4341
this.parent = obj;
44-
45-
this.stopTimer = false
46-
4742
}
4843

4944
/***
@@ -128,65 +123,30 @@ ironsugar.prototype._callREST = function (method,data,callback) {
128123
*
129124
*/
130125
ironsugar.prototype.postlogin = function(callback,response) {
126+
127+
// Set default response
128+
responsetxt = response.text;
129+
131130
try {
132-
var j = eval("(" + response.text + ")");
133-
134-
if (!j.id) this.sessid = false;
135-
else {
136-
this.sessid = j.id;
137-
this.uid = j['name_value_list']['user_id']['value'];
138-
}
139-
this.initTimer();
140-
}catch(e){}
131+
var j = eval("(" + response.text + ")");
141132

142-
if (callback !== undefined )
143-
callback.call(this.parent);
144-
}
145-
146-
/***
147-
* ironsugar.prototype.initTimer
148-
*
149-
* This function inits the timer that will be used
150-
* for keeping alive SugarCRM session.
151-
*
152-
*/
153-
ironsugar.prototype.initTimer = function() {
154-
155-
// Check every minute session is still alive...
156-
var o = this;
157-
window.setTimeout(function() {
158-
o.getUserId.call(o);
159-
},60000);
160-
}
133+
if (!j.id) {
134+
this.sessid = false;
135+
} else {
136+
this.sessid = j.id;
137+
this.uid = j['name_value_list']['user_id']['value'];
138+
}
161139

162-
/***
163-
* ironsugar.prototype.keepalive
164-
*
165-
* Callback function of internal timer that sends a
166-
* login method to avoid SugarCRM session expire.
167-
*
168-
* @param response Response JSON data from SugarCRM
169-
*
170-
*/
171-
ironsugar.prototype.keepalive = function(response) {
172-
try{
173-
var id = eval(response.text);
174-
this.parent._checkAtt();
175-
}catch(e){}
176-
177-
if (id != this.uid) {
178-
this.sessid = false;
179-
this.parent._checkAuth();
180-
return;
181-
}
182-
if (this.stopTimer) {
183-
this.stopTimer = false;
184-
this.parent._login();
185-
return;
186-
}
140+
// This response comes from SugarCRM
141+
if (j.name)
142+
responsetxt = j.name;
187143

188-
this.initTimer();
144+
}catch(e) {
189145

146+
}
147+
148+
// Provide responsetext to callback
149+
callback.run(responsetxt);
190150
}
191151

192152
/***
@@ -199,7 +159,6 @@ ironsugar.prototype.keepalive = function(response) {
199159
*/
200160
ironsugar.prototype.login = function(callback) {
201161
this._callREST("login",'[{"password":"'+this.pass+'","user_name":"'+this.user+'"},"'+this.application+'",[]]',this.postlogin, callback);
202-
return;
203162
};
204163

205164
/***
@@ -214,9 +173,10 @@ ironsugar.prototype.login = function(callback) {
214173
ironsugar.prototype.postOp = function(callback, response) {
215174
try{
216175
var j = eval("("+response.text + ")");
217-
}catch(e){}
218-
if (callback !== undefined )
219-
callback.call(this.parent,j);
176+
}catch(e) {}
177+
178+
if (callback !== undefined )
179+
callback.call(this.parent,j);
220180
};
221181

222182
/***
@@ -277,18 +237,6 @@ ironsugar.prototype.postRelations = function(contactID, contactModule, relCnt, c
277237
callback.call(this.parent,contactID,contactModule, relCnt, j);
278238
};
279239

280-
/***
281-
* ironsugar.prototype.getUserId
282-
*
283-
* This function sends a get_user_id request to Sugarcrm
284-
*
285-
* @params Callback Function
286-
*
287-
*/
288-
ironsugar.prototype.getUserId = function() {
289-
this._callREST("get_user_id",'["'+this.sessid+'"]',this.keepalive);
290-
};
291-
292240
/***
293241
* ironsugar.prototype.saveEmail
294242
*

0 commit comments

Comments
 (0)