[30631] | 1 | <?php |
---|
[31409] | 2 | // +-----------------------------------------------------------------------+ |
---|
[32135] | 3 | // | Manage Properties Photos plugin for Piwigo by TEMMII | |
---|
[31409] | 4 | // +-----------------------------------------------------------------------+ |
---|
[32135] | 5 | // | Copyright(C) 2007-2020 ddtddt http://temmii.com/piwigo/ | |
---|
[31409] | 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 | // +-----------------------------------------------------------------------+ |
---|
[30631] | 21 | |
---|
| 22 | if (!defined('PHPWG_ROOT_PATH')) |
---|
| 23 | die('Hacking attempt!'); |
---|
| 24 | global $template, $conf, $user; |
---|
| 25 | include_once(PHPWG_ROOT_PATH . 'admin/include/tabsheet.class.php'); |
---|
[30702] | 26 | load_language('plugin.lang', ADD_PROP_PHOTO_PATH); |
---|
[30631] | 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 |
---|
[32135] | 35 | |
---|
| 36 | $template->assign(array( |
---|
| 37 | 'ADD_PROP_PHOTO_PATH'=> get_root_url() . ADD_PROP_PHOTO_PATH, |
---|
| 38 | )); |
---|
| 39 | |
---|
| 40 | |
---|
[30631] | 41 | if (!isset($_GET['tab'])) |
---|
[30702] | 42 | $page['tab'] = 'define_properties'; |
---|
[30631] | 43 | else |
---|
| 44 | $page['tab'] = $_GET['tab']; |
---|
| 45 | |
---|
| 46 | |
---|
| 47 | if ($page['tab'] != 'iap') { |
---|
| 48 | $tabsheet = new tabsheet(); |
---|
[30702] | 49 | $tabsheet->add('addip', l10n('Property'), ADD_PROP_PHOTO_ADMIN . '-define_properties'); |
---|
[32135] | 50 | $tabsheet->add('config', l10n('Configuration'), ADD_PROP_PHOTO_ADMIN . '-config'); |
---|
[30631] | 51 | $tabsheet->select($page['tab']); |
---|
| 52 | $tabsheet->assign(); |
---|
| 53 | } else if ($_GET['tab'] == 'iap') { |
---|
| 54 | |
---|
| 55 | $page['active_menu'] = get_active_menu('photo'); // force oppening "Photos" menu block |
---|
| 56 | |
---|
| 57 | /* Basic checks */ |
---|
| 58 | check_status(ACCESS_ADMINISTRATOR); |
---|
| 59 | |
---|
| 60 | check_input_parameter('image_id', $_GET, false, PATTERN_ID); |
---|
| 61 | $id_img = $_GET['image_id']; |
---|
| 62 | $admin_photo_base_url = get_root_url() . 'admin.php?page=photo-' . $_GET['image_id']; |
---|
| 63 | |
---|
| 64 | $page['tab'] = 'iap'; |
---|
| 65 | |
---|
| 66 | $tabsheet = new tabsheet(); |
---|
| 67 | $tabsheet->set_id('photo'); |
---|
| 68 | $tabsheet->select('iap'); |
---|
| 69 | $tabsheet->assign(); |
---|
| 70 | |
---|
| 71 | $template->assign( |
---|
| 72 | 'gestionD', array( |
---|
| 73 | 'A' => 'a' |
---|
| 74 | )); |
---|
| 75 | |
---|
[32135] | 76 | if (isset($pwg_loaded_plugins['ExtendedDescription'])){ |
---|
[30655] | 77 | add_event_handler('AP_render_content', 'get_user_language_desc'); |
---|
| 78 | $template->assign('useED',1); |
---|
| 79 | }else{ |
---|
| 80 | $template->assign('useED',0); |
---|
| 81 | } |
---|
[30631] | 82 | |
---|
| 83 | $tab_add_info_one_photo = tab_add_info_by_photo($_GET['image_id']); |
---|
| 84 | if (pwg_db_num_rows($tab_add_info_one_photo)) { |
---|
| 85 | while ($info_photos = pwg_db_fetch_assoc($tab_add_info_one_photo)) { |
---|
[32135] | 86 | if($info_photos['Typ']==2){ |
---|
| 87 | $d = data_info_photosdate($id_img, $info_photos['id_prop_pho']); |
---|
| 88 | $row = pwg_db_fetch_assoc($d); |
---|
[30631] | 89 | |
---|
[32135] | 90 | $items = array( |
---|
| 91 | 'IDPHO' => $_GET['image_id'], |
---|
| 92 | 'IDINFOPHO' => $info_photos['id_prop_pho'], |
---|
| 93 | 'AIPWORDING' => trigger_change('AP_render_content',$info_photos['wording']), |
---|
| 94 | 'AIPDATA' => $row['datadate'], |
---|
| 95 | 'AIPTYP' => $info_photos['Typ'], |
---|
| 96 | ); |
---|
| 97 | if($info_photos['wording']=="**delpho**"){ |
---|
| 98 | $items['AIPWORDING'] =l10n('Delete photo'); |
---|
| 99 | } |
---|
| 100 | }else{ |
---|
| 101 | $d = data_info_photos($id_img, $info_photos['id_prop_pho']); |
---|
| 102 | $row = pwg_db_fetch_assoc($d); |
---|
[30631] | 103 | |
---|
[32135] | 104 | $items = array( |
---|
| 105 | 'IDPHO' => $_GET['image_id'], |
---|
| 106 | 'IDINFOPHO' => $info_photos['id_prop_pho'], |
---|
| 107 | 'AIPWORDING' => trigger_change('AP_render_content',$info_photos['wording']), |
---|
| 108 | 'AIPDATA' => $row['data'], |
---|
| 109 | 'AIPTYP' => $info_photos['Typ'], |
---|
| 110 | ); |
---|
| 111 | if($info_photos['Typ']==4||$info_photos['Typ']==5){ |
---|
| 112 | $items['AIPSELECT']=unserialize($info_photos['dataprop']); |
---|
| 113 | foreach ($items['AIPSELECT'] as $key => $dataselect){ |
---|
| 114 | $items['AIPSELECTTRANS'][] = trigger_change('AP_render_content',$dataselect); |
---|
| 115 | } |
---|
| 116 | } |
---|
| 117 | } |
---|
[30631] | 118 | $template->append('info_photos', $items); |
---|
| 119 | } |
---|
| 120 | } |
---|
| 121 | |
---|
| 122 | if (isset($_POST['submitaddinfoimg'])) { |
---|
[30702] | 123 | foreach ($_POST['data'] AS $id_prop_pho => $data) { |
---|
| 124 | $q = 'SELECT 1 FROM ' . ADD_PROP_PHOTO_DATA_TABLE . ' WHERE id_img=' . $id_img . ' AND id_prop_pho=' . $id_prop_pho; |
---|
[30631] | 125 | $test = pwg_query($q); |
---|
| 126 | $row = pwg_db_fetch_assoc($test); |
---|
| 127 | if (count($row) > 0) { |
---|
| 128 | if ($data != '') { |
---|
[30702] | 129 | $query = 'UPDATE ' . $prefixeTable . 'add_properties_photos_data SET data="' . $data . '" WHERE id_img=' . $id_img . ' AND id_prop_pho=' . $id_prop_pho; |
---|
[30631] | 130 | pwg_query($query); |
---|
| 131 | } else { |
---|
[30702] | 132 | $query = 'DELETE FROM ' . $prefixeTable . 'add_properties_photos_data WHERE id_img=' . $id_img . ' AND id_prop_pho=' . $id_prop_pho; |
---|
[30631] | 133 | pwg_query($query); |
---|
| 134 | } |
---|
| 135 | } else if ($data != '') { |
---|
[30702] | 136 | $query = 'INSERT ' . $prefixeTable . 'add_properties_photos_data(id_img,id_prop_pho,data) VALUES (' . $id_img . ',' . $id_prop_pho . ',"' . $data . '");'; |
---|
[30631] | 137 | pwg_query($query); |
---|
[32135] | 138 | } |
---|
[30631] | 139 | } |
---|
[32135] | 140 | foreach ($_POST['datadate'] AS $id_prop_pho => $data) { |
---|
| 141 | $q = 'SELECT 1 FROM ' . ADD_PROP_PHOTO_DATADATE_TABLE . ' WHERE id_img=' . $id_img . ' AND id_prop_pho=' . $id_prop_pho; |
---|
| 142 | $test = pwg_query($q); |
---|
| 143 | $row = pwg_db_fetch_assoc($test); |
---|
| 144 | if (count($row) > 0) { |
---|
| 145 | if ($data != '') { |
---|
| 146 | $query = 'UPDATE ' . $prefixeTable . 'add_properties_photos_datadate SET datadate="' . $data . '" WHERE id_img=' . $id_img . ' AND id_prop_pho=' . $id_prop_pho; |
---|
| 147 | pwg_query($query); |
---|
| 148 | } else { |
---|
| 149 | $query = 'DELETE FROM ' . $prefixeTable . 'add_properties_photos_datadate WHERE id_img=' . $id_img . ' AND id_prop_pho=' . $id_prop_pho; |
---|
| 150 | pwg_query($query); |
---|
| 151 | } |
---|
| 152 | } else if ($data != '') { |
---|
| 153 | $query = 'INSERT ' . $prefixeTable . 'add_properties_photos_datadate(id_img,id_prop_pho,datadate) VALUES (' . $id_img . ',' . $id_prop_pho . ',"' . $data . '");'; |
---|
| 154 | pwg_query($query); |
---|
| 155 | } |
---|
| 156 | } |
---|
[30702] | 157 | $redirect_url = ADD_PROP_PHOTO_ADMIN . '-iap&image_id=' . $id_img; |
---|
| 158 | $_SESSION['page_infos'] = array(l10n('Properties update')); |
---|
[30631] | 159 | redirect($redirect_url); |
---|
| 160 | } |
---|
| 161 | } |
---|
| 162 | |
---|
| 163 | switch ($page['tab']) { |
---|
[30702] | 164 | case 'define_properties': |
---|
| 165 | $admin_base_url = ADD_PROP_PHOTO_ADMIN . '-define_properties'; |
---|
[30631] | 166 | $template->assign( |
---|
[32135] | 167 | 'addinfotemplate', array( |
---|
| 168 | 'addinfo' => l10n('addinfo'), |
---|
| 169 | )); |
---|
| 170 | $maxfields = (isset($conf['mpp_max_fields'])) ? $conf['mpp_max_fields'] : '5'; |
---|
| 171 | $template->assign('MPPMAXFIELD',$maxfields); |
---|
| 172 | |
---|
| 173 | if (isset($pwg_loaded_plugins['ExtendedDescription'])){ |
---|
[30655] | 174 | add_event_handler('AP_render_content', 'get_user_language_desc'); |
---|
| 175 | $template->assign('useED',1); |
---|
| 176 | }else{ |
---|
| 177 | $template->assign('useED',0); |
---|
| 178 | } |
---|
[30631] | 179 | |
---|
[30702] | 180 | $admin_base_url = ADD_PROP_PHOTO_ADMIN . '-define_properties'; |
---|
[30631] | 181 | $tab_info_photos = tab_info_photos(); |
---|
| 182 | |
---|
| 183 | if (pwg_db_num_rows($tab_info_photos)) { |
---|
| 184 | while ($info_photos = pwg_db_fetch_assoc($tab_info_photos)) { |
---|
[32135] | 185 | $items = array( |
---|
| 186 | 'IDINFOPHO' => $info_photos['id_prop_pho'], |
---|
| 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 | ); |
---|
[30702] | 193 | if($info_photos['id_prop_pho']==1){ |
---|
[32135] | 194 | $items['AIPWORDING'] = l10n('Author'); |
---|
[30702] | 195 | }else if($info_photos['id_prop_pho']==2){ |
---|
[32135] | 196 | $items['AIPWORDING'] = l10n('Created on'); |
---|
[30702] | 197 | }else if($info_photos['id_prop_pho']==3){ |
---|
[32135] | 198 | $items['AIPWORDING'] = l10n('Posted on'); |
---|
[30702] | 199 | }else if($info_photos['id_prop_pho']==4){ |
---|
[32135] | 200 | $items['AIPWORDING'] = l10n('Dimensions'); |
---|
[30702] | 201 | }else if($info_photos['id_prop_pho']==5){ |
---|
[32135] | 202 | $items['AIPWORDING'] = l10n('File'); |
---|
[30702] | 203 | }else if($info_photos['id_prop_pho']==6){ |
---|
[32135] | 204 | $items['AIPWORDING'] = l10n('Filesize'); |
---|
[30702] | 205 | }else if($info_photos['id_prop_pho']==7){ |
---|
[32135] | 206 | $items['AIPWORDING'] = l10n('Tags'); |
---|
[30702] | 207 | }else if($info_photos['id_prop_pho']==8){ |
---|
[32135] | 208 | $items['AIPWORDING'] = l10n('Albums'); |
---|
[30702] | 209 | }else if($info_photos['id_prop_pho']==9){ |
---|
[32135] | 210 | $items['AIPWORDING'] = l10n('Visits'); |
---|
[30702] | 211 | }else if($info_photos['id_prop_pho']==10){ |
---|
[32135] | 212 | $items['AIPWORDING'] = l10n('Average'); |
---|
[30702] | 213 | }else if($info_photos['id_prop_pho']==11){ |
---|
[32135] | 214 | $items['AIPWORDING'] = l10n('Who can see this photo?'); |
---|
[30631] | 215 | }else{ |
---|
[32135] | 216 | if($info_photos['dataprop']=="DeletePhoto" and $info_photos['wording'] ="**delpho**"){ |
---|
| 217 | $items['AIPWORDING'] = l10n('Delete photo'); |
---|
| 218 | }else{ |
---|
| 219 | $items['AIPWORDING'] = trigger_change('AP_render_content',$info_photos['wording']); |
---|
| 220 | } |
---|
| 221 | $items['AIPWORDING2'] = $info_photos['wording']; |
---|
| 222 | $items['U_DELETE'] = $admin_base_url . '&delete=' . $info_photos['id_prop_pho']; |
---|
| 223 | $items['AIPTYP'] = $info_photos['Typ']; |
---|
| 224 | if($info_photos['Typ']==4||$info_photos['Typ']==5){ |
---|
| 225 | $items['AIPDATAPROP'] = json_encode(unserialize($info_photos['dataprop'])); |
---|
| 226 | } |
---|
| 227 | if($info_photos['Typ']==3||$info_photos['Typ']==6){ |
---|
| 228 | $items['AIPDATAPROP'] = $info_photos['dataprop']; |
---|
| 229 | } |
---|
[30631] | 230 | } |
---|
| 231 | $template->append('info_photos', $items); |
---|
| 232 | } |
---|
[32135] | 233 | |
---|
| 234 | $idexifone = pwg_db_fetch_assoc(pwg_query("SELECT MIN(id) as id FROM " . IMAGES_TABLE .";")); |
---|
| 235 | $idexif = (isset($conf['mpp_idexif'])) ? $conf['mpp_idexif'] : $idexifone['id']; |
---|
| 236 | $filename = pwg_db_fetch_assoc(pwg_query("SELECT path FROM " . IMAGES_TABLE . " WHERE id = '".$idexif."';")); |
---|
[32136] | 237 | if(empty($filename['path'])){ |
---|
| 238 | $_SESSION['page_errors'] = array(l10n('reference photo id doesn\'t exist please update')); |
---|
[32137] | 239 | }else if(exif_imagetype($filename['path']) != IMAGETYPE_JPEG and exif_imagetype($filename['path']) != IMAGETYPE_TIFF_II and exif_imagetype($filename['path']) != IMAGETYPE_TIFF_MM){ |
---|
| 240 | $_SESSION['page_errors'] = array(l10n('reference photo type doesn\'t use metadata please update')); |
---|
[32136] | 241 | }else{ |
---|
[32135] | 242 | $exif = exif_read_data($filename['path']); |
---|
| 243 | foreach ($exif as $key => $section){ |
---|
| 244 | if(is_array($section)){ |
---|
| 245 | $i=0; |
---|
| 246 | foreach ($section as $name => $value){ |
---|
| 247 | if($i==0){ |
---|
| 248 | $items['RM_AFF'] = $key; |
---|
| 249 | }else{ |
---|
| 250 | $items['RM_AFF'] = ''; |
---|
| 251 | } |
---|
| 252 | $items['RM_SECTION'] = $key; |
---|
| 253 | $items['RM_KEY'] = $name; |
---|
| 254 | $template->append('rm_exif', $items); |
---|
| 255 | $i++; |
---|
| 256 | } |
---|
| 257 | }else{ |
---|
| 258 | $items['RM_SECTION'] = '1'; |
---|
| 259 | $items['RM_KEY'] = $key; |
---|
| 260 | $items['RM_VALUE'] = $section; |
---|
| 261 | $template->append('rm_exif', $items); |
---|
| 262 | } |
---|
| 263 | } |
---|
| 264 | $iptc_result = array(); |
---|
| 265 | $imginfo = array(); |
---|
| 266 | getimagesize($filename['path'], $imginfo); |
---|
| 267 | if (isset ($imginfo['APP13'])){ |
---|
| 268 | $iptc = iptcparse($imginfo['APP13']); |
---|
| 269 | if (is_array($iptc)){ |
---|
| 270 | foreach (array_keys($iptc) as $iptc_key){ |
---|
| 271 | if (isset($iptc[$iptc_key][0])){ |
---|
| 272 | $iptc_result[$iptc_key] = $value; |
---|
| 273 | } |
---|
| 274 | } |
---|
| 275 | } |
---|
| 276 | $keys = array_keys($iptc_result); |
---|
| 277 | sort($keys); |
---|
| 278 | foreach ($keys as $key){ |
---|
| 279 | $items['RM_KEY'] = $key; |
---|
| 280 | $template->append('rm_iptc', $items); |
---|
| 281 | } |
---|
| 282 | } |
---|
[32136] | 283 | } |
---|
[30631] | 284 | } |
---|
| 285 | |
---|
| 286 | if (isset($_POST['submitManualOrderInfo'])){ |
---|
| 287 | |
---|
| 288 | asort($_POST['infoOrd'], SORT_NUMERIC); |
---|
| 289 | |
---|
| 290 | $data = array(); |
---|
| 291 | foreach ($_POST['infoOrd'] as $id =>$val){ |
---|
| 292 | |
---|
[30702] | 293 | $data[] = array('id_prop_pho' => $id, 'orderprop' => $val+1); |
---|
[30631] | 294 | } |
---|
[30702] | 295 | $fields = array('primary' => array('id_prop_pho'), 'update' => array('orderprop')); |
---|
| 296 | mass_updates(ADD_PROP_PHOTO_TABLE, $fields, $data); |
---|
[30631] | 297 | |
---|
[30702] | 298 | $page['infos'][] = l10n('Properties manual order was saved'); |
---|
[30631] | 299 | redirect($admin_base_url); |
---|
| 300 | } |
---|
[30654] | 301 | |
---|
[30631] | 302 | if (isset($_POST['submitaddAIP'])) { |
---|
[32135] | 303 | if ($_POST['inserwording'] == '') { |
---|
| 304 | $_SESSION['page_errors'] = array(l10n('Wording isn\'t empty')); |
---|
| 305 | redirect($admin_base_url); |
---|
| 306 | } |
---|
| 307 | if ($_POST['typ'] == '4'||$_POST['typ'] == '5') { |
---|
| 308 | $select= serialize($_POST['mytext']); |
---|
| 309 | } |
---|
| 310 | if ($_POST['typ'] == '3') { |
---|
[32151] | 311 | if($_POST['selectexif']==''){ |
---|
| 312 | $_SESSION['page_errors'] = array(l10n('exif field can\'t be empty')); |
---|
| 313 | redirect($admin_base_url); |
---|
| 314 | } |
---|
[32135] | 315 | $select= $_POST['selectexif']; |
---|
| 316 | } |
---|
| 317 | if ($_POST['typ'] == '6') { |
---|
[32151] | 318 | if($_POST['selectiptc']==''){ |
---|
| 319 | $_SESSION['page_errors'] = array(l10n('IPTC field can\'t be empty')); |
---|
| 320 | redirect($admin_base_url); |
---|
| 321 | } |
---|
[32135] | 322 | $select= $_POST['selectiptc']; |
---|
| 323 | } |
---|
[30631] | 324 | if (!isset($_POST['inseractive'])) { |
---|
| 325 | $_POST['inseractive'] = 0; |
---|
| 326 | } |
---|
| 327 | if ($_POST['invisibleID'] == 0) { |
---|
[30702] | 328 | $result = pwg_query('SELECT MAX(orderprop) FROM '. ADD_PROP_PHOTO_TABLE ); |
---|
[30631] | 329 | $row = pwg_db_fetch_assoc($result); |
---|
[30702] | 330 | $or = ($row['MAX(orderprop)'] + 1); |
---|
[32135] | 331 | if ($_POST['typ'] == '4'||$_POST['typ'] == '3'||$_POST['typ'] == '5'||$_POST['typ'] == '6') { |
---|
| 332 | $q = 'INSERT INTO ' . $prefixeTable . 'add_properties_photos(wording,orderprop,active,edit,Typ,dataprop)VALUES ("' . $_POST['inserwording'] . '","' . $or . '","' . $_POST['inseractive'] . '",1,"' . $_POST['typ'] . '",\''. $select .'\');'; |
---|
| 333 | pwg_query($q); |
---|
| 334 | }else{ |
---|
| 335 | $q = 'INSERT INTO ' . $prefixeTable . 'add_properties_photos(wording,orderprop,active,edit,Typ)VALUES ("' . $_POST['inserwording'] . '","' . $or . '","' . $_POST['inseractive'] . '",1,"' . $_POST['typ'] . '");'; |
---|
| 336 | pwg_query($q); |
---|
| 337 | } |
---|
[30702] | 338 | $_SESSION['page_infos'] = array(l10n('Property photo add')); |
---|
[30631] | 339 | } else { |
---|
[32135] | 340 | if ($_POST['typ'] == '4'||$_POST['typ'] == '3'||$_POST['typ'] == '5'||$_POST['typ'] == '6') { |
---|
| 341 | $q = ' |
---|
| 342 | UPDATE ' . $prefixeTable . 'add_properties_photos' |
---|
[30702] | 343 | . ' set wording ="' . $_POST['inserwording'] . '" ' |
---|
[32135] | 344 | . ' ,active =' . $_POST['inseractive'] |
---|
| 345 | . ' ,Typ =' . $_POST['typ'] |
---|
| 346 | . ' ,dataprop =\'' . $select . '\' ' |
---|
| 347 | . ' WHERE id_prop_pho=' . $_POST['invisibleID'] . ';'; |
---|
| 348 | }else{ |
---|
| 349 | $q = ' |
---|
| 350 | UPDATE ' . $prefixeTable . 'add_properties_photos' |
---|
| 351 | . ' set wording ="' . $_POST['inserwording'] . '" ' |
---|
[30631] | 352 | . ' ,active=' . $_POST['inseractive'] |
---|
[32135] | 353 | . ' ,Typ =' . $_POST['typ'] |
---|
[30702] | 354 | . ' WHERE id_prop_pho=' . $_POST['invisibleID'] . ';'; |
---|
[32135] | 355 | } |
---|
[30631] | 356 | pwg_query($q); |
---|
[30702] | 357 | $_SESSION['page_infos'] = array(l10n('Property photo update')); |
---|
[30631] | 358 | } |
---|
| 359 | redirect($admin_base_url); |
---|
| 360 | } |
---|
| 361 | |
---|
| 362 | if (isset($_GET['delete'])) { |
---|
| 363 | check_input_parameter('delete', $_GET, false, PATTERN_ID); |
---|
[30702] | 364 | $query = 'DELETE FROM ' . ADD_PROP_PHOTO_TABLE . ' WHERE id_prop_pho = ' . $_GET['delete'] . ';'; |
---|
[30631] | 365 | pwg_query($query); |
---|
[30702] | 366 | $query = 'DELETE FROM ' . ADD_PROP_PHOTO_DATA_TABLE . ' WHERE id_prop_pho = ' . $_GET['delete'] . ';'; |
---|
[30639] | 367 | pwg_query($query); |
---|
[32135] | 368 | $query = 'DELETE FROM ' . ADD_PROP_PHOTO_DATADATE_TABLE . ' WHERE id_prop_pho = ' . $_GET['delete'] . ';'; |
---|
| 369 | pwg_query($query); |
---|
[30631] | 370 | |
---|
[30702] | 371 | $_SESSION['page_infos'] = array(l10n('Property delete')); |
---|
[30631] | 372 | redirect($admin_base_url); |
---|
| 373 | } |
---|
| 374 | |
---|
| 375 | if (isset($_GET['hide'])) { |
---|
| 376 | check_input_parameter('hide', $_GET, false, PATTERN_ID); |
---|
[30702] | 377 | $query = 'UPDATE ' . ADD_PROP_PHOTO_TABLE . ' SET active = 1 WHERE id_prop_pho=' . $_GET['hide'] . ';'; |
---|
[30631] | 378 | pwg_query($query); |
---|
| 379 | } |
---|
| 380 | |
---|
| 381 | if (isset($_GET['show'])) { |
---|
| 382 | check_input_parameter('show', $_GET, false, PATTERN_ID); |
---|
[30702] | 383 | $query = 'UPDATE ' . ADD_PROP_PHOTO_TABLE . ' SET active = 0 WHERE id_prop_pho=' . $_GET['show'] . ';'; |
---|
[30631] | 384 | pwg_query($query); |
---|
| 385 | } |
---|
| 386 | |
---|
| 387 | break; |
---|
[32135] | 388 | case 'config': |
---|
| 389 | $maxfields = (isset($conf['mpp_max_fields'])) ? $conf['mpp_max_fields'] : '5'; |
---|
| 390 | $template->assign('MPPMAXFIELD',$maxfields); |
---|
| 391 | $idexif = (isset($conf['mpp_idexif'])) ? $conf['mpp_idexif'] : ''; |
---|
| 392 | $template->assign('MPPIDEXIF',$idexif); |
---|
| 393 | $admin_base_url = ADD_PROP_PHOTO_ADMIN . '-config'; |
---|
| 394 | $template->assign( |
---|
| 395 | 'mppconfig', array( |
---|
| 396 | 'a' => 'a', |
---|
| 397 | )); |
---|
| 398 | |
---|
| 399 | $delpho = pwg_db_fetch_assoc(pwg_query('SELECT dataprop FROM ' . ADD_PROP_PHOTO_TABLE.' WHERE dataprop="DeletePhoto";')); |
---|
| 400 | if(empty($delpho)){ |
---|
| 401 | $template->assign( |
---|
| 402 | 'mppconfig', array( |
---|
| 403 | 'ADDPHOAC' => 'actiondelphoadd', |
---|
| 404 | )); |
---|
| 405 | } |
---|
| 406 | if (isset($_POST['submitadddelpho'])){ |
---|
| 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 | $q = 'INSERT INTO ' . $prefixeTable . 'add_properties_photos(wording,orderprop,active,edit,Typ,dataprop)VALUES ("**delpho**","' . $or . '","1",1,"2","DeletePhoto");'; |
---|
| 411 | pwg_query($q); |
---|
[32151] | 412 | $_SESSION['page_infos'] = array(l10n('Information data registered in database')); |
---|
| 413 | redirect(ADD_PROP_PHOTO_ADMIN . '-config'); |
---|
[32135] | 414 | } |
---|
| 415 | if (isset($_POST['submitremovedelpho'])){ |
---|
| 416 | $iddelpho = pwg_db_fetch_assoc(pwg_query('SELECT id_prop_pho FROM '. ADD_PROP_PHOTO_TABLE.' where dataprop="DeletePhoto";')); |
---|
| 417 | pwg_query('DELETE FROM ' . ADD_PROP_PHOTO_TABLE . ' where dataprop ="DeletePhoto";'); |
---|
| 418 | $query = 'DELETE FROM ' . ADD_PROP_PHOTO_DATADATE_TABLE . ' WHERE id_prop_pho = ' . $iddelpho['id_prop_pho'] . ';'; |
---|
| 419 | pwg_query($query); |
---|
[32151] | 420 | $_SESSION['page_infos'] = array(l10n('Information data registered in database')); |
---|
| 421 | redirect(ADD_PROP_PHOTO_ADMIN . '-config'); |
---|
[32135] | 422 | } |
---|
| 423 | $descpho = pwg_db_fetch_assoc(pwg_query('SELECT dataprop FROM ' . ADD_PROP_PHOTO_TABLE.' WHERE dataprop="movedescription";')); |
---|
| 424 | if(empty($descpho)){ |
---|
| 425 | $vars['MOVEDESC']='actionmovedesc'; |
---|
| 426 | $template->append('mppconfig', $vars, true); |
---|
| 427 | } |
---|
| 428 | if (isset($_POST['submitmovedesc'])){ |
---|
| 429 | $result = pwg_query('SELECT MAX(orderprop) FROM '. ADD_PROP_PHOTO_TABLE ); |
---|
| 430 | $row = pwg_db_fetch_assoc($result); |
---|
| 431 | $or = ($row['MAX(orderprop)'] + 1); |
---|
| 432 | $q = 'INSERT INTO ' . $prefixeTable . 'add_properties_photos(wording,orderprop,active,edit,Typ,dataprop)VALUES ("Description","' . $or . '","0",0,"1","movedescription");'; |
---|
| 433 | pwg_query($q); |
---|
[32151] | 434 | $_SESSION['page_infos'] = array(l10n('Information data registered in database')); |
---|
| 435 | redirect(ADD_PROP_PHOTO_ADMIN . '-config'); |
---|
[32135] | 436 | } |
---|
| 437 | if (isset($_POST['submitdefaultdesc'])){ |
---|
| 438 | pwg_query('DELETE FROM ' . ADD_PROP_PHOTO_TABLE . ' where dataprop ="movedescription";'); |
---|
[32151] | 439 | $_SESSION['page_infos'] = array(l10n('Information data registered in database')); |
---|
| 440 | redirect(ADD_PROP_PHOTO_ADMIN . '-config'); |
---|
[32135] | 441 | } |
---|
| 442 | if (isset($_POST['submitmppoption'])){ |
---|
| 443 | conf_update_param('mpp_max_fields', $_POST['mppmaxfield']); |
---|
| 444 | conf_update_param('mpp_idexif', $_POST['mppitidexif']); |
---|
[32136] | 445 | $_SESSION['page_infos'] = array(l10n('Information data registered in database')); |
---|
| 446 | redirect(ADD_PROP_PHOTO_ADMIN . '-config'); |
---|
[32135] | 447 | } |
---|
| 448 | break; |
---|
[30702] | 449 | } |
---|
[30631] | 450 | |
---|
| 451 | |
---|
| 452 | $template->set_filenames(array('plugin_admin_content' => dirname(__FILE__) . '/admin/admin.tpl')); |
---|
| 453 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
| 454 | ?> |
---|