source: extensions/manage_properties_photos/admin.php

Last change on this file was 32902, checked in by ddtddt, 15 months ago

[manage_properties_photos] compatybilité php8

File size: 25.1 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | Manage Properties Photos plugin for Piwigo by TEMMII                  |
4// +-----------------------------------------------------------------------+
5// | Copyright(C) 2007-2023 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
22if (!defined('PHPWG_ROOT_PATH'))
23    die('Hacking attempt!');
24global $template, $conf, $user, $pwg_loaded_plugins;
25include_once(PHPWG_ROOT_PATH . 'admin/include/tabsheet.class.php');
26load_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// +-----------------------------------------------------------------------+
32check_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*/
41if (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*/
53if (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*/
65if (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*/
77if (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*/
89if (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
101if (!isset($_GET['tab']))
102    $page['tab'] = 'define_properties';
103else
104    $page['tab'] = $_GET['tab'];
105
106
107if ($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                                }else{
160                                        $items['AIPDATA']="";   
161                                }
162                                if($info_photos['wording']=="**delpho**"){
163                                        $items['AIPWORDING'] =l10n('Delete photo');
164                                }
165                        }else{
166                                $d = data_info_photos($id_img, $info_photos['id_prop_pho']);
167                                $row = pwg_db_fetch_assoc($d);
168
169                                $items = array(
170                                        'IDPHO' => $_GET['image_id'],
171                                        'IDINFOPHO' => $info_photos['id_prop_pho'],
172                                        'AIPWORDING' => trigger_change('AP_render_content',$info_photos['wording']),
173                                        'AIPTYP' => $info_photos['Typ'],
174                                );
175                                if(isset($row['data'])){
176                                  $items['AIPDATA']=$row['data'];       
177                                }else{
178                                  $items['AIPDATA']=""; 
179                                }
180                                if($info_photos['Typ']==4||$info_photos['Typ']==5){
181                                        $items['AIPSELECT']=unserialize($info_photos['dataprop']);
182                                        foreach ($items['AIPSELECT'] as $key => $dataselect){
183                                                $items['AIPSELECTTRANS'][] = trigger_change('AP_render_content',$dataselect);
184                                        }
185                                }
186                        }
187            $template->append('info_photosI', $items);
188        }
189    }
190
191    if (isset($_POST['submitaddinfoimg'])) {
192        foreach ($_POST['data'] AS $id_prop_pho => $data) {
193            $q = 'SELECT 1 FROM ' . ADD_PROP_PHOTO_DATA_TABLE . ' WHERE id_img=' . $id_img . ' AND id_prop_pho=' . $id_prop_pho;
194            $test = pwg_query($q);
195            $row = pwg_db_fetch_assoc($test);
196            if (!empty($row)) {
197                if ($data != '') {
198                    $query = 'UPDATE ' . $prefixeTable . 'add_properties_photos_data SET data="' . $data . '" WHERE id_img=' . $id_img . ' AND id_prop_pho=' . $id_prop_pho;
199                    pwg_query($query);
200                } else {
201                    $query = 'DELETE FROM ' . $prefixeTable . 'add_properties_photos_data WHERE id_img=' . $id_img . ' AND id_prop_pho=' . $id_prop_pho;
202                    pwg_query($query);
203                }
204            } else if ($data != '') {
205                $query = 'INSERT ' . $prefixeTable . 'add_properties_photos_data(id_img,id_prop_pho,data) VALUES (' . $id_img . ',' . $id_prop_pho . ',"' . $data . '");';
206                pwg_query($query);
207            }   
208        }
209                        foreach ($_POST['datadate'] AS $id_prop_pho => $data) {
210            $q = 'SELECT 1 FROM ' . ADD_PROP_PHOTO_DATADATE_TABLE . ' WHERE id_img=' . $id_img . ' AND id_prop_pho=' . $id_prop_pho;
211            $test = pwg_query($q);
212            $row = pwg_db_fetch_assoc($test);
213            if (!empty($row)) {
214                if ($data != '') {
215                    $query = 'UPDATE ' . $prefixeTable . 'add_properties_photos_datadate SET datadate="' . $data . '" WHERE id_img=' . $id_img . ' AND id_prop_pho=' . $id_prop_pho;
216                    pwg_query($query);
217                } else {
218                    $query = 'DELETE FROM ' . $prefixeTable . 'add_properties_photos_datadate WHERE id_img=' . $id_img . ' AND id_prop_pho=' . $id_prop_pho;
219                    pwg_query($query);
220                }
221            } else if ($data != '') {
222                $query = 'INSERT ' . $prefixeTable . 'add_properties_photos_datadate(id_img,id_prop_pho,datadate) VALUES (' . $id_img . ',' . $id_prop_pho . ',"' . $data . '");';
223                pwg_query($query);
224            }   
225        }
226        $redirect_url = ADD_PROP_PHOTO_ADMIN . '-iap&amp;image_id=' . $id_img;
227        $_SESSION['page_infos'] = array(l10n('Properties update'));
228        redirect($redirect_url);
229    }
230}
231
232switch ($page['tab']) {
233    case 'define_properties':
234        $admin_base_url = ADD_PROP_PHOTO_ADMIN . '-define_properties';
235        $template->assign(
236            'addinfotemplate', array(
237                                'addinfo' => l10n('addinfo'),
238                ));
239                $maxfields = (isset($conf['mpp_max_fields'])) ? $conf['mpp_max_fields'] : '5';
240        $template->assign('MPPMAXFIELD',$maxfields);
241               
242    if (isset($pwg_loaded_plugins['ExtendedDescription'])){
243        add_event_handler('AP_render_content', 'get_user_language_desc');
244                $template->assign('useED',1);
245    }else{
246        $template->assign('useED',0);
247    }
248       
249        $admin_base_url = ADD_PROP_PHOTO_ADMIN . '-define_properties';
250        $tab_info_photos = tab_info_photos();
251
252        if (pwg_db_num_rows($tab_info_photos)) {
253            while ($info_photos = pwg_db_fetch_assoc($tab_info_photos)) {
254                                $items = array(
255                    'IDINFOPHO' => $info_photos['id_prop_pho'],
256                    'AIPORDER' => $info_photos['orderprop'],
257                    'AIPACTIVE' => $info_photos['active'],
258                    'AIPEDIT' => $info_photos['edit'],
259                    'U_HIDE' => $admin_base_url . '&amp;hide=' . $info_photos['id_prop_pho'],
260                    'U_SHOW' => $admin_base_url . '&amp;show=' . $info_photos['id_prop_pho']
261                                );
262                if($info_photos['id_prop_pho']==1){
263                                    $items['AIPWORDING'] = l10n('Author');
264                }else if($info_photos['id_prop_pho']==2){
265                                        $items['AIPWORDING'] = l10n('Created on');
266                }else if($info_photos['id_prop_pho']==3){
267                    $items['AIPWORDING'] = l10n('Posted on');
268                }else if($info_photos['id_prop_pho']==4){
269                    $items['AIPWORDING'] = l10n('Dimensions');
270                }else if($info_photos['id_prop_pho']==5){
271                    $items['AIPWORDING'] = l10n('File');
272                }else if($info_photos['id_prop_pho']==6){
273                    $items['AIPWORDING'] = l10n('Filesize');
274                }else if($info_photos['id_prop_pho']==7){
275                    $items['AIPWORDING'] = l10n('Tags');
276                }else if($info_photos['id_prop_pho']==8){
277                    $items['AIPWORDING'] = l10n('Albums');
278                }else if($info_photos['id_prop_pho']==9){
279                    $items['AIPWORDING'] = l10n('Visits');
280                }else if($info_photos['id_prop_pho']==10){
281                                        $items['AIPWORDING'] = l10n('Rating score');
282                }else if($info_photos['id_prop_pho']==11){
283                    $items['AIPWORDING'] = l10n('Who can see this photo?');
284                }else{
285                                        if($info_photos['dataprop']=="DeletePhoto" and $info_photos['wording'] ="**delpho**"){
286                                                $items['AIPWORDING'] = l10n('Delete photo');
287                                        }else if($info_photos['dataprop']=="movedescription"){
288                                                $items['AIPWORDING'] = l10n('Description');
289                                        }else if($info_photos['dataprop']=="showid"){
290                                                $items['AIPWORDING'] = l10n('Image id');
291                                        }else if($info_photos['dataprop']=="plugPhoto_add_by"){
292                                                $items['AIPWORDING'] = l10n('Plugins')." - ".l10n('Photo added by');
293                                        }else if($info_photos['dataprop']=="plugdownload_counter"){
294                                                $items['AIPWORDING'] = l10n('Plugins')." - ".l10n('Downloads');
295                                        }else if($info_photos['dataprop']=="plugColorPalette"){
296                                                $items['AIPWORDING'] = l10n('Plugins')." - ".l10n('Palette');
297                                        }else if($info_photos['dataprop']=="plugexpiry_date"){
298                                                $items['AIPWORDING'] = l10n('Plugins')." - ".l10n('Expiry date');
299                                        }else if($info_photos['dataprop']=="plugCopyrights"){
300                                                $items['AIPWORDING'] = l10n('Plugins')." - ".l10n('Copyrights');
301                                        }else{
302                                                $items['AIPWORDING'] = trigger_change('AP_render_content',$info_photos['wording']);     
303                                        }
304                    $items['AIPWORDING2'] =  $info_photos['wording'];
305                                        $items['U_DELETE'] =  $admin_base_url . '&amp;delete=' . $info_photos['id_prop_pho'];
306                                        $items['AIPTYP'] =  $info_photos['Typ'];
307                                        if($info_photos['Typ']==4||$info_photos['Typ']==5){
308                                                $items['AIPDATAPROP'] =  json_encode(unserialize($info_photos['dataprop']));
309                                        }else{
310                                                $items['AIPDATAPROP'] = "";
311                                        }
312                                        if($info_photos['Typ']==3||$info_photos['Typ']==6){
313                                                        $items['AIPDATAPROP'] =  $info_photos['dataprop'];
314                                        }                                       
315                }       
316                $template->append('info_photos', $items);
317            }
318                       
319                        $idexifone = pwg_db_fetch_assoc(pwg_query("SELECT MIN(id) as id FROM " . IMAGES_TABLE .";"));
320                        $idexif = (isset($conf['mpp_idexif'])) ? $conf['mpp_idexif'] : $idexifone['id'];
321                        $filename = pwg_db_fetch_assoc(pwg_query("SELECT path FROM " . IMAGES_TABLE . " WHERE id = '".$idexif."';"));
322                  if(empty($filename['path'])){
323                          $_SESSION['page_errors'] = array(l10n('reference photo id doesn\'t exist please update'));
324                  }else if(exif_imagetype($filename['path']) != IMAGETYPE_JPEG and exif_imagetype($filename['path']) != IMAGETYPE_TIFF_II and exif_imagetype($filename['path']) != IMAGETYPE_TIFF_MM){
325                          $_SESSION['page_errors'] = array(l10n('reference photo type doesn\'t use metadata please update')); 
326                  }else{       
327                        $exif = @exif_read_data($filename['path']);
328                                foreach ($exif as $key => $section){
329                                        if(is_array($section)){
330                                                $i=0;
331                                        foreach ($section as $name => $value){
332                                                if($i==0){
333                                                        $items['RM_AFF'] = $key;
334                                                }else{
335                                                        $items['RM_AFF'] = '';
336                                                }
337                                                $items['RM_SECTION'] = $key;
338                                                $items['RM_KEY'] = $name;
339                                                $template->append('rm_exif', $items);
340                                                $i++;
341                                        }
342                                }else{
343                                        $items['RM_SECTION'] = '1';
344                                        $items['RM_KEY'] = $key;
345                                        $items['RM_VALUE'] = $section;
346                                        $template->append('rm_exif', $items);
347                                }
348                        }
349                        $iptc_result = array();
350                        $imginfo = array();
351                        getimagesize($filename['path'], $imginfo);
352                        if (isset ($imginfo['APP13'])){
353                         $iptc = iptcparse($imginfo['APP13']);
354                          if (is_array($iptc)){
355                                foreach (array_keys($iptc) as $iptc_key){
356                                        if (isset($iptc[$iptc_key][0])){
357                                                $iptc_result[$iptc_key] = $value;
358                                        }
359                                }
360                          }
361                          $keys = array_keys($iptc_result);
362                          sort($keys);
363                          foreach ($keys as $key){
364                                $items['RM_KEY'] = $key;
365                                $template->append('rm_iptc', $items);
366                          }
367                        }
368                  }
369        }
370       
371        if (isset($_POST['submitManualOrderInfo'])){
372           
373            asort($_POST['infoOrd'], SORT_NUMERIC);
374           
375            $data = array();
376            foreach ($_POST['infoOrd'] as $id =>$val){
377           
378            $data[] = array('id_prop_pho' => $id, 'orderprop' => $val+1);
379            }
380            $fields = array('primary' => array('id_prop_pho'), 'update' => array('orderprop'));
381            mass_updates(ADD_PROP_PHOTO_TABLE, $fields, $data);
382
383          $page['infos'][] = l10n('Properties manual order was saved');
384          redirect($admin_base_url);
385        }
386
387        if (isset($_POST['submitaddAIP'])) {
388                        if ($_POST['inserwording'] == '') {
389                        $_SESSION['page_errors'] = array(l10n('Wording isn\'t empty'));
390                        redirect($admin_base_url);
391                        }
392                        if ($_POST['typ'] == '4'||$_POST['typ'] == '5') {
393                        $select= serialize($_POST['mytext']);
394                        }
395                        if ($_POST['typ'] == '3') {
396                                if($_POST['selectexif']==''){
397                                        $_SESSION['page_errors'] = array(l10n('exif field can\'t be empty'));
398                                        redirect($admin_base_url);
399                                }
400                        $select= $_POST['selectexif'];
401                        }
402                        if ($_POST['typ'] == '6') {
403                                if($_POST['selectiptc']==''){
404                                        $_SESSION['page_errors'] = array(l10n('IPTC field can\'t be empty'));
405                                        redirect($admin_base_url);
406                                }
407                        $select= $_POST['selectiptc'];
408                        }
409            if (!isset($_POST['inseractive'])) {
410                $_POST['inseractive'] = 0;
411            }
412            if ($_POST['invisibleID'] == 0) {
413                $result = pwg_query('SELECT MAX(orderprop) FROM '. ADD_PROP_PHOTO_TABLE );
414                $row = pwg_db_fetch_assoc($result);
415                $or = ($row['MAX(orderprop)'] + 1);
416                                        if ($_POST['typ'] == '4'||$_POST['typ'] == '3'||$_POST['typ'] == '5'||$_POST['typ'] == '6') {
417                                                $q = 'INSERT INTO ' . $prefixeTable . 'add_properties_photos(wording,orderprop,active,edit,Typ,dataprop)VALUES ("' . $_POST['inserwording'] . '","' . $or . '","' . $_POST['inseractive'] . '",1,"' . $_POST['typ'] . '",\''. $select .'\');';
418                                                pwg_query($q);
419                                        }else{
420                                                $q = 'INSERT INTO ' . $prefixeTable . 'add_properties_photos(wording,orderprop,active,edit,Typ)VALUES ("' . $_POST['inserwording'] . '","' . $or . '","' . $_POST['inseractive'] . '",1,"' . $_POST['typ'] . '");';
421                                                pwg_query($q);
422                                        }
423                $_SESSION['page_infos'] = array(l10n('Property photo add'));
424            } else {
425                                        if ($_POST['typ'] == '4'||$_POST['typ'] == '3'||$_POST['typ'] == '5'||$_POST['typ'] == '6') {
426                                          $q = '
427                                          UPDATE ' . $prefixeTable . 'add_properties_photos'
428                        . ' set wording ="' . $_POST['inserwording'] . '" '
429                        . ' ,active =' . $_POST['inseractive']
430                                                . ' ,Typ =' . $_POST['typ']
431                                                . ' ,dataprop =\'' . $select . '\' '
432                        . ' WHERE id_prop_pho=' . $_POST['invisibleID'] . ';';
433                                        }else{
434                                          $q = '
435                                          UPDATE ' . $prefixeTable . 'add_properties_photos'
436                        . ' set wording ="' . $_POST['inserwording'] . '" '
437                        . ' ,active=' . $_POST['inseractive']
438                                                . ' ,Typ =' . $_POST['typ']
439                        . ' WHERE id_prop_pho=' . $_POST['invisibleID'] . ';';
440                                        }
441                pwg_query($q);
442                $_SESSION['page_infos'] = array(l10n('Property photo update'));
443            }
444            redirect($admin_base_url);
445        }
446
447        if (isset($_GET['delete'])) {
448            check_input_parameter('delete', $_GET, false, PATTERN_ID);
449            $query = 'DELETE FROM ' . ADD_PROP_PHOTO_TABLE . ' WHERE id_prop_pho = ' . $_GET['delete'] . ';';
450            pwg_query($query);
451            $query = 'DELETE FROM ' . ADD_PROP_PHOTO_DATA_TABLE . ' WHERE id_prop_pho = ' . $_GET['delete'] . ';';
452            pwg_query($query);
453                        $query = 'DELETE FROM ' . ADD_PROP_PHOTO_DATADATE_TABLE . ' WHERE id_prop_pho = ' . $_GET['delete'] . ';';
454            pwg_query($query);
455
456            $_SESSION['page_infos'] = array(l10n('Property delete'));
457            redirect($admin_base_url);
458        }
459       
460        if (isset($_GET['hide'])) {
461            check_input_parameter('hide', $_GET, false, PATTERN_ID);
462            $query = 'UPDATE ' . ADD_PROP_PHOTO_TABLE . ' SET active = 1 WHERE id_prop_pho=' . $_GET['hide'] . ';';
463            pwg_query($query);
464        }
465       
466        if (isset($_GET['show'])) {
467            check_input_parameter('show', $_GET, false, PATTERN_ID);
468            $query = 'UPDATE ' . ADD_PROP_PHOTO_TABLE . ' SET active = 0 WHERE id_prop_pho=' . $_GET['show'] . ';';
469            pwg_query($query);
470        }
471
472        break;
473                case 'config':
474                $maxfields = (isset($conf['mpp_max_fields'])) ? $conf['mpp_max_fields'] : '5';
475        $template->assign('MPPMAXFIELD',$maxfields);
476                $idexif = (isset($conf['mpp_idexif'])) ? $conf['mpp_idexif'] : '';
477        $template->assign('MPPIDEXIF',$idexif);
478        $admin_base_url = ADD_PROP_PHOTO_ADMIN . '-config';
479                        $template->assign(
480                                'mppconfig', array(
481                                        'a' => 'a',
482                        ));
483                               
484                $delpho = pwg_db_fetch_assoc(pwg_query('SELECT dataprop FROM ' . ADD_PROP_PHOTO_TABLE.' WHERE dataprop="DeletePhoto";'));
485                if(empty($delpho)){
486                        $template->assign(
487                                'mppconfig', array(
488                                        'ADDPHOAC' => 'actiondelphoadd',
489                        ));
490                }
491                if (isset($_POST['submitadddelpho'])){
492                        $result = pwg_query('SELECT MAX(orderprop) FROM '. ADD_PROP_PHOTO_TABLE );
493                        $row = pwg_db_fetch_assoc($result);
494                        $or = ($row['MAX(orderprop)'] + 1);
495                        $q = 'INSERT INTO ' . $prefixeTable . 'add_properties_photos(wording,orderprop,active,edit,Typ,dataprop)VALUES ("**delpho**","' . $or . '","1",1,"2","DeletePhoto");';
496                        pwg_query($q);
497                        $_SESSION['page_infos'] = array(l10n('Information data registered in database'));
498                        redirect(ADD_PROP_PHOTO_ADMIN . '-config');
499                }
500                if (isset($_POST['submitremovedelpho'])){
501                        $iddelpho = pwg_db_fetch_assoc(pwg_query('SELECT id_prop_pho FROM '. ADD_PROP_PHOTO_TABLE.' where dataprop="DeletePhoto";'));
502                        pwg_query('DELETE FROM ' . ADD_PROP_PHOTO_TABLE . ' where dataprop ="DeletePhoto";');
503                        $query = 'DELETE FROM ' . ADD_PROP_PHOTO_DATADATE_TABLE . ' WHERE id_prop_pho = ' . $iddelpho['id_prop_pho'] . ';';
504            pwg_query($query);
505                        $_SESSION['page_infos'] = array(l10n('Information data registered in database'));
506                        redirect(ADD_PROP_PHOTO_ADMIN . '-config');
507                }
508                $descpho = pwg_db_fetch_assoc(pwg_query('SELECT dataprop FROM ' . ADD_PROP_PHOTO_TABLE.' WHERE dataprop="movedescription";'));
509                if(empty($descpho)){
510                        $vars['MOVEDESC']='actionmovedesc';
511                        $template->append('mppconfig', $vars, true);
512                }
513                if (isset($_POST['submitmovedesc'])){
514                        $result = pwg_query('SELECT MAX(orderprop) FROM '. ADD_PROP_PHOTO_TABLE );
515                        $row = pwg_db_fetch_assoc($result);
516                        $or = ($row['MAX(orderprop)'] + 1);
517                        $q = 'INSERT INTO ' . $prefixeTable . 'add_properties_photos(wording,orderprop,active,edit,Typ,dataprop)VALUES ("Description","' . $or . '","0",0,"1","movedescription");';
518                        pwg_query($q);
519                        $_SESSION['page_infos'] = array(l10n('Information data registered in database'));
520                        redirect(ADD_PROP_PHOTO_ADMIN . '-config');
521                }
522                if (isset($_POST['submitdefaultdesc'])){
523                        pwg_query('DELETE FROM ' . ADD_PROP_PHOTO_TABLE . ' where dataprop ="movedescription";');
524                        $_SESSION['page_infos'] = array(l10n('Information data registered in database'));
525                        redirect(ADD_PROP_PHOTO_ADMIN . '-config');
526                }
527                if (isset($_POST['submitmppoption'])){
528                        conf_update_param('mpp_max_fields', $_POST['mppmaxfield']);
529                        conf_update_param('mpp_idexif', $_POST['mppitidexif']);
530                        $_SESSION['page_infos'] = array(l10n('Information data registered in database'));
531                        redirect(ADD_PROP_PHOTO_ADMIN . '-config');
532                }
533                $mppshid = pwg_db_fetch_assoc(pwg_query('SELECT dataprop FROM ' . ADD_PROP_PHOTO_TABLE.' WHERE dataprop="showid";'));
534                if(empty($mppshid)){
535                        $vars['MPPSHID']='actionschowid';
536                        $template->append('mppconfig', $vars, true);
537                }
538                if (isset($_POST['submitmppsid'])){
539                        $row = pwg_db_fetch_assoc(pwg_query('SELECT MAX(orderprop) FROM '. ADD_PROP_PHOTO_TABLE ));
540                        $or = ($row['MAX(orderprop)'] + 1);
541                        $q = 'INSERT INTO ' . $prefixeTable . 'add_properties_photos(wording,orderprop,active,edit,Typ,dataprop)VALUES ("ID","' . $or . '","0",0,"1","showid");';
542                        pwg_query($q);
543                        $_SESSION['page_infos'] = array(l10n('Information data registered in database'));
544                        redirect(ADD_PROP_PHOTO_ADMIN . '-config');
545                }
546                if (isset($_POST['submitmpphid'])){
547                        pwg_query('DELETE FROM ' . ADD_PROP_PHOTO_TABLE . ' where dataprop ="showid";');
548                        $_SESSION['page_infos'] = array(l10n('Information data registered in database'));
549                        redirect(ADD_PROP_PHOTO_ADMIN . '-config');
550                }
551                break;
552 }
553
554
555$template->set_filenames(array('plugin_admin_content' => dirname(__FILE__) . '/admin/admin.tpl'));
556$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
557?>
Note: See TracBrowser for help on using the repository browser.