Parcourir la source

fixed sql

tags/0.1.0
Robin Thoni il y a 9 ans
Parent
révision
81e74fc286
2 fichiers modifiés avec 40 ajouts et 40 suppressions
  1. 1
    1
      sql/data_init.sql
  2. 39
    39
      sql/struct_init.sql

+ 1
- 1
sql/data_init.sql Voir le fichier

@@ -114,7 +114,7 @@ INSERT INTO luticate_permissions_groups VALUES ('LU_PERM_DEL', false, 1);
114 114
 --
115 115
 
116 116
 INSERT INTO luticate_users VALUES (0, 'anonymous', 'anonymous@example.com', '', '', NULL, 'anonymous', 'anonymous');
117
-INSERT INTO luticate_users VALUES (1, 'root', 'root@me.com', '$2y$10$m1aN1a1ZEr1vmjFPfWl4Pu/63EhcxVCrC/DF0DFhdGbvORwtJtCmy', '3vwW1qQ28I', NULL, 'root', 'root');
117
+INSERT INTO luticate_users VALUES (1, 'root', 'root@example.com', '$2y$10$m1aN1a1ZEr1vmjFPfWl4Pu/63EhcxVCrC/DF0DFhdGbvORwtJtCmy', '3vwW1qQ28I', NULL, 'root', 'root');
118 118
 
119 119
 
120 120
 --

+ 39
- 39
sql/struct_init.sql Voir le fichier

@@ -1,47 +1,6 @@
1 1
 --
2 2
 -- PostgreSQL database dump
3 3
 --
4
---
5
---
6
-
7
-CREATE FUNCTION sp_lu_get_all_user_permission(_user_id integer, OUT _permisson_name character varying, OUT val boolean) RETURNS SETOF record
8
-LANGUAGE sql IMMUTABLE SECURITY DEFINER COST 10
9
-AS $$
10
-SELECT p.name, sp_lu_get_user_permission(_user_id, p.name) FROM luticate_permissions p ORDER bY p.name
11
-$$;
12
-
13
-
14
-
15
---
16
---
17
-
18
-CREATE FUNCTION sp_lu_get_user_permission(_user_id integer, _permisson_name character varying, OUT val boolean) RETURNS boolean
19
-LANGUAGE plpgsql IMMUTABLE SECURITY DEFINER COST 10
20
-AS $$
21
-DECLARE
22
-groups int[];
23
-g INT;
24
-BEGIN
25
-    SELECT "value" INTO val FROM luticate_permissions_users WHERE "user_id" = _user_id AND "name" = _permisson_name;
26
-    IF val is null THEN
27
-        SELECT lpg."value" into val FROM luticate_permissions_groups lpg
28
-            INNER JOIN luticate_groups lg ON lg."id" = lpg."group_id"
29
-            INNER JOIN luticate_users_groups lug ON lug."user_id" = _user_id AND lug."group_id" = lg."id"
30
-        WHERE lpg."name" = _permisson_name and lpg."value" = FALSE;
31
-        IF val is null then
32
-            SELECT lpg."value" into val FROM luticate_permissions_groups lpg
33
-                INNER JOIN luticate_groups lg ON lg."id" = lpg."group_id"
34
-                INNER JOIN luticate_users_groups lug ON lug."user_id" = _user_id AND lug."group_id" = lg."id"
35
-            WHERE lpg."name" = _permisson_name and lpg."value" = TRUE;
36
-            IF val is null then
37
-                SELECT "value" INTO val FROM luticate_permissions WHERE "name" = _permisson_name;
38
-            END IF;
39
-        end if;
40
-    END IF;
41
-END;
42
-$$;
43 4
 
44 5
 --
45 6
 -- Name: luticate_groups_id_seq; Type: SEQUENCE; Schema: public; Owner: dev
@@ -263,6 +222,45 @@ ADD CONSTRAINT foreign_user FOREIGN KEY (user_id) REFERENCES luticate_users(id)
263 222
 ALTER TABLE ONLY luticate_users_groups
264 223
 ADD CONSTRAINT foreign_user FOREIGN KEY (user_id) REFERENCES luticate_users(id) ON DELETE CASCADE;
265 224
 
225
+--
226
+-- Name: sp_lu_get_user_permission(integer, character varying); Type: FUNCTION; Schema: public; Owner: dev
227
+--
228
+
229
+CREATE FUNCTION sp_lu_get_user_permission(_user_id integer, _permisson_name character varying, OUT val boolean) RETURNS boolean
230
+LANGUAGE plpgsql IMMUTABLE SECURITY DEFINER COST 10
231
+AS $$
232
+DECLARE
233
+    groups int[];
234
+    g INT;
235
+BEGIN
236
+    SELECT "value" INTO val FROM luticate_permissions_users WHERE "user_id" = _user_id AND "name" = _permisson_name;
237
+    IF val is null THEN
238
+        SELECT lpg."value" into val FROM luticate_permissions_groups lpg
239
+            INNER JOIN luticate_groups lg ON lg."id" = lpg."group_id"
240
+            INNER JOIN luticate_users_groups lug ON lug."user_id" = _user_id AND lug."group_id" = lg."id"
241
+        WHERE lpg."name" = _permisson_name and lpg."value" = FALSE;
242
+        IF val is null then
243
+            SELECT lpg."value" into val FROM luticate_permissions_groups lpg
244
+                INNER JOIN luticate_groups lg ON lg."id" = lpg."group_id"
245
+                INNER JOIN luticate_users_groups lug ON lug."user_id" = _user_id AND lug."group_id" = lg."id"
246
+            WHERE lpg."name" = _permisson_name and lpg."value" = TRUE;
247
+            IF val is null then
248
+                SELECT "value" INTO val FROM luticate_permissions WHERE "name" = _permisson_name;
249
+            END IF;
250
+        end if;
251
+    END IF;
252
+END;
253
+$$;
254
+
255
+--
256
+-- Name: sp_lu_get_all_user_permission(integer); Type: FUNCTION; Schema: public; Owner: dev
257
+--
258
+
259
+CREATE FUNCTION sp_lu_get_all_user_permission(_user_id integer, OUT _permisson_name character varying, OUT val boolean) RETURNS SETOF record
260
+LANGUAGE sql IMMUTABLE SECURITY DEFINER COST 10
261
+AS $$
262
+SELECT p.name, sp_lu_get_user_permission(_user_id, p.name) FROM luticate_permissions p ORDER bY p.name
263
+$$;
266 264
 
267 265
 --
268 266
 -- PostgreSQL database dump complete

Chargement…
Annuler
Enregistrer