source: extensions/download_permissions/cat_options.php @ 30871

Last change on this file since 30871 was 29460, checked in by plg, 10 years ago

initial import

File size: 5.0 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | Piwigo - a PHP based photo gallery                                    |
4// +-----------------------------------------------------------------------+
5// | Copyright(C) 2008-2014 Piwigo Team                  http://piwigo.org |
6// | Copyright(C) 2003-2008 PhpWebGallery Team    http://phpwebgallery.net |
7// | Copyright(C) 2002-2003 Pierrick LE GALL   http://le-gall.net/pierrick |
8// +-----------------------------------------------------------------------+
9// | This program is free software; you can redistribute it and/or modify  |
10// | it under the terms of the GNU General Public License as published by  |
11// | the Free Software Foundation                                          |
12// |                                                                       |
13// | This program is distributed in the hope that it will be useful, but   |
14// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
15// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
16// | General Public License for more details.                              |
17// |                                                                       |
18// | You should have received a copy of the GNU General Public License     |
19// | along with this program; if not, write to the Free Software           |
20// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
21// | USA.                                                                  |
22// +-----------------------------------------------------------------------+
23
24if (!defined('PHPWG_ROOT_PATH'))
25{
26  die ("Hacking attempt!");
27}
28
29include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
30include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
31
32// +-----------------------------------------------------------------------+
33// | Check Access and exit when user status is not ok                      |
34// +-----------------------------------------------------------------------+
35
36check_status(ACCESS_ADMINISTRATOR);
37
38// +-----------------------------------------------------------------------+
39// |                       modification registration                       |
40// +-----------------------------------------------------------------------+
41
42// print '<pre>';
43// print_r($_POST);
44// print '</pre>';
45if (isset($_POST['falsify'])
46    and isset($_POST['cat_true'])
47    and count($_POST['cat_true']) > 0)
48{
49  $query = '
50UPDATE '.CATEGORIES_TABLE.'
51  SET downloadable = \'false\'
52  WHERE id IN ('.implode(',', $_POST['cat_true']).')
53;';
54  pwg_query($query);
55}
56else if (isset($_POST['trueify'])
57         and isset($_POST['cat_false'])
58         and count($_POST['cat_false']) > 0)
59{
60  $query = '
61UPDATE '.CATEGORIES_TABLE.'
62  SET downloadable = \'true\'
63  WHERE id IN ('.implode(',', $_POST['cat_false']).')
64;';
65  pwg_query($query);
66}
67
68// +-----------------------------------------------------------------------+
69// |                             template init                             |
70// +-----------------------------------------------------------------------+
71
72$template->set_filenames(
73  array(
74    'double_select' => 'double_select.tpl',
75    'download_permissions' => realpath(DLPERMS_PATH . 'cat_options.tpl'),
76    )
77  );
78
79$template->assign(
80  array(
81    'F_ACTION' => '',
82   )
83 );
84
85// TabSheet
86$tabsheet = new tabsheet();
87$tabsheet->set_id('cat_options');
88$tabsheet->select('dlperms');
89$tabsheet->assign();
90
91// +-----------------------------------------------------------------------+
92// |                              form display                             |
93// +-----------------------------------------------------------------------+
94
95// for each section, categories in the multiselect field can be :
96//
97// - true : commentable for comment section
98// - false : un-commentable for comment section
99// - NA : (not applicable) for virtual categories
100//
101// for true and false status, we associates an array of category ids,
102// function display_select_categories will use the given CSS class for each
103// option
104$cats_true = array();
105$cats_false = array();
106
107$query_true = '
108SELECT id,name,uppercats,global_rank
109  FROM '.CATEGORIES_TABLE.'
110  WHERE downloadable = \'true\'
111;';
112
113$query_false = '
114SELECT id,name,uppercats,global_rank
115  FROM '.CATEGORIES_TABLE.'
116  WHERE downloadable = \'false\'
117;';
118
119$template->assign(
120  array(
121    'L_SECTION' => l10n('Authorize download on photos'),
122    'L_CAT_OPTIONS_TRUE' => l10n('Authorized'),
123    'L_CAT_OPTIONS_FALSE' => l10n('Forbidden'),
124    )
125  );
126
127display_select_cat_wrapper($query_true,array(),'category_option_true');
128display_select_cat_wrapper($query_false,array(),'category_option_false');
129
130// +-----------------------------------------------------------------------+
131// |                           sending html code                           |
132// +-----------------------------------------------------------------------+
133
134$template->assign_var_from_handle('DOUBLE_SELECT', 'double_select');
135// $template->assign_var_from_handle('ADMIN_CONTENT', 'cat_options');
136?>
Note: See TracBrowser for help on using the repository browser.