source: extensions/adult_content/maintain.inc.php @ 22821

Last change on this file since 22821 was 21057, checked in by flop25, 12 years ago

removed the option for PWG stuffs
added an explicative texte
added new lang key for the PWG Stuff module

File size: 6.3 KB
Line 
1<?php
2
3function plugin_install()
4{
5  global $conf;
6
7////////////créer groupe////////////
8  $query = '
9INSERT INTO '.GROUPS_TABLE.'
10  (name)
11  VALUES
12  (\'+18\')
13;';
14  pwg_query($query);
15  $query = '
16INSERT INTO '.GROUPS_TABLE.'
17  (name)
18  VALUES
19  (\'16-17\')
20;';
21  pwg_query($query);
22  $query = '
23INSERT 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 = pwg_db_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 = pwg_db_fetch_array($result);
42          pwg_query('INSERT INTO '.USER_GROUP_TABLE.' VALUES(\''.get_userid('18').'\', \''.$data_group['id'].'\' )' );
43
44////////////placer dans group nothing////////////
45  $result = pwg_query('SELECT id FROM '.GROUPS_TABLE.' WHERE name IN (\'nothing\') ;');
46  $data_group = pwg_db_fetch_array($result);
47          pwg_query('INSERT INTO '.USER_GROUP_TABLE.' VALUES(\''.$conf['guest_id'].'\', \''.$data_group['id'].'\' )' );
48
49/////////////Config plugin
50    $config_start=array('menublock_for_guest'=>true,'manage_what'=>'both');
51    $q = '
52INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment)
53        VALUES
54        ("ad_c_plugin" , "'.pwg_db_real_escape_string(serialize($config_start)).'" , "Plugin adult_content : menublock_for_guest, manage_what");';
55    pwg_query($q);
56
57}
58
59
60
61function plugin_activate()
62{
63  global $conf;
64///user exist ?///
65        $query = '
66        SELECT COUNT(*) AS result FROM '.USERS_TABLE.'
67        WHERE username IN (\'18\')
68        ;';
69        $data_user = pwg_db_fetch_array(pwg_query($query));
70        $exist = $data_user['result'];
71        if ( $exist == 0 )
72        {
73                register_user('18', 'adult_content', '');
74        }
75       
76        $query = '
77        SELECT COUNT(*) AS result FROM '.USERS_TABLE.'
78        WHERE username IN (\'16\')
79        ;';
80        $data_user = pwg_db_fetch_array(pwg_query($query));
81        $exist = $data_user['result'];
82        if ( $exist == 0 )
83        {
84                register_user('16', 'adult_content', '');
85        }
86///groups///
87  $query = 'INSERT IGNORE INTO '.GROUPS_TABLE.' (name) VALUES (\'+18\'),(\'16-17\'),(\'nothing\') ;';
88        pwg_query($query);
89////////////placer dans group 18////////////
90  $result = pwg_query('SELECT id FROM '.GROUPS_TABLE.' WHERE name IN (\'+18\') ;');
91  $data_group = pwg_db_fetch_array($result);
92  pwg_query('INSERT IGNORE INTO '.USER_GROUP_TABLE.' VALUES(\''.get_userid('18').'\', \''.$data_group['id'].'\' )' );
93////////////placer dans group 16////////////
94  $result = pwg_query('SELECT id FROM '.GROUPS_TABLE.' WHERE name IN (\'16-17\') ;');
95  $data_group = pwg_db_fetch_array($result);
96  pwg_query('INSERT IGNORE INTO '.USER_GROUP_TABLE.' VALUES(\''.get_userid('16').'\', \''.$data_group['id'].'\' )' );
97////////////placer dans group nothing////////////
98  $result = pwg_query('SELECT id FROM '.GROUPS_TABLE.' WHERE name IN (\'nothing\') ;');
99  $data_group = pwg_db_fetch_array($result);
100  pwg_query('INSERT IGNORE INTO '.USER_GROUP_TABLE.' VALUES(\''.$conf['guest_id'].'\', \''.$data_group['id'].'\' )' );
101       
102        ////////////mis en generic////////////
103        $query = '
104        UPDATE '.USER_INFOS_TABLE.'
105        SET status=\'generic\'
106        WHERE user_id IN (\''.get_userid('16').'\')
107        ;';
108        pwg_query($query);
109       
110        $query = '
111        UPDATE '.USER_INFOS_TABLE.'
112        SET status=\'generic\'
113        WHERE user_id IN (\''.get_userid('18').'\')
114        ;';
115        pwg_query($query);
116       
117        //////////// Check Config
118        $query = '
119        SELECT COUNT(*) AS result FROM '.CONFIG_TABLE.'
120        WHERE param IN (\'ad_c_plugin\')
121        ;';
122        $data_table = pwg_db_fetch_array(pwg_query($query));
123        $exist = $data_table['result'];
124        if ( $exist == 0 )
125        {
126          $config_start=array('menublock_for_guest'=>true,'manage_what'=>'both');
127    $q = '
128    INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment)
129    VALUES
130      ("ad_c_plugin" , "'.pwg_db_real_escape_string(serialize($config_start)).'" , "Plugin adult_content : menublock_for_guest, manage_what");';
131    pwg_query($q);
132        } 
133        else {
134                $query = '
135    SELECT value FROM '.CONFIG_TABLE.'
136    WHERE param IN (\'ad_c_plugin\')
137    ;';
138    $data_conf = pwg_db_fetch_array(pwg_query($query));
139    $cf=@unserialize($data_conf);
140    $nbr=count($cf);
141       
142          if ($nbr!=2)
143          {
144      $config_start=array('menublock_for_guest'=>true,'manage_what'=>'both');
145      $q = '
146      UPDATE ' . CONFIG_TABLE . ' SET
147      param="ad_c_plugin", value="'.pwg_db_real_escape_string(serialize($config_start)).'", comment="Plugin adult_content : menublock_for_guest, manage_what"
148      WHERE param IN (\'ad_c_plugin\');';
149      pwg_query($q);
150    }
151        }
152       
153}//fin active
154
155
156
157
158function plugin_uninstall()
159{
160  include_once(PHPWG_ROOT_PATH.'include/functions_user.inc.php');
161////////////suppr user////////////
162  delete_user(get_userid('18'));
163  delete_user(get_userid('16'));
164 
165////////////suppr assoc user all /groupe 16////////////
166    $query = '
167SELECT id FROM '.GROUPS_TABLE.'
168  WHERE name IN (\'16-17\')
169;';
170    $data_group = pwg_db_fetch_array(pwg_query($query));
171          pwg_query('DELETE FROM '.USER_GROUP_TABLE.' WHERE group_id IN (\''.$data_group['id'].'\')' );
172         
173////////////suppr assoc user all /groupe 18////////////
174    $query = '
175SELECT id FROM '.GROUPS_TABLE.'
176  WHERE name IN (\'+18\')
177;';
178    $data_group = pwg_db_fetch_array(pwg_query($query));
179          pwg_query('DELETE FROM '.USER_GROUP_TABLE.' WHERE group_id IN (\''.$data_group['id'].'\')' );
180
181////////////suppr assoc user all /groupe nothing////////////
182    $query = '
183SELECT id FROM '.GROUPS_TABLE.'
184  WHERE name IN (\'nothing\')
185;';
186    $data_group = pwg_db_fetch_array(pwg_query($query));
187          pwg_query('DELETE FROM '.USER_GROUP_TABLE.' WHERE group_id IN (\''.$data_group['id'].'\')' );
188 
189 
190////////////suppr groupe////////////
191  $query = '
192DELETE FROM '.GROUPS_TABLE.'
193  WHERE name IN (\'+18\')
194;';
195  pwg_query($query);
196 
197  $query = '
198DELETE FROM '.GROUPS_TABLE.'
199  WHERE name IN (\'16-17\')
200;';
201  pwg_query($query);
202  $query = '
203DELETE FROM '.GROUPS_TABLE.'
204  WHERE name IN (\'nothing\')
205;';
206  pwg_query($query);
207
208//////////////// Delete config
209  pwg_query('DELETE FROM '.CONFIG_TABLE.' WHERE param IN (\'ad_c_plugin\')');
210}//fin uninstall
211
212
213?>
Note: See TracBrowser for help on using the repository browser.