source: trunk/admin/cat_modify.php @ 61

Last change on this file since 61 was 57, checked in by z0rglub, 21 years ago

improve the header of each file

  • 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 *                               cat_modify.php                            *
4 *                            -------------------                          *
5 *   application   : PhpWebGallery 1.3 <http://phpwebgallery.net>          *
6 *   author        : Pierrick LE GALL <pierrick@z0rglub.com>               *
7 *                                                                         *
8 *   $Id: cat_modify.php 57 2003-08-24 07:40:56Z z0rglub $
9 *                                                                         *
10 ***************************************************************************/
11
12/***************************************************************************
13 *                                                                         *
14 *   This program is free software; you can redistribute it and/or modify  *
15 *   it under the terms of the GNU General Public License as published by  *
16 *   the Free Software Foundation;                                         *
17 *                                                                         *
18 ***************************************************************************/
19
20include_once( './include/isadmin.inc.php' );
21//----------------------------------------------------- template initialization
22$sub = $vtp->Open( '../template/'.$user['template'].'/admin/cat_modify.vtp' );
23$tpl = array( 'remote_site','editcat_confirm','editcat_back','editcat_title1',
24              'editcat_name','editcat_comment','editcat_status',
25              'editcat_visible','editcat_visible_info', 'submit',
26              'editcat_uploadable' );
27templatize_array( $tpl, 'lang', $sub );
28//---------------------------------------------------------------- verification
29if ( !is_numeric( $_GET['cat'] ) )
30{
31  $_GET['cat'] = '-1';
32}
33//--------------------------------------------------------- form criteria check
34if ( isset( $_POST['submit'] ) )
35{
36  // if new status is different from previous one, deletion of all related
37  // links for access rights
38  $query = 'SELECT status';
39  $query.= ' FROM '.PREFIX_TABLE.'categories';
40  $query.= ' WHERE id = '.$_GET['cat'];
41  $query.= ';';
42  $row = mysql_fetch_array( mysql_query( $query ) );
43
44  if ( $_POST['status'] != $row['status'] )
45  {
46    // deletion of all access for groups concerning this category
47    $query = 'DELETE';
48    $query.= ' FROM '.PREFIX_TABLE.'group_access';
49    $query.= ' WHERE cat_id = '.$_GET['cat'];
50    mysql_query( $query );
51    // deletion of all access for users concerning this category
52    $query = 'DELETE';
53    $query.= ' FROM '.PREFIX_TABLE.'user_access';
54    $query.= ' WHERE cat_id = '.$_GET['cat'];
55    mysql_query( $query );
56  }
57 
58  $query = 'UPDATE '.PREFIX_TABLE.'categories';
59
60  $query.= ' SET name = ';
61  if ( $_POST['name'] == '' )
62    $query.= 'NULL';
63  else
64    $query.= "'".htmlentities( $_POST['name'], ENT_QUOTES)."'";
65
66  $query.= ', comment = ';
67  if ( $_POST['comment'] == '' )
68    $query.= 'NULL';
69  else
70    $query.= "'".htmlentities( $_POST['comment'], ENT_QUOTES )."'";
71
72  $query.= ", status = '".$_POST['status']."'";
73  $query.= ", visible = '".$_POST['visible']."'";
74  $query.= ", uploadable = '".$_POST['uploadable']."'";
75  $query.= ' WHERE id = '.$_GET['cat'];
76  $query.= ';';
77  mysql_query( $query );
78
79  $query = 'SELECT id';
80  $query.= ' FROM '.PREFIX_TABLE.'users';
81  $query.= " WHERE username != '".$conf['webmaster']."'";
82  $query.= ';';
83  $result = mysql_query( $query );
84  while ( $row = mysql_fetch_array ( $result ) )
85  {
86    check_favorites( $row['id'] );
87  }
88  $vtp->addSession( $sub, 'confirmation' );
89  $url = add_session_id( './admin.php?page=cat_list' );
90  $vtp->setVar( $sub, 'confirmation.back_url', $url );
91  $vtp->closeSession( $sub, 'confirmation' );
92}
93//------------------------------------------------------------------------ form
94$form_action = './admin.php?page=cat_modify&amp;cat='.$_GET['cat'];
95$vtp->setVar( $sub, 'form_action', add_session_id( $form_action ) );
96
97$query = 'SELECT a.id,name,dir,status,comment,uploadable';
98$query.= ',id_uppercat,site_id,galleries_url,visible';
99$query.= ' FROM '.PREFIX_TABLE.'categories as a, '.PREFIX_TABLE.'sites as b';
100$query.= ' WHERE a.id = '.$_GET['cat'];
101$query.= ' AND a.site_id = b.id';
102$query.= ';';
103$row = mysql_fetch_array( mysql_query( $query ) );
104$result = get_cat_info( $row['id'] );
105// cat name
106$cat_name = get_cat_display_name( $result['name'], ' - ', '' );
107$vtp->setVar( $sub, 'cat:name', $cat_name );
108// cat dir
109$vtp->setVar( $sub, 'cat:dir', $row['dir'] );
110// remote site ?
111if ( $row['site_id'] != 1 )
112{
113  $vtp->addSession( $sub, 'server' );
114  $vtp->setVar( $sub, 'server.url', $row['galleries_url'] );
115  $vtp->closeSession( $sub, 'server' );
116}
117$vtp->setVar( $sub, 'name',    $row['name'] );
118$vtp->setVar( $sub, 'comment', $row['comment'] );
119// status : public, private...
120$options = get_enums( PREFIX_TABLE.'categories', 'status' );
121foreach ( $options as $option  ) {
122  $vtp->addSession( $sub, 'status_option' );
123  $vtp->setVar( $sub, 'status_option.option', $lang[$option] );
124  $vtp->setVar( $sub, 'status_option.value', $option );
125  if ( $option == $row['status'] )
126  {
127    $vtp->setVar( $sub, 'status_option.checked', ' checked="checked"' ); 
128  }
129  $vtp->closeSession( $sub, 'status_option' );
130}
131// visible : true or false
132$vtp->addSession( $sub, 'visible_option' );
133$vtp->setVar( $sub, 'visible_option.value', 'true' );
134$vtp->setVar( $sub, 'visible_option.option', $lang['yes'] );
135$checked = '';
136if ( $row['visible'] == 'true' )
137{
138  $checked = ' checked="checked"';
139}
140$vtp->setVar( $sub, 'visible_option.checked', $checked );
141$vtp->closeSession( $sub, 'visible_option' );
142$vtp->addSession( $sub, 'visible_option' );
143$vtp->setVar( $sub, 'visible_option.value', 'false' );
144$vtp->setVar( $sub, 'visible_option.option', $lang['no'] );
145$checked = '';
146if ( $row['visible'] == 'false' )
147{
148  $checked = ' checked="checked"';
149}
150$vtp->setVar( $sub, 'visible_option.checked', $checked );
151$vtp->closeSession( $sub, 'visible_option' );
152// uploadable : true or false
153if ( $conf['upload_available'] )
154{
155  $vtp->addSession( $sub, 'uploadable' );
156  $vtp->addSession( $sub, 'uploadable_option' );
157  $vtp->setVar( $sub, 'uploadable_option.value', 'true' );
158  $vtp->setVar( $sub, 'uploadable_option.option', $lang['yes'] );
159  $checked = '';
160  if ( $row['uploadable'] == 'true' )
161  {
162    $checked = ' checked="checked"';
163  }
164  $vtp->setVar( $sub, 'uploadable_option.checked', $checked );
165  $vtp->closeSession( $sub, 'uploadable_option' );
166  $vtp->addSession( $sub, 'uploadable_option' );
167  $vtp->setVar( $sub, 'uploadable_option.value', 'false' );
168  $vtp->setVar( $sub, 'uploadable_option.option', $lang['no'] );
169  $checked = '';
170  if ( $row['uploadable'] == 'false' )
171  {
172    $checked = ' checked="checked"';
173  }
174  $vtp->setVar( $sub, 'uploadable_option.checked', $checked );
175  $vtp->closeSession( $sub, 'uploadable_option' );
176  $vtp->closeSession( $sub, 'uploadable' );
177}
178//----------------------------------------------------------- sending html code
179$vtp->Parse( $handle , 'sub', $sub );
180?>
Note: See TracBrowser for help on using the repository browser.