Subversion Repositories svnkaklik

Rev

Go to most recent revision | Details | Last modification | View Log

Rev Author Line No. Line
6 kaklik 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: cat_modify.php,v $
9
// | last update   : $Date: 2005/01/07 23:10:51 $
10
// | last modifier : $Author: plg $
11
// | revision      : $Revision: 1.27 $
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
 
28
if (!defined('PHPWG_ROOT_PATH'))
29
{
30
  die('Hacking attempt!');
31
}
32
include_once(PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php');
33
//---------------------------------------------------------------- verification
34
if ( !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
42
if ( 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['commentable'] ) )
67
    $query.= ", commentable = '".$_POST['commentable']."'";
68
 
69
  if ( isset( $_POST['associate'] ) )
70
  {
71
    $query.= ', id_uppercat = ';
72
    if ( $_POST['associate'] == -1 or $_POST['associate'] == '' )
73
      $query.= 'NULL';
74
    else
75
      $query.= $_POST['associate'];
76
  }
77
  $query.= ' WHERE id = '.$_GET['cat_id'];
78
  $query.= ';';
79
  pwg_query( $query );
80
 
81
  set_cat_visible(array($_GET['cat_id']), $_POST['visible']);
82
  set_cat_status(array($_GET['cat_id']), $_POST['status']);
83
 
84
  $template->assign_block_vars('confirmation' ,array());
85
}
86
else if (isset($_POST['set_random_representant']))
87
{
88
  set_random_representant(array($_GET['cat_id']));
89
}
90
 
91
$query = '
92
SELECT *
93
  FROM '.CATEGORIES_TABLE.'
94
  WHERE id = '.$_GET['cat_id'].'
95
;';
96
$category = mysql_fetch_array( pwg_query( $query ) );
97
// nullable fields
98
foreach (array('comment','dir','site_id') as $nullable)
99
{
100
  if (!isset($category[$nullable]))
101
  {
102
    $category[$nullable] = '';
103
  }
104
}
105
 
106
// Navigation path
107
$url = PHPWG_ROOT_PATH.'admin.php?page=cat_list&amp;parent_id=';
108
$navigation = '<a class="" href="'.add_session_id(PHPWG_ROOT_PATH.'admin.php?page=cat_list').'">';
109
$navigation.= $lang['home'].'</a>'.$conf['level_separator'];
110
 
111
$navigation.= get_cat_display_name_cache(
112
  $category['uppercats'],
113
  $url);
114
 
115
$form_action = PHPWG_ROOT_PATH.'admin.php?page=cat_modify&amp;cat_id='.$_GET['cat_id'];
116
$status = ($category['status']=='public')?'STATUS_PUBLIC':'STATUS_PRIVATE'; 
117
$lock = ($category['visible']=='true')?'UNLOCKED':'LOCKED';
118
 
119
if ($category['commentable'] == 'true')
120
{
121
  $commentable = 'COMMENTABLE_TRUE';
122
}
123
else
124
{
125
  $commentable = 'COMMENTABLE_FALSE';
126
}
127
if ($category['uploadable'] == 'true')
128
{
129
  $uploadable = 'UPLOADABLE_TRUE';
130
}
131
else
132
{
133
  $uploadable = 'UPLOADABLE_FALSE';
134
}
135
 
136
//----------------------------------------------------- template initialization
137
$template->assign_vars(array( 
138
  'CATEGORIES_NAV'=>$navigation,
139
  'CAT_NAME'=>$category['name'],
140
  'CAT_COMMENT'=>$category['comment'],
141
 
142
  $status=>'checked="checked"',
143
  $lock=>'checked="checked"',
144
  $commentable=>'checked="checked"',
145
  $uploadable=>'checked="checked"',
146
 
147
  'L_EDIT_CONFIRM'=>$lang['editcat_confirm'],
148
  'L_EDIT_NAME'=>$lang['name'],
149
  'L_STORAGE'=>$lang['storage'],
150
  'L_REMOTE_SITE'=>$lang['remote_site'],
151
  'L_EDIT_COMMENT'=>$lang['description'],
152
  'L_EDIT_CAT_OPTIONS'=>$lang['cat_options'],
153
  'L_EDIT_STATUS'=>$lang['conf_access'],
154
  'L_EDIT_STATUS_INFO'=>$lang['cat_access_info'],
155
  'L_STATUS_PUBLIC'=>$lang['public'],
156
  'L_STATUS_PRIVATE'=>$lang['private'],
157
  'L_EDIT_LOCK'=>$lang['lock'],
158
  'L_EDIT_LOCK_INFO'=>$lang['editcat_lock_info'],
159
  'L_EDIT_UPLOADABLE'=>$lang['editcat_uploadable'],
160
  'L_EDIT_UPLOADABLE_INFO'=>$lang['editcat_uploadable_info'],
161
  'L_EDIT_COMMENTABLE'=>$lang['comments'],
162
  'L_EDIT_COMMENTABLE_INFO'=>$lang['editcat_commentable_info'],
163
  'L_YES'=>$lang['yes'],
164
  'L_NO'=>$lang['no'],
165
  'L_SUBMIT'=>$lang['submit'],
166
  'L_SET_RANDOM_REPRESENTANT'=>$lang['cat_representant'],
167
 
168
  'F_ACTION'=>add_session_id($form_action)
169
  ));
170
 
171
if ($category['nb_images'] > 0)
172
{
173
  $query = '
174
SELECT tn_ext,path
175
  FROM '.IMAGES_TABLE.'
176
  WHERE id = '.$category['representative_picture_id'].'
177
;';
178
  $row = mysql_fetch_array(pwg_query($query));
179
  $src = get_thumbnail_src($row['path'], @$row['tn_ext']);
180
  $url = PHPWG_ROOT_PATH.'admin.php?page=picture_modify';
181
  $url.= '&amp;image_id='.$category['representative_picture_id'];
182
  $template->assign_block_vars('representant',
183
                               array('SRC' => $src,
184
                                     'URL' => $url));
185
}
186
 
187
if (!empty($category['dir']))
188
{
189
  $template->assign_block_vars(
190
    'storage',
191
    array('CATEGORY_DIR'=>preg_replace('/\/$/',
192
                                       '',
193
                                       get_complete_dir($category['id']))));
194
  $template->assign_block_vars('upload' ,array());
195
}
196
 
197
if (is_numeric($category['site_id']) and $category['site_id'] != 1)
198
{
199
  $query = '
200
SELECT galleries_url
201
  FROM '.SITES_TABLE.'
202
  WHERE id = '.$category['site_id'].'
203
;';
204
  list($galleries_url) = mysql_fetch_array(pwg_query($query));
205
  $template->assign_block_vars('server', array('SITE_URL' => $galleries_url));
206
}
207
 
208
//----------------------------------------------------------- sending html code
209
$template->assign_var_from_handle('ADMIN_CONTENT', 'categories');
210
?>