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

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



Revision: 4296
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=4296&view=rev
Author:   einhverfr
Date:     2012-02-09 08:53:35 +0000 (Thu, 09 Feb 2012)
Log Message:
-----------
Fixes for menu and non-existent roles

Modified Paths:
--------------
    trunk/sql/modules/Menu.sql

Modified: trunk/sql/modules/Menu.sql
===================================================================
--- trunk/sql/modules/Menu.sql	2012-02-08 17:48:06 UTC (rev 4295)
+++ trunk/sql/modules/Menu.sql	2012-02-09 08:53:35 UTC (rev 4296)
@@ -1,4 +1,4 @@
-
+DROP TYPE IF EXISTS menu_item CASCADE;
 CREATE TYPE menu_item AS (
    position int,
    id int,
@@ -34,12 +34,17 @@
 		FROM tree c
 		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
-                               WHERE pg_has_role(CASE WHEN role_name 
+               WHERE n.id IN (select node_id 
+                                FROM menu_acl acl
+                                JOIN pg_roles pr on pr.rolname = acl.role_name
+                               WHERE CASE WHEN rolname 
                                                            ilike 'public'
-                                                      THEN current_user
-                                                      ELSE role_name
-                                                   END, 'USAGE')
+                                                      THEN true
+                                                      WHEN rolname IS NULL
+                                                      THEN FALSE
+                                                      ELSE pg_has_role(rolname,
+                                                                       'USAGE')
+                                      END
                             GROUP BY node_id
                               HAVING bool_and(CASE WHEN acl_type ilike 'DENY'
                                                    THEN FALSE
@@ -50,12 +55,18 @@
                                  FROM tree cc
                                  JOIN menu_node cn USING(id)
                                 WHERE cn.id IN 
-                                      (select node_id FROM menu_acl
-                                        WHERE pg_has_role(CASE WHEN role_name 
+                                      (select node_id 
+                                         FROM menu_acl acl
+                                         JOIN pg_roles pr 
+                                              on pr.rolname = acl.role_name
+                                        WHERE CASE WHEN rolname 
                                                            ilike 'public'
-                                                      THEN current_user
-                                                      ELSE role_name
-                                                   END, 'USAGE')
+                                                      THEN true
+                                                      WHEN rolname IS NULL
+                                                      THEN FALSE
+                                                      ELSE pg_has_role(rolname,
+                                                                       'USAGE')
+                                                END
                                      GROUP BY node_id
                                        HAVING bool_and(CASE WHEN acl_type 
                                                                  ilike 'DENY'

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