1 | <?php |
---|
2 | // +-----------------------------------------------------------------------+ |
---|
3 | // | Manage Properties Photos plugin for Piwigo by TEMMII | |
---|
4 | // +-----------------------------------------------------------------------+ |
---|
5 | // | Copyright(C) 2007-2022 ddtddt http://temmii.com/piwigo/ | |
---|
6 | // +-----------------------------------------------------------------------+ |
---|
7 | // | This program is free software; you can redistribute it and/or modify | |
---|
8 | // | it under the terms of the GNU General Public License as published by | |
---|
9 | // | the Free Software Foundation | |
---|
10 | // | | |
---|
11 | // | This program is distributed in the hope that it will be useful, but | |
---|
12 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
13 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
14 | // | General Public License for more details. | |
---|
15 | // | | |
---|
16 | // | You should have received a copy of the GNU General Public License | |
---|
17 | // | along with this program; if not, write to the Free Software | |
---|
18 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
19 | // | USA. | |
---|
20 | // +-----------------------------------------------------------------------+ |
---|
21 | |
---|
22 | if (!defined('PHPWG_ROOT_PATH')) |
---|
23 | die('Hacking attempt!'); |
---|
24 | global $template, $conf, $user, $pwg_loaded_plugins; |
---|
25 | include_once(PHPWG_ROOT_PATH . 'admin/include/tabsheet.class.php'); |
---|
26 | load_language('plugin.lang', ADD_PROP_PHOTO_PATH); |
---|
27 | $my_base_url = get_admin_plugin_menu_link(__FILE__); |
---|
28 | |
---|
29 | // +-----------------------------------------------------------------------+ |
---|
30 | // | Check Access and exit when user status is not ok | |
---|
31 | // +-----------------------------------------------------------------------+ |
---|
32 | check_status(ACCESS_ADMINISTRATOR); |
---|
33 | |
---|
34 | //-------------------------------------------------------- sections definitions |
---|
35 | |
---|
36 | $template->assign(array( |
---|
37 | 'ADD_PROP_PHOTO_PATH'=> get_root_url() . ADD_PROP_PHOTO_PATH, |
---|
38 | )); |
---|
39 | |
---|
40 | /*download_counter*/ |
---|
41 | if (isset($pwg_loaded_plugins['download_counter'])){ |
---|
42 | $row = pwg_db_fetch_assoc(pwg_query('SELECT dataprop FROM '. ADD_PROP_PHOTO_TABLE .' where dataprop ="plugdownload_counter";')); |
---|
43 | if(empty($row)){ |
---|
44 | $row = pwg_db_fetch_assoc(pwg_query('SELECT MAX(orderprop) FROM '. ADD_PROP_PHOTO_TABLE )); |
---|
45 | $or = ($row['MAX(orderprop)'] + 1); |
---|
46 | pwg_query('INSERT INTO ' . $prefixeTable . 'add_properties_photos(wording,orderprop,active,edit,Typ,dataprop)VALUES ("Download Counter","' . $or . '","0",0,"1","plugdownload_counter");'); |
---|
47 | } |
---|
48 | }else{ |
---|
49 | pwg_query('DELETE FROM ' . ADD_PROP_PHOTO_TABLE . ' where dataprop ="plugdownload_counter";'); |
---|
50 | } |
---|
51 | /*end*/ |
---|
52 | /*Color Palette*/ |
---|
53 | if (isset($pwg_loaded_plugins['ColorPalette'])){ |
---|
54 | $row = pwg_db_fetch_assoc(pwg_query('SELECT dataprop FROM '. ADD_PROP_PHOTO_TABLE .' where dataprop ="plugColorPalette";')); |
---|
55 | if(empty($row)){ |
---|
56 | $row = pwg_db_fetch_assoc(pwg_query('SELECT MAX(orderprop) FROM '. ADD_PROP_PHOTO_TABLE )); |
---|
57 | $or = ($row['MAX(orderprop)'] + 1); |
---|
58 | pwg_query('INSERT INTO ' . $prefixeTable . 'add_properties_photos(wording,orderprop,active,edit,Typ,dataprop)VALUES ("ColorPalette","' . $or . '","0",0,"1","plugColorPalette");'); |
---|
59 | } |
---|
60 | }else{ |
---|
61 | pwg_query('DELETE FROM ' . ADD_PROP_PHOTO_TABLE . ' where dataprop ="plugColorPalette";'); |
---|
62 | } |
---|
63 | /*end*/ |
---|
64 | /*Expiry Date*/ |
---|
65 | if (isset($pwg_loaded_plugins['expiry_date'])){ |
---|
66 | $row = pwg_db_fetch_assoc(pwg_query('SELECT dataprop FROM '. ADD_PROP_PHOTO_TABLE .' where dataprop ="plugexpiry_date";')); |
---|
67 | if(empty($row)){ |
---|
68 | $row = pwg_db_fetch_assoc(pwg_query('SELECT MAX(orderprop) FROM '. ADD_PROP_PHOTO_TABLE )); |
---|
69 | $or = ($row['MAX(orderprop)'] + 1); |
---|
70 | pwg_query('INSERT INTO ' . $prefixeTable . 'add_properties_photos(wording,orderprop,active,edit,Typ,dataprop)VALUES ("expiry_date","' . $or . '","0",0,"1","plugexpiry_date");'); |
---|
71 | } |
---|
72 | }else{ |
---|
73 | pwg_query('DELETE FROM ' . ADD_PROP_PHOTO_TABLE . ' where dataprop ="plugexpiry_date";'); |
---|
74 | } |
---|
75 | /*end*/ |
---|
76 | /*Copyrights*/ |
---|
77 | if (isset($pwg_loaded_plugins['Copyrights'])){ |
---|
78 | $row = pwg_db_fetch_assoc(pwg_query('SELECT dataprop FROM '. ADD_PROP_PHOTO_TABLE .' where dataprop ="plugCopyrights";')); |
---|
79 | if(empty($row)){ |
---|
80 | $row = pwg_db_fetch_assoc(pwg_query('SELECT MAX(orderprop) FROM '. ADD_PROP_PHOTO_TABLE )); |
---|
81 | $or = ($row['MAX(orderprop)'] + 1); |
---|
82 | pwg_query('INSERT INTO ' . $prefixeTable . 'add_properties_photos(wording,orderprop,active,edit,Typ,dataprop)VALUES ("Copyrights","' . $or . '","0",0,"1","plugCopyrights");'); |
---|
83 | } |
---|
84 | }else{ |
---|
85 | pwg_query('DELETE FROM ' . ADD_PROP_PHOTO_TABLE . ' where dataprop ="plugCopyrights";'); |
---|
86 | } |
---|
87 | /*end*/ |
---|
88 | /*added by*/ |
---|
89 | if (isset($pwg_loaded_plugins['Photo_add_by'])){ |
---|
90 | $row = pwg_db_fetch_assoc(pwg_query('SELECT dataprop FROM '. ADD_PROP_PHOTO_TABLE .' where dataprop ="plugPhoto_add_by";')); |
---|
91 | if(empty($row)){ |
---|
92 | $row = pwg_db_fetch_assoc(pwg_query('SELECT MAX(orderprop) FROM '. ADD_PROP_PHOTO_TABLE )); |
---|
93 | $or = ($row['MAX(orderprop)'] + 1); |
---|
94 | pwg_query('INSERT INTO ' . $prefixeTable . 'add_properties_photos(wording,orderprop,active,edit,Typ,dataprop)VALUES ("addedby","' . $or . '","0",0,"1","plugPhoto_add_by");'); |
---|
95 | } |
---|
96 | }else{ |
---|
97 | pwg_query('DELETE FROM ' . ADD_PROP_PHOTO_TABLE . ' where dataprop ="plugPhoto_add_by";'); |
---|
98 | } |
---|
99 | /*end*/ |
---|
100 | |
---|
101 | if (!isset($_GET['tab'])) |
---|
102 | $page['tab'] = 'define_properties'; |
---|
103 | else |
---|
104 | $page['tab'] = $_GET['tab']; |
---|
105 | |
---|
106 | |
---|
107 | if ($page['tab'] != 'iap') { |
---|
108 | $tabsheet = new tabsheet(); |
---|
109 | $tabsheet->add('addip', l10n('Property'), ADD_PROP_PHOTO_ADMIN . '-define_properties'); |
---|
110 | $tabsheet->add('config', l10n('Configuration'), ADD_PROP_PHOTO_ADMIN . '-config'); |
---|
111 | $tabsheet->select($page['tab']); |
---|
112 | $tabsheet->assign(); |
---|
113 | } else if ($_GET['tab'] == 'iap') { |
---|
114 | |
---|
115 | $page['active_menu'] = get_active_menu('photo'); // force oppening "Photos" menu block |
---|
116 | |
---|
117 | /* Basic checks */ |
---|
118 | check_status(ACCESS_ADMINISTRATOR); |
---|
119 | |
---|
120 | check_input_parameter('image_id', $_GET, false, PATTERN_ID); |
---|
121 | $id_img = $_GET['image_id']; |
---|
122 | $admin_photo_base_url = get_root_url() . 'admin.php?page=photo-' . $_GET['image_id']; |
---|
123 | |
---|
124 | $page['tab'] = 'iap'; |
---|
125 | |
---|
126 | $tabsheet = new tabsheet(); |
---|
127 | $tabsheet->set_id('photo'); |
---|
128 | $tabsheet->select('iap'); |
---|
129 | $tabsheet->assign(); |
---|
130 | |
---|
131 | $template->assign( |
---|
132 | 'gestionD', array( |
---|
133 | 'A' => 'a' |
---|
134 | )); |
---|
135 | |
---|
136 | if (isset($pwg_loaded_plugins['ExtendedDescription'])){ |
---|
137 | add_event_handler('AP_render_content', 'get_user_language_desc'); |
---|
138 | $template->assign('useED',1); |
---|
139 | }else{ |
---|
140 | $template->assign('useED',0); |
---|
141 | } |
---|
142 | |
---|
143 | $tab_add_info_one_photo = tab_add_info_by_photo($_GET['image_id']); |
---|
144 | if (pwg_db_num_rows($tab_add_info_one_photo)) { |
---|
145 | while ($info_photos = pwg_db_fetch_assoc($tab_add_info_one_photo)) { |
---|
146 | if($info_photos['Typ']==2){ |
---|
147 | $d = data_info_photosdate($id_img, $info_photos['id_prop_pho']); |
---|
148 | $row = pwg_db_fetch_assoc($d); |
---|
149 | |
---|
150 | $items = array( |
---|
151 | 'IDPHO' => $_GET['image_id'], |
---|
152 | 'IDINFOPHO' => $info_photos['id_prop_pho'], |
---|
153 | 'AIPWORDING' => trigger_change('AP_render_content',$info_photos['wording']), |
---|
154 | 'AIPDATA' => $row['datadate'], |
---|
155 | 'AIPTYP' => $info_photos['Typ'], |
---|
156 | ); |
---|
157 | if(isset($row['datadate'])){ |
---|
158 | $items['AIPDATA']=$row['datadate']; |
---|
159 | } |
---|
160 | if($info_photos['wording']=="**delpho**"){ |
---|
161 | $items['AIPWORDING'] =l10n('Delete photo'); |
---|
162 | } |
---|
163 | }else{ |
---|
164 | $d = data_info_photos($id_img, $info_photos['id_prop_pho']); |
---|
165 | $row = pwg_db_fetch_assoc($d); |
---|
166 | |
---|
167 | $items = array( |
---|
168 | 'IDPHO' => $_GET['image_id'], |
---|
169 | 'IDINFOPHO' => $info_photos['id_prop_pho'], |
---|
170 | 'AIPWORDING' => trigger_change('AP_render_content',$info_photos['wording']), |
---|
171 | 'AIPTYP' => $info_photos['Typ'], |
---|
172 | ); |
---|
173 | if(isset($row['data'])){ |
---|
174 | $items['AIPDATA']=$row['data']; |
---|
175 | } |
---|
176 | if($info_photos['Typ']==4||$info_photos['Typ']==5){ |
---|
177 | $items['AIPSELECT']=unserialize($info_photos['dataprop']); |
---|
178 | foreach ($items['AIPSELECT'] as $key => $dataselect){ |
---|
179 | $items['AIPSELECTTRANS'][] = trigger_change('AP_render_content',$dataselect); |
---|
180 | } |
---|
181 | } |
---|
182 | } |
---|
183 | $template->append('info_photosI', $items); |
---|
184 | } |
---|
185 | } |
---|
186 | |
---|
187 | if (isset($_POST['submitaddinfoimg'])) { |
---|
188 | foreach ($_POST['data'] AS $id_prop_pho => $data) { |
---|
189 | $q = 'SELECT 1 FROM ' . ADD_PROP_PHOTO_DATA_TABLE . ' WHERE id_img=' . $id_img . ' AND id_prop_pho=' . $id_prop_pho; |
---|
190 | $test = pwg_query($q); |
---|
191 | $row = pwg_db_fetch_assoc($test); |
---|
192 | if (count($row) > 0) { |
---|
193 | if ($data != '') { |
---|
194 | $query = 'UPDATE ' . $prefixeTable . 'add_properties_photos_data SET data="' . $data . '" WHERE id_img=' . $id_img . ' AND id_prop_pho=' . $id_prop_pho; |
---|
195 | pwg_query($query); |
---|
196 | } else { |
---|
197 | $query = 'DELETE FROM ' . $prefixeTable . 'add_properties_photos_data WHERE id_img=' . $id_img . ' AND id_prop_pho=' . $id_prop_pho; |
---|
198 | pwg_query($query); |
---|
199 | } |
---|
200 | } else if ($data != '') { |
---|
201 | $query = 'INSERT ' . $prefixeTable . 'add_properties_photos_data(id_img,id_prop_pho,data) VALUES (' . $id_img . ',' . $id_prop_pho . ',"' . $data . '");'; |
---|
202 | pwg_query($query); |
---|
203 | } |
---|
204 | } |
---|
205 | foreach ($_POST['datadate'] AS $id_prop_pho => $data) { |
---|
206 | $q = 'SELECT 1 FROM ' . ADD_PROP_PHOTO_DATADATE_TABLE . ' WHERE id_img=' . $id_img . ' AND id_prop_pho=' . $id_prop_pho; |
---|
207 | $test = pwg_query($q); |
---|
208 | $row = pwg_db_fetch_assoc($test); |
---|
209 | if (count($row) > 0) { |
---|
210 | if ($data != '') { |
---|
211 | $query = 'UPDATE ' . $prefixeTable . 'add_properties_photos_datadate SET datadate="' . $data . '" WHERE id_img=' . $id_img . ' AND id_prop_pho=' . $id_prop_pho; |
---|
212 | pwg_query($query); |
---|
213 | } else { |
---|
214 | $query = 'DELETE FROM ' . $prefixeTable . 'add_properties_photos_datadate WHERE id_img=' . $id_img . ' AND id_prop_pho=' . $id_prop_pho; |
---|
215 | pwg_query($query); |
---|
216 | } |
---|
217 | } else if ($data != '') { |
---|
218 | $query = 'INSERT ' . $prefixeTable . 'add_properties_photos_datadate(id_img,id_prop_pho,datadate) VALUES (' . $id_img . ',' . $id_prop_pho . ',"' . $data . '");'; |
---|
219 | pwg_query($query); |
---|
220 | } |
---|
221 | } |
---|
222 | $redirect_url = ADD_PROP_PHOTO_ADMIN . '-iap&image_id=' . $id_img; |
---|
223 | $_SESSION['page_infos'] = array(l10n('Properties update')); |
---|
224 | redirect($redirect_url); |
---|
225 | } |
---|
226 | } |
---|
227 | |
---|
228 | switch ($page['tab']) { |
---|
229 | case 'define_properties': |
---|
230 | $admin_base_url = ADD_PROP_PHOTO_ADMIN . '-define_properties'; |
---|
231 | $template->assign( |
---|
232 | 'addinfotemplate', array( |
---|
233 | 'addinfo' => l10n('addinfo'), |
---|
234 | )); |
---|
235 | $maxfields = (isset($conf['mpp_max_fields'])) ? $conf['mpp_max_fields'] : '5'; |
---|
236 | $template->assign('MPPMAXFIELD',$maxfields); |
---|
237 | |
---|
238 | if (isset($pwg_loaded_plugins['ExtendedDescription'])){ |
---|
239 | add_event_handler('AP_render_content', 'get_user_language_desc'); |
---|
240 | $template->assign('useED',1); |
---|
241 | }else{ |
---|
242 | $template->assign('useED',0); |
---|
243 | } |
---|
244 | |
---|
245 | $admin_base_url = ADD_PROP_PHOTO_ADMIN . '-define_properties'; |
---|
246 | $tab_info_photos = tab_info_photos(); |
---|
247 | |
---|
248 | if (pwg_db_num_rows($tab_info_photos)) { |
---|
249 | while ($info_photos = pwg_db_fetch_assoc($tab_info_photos)) { |
---|
250 | $items = array( |
---|
251 | 'IDINFOPHO' => $info_photos['id_prop_pho'], |
---|
252 | 'AIPORDER' => $info_photos['orderprop'], |
---|
253 | 'AIPACTIVE' => $info_photos['active'], |
---|
254 | 'AIPEDIT' => $info_photos['edit'], |
---|
255 | 'U_HIDE' => $admin_base_url . '&hide=' . $info_photos['id_prop_pho'], |
---|
256 | 'U_SHOW' => $admin_base_url . '&show=' . $info_photos['id_prop_pho'] |
---|
257 | ); |
---|
258 | if($info_photos['id_prop_pho']==1){ |
---|
259 | $items['AIPWORDING'] = l10n('Author'); |
---|
260 | }else if($info_photos['id_prop_pho']==2){ |
---|
261 | $items['AIPWORDING'] = l10n('Created on'); |
---|
262 | }else if($info_photos['id_prop_pho']==3){ |
---|
263 | $items['AIPWORDING'] = l10n('Posted on'); |
---|
264 | }else if($info_photos['id_prop_pho']==4){ |
---|
265 | $items['AIPWORDING'] = l10n('Dimensions'); |
---|
266 | }else if($info_photos['id_prop_pho']==5){ |
---|
267 | $items['AIPWORDING'] = l10n('File'); |
---|
268 | }else if($info_photos['id_prop_pho']==6){ |
---|
269 | $items['AIPWORDING'] = l10n('Filesize'); |
---|
270 | }else if($info_photos['id_prop_pho']==7){ |
---|
271 | $items['AIPWORDING'] = l10n('Tags'); |
---|
272 | }else if($info_photos['id_prop_pho']==8){ |
---|
273 | $items['AIPWORDING'] = l10n('Albums'); |
---|
274 | }else if($info_photos['id_prop_pho']==9){ |
---|
275 | $items['AIPWORDING'] = l10n('Visits'); |
---|
276 | }else if($info_photos['id_prop_pho']==10){ |
---|
277 | $items['AIPWORDING'] = l10n('Rating score'); |
---|
278 | }else if($info_photos['id_prop_pho']==11){ |
---|
279 | $items['AIPWORDING'] = l10n('Who can see this photo?'); |
---|
280 | }else{ |
---|
281 | if($info_photos['dataprop']=="DeletePhoto" and $info_photos['wording'] ="**delpho**"){ |
---|
282 | $items['AIPWORDING'] = l10n('Delete photo'); |
---|
283 | }else if($info_photos['dataprop']=="movedescription"){ |
---|
284 | $items['AIPWORDING'] = l10n('Description'); |
---|
285 | }else if($info_photos['dataprop']=="showid"){ |
---|
286 | $items['AIPWORDING'] = l10n('Image id'); |
---|
287 | }else if($info_photos['dataprop']=="plugPhoto_add_by"){ |
---|
288 | $items['AIPWORDING'] = l10n('Plugins')." - ".l10n('Photo added by'); |
---|
289 | }else if($info_photos['dataprop']=="plugdownload_counter"){ |
---|
290 | $items['AIPWORDING'] = l10n('Plugins')." - ".l10n('Downloads'); |
---|
291 | }else if($info_photos['dataprop']=="plugColorPalette"){ |
---|
292 | $items['AIPWORDING'] = l10n('Plugins')." - ".l10n('Palette'); |
---|
293 | }else if($info_photos['dataprop']=="plugexpiry_date"){ |
---|
294 | $items['AIPWORDING'] = l10n('Plugins')." - ".l10n('Expiry date'); |
---|
295 | }else if($info_photos['dataprop']=="plugCopyrights"){ |
---|
296 | $items['AIPWORDING'] = l10n('Plugins')." - ".l10n('Copyrights'); |
---|
297 | }else{ |
---|
298 | $items['AIPWORDING'] = trigger_change('AP_render_content',$info_photos['wording']); |
---|
299 | } |
---|
300 | $items['AIPWORDING2'] = $info_photos['wording']; |
---|
301 | $items['U_DELETE'] = $admin_base_url . '&delete=' . $info_photos['id_prop_pho']; |
---|
302 | $items['AIPTYP'] = $info_photos['Typ']; |
---|
303 | if($info_photos['Typ']==4||$info_photos['Typ']==5){ |
---|
304 | $items['AIPDATAPROP'] = json_encode(unserialize($info_photos['dataprop'])); |
---|
305 | } |
---|
306 | if($info_photos['Typ']==3||$info_photos['Typ']==6){ |
---|
307 | $items['AIPDATAPROP'] = $info_photos['dataprop']; |
---|
308 | } |
---|
309 | } |
---|
310 | $template->append('info_photos', $items); |
---|
311 | } |
---|
312 | |
---|
313 | $idexifone = pwg_db_fetch_assoc(pwg_query("SELECT MIN(id) as id FROM " . IMAGES_TABLE .";")); |
---|
314 | $idexif = (isset($conf['mpp_idexif'])) ? $conf['mpp_idexif'] : $idexifone['id']; |
---|
315 | $filename = pwg_db_fetch_assoc(pwg_query("SELECT path FROM " . IMAGES_TABLE . " WHERE id = '".$idexif."';")); |
---|
316 | if(empty($filename['path'])){ |
---|
317 | $_SESSION['page_errors'] = array(l10n('reference photo id doesn\'t exist please update')); |
---|
318 | }else if(exif_imagetype($filename['path']) != IMAGETYPE_JPEG and exif_imagetype($filename['path']) != IMAGETYPE_TIFF_II and exif_imagetype($filename['path']) != IMAGETYPE_TIFF_MM){ |
---|
319 | $_SESSION['page_errors'] = array(l10n('reference photo type doesn\'t use metadata please update')); |
---|
320 | }else{ |
---|
321 | $exif = @exif_read_data($filename['path']); |
---|
322 | foreach ($exif as $key => $section){ |
---|
323 | if(is_array($section)){ |
---|
324 | $i=0; |
---|
325 | foreach ($section as $name => $value){ |
---|
326 | if($i==0){ |
---|
327 | $items['RM_AFF'] = $key; |
---|
328 | }else{ |
---|
329 | $items['RM_AFF'] = ''; |
---|
330 | } |
---|
331 | $items['RM_SECTION'] = $key; |
---|
332 | $items['RM_KEY'] = $name; |
---|
333 | $template->append('rm_exif', $items); |
---|
334 | $i++; |
---|
335 | } |
---|
336 | }else{ |
---|
337 | $items['RM_SECTION'] = '1'; |
---|
338 | $items['RM_KEY'] = $key; |
---|
339 | $items['RM_VALUE'] = $section; |
---|
340 | $template->append('rm_exif', $items); |
---|
341 | } |
---|
342 | } |
---|
343 | $iptc_result = array(); |
---|
344 | $imginfo = array(); |
---|
345 | getimagesize($filename['path'], $imginfo); |
---|
346 | if (isset ($imginfo['APP13'])){ |
---|
347 | $iptc = iptcparse($imginfo['APP13']); |
---|
348 | if (is_array($iptc)){ |
---|
349 | foreach (array_keys($iptc) as $iptc_key){ |
---|
350 | if (isset($iptc[$iptc_key][0])){ |
---|
351 | $iptc_result[$iptc_key] = $value; |
---|
352 | } |
---|
353 | } |
---|
354 | } |
---|
355 | $keys = array_keys($iptc_result); |
---|
356 | sort($keys); |
---|
357 | foreach ($keys as $key){ |
---|
358 | $items['RM_KEY'] = $key; |
---|
359 | $template->append('rm_iptc', $items); |
---|
360 | } |
---|
361 | } |
---|
362 | } |
---|
363 | } |
---|
364 | |
---|
365 | if (isset($_POST['submitManualOrderInfo'])){ |
---|
366 | |
---|
367 | asort($_POST['infoOrd'], SORT_NUMERIC); |
---|
368 | |
---|
369 | $data = array(); |
---|
370 | foreach ($_POST['infoOrd'] as $id =>$val){ |
---|
371 | |
---|
372 | $data[] = array('id_prop_pho' => $id, 'orderprop' => $val+1); |
---|
373 | } |
---|
374 | $fields = array('primary' => array('id_prop_pho'), 'update' => array('orderprop')); |
---|
375 | mass_updates(ADD_PROP_PHOTO_TABLE, $fields, $data); |
---|
376 | |
---|
377 | $page['infos'][] = l10n('Properties manual order was saved'); |
---|
378 | redirect($admin_base_url); |
---|
379 | } |
---|
380 | |
---|
381 | if (isset($_POST['submitaddAIP'])) { |
---|
382 | if ($_POST['inserwording'] == '') { |
---|
383 | $_SESSION['page_errors'] = array(l10n('Wording isn\'t empty')); |
---|
384 | redirect($admin_base_url); |
---|
385 | } |
---|
386 | if ($_POST['typ'] == '4'||$_POST['typ'] == '5') { |
---|
387 | $select= serialize($_POST['mytext']); |
---|
388 | } |
---|
389 | if ($_POST['typ'] == '3') { |
---|
390 | if($_POST['selectexif']==''){ |
---|
391 | $_SESSION['page_errors'] = array(l10n('exif field can\'t be empty')); |
---|
392 | redirect($admin_base_url); |
---|
393 | } |
---|
394 | $select= $_POST['selectexif']; |
---|
395 | } |
---|
396 | if ($_POST['typ'] == '6') { |
---|
397 | if($_POST['selectiptc']==''){ |
---|
398 | $_SESSION['page_errors'] = array(l10n('IPTC field can\'t be empty')); |
---|
399 | redirect($admin_base_url); |
---|
400 | } |
---|
401 | $select= $_POST['selectiptc']; |
---|
402 | } |
---|
403 | if (!isset($_POST['inseractive'])) { |
---|
404 | $_POST['inseractive'] = 0; |
---|
405 | } |
---|
406 | if ($_POST['invisibleID'] == 0) { |
---|
407 | $result = pwg_query('SELECT MAX(orderprop) FROM '. ADD_PROP_PHOTO_TABLE ); |
---|
408 | $row = pwg_db_fetch_assoc($result); |
---|
409 | $or = ($row['MAX(orderprop)'] + 1); |
---|
410 | if ($_POST['typ'] == '4'||$_POST['typ'] == '3'||$_POST['typ'] == '5'||$_POST['typ'] == '6') { |
---|
411 | $q = 'INSERT INTO ' . $prefixeTable . 'add_properties_photos(wording,orderprop,active,edit,Typ,dataprop)VALUES ("' . $_POST['inserwording'] . '","' . $or . '","' . $_POST['inseractive'] . '",1,"' . $_POST['typ'] . '",\''. $select .'\');'; |
---|
412 | pwg_query($q); |
---|
413 | }else{ |
---|
414 | $q = 'INSERT INTO ' . $prefixeTable . 'add_properties_photos(wording,orderprop,active,edit,Typ)VALUES ("' . $_POST['inserwording'] . '","' . $or . '","' . $_POST['inseractive'] . '",1,"' . $_POST['typ'] . '");'; |
---|
415 | pwg_query($q); |
---|
416 | } |
---|
417 | $_SESSION['page_infos'] = array(l10n('Property photo add')); |
---|
418 | } else { |
---|
419 | if ($_POST['typ'] == '4'||$_POST['typ'] == '3'||$_POST['typ'] == '5'||$_POST['typ'] == '6') { |
---|
420 | $q = ' |
---|
421 | UPDATE ' . $prefixeTable . 'add_properties_photos' |
---|
422 | . ' set wording ="' . $_POST['inserwording'] . '" ' |
---|
423 | . ' ,active =' . $_POST['inseractive'] |
---|
424 | . ' ,Typ =' . $_POST['typ'] |
---|
425 | . ' ,dataprop =\'' . $select . '\' ' |
---|
426 | . ' WHERE id_prop_pho=' . $_POST['invisibleID'] . ';'; |
---|
427 | }else{ |
---|
428 | $q = ' |
---|
429 | UPDATE ' . $prefixeTable . 'add_properties_photos' |
---|
430 | . ' set wording ="' . $_POST['inserwording'] . '" ' |
---|
431 | . ' ,active=' . $_POST['inseractive'] |
---|
432 | . ' ,Typ =' . $_POST['typ'] |
---|
433 | . ' WHERE id_prop_pho=' . $_POST['invisibleID'] . ';'; |
---|
434 | } |
---|
435 | pwg_query($q); |
---|
436 | $_SESSION['page_infos'] = array(l10n('Property photo update')); |
---|
437 | } |
---|
438 | redirect($admin_base_url); |
---|
439 | } |
---|
440 | |
---|
441 | if (isset($_GET['delete'])) { |
---|
442 | check_input_parameter('delete', $_GET, false, PATTERN_ID); |
---|
443 | $query = 'DELETE FROM ' . ADD_PROP_PHOTO_TABLE . ' WHERE id_prop_pho = ' . $_GET['delete'] . ';'; |
---|
444 | pwg_query($query); |
---|
445 | $query = 'DELETE FROM ' . ADD_PROP_PHOTO_DATA_TABLE . ' WHERE id_prop_pho = ' . $_GET['delete'] . ';'; |
---|
446 | pwg_query($query); |
---|
447 | $query = 'DELETE FROM ' . ADD_PROP_PHOTO_DATADATE_TABLE . ' WHERE id_prop_pho = ' . $_GET['delete'] . ';'; |
---|
448 | pwg_query($query); |
---|
449 | |
---|
450 | $_SESSION['page_infos'] = array(l10n('Property delete')); |
---|
451 | redirect($admin_base_url); |
---|
452 | } |
---|
453 | |
---|
454 | if (isset($_GET['hide'])) { |
---|
455 | check_input_parameter('hide', $_GET, false, PATTERN_ID); |
---|
456 | $query = 'UPDATE ' . ADD_PROP_PHOTO_TABLE . ' SET active = 1 WHERE id_prop_pho=' . $_GET['hide'] . ';'; |
---|
457 | pwg_query($query); |
---|
458 | } |
---|
459 | |
---|
460 | if (isset($_GET['show'])) { |
---|
461 | check_input_parameter('show', $_GET, false, PATTERN_ID); |
---|
462 | $query = 'UPDATE ' . ADD_PROP_PHOTO_TABLE . ' SET active = 0 WHERE id_prop_pho=' . $_GET['show'] . ';'; |
---|
463 | pwg_query($query); |
---|
464 | } |
---|
465 | |
---|
466 | break; |
---|
467 | case 'config': |
---|
468 | $maxfields = (isset($conf['mpp_max_fields'])) ? $conf['mpp_max_fields'] : '5'; |
---|
469 | $template->assign('MPPMAXFIELD',$maxfields); |
---|
470 | $idexif = (isset($conf['mpp_idexif'])) ? $conf['mpp_idexif'] : ''; |
---|
471 | $template->assign('MPPIDEXIF',$idexif); |
---|
472 | $admin_base_url = ADD_PROP_PHOTO_ADMIN . '-config'; |
---|
473 | $template->assign( |
---|
474 | 'mppconfig', array( |
---|
475 | 'a' => 'a', |
---|
476 | )); |
---|
477 | |
---|
478 | $delpho = pwg_db_fetch_assoc(pwg_query('SELECT dataprop FROM ' . ADD_PROP_PHOTO_TABLE.' WHERE dataprop="DeletePhoto";')); |
---|
479 | if(empty($delpho)){ |
---|
480 | $template->assign( |
---|
481 | 'mppconfig', array( |
---|
482 | 'ADDPHOAC' => 'actiondelphoadd', |
---|
483 | )); |
---|
484 | } |
---|
485 | if (isset($_POST['submitadddelpho'])){ |
---|
486 | $result = pwg_query('SELECT MAX(orderprop) FROM '. ADD_PROP_PHOTO_TABLE ); |
---|
487 | $row = pwg_db_fetch_assoc($result); |
---|
488 | $or = ($row['MAX(orderprop)'] + 1); |
---|
489 | $q = 'INSERT INTO ' . $prefixeTable . 'add_properties_photos(wording,orderprop,active,edit,Typ,dataprop)VALUES ("**delpho**","' . $or . '","1",1,"2","DeletePhoto");'; |
---|
490 | pwg_query($q); |
---|
491 | $_SESSION['page_infos'] = array(l10n('Information data registered in database')); |
---|
492 | redirect(ADD_PROP_PHOTO_ADMIN . '-config'); |
---|
493 | } |
---|
494 | if (isset($_POST['submitremovedelpho'])){ |
---|
495 | $iddelpho = pwg_db_fetch_assoc(pwg_query('SELECT id_prop_pho FROM '. ADD_PROP_PHOTO_TABLE.' where dataprop="DeletePhoto";')); |
---|
496 | pwg_query('DELETE FROM ' . ADD_PROP_PHOTO_TABLE . ' where dataprop ="DeletePhoto";'); |
---|
497 | $query = 'DELETE FROM ' . ADD_PROP_PHOTO_DATADATE_TABLE . ' WHERE id_prop_pho = ' . $iddelpho['id_prop_pho'] . ';'; |
---|
498 | pwg_query($query); |
---|
499 | $_SESSION['page_infos'] = array(l10n('Information data registered in database')); |
---|
500 | redirect(ADD_PROP_PHOTO_ADMIN . '-config'); |
---|
501 | } |
---|
502 | $descpho = pwg_db_fetch_assoc(pwg_query('SELECT dataprop FROM ' . ADD_PROP_PHOTO_TABLE.' WHERE dataprop="movedescription";')); |
---|
503 | if(empty($descpho)){ |
---|
504 | $vars['MOVEDESC']='actionmovedesc'; |
---|
505 | $template->append('mppconfig', $vars, true); |
---|
506 | } |
---|
507 | if (isset($_POST['submitmovedesc'])){ |
---|
508 | $result = pwg_query('SELECT MAX(orderprop) FROM '. ADD_PROP_PHOTO_TABLE ); |
---|
509 | $row = pwg_db_fetch_assoc($result); |
---|
510 | $or = ($row['MAX(orderprop)'] + 1); |
---|
511 | $q = 'INSERT INTO ' . $prefixeTable . 'add_properties_photos(wording,orderprop,active,edit,Typ,dataprop)VALUES ("Description","' . $or . '","0",0,"1","movedescription");'; |
---|
512 | pwg_query($q); |
---|
513 | $_SESSION['page_infos'] = array(l10n('Information data registered in database')); |
---|
514 | redirect(ADD_PROP_PHOTO_ADMIN . '-config'); |
---|
515 | } |
---|
516 | if (isset($_POST['submitdefaultdesc'])){ |
---|
517 | pwg_query('DELETE FROM ' . ADD_PROP_PHOTO_TABLE . ' where dataprop ="movedescription";'); |
---|
518 | $_SESSION['page_infos'] = array(l10n('Information data registered in database')); |
---|
519 | redirect(ADD_PROP_PHOTO_ADMIN . '-config'); |
---|
520 | } |
---|
521 | if (isset($_POST['submitmppoption'])){ |
---|
522 | conf_update_param('mpp_max_fields', $_POST['mppmaxfield']); |
---|
523 | conf_update_param('mpp_idexif', $_POST['mppitidexif']); |
---|
524 | $_SESSION['page_infos'] = array(l10n('Information data registered in database')); |
---|
525 | redirect(ADD_PROP_PHOTO_ADMIN . '-config'); |
---|
526 | } |
---|
527 | $mppshid = pwg_db_fetch_assoc(pwg_query('SELECT dataprop FROM ' . ADD_PROP_PHOTO_TABLE.' WHERE dataprop="showid";')); |
---|
528 | if(empty($mppshid)){ |
---|
529 | $vars['MPPSHID']='actionschowid'; |
---|
530 | $template->append('mppconfig', $vars, true); |
---|
531 | } |
---|
532 | if (isset($_POST['submitmppsid'])){ |
---|
533 | $row = pwg_db_fetch_assoc(pwg_query('SELECT MAX(orderprop) FROM '. ADD_PROP_PHOTO_TABLE )); |
---|
534 | $or = ($row['MAX(orderprop)'] + 1); |
---|
535 | $q = 'INSERT INTO ' . $prefixeTable . 'add_properties_photos(wording,orderprop,active,edit,Typ,dataprop)VALUES ("ID","' . $or . '","0",0,"1","showid");'; |
---|
536 | pwg_query($q); |
---|
537 | $_SESSION['page_infos'] = array(l10n('Information data registered in database')); |
---|
538 | redirect(ADD_PROP_PHOTO_ADMIN . '-config'); |
---|
539 | } |
---|
540 | if (isset($_POST['submitmpphid'])){ |
---|
541 | pwg_query('DELETE FROM ' . ADD_PROP_PHOTO_TABLE . ' where dataprop ="showid";'); |
---|
542 | $_SESSION['page_infos'] = array(l10n('Information data registered in database')); |
---|
543 | redirect(ADD_PROP_PHOTO_ADMIN . '-config'); |
---|
544 | } |
---|
545 | break; |
---|
546 | } |
---|
547 | |
---|
548 | |
---|
549 | $template->set_filenames(array('plugin_admin_content' => dirname(__FILE__) . '/admin/admin.tpl')); |
---|
550 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
551 | ?> |
---|