source: tags/release-1_5_0RC1/admin/cat_modify.php @ 21188

Last change on this file since 21188 was 862, checked in by plg, 19 years ago
  • improvement: long localized messages are in HTML files instead of $lang array. This is the case of admin/help and about pages.
  • deletion: of unused functions (ts_to_mysqldt, is_image, TN_exists, check_date_format, date_convert, get_category_directories, get_used_metadata_list, array_remove, pwg_write_debug, get_group_restrictions, get_all_group_restrictions, is_group_allowed, style_select, deprecated_getAttribute).
  • new: many new contextual help pages to replace descriptions previously included in pages.
  • modification: reorganisation of language files. Deletion of unused language keys, alphabetical sort. No faq.lang.php anymore (replaced by help.html). Only done for en_UK.iso-8859-1.
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 9.1 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-09-14 21:57:05 +0000 (Wed, 14 Sep 2005) $
10// | last modifier : $Author: plg $
11// | revision      : $Revision: 862 $
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//---------------------------------------------------------------- verification
34if ( !isset( $_GET['cat_id'] ) || !is_numeric( $_GET['cat_id'] ) )
35{
36  $_GET['cat_id'] = '-1';
37}
38
39$template->set_filenames( array('categories'=>'admin/cat_modify.tpl') );
40
41//--------------------------------------------------------- form criteria check
42if (isset($_POST['submit']))
43{
44  $data =
45    array(
46      'id' => $_GET['cat_id'],
47      'name' => @$_POST['name'],
48      'commentable' => $_POST['commentable'],
49      'uploadable' =>
50        isset($_POST['uploadable']) ? $_POST['uploadable'] : 'false',
51      'comment' =>
52        $conf['allow_html_descriptions'] ?
53          @$_POST['comment'] : strip_tags(@$_POST['comment'])
54      );
55
56  mass_updates(
57    CATEGORIES_TABLE,
58    array(
59      'primary' => array('id'),
60      'update' => array_diff(array_keys($data), array('id'))
61      ),
62    array($data)
63    );
64 
65  set_cat_visible(array($_GET['cat_id']), $_POST['visible']);
66  set_cat_status(array($_GET['cat_id']), $_POST['status']);
67
68  if (isset($_POST['parent']))
69  {
70    move_category($_GET['cat_id'], $_POST['parent']);
71  }
72
73  array_push($page['infos'], $lang['editcat_confirm']);
74}
75else if (isset($_POST['set_random_representant']))
76{
77  set_random_representant(array($_GET['cat_id']));
78}
79else if (isset($_POST['delete_representant']))
80{
81  $query = '
82UPDATE '.CATEGORIES_TABLE.'
83  SET representative_picture_id = NULL
84  WHERE id = '.$_GET['cat_id'].'
85;';
86  pwg_query($query);
87}
88
89$query = '
90SELECT *
91  FROM '.CATEGORIES_TABLE.'
92  WHERE id = '.$_GET['cat_id'].'
93;';
94$category = mysql_fetch_array( pwg_query( $query ) );
95// nullable fields
96foreach (array('comment','dir','site_id', 'id_uppercat') as $nullable)
97{
98  if (!isset($category[$nullable]))
99  {
100    $category[$nullable] = '';
101  }
102}
103
104$category['is_virtual'] = empty($category['dir']) ? true : false;
105
106// Navigation path
107$url = PHPWG_ROOT_PATH.'admin.php?page=cat_modify&amp;cat_id=';
108
109$navigation = get_cat_display_name_cache(
110  $category['uppercats'],
111  PHPWG_ROOT_PATH.'admin.php?page=cat_modify&amp;cat_id='
112  );
113
114$form_action = PHPWG_ROOT_PATH.'admin.php?page=cat_modify&amp;cat_id='.$_GET['cat_id'];
115$status = ($category['status']=='public')?'STATUS_PUBLIC':'STATUS_PRIVATE'; 
116$lock = ($category['visible']=='true')?'UNLOCKED':'LOCKED';
117
118if ($category['commentable'] == 'true')
119{
120  $commentable = 'COMMENTABLE_TRUE';
121}
122else
123{
124  $commentable = 'COMMENTABLE_FALSE';
125}
126if ($category['uploadable'] == 'true')
127{
128  $uploadable = 'UPLOADABLE_TRUE';
129}
130else
131{
132  $uploadable = 'UPLOADABLE_FALSE';
133}
134
135//----------------------------------------------------- template initialization
136
137$base_url = PHPWG_ROOT_PATH.'admin.php?page=';
138$cat_list_url = $base_url.'cat_list';
139 
140$self_url = $cat_list_url;
141if (!empty($category['id_uppercat']))
142{
143  $self_url.= '&amp;parent_id='.$category['id_uppercat'];
144}
145
146$template->assign_vars(array( 
147  'CATEGORIES_NAV'=>$navigation,
148  'CAT_NAME'=>$category['name'],
149  'CAT_COMMENT'=>$category['comment'],
150 
151  $status=>'checked="checked"',
152  $lock=>'checked="checked"',
153  $commentable=>'checked="checked"',
154  $uploadable=>'checked="checked"',
155 
156  'L_EDIT_NAME'=>$lang['name'],
157  'L_STORAGE'=>$lang['storage'],
158  'L_REMOTE_SITE'=>$lang['remote_site'],
159  'L_EDIT_COMMENT'=>$lang['description'],
160  'L_EDIT_STATUS'=>$lang['conf_access'],
161  'L_STATUS_PUBLIC'=>$lang['public'],
162  'L_STATUS_PRIVATE'=>$lang['private'],
163  'L_EDIT_LOCK'=>$lang['lock'],
164  'L_EDIT_UPLOADABLE'=>$lang['editcat_uploadable'],
165  'L_EDIT_COMMENTABLE'=>$lang['comments'],
166  'L_YES'=>$lang['yes'],
167  'L_NO'=>$lang['no'],
168  'L_SUBMIT'=>$lang['submit'],
169  'L_SET_RANDOM_REPRESENTANT'=>$lang['cat_representant'],
170
171  'U_JUMPTO'=>
172    add_session_id(PHPWG_ROOT_PATH.'category.php?cat='.$category['id']),
173  'U_CHILDREN'=>
174    add_session_id($cat_list_url.'&amp;parent_id='.$category['id']),
175  'U_HELP' => PHPWG_ROOT_PATH.'/popuphelp.php?page=cat_modify',
176   
177  'F_ACTION'=>add_session_id($form_action)
178  ));
179
180
181if ('private' == $category['status'])
182{
183  $template->assign_block_vars(
184    'permissions',
185    array(
186      'URL'=>add_session_id($base_url.'cat_perm&amp;cat='.$category['id'])
187        )
188    );
189}
190
191// manage category elements link
192if ($category['nb_images'] > 0)
193{
194  $template->assign_block_vars(
195    'elements',
196    array(
197      'URL'=>add_session_id($base_url.'element_set&amp;cat='.$category['id'])
198      )
199    );
200}
201
202// representant management
203if ($category['nb_images'] > 0
204    or !empty($category['representative_picture_id']))
205{
206  $template->assign_block_vars('representant', array());
207
208  // picture to display : the identified representant or the generic random
209  // representant ?
210  if (!empty($category['representative_picture_id']))
211  {
212    $query = '
213SELECT tn_ext,path
214  FROM '.IMAGES_TABLE.'
215  WHERE id = '.$category['representative_picture_id'].'
216;';
217    $row = mysql_fetch_array(pwg_query($query));
218    $src = get_thumbnail_src($row['path'], @$row['tn_ext']);
219    $url = PHPWG_ROOT_PATH.'admin.php?page=picture_modify';
220    $url.= '&amp;image_id='.$category['representative_picture_id'];
221 
222    $template->assign_block_vars(
223      'representant.picture',
224      array(
225        'SRC' => $src,
226        'URL' => $url
227        )
228      );
229  }
230  else // $category['nb_images'] > 0
231  {
232    $template->assign_block_vars('representant.random', array());
233  }
234
235  // can the admin choose to set a new random representant ?
236  if ($category['nb_images'] > 0)
237  {
238    $template->assign_block_vars('representant.set_random', array());
239  }
240
241  // can the admin delete the current representant ?
242  if (
243    ($category['nb_images'] > 0
244     and $conf['allow_random_representative'])
245    or
246    ($category['nb_images'] == 0
247     and !empty($category['representative_picture_id'])))
248  {
249    $template->assign_block_vars('representant.delete_representant', array());
250  }
251}
252
253if (!$category['is_virtual']) //!empty($category['dir']))
254{
255  $template->assign_block_vars(
256    'storage',
257    array('CATEGORY_DIR'=>preg_replace('/\/$/',
258                                       '',
259                                       get_complete_dir($category['id']))));
260  $template->assign_block_vars('upload' ,array());
261}
262else
263{
264  $template->assign_block_vars(
265    'delete',
266    array(
267      'URL'=>add_session_id($self_url.'&amp;delete='.$category['id'])
268      )
269    );
270
271  $template->assign_block_vars('move', array());
272
273  // the category can be moved in any category but in itself, in any
274  // sub-category
275  $unmovables = get_subcat_ids(array($category['id']));
276 
277  $blockname = 'move.parent_option';
278
279  $template->assign_block_vars(
280    $blockname,
281    array(
282      'SELECTED'
283        => empty($category['id_uppercat']) ? 'selected="selected"' : '',
284      'VALUE'=> 0,
285      'OPTION' => '------------'
286      )
287    );
288 
289  $query = '
290SELECT id,name,uppercats,global_rank
291  FROM '.CATEGORIES_TABLE.'
292  WHERE id NOT IN ('.implode(',', $unmovables).')
293;';
294 
295  display_select_cat_wrapper(
296    $query,
297    empty($category['id_uppercat']) ? array() : array($category['id_uppercat']),
298    $blockname
299    );
300}
301
302if (is_numeric($category['site_id']) and $category['site_id'] != 1)
303{
304  $query = '
305SELECT galleries_url
306  FROM '.SITES_TABLE.'
307  WHERE id = '.$category['site_id'].'
308;';
309  list($galleries_url) = mysql_fetch_array(pwg_query($query));
310  $template->assign_block_vars('server', array('SITE_URL' => $galleries_url));
311}
312
313//----------------------------------------------------------- sending html code
314$template->assign_var_from_handle('ADMIN_CONTENT', 'categories');
315?>
Note: See TracBrowser for help on using the repository browser.