Kaynağa Gözat

sql script

tags/0.1.3
Robin Thoni 8 yıl önce
ebeveyn
işleme
d27b14412a
2 değiştirilmiş dosya ile 149 ekleme ve 0 silme
  1. 56
    0
      sql/data_0_1_3.sql
  2. 93
    0
      sql/struct_0_1_3.sql

+ 56
- 0
sql/data_0_1_3.sql Dosyayı Görüntüle

@@ -0,0 +1,56 @@
1
+--
2
+-- Data for Name: luticate_settings; Type: TABLE DATA; Schema: public; Owner: dev
3
+--
4
+
5
+INSERT INTO luticate_settings VALUES ('LU_SESSION_DAYS', 'int', '30', true, true);
6
+INSERT INTO luticate_settings VALUES ('LU_USERS_PER_PAGE', 'int', '15', false, false);
7
+INSERT INTO luticate_settings VALUES ('LU_GROUPS_PER_PAGE', 'int', '15', false, false);
8
+INSERT INTO luticate_settings VALUES ('LU_SETTINGS_PER_PAGE', 'int', '15', false, false);
9
+INSERT INTO luticate_settings VALUES ('LU_PERMISSIONS_PER_PAGE', 'int', '15', false, false);
10
+
11
+--
12
+-- Data for Name: luticate_permissions; Type: TABLE DATA; Schema: public; Owner: dev
13
+--
14
+
15
+INSERT INTO luticate_permissions VALUES ('LU_SETTING_DEL', false);
16
+INSERT INTO luticate_permissions VALUES ('LU_SETTING_EDIT', false);
17
+INSERT INTO luticate_permissions VALUES ('LU_SETTING_EFFECTIVE_GET', false);
18
+INSERT INTO luticate_permissions VALUES ('LU_SETTING_GET', false);
19
+INSERT INTO luticate_permissions VALUES ('LU_SETTING_USER_EDIT', false);
20
+INSERT INTO luticate_permissions VALUES ('LU_SETTING_USER_GET', false);
21
+INSERT INTO luticate_permissions VALUES ('LU_SETTING_EDIT_ME', false);
22
+INSERT INTO luticate_permissions VALUES ('LU_SETTING_ADD', false);
23
+
24
+--
25
+-- Data for Name: luticate_permissions_groups; Type: TABLE DATA; Schema: public; Owner: dev
26
+--
27
+
28
+INSERT INTO luticate_permissions_groups VALUES ('LU_SETTING_ADD', false, 1);
29
+INSERT INTO luticate_permissions_groups VALUES ('LU_SETTING_DEL', false, 1);
30
+INSERT INTO luticate_permissions_groups VALUES ('LU_SETTING_EDIT', true, 1);
31
+INSERT INTO luticate_permissions_groups VALUES ('LU_SETTING_EFFECTIVE_GET', true, 1);
32
+INSERT INTO luticate_permissions_groups VALUES ('LU_SETTING_GET', true, 1);
33
+INSERT INTO luticate_permissions_groups VALUES ('LU_SETTING_USER_EDIT', true, 1);
34
+INSERT INTO luticate_permissions_groups VALUES ('LU_SETTING_USER_GET', true, 1);
35
+INSERT INTO luticate_permissions_groups VALUES ('LU_SETTING_ADD', true, 0);
36
+INSERT INTO luticate_permissions_groups VALUES ('LU_SETTING_DEL', true, 0);
37
+INSERT INTO luticate_permissions_groups VALUES ('LU_SETTING_EDIT', true, 0);
38
+INSERT INTO luticate_permissions_groups VALUES ('LU_SETTING_EFFECTIVE_GET', true, 0);
39
+INSERT INTO luticate_permissions_groups VALUES ('LU_SETTING_GET', true, 0);
40
+INSERT INTO luticate_permissions_groups VALUES ('LU_SETTING_USER_EDIT', true, 0);
41
+INSERT INTO luticate_permissions_groups VALUES ('LU_SETTING_USER_GET', true, 0);
42
+INSERT INTO luticate_permissions_groups VALUES ('LU_SETTING_EDIT_ME', true, 1);
43
+INSERT INTO luticate_permissions_groups VALUES ('LU_SETTING_EDIT_ME', true, 0);
44
+
45
+--
46
+-- Data for Name: luticate_permissions_users; Type: TABLE DATA; Schema: public; Owner: dev
47
+--
48
+
49
+INSERT INTO luticate_permissions_users VALUES ('LU_SETTING_USER_GET', true, 0);
50
+INSERT INTO luticate_permissions_users VALUES ('LU_SETTING_ADD', false, 0);
51
+INSERT INTO luticate_permissions_users VALUES ('LU_SETTING_EDIT', false, 0);
52
+INSERT INTO luticate_permissions_users VALUES ('LU_SETTING_EFFECTIVE_GET', false, 0);
53
+INSERT INTO luticate_permissions_users VALUES ('LU_SETTING_DEL', false, 0);
54
+INSERT INTO luticate_permissions_users VALUES ('LU_SETTING_EDIT_ME', false, 0);
55
+INSERT INTO luticate_permissions_users VALUES ('LU_SETTING_GET', false, 0);
56
+INSERT INTO luticate_permissions_users VALUES ('LU_SETTING_USER_EDIT', false, 0);

+ 93
- 0
sql/struct_0_1_3.sql Dosyayı Görüntüle

@@ -0,0 +1,93 @@
1
+--
2
+-- Name: luticate_settings; Type: TABLE; Schema: public; Owner: dev; Tablespace:
3
+--
4
+
5
+CREATE TABLE luticate_settings (
6
+    name character varying(128) NOT NULL,
7
+    type character varying(128) NOT NULL,
8
+    value text NOT NULL,
9
+    is_blocked boolean NOT NULL,
10
+    is_admin boolean NOT NULL
11
+);
12
+
13
+
14
+--
15
+-- Name: luticate_settings_users; Type: TABLE; Schema: public; Owner: dev; Tablespace:
16
+--
17
+
18
+CREATE TABLE luticate_settings_users (
19
+    name character varying(128) NOT NULL,
20
+    value text NOT NULL,
21
+    user_id integer NOT NULL,
22
+    is_blocked boolean NOT NULL
23
+);
24
+
25
+--
26
+-- Name: luticate_settings_pkey; Type: CONSTRAINT; Schema: public; Owner: dev; Tablespace:
27
+--
28
+
29
+ALTER TABLE ONLY luticate_settings
30
+    ADD CONSTRAINT luticate_settings_pkey PRIMARY KEY (name);
31
+
32
+
33
+--
34
+-- Name: luticate_settings_users_pkey; Type: CONSTRAINT; Schema: public; Owner: dev; Tablespace:
35
+--
36
+
37
+ALTER TABLE ONLY luticate_settings_users
38
+    ADD CONSTRAINT luticate_settings_users_pkey PRIMARY KEY (name, user_id);
39
+
40
+--
41
+-- Name: luticate_settings_users_name_fkey; Type: FK CONSTRAINT; Schema: public; Owner: dev
42
+--
43
+
44
+ALTER TABLE ONLY luticate_settings_users
45
+    ADD CONSTRAINT luticate_settings_users_name_fkey FOREIGN KEY (name) REFERENCES luticate_settings(name) ON DELETE CASCADE;
46
+
47
+
48
+--
49
+-- Name: luticate_settings_users_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: dev
50
+--
51
+
52
+ALTER TABLE ONLY luticate_settings_users
53
+    ADD CONSTRAINT luticate_settings_users_user_id_fkey FOREIGN KEY (user_id) REFERENCES luticate_users(id) ON DELETE CASCADE;
54
+
55
+--
56
+-- Name: sp_lu_get_user_setting(integer, character varying); Type: FUNCTION; Schema: public; Owner: dev
57
+--
58
+
59
+CREATE FUNCTION sp_lu_get_user_setting(_user_id integer, _setting_name character varying, OUT setting json) RETURNS json
60
+    LANGUAGE plpgsql IMMUTABLE SECURITY DEFINER COST 10
61
+    AS $$
62
+DECLARE
63
+_setting luticate_settings;
64
+_setting_user luticate_settings_users;
65
+BEGIN
66
+    SELECT * INTO _setting FROM luticate_settings WHERE "name" = _setting_name AND NOT "is_admin";
67
+    IF _setting IS NULL THEN
68
+        setting := NULL;
69
+    ELSE
70
+        IF NOT _setting.is_blocked THEN
71
+            SELECT * INTO _setting_user FROM luticate_settings_users WHERE "user_id" = _user_id AND "name" = _setting_name;
72
+            IF _setting_user IS NOT NULL THEN
73
+                _setting.value := _setting_user.value;
74
+            END IF;
75
+        END IF;
76
+        setting := to_json(_setting);
77
+    END IF;
78
+END;
79
+$$;
80
+
81
+
82
+--
83
+-- Name: sp_lu_get_all_user_settings(integer); Type: FUNCTION; Schema: public; Owner: dev
84
+--
85
+
86
+CREATE FUNCTION sp_lu_get_all_user_settings(_user_id integer, OUT _settings json) RETURNS SETOF json
87
+    LANGUAGE sql IMMUTABLE SECURITY DEFINER COST 10
88
+    AS $$
89
+	SELECT sp_lu_get_user_setting(_user_id, s.name)
90
+	FROM luticate_settings s
91
+	WHERE NOT s.is_admin
92
+	ORDER BY s.name
93
+$$;

Loading…
İptal
Kaydet