source: trunk/admin/cat_options.php @ 6993

Last change on this file since 6993 was 6993, checked in by rvelices, 14 years ago

feature 1616: rename "category" into "album" (4th commit; almost there)

  • Property svn:eol-style set to LF
File size: 9.3 KB
RevLine 
[604]1<?php
2// +-----------------------------------------------------------------------+
[2297]3// | Piwigo - a PHP based picture gallery                                  |
4// +-----------------------------------------------------------------------+
[5196]5// | Copyright(C) 2008-2010 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
24if (!defined('PHPWG_ROOT_PATH'))
25{
26  die ("Hacking attempt!");
27}
[817]28
[1072]29include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
[2226]30include_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// +-----------------------------------------------------------------------+
35check_status(ACCESS_ADMINISTRATOR);
36
37// +-----------------------------------------------------------------------+
[604]38// |                       modification registration                       |
39// +-----------------------------------------------------------------------+
[817]40
[604]41// print '<pre>';
42// print_r($_POST);
43// print '</pre>';
[627]44if (isset($_POST['falsify'])
45    and isset($_POST['cat_true'])
46    and count($_POST['cat_true']) > 0)
[604]47{
48  switch ($_GET['section'])
49  {
50    case 'upload' :
51    {
52      $query = '
53UPDATE '.CATEGORIES_TABLE.'
[614]54  SET uploadable = \'false\'
55  WHERE id IN ('.implode(',', $_POST['cat_true']).')
[604]56;';
57      pwg_query($query);
58      break;
59    }
[1877]60    case 'comments' :
61    {
62      $query = '
63UPDATE '.CATEGORIES_TABLE.'
64  SET commentable = \'false\'
65  WHERE id IN ('.implode(',', $_POST['cat_true']).')
66;';
67      pwg_query($query);
68      break;
69    }
[604]70    case 'visible' :
71    {
[632]72      set_cat_visible($_POST['cat_true'], 'false');
[614]73      break;
74    }
75    case 'status' :
76    {
[632]77      set_cat_status($_POST['cat_true'], 'private');
[614]78      break;
79    }
[809]80    case 'representative' :
81    {
82      $query = '
83UPDATE '.CATEGORIES_TABLE.'
84  SET representative_picture_id = NULL
85  WHERE id IN ('.implode(',', $_POST['cat_true']).')
86;';
87      pwg_query($query);
88      break;
89    }
[614]90  }
91}
[627]92else if (isset($_POST['trueify'])
93         and isset($_POST['cat_false'])
94         and count($_POST['cat_false']) > 0)
[614]95{
96  switch ($_GET['section'])
97  {
98    case 'upload' :
99    {
100      $query = '
101UPDATE '.CATEGORIES_TABLE.'
102  SET uploadable = \'true\'
103  WHERE id IN ('.implode(',', $_POST['cat_false']).')
104;';
105      pwg_query($query);
106      break;
107    }
[1877]108    case 'comments' :
109    {
110      $query = '
111UPDATE '.CATEGORIES_TABLE.'
112  SET commentable = \'true\'
113  WHERE id IN ('.implode(',', $_POST['cat_false']).')
114;';
115      pwg_query($query);
116      break;
117    }
[614]118    case 'visible' :
119    {
[632]120      set_cat_visible($_POST['cat_false'], 'true');
[604]121      break;
122    }
123    case 'status' :
124    {
[632]125      set_cat_status($_POST['cat_false'], 'public');
[604]126      break;
127    }
[809]128    case 'representative' :
129    {
130      // theoretically, all categories in $_POST['cat_false'] contain at
[2339]131      // least one element, so Piwigo can find a representant.
[809]132      set_random_representant($_POST['cat_false']);
133      break;
134    }
[604]135  }
136}
[817]137
[604]138// +-----------------------------------------------------------------------+
139// |                             template init                             |
140// +-----------------------------------------------------------------------+
141
[817]142$template->set_filenames(
143  array(
[2530]144    'cat_options' => 'cat_options.tpl',
145    'double_select' => 'double_select.tpl'
[817]146    )
147  );
[604]148
[2223]149$page['section'] = isset($_GET['section']) ? $_GET['section'] : 'status';
[604]150$base_url = PHPWG_ROOT_PATH.'admin.php?page=cat_options&amp;section=';
[817]151
[2223]152$template->assign(
[604]153  array(
[5920]154    'U_HELP' => get_root_url().'admin/popuphelp.php?page=cat_options',
[1004]155    'F_ACTION'=>$base_url.$page['section']
[604]156   )
157 );
158
[2226]159// TabSheet
160$tabsheet = new tabsheet();
[1878]161// TabSheet initialization
162$opt_link = $link_start.'cat_options&amp;section=';
[5021]163$tabsheet->add('status', l10n('Public / Private'), $opt_link.'status');
164$tabsheet->add('visible', l10n('Lock'), $opt_link.'visible');
[6365]165if ($conf['enable_synchronization'])
166{
167  $tabsheet->add('upload', l10n('Upload'), $opt_link.'upload');
168}
[5036]169$tabsheet->add('comments', l10n('Comments'), $opt_link.'comments');
[1878]170if ($conf['allow_random_representative'])
171{
[2226]172  $tabsheet->add('representative', l10n('Representative'), $opt_link.'representative');
[1878]173}
[2226]174// TabSheet selection
175$tabsheet->select($page['section']);
[1878]176// Assign tabsheet to template
[2226]177$tabsheet->assign();
[1878]178
[604]179// +-----------------------------------------------------------------------+
180// |                              form display                             |
181// +-----------------------------------------------------------------------+
182
183// for each section, categories in the multiselect field can be :
184//
185// - true : uploadable for upload section
186// - false : un-uploadable for upload section
187// - NA : (not applicable) for virtual categories
188//
189// for true and false status, we associates an array of category ids,
190// function display_select_categories will use the given CSS class for each
191// option
192$cats_true = array();
193$cats_false = array();
194switch ($page['section'])
195{
196  case 'upload' :
197  {
[614]198    $query_true = '
199SELECT id,name,uppercats,global_rank
[604]200  FROM '.CATEGORIES_TABLE.'
201  WHERE uploadable = \'true\'
202    AND dir IS NOT NULL
203    AND site_id = 1
204;';
[614]205    $query_false = '
206SELECT id,name,uppercats,global_rank
[604]207  FROM '.CATEGORIES_TABLE.'
208  WHERE uploadable = \'false\'
209    AND dir IS NOT NULL
210    AND site_id = 1
211;';
[2223]212    $template->assign(
[614]213      array(
[6993]214        'L_SECTION' => l10n('Select uploadable albums'),
[5021]215        'L_CAT_OPTIONS_TRUE' => l10n('Authorized'),
216        'L_CAT_OPTIONS_FALSE' => l10n('Forbidden'),
[614]217        )
218      );
[604]219    break;
220  }
[1877]221  case 'comments' :
222  {
223    $query_true = '
224SELECT id,name,uppercats,global_rank
225  FROM '.CATEGORIES_TABLE.'
226  WHERE commentable = \'true\'
227;';
228    $query_false = '
229SELECT id,name,uppercats,global_rank
230  FROM '.CATEGORIES_TABLE.'
231  WHERE commentable = \'false\'
232;';
[2223]233    $template->assign(
[1877]234      array(
[6993]235        'L_SECTION' => l10n('Authorize users to add comments on selected albums'),
[5021]236        'L_CAT_OPTIONS_TRUE' => l10n('Authorized'),
237        'L_CAT_OPTIONS_FALSE' => l10n('Forbidden'),
[1877]238        )
239      );
240    break;
241  }
[604]242  case 'visible' :
243  {
[614]244    $query_true = '
245SELECT id,name,uppercats,global_rank
[604]246  FROM '.CATEGORIES_TABLE.'
247  WHERE visible = \'true\'
248;';
[614]249    $query_false = '
250SELECT id,name,uppercats,global_rank
[604]251  FROM '.CATEGORIES_TABLE.'
252  WHERE visible = \'false\'
253;';
[2223]254    $template->assign(
[614]255      array(
[6969]256        'L_SECTION' => l10n('Lock albums'),
[5021]257        'L_CAT_OPTIONS_TRUE' => l10n('Unlocked'),
258        'L_CAT_OPTIONS_FALSE' => l10n('Locked'),
[614]259        )
260      );
[604]261    break;
262  }
263  case 'status' :
264  {
[614]265    $query_true = '
266SELECT id,name,uppercats,global_rank
[604]267  FROM '.CATEGORIES_TABLE.'
268  WHERE status = \'public\'
269;';
[614]270    $query_false = '
271SELECT id,name,uppercats,global_rank
[604]272  FROM '.CATEGORIES_TABLE.'
273  WHERE status = \'private\'
274;';
[2223]275    $template->assign(
[614]276      array(
[6993]277        'L_SECTION' => l10n('Manage authorizations for selected albums'),
[6969]278        'L_CAT_OPTIONS_TRUE' => l10n('Public'),
279        'L_CAT_OPTIONS_FALSE' => l10n('Private'),
[614]280        )
281      );
[604]282    break;
283  }
[809]284  case 'representative' :
285  {
286    $query_true = '
287SELECT id,name,uppercats,global_rank
288  FROM '.CATEGORIES_TABLE.'
289  WHERE representative_picture_id IS NOT NULL
290;';
291    $query_false = '
[2324]292SELECT DISTINCT id,name,uppercats,global_rank
293  FROM '.CATEGORIES_TABLE.' INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON id=category_id
294  WHERE representative_picture_id IS NULL
[809]295;';
[2223]296    $template->assign(
[809]297      array(
[817]298        'L_SECTION' => l10n('Representative'),
[809]299        'L_CAT_OPTIONS_TRUE' => l10n('singly represented'),
[862]300        'L_CAT_OPTIONS_FALSE' => l10n('randomly represented')
[809]301        )
302      );
303    break;
304  }
[604]305}
[614]306display_select_cat_wrapper($query_true,array(),'category_option_true');
307display_select_cat_wrapper($query_false,array(),'category_option_false');
[817]308
[604]309// +-----------------------------------------------------------------------+
310// |                           sending html code                           |
311// +-----------------------------------------------------------------------+
[817]312
313$template->assign_var_from_handle('DOUBLE_SELECT', 'double_select');
[604]314$template->assign_var_from_handle('ADMIN_CONTENT', 'cat_options');
315?>
Note: See TracBrowser for help on using the repository browser.