source: trunk/admin/cat_modify.php @ 633

Last change on this file since 633 was 633, checked in by plg, 19 years ago
  • shows the element representing a non empty category in cat_modify
  • possibility to set a random representing element for a category
  • bug fixed : update_category function could not update nb_images
  • bug fixed : mass_updates was inserting in the wrong table
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.9 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 17:42:07 +0000 (Sat, 04 Dec 2004) $
10// | last modifier : $Author: plg $
11// | revision      : $Revision: 633 $
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  $query = 'SELECT status';
45  $query.= ' FROM '.CATEGORIES_TABLE;
46  $query.= ' WHERE id = '.$_GET['cat_id'];
47  $query.= ';';
48  $row = mysql_fetch_array( pwg_query( $query ) );
49 
50  $query = 'UPDATE '.CATEGORIES_TABLE;
51  $query.= ' SET name = ';
52  if ( empty($_POST['name']))
53    $query.= 'NULL';
54  else
55    $query.= "'".htmlentities( $_POST['name'], ENT_QUOTES)."'";
56
57  $query.= ', comment = ';
58  if ( empty($_POST['comment']))
59    $query.= 'NULL';
60  else
61    $query.= "'".htmlentities( $_POST['comment'], ENT_QUOTES )."'";
62
63  if ( isset( $_POST['uploadable'] ) )
64    $query.= ", uploadable = '".$_POST['uploadable']."'";
65
66  if ( isset( $_POST['associate'] ) )
67  {
68    $query.= ', id_uppercat = ';
69    if ( $_POST['associate'] == -1 or $_POST['associate'] == '' )
70      $query.= 'NULL';
71    else
72      $query.= $_POST['associate'];
73  }
74  $query.= ' WHERE id = '.$_GET['cat_id'];
75  $query.= ';';
76  pwg_query( $query );
77
78  set_cat_visible(array($_GET['cat_id']), $_POST['visible']);
79  set_cat_status(array($_GET['cat_id']), $_POST['status']);
80
81  $template->assign_block_vars('confirmation' ,array());
82}
83else if (isset($_POST['set_random_representant']))
84{
85  set_random_representant(array($_GET['cat_id']));
86}
87
88$query = '
89SELECT *
90  FROM '.CATEGORIES_TABLE.'
91  WHERE id = '.$_GET['cat_id'].'
92;';
93$category = mysql_fetch_array( pwg_query( $query ) );
94// nullable fields
95foreach (array('comment','dir','site_id') as $nullable)
96{
97  if (!isset($category[$nullable]))
98  {
99    $category[$nullable] = '';
100  }
101}
102
103// Navigation path
104$current_category = get_cat_info($_GET['cat_id']);
105$url = PHPWG_ROOT_PATH.'admin.php?page=cat_list&amp;parent_id=';
106$navigation = '<a class="" href="'.add_session_id(PHPWG_ROOT_PATH.'admin.php?page=cat_list').'">';
107$navigation.= $lang['home'].'</a> <span style="font-size:15px">&rarr;</span>';
108$navigation.= get_cat_display_name(
109  $current_category['name'],
110  ' <span style="font-size:15px">&rarr;</span>',
111  $url);
112
113$form_action = PHPWG_ROOT_PATH.'admin.php?page=cat_modify&amp;cat_id='.$_GET['cat_id'];
114$status = ($category['status']=='public')?'STATUS_PUBLIC':'STATUS_PRIVATE'; 
115$lock = ($category['visible']=='true')?'UNLOCKED':'LOCKED';
116
117if ($category['commentable'] == 'true')
118{
119  $commentable = 'COMMENTABLE_TRUE';
120}
121else
122{
123  $commentable = 'COMMENTABLE_FALSE';
124}
125if ($category['uploadable'] == 'true')
126{
127  $uploadable = 'UPLOADABLE_TRUE';
128}
129else
130{
131  $uploadable = 'UPLOADABLE_FALSE';
132}
133
134//----------------------------------------------------- template initialization
135$template->assign_vars(array( 
136  'CATEGORIES_NAV'=>$navigation,
137  'CAT_NAME'=>$category['name'],
138  'CAT_COMMENT'=>$category['comment'],
139  'CATEGORY_DIR'=>preg_replace('/\/$/', '', get_complete_dir($category['id'])),
140 
141  $status=>'checked="checked"',
142  $lock=>'checked="checked"',
143  $commentable=>'checked="checked"',
144  $uploadable=>'checked="checked"',
145 
146  'L_EDIT_CONFIRM'=>$lang['editcat_confirm'],
147  'L_EDIT_NAME'=>$lang['description'],
148  'L_STORAGE'=>$lang['storage'],
149  'L_REMOTE_SITE'=>$lang['remote_site'],
150  'L_EDIT_COMMENT'=>$lang['comment'],
151  'L_EDIT_STATUS'=>$lang['conf_access'],
152  'L_EDIT_STATUS_INFO'=>$lang['cat_access_info'],
153  'L_STATUS_PUBLIC'=>$lang['public'],
154  'L_STATUS_PRIVATE'=>$lang['private'],
155  'L_EDIT_LOCK'=>$lang['lock'],
156  'L_EDIT_LOCK_INFO'=>$lang['editcat_visible_info'],
157  'L_EDIT_UPLOADABLE'=>$lang['editcat_uploadable'],
158  'L_EDIT_UPLOADABLE_INFO'=>$lang['editcat_uploadable_info'],
159  'L_EDIT_COMMENTABLE'=>$lang['editcat_commentable'],
160  'L_EDIT_COMMENTABLE_INFO'=>$lang['editcat_commentable_info'],
161  'L_YES'=>$lang['yes'],
162  'L_NO'=>$lang['no'],
163  'L_SUBMIT'=>$lang['submit'],
164  'L_SET_RANDOM_REPRESENTANT'=>$lang['set_random_representant'],
165   
166  'F_ACTION'=>add_session_id($form_action)
167  ));
168
169if ($category['nb_images'] > 0)
170{
171  $query = '
172SELECT tn_ext,path
173  FROM '.IMAGES_TABLE.'
174  WHERE id = '.$category['representative_picture_id'].'
175;';
176  $row = mysql_fetch_array(pwg_query($query));
177  $src = get_thumbnail_src($row['path'], @$row['tn_ext']);
178  $url = PHPWG_ROOT_PATH.'admin.php?page=picture_modify';
179  $url.= '&amp;image_id='.$category['representative_picture_id'];
180  $template->assign_block_vars('representant',
181                               array('SRC' => $src,
182                                     'URL' => $url));
183}
184
185if (!empty($category['dir']))
186{
187  $template->assign_block_vars('storage' ,array());
188  $template->assign_block_vars('upload' ,array());
189}
190
191if (is_numeric($category['site_id']) and $category['site_id'] != 1)
192{
193  $query = '
194SELECT galleries_url
195  FROM '.SITES_TABLE.'
196  WHERE id = '.$category['site_id'].'
197;';
198  list($galleries_url) = mysql_fetch_array(pwg_query($query));
199  $template->assign_block_vars('server', array('SITE_URL' => $galleries_url));
200}
201
202//----------------------------------------------------------- sending html code
203$template->assign_var_from_handle('ADMIN_CONTENT', 'categories');
204?>
Note: See TracBrowser for help on using the repository browser.