[604] | 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-23 22:31:24 +0000 (Tue, 23 Nov 2004) $ |
---|
| 10 | // | last modifier : $Author: plg $ |
---|
| 11 | // | revision : $Revision: 614 $ |
---|
| 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>'; |
---|
[614] | 39 | if (isset($_POST['falsify']) and count($_POST['cat_true']) > 0) |
---|
[604] | 40 | { |
---|
| 41 | switch ($_GET['section']) |
---|
| 42 | { |
---|
| 43 | case 'upload' : |
---|
| 44 | { |
---|
| 45 | $query = ' |
---|
| 46 | UPDATE '.CATEGORIES_TABLE.' |
---|
[614] | 47 | SET uploadable = \'false\' |
---|
| 48 | WHERE id IN ('.implode(',', $_POST['cat_true']).') |
---|
[604] | 49 | ;'; |
---|
| 50 | pwg_query($query); |
---|
| 51 | break; |
---|
| 52 | } |
---|
| 53 | case 'comments' : |
---|
| 54 | { |
---|
| 55 | $query = ' |
---|
| 56 | UPDATE '.CATEGORIES_TABLE.' |
---|
[614] | 57 | SET commentable = \'false\' |
---|
| 58 | WHERE id IN ('.implode(',', $_POST['cat_true']).') |
---|
[604] | 59 | ;'; |
---|
| 60 | pwg_query($query); |
---|
| 61 | break; |
---|
| 62 | } |
---|
| 63 | case 'visible' : |
---|
| 64 | { |
---|
| 65 | // locking a category => all its child categories become locked |
---|
[614] | 66 | $subcats = get_subcat_ids($_POST['cat_true']); |
---|
| 67 | $query = ' |
---|
[604] | 68 | UPDATE '.CATEGORIES_TABLE.' |
---|
| 69 | SET visible = \'false\' |
---|
| 70 | WHERE id IN ('.implode(',', $subcats).') |
---|
| 71 | ;'; |
---|
[614] | 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 | { |
---|
[604] | 115 | // unlocking a category => all its parent categories become unlocked |
---|
[614] | 116 | $uppercats = array(); |
---|
| 117 | $query = ' |
---|
[604] | 118 | SELECT uppercats |
---|
| 119 | FROM '.CATEGORIES_TABLE.' |
---|
[614] | 120 | WHERE id IN ('.implode(',', $_POST['cat_false']).') |
---|
[604] | 121 | ;'; |
---|
[614] | 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 = ' |
---|
[604] | 131 | UPDATE '.CATEGORIES_TABLE.' |
---|
| 132 | SET visible = \'true\' |
---|
| 133 | WHERE id IN ('.implode(',', $uppercats).') |
---|
| 134 | ;'; |
---|
[614] | 135 | pwg_query($query); |
---|
[604] | 136 | break; |
---|
| 137 | } |
---|
| 138 | case 'status' : |
---|
| 139 | { |
---|
| 140 | // make public a category => all its parent categories become public |
---|
[614] | 141 | $uppercats = array(); |
---|
| 142 | $query = ' |
---|
[604] | 143 | SELECT uppercats |
---|
| 144 | FROM '.CATEGORIES_TABLE.' |
---|
[614] | 145 | WHERE id IN ('.implode(',', $_POST['cat_false']).') |
---|
[604] | 146 | ;'; |
---|
[614] | 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 = ' |
---|
[604] | 156 | UPDATE '.CATEGORIES_TABLE.' |
---|
| 157 | SET status = \'public\' |
---|
| 158 | WHERE id IN ('.implode(',', $uppercats).') |
---|
| 159 | ;'; |
---|
[614] | 160 | pwg_query($query); |
---|
[604] | 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 | 'U_UPLOAD'=>add_session_id($base_url.'upload'), |
---|
| 186 | 'U_VISIBLE'=>add_session_id($base_url.'visible'), |
---|
| 187 | 'U_COMMENTS'=>add_session_id($base_url.'comments'), |
---|
| 188 | 'U_STATUS'=>add_session_id($base_url.'status'), |
---|
| 189 | |
---|
| 190 | 'F_ACTION'=>add_session_id($base_url.$page['section']) |
---|
| 191 | ) |
---|
| 192 | ); |
---|
| 193 | |
---|
| 194 | $template->assign_vars(array(strtoupper($page['section']).'_CLASS'=>'opened')); |
---|
| 195 | // +-----------------------------------------------------------------------+ |
---|
| 196 | // | form display | |
---|
| 197 | // +-----------------------------------------------------------------------+ |
---|
| 198 | |
---|
| 199 | // for each section, categories in the multiselect field can be : |
---|
| 200 | // |
---|
| 201 | // - true : uploadable for upload section |
---|
| 202 | // - false : un-uploadable for upload section |
---|
| 203 | // - NA : (not applicable) for virtual categories |
---|
| 204 | // |
---|
| 205 | // for true and false status, we associates an array of category ids, |
---|
| 206 | // function display_select_categories will use the given CSS class for each |
---|
| 207 | // option |
---|
| 208 | $cats_true = array(); |
---|
| 209 | $cats_false = array(); |
---|
| 210 | switch ($page['section']) |
---|
| 211 | { |
---|
| 212 | case 'upload' : |
---|
| 213 | { |
---|
[614] | 214 | $query_true = ' |
---|
| 215 | SELECT id,name,uppercats,global_rank |
---|
[604] | 216 | FROM '.CATEGORIES_TABLE.' |
---|
| 217 | WHERE uploadable = \'true\' |
---|
| 218 | AND dir IS NOT NULL |
---|
| 219 | AND site_id = 1 |
---|
| 220 | ;'; |
---|
[614] | 221 | $query_false = ' |
---|
| 222 | SELECT id,name,uppercats,global_rank |
---|
[604] | 223 | FROM '.CATEGORIES_TABLE.' |
---|
| 224 | WHERE uploadable = \'false\' |
---|
| 225 | AND dir IS NOT NULL |
---|
| 226 | AND site_id = 1 |
---|
| 227 | ;'; |
---|
[614] | 228 | $template->assign_vars( |
---|
| 229 | array( |
---|
| 230 | 'L_TITLE' => $lang['cat_options_upload_title'], |
---|
| 231 | 'L_CAT_OPTIONS_TRUE' => $lang['cat_options_upload_true'], |
---|
| 232 | 'L_CAT_OPTIONS_FALSE' => $lang['cat_options_upload_false'], |
---|
| 233 | 'L_CAT_OPTIONS_INFO' => $lang['cat_options_upload_info'], |
---|
| 234 | ) |
---|
| 235 | ); |
---|
[604] | 236 | $template->assign_block_vars('upload', array()); |
---|
| 237 | break; |
---|
| 238 | } |
---|
| 239 | case 'comments' : |
---|
| 240 | { |
---|
[614] | 241 | $query_true = ' |
---|
| 242 | SELECT id,name,uppercats,global_rank |
---|
[604] | 243 | FROM '.CATEGORIES_TABLE.' |
---|
| 244 | WHERE commentable = \'true\' |
---|
| 245 | ;'; |
---|
[614] | 246 | $query_false = ' |
---|
| 247 | SELECT id,name,uppercats,global_rank |
---|
[604] | 248 | FROM '.CATEGORIES_TABLE.' |
---|
| 249 | WHERE commentable = \'false\' |
---|
| 250 | ;'; |
---|
[614] | 251 | $template->assign_vars( |
---|
| 252 | array( |
---|
| 253 | 'L_TITLE' => $lang['cat_options_comments_title'], |
---|
| 254 | 'L_CAT_OPTIONS_TRUE' => $lang['cat_options_comments_true'], |
---|
| 255 | 'L_CAT_OPTIONS_FALSE' => $lang['cat_options_comments_false'], |
---|
| 256 | 'L_CAT_OPTIONS_INFO' => $lang['cat_options_comments_info'], |
---|
| 257 | ) |
---|
| 258 | ); |
---|
[604] | 259 | $template->assign_block_vars('comments', array()); |
---|
| 260 | break; |
---|
| 261 | } |
---|
| 262 | case 'visible' : |
---|
| 263 | { |
---|
[614] | 264 | $query_true = ' |
---|
| 265 | SELECT id,name,uppercats,global_rank |
---|
[604] | 266 | FROM '.CATEGORIES_TABLE.' |
---|
| 267 | WHERE visible = \'true\' |
---|
| 268 | ;'; |
---|
[614] | 269 | $query_false = ' |
---|
| 270 | SELECT id,name,uppercats,global_rank |
---|
[604] | 271 | FROM '.CATEGORIES_TABLE.' |
---|
| 272 | WHERE visible = \'false\' |
---|
| 273 | ;'; |
---|
[614] | 274 | $template->assign_vars( |
---|
| 275 | array( |
---|
| 276 | 'L_TITLE' => $lang['cat_options_visible_title'], |
---|
| 277 | 'L_CAT_OPTIONS_TRUE' => $lang['cat_options_visible_true'], |
---|
| 278 | 'L_CAT_OPTIONS_FALSE' => $lang['cat_options_visible_false'], |
---|
| 279 | 'L_CAT_OPTIONS_INFO' => $lang['cat_options_visible_info'], |
---|
| 280 | ) |
---|
| 281 | ); |
---|
[604] | 282 | $template->assign_block_vars('visible', array()); |
---|
| 283 | break; |
---|
| 284 | } |
---|
| 285 | case 'status' : |
---|
| 286 | { |
---|
[614] | 287 | $query_true = ' |
---|
| 288 | SELECT id,name,uppercats,global_rank |
---|
[604] | 289 | FROM '.CATEGORIES_TABLE.' |
---|
| 290 | WHERE status = \'public\' |
---|
| 291 | ;'; |
---|
[614] | 292 | $query_false = ' |
---|
| 293 | SELECT id,name,uppercats,global_rank |
---|
[604] | 294 | FROM '.CATEGORIES_TABLE.' |
---|
| 295 | WHERE status = \'private\' |
---|
| 296 | ;'; |
---|
[614] | 297 | $template->assign_vars( |
---|
| 298 | array( |
---|
| 299 | 'L_TITLE' => $lang['cat_options_status_title'], |
---|
| 300 | 'L_CAT_OPTIONS_TRUE' => $lang['cat_options_status_true'], |
---|
| 301 | 'L_CAT_OPTIONS_FALSE' => $lang['cat_options_status_false'], |
---|
| 302 | 'L_CAT_OPTIONS_INFO' => $lang['cat_options_status_info'], |
---|
| 303 | ) |
---|
| 304 | ); |
---|
[604] | 305 | $template->assign_block_vars('status', array()); |
---|
| 306 | break; |
---|
| 307 | } |
---|
| 308 | } |
---|
[614] | 309 | display_select_cat_wrapper($query_true,array(),'category_option_true'); |
---|
| 310 | display_select_cat_wrapper($query_false,array(),'category_option_false'); |
---|
[604] | 311 | // +-----------------------------------------------------------------------+ |
---|
| 312 | // | sending html code | |
---|
| 313 | // +-----------------------------------------------------------------------+ |
---|
| 314 | $template->assign_var_from_handle('ADMIN_CONTENT', 'cat_options'); |
---|
| 315 | ?> |
---|