add pgsql
authorAlan Knowles <alan@roojs.com>
Sat, 2 Feb 2013 08:17:51 +0000 (16:17 +0800)
committerAlan Knowles <alan@roojs.com>
Sat, 2 Feb 2013 08:17:51 +0000 (16:17 +0800)
Pman.Login.js
pgsql/core_enum_functions.sql [new file with mode: 0644]
pgsql/i18n_function.sql [new file with mode: 0644]

index 3fd9e94..982f157 100644 (file)
@@ -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 (file)
index 0000000..9826de3
--- /dev/null
@@ -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 (file)
index 0000000..e075fb0
--- /dev/null
@@ -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