[604] | 1 | <?php |
---|
| 2 | // +-----------------------------------------------------------------------+ |
---|
[8728] | 3 | // | Piwigo - a PHP based photo gallery | |
---|
[2297] | 4 | // +-----------------------------------------------------------------------+ |
---|
[8728] | 5 | // | Copyright(C) 2008-2011 Piwigo Team http://piwigo.org | |
---|
[2297] | 6 | // | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net | |
---|
| 7 | // | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick | |
---|
| 8 | // +-----------------------------------------------------------------------+ |
---|
| 9 | // | This program is free software; you can redistribute it and/or modify | |
---|
| 10 | // | it under the terms of the GNU General Public License as published by | |
---|
| 11 | // | the Free Software Foundation | |
---|
| 12 | // | | |
---|
| 13 | // | This program is distributed in the hope that it will be useful, but | |
---|
| 14 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
| 15 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
| 16 | // | General Public License for more details. | |
---|
| 17 | // | | |
---|
| 18 | // | You should have received a copy of the GNU General Public License | |
---|
| 19 | // | along with this program; if not, write to the Free Software | |
---|
| 20 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
| 21 | // | USA. | |
---|
| 22 | // +-----------------------------------------------------------------------+ |
---|
[604] | 23 | |
---|
| 24 | if (!defined('PHPWG_ROOT_PATH')) |
---|
| 25 | { |
---|
| 26 | die ("Hacking attempt!"); |
---|
| 27 | } |
---|
[817] | 28 | |
---|
[1072] | 29 | include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); |
---|
[2226] | 30 | include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php'); |
---|
[1072] | 31 | |
---|
[604] | 32 | // +-----------------------------------------------------------------------+ |
---|
[1072] | 33 | // | Check Access and exit when user status is not ok | |
---|
| 34 | // +-----------------------------------------------------------------------+ |
---|
| 35 | check_status(ACCESS_ADMINISTRATOR); |
---|
| 36 | |
---|
| 37 | // +-----------------------------------------------------------------------+ |
---|
[604] | 38 | // | modification registration | |
---|
| 39 | // +-----------------------------------------------------------------------+ |
---|
[817] | 40 | |
---|
[604] | 41 | // print '<pre>'; |
---|
| 42 | // print_r($_POST); |
---|
| 43 | // print '</pre>'; |
---|
[627] | 44 | if (isset($_POST['falsify']) |
---|
| 45 | and isset($_POST['cat_true']) |
---|
| 46 | and count($_POST['cat_true']) > 0) |
---|
[604] | 47 | { |
---|
| 48 | switch ($_GET['section']) |
---|
| 49 | { |
---|
[1877] | 50 | case 'comments' : |
---|
| 51 | { |
---|
| 52 | $query = ' |
---|
| 53 | UPDATE '.CATEGORIES_TABLE.' |
---|
| 54 | SET commentable = \'false\' |
---|
| 55 | WHERE id IN ('.implode(',', $_POST['cat_true']).') |
---|
| 56 | ;'; |
---|
| 57 | pwg_query($query); |
---|
| 58 | break; |
---|
| 59 | } |
---|
[604] | 60 | case 'visible' : |
---|
| 61 | { |
---|
[632] | 62 | set_cat_visible($_POST['cat_true'], 'false'); |
---|
[614] | 63 | break; |
---|
| 64 | } |
---|
| 65 | case 'status' : |
---|
| 66 | { |
---|
[632] | 67 | set_cat_status($_POST['cat_true'], 'private'); |
---|
[614] | 68 | break; |
---|
| 69 | } |
---|
[809] | 70 | case 'representative' : |
---|
| 71 | { |
---|
| 72 | $query = ' |
---|
| 73 | UPDATE '.CATEGORIES_TABLE.' |
---|
| 74 | SET representative_picture_id = NULL |
---|
| 75 | WHERE id IN ('.implode(',', $_POST['cat_true']).') |
---|
| 76 | ;'; |
---|
| 77 | pwg_query($query); |
---|
| 78 | break; |
---|
| 79 | } |
---|
[614] | 80 | } |
---|
| 81 | } |
---|
[627] | 82 | else if (isset($_POST['trueify']) |
---|
| 83 | and isset($_POST['cat_false']) |
---|
| 84 | and count($_POST['cat_false']) > 0) |
---|
[614] | 85 | { |
---|
| 86 | switch ($_GET['section']) |
---|
| 87 | { |
---|
[1877] | 88 | case 'comments' : |
---|
| 89 | { |
---|
| 90 | $query = ' |
---|
| 91 | UPDATE '.CATEGORIES_TABLE.' |
---|
| 92 | SET commentable = \'true\' |
---|
| 93 | WHERE id IN ('.implode(',', $_POST['cat_false']).') |
---|
| 94 | ;'; |
---|
| 95 | pwg_query($query); |
---|
| 96 | break; |
---|
| 97 | } |
---|
[614] | 98 | case 'visible' : |
---|
| 99 | { |
---|
[632] | 100 | set_cat_visible($_POST['cat_false'], 'true'); |
---|
[604] | 101 | break; |
---|
| 102 | } |
---|
| 103 | case 'status' : |
---|
| 104 | { |
---|
[632] | 105 | set_cat_status($_POST['cat_false'], 'public'); |
---|
[604] | 106 | break; |
---|
| 107 | } |
---|
[809] | 108 | case 'representative' : |
---|
| 109 | { |
---|
| 110 | // theoretically, all categories in $_POST['cat_false'] contain at |
---|
[2339] | 111 | // least one element, so Piwigo can find a representant. |
---|
[809] | 112 | set_random_representant($_POST['cat_false']); |
---|
| 113 | break; |
---|
| 114 | } |
---|
[604] | 115 | } |
---|
| 116 | } |
---|
[817] | 117 | |
---|
[604] | 118 | // +-----------------------------------------------------------------------+ |
---|
| 119 | // | template init | |
---|
| 120 | // +-----------------------------------------------------------------------+ |
---|
| 121 | |
---|
[817] | 122 | $template->set_filenames( |
---|
| 123 | array( |
---|
[2530] | 124 | 'cat_options' => 'cat_options.tpl', |
---|
| 125 | 'double_select' => 'double_select.tpl' |
---|
[817] | 126 | ) |
---|
| 127 | ); |
---|
[604] | 128 | |
---|
[2223] | 129 | $page['section'] = isset($_GET['section']) ? $_GET['section'] : 'status'; |
---|
[604] | 130 | $base_url = PHPWG_ROOT_PATH.'admin.php?page=cat_options&section='; |
---|
[817] | 131 | |
---|
[2223] | 132 | $template->assign( |
---|
[604] | 133 | array( |
---|
[5920] | 134 | 'U_HELP' => get_root_url().'admin/popuphelp.php?page=cat_options', |
---|
[1004] | 135 | 'F_ACTION'=>$base_url.$page['section'] |
---|
[604] | 136 | ) |
---|
| 137 | ); |
---|
| 138 | |
---|
[2226] | 139 | // TabSheet |
---|
| 140 | $tabsheet = new tabsheet(); |
---|
[1878] | 141 | // TabSheet initialization |
---|
| 142 | $opt_link = $link_start.'cat_options&section='; |
---|
[5021] | 143 | $tabsheet->add('status', l10n('Public / Private'), $opt_link.'status'); |
---|
| 144 | $tabsheet->add('visible', l10n('Lock'), $opt_link.'visible'); |
---|
[5036] | 145 | $tabsheet->add('comments', l10n('Comments'), $opt_link.'comments'); |
---|
[1878] | 146 | if ($conf['allow_random_representative']) |
---|
| 147 | { |
---|
[2226] | 148 | $tabsheet->add('representative', l10n('Representative'), $opt_link.'representative'); |
---|
[1878] | 149 | } |
---|
[2226] | 150 | // TabSheet selection |
---|
| 151 | $tabsheet->select($page['section']); |
---|
[1878] | 152 | // Assign tabsheet to template |
---|
[2226] | 153 | $tabsheet->assign(); |
---|
[1878] | 154 | |
---|
[604] | 155 | // +-----------------------------------------------------------------------+ |
---|
| 156 | // | form display | |
---|
| 157 | // +-----------------------------------------------------------------------+ |
---|
| 158 | |
---|
| 159 | // for each section, categories in the multiselect field can be : |
---|
| 160 | // |
---|
[8651] | 161 | // - true : commentable for comment section |
---|
| 162 | // - false : un-commentable for comment section |
---|
[604] | 163 | // - NA : (not applicable) for virtual categories |
---|
| 164 | // |
---|
| 165 | // for true and false status, we associates an array of category ids, |
---|
| 166 | // function display_select_categories will use the given CSS class for each |
---|
| 167 | // option |
---|
| 168 | $cats_true = array(); |
---|
| 169 | $cats_false = array(); |
---|
| 170 | switch ($page['section']) |
---|
| 171 | { |
---|
[1877] | 172 | case 'comments' : |
---|
| 173 | { |
---|
| 174 | $query_true = ' |
---|
| 175 | SELECT id,name,uppercats,global_rank |
---|
| 176 | FROM '.CATEGORIES_TABLE.' |
---|
| 177 | WHERE commentable = \'true\' |
---|
| 178 | ;'; |
---|
| 179 | $query_false = ' |
---|
| 180 | SELECT id,name,uppercats,global_rank |
---|
| 181 | FROM '.CATEGORIES_TABLE.' |
---|
| 182 | WHERE commentable = \'false\' |
---|
| 183 | ;'; |
---|
[2223] | 184 | $template->assign( |
---|
[1877] | 185 | array( |
---|
[6993] | 186 | 'L_SECTION' => l10n('Authorize users to add comments on selected albums'), |
---|
[5021] | 187 | 'L_CAT_OPTIONS_TRUE' => l10n('Authorized'), |
---|
| 188 | 'L_CAT_OPTIONS_FALSE' => l10n('Forbidden'), |
---|
[1877] | 189 | ) |
---|
| 190 | ); |
---|
| 191 | break; |
---|
| 192 | } |
---|
[604] | 193 | case 'visible' : |
---|
| 194 | { |
---|
[614] | 195 | $query_true = ' |
---|
| 196 | SELECT id,name,uppercats,global_rank |
---|
[604] | 197 | FROM '.CATEGORIES_TABLE.' |
---|
| 198 | WHERE visible = \'true\' |
---|
| 199 | ;'; |
---|
[614] | 200 | $query_false = ' |
---|
| 201 | SELECT id,name,uppercats,global_rank |
---|
[604] | 202 | FROM '.CATEGORIES_TABLE.' |
---|
| 203 | WHERE visible = \'false\' |
---|
| 204 | ;'; |
---|
[2223] | 205 | $template->assign( |
---|
[614] | 206 | array( |
---|
[6969] | 207 | 'L_SECTION' => l10n('Lock albums'), |
---|
[5021] | 208 | 'L_CAT_OPTIONS_TRUE' => l10n('Unlocked'), |
---|
| 209 | 'L_CAT_OPTIONS_FALSE' => l10n('Locked'), |
---|
[614] | 210 | ) |
---|
| 211 | ); |
---|
[604] | 212 | break; |
---|
| 213 | } |
---|
| 214 | case 'status' : |
---|
| 215 | { |
---|
[614] | 216 | $query_true = ' |
---|
| 217 | SELECT id,name,uppercats,global_rank |
---|
[604] | 218 | FROM '.CATEGORIES_TABLE.' |
---|
| 219 | WHERE status = \'public\' |
---|
| 220 | ;'; |
---|
[614] | 221 | $query_false = ' |
---|
| 222 | SELECT id,name,uppercats,global_rank |
---|
[604] | 223 | FROM '.CATEGORIES_TABLE.' |
---|
| 224 | WHERE status = \'private\' |
---|
| 225 | ;'; |
---|
[2223] | 226 | $template->assign( |
---|
[614] | 227 | array( |
---|
[6993] | 228 | 'L_SECTION' => l10n('Manage authorizations for selected albums'), |
---|
[6969] | 229 | 'L_CAT_OPTIONS_TRUE' => l10n('Public'), |
---|
| 230 | 'L_CAT_OPTIONS_FALSE' => l10n('Private'), |
---|
[614] | 231 | ) |
---|
| 232 | ); |
---|
[604] | 233 | break; |
---|
| 234 | } |
---|
[809] | 235 | case 'representative' : |
---|
| 236 | { |
---|
| 237 | $query_true = ' |
---|
| 238 | SELECT id,name,uppercats,global_rank |
---|
| 239 | FROM '.CATEGORIES_TABLE.' |
---|
| 240 | WHERE representative_picture_id IS NOT NULL |
---|
| 241 | ;'; |
---|
| 242 | $query_false = ' |
---|
[2324] | 243 | SELECT DISTINCT id,name,uppercats,global_rank |
---|
| 244 | FROM '.CATEGORIES_TABLE.' INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON id=category_id |
---|
| 245 | WHERE representative_picture_id IS NULL |
---|
[809] | 246 | ;'; |
---|
[2223] | 247 | $template->assign( |
---|
[809] | 248 | array( |
---|
[817] | 249 | 'L_SECTION' => l10n('Representative'), |
---|
[809] | 250 | 'L_CAT_OPTIONS_TRUE' => l10n('singly represented'), |
---|
[862] | 251 | 'L_CAT_OPTIONS_FALSE' => l10n('randomly represented') |
---|
[809] | 252 | ) |
---|
| 253 | ); |
---|
| 254 | break; |
---|
| 255 | } |
---|
[604] | 256 | } |
---|
[614] | 257 | display_select_cat_wrapper($query_true,array(),'category_option_true'); |
---|
| 258 | display_select_cat_wrapper($query_false,array(),'category_option_false'); |
---|
[817] | 259 | |
---|
[604] | 260 | // +-----------------------------------------------------------------------+ |
---|
| 261 | // | sending html code | |
---|
| 262 | // +-----------------------------------------------------------------------+ |
---|
[817] | 263 | |
---|
| 264 | $template->assign_var_from_handle('DOUBLE_SELECT', 'double_select'); |
---|
[604] | 265 | $template->assign_var_from_handle('ADMIN_CONTENT', 'cat_options'); |
---|
| 266 | ?> |
---|