1 | <?php |
---|
2 | // +-----------------------------------------------------------------------+ |
---|
3 | // | PhpWebGallery - a PHP based picture gallery | |
---|
4 | // | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net | |
---|
5 | // | Copyright (C) 2003-2004 PhpWebGallery Team - http://phpwebgallery.net | |
---|
6 | // +-----------------------------------------------------------------------+ |
---|
7 | // | branch : BSF (Best So Far) |
---|
8 | // | file : $RCSfile$ |
---|
9 | // | last update : $Date: 2004-11-25 16:44:41 +0000 (Thu, 25 Nov 2004) $ |
---|
10 | // | last modifier : $Author: gweltas $ |
---|
11 | // | revision : $Revision: 622 $ |
---|
12 | // +-----------------------------------------------------------------------+ |
---|
13 | // | This program is free software; you can redistribute it and/or modify | |
---|
14 | // | it under the terms of the GNU General Public License as published by | |
---|
15 | // | the Free Software Foundation | |
---|
16 | // | | |
---|
17 | // | This program is distributed in the hope that it will be useful, but | |
---|
18 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
19 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
20 | // | General Public License for more details. | |
---|
21 | // | | |
---|
22 | // | You should have received a copy of the GNU General Public License | |
---|
23 | // | along with this program; if not, write to the Free Software | |
---|
24 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
25 | // | USA. | |
---|
26 | // +-----------------------------------------------------------------------+ |
---|
27 | |
---|
28 | if (!defined('PHPWG_ROOT_PATH')) |
---|
29 | { |
---|
30 | die ("Hacking attempt!"); |
---|
31 | } |
---|
32 | include_once(PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php'); |
---|
33 | // +-----------------------------------------------------------------------+ |
---|
34 | // | modification registration | |
---|
35 | // +-----------------------------------------------------------------------+ |
---|
36 | // print '<pre>'; |
---|
37 | // print_r($_POST); |
---|
38 | // print '</pre>'; |
---|
39 | if (isset($_POST['falsify']) and count($_POST['cat_true']) > 0) |
---|
40 | { |
---|
41 | switch ($_GET['section']) |
---|
42 | { |
---|
43 | case 'upload' : |
---|
44 | { |
---|
45 | $query = ' |
---|
46 | UPDATE '.CATEGORIES_TABLE.' |
---|
47 | SET uploadable = \'false\' |
---|
48 | WHERE id IN ('.implode(',', $_POST['cat_true']).') |
---|
49 | ;'; |
---|
50 | pwg_query($query); |
---|
51 | break; |
---|
52 | } |
---|
53 | case 'comments' : |
---|
54 | { |
---|
55 | $query = ' |
---|
56 | UPDATE '.CATEGORIES_TABLE.' |
---|
57 | SET commentable = \'false\' |
---|
58 | WHERE id IN ('.implode(',', $_POST['cat_true']).') |
---|
59 | ;'; |
---|
60 | pwg_query($query); |
---|
61 | break; |
---|
62 | } |
---|
63 | case 'visible' : |
---|
64 | { |
---|
65 | // locking a category => all its child categories become locked |
---|
66 | $subcats = get_subcat_ids($_POST['cat_true']); |
---|
67 | $query = ' |
---|
68 | UPDATE '.CATEGORIES_TABLE.' |
---|
69 | SET visible = \'false\' |
---|
70 | WHERE id IN ('.implode(',', $subcats).') |
---|
71 | ;'; |
---|
72 | pwg_query($query); |
---|
73 | break; |
---|
74 | } |
---|
75 | case 'status' : |
---|
76 | { |
---|
77 | // make a category private => all its child categories become private |
---|
78 | $subcats = get_subcat_ids($_POST['cat_true']); |
---|
79 | $query = ' |
---|
80 | UPDATE '.CATEGORIES_TABLE.' |
---|
81 | SET status = \'private\' |
---|
82 | WHERE id IN ('.implode(',', $subcats).') |
---|
83 | ;'; |
---|
84 | pwg_query($query); |
---|
85 | break; |
---|
86 | } |
---|
87 | } |
---|
88 | } |
---|
89 | else if (isset($_POST['trueify']) and count($_POST['cat_false']) > 0) |
---|
90 | { |
---|
91 | switch ($_GET['section']) |
---|
92 | { |
---|
93 | case 'upload' : |
---|
94 | { |
---|
95 | $query = ' |
---|
96 | UPDATE '.CATEGORIES_TABLE.' |
---|
97 | SET uploadable = \'true\' |
---|
98 | WHERE id IN ('.implode(',', $_POST['cat_false']).') |
---|
99 | ;'; |
---|
100 | pwg_query($query); |
---|
101 | break; |
---|
102 | } |
---|
103 | case 'comments' : |
---|
104 | { |
---|
105 | $query = ' |
---|
106 | UPDATE '.CATEGORIES_TABLE.' |
---|
107 | SET commentable = \'true\' |
---|
108 | WHERE id IN ('.implode(',', $_POST['cat_false']).') |
---|
109 | ;'; |
---|
110 | pwg_query($query); |
---|
111 | break; |
---|
112 | } |
---|
113 | case 'visible' : |
---|
114 | { |
---|
115 | // unlocking a category => all its parent categories become unlocked |
---|
116 | $uppercats = array(); |
---|
117 | $query = ' |
---|
118 | SELECT uppercats |
---|
119 | FROM '.CATEGORIES_TABLE.' |
---|
120 | WHERE id IN ('.implode(',', $_POST['cat_false']).') |
---|
121 | ;'; |
---|
122 | $result = pwg_query($query); |
---|
123 | while ($row = mysql_fetch_array($result)) |
---|
124 | { |
---|
125 | $uppercats = array_merge($uppercats, |
---|
126 | explode(',', $row['uppercats'])); |
---|
127 | } |
---|
128 | $uppercats = array_unique($uppercats); |
---|
129 | |
---|
130 | $query = ' |
---|
131 | UPDATE '.CATEGORIES_TABLE.' |
---|
132 | SET visible = \'true\' |
---|
133 | WHERE id IN ('.implode(',', $uppercats).') |
---|
134 | ;'; |
---|
135 | pwg_query($query); |
---|
136 | break; |
---|
137 | } |
---|
138 | case 'status' : |
---|
139 | { |
---|
140 | // make public a category => all its parent categories become public |
---|
141 | $uppercats = array(); |
---|
142 | $query = ' |
---|
143 | SELECT uppercats |
---|
144 | FROM '.CATEGORIES_TABLE.' |
---|
145 | WHERE id IN ('.implode(',', $_POST['cat_false']).') |
---|
146 | ;'; |
---|
147 | $result = pwg_query($query); |
---|
148 | while ($row = mysql_fetch_array($result)) |
---|
149 | { |
---|
150 | $uppercats = array_merge($uppercats, |
---|
151 | explode(',', $row['uppercats'])); |
---|
152 | } |
---|
153 | $uppercats = array_unique($uppercats); |
---|
154 | |
---|
155 | $query = ' |
---|
156 | UPDATE '.CATEGORIES_TABLE.' |
---|
157 | SET status = \'public\' |
---|
158 | WHERE id IN ('.implode(',', $uppercats).') |
---|
159 | ;'; |
---|
160 | pwg_query($query); |
---|
161 | break; |
---|
162 | } |
---|
163 | } |
---|
164 | } |
---|
165 | // +-----------------------------------------------------------------------+ |
---|
166 | // | template init | |
---|
167 | // +-----------------------------------------------------------------------+ |
---|
168 | $template->set_filenames(array('cat_options'=>'admin/cat_options.tpl')); |
---|
169 | |
---|
170 | if (!isset($_GET['section'])) |
---|
171 | { |
---|
172 | $page['section'] = 'upload'; |
---|
173 | } |
---|
174 | else |
---|
175 | { |
---|
176 | $page['section'] = $_GET['section']; |
---|
177 | } |
---|
178 | |
---|
179 | $base_url = PHPWG_ROOT_PATH.'admin.php?page=cat_options&section='; |
---|
180 | $template->assign_vars( |
---|
181 | array( |
---|
182 | 'L_SUBMIT'=>$lang['submit'], |
---|
183 | 'L_RESET'=>$lang['reset'], |
---|
184 | |
---|
185 | 'F_ACTION'=>add_session_id($base_url.$page['section']) |
---|
186 | ) |
---|
187 | ); |
---|
188 | |
---|
189 | $template->assign_vars(array(strtoupper($page['section']).'_CLASS'=>'opened')); |
---|
190 | // +-----------------------------------------------------------------------+ |
---|
191 | // | form display | |
---|
192 | // +-----------------------------------------------------------------------+ |
---|
193 | |
---|
194 | // for each section, categories in the multiselect field can be : |
---|
195 | // |
---|
196 | // - true : uploadable for upload section |
---|
197 | // - false : un-uploadable for upload section |
---|
198 | // - NA : (not applicable) for virtual categories |
---|
199 | // |
---|
200 | // for true and false status, we associates an array of category ids, |
---|
201 | // function display_select_categories will use the given CSS class for each |
---|
202 | // option |
---|
203 | $cats_true = array(); |
---|
204 | $cats_false = array(); |
---|
205 | switch ($page['section']) |
---|
206 | { |
---|
207 | case 'upload' : |
---|
208 | { |
---|
209 | $query_true = ' |
---|
210 | SELECT id,name,uppercats,global_rank |
---|
211 | FROM '.CATEGORIES_TABLE.' |
---|
212 | WHERE uploadable = \'true\' |
---|
213 | AND dir IS NOT NULL |
---|
214 | AND site_id = 1 |
---|
215 | ;'; |
---|
216 | $query_false = ' |
---|
217 | SELECT id,name,uppercats,global_rank |
---|
218 | FROM '.CATEGORIES_TABLE.' |
---|
219 | WHERE uploadable = \'false\' |
---|
220 | AND dir IS NOT NULL |
---|
221 | AND site_id = 1 |
---|
222 | ;'; |
---|
223 | $template->assign_vars( |
---|
224 | array( |
---|
225 | 'L_CAT_TITLE' => $lang['cat_upload_title'], |
---|
226 | 'L_CAT_OPTIONS_TRUE' => $lang['authorized'], |
---|
227 | 'L_CAT_OPTIONS_FALSE' => $lang['forbidden'], |
---|
228 | 'L_CAT_OPTIONS_INFO' => $lang['cat_upload_info'], |
---|
229 | ) |
---|
230 | ); |
---|
231 | $template->assign_block_vars('upload', array()); |
---|
232 | break; |
---|
233 | } |
---|
234 | case 'comments' : |
---|
235 | { |
---|
236 | $query_true = ' |
---|
237 | SELECT id,name,uppercats,global_rank |
---|
238 | FROM '.CATEGORIES_TABLE.' |
---|
239 | WHERE commentable = \'true\' |
---|
240 | ;'; |
---|
241 | $query_false = ' |
---|
242 | SELECT id,name,uppercats,global_rank |
---|
243 | FROM '.CATEGORIES_TABLE.' |
---|
244 | WHERE commentable = \'false\' |
---|
245 | ;'; |
---|
246 | $template->assign_vars( |
---|
247 | array( |
---|
248 | 'L_CAT_TITLE' => $lang['cat_comments_title'], |
---|
249 | 'L_CAT_OPTIONS_TRUE' => $lang['authorized'], |
---|
250 | 'L_CAT_OPTIONS_FALSE' => $lang['forbidden'], |
---|
251 | 'L_CAT_OPTIONS_INFO' => $lang['cat_comments_info'], |
---|
252 | ) |
---|
253 | ); |
---|
254 | $template->assign_block_vars('comments', array()); |
---|
255 | break; |
---|
256 | } |
---|
257 | case 'visible' : |
---|
258 | { |
---|
259 | $query_true = ' |
---|
260 | SELECT id,name,uppercats,global_rank |
---|
261 | FROM '.CATEGORIES_TABLE.' |
---|
262 | WHERE visible = \'true\' |
---|
263 | ;'; |
---|
264 | $query_false = ' |
---|
265 | SELECT id,name,uppercats,global_rank |
---|
266 | FROM '.CATEGORIES_TABLE.' |
---|
267 | WHERE visible = \'false\' |
---|
268 | ;'; |
---|
269 | $template->assign_vars( |
---|
270 | array( |
---|
271 | 'L_CAT_TITLE' => $lang['cat_lock_title'], |
---|
272 | 'L_CAT_OPTIONS_TRUE' => $lang['lock'], |
---|
273 | 'L_CAT_OPTIONS_FALSE' => $lang['unlock'], |
---|
274 | 'L_CAT_OPTIONS_INFO' => $lang['cat_lock_info'], |
---|
275 | ) |
---|
276 | ); |
---|
277 | $template->assign_block_vars('visible', array()); |
---|
278 | break; |
---|
279 | } |
---|
280 | case 'status' : |
---|
281 | { |
---|
282 | $query_true = ' |
---|
283 | SELECT id,name,uppercats,global_rank |
---|
284 | FROM '.CATEGORIES_TABLE.' |
---|
285 | WHERE status = \'public\' |
---|
286 | ;'; |
---|
287 | $query_false = ' |
---|
288 | SELECT id,name,uppercats,global_rank |
---|
289 | FROM '.CATEGORIES_TABLE.' |
---|
290 | WHERE status = \'private\' |
---|
291 | ;'; |
---|
292 | $template->assign_vars( |
---|
293 | array( |
---|
294 | 'L_CAT_TITLE' => $lang['cat_status_title'], |
---|
295 | 'L_CAT_OPTIONS_TRUE' => $lang['cat_public'], |
---|
296 | 'L_CAT_OPTIONS_FALSE' => $lang['cat_private'], |
---|
297 | 'L_CAT_OPTIONS_INFO' => $lang['cat_status_info'], |
---|
298 | ) |
---|
299 | ); |
---|
300 | $template->assign_block_vars('status', array()); |
---|
301 | break; |
---|
302 | } |
---|
303 | } |
---|
304 | display_select_cat_wrapper($query_true,array(),'category_option_true'); |
---|
305 | display_select_cat_wrapper($query_false,array(),'category_option_false'); |
---|
306 | // +-----------------------------------------------------------------------+ |
---|
307 | // | sending html code | |
---|
308 | // +-----------------------------------------------------------------------+ |
---|
309 | $template->assign_var_from_handle('ADMIN_CONTENT', 'cat_options'); |
---|
310 | ?> |
---|