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-2005 PhpWebGallery Team - http://phpwebgallery.net | |
---|
6 | // +-----------------------------------------------------------------------+ |
---|
7 | // | branch : BSF (Best So Far) |
---|
8 | // | file : $RCSfile$ |
---|
9 | // | last update : $Date: 2006-04-21 19:33:58 +0000 (Fri, 21 Apr 2006) $ |
---|
10 | // | last modifier : $Author: nikrou $ |
---|
11 | // | revision : $Revision: 1234 $ |
---|
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 | |
---|
33 | include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); |
---|
34 | |
---|
35 | // +-----------------------------------------------------------------------+ |
---|
36 | // | Check Access and exit when user status is not ok | |
---|
37 | // +-----------------------------------------------------------------------+ |
---|
38 | check_status(ACCESS_ADMINISTRATOR); |
---|
39 | |
---|
40 | // +-----------------------------------------------------------------------+ |
---|
41 | // | modification registration | |
---|
42 | // +-----------------------------------------------------------------------+ |
---|
43 | |
---|
44 | // print '<pre>'; |
---|
45 | // print_r($_POST); |
---|
46 | // print '</pre>'; |
---|
47 | if (isset($_POST['falsify']) |
---|
48 | and isset($_POST['cat_true']) |
---|
49 | and count($_POST['cat_true']) > 0) |
---|
50 | { |
---|
51 | switch ($_GET['section']) |
---|
52 | { |
---|
53 | case 'upload' : |
---|
54 | { |
---|
55 | $query = ' |
---|
56 | UPDATE '.CATEGORIES_TABLE.' |
---|
57 | SET uploadable = \'false\' |
---|
58 | WHERE id IN ('.implode(',', $_POST['cat_true']).') |
---|
59 | ;'; |
---|
60 | pwg_query($query); |
---|
61 | break; |
---|
62 | } |
---|
63 | case 'comments' : |
---|
64 | { |
---|
65 | $query = ' |
---|
66 | UPDATE '.CATEGORIES_TABLE.' |
---|
67 | SET commentable = \'false\' |
---|
68 | WHERE id IN ('.implode(',', $_POST['cat_true']).') |
---|
69 | ;'; |
---|
70 | pwg_query($query); |
---|
71 | break; |
---|
72 | } |
---|
73 | case 'visible' : |
---|
74 | { |
---|
75 | set_cat_visible($_POST['cat_true'], 'false'); |
---|
76 | break; |
---|
77 | } |
---|
78 | case 'status' : |
---|
79 | { |
---|
80 | set_cat_status($_POST['cat_true'], 'private'); |
---|
81 | break; |
---|
82 | } |
---|
83 | case 'representative' : |
---|
84 | { |
---|
85 | $query = ' |
---|
86 | UPDATE '.CATEGORIES_TABLE.' |
---|
87 | SET representative_picture_id = NULL |
---|
88 | WHERE id IN ('.implode(',', $_POST['cat_true']).') |
---|
89 | ;'; |
---|
90 | pwg_query($query); |
---|
91 | break; |
---|
92 | } |
---|
93 | } |
---|
94 | } |
---|
95 | else if (isset($_POST['trueify']) |
---|
96 | and isset($_POST['cat_false']) |
---|
97 | and count($_POST['cat_false']) > 0) |
---|
98 | { |
---|
99 | switch ($_GET['section']) |
---|
100 | { |
---|
101 | case 'upload' : |
---|
102 | { |
---|
103 | $query = ' |
---|
104 | UPDATE '.CATEGORIES_TABLE.' |
---|
105 | SET uploadable = \'true\' |
---|
106 | WHERE id IN ('.implode(',', $_POST['cat_false']).') |
---|
107 | ;'; |
---|
108 | pwg_query($query); |
---|
109 | break; |
---|
110 | } |
---|
111 | case 'comments' : |
---|
112 | { |
---|
113 | $query = ' |
---|
114 | UPDATE '.CATEGORIES_TABLE.' |
---|
115 | SET commentable = \'true\' |
---|
116 | WHERE id IN ('.implode(',', $_POST['cat_false']).') |
---|
117 | ;'; |
---|
118 | pwg_query($query); |
---|
119 | break; |
---|
120 | } |
---|
121 | case 'visible' : |
---|
122 | { |
---|
123 | set_cat_visible($_POST['cat_false'], 'true'); |
---|
124 | break; |
---|
125 | } |
---|
126 | case 'status' : |
---|
127 | { |
---|
128 | set_cat_status($_POST['cat_false'], 'public'); |
---|
129 | break; |
---|
130 | } |
---|
131 | case 'representative' : |
---|
132 | { |
---|
133 | // theoretically, all categories in $_POST['cat_false'] contain at |
---|
134 | // least one element, so PhpWebGallery can find a representant. |
---|
135 | set_random_representant($_POST['cat_false']); |
---|
136 | break; |
---|
137 | } |
---|
138 | } |
---|
139 | } |
---|
140 | |
---|
141 | // +-----------------------------------------------------------------------+ |
---|
142 | // | template init | |
---|
143 | // +-----------------------------------------------------------------------+ |
---|
144 | |
---|
145 | $template->set_filenames( |
---|
146 | array( |
---|
147 | 'cat_options' => 'admin/cat_options.tpl', |
---|
148 | 'double_select' => 'admin/double_select.tpl' |
---|
149 | ) |
---|
150 | ); |
---|
151 | |
---|
152 | $page['section'] = isset($_GET['section']) ? $_GET['section'] : 'upload'; |
---|
153 | $base_url = PHPWG_ROOT_PATH.'admin.php?page=cat_options&section='; |
---|
154 | |
---|
155 | $template->assign_vars( |
---|
156 | array( |
---|
157 | 'L_SUBMIT'=>$lang['submit'], |
---|
158 | 'L_RESET'=>$lang['reset'], |
---|
159 | |
---|
160 | 'U_HELP' => PHPWG_ROOT_PATH.'popuphelp.php?page=cat_options', |
---|
161 | |
---|
162 | 'F_ACTION'=>$base_url.$page['section'] |
---|
163 | ) |
---|
164 | ); |
---|
165 | |
---|
166 | // +-----------------------------------------------------------------------+ |
---|
167 | // | form display | |
---|
168 | // +-----------------------------------------------------------------------+ |
---|
169 | |
---|
170 | // for each section, categories in the multiselect field can be : |
---|
171 | // |
---|
172 | // - true : uploadable for upload section |
---|
173 | // - false : un-uploadable for upload section |
---|
174 | // - NA : (not applicable) for virtual categories |
---|
175 | // |
---|
176 | // for true and false status, we associates an array of category ids, |
---|
177 | // function display_select_categories will use the given CSS class for each |
---|
178 | // option |
---|
179 | $cats_true = array(); |
---|
180 | $cats_false = array(); |
---|
181 | switch ($page['section']) |
---|
182 | { |
---|
183 | case 'upload' : |
---|
184 | { |
---|
185 | $query_true = ' |
---|
186 | SELECT id,name,uppercats,global_rank |
---|
187 | FROM '.CATEGORIES_TABLE.' |
---|
188 | WHERE uploadable = \'true\' |
---|
189 | AND dir IS NOT NULL |
---|
190 | AND site_id = 1 |
---|
191 | ;'; |
---|
192 | $query_false = ' |
---|
193 | SELECT id,name,uppercats,global_rank |
---|
194 | FROM '.CATEGORIES_TABLE.' |
---|
195 | WHERE uploadable = \'false\' |
---|
196 | AND dir IS NOT NULL |
---|
197 | AND site_id = 1 |
---|
198 | ;'; |
---|
199 | $template->assign_vars( |
---|
200 | array( |
---|
201 | 'L_SECTION' => $lang['cat_upload_title'], |
---|
202 | 'L_CAT_OPTIONS_TRUE' => $lang['authorized'], |
---|
203 | 'L_CAT_OPTIONS_FALSE' => $lang['forbidden'], |
---|
204 | ) |
---|
205 | ); |
---|
206 | break; |
---|
207 | } |
---|
208 | case 'comments' : |
---|
209 | { |
---|
210 | $query_true = ' |
---|
211 | SELECT id,name,uppercats,global_rank |
---|
212 | FROM '.CATEGORIES_TABLE.' |
---|
213 | WHERE commentable = \'true\' |
---|
214 | ;'; |
---|
215 | $query_false = ' |
---|
216 | SELECT id,name,uppercats,global_rank |
---|
217 | FROM '.CATEGORIES_TABLE.' |
---|
218 | WHERE commentable = \'false\' |
---|
219 | ;'; |
---|
220 | $template->assign_vars( |
---|
221 | array( |
---|
222 | 'L_SECTION' => $lang['cat_comments_title'], |
---|
223 | 'L_CAT_OPTIONS_TRUE' => $lang['authorized'], |
---|
224 | 'L_CAT_OPTIONS_FALSE' => $lang['forbidden'], |
---|
225 | ) |
---|
226 | ); |
---|
227 | break; |
---|
228 | } |
---|
229 | case 'visible' : |
---|
230 | { |
---|
231 | $query_true = ' |
---|
232 | SELECT id,name,uppercats,global_rank |
---|
233 | FROM '.CATEGORIES_TABLE.' |
---|
234 | WHERE visible = \'true\' |
---|
235 | ;'; |
---|
236 | $query_false = ' |
---|
237 | SELECT id,name,uppercats,global_rank |
---|
238 | FROM '.CATEGORIES_TABLE.' |
---|
239 | WHERE visible = \'false\' |
---|
240 | ;'; |
---|
241 | $template->assign_vars( |
---|
242 | array( |
---|
243 | 'L_SECTION' => $lang['cat_lock_title'], |
---|
244 | 'L_CAT_OPTIONS_TRUE' => $lang['unlocked'], |
---|
245 | 'L_CAT_OPTIONS_FALSE' => $lang['locked'], |
---|
246 | ) |
---|
247 | ); |
---|
248 | break; |
---|
249 | } |
---|
250 | case 'status' : |
---|
251 | { |
---|
252 | $query_true = ' |
---|
253 | SELECT id,name,uppercats,global_rank |
---|
254 | FROM '.CATEGORIES_TABLE.' |
---|
255 | WHERE status = \'public\' |
---|
256 | ;'; |
---|
257 | $query_false = ' |
---|
258 | SELECT id,name,uppercats,global_rank |
---|
259 | FROM '.CATEGORIES_TABLE.' |
---|
260 | WHERE status = \'private\' |
---|
261 | ;'; |
---|
262 | $template->assign_vars( |
---|
263 | array( |
---|
264 | 'L_SECTION' => $lang['cat_status_title'], |
---|
265 | 'L_CAT_OPTIONS_TRUE' => $lang['cat_public'], |
---|
266 | 'L_CAT_OPTIONS_FALSE' => $lang['cat_private'], |
---|
267 | ) |
---|
268 | ); |
---|
269 | break; |
---|
270 | } |
---|
271 | case 'representative' : |
---|
272 | { |
---|
273 | $query_true = ' |
---|
274 | SELECT id,name,uppercats,global_rank |
---|
275 | FROM '.CATEGORIES_TABLE.' |
---|
276 | WHERE representative_picture_id IS NOT NULL |
---|
277 | ;'; |
---|
278 | $query_false = ' |
---|
279 | SELECT id,name,uppercats,global_rank |
---|
280 | FROM '.CATEGORIES_TABLE.' |
---|
281 | WHERE nb_images != 0 |
---|
282 | AND representative_picture_id IS NULL |
---|
283 | ;'; |
---|
284 | $template->assign_vars( |
---|
285 | array( |
---|
286 | 'L_SECTION' => l10n('Representative'), |
---|
287 | 'L_CAT_OPTIONS_TRUE' => l10n('singly represented'), |
---|
288 | 'L_CAT_OPTIONS_FALSE' => l10n('randomly represented') |
---|
289 | ) |
---|
290 | ); |
---|
291 | break; |
---|
292 | } |
---|
293 | } |
---|
294 | display_select_cat_wrapper($query_true,array(),'category_option_true'); |
---|
295 | display_select_cat_wrapper($query_false,array(),'category_option_false'); |
---|
296 | |
---|
297 | // +-----------------------------------------------------------------------+ |
---|
298 | // | sending html code | |
---|
299 | // +-----------------------------------------------------------------------+ |
---|
300 | |
---|
301 | $template->assign_var_from_handle('DOUBLE_SELECT', 'double_select'); |
---|
302 | $template->assign_var_from_handle('ADMIN_CONTENT', 'cat_options'); |
---|
303 | ?> |
---|