source: trunk/admin/cat_modify.php @ 607

Last change on this file since 607 was 607, checked in by gweltas, 20 years ago

Unification of "Return to main page" entry in the language files.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.4 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-11-18 14:57:00 +0000 (Thu, 18 Nov 2004) $
10// | last modifier : $Author: gweltas $
11// | revision      : $Revision: 607 $
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//---------------------------------------------------------------- verification
35if ( !isset( $_GET['cat_id'] ) || !is_numeric( $_GET['cat_id'] ) )
36{
37  $_GET['cat_id'] = '-1';
38}
39
40$template->set_filenames( array('categories'=>'admin/cat_modify.tpl') );
41
42//--------------------------------------------------------- form criteria check
43if ( isset( $_POST['submit'] ) )
44{
45  // if new status is different from previous one, deletion of all related
46  // links for access rights
47  $query = 'SELECT status';
48  $query.= ' FROM '.CATEGORIES_TABLE;
49  $query.= ' WHERE id = '.$_GET['cat_id'];
50  $query.= ';';
51  $row = mysql_fetch_array( pwg_query( $query ) );
52 
53  $query = 'UPDATE '.CATEGORIES_TABLE;
54  $query.= ' SET name = ';
55  if ( empty($_POST['name']))
56    $query.= 'NULL';
57  else
58    $query.= "'".htmlentities( $_POST['name'], ENT_QUOTES)."'";
59
60  $query.= ', comment = ';
61  if ( empty($_POST['comment']))
62    $query.= 'NULL';
63  else
64    $query.= "'".htmlentities( $_POST['comment'], ENT_QUOTES )."'";
65
66  $query.= ", status = '".$_POST['status']."'";
67  $query.= ", visible = '".$_POST['visible']."'";
68  if ( isset( $_POST['uploadable'] ) )
69    $query.= ", uploadable = '".$_POST['uploadable']."'";
70
71  if ( isset( $_POST['associate'] ) )
72  {
73    $query.= ', id_uppercat = ';
74    if ( $_POST['associate'] == -1 or $_POST['associate'] == '' )
75      $query.= 'NULL';
76    else
77      $query.= $_POST['associate'];
78  }
79  $query.= ' WHERE id = '.$_GET['cat_id'];
80  $query.= ';';
81  pwg_query( $query );
82
83  if ( $_POST['status'] != $row['status'] )
84  {
85    // deletion of all access for groups concerning this category
86    $query = 'DELETE';
87    $query.= ' FROM '.GROUP_ACCESS_TABLE;
88    $query.= ' WHERE cat_id = '.$_GET['cat_id'];
89    pwg_query( $query );
90    // deletion of all access for users concerning this category
91    $query = 'DELETE';
92    $query.= ' FROM '.USER_ACCESS_TABLE;
93    $query.= ' WHERE cat_id = '.$_GET['cat_id'];
94    pwg_query( $query );
95  }
96
97  // checking users favorites
98  $query = 'SELECT id';
99  $query.= ' FROM '.USERS_TABLE;
100  $query.= ';';
101  $result = pwg_query( $query );
102  while ( $row = mysql_fetch_array( $result ) )
103  {
104    check_favorites( $row['id'] );
105  }
106  $template->assign_block_vars('confirmation' ,array());
107}
108
109$query = 'SELECT a.*, b.*';
110$query.= ' FROM '.CATEGORIES_TABLE.' as a, '.SITES_TABLE.' as b';
111$query.= ' WHERE a.id = '.$_GET['cat_id'];
112$query.= ' AND a.site_id = b.id';
113$query.= ';';
114$category = mysql_fetch_array( pwg_query( $query ) );
115// nullable fields
116foreach (array('comment','dir') as $nullable)
117{
118  if (!isset($category[$nullable]))
119  {
120    $category[$nullable] = '';
121  }
122}
123
124// Navigation path
125$current_category = get_cat_info($_GET['cat_id']);
126$url = PHPWG_ROOT_PATH.'admin.php?page=cat_list&amp;parent_id=';
127$navigation = '<a class="" href="'.add_session_id(PHPWG_ROOT_PATH.'admin.php?page=cat_list').'">';
128$navigation.= $lang['home'].'</a>-&gt;';
129$navigation.= get_cat_display_name($current_category['name'], '-&gt;', $url);
130
131$form_action = PHPWG_ROOT_PATH.'admin.php?page=cat_modify&amp;cat_id='.$_GET['cat_id'];
132$access = ($category['status']=='public')?'ACCESS_FREE':'ACCESS_RESTRICTED'; 
133$lock = ($category['visible']=='true')?'UNLOCKED':'LOCKED';
134
135//----------------------------------------------------- template initialization
136$template->assign_vars(array( 
137  'CATEGORIES_NAV'=>$navigation,
138  'CAT_NAME'=>$category['name'],
139  'CAT_COMMENT'=>$category['comment'],
140  'CATEGORY_DIR'=>$category['dir'],
141  'SITE_URL'=>$category['galleries_url'],
142 
143  $access=>'checked="checked"',
144  $lock=>'checked="checked"',
145 
146  'L_EDIT_CONFIRM'=>$lang['editcat_confirm'],
147  'L_EDIT_NAME'=>$lang['description'],
148  'L_STORAGE'=>$lang['storage'],
149  'L_EDIT_COMMENT'=>$lang['comment'],
150  'L_EDIT_STATUS'=>$lang['conf_access'],
151  'L_EDIT_STATUS_INFO'=>$lang['cat_access_info'],
152  'L_ACCESS_FREE'=>$lang['free'],
153  'L_ACCESS_RESTRICTED'=>$lang['restricted'],
154  'L_EDIT_LOCK'=>$lang['cat_lock'],
155  'L_EDIT_LOCK_INFO'=>$lang['cat_lock_info'],
156  'L_YES'=>$lang['yes'],
157  'L_NO'=>$lang['no'],
158  'L_SUBMIT'=>$lang['submit'],
159   
160  'F_ACTION'=>add_session_id($form_action)
161  ));
162 
163if ( !empty($category['dir']))
164{
165  $template->assign_block_vars('storage' ,array());
166}
167
168if ( $category['site_id'] != 1 )
169{
170  $template->assign_block_vars('storage' ,array());
171}
172
173/*
174// can the parent category be changed ? (is the category virtual ?)
175if ( $row['dir'] == '' )
176{
177  $vtp->addSession( $sub, 'parent' );
178  // We only show a List Of Values if the number of categories is less than
179  // $conf['max_LOV_categories']
180  $query = 'SELECT COUNT(id) AS nb_total_categories';
181  $query.= ' FROM '.CATEGORIES_TABLE;
182  $query.= ';';
183  $countrow = mysql_fetch_array( pwg_query( $query ) );
184  if ( $countrow['nb_total_categories'] < $conf['max_LOV_categories'] )
185  {
186    $vtp->addSession( $sub, 'associate_LOV' );
187    $vtp->addSession( $sub, 'associate_cat' );
188    $vtp->setVar( $sub, 'associate_cat.value', '-1' );
189    $vtp->setVar( $sub, 'associate_cat.content', '' );
190    $vtp->closeSession( $sub, 'associate_cat' );
191    $page['plain_structure'] = get_plain_structure( true );
192    $structure = create_structure( '', array() );
193    display_categories( $structure, '&nbsp;', $row['id_uppercat'],$row['id'] );
194    $vtp->closeSession( $sub, 'associate_LOV' );
195  }
196  // else, we only display a small text field, we suppose the administrator
197  // knows the id of its category
198  else
199  {
200    $vtp->addSession( $sub, 'associate_text' );
201    $vtp->setVar( $sub, 'associate_text.value', $row['id_uppercat'] );
202    $vtp->closeSession( $sub, 'associate_text' );
203  }
204  $vtp->closeSession( $sub, 'parent' );
205}
206*/
207//----------------------------------------------------------- sending html code
208$template->assign_var_from_handle('ADMIN_CONTENT', 'categories');
209?>
Note: See TracBrowser for help on using the repository browser.