[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SF.net SVN: ledger-smb:[4332] trunk/sql/modules



Revision: 4332
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=4332&view=rev
Author:   einhverfr
Date:     2012-02-18 11:26:58 +0000 (Sat, 18 Feb 2012)
Log Message:
-----------
Correcting breakage when we reload database due to old fixes

Modified Paths:
--------------
    trunk/sql/modules/Fixes.sql
    trunk/sql/modules/Roles.sql

Modified: trunk/sql/modules/Fixes.sql
===================================================================
--- trunk/sql/modules/Fixes.sql	2012-02-18 10:58:38 UTC (rev 4331)
+++ trunk/sql/modules/Fixes.sql	2012-02-18 11:26:58 UTC (rev 4332)
@@ -89,152 +89,3 @@
        AND node_id = (SELECT id FROM menu_node WHERE label = 'Ship');
 COMMIT;
 
-BEGIN;
--- fix for non-existant role handling in menu_generate() and related
-
-
-CREATE OR REPLACE FUNCTION menu_generate() RETURNS SETOF menu_item AS 
-$$
-DECLARE 
-	item menu_item;
-	arg menu_attribute%ROWTYPE;
-BEGIN
-	FOR item IN 
-		SELECT n.position, n.id, c.level, n.label, c.path, 
-                       to_args(array[ma.attribute, ma.value])
-		FROM connectby('menu_node', 'id', 'parent', 'position', '0', 
-				0, ',') 
-			c(id integer, parent integer, "level" integer, 
-				path text, list_order integer)
-		JOIN menu_node n USING(id)
-                JOIN menu_attribute ma ON (n.id = ma.node_id)
-               WHERE n.id IN (select node_id 
-                                FROM menu_acl
-                                JOIN (select rolname FROM pg_roles
-                                      UNION 
-                                     select 'public') pgr 
-                                     ON pgr.rolname = role_name
-                               WHERE pg_has_role(CASE WHEN coalesce(pgr.rolname,
-                                                                    'public') 
-                                                                    = 'public'
-                                                      THEN current_user
-                                                      ELSE pgr.rolname
-                                                   END, 'USAGE')
-                            GROUP BY node_id
-                              HAVING bool_and(CASE WHEN acl_type ilike 'DENY'
-                                                   THEN FALSE
-                                                   WHEN acl_type ilike 'ALLOW'
-                                                   THEN TRUE
-                                                END))
-                    or exists (select cn.id, cc.path
-                                 FROM connectby('menu_node', 'id', 'parent', 
-                                                'position', '0', 0, ',')
-                                      cc(id integer, parent integer, 
-                                         "level" integer, path text,
-                                         list_order integer)
-                                 JOIN menu_node cn USING(id)
-                                WHERE cn.id IN 
-                                      (select node_id FROM menu_acl
-                                        JOIN (select rolname FROM pg_roles
-                                              UNION 
-                                              select 'public') pgr 
-                                              ON pgr.rolname = role_name
-                                        WHERE pg_has_role(CASE WHEN coalesce(pgr.rolname,
-                                                                    'public') 
-                                                                    = 'public'
-                                                      THEN current_user
-                                                      ELSE pgr.rolname
-                                                   END, 'USAGE')
-                                     GROUP BY node_id
-                                       HAVING bool_and(CASE WHEN acl_type 
-                                                                 ilike 'DENY'
-                                                            THEN false
-                                                            WHEN acl_type 
-                                                                 ilike 'ALLOW'
-                                                            THEN TRUE
-                                                         END))
-                                       and cc.path like c.path || ',%')
-            GROUP BY n.position, n.id, c.level, n.label, c.path, c.list_order
-            ORDER BY c.list_order
-                             
-	LOOP
-		RETURN NEXT item;
-	END LOOP;
-END;
-$$ language plpgsql;
-
-COMMENT ON FUNCTION menu_generate() IS
-$$
-This function returns the complete menu tree.  It is used to generate nested
-menus for the web interface.
-$$;
-
-CREATE OR REPLACE FUNCTION menu_children(in_parent_id int) RETURNS SETOF menu_item
-AS $$
-declare 
-	item menu_item;
-	arg menu_attribute%ROWTYPE;
-begin
-        FOR item IN
-		SELECT n.position, n.id, c.level, n.label, c.path, 
-                       to_args(array[ma.attribute, ma.value])
-		FROM connectby('menu_node', 'id', 'parent', 'position', 
-				in_parent_id, 1, ',') 
-			c(id integer, parent integer, "level" integer, 
-				path text, list_order integer)
-		JOIN menu_node n USING(id)
-                JOIN menu_attribute ma ON (n.id = ma.node_id)
-               WHERE n.id IN (select node_id 
-                                FROM menu_acl
-                                JOIN (select rolname FROM pg_roles
-                                      UNION 
-                                      select 'public') pgr 
-                                      ON pgr.rolname = role_name
-                                WHERE pg_has_role(CASE WHEN coalesce(pgr.rolname,
-                                                                    'public') 
-                                                                    = 'public'
-                                                               THEN current_user
-                                                               ELSE pgr.rolname
-                                                               END, 'USAGE')
-                            GROUP BY node_id
-                              HAVING bool_and(CASE WHEN acl_type ilike 'DENY'
-                                                   THEN FALSE
-                                                   WHEN acl_type ilike 'ALLOW'
-                                                   THEN TRUE
-                                                END))
-                    or exists (select cn.id, cc.path
-                                 FROM connectby('menu_node', 'id', 'parent', 
-                                                'position', '0', 0, ',')
-                                      cc(id integer, parent integer, 
-                                         "level" integer, path text,
-                                         list_order integer)
-                                 JOIN menu_node cn USING(id)
-                                WHERE cn.id IN 
-                                      (select node_id FROM menu_acl
-                                         JOIN (select rolname FROM pg_roles
-                                              UNION 
-                                              select 'public') pgr 
-                                              ON pgr.rolname = role_name
-                                        WHERE pg_has_role(CASE WHEN coalesce(pgr.rolname,
-                                                                    'public') 
-                                                                    = 'public'
-                                                               THEN current_user
-                                                               ELSE pgr.rolname
-                                                               END, 'USAGE')
-                                     GROUP BY node_id
-                                       HAVING bool_and(CASE WHEN acl_type 
-                                                                 ilike 'DENY'
-                                                            THEN false
-                                                            WHEN acl_type 
-                                                                 ilike 'ALLOW'
-                                                            THEN TRUE
-                                                         END))
-                                       and cc.path like c.path || ',%')
-            GROUP BY n.position, n.id, c.level, n.label, c.path, c.list_order
-            ORDER BY c.list_order
-        LOOP
-                return next item;
-        end loop;
-end;
-$$ language plpgsql;
-COMMIT;

Modified: trunk/sql/modules/Roles.sql
===================================================================
--- trunk/sql/modules/Roles.sql	2012-02-18 10:58:38 UTC (rev 4331)
+++ trunk/sql/modules/Roles.sql	2012-02-18 11:26:58 UTC (rev 4332)
@@ -1,5 +1,13 @@
 GRANT ALL ON SCHEMA public TO public; -- required for Pg 8.2
 
+CRATE ROLE "lsmb_<?lsmb dbname ?>__business_units_manage"
+WITH INHERIT NOLOGIN;
+
+GRANT INSERT, UPDATE, DELETE ON business_unit_class, business_unit
+TO "lsmb_<?lsmb dbname ?>__business_units_manage";
+
+GRANT SELECT ON business_unit_class, business_unit TO PUBLIC;
+
 -- Exchange rate creation (required insert and update on 'exchangerate' table)
 
 CREATE ROLE "lsmb_<?lsmb dbname ?>__exchangerate_edit"

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.