1 | <?php |
---|
2 | |
---|
3 | function plugin_install() |
---|
4 | { |
---|
5 | global $conf; |
---|
6 | |
---|
7 | ////////////créer groupe//////////// |
---|
8 | $query = ' |
---|
9 | INSERT INTO '.GROUPS_TABLE.' |
---|
10 | (name) |
---|
11 | VALUES |
---|
12 | (\'+18\') |
---|
13 | ;'; |
---|
14 | pwg_query($query); |
---|
15 | $query = ' |
---|
16 | INSERT INTO '.GROUPS_TABLE.' |
---|
17 | (name) |
---|
18 | VALUES |
---|
19 | (\'16-17\') |
---|
20 | ;'; |
---|
21 | pwg_query($query); |
---|
22 | $query = ' |
---|
23 | INSERT INTO '.GROUPS_TABLE.' |
---|
24 | (name) |
---|
25 | VALUES |
---|
26 | (\'nothing\') |
---|
27 | ;'; |
---|
28 | pwg_query($query); |
---|
29 | ////////////créer user//////////// |
---|
30 | include_once(PHPWG_ROOT_PATH.'include/functions_user.inc.php'); |
---|
31 | register_user('18', 'adult_content', ''); |
---|
32 | register_user('16', 'adult_content', ''); |
---|
33 | |
---|
34 | ////////////placer dans group 16//////////// |
---|
35 | $result = pwg_query('SELECT id FROM '.GROUPS_TABLE.' WHERE name IN (\'16-17\') ;'); |
---|
36 | $data_group = mysql_fetch_array($result); |
---|
37 | pwg_query('INSERT INTO '.USER_GROUP_TABLE.' VALUES(\''.get_userid('16').'\', \''.$data_group['id'].'\' )' ); |
---|
38 | |
---|
39 | ////////////placer dans group 18//////////// |
---|
40 | $result = pwg_query('SELECT id FROM '.GROUPS_TABLE.' WHERE name IN (\'+18\') ;'); |
---|
41 | $data_group = mysql_fetch_array($result); |
---|
42 | pwg_query('INSERT INTO '.USER_GROUP_TABLE.' VALUES(\''.get_userid('18').'\', \''.$data_group['id'].'\' )' ); |
---|
43 | |
---|
44 | } |
---|
45 | |
---|
46 | |
---|
47 | |
---|
48 | function plugin_activate() |
---|
49 | { |
---|
50 | global $conf; |
---|
51 | include_once(PHPWG_ROOT_PATH.'include/functions_user.inc.php'); |
---|
52 | ///user exist ?/// |
---|
53 | $query = ' |
---|
54 | SELECT COUNT(*) AS result FROM '.USERS_TABLE.' |
---|
55 | WHERE username IN (\'18\') |
---|
56 | ;'; |
---|
57 | $data_user = mysql_fetch_array(pwg_query($query)); |
---|
58 | $exist = $data_user['result']; |
---|
59 | if ( $exist == 0 ) |
---|
60 | { |
---|
61 | register_user('18', 'adult_content', ''); |
---|
62 | } |
---|
63 | |
---|
64 | $query = ' |
---|
65 | SELECT COUNT(*) AS result FROM '.USERS_TABLE.' |
---|
66 | WHERE username IN (\'16\') |
---|
67 | ;'; |
---|
68 | $data_user = mysql_fetch_array(pwg_query($query)); |
---|
69 | $exist = $data_user['result']; |
---|
70 | if ( $exist == 0 ) |
---|
71 | { |
---|
72 | register_user('16', 'adult_content', ''); |
---|
73 | } |
---|
74 | ///group exist ?/// |
---|
75 | $query = ' |
---|
76 | SELECT COUNT(*) AS result FROM '.GROUPS_TABLE.' |
---|
77 | WHERE name IN (\'+18\') |
---|
78 | ;'; |
---|
79 | $data_user = mysql_fetch_array(pwg_query($query)); |
---|
80 | $exist = $data_user['result']; |
---|
81 | if ( $exist == 0 ) |
---|
82 | { |
---|
83 | $query = ' |
---|
84 | INSERT INTO '.GROUPS_TABLE.' |
---|
85 | (name) |
---|
86 | VALUES |
---|
87 | (\'+18\') |
---|
88 | ;'; |
---|
89 | pwg_query($query); |
---|
90 | ////////////placer dans group 18//////////// |
---|
91 | $result = pwg_query('SELECT id FROM '.GROUPS_TABLE.' WHERE name IN (\'+18\') ;'); |
---|
92 | $data_group = mysql_fetch_array($result); |
---|
93 | pwg_query('INSERT INTO '.USER_GROUP_TABLE.' VALUES(\''.get_userid('18').'\', \''.$data_group['id'].'\' )' ); |
---|
94 | } |
---|
95 | |
---|
96 | $query = ' |
---|
97 | SELECT COUNT(*) AS result FROM '.GROUPS_TABLE.' |
---|
98 | WHERE name IN (\'16-17\') |
---|
99 | ;'; |
---|
100 | $data_user = mysql_fetch_array(pwg_query($query)); |
---|
101 | $exist = $data_user['result']; |
---|
102 | if ( $exist == 0 ) |
---|
103 | { |
---|
104 | $query = ' |
---|
105 | INSERT INTO '.GROUPS_TABLE.' |
---|
106 | (name) |
---|
107 | VALUES |
---|
108 | (\'16-17\') |
---|
109 | ;'; |
---|
110 | pwg_query($query); |
---|
111 | ////////////placer dans group 16//////////// |
---|
112 | $result = pwg_query('SELECT id FROM '.GROUPS_TABLE.' WHERE name IN (\'16-17\') ;'); |
---|
113 | $data_group = mysql_fetch_array($result); |
---|
114 | pwg_query('INSERT INTO '.USER_GROUP_TABLE.' VALUES(\''.get_userid('16').'\', \''.$data_group['id'].'\' )' ); |
---|
115 | |
---|
116 | } |
---|
117 | //grp nothing |
---|
118 | $query = ' |
---|
119 | SELECT COUNT(*) AS result FROM '.GROUPS_TABLE.' |
---|
120 | WHERE name IN (\'nothing\') |
---|
121 | ;'; |
---|
122 | $data_user = mysql_fetch_array(pwg_query($query)); |
---|
123 | $exist = $data_user['result']; |
---|
124 | if ( $exist == 0 ) |
---|
125 | { |
---|
126 | $query = ' |
---|
127 | INSERT INTO '.GROUPS_TABLE.' |
---|
128 | (name) |
---|
129 | VALUES |
---|
130 | (\'nothing\') |
---|
131 | ;'; |
---|
132 | pwg_query($query); |
---|
133 | } |
---|
134 | |
---|
135 | ///assoc user/group exist ?/// |
---|
136 | |
---|
137 | $n_query = ' |
---|
138 | SELECT id FROM '.GROUPS_TABLE.' |
---|
139 | WHERE name IN (\'16-17\') |
---|
140 | ;'; |
---|
141 | $data_group = mysql_fetch_array(pwg_query($n_query)); |
---|
142 | $query = ' |
---|
143 | SELECT COUNT(*) AS result FROM '.USER_GROUP_TABLE.' |
---|
144 | WHERE group_id IN (\''.$data_group['id'].'\') AND user_id IN (\''.get_userid('16').'\') |
---|
145 | ;'; |
---|
146 | $data_user_group = mysql_fetch_array(pwg_query($query)); |
---|
147 | $exist = $data_user_group['result']; |
---|
148 | if ( $exist == 0 ) |
---|
149 | { |
---|
150 | pwg_query('INSERT INTO '.USER_GROUP_TABLE.' VALUES(\''.get_userid('16').'\', \''.$data_group['id'].'\' )' ); |
---|
151 | } |
---|
152 | $n_query = ' |
---|
153 | SELECT id FROM '.GROUPS_TABLE.' |
---|
154 | WHERE name IN (\'+18\') |
---|
155 | ;'; |
---|
156 | $data_group = mysql_fetch_array(pwg_query($n_query)); |
---|
157 | $query = ' |
---|
158 | SELECT COUNT(*) AS result FROM '.USER_GROUP_TABLE.' |
---|
159 | WHERE group_id IN (\''.$data_group['id'].'\') AND user_id IN (\''.get_userid('18').'\') |
---|
160 | ;'; |
---|
161 | $data_user_group = mysql_fetch_array(pwg_query($query)); |
---|
162 | $exist = $data_user_group['result']; |
---|
163 | if ( $exist == 0 ) |
---|
164 | { |
---|
165 | pwg_query('INSERT INTO '.USER_GROUP_TABLE.' VALUES(\''.get_userid('18').'\', \''.$data_group['id'].'\' )' ); |
---|
166 | } |
---|
167 | |
---|
168 | ////////////mis en generic//////////// |
---|
169 | $query = ' |
---|
170 | UPDATE '.USER_INFOS_TABLE.' |
---|
171 | SET status=\'generic\' |
---|
172 | WHERE user_id IN (\''.get_userid('16').'\') |
---|
173 | ;'; |
---|
174 | pwg_query($query); |
---|
175 | |
---|
176 | $query = ' |
---|
177 | UPDATE '.USER_INFOS_TABLE.' |
---|
178 | SET status=\'generic\' |
---|
179 | WHERE user_id IN (\''.get_userid('18').'\') |
---|
180 | ;'; |
---|
181 | pwg_query($query); |
---|
182 | |
---|
183 | }//fin active |
---|
184 | |
---|
185 | |
---|
186 | |
---|
187 | |
---|
188 | function plugin_uninstall() |
---|
189 | { |
---|
190 | include_once(PHPWG_ROOT_PATH.'include/functions_user.inc.php'); |
---|
191 | ////////////suppr user//////////// |
---|
192 | delete_user(get_userid('18')); |
---|
193 | delete_user(get_userid('16')); |
---|
194 | |
---|
195 | ////////////suppr assoc user all /groupe 16//////////// |
---|
196 | $query = ' |
---|
197 | SELECT id FROM '.GROUPS_TABLE.' |
---|
198 | WHERE name IN (\'16-17\') |
---|
199 | ;'; |
---|
200 | $data_group = mysql_fetch_array(pwg_query($query)); |
---|
201 | pwg_query('DELETE FROM '.USER_GROUP_TABLE.' WHERE group_id IN (\''.$data_group['id'].'\')' ); |
---|
202 | |
---|
203 | ////////////suppr assoc user all /groupe 18//////////// |
---|
204 | $query = ' |
---|
205 | SELECT id FROM '.GROUPS_TABLE.' |
---|
206 | WHERE name IN (\'+18\') |
---|
207 | ;'; |
---|
208 | $data_group = mysql_fetch_array(pwg_query($query)); |
---|
209 | pwg_query('DELETE FROM '.USER_GROUP_TABLE.' WHERE group_id IN (\''.$data_group['id'].'\')' ); |
---|
210 | |
---|
211 | ////////////suppr assoc user all /groupe nothing//////////// |
---|
212 | $query = ' |
---|
213 | SELECT id FROM '.GROUPS_TABLE.' |
---|
214 | WHERE name IN (\'nothing\') |
---|
215 | ;'; |
---|
216 | $data_group = mysql_fetch_array(pwg_query($query)); |
---|
217 | pwg_query('DELETE FROM '.USER_GROUP_TABLE.' WHERE group_id IN (\''.$data_group['id'].'\')' ); |
---|
218 | |
---|
219 | |
---|
220 | ////////////suppr groupe//////////// |
---|
221 | $query = ' |
---|
222 | DELETE FROM '.GROUPS_TABLE.' |
---|
223 | WHERE name IN (\'+18\') |
---|
224 | ;'; |
---|
225 | pwg_query($query); |
---|
226 | |
---|
227 | $query = ' |
---|
228 | DELETE FROM '.GROUPS_TABLE.' |
---|
229 | WHERE name IN (\'16-17\') |
---|
230 | ;'; |
---|
231 | pwg_query($query); |
---|
232 | $query = ' |
---|
233 | DELETE FROM '.GROUPS_TABLE.' |
---|
234 | WHERE name IN (\'nothing\') |
---|
235 | ;'; |
---|
236 | pwg_query($query); |
---|
237 | |
---|
238 | }//fin uninstall |
---|
239 | |
---|
240 | |
---|
241 | ?> |
---|