1 | <?php |
---|
2 | |
---|
3 | if (!defined('PHPWG_ROOT_PATH')) |
---|
4 | die('Hacking attempt!'); |
---|
5 | global $template, $conf, $user; |
---|
6 | include_once(PHPWG_ROOT_PATH . 'admin/include/tabsheet.class.php'); |
---|
7 | load_language('plugin.lang', ADD_PROP_PHOTO_PATH); |
---|
8 | $my_base_url = get_admin_plugin_menu_link(__FILE__); |
---|
9 | |
---|
10 | // +-----------------------------------------------------------------------+ |
---|
11 | // | Check Access and exit when user status is not ok | |
---|
12 | // +-----------------------------------------------------------------------+ |
---|
13 | check_status(ACCESS_ADMINISTRATOR); |
---|
14 | |
---|
15 | //-------------------------------------------------------- sections definitions |
---|
16 | if (!isset($_GET['tab'])) |
---|
17 | $page['tab'] = 'define_properties'; |
---|
18 | else |
---|
19 | $page['tab'] = $_GET['tab']; |
---|
20 | |
---|
21 | |
---|
22 | if ($page['tab'] != 'iap') { |
---|
23 | $tabsheet = new tabsheet(); |
---|
24 | $tabsheet->add('addip', l10n('Property'), ADD_PROP_PHOTO_ADMIN . '-define_properties'); |
---|
25 | $tabsheet->select($page['tab']); |
---|
26 | $tabsheet->assign(); |
---|
27 | } else if ($_GET['tab'] == 'iap') { |
---|
28 | |
---|
29 | $page['active_menu'] = get_active_menu('photo'); // force oppening "Photos" menu block |
---|
30 | |
---|
31 | /* Basic checks */ |
---|
32 | check_status(ACCESS_ADMINISTRATOR); |
---|
33 | |
---|
34 | check_input_parameter('image_id', $_GET, false, PATTERN_ID); |
---|
35 | $id_img = $_GET['image_id']; |
---|
36 | $admin_photo_base_url = get_root_url() . 'admin.php?page=photo-' . $_GET['image_id']; |
---|
37 | |
---|
38 | $page['tab'] = 'iap'; |
---|
39 | |
---|
40 | $tabsheet = new tabsheet(); |
---|
41 | $tabsheet->set_id('photo'); |
---|
42 | $tabsheet->select('iap'); |
---|
43 | $tabsheet->assign(); |
---|
44 | |
---|
45 | $template->assign( |
---|
46 | 'gestionD', array( |
---|
47 | 'A' => 'a' |
---|
48 | )); |
---|
49 | |
---|
50 | $PAED = pwg_db_fetch_assoc(pwg_query("SELECT state FROM " . PLUGINS_TABLE . " WHERE id = 'ExtendedDescription';")); |
---|
51 | $PAED = pwg_db_fetch_assoc(pwg_query("SELECT state FROM " . PLUGINS_TABLE . " WHERE id = 'ExtendedDescription';")); |
---|
52 | if($PAED['state'] == 'active'){ |
---|
53 | add_event_handler('AP_render_content', 'get_user_language_desc'); |
---|
54 | $template->assign('useED',1); |
---|
55 | }else{ |
---|
56 | $template->assign('useED',0); |
---|
57 | } |
---|
58 | |
---|
59 | $tab_add_info_one_photo = tab_add_info_by_photo($_GET['image_id']); |
---|
60 | if (pwg_db_num_rows($tab_add_info_one_photo)) { |
---|
61 | while ($info_photos = pwg_db_fetch_assoc($tab_add_info_one_photo)) { |
---|
62 | |
---|
63 | $d = data_info_photos($id_img, $info_photos['id_prop_pho']); |
---|
64 | $row = pwg_db_fetch_assoc($d); |
---|
65 | |
---|
66 | $items = array( |
---|
67 | 'IDPHO' => $_GET['image_id'], |
---|
68 | 'IDINFOPHO' => $info_photos['id_prop_pho'], |
---|
69 | 'AIPWORDING' => trigger_change('AP_render_content',$info_photos['wording']), |
---|
70 | 'AIPDATA' => $row['data'], |
---|
71 | ); |
---|
72 | |
---|
73 | $template->append('info_photos', $items); |
---|
74 | } |
---|
75 | } |
---|
76 | |
---|
77 | if (isset($_POST['submitaddinfoimg'])) { |
---|
78 | foreach ($_POST['data'] AS $id_prop_pho => $data) { |
---|
79 | $q = 'SELECT 1 FROM ' . ADD_PROP_PHOTO_DATA_TABLE . ' WHERE id_img=' . $id_img . ' AND id_prop_pho=' . $id_prop_pho; |
---|
80 | $test = pwg_query($q); |
---|
81 | $row = pwg_db_fetch_assoc($test); |
---|
82 | if (count($row) > 0) { |
---|
83 | if ($data != '') { |
---|
84 | $query = 'UPDATE ' . $prefixeTable . 'add_properties_photos_data SET data="' . $data . '" WHERE id_img=' . $id_img . ' AND id_prop_pho=' . $id_prop_pho; |
---|
85 | pwg_query($query); |
---|
86 | } else { |
---|
87 | $query = 'DELETE FROM ' . $prefixeTable . 'add_properties_photos_data WHERE id_img=' . $id_img . ' AND id_prop_pho=' . $id_prop_pho; |
---|
88 | pwg_query($query); |
---|
89 | } |
---|
90 | } else if ($data != '') { |
---|
91 | $query = 'INSERT ' . $prefixeTable . 'add_properties_photos_data(id_img,id_prop_pho,data) VALUES (' . $id_img . ',' . $id_prop_pho . ',"' . $data . '");'; |
---|
92 | pwg_query($query); |
---|
93 | } |
---|
94 | |
---|
95 | } |
---|
96 | $redirect_url = ADD_PROP_PHOTO_ADMIN . '-iap&image_id=' . $id_img; |
---|
97 | $_SESSION['page_infos'] = array(l10n('Properties update')); |
---|
98 | redirect($redirect_url); |
---|
99 | } |
---|
100 | } |
---|
101 | |
---|
102 | switch ($page['tab']) { |
---|
103 | case 'define_properties': |
---|
104 | $admin_base_url = ADD_PROP_PHOTO_ADMIN . '-define_properties'; |
---|
105 | $template->assign( |
---|
106 | 'addinfotemplate', array( |
---|
107 | 'addinfo' => l10n('addinfo'), |
---|
108 | )); |
---|
109 | |
---|
110 | $PAED = pwg_db_fetch_assoc(pwg_query("SELECT state FROM " . PLUGINS_TABLE . " WHERE id = 'ExtendedDescription';")); |
---|
111 | if($PAED['state'] == 'active'){ |
---|
112 | add_event_handler('AP_render_content', 'get_user_language_desc'); |
---|
113 | $template->assign('useED',1); |
---|
114 | }else{ |
---|
115 | $template->assign('useED',0); |
---|
116 | } |
---|
117 | |
---|
118 | $admin_base_url = ADD_PROP_PHOTO_ADMIN . '-define_properties'; |
---|
119 | $tab_info_photos = tab_info_photos(); |
---|
120 | |
---|
121 | if (pwg_db_num_rows($tab_info_photos)) { |
---|
122 | while ($info_photos = pwg_db_fetch_assoc($tab_info_photos)) { |
---|
123 | if($info_photos['id_prop_pho']==1){ |
---|
124 | $items = array( |
---|
125 | 'IDINFOPHO' => $info_photos['id_prop_pho'], |
---|
126 | 'AIPWORDING' => l10n('Author'), |
---|
127 | 'AIPORDER' => $info_photos['orderprop'], |
---|
128 | 'AIPACTIVE' => $info_photos['active'], |
---|
129 | 'AIPEDIT' => $info_photos['edit'], |
---|
130 | 'U_HIDE' => $admin_base_url . '&hide=' . $info_photos['id_prop_pho'], |
---|
131 | 'U_SHOW' => $admin_base_url . '&show=' . $info_photos['id_prop_pho'], |
---|
132 | ); |
---|
133 | }else if($info_photos['id_prop_pho']==2){ |
---|
134 | $items = array( |
---|
135 | 'IDINFOPHO' => $info_photos['id_prop_pho'], |
---|
136 | 'AIPWORDING' => l10n('Created on'), |
---|
137 | 'AIPORDER' => $info_photos['orderprop'], |
---|
138 | 'AIPACTIVE' => $info_photos['active'], |
---|
139 | 'AIPEDIT' => $info_photos['edit'], |
---|
140 | 'U_HIDE' => $admin_base_url . '&hide=' . $info_photos['id_prop_pho'], |
---|
141 | 'U_SHOW' => $admin_base_url . '&show=' . $info_photos['id_prop_pho'], |
---|
142 | ); |
---|
143 | }else if($info_photos['id_prop_pho']==3){ |
---|
144 | $items = array( |
---|
145 | 'IDINFOPHO' => $info_photos['id_prop_pho'], |
---|
146 | 'AIPWORDING' => l10n('Posted on'), |
---|
147 | 'AIPORDER' => $info_photos['orderprop'], |
---|
148 | 'AIPACTIVE' => $info_photos['active'], |
---|
149 | 'AIPEDIT' => $info_photos['edit'], |
---|
150 | 'U_HIDE' => $admin_base_url . '&hide=' . $info_photos['id_prop_pho'], |
---|
151 | 'U_SHOW' => $admin_base_url . '&show=' . $info_photos['id_prop_pho'], |
---|
152 | ); |
---|
153 | }else if($info_photos['id_prop_pho']==4){ |
---|
154 | $items = array( |
---|
155 | 'IDINFOPHO' => $info_photos['id_prop_pho'], |
---|
156 | 'AIPWORDING' => l10n('Dimensions'), |
---|
157 | 'AIPORDER' => $info_photos['orderprop'], |
---|
158 | 'AIPACTIVE' => $info_photos['active'], |
---|
159 | 'AIPEDIT' => $info_photos['edit'], |
---|
160 | 'U_HIDE' => $admin_base_url . '&hide=' . $info_photos['id_prop_pho'], |
---|
161 | 'U_SHOW' => $admin_base_url . '&show=' . $info_photos['id_prop_pho'], |
---|
162 | ); |
---|
163 | }else if($info_photos['id_prop_pho']==5){ |
---|
164 | $items = array( |
---|
165 | 'IDINFOPHO' => $info_photos['id_prop_pho'], |
---|
166 | 'AIPWORDING' => l10n('File'), |
---|
167 | 'AIPORDER' => $info_photos['orderprop'], |
---|
168 | 'AIPACTIVE' => $info_photos['active'], |
---|
169 | 'AIPEDIT' => $info_photos['edit'], |
---|
170 | 'U_HIDE' => $admin_base_url . '&hide=' . $info_photos['id_prop_pho'], |
---|
171 | 'U_SHOW' => $admin_base_url . '&show=' . $info_photos['id_prop_pho'], |
---|
172 | ); |
---|
173 | }else if($info_photos['id_prop_pho']==6){ |
---|
174 | $items = array( |
---|
175 | 'IDINFOPHO' => $info_photos['id_prop_pho'], |
---|
176 | 'AIPWORDING' => l10n('Filesize'), |
---|
177 | 'AIPORDER' => $info_photos['orderprop'], |
---|
178 | 'AIPACTIVE' => $info_photos['active'], |
---|
179 | 'AIPEDIT' => $info_photos['edit'], |
---|
180 | 'U_HIDE' => $admin_base_url . '&hide=' . $info_photos['id_prop_pho'], |
---|
181 | 'U_SHOW' => $admin_base_url . '&show=' . $info_photos['id_prop_pho'], |
---|
182 | ); |
---|
183 | }else if($info_photos['id_prop_pho']==7){ |
---|
184 | $items = array( |
---|
185 | 'IDINFOPHO' => $info_photos['id_prop_pho'], |
---|
186 | 'AIPWORDING' => l10n('Tags'), |
---|
187 | 'AIPORDER' => $info_photos['orderprop'], |
---|
188 | 'AIPACTIVE' => $info_photos['active'], |
---|
189 | 'AIPEDIT' => $info_photos['edit'], |
---|
190 | 'U_HIDE' => $admin_base_url . '&hide=' . $info_photos['id_prop_pho'], |
---|
191 | 'U_SHOW' => $admin_base_url . '&show=' . $info_photos['id_prop_pho'], |
---|
192 | ); |
---|
193 | }else if($info_photos['id_prop_pho']==8){ |
---|
194 | $items = array( |
---|
195 | 'IDINFOPHO' => $info_photos['id_prop_pho'], |
---|
196 | 'AIPWORDING' => l10n('Albums'), |
---|
197 | 'AIPORDER' => $info_photos['orderprop'], |
---|
198 | 'AIPACTIVE' => $info_photos['active'], |
---|
199 | 'AIPEDIT' => $info_photos['edit'], |
---|
200 | 'U_HIDE' => $admin_base_url . '&hide=' . $info_photos['id_prop_pho'], |
---|
201 | 'U_SHOW' => $admin_base_url . '&show=' . $info_photos['id_prop_pho'], |
---|
202 | ); |
---|
203 | }else if($info_photos['id_prop_pho']==9){ |
---|
204 | $items = array( |
---|
205 | 'IDINFOPHO' => $info_photos['id_prop_pho'], |
---|
206 | 'AIPWORDING' => l10n('Visits'), |
---|
207 | 'AIPORDER' => $info_photos['orderprop'], |
---|
208 | 'AIPACTIVE' => $info_photos['active'], |
---|
209 | 'AIPEDIT' => $info_photos['edit'], |
---|
210 | 'U_HIDE' => $admin_base_url . '&hide=' . $info_photos['id_prop_pho'], |
---|
211 | 'U_SHOW' => $admin_base_url . '&show=' . $info_photos['id_prop_pho'], |
---|
212 | ); |
---|
213 | }else if($info_photos['id_prop_pho']==10){ |
---|
214 | $items = array( |
---|
215 | 'IDINFOPHO' => $info_photos['id_prop_pho'], |
---|
216 | 'AIPWORDING' => l10n('Average'), |
---|
217 | 'AIPORDER' => $info_photos['orderprop'], |
---|
218 | 'AIPACTIVE' => $info_photos['active'], |
---|
219 | 'AIPEDIT' => $info_photos['edit'], |
---|
220 | 'U_HIDE' => $admin_base_url . '&hide=' . $info_photos['id_prop_pho'], |
---|
221 | 'U_SHOW' => $admin_base_url . '&show=' . $info_photos['id_prop_pho'], |
---|
222 | ); |
---|
223 | }else if($info_photos['id_prop_pho']==11){ |
---|
224 | $items = array( |
---|
225 | 'IDINFOPHO' => $info_photos['id_prop_pho'], |
---|
226 | 'AIPWORDING' => l10n('Who can see this photo?'), |
---|
227 | 'AIPORDER' => $info_photos['orderprop'], |
---|
228 | 'AIPACTIVE' => $info_photos['active'], |
---|
229 | 'AIPEDIT' => $info_photos['edit'], |
---|
230 | 'U_HIDE' => $admin_base_url . '&hide=' . $info_photos['id_prop_pho'], |
---|
231 | 'U_SHOW' => $admin_base_url . '&show=' . $info_photos['id_prop_pho'], |
---|
232 | ); |
---|
233 | }else{ |
---|
234 | $items = array( |
---|
235 | 'IDINFOPHO' => $info_photos['id_prop_pho'], |
---|
236 | 'AIPWORDING' => trigger_change('AP_render_content',$info_photos['wording']), |
---|
237 | 'AIPWORDING2' => $info_photos['wording'], |
---|
238 | 'AIPORDER' => $info_photos['orderprop'], |
---|
239 | 'AIPACTIVE' => $info_photos['active'], |
---|
240 | 'AIPEDIT' => $info_photos['edit'], |
---|
241 | 'U_DELETE' => $admin_base_url . '&delete=' . $info_photos['id_prop_pho'], |
---|
242 | 'U_HIDE' => $admin_base_url . '&hide=' . $info_photos['id_prop_pho'], |
---|
243 | 'U_SHOW' => $admin_base_url . '&show=' . $info_photos['id_prop_pho'], |
---|
244 | ); |
---|
245 | } |
---|
246 | $template->append('info_photos', $items); |
---|
247 | } |
---|
248 | } |
---|
249 | |
---|
250 | if (isset($_POST['submitManualOrderInfo'])){ |
---|
251 | |
---|
252 | asort($_POST['infoOrd'], SORT_NUMERIC); |
---|
253 | |
---|
254 | $data = array(); |
---|
255 | foreach ($_POST['infoOrd'] as $id =>$val){ |
---|
256 | |
---|
257 | $data[] = array('id_prop_pho' => $id, 'orderprop' => $val+1); |
---|
258 | } |
---|
259 | $fields = array('primary' => array('id_prop_pho'), 'update' => array('orderprop')); |
---|
260 | mass_updates(ADD_PROP_PHOTO_TABLE, $fields, $data); |
---|
261 | |
---|
262 | $page['infos'][] = l10n('Properties manual order was saved'); |
---|
263 | redirect($admin_base_url); |
---|
264 | } |
---|
265 | |
---|
266 | if (isset($_POST['submitaddAIP'])) { |
---|
267 | if (!isset($_POST['inseractive'])) { |
---|
268 | $_POST['inseractive'] = 0; |
---|
269 | } |
---|
270 | if ($_POST['invisibleID'] == 0) { |
---|
271 | $result = pwg_query('SELECT MAX(orderprop) FROM '. ADD_PROP_PHOTO_TABLE ); |
---|
272 | $row = pwg_db_fetch_assoc($result); |
---|
273 | $or = ($row['MAX(orderprop)'] + 1); |
---|
274 | |
---|
275 | $q = ' |
---|
276 | INSERT INTO ' . $prefixeTable . 'add_properties_photos(wording,orderprop,active,edit)VALUES ("' . $_POST['inserwording'] . '","' . $or . '","' . $_POST['inseractive'] . '",1);'; |
---|
277 | pwg_query($q); |
---|
278 | $_SESSION['page_infos'] = array(l10n('Property photo add')); |
---|
279 | } else { |
---|
280 | $q = ' |
---|
281 | UPDATE ' . $prefixeTable . 'add_properties_photos' |
---|
282 | . ' set wording ="' . $_POST['inserwording'] . '" ' |
---|
283 | . ' ,active=' . $_POST['inseractive'] |
---|
284 | . ' WHERE id_prop_pho=' . $_POST['invisibleID'] . ';'; |
---|
285 | pwg_query($q); |
---|
286 | $_SESSION['page_infos'] = array(l10n('Property photo update')); |
---|
287 | } |
---|
288 | redirect($admin_base_url); |
---|
289 | } |
---|
290 | |
---|
291 | if (isset($_GET['delete'])) { |
---|
292 | check_input_parameter('delete', $_GET, false, PATTERN_ID); |
---|
293 | $query = 'DELETE FROM ' . ADD_PROP_PHOTO_TABLE . ' WHERE id_prop_pho = ' . $_GET['delete'] . ';'; |
---|
294 | pwg_query($query); |
---|
295 | $query = 'DELETE FROM ' . ADD_PROP_PHOTO_DATA_TABLE . ' WHERE id_prop_pho = ' . $_GET['delete'] . ';'; |
---|
296 | pwg_query($query); |
---|
297 | |
---|
298 | $_SESSION['page_infos'] = array(l10n('Property delete')); |
---|
299 | redirect($admin_base_url); |
---|
300 | } |
---|
301 | |
---|
302 | if (isset($_GET['hide'])) { |
---|
303 | check_input_parameter('hide', $_GET, false, PATTERN_ID); |
---|
304 | $query = 'UPDATE ' . ADD_PROP_PHOTO_TABLE . ' SET active = 1 WHERE id_prop_pho=' . $_GET['hide'] . ';'; |
---|
305 | pwg_query($query); |
---|
306 | } |
---|
307 | |
---|
308 | if (isset($_GET['show'])) { |
---|
309 | check_input_parameter('show', $_GET, false, PATTERN_ID); |
---|
310 | $query = 'UPDATE ' . ADD_PROP_PHOTO_TABLE . ' SET active = 0 WHERE id_prop_pho=' . $_GET['show'] . ';'; |
---|
311 | pwg_query($query); |
---|
312 | } |
---|
313 | |
---|
314 | break; |
---|
315 | } |
---|
316 | |
---|
317 | |
---|
318 | $template->set_filenames(array('plugin_admin_content' => dirname(__FILE__) . '/admin/admin.tpl')); |
---|
319 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
320 | ?> |
---|