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_options.php,v $
9
// | last update   : $Date: 2005/01/07 23:10:51 $
10
// | last modifier : $Author: plg $
11
// | revision      : $Revision: 1.6 $
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
// +-----------------------------------------------------------------------+
34
// |                       modification registration                       |
35
// +-----------------------------------------------------------------------+
36
// print '<pre>';
37
// print_r($_POST);
38
// print '</pre>';
39
if (isset($_POST['falsify'])
40
    and isset($_POST['cat_true'])
41
    and count($_POST['cat_true']) > 0)
42
{
43
  switch ($_GET['section'])
44
  {
45
    case 'upload' :
46
    {
47
      $query = '
48
UPDATE '.CATEGORIES_TABLE.'
49
  SET uploadable = \'false\'
50
  WHERE id IN ('.implode(',', $_POST['cat_true']).')
51
;';
52
      pwg_query($query);
53
      break;
54
    }
55
    case 'comments' :
56
    {
57
      $query = '
58
UPDATE '.CATEGORIES_TABLE.'
59
  SET commentable = \'false\'
60
  WHERE id IN ('.implode(',', $_POST['cat_true']).')
61
;';
62
      pwg_query($query);
63
      break;
64
    }
65
    case 'visible' :
66
    {
67
      set_cat_visible($_POST['cat_true'], 'false');
68
      break;
69
    }
70
    case 'status' :
71
    {
72
      set_cat_status($_POST['cat_true'], 'private');
73
      break;
74
    }
75
  }
76
}
77
else if (isset($_POST['trueify'])
78
         and isset($_POST['cat_false'])
79
         and count($_POST['cat_false']) > 0)
80
{
81
  switch ($_GET['section'])
82
  {
83
    case 'upload' :
84
    {
85
      $query = '
86
UPDATE '.CATEGORIES_TABLE.'
87
  SET uploadable = \'true\'
88
  WHERE id IN ('.implode(',', $_POST['cat_false']).')
89
;';
90
      pwg_query($query);
91
      break;
92
    }
93
    case 'comments' :
94
    {
95
      $query = '
96
UPDATE '.CATEGORIES_TABLE.'
97
  SET commentable = \'true\'
98
  WHERE id IN ('.implode(',', $_POST['cat_false']).')
99
;';
100
      pwg_query($query);
101
      break;
102
    }
103
    case 'visible' :
104
    {
105
      set_cat_visible($_POST['cat_false'], 'true');
106
      break;
107
    }
108
    case 'status' :
109
    {
110
      set_cat_status($_POST['cat_false'], 'public');
111
      break;
112
    }
113
  }
114
}
115
// +-----------------------------------------------------------------------+
116
// |                             template init                             |
117
// +-----------------------------------------------------------------------+
118
$template->set_filenames(array('cat_options'=>'admin/cat_options.tpl'));
119
 
120
if (!isset($_GET['section']))
121
{
122
  $page['section'] = 'upload';
123
}
124
else
125
{
126
  $page['section'] = $_GET['section'];
127
}
128
 
129
$base_url = PHPWG_ROOT_PATH.'admin.php?page=cat_options&amp;section=';
130
$template->assign_vars(
131
  array(
132
    'L_SUBMIT'=>$lang['submit'],
133
    'L_RESET'=>$lang['reset'],
134
 
135
    'F_ACTION'=>add_session_id($base_url.$page['section'])
136
   )
137
 );
138
 
139
$template->assign_vars(array(strtoupper($page['section']).'_CLASS'=>'opened'));
140
// +-----------------------------------------------------------------------+
141
// |                              form display                             |
142
// +-----------------------------------------------------------------------+
143
 
144
// for each section, categories in the multiselect field can be :
145
//
146
// - true : uploadable for upload section
147
// - false : un-uploadable for upload section
148
// - NA : (not applicable) for virtual categories
149
//
150
// for true and false status, we associates an array of category ids,
151
// function display_select_categories will use the given CSS class for each
152
// option
153
$cats_true = array();
154
$cats_false = array();
155
switch ($page['section'])
156
{
157
  case 'upload' :
158
  {
159
    $query_true = '
160
SELECT id,name,uppercats,global_rank
161
  FROM '.CATEGORIES_TABLE.'
162
  WHERE uploadable = \'true\'
163
    AND dir IS NOT NULL
164
    AND site_id = 1
165
;';
166
    $query_false = '
167
SELECT id,name,uppercats,global_rank
168
  FROM '.CATEGORIES_TABLE.'
169
  WHERE uploadable = \'false\'
170
    AND dir IS NOT NULL
171
    AND site_id = 1
172
;';
173
    $template->assign_vars(
174
      array(
175
        'L_CAT_TITLE' => $lang['cat_upload_title'],
176
        'L_CAT_OPTIONS_TRUE' => $lang['authorized'],
177
        'L_CAT_OPTIONS_FALSE' => $lang['forbidden'],
178
        'L_CAT_OPTIONS_INFO' => $lang['cat_upload_info'],
179
        )
180
      );
181
    $template->assign_block_vars('upload', array());
182
    break;
183
  }
184
  case 'comments' :
185
  {
186
    $query_true = '
187
SELECT id,name,uppercats,global_rank
188
  FROM '.CATEGORIES_TABLE.'
189
  WHERE commentable = \'true\'
190
;';
191
    $query_false = '
192
SELECT id,name,uppercats,global_rank
193
  FROM '.CATEGORIES_TABLE.'
194
  WHERE commentable = \'false\'
195
;';
196
    $template->assign_vars(
197
      array(
198
        'L_CAT_TITLE' => $lang['cat_comments_title'],
199
        'L_CAT_OPTIONS_TRUE' => $lang['authorized'],
200
        'L_CAT_OPTIONS_FALSE' => $lang['forbidden'],
201
        'L_CAT_OPTIONS_INFO' => $lang['cat_comments_info'],
202
        )
203
      );
204
    $template->assign_block_vars('comments', array());
205
    break;
206
  }
207
  case 'visible' :
208
  {
209
    $query_true = '
210
SELECT id,name,uppercats,global_rank
211
  FROM '.CATEGORIES_TABLE.'
212
  WHERE visible = \'true\'
213
;';
214
    $query_false = '
215
SELECT id,name,uppercats,global_rank
216
  FROM '.CATEGORIES_TABLE.'
217
  WHERE visible = \'false\'
218
;';
219
    $template->assign_vars(
220
      array(
221
        'L_CAT_TITLE' => $lang['cat_lock_title'],
222
        'L_CAT_OPTIONS_TRUE' => $lang['unlocked'],
223
        'L_CAT_OPTIONS_FALSE' => $lang['locked'],
224
        'L_CAT_OPTIONS_INFO' => $lang['cat_lock_info'],
225
        )
226
      );
227
    $template->assign_block_vars('visible', array());
228
    break;
229
  }
230
  case 'status' :
231
  {
232
    $query_true = '
233
SELECT id,name,uppercats,global_rank
234
  FROM '.CATEGORIES_TABLE.'
235
  WHERE status = \'public\'
236
;';
237
    $query_false = '
238
SELECT id,name,uppercats,global_rank
239
  FROM '.CATEGORIES_TABLE.'
240
  WHERE status = \'private\'
241
;';
242
    $template->assign_vars(
243
      array(
244
        'L_CAT_TITLE' => $lang['cat_status_title'],
245
        'L_CAT_OPTIONS_TRUE' => $lang['cat_public'],
246
        'L_CAT_OPTIONS_FALSE' => $lang['cat_private'],
247
        'L_CAT_OPTIONS_INFO' => $lang['cat_status_info'],
248
        )
249
      );
250
    $template->assign_block_vars('status', array());
251
    break;
252
  }
253
}
254
display_select_cat_wrapper($query_true,array(),'category_option_true');
255
display_select_cat_wrapper($query_false,array(),'category_option_false');
256
// +-----------------------------------------------------------------------+
257
// |                           sending html code                           |
258
// +-----------------------------------------------------------------------+
259
$template->assign_var_from_handle('ADMIN_CONTENT', 'cat_options');
260
?>