From e397c54a2ac7c5daa67f6403633e1142553dbdd9 Mon Sep 17 00:00:00 2001 From: Alan Knowles Date: Sat, 2 Feb 2013 16:17:51 +0800 Subject: [PATCH] add pgsql --- Pman.Login.js | 8 ++- pgsql/core_enum_functions.sql | 105 ++++++++++++++++++++++++++++++++++ pgsql/i18n_function.sql | 39 +++++++++++++ 3 files changed, 150 insertions(+), 2 deletions(-) create mode 100644 pgsql/core_enum_functions.sql create mode 100644 pgsql/i18n_function.sql diff --git a/Pman.Login.js b/Pman.Login.js index 3fd9e94c..982f1577 100644 --- a/Pman.Login.js +++ b/Pman.Login.js @@ -36,6 +36,8 @@ Pman.Login = new Roo.util.Observable({ versionWarn: false, sending : false, + checkConnection : false, // the Roo.data.Connection for checking if still authenticated. + onLoad : function() // called on page load... { // load @@ -105,8 +107,10 @@ Pman.Login = new Roo.util.Observable({ return; } this.sending = true; - var c = new Roo.data.Connection(); - c.request({ + if (!this.checkConnection) { + this.checkConnection = new Roo.data.Connection(); + } + this.checkConnection.request({ url: baseURL + '/Login.js', params: { getAuthUser: true diff --git a/pgsql/core_enum_functions.sql b/pgsql/core_enum_functions.sql new file mode 100644 index 00000000..9826de37 --- /dev/null +++ b/pgsql/core_enum_functions.sql @@ -0,0 +1,105 @@ + + +-- also update the pgsql version of these!? + + +CREATE OR REPLACE FUNCTION core_enum_display_name(integer) + RETURNS text AS +$BODY$ + +DECLARE + in_id ALIAS FOR $1; + + ret TEXT; + +BEGIN + + SELECT display_name INTO ret FROM core_enum + WHERE id=in_id LIMIT 1; + + RETURN ret; + +END; +$BODY$ + LANGUAGE plpgsql VOLATILE + COST 100; + +ALTER FUNCTION core_enum_display_name(integer) + OWNER TO admin; + + + + + + +CREATE OR REPLACE FUNCTION core_enum_name(integer) + RETURNS text AS +$BODY$ +DECLARE + in_id ALIAS FOR $1; + ret TEXT; +BEGIN + + SELECT name INTO ret FROM core_enum + WHERE id=in_id LIMIT 1; + RETURN ret; + +END; +$BODY$ + LANGUAGE plpgsql VOLATILE + COST 100; +ALTER FUNCTION core_enum_name(integer) + OWNER TO admin; + + + + + + +CREATE OR REPLACE FUNCTION core_enum_name_to_display_name(text,text) + RETURNS text AS +$BODY$ +DECLARE + in_etype ALIAS FOR $1; + in_name ALIAS FOR $2; + ret TEXT; +BEGIN + + SELECT display_name INTO ret FROM core_enum + WHERE name=in_name AND etype=in_etype LIMIT 1; + RETURN ret; + +END; +$BODY$ + LANGUAGE plpgsql VOLATILE + COST 100; +ALTER FUNCTION core_enum_name_to_display_name(text,text) + OWNER TO admin; + + + + + +CREATE OR REPLACE FUNCTION core_enum_id_by_name(text,text) + RETURNS INTEGER AS +$BODY$ +DECLARE + in_etype ALIAS FOR $1; + in_name ALIAS FOR $2; + ret INTEGER; +BEGIN + + SELECT id INTO ret FROM core_enum + WHERE name=in_name AND etype=in_etype LIMIT 1; + RETURN ret; + +END; +$BODY$ + LANGUAGE plpgsql VOLATILE + COST 100; +ALTER FUNCTION core_enum_id_by_name(text,text) + OWNER TO admin; + + + + \ No newline at end of file diff --git a/pgsql/i18n_function.sql b/pgsql/i18n_function.sql new file mode 100644 index 00000000..e075fb04 --- /dev/null +++ b/pgsql/i18n_function.sql @@ -0,0 +1,39 @@ + + + + + +CREATE OR REPLACE FUNCTION i18n_translate(text,text,text) + RETURNS text AS +$BODY$ +-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. +-- See www.xtuple.com/CPAL for the full text of the software license. +DECLARE + in_ltype ALIAS FOR $1; + in_lkey ALIAS FOR $2; + in_inlang ALIAS FOR $3; + + ret TEXT; + +BEGIN + + ret := ''; + SELECT lval INTO ret FROM i18n + WHERE ltype=in_ltype AND lkey=in_lkey and inlang=in_inlang LIMIT 1; + RETURN ret; + + + RETURN ret; + +END; +$BODY$ + LANGUAGE plpgsql VOLATILE + COST 100; + +ALTER FUNCTION i18n_translate(text,text,text) + OWNER TO admin; + + + + + \ No newline at end of file -- 2.39.2