Commit 3dfb1af6 authored by Frank Bergmann's avatar Frank Bergmann

- Helpdesk Ticket Stats:

  - Now with persistent state
  - Moved currentUserId() function from PreferenceStateProvider to Utilities
parent 97829317
......@@ -14,6 +14,30 @@ Ext.define('PO.Utilities', {
debug: false,
statics: {
/**
* Extract the current userId from the OpenACS session cookie
*/
currentUserId : function(){
var me = this;
var userId = 0; // user_id=0 represents "anonymous visitor"
var c = document.cookie + ";";
var re = /\s?(.*?)=(.*?);/g;
var prefix = 'ad_';
var prefixLen = prefix.length;
while((matches = re.exec(c)) != null){
var key = matches[1];
var valueUndecoded = matches[2];
if (key == 'ad_user_login') {
var userIdString = valueUndecoded.substr(0, valueUndecoded.indexOf('%'));
userId = parseInt(userIdString);
}
}
return userId;
},
/**
* Convert a date to PostgreSQL "time stamp with timezone" string
*/
......
......@@ -16,6 +16,7 @@
Ext.define('PO.class.PreferenceStateProvider', {
extend: 'Ext.state.Provider',
requires: [
'PO.Utilities',
'PO.model.user.SenchaPreference',
'PO.store.user.SenchaPreferenceStore'
],
......@@ -26,12 +27,11 @@ Ext.define('PO.class.PreferenceStateProvider', {
*/
constructor : function(config){
var me = this;
me.currentUserId = me.currentUserId();
me.currentUserId = PO.Utilities.currentUserId();
me.currentUrl = config.url;
if (typeof me.currentUrl == "undefined" || me.currentUrl === null) {
me.currenturl = window.location.pathname;
}
me.prefix = 'ad_';
me.callParent(arguments);
me.state = me.readPreferences();
},
......@@ -51,29 +51,6 @@ Ext.define('PO.class.PreferenceStateProvider', {
this.callParent(arguments);
},
/**
* Extract the current userId from the OpenACS session cookie
*/
currentUserId : function(){
var me = this;
var userId = 0; // user_id=0 represents "anonymous visitor"
var c = document.cookie + ";";
var re = /\s?(.*?)=(.*?);/g;
var prefix = me.prefix;
var prefixLen = prefix.length;
while((matches = re.exec(c)) != null){
var key = matches[1];
var valueUndecoded = matches[2];
if (key == 'ad_user_login') {
var userIdString = valueUndecoded.substr(0, valueUndecoded.indexOf('%'));
userId = parseInt(userIdString);
}
}
return userId;
},
/**
* Retreive all available preferences for this user and this URL from the server
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment