source: trunk/admin/cat_options.php @ 809

Last change on this file since 809 was 809, checked in by plg, 19 years ago
  • new : maintenance screen in administration. There you can update categories informations (number of images, date of the last added element), update images informations (path, average rate), purge obsolete sessions, purge history.
  • new : ability to have random representative for categories. This configuration parameter is set to false by default.
  • new : ability to set an element as representative of a category without belonging to the category. Thus, administrator can choose representative even for empty categories.
  • improvement : semantically superior design for category edition screen by regrouping fields in fieldsets. The improved screen contains action buttons as in category list screen.
  • new : ability to move a virtual category (ie change its parent category).
  • bug fixed : the sync_users function checks all user children tables (access, cache, group association).
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.6 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-13 23:09:54 +0000 (Sat, 13 Aug 2005) $
10// | last modifier : $Author: plg $
11// | revision      : $Revision: 809 $
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// |                       modification registration                       |
35// +-----------------------------------------------------------------------+
36// print '<pre>';
37// print_r($_POST);
38// print '</pre>';
39if (isset($_POST['falsify'])
40    and isset($_POST['cat_true'])
41    and count($_POST['cat_true']) > 0)
42{
43  switch ($_GET['section'])
44  {
45    case 'upload' :
46    {
47      $query = '
48UPDATE '.CATEGORIES_TABLE.'
49  SET uploadable = \'false\'
50  WHERE id IN ('.implode(',', $_POST['cat_true']).')
51;';
52      pwg_query($query);
53      break;
54    }
55    case 'comments' :
56    {
57      $query = '
58UPDATE '.CATEGORIES_TABLE.'
59  SET commentable = \'false\'
60  WHERE id IN ('.implode(',', $_POST['cat_true']).')
61;';
62      pwg_query($query);
63      break;
64    }
65    case 'visible' :
66    {
67      set_cat_visible($_POST['cat_true'], 'false');
68      break;
69    }
70    case 'status' :
71    {
72      set_cat_status($_POST['cat_true'], 'private');
73      break;
74    }
75    case 'representative' :
76    {
77      $query = '
78UPDATE '.CATEGORIES_TABLE.'
79  SET representative_picture_id = NULL
80  WHERE id IN ('.implode(',', $_POST['cat_true']).')
81;';
82      pwg_query($query);
83      break;
84    }
85  }
86}
87else if (isset($_POST['trueify'])
88         and isset($_POST['cat_false'])
89         and count($_POST['cat_false']) > 0)
90{
91  switch ($_GET['section'])
92  {
93    case 'upload' :
94    {
95      $query = '
96UPDATE '.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 = '
106UPDATE '.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    {
115      set_cat_visible($_POST['cat_false'], 'true');
116      break;
117    }
118    case 'status' :
119    {
120      set_cat_status($_POST['cat_false'], 'public');
121      break;
122    }
123    case 'representative' :
124    {
125      // theoretically, all categories in $_POST['cat_false'] contain at
126      // least one element, so PhpWebGallery can find a representant.
127      set_random_representant($_POST['cat_false']);
128      break;
129    }
130  }
131}
132// +-----------------------------------------------------------------------+
133// |                             template init                             |
134// +-----------------------------------------------------------------------+
135$template->set_filenames(array('cat_options'=>'admin/cat_options.tpl'));
136
137if (!isset($_GET['section']))
138{
139  $page['section'] = 'upload';
140}
141else
142{
143  $page['section'] = $_GET['section'];
144}
145
146$base_url = PHPWG_ROOT_PATH.'admin.php?page=cat_options&amp;section=';
147$template->assign_vars(
148  array(
149    'L_SUBMIT'=>$lang['submit'],
150    'L_RESET'=>$lang['reset'],
151   
152    'F_ACTION'=>add_session_id($base_url.$page['section'])
153   )
154 );
155
156$template->assign_vars(array(strtoupper($page['section']).'_CLASS'=>'opened'));
157// +-----------------------------------------------------------------------+
158// |                              form display                             |
159// +-----------------------------------------------------------------------+
160
161// for each section, categories in the multiselect field can be :
162//
163// - true : uploadable for upload section
164// - false : un-uploadable for upload section
165// - NA : (not applicable) for virtual categories
166//
167// for true and false status, we associates an array of category ids,
168// function display_select_categories will use the given CSS class for each
169// option
170$cats_true = array();
171$cats_false = array();
172switch ($page['section'])
173{
174  case 'upload' :
175  {
176    $query_true = '
177SELECT id,name,uppercats,global_rank
178  FROM '.CATEGORIES_TABLE.'
179  WHERE uploadable = \'true\'
180    AND dir IS NOT NULL
181    AND site_id = 1
182;';
183    $query_false = '
184SELECT id,name,uppercats,global_rank
185  FROM '.CATEGORIES_TABLE.'
186  WHERE uploadable = \'false\'
187    AND dir IS NOT NULL
188    AND site_id = 1
189;';
190    $template->assign_vars(
191      array(
192        'L_CAT_TITLE' => $lang['cat_upload_title'],
193        'L_CAT_OPTIONS_TRUE' => $lang['authorized'],
194        'L_CAT_OPTIONS_FALSE' => $lang['forbidden'],
195        'L_CAT_OPTIONS_INFO' => $lang['cat_upload_info'],
196        )
197      );
198    break;
199  }
200  case 'comments' :
201  {
202    $query_true = '
203SELECT id,name,uppercats,global_rank
204  FROM '.CATEGORIES_TABLE.'
205  WHERE commentable = \'true\'
206;';
207    $query_false = '
208SELECT id,name,uppercats,global_rank
209  FROM '.CATEGORIES_TABLE.'
210  WHERE commentable = \'false\'
211;';
212    $template->assign_vars(
213      array(
214        'L_CAT_TITLE' => $lang['cat_comments_title'],
215        'L_CAT_OPTIONS_TRUE' => $lang['authorized'],
216        'L_CAT_OPTIONS_FALSE' => $lang['forbidden'],
217        'L_CAT_OPTIONS_INFO' => $lang['cat_comments_info'],
218        )
219      );
220    break;
221  }
222  case 'visible' :
223  {
224    $query_true = '
225SELECT id,name,uppercats,global_rank
226  FROM '.CATEGORIES_TABLE.'
227  WHERE visible = \'true\'
228;';
229    $query_false = '
230SELECT id,name,uppercats,global_rank
231  FROM '.CATEGORIES_TABLE.'
232  WHERE visible = \'false\'
233;';
234    $template->assign_vars(
235      array(
236        'L_CAT_TITLE' => $lang['cat_lock_title'],
237        'L_CAT_OPTIONS_TRUE' => $lang['unlocked'],
238        'L_CAT_OPTIONS_FALSE' => $lang['locked'],
239        'L_CAT_OPTIONS_INFO' => $lang['cat_lock_info'],
240        )
241      );
242    break;
243  }
244  case 'status' :
245  {
246    $query_true = '
247SELECT id,name,uppercats,global_rank
248  FROM '.CATEGORIES_TABLE.'
249  WHERE status = \'public\'
250;';
251    $query_false = '
252SELECT id,name,uppercats,global_rank
253  FROM '.CATEGORIES_TABLE.'
254  WHERE status = \'private\'
255;';
256    $template->assign_vars(
257      array(
258        'L_CAT_TITLE' => $lang['cat_status_title'],
259        'L_CAT_OPTIONS_TRUE' => $lang['cat_public'],
260        'L_CAT_OPTIONS_FALSE' => $lang['cat_private'],
261        'L_CAT_OPTIONS_INFO' => $lang['cat_status_info'],
262        )
263      );
264    break;
265  }
266  case 'representative' :
267  {
268    $query_true = '
269SELECT id,name,uppercats,global_rank
270  FROM '.CATEGORIES_TABLE.'
271  WHERE representative_picture_id IS NOT NULL
272;';
273    $query_false = '
274SELECT id,name,uppercats,global_rank
275  FROM '.CATEGORIES_TABLE.'
276  WHERE nb_images != 0
277    AND representative_picture_id IS NULL
278;';
279    $template->assign_vars(
280      array(
281        'L_CAT_TITLE' => l10n('Representative'),
282        'L_CAT_OPTIONS_TRUE' => l10n('singly represented'),
283        'L_CAT_OPTIONS_FALSE' => l10n('randomly represented'),
284        'L_CAT_OPTIONS_INFO' => l10n('')
285        )
286      );
287    break;
288  }
289}
290display_select_cat_wrapper($query_true,array(),'category_option_true');
291display_select_cat_wrapper($query_false,array(),'category_option_false');
292// +-----------------------------------------------------------------------+
293// |                           sending html code                           |
294// +-----------------------------------------------------------------------+
295$template->assign_var_from_handle('ADMIN_CONTENT', 'cat_options');
296?>
Note: See TracBrowser for help on using the repository browser.