source: trunk/admin/cat_options.php @ 632

Last change on this file since 632 was 632, checked in by plg, 19 years ago
  • change "->" in a beautiful arrow :-) for categories level in admin
  • single category management screen updated : commentable and uploadable properties added, full directory displayed, status and visibility properties update uses inheritance, user favorite elements check moved to somewhere else : would be too long to calculate here for too many users
  • new admin functions set_cat_visible and set_cat_status : visibility and status updates can be done in cat_options and cat_modify
  • language : differentiate "locked" (state) and "lock" (action)
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.8 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-2004 PhpWebGallery Team - http://phpwebgallery.net |
6// +-----------------------------------------------------------------------+
7// | branch        : BSF (Best So Far)
8// | file          : $RCSfile$
9// | last update   : $Date: 2004-12-04 12:10:17 +0000 (Sat, 04 Dec 2004) $
10// | last modifier : $Author: plg $
11// | revision      : $Revision: 632 $
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  }
76}
77else if (isset($_POST['trueify'])
78         and isset($_POST['cat_false'])
79         and count($_POST['cat_false']) > 0)
80{
81  switch ($_GET['section'])
82  {
83    case 'upload' :
84    {
85      $query = '
86UPDATE '.CATEGORIES_TABLE.'
87  SET uploadable = \'true\'
88  WHERE id IN ('.implode(',', $_POST['cat_false']).')
89;';
90      pwg_query($query);
91      break;
92    }
93    case 'comments' :
94    {
95      $query = '
96UPDATE '.CATEGORIES_TABLE.'
97  SET commentable = \'true\'
98  WHERE id IN ('.implode(',', $_POST['cat_false']).')
99;';
100      pwg_query($query);
101      break;
102    }
103    case 'visible' :
104    {
105      set_cat_visible($_POST['cat_false'], 'true');
106      break;
107    }
108    case 'status' :
109    {
110      set_cat_status($_POST['cat_false'], 'public');
111      break;
112    }
113  }
114}
115// +-----------------------------------------------------------------------+
116// |                             template init                             |
117// +-----------------------------------------------------------------------+
118$template->set_filenames(array('cat_options'=>'admin/cat_options.tpl'));
119
120if (!isset($_GET['section']))
121{
122  $page['section'] = 'upload';
123}
124else
125{
126  $page['section'] = $_GET['section'];
127}
128
129$base_url = PHPWG_ROOT_PATH.'admin.php?page=cat_options&amp;section=';
130$template->assign_vars(
131  array(
132    'L_SUBMIT'=>$lang['submit'],
133    'L_RESET'=>$lang['reset'],
134   
135    'F_ACTION'=>add_session_id($base_url.$page['section'])
136   )
137 );
138
139$template->assign_vars(array(strtoupper($page['section']).'_CLASS'=>'opened'));
140// +-----------------------------------------------------------------------+
141// |                              form display                             |
142// +-----------------------------------------------------------------------+
143
144// for each section, categories in the multiselect field can be :
145//
146// - true : uploadable for upload section
147// - false : un-uploadable for upload section
148// - NA : (not applicable) for virtual categories
149//
150// for true and false status, we associates an array of category ids,
151// function display_select_categories will use the given CSS class for each
152// option
153$cats_true = array();
154$cats_false = array();
155switch ($page['section'])
156{
157  case 'upload' :
158  {
159    $query_true = '
160SELECT id,name,uppercats,global_rank
161  FROM '.CATEGORIES_TABLE.'
162  WHERE uploadable = \'true\'
163    AND dir IS NOT NULL
164    AND site_id = 1
165;';
166    $query_false = '
167SELECT id,name,uppercats,global_rank
168  FROM '.CATEGORIES_TABLE.'
169  WHERE uploadable = \'false\'
170    AND dir IS NOT NULL
171    AND site_id = 1
172;';
173    $template->assign_vars(
174      array(
175        'L_CAT_TITLE' => $lang['cat_upload_title'],
176        'L_CAT_OPTIONS_TRUE' => $lang['authorized'],
177        'L_CAT_OPTIONS_FALSE' => $lang['forbidden'],
178        'L_CAT_OPTIONS_INFO' => $lang['cat_upload_info'],
179        )
180      );
181    $template->assign_block_vars('upload', array());
182    break;
183  }
184  case 'comments' :
185  {
186    $query_true = '
187SELECT id,name,uppercats,global_rank
188  FROM '.CATEGORIES_TABLE.'
189  WHERE commentable = \'true\'
190;';
191    $query_false = '
192SELECT id,name,uppercats,global_rank
193  FROM '.CATEGORIES_TABLE.'
194  WHERE commentable = \'false\'
195;';
196    $template->assign_vars(
197      array(
198        'L_CAT_TITLE' => $lang['cat_comments_title'],
199        'L_CAT_OPTIONS_TRUE' => $lang['authorized'],
200        'L_CAT_OPTIONS_FALSE' => $lang['forbidden'],
201        'L_CAT_OPTIONS_INFO' => $lang['cat_comments_info'],
202        )
203      );
204    $template->assign_block_vars('comments', array());
205    break;
206  }
207  case 'visible' :
208  {
209    $query_true = '
210SELECT id,name,uppercats,global_rank
211  FROM '.CATEGORIES_TABLE.'
212  WHERE visible = \'true\'
213;';
214    $query_false = '
215SELECT id,name,uppercats,global_rank
216  FROM '.CATEGORIES_TABLE.'
217  WHERE visible = \'false\'
218;';
219    $template->assign_vars(
220      array(
221        'L_CAT_TITLE' => $lang['cat_lock_title'],
222        'L_CAT_OPTIONS_TRUE' => $lang['unlocked'],
223        'L_CAT_OPTIONS_FALSE' => $lang['locked'],
224        'L_CAT_OPTIONS_INFO' => $lang['cat_lock_info'],
225        )
226      );
227    $template->assign_block_vars('visible', array());
228    break;
229  }
230  case 'status' :
231  {
232    $query_true = '
233SELECT id,name,uppercats,global_rank
234  FROM '.CATEGORIES_TABLE.'
235  WHERE status = \'public\'
236;';
237    $query_false = '
238SELECT id,name,uppercats,global_rank
239  FROM '.CATEGORIES_TABLE.'
240  WHERE status = \'private\'
241;';
242    $template->assign_vars(
243      array(
244        'L_CAT_TITLE' => $lang['cat_status_title'],
245        'L_CAT_OPTIONS_TRUE' => $lang['cat_public'],
246        'L_CAT_OPTIONS_FALSE' => $lang['cat_private'],
247        'L_CAT_OPTIONS_INFO' => $lang['cat_status_info'],
248        )
249      );
250    $template->assign_block_vars('status', array());
251    break;
252  }
253}
254display_select_cat_wrapper($query_true,array(),'category_option_true');
255display_select_cat_wrapper($query_false,array(),'category_option_false');
256// +-----------------------------------------------------------------------+
257// |                           sending html code                           |
258// +-----------------------------------------------------------------------+
259$template->assign_var_from_handle('ADMIN_CONTENT', 'cat_options');
260?>
Note: See TracBrowser for help on using the repository browser.