1 | <?php |
---|
2 | // +-----------------------------------------------------------------------+ |
---|
3 | // | cat_modify.php | |
---|
4 | // +-----------------------------------------------------------------------+ |
---|
5 | // | application : PhpWebGallery <http://phpwebgallery.net> | |
---|
6 | // | branch : BSF (Best So Far) | |
---|
7 | // +-----------------------------------------------------------------------+ |
---|
8 | // | file : $RCSfile$ |
---|
9 | // | last update : $Date: 2004-03-31 17:26:31 +0000 (Wed, 31 Mar 2004) $ |
---|
10 | // | last modifier : $Author: gweltas $ |
---|
11 | // | revision : $Revision: 403 $ |
---|
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 | //---------------------------------------------------------------- verification |
---|
35 | if ( !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 |
---|
43 | if ( 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( mysql_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 | mysql_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 | mysql_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 | mysql_query( $query ); |
---|
95 | // resynchronize all users |
---|
96 | synchronize_all_users(); |
---|
97 | } |
---|
98 | |
---|
99 | // checking users favorites |
---|
100 | $query = 'SELECT id'; |
---|
101 | $query.= ' FROM '.USERS_TABLE; |
---|
102 | $query.= ';'; |
---|
103 | $result = mysql_query( $query ); |
---|
104 | while ( $row = mysql_fetch_array( $result ) ) |
---|
105 | { |
---|
106 | check_favorites( $row['id'] ); |
---|
107 | } |
---|
108 | $template->assign_block_vars('confirmation' ,array()); |
---|
109 | } |
---|
110 | |
---|
111 | $query = 'SELECT a.*, b.*'; |
---|
112 | $query.= ' FROM '.CATEGORIES_TABLE.' as a, '.SITES_TABLE.' as b'; |
---|
113 | $query.= ' WHERE a.id = '.$_GET['cat_id']; |
---|
114 | $query.= ' AND a.site_id = b.id'; |
---|
115 | $query.= ';'; |
---|
116 | $category = mysql_fetch_array( mysql_query( $query ) ); |
---|
117 | |
---|
118 | // Navigation path |
---|
119 | $current_category = get_cat_info($_GET['cat_id']); |
---|
120 | $url = PHPWG_ROOT_PATH.'admin.php?page=cat_list&parent_id='; |
---|
121 | $navigation = '<a class="" href="'.add_session_id(PHPWG_ROOT_PATH.'admin.php?page=cat_list').'">'; |
---|
122 | $navigation.= $lang['gallery_index'].'</a>->'; |
---|
123 | $navigation.= get_cat_display_name($current_category['name'], '->', $url); |
---|
124 | |
---|
125 | $form_action = PHPWG_ROOT_PATH.'admin.php?page=cat_modify&cat_id='.$_GET['cat_id']; |
---|
126 | $access = ($category['status']=='public')?'ACCESS_FREE':'ACCESS_RESTRICTED'; |
---|
127 | $lock = ($category['visible']=='true')?'UNLOCKED':'LOCKED'; |
---|
128 | |
---|
129 | //----------------------------------------------------- template initialization |
---|
130 | |
---|
131 | $template->assign_vars(array( |
---|
132 | 'CATEGORIES_NAV'=>$navigation, |
---|
133 | 'CAT_NAME'=>$category['name'], |
---|
134 | 'CAT_COMMENT'=>$category['comment'], |
---|
135 | 'CATEGORY_DIR'=>$category['dir'], |
---|
136 | 'SITE_URL'=>$category['galleries_url'], |
---|
137 | |
---|
138 | $access=>'checked="checked"', |
---|
139 | $lock=>'checked="checked"', |
---|
140 | |
---|
141 | 'L_EDIT_CONFIRM'=>$lang['editcat_confirm'], |
---|
142 | 'L_EDIT_NAME'=>$lang['description'], |
---|
143 | 'L_STORAGE'=>$lang['storage'], |
---|
144 | 'L_EDIT_COMMENT'=>$lang['comment'], |
---|
145 | 'L_EDIT_STATUS'=>$lang['conf_general_access'], |
---|
146 | 'L_EDIT_STATUS_INFO'=>$lang['cat_access_info'], |
---|
147 | 'L_ACCESS_FREE'=>$lang['conf_general_access_1'], |
---|
148 | 'L_ACCESS_RESTRICTED'=>$lang['conf_general_access_2'], |
---|
149 | 'L_EDIT_LOCK'=>$lang['cat_lock'], |
---|
150 | 'L_EDIT_LOCK_INFO'=>$lang['cat_lock_info'], |
---|
151 | 'L_YES'=>$lang['yes'], |
---|
152 | 'L_NO'=>$lang['no'], |
---|
153 | 'L_SUBMIT'=>$lang['submit'], |
---|
154 | |
---|
155 | 'F_ACTION'=>add_session_id($form_action) |
---|
156 | )); |
---|
157 | |
---|
158 | if ( !empty($category['dir'])) |
---|
159 | { |
---|
160 | $template->assign_block_vars('storage' ,array()); |
---|
161 | } |
---|
162 | |
---|
163 | if ( $category['site_id'] != 1 ) |
---|
164 | { |
---|
165 | $template->assign_block_vars('storage' ,array()); |
---|
166 | } |
---|
167 | |
---|
168 | /* |
---|
169 | // can the parent category be changed ? (is the category virtual ?) |
---|
170 | if ( $row['dir'] == '' ) |
---|
171 | { |
---|
172 | $vtp->addSession( $sub, 'parent' ); |
---|
173 | // We only show a List Of Values if the number of categories is less than |
---|
174 | // $conf['max_LOV_categories'] |
---|
175 | $query = 'SELECT COUNT(id) AS nb_total_categories'; |
---|
176 | $query.= ' FROM '.CATEGORIES_TABLE; |
---|
177 | $query.= ';'; |
---|
178 | $countrow = mysql_fetch_array( mysql_query( $query ) ); |
---|
179 | if ( $countrow['nb_total_categories'] < $conf['max_LOV_categories'] ) |
---|
180 | { |
---|
181 | $vtp->addSession( $sub, 'associate_LOV' ); |
---|
182 | $vtp->addSession( $sub, 'associate_cat' ); |
---|
183 | $vtp->setVar( $sub, 'associate_cat.value', '-1' ); |
---|
184 | $vtp->setVar( $sub, 'associate_cat.content', '' ); |
---|
185 | $vtp->closeSession( $sub, 'associate_cat' ); |
---|
186 | $page['plain_structure'] = get_plain_structure( true ); |
---|
187 | $structure = create_structure( '', array() ); |
---|
188 | display_categories( $structure, ' ', $row['id_uppercat'],$row['id'] ); |
---|
189 | $vtp->closeSession( $sub, 'associate_LOV' ); |
---|
190 | } |
---|
191 | // else, we only display a small text field, we suppose the administrator |
---|
192 | // knows the id of its category |
---|
193 | else |
---|
194 | { |
---|
195 | $vtp->addSession( $sub, 'associate_text' ); |
---|
196 | $vtp->setVar( $sub, 'associate_text.value', $row['id_uppercat'] ); |
---|
197 | $vtp->closeSession( $sub, 'associate_text' ); |
---|
198 | } |
---|
199 | $vtp->closeSession( $sub, 'parent' ); |
---|
200 | } |
---|
201 | */ |
---|
202 | //----------------------------------------------------------- sending html code |
---|
203 | $template->assign_var_from_handle('ADMIN_CONTENT', 'categories'); |
---|
204 | ?> |
---|