source: trunk/admin/cat_options.php @ 817

Last change on this file since 817 was 817, checked in by plg, 19 years ago
  • modification : major simplification of admin.php. Titles are managed by included page, localized items are managed directly in the template.
  • new : sub template admin/double_select is included in templates admin/cat_options, admin/user_perm and admin/group_perm. I haven't been able to use it in admin/picture_modify because it seems impossible to have two instance of the same sub-template without interfering.
  • modification : bug 99, in profile manager, no auto submit when changing language (useless and generate accessibility problem).
  • improvement : HTML semantically correct for administration menu, simpler syntax, less tags, correct tags (dl/dt/dd instead of div/div).
  • modification : number of waiting elements and unvalidated comments are displayed in admin/intro instead of administration menu (with a link to the dedicated pages).
  • deletion : no link to profile from admin/user_list anymore (no need).
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.7 KB
Line 
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: 2005-08-17 14:25:38 +0000 (Wed, 17 Aug 2005) $
10// | last modifier : $Author: plg $
11// | revision      : $Revision: 817 $
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
28if (!defined('PHPWG_ROOT_PATH'))
29{
30  die ("Hacking attempt!");
31}
32include_once(PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php');
33
34// +-----------------------------------------------------------------------+
35// |                       modification registration                       |
36// +-----------------------------------------------------------------------+
37
38// print '<pre>';
39// print_r($_POST);
40// print '</pre>';
41if (isset($_POST['falsify'])
42    and isset($_POST['cat_true'])
43    and count($_POST['cat_true']) > 0)
44{
45  switch ($_GET['section'])
46  {
47    case 'upload' :
48    {
49      $query = '
50UPDATE '.CATEGORIES_TABLE.'
51  SET uploadable = \'false\'
52  WHERE id IN ('.implode(',', $_POST['cat_true']).')
53;';
54      pwg_query($query);
55      break;
56    }
57    case 'comments' :
58    {
59      $query = '
60UPDATE '.CATEGORIES_TABLE.'
61  SET commentable = \'false\'
62  WHERE id IN ('.implode(',', $_POST['cat_true']).')
63;';
64      pwg_query($query);
65      break;
66    }
67    case 'visible' :
68    {
69      set_cat_visible($_POST['cat_true'], 'false');
70      break;
71    }
72    case 'status' :
73    {
74      set_cat_status($_POST['cat_true'], 'private');
75      break;
76    }
77    case 'representative' :
78    {
79      $query = '
80UPDATE '.CATEGORIES_TABLE.'
81  SET representative_picture_id = NULL
82  WHERE id IN ('.implode(',', $_POST['cat_true']).')
83;';
84      pwg_query($query);
85      break;
86    }
87  }
88}
89else if (isset($_POST['trueify'])
90         and isset($_POST['cat_false'])
91         and count($_POST['cat_false']) > 0)
92{
93  switch ($_GET['section'])
94  {
95    case 'upload' :
96    {
97      $query = '
98UPDATE '.CATEGORIES_TABLE.'
99  SET uploadable = \'true\'
100  WHERE id IN ('.implode(',', $_POST['cat_false']).')
101;';
102      pwg_query($query);
103      break;
104    }
105    case 'comments' :
106    {
107      $query = '
108UPDATE '.CATEGORIES_TABLE.'
109  SET commentable = \'true\'
110  WHERE id IN ('.implode(',', $_POST['cat_false']).')
111;';
112      pwg_query($query);
113      break;
114    }
115    case 'visible' :
116    {
117      set_cat_visible($_POST['cat_false'], 'true');
118      break;
119    }
120    case 'status' :
121    {
122      set_cat_status($_POST['cat_false'], 'public');
123      break;
124    }
125    case 'representative' :
126    {
127      // theoretically, all categories in $_POST['cat_false'] contain at
128      // least one element, so PhpWebGallery can find a representant.
129      set_random_representant($_POST['cat_false']);
130      break;
131    }
132  }
133}
134
135// +-----------------------------------------------------------------------+
136// |                             template init                             |
137// +-----------------------------------------------------------------------+
138
139$template->set_filenames(
140  array(
141    'cat_options' => 'admin/cat_options.tpl',
142    'double_select' => 'admin/double_select.tpl'
143    )
144  );
145
146$page['section'] = isset($_GET['section']) ? $_GET['section'] : 'upload';
147$base_url = PHPWG_ROOT_PATH.'admin.php?page=cat_options&amp;section=';
148
149$template->assign_vars(
150  array(
151    'L_SUBMIT'=>$lang['submit'],
152    'L_RESET'=>$lang['reset'],
153   
154    'F_ACTION'=>add_session_id($base_url.$page['section'])
155   )
156 );
157
158// +-----------------------------------------------------------------------+
159// |                              form display                             |
160// +-----------------------------------------------------------------------+
161
162// for each section, categories in the multiselect field can be :
163//
164// - true : uploadable for upload section
165// - false : un-uploadable for upload section
166// - NA : (not applicable) for virtual categories
167//
168// for true and false status, we associates an array of category ids,
169// function display_select_categories will use the given CSS class for each
170// option
171$cats_true = array();
172$cats_false = array();
173switch ($page['section'])
174{
175  case 'upload' :
176  {
177    $query_true = '
178SELECT id,name,uppercats,global_rank
179  FROM '.CATEGORIES_TABLE.'
180  WHERE uploadable = \'true\'
181    AND dir IS NOT NULL
182    AND site_id = 1
183;';
184    $query_false = '
185SELECT id,name,uppercats,global_rank
186  FROM '.CATEGORIES_TABLE.'
187  WHERE uploadable = \'false\'
188    AND dir IS NOT NULL
189    AND site_id = 1
190;';
191    $template->assign_vars(
192      array(
193        'L_SECTION' => $lang['cat_upload_title'],
194        'L_CAT_OPTIONS_TRUE' => $lang['authorized'],
195        'L_CAT_OPTIONS_FALSE' => $lang['forbidden'],
196        'L_CAT_OPTIONS_INFO' => $lang['cat_upload_info'],
197        )
198      );
199    break;
200  }
201  case 'comments' :
202  {
203    $query_true = '
204SELECT id,name,uppercats,global_rank
205  FROM '.CATEGORIES_TABLE.'
206  WHERE commentable = \'true\'
207;';
208    $query_false = '
209SELECT id,name,uppercats,global_rank
210  FROM '.CATEGORIES_TABLE.'
211  WHERE commentable = \'false\'
212;';
213    $template->assign_vars(
214      array(
215        'L_SECTION' => $lang['cat_comments_title'],
216        'L_CAT_OPTIONS_TRUE' => $lang['authorized'],
217        'L_CAT_OPTIONS_FALSE' => $lang['forbidden'],
218        'L_CAT_OPTIONS_INFO' => $lang['cat_comments_info'],
219        )
220      );
221    break;
222  }
223  case 'visible' :
224  {
225    $query_true = '
226SELECT id,name,uppercats,global_rank
227  FROM '.CATEGORIES_TABLE.'
228  WHERE visible = \'true\'
229;';
230    $query_false = '
231SELECT id,name,uppercats,global_rank
232  FROM '.CATEGORIES_TABLE.'
233  WHERE visible = \'false\'
234;';
235    $template->assign_vars(
236      array(
237        'L_SECTION' => $lang['cat_lock_title'],
238        'L_CAT_OPTIONS_TRUE' => $lang['unlocked'],
239        'L_CAT_OPTIONS_FALSE' => $lang['locked'],
240        'L_CAT_OPTIONS_INFO' => $lang['cat_lock_info'],
241        )
242      );
243    break;
244  }
245  case 'status' :
246  {
247    $query_true = '
248SELECT id,name,uppercats,global_rank
249  FROM '.CATEGORIES_TABLE.'
250  WHERE status = \'public\'
251;';
252    $query_false = '
253SELECT id,name,uppercats,global_rank
254  FROM '.CATEGORIES_TABLE.'
255  WHERE status = \'private\'
256;';
257    $template->assign_vars(
258      array(
259        'L_SECTION' => $lang['cat_status_title'],
260        'L_CAT_OPTIONS_TRUE' => $lang['cat_public'],
261        'L_CAT_OPTIONS_FALSE' => $lang['cat_private'],
262        'L_CAT_OPTIONS_INFO' => $lang['cat_status_info'],
263        )
264      );
265    break;
266  }
267  case 'representative' :
268  {
269    $query_true = '
270SELECT id,name,uppercats,global_rank
271  FROM '.CATEGORIES_TABLE.'
272  WHERE representative_picture_id IS NOT NULL
273;';
274    $query_false = '
275SELECT id,name,uppercats,global_rank
276  FROM '.CATEGORIES_TABLE.'
277  WHERE nb_images != 0
278    AND representative_picture_id IS NULL
279;';
280    $template->assign_vars(
281      array(
282        'L_SECTION' => l10n('Representative'),
283        'L_CAT_OPTIONS_TRUE' => l10n('singly represented'),
284        'L_CAT_OPTIONS_FALSE' => l10n('randomly represented'),
285        'L_CAT_OPTIONS_INFO' => l10n('')
286        )
287      );
288    break;
289  }
290}
291display_select_cat_wrapper($query_true,array(),'category_option_true');
292display_select_cat_wrapper($query_false,array(),'category_option_false');
293
294// +-----------------------------------------------------------------------+
295// |                           sending html code                           |
296// +-----------------------------------------------------------------------+
297
298$template->assign_var_from_handle('DOUBLE_SELECT', 'double_select');
299$template->assign_var_from_handle('ADMIN_CONTENT', 'cat_options');
300?>
Note: See TracBrowser for help on using the repository browser.