1 | <?php |
---|
2 | /* |
---|
3 | Plugin Name: Manage Properties Photos |
---|
4 | Version: auto |
---|
5 | Description: Add properties on photo page and organize this |
---|
6 | Plugin URI: http://piwigo.org/ext/extension_view.php?eid=783 |
---|
7 | Author: ddtddt |
---|
8 | Author URI: http://temmii.com/piwigo/ |
---|
9 | Has Settings: webmaster |
---|
10 | */ |
---|
11 | |
---|
12 | // +-----------------------------------------------------------------------+ |
---|
13 | // | Manage Properties Photos plugin for Piwigo by TEMMII | |
---|
14 | // +-----------------------------------------------------------------------+ |
---|
15 | // | Copyright(C) 2007-2021 ddtddt http://temmii.com/piwigo/ | |
---|
16 | // +-----------------------------------------------------------------------+ |
---|
17 | // | This program is free software; you can redistribute it and/or modify | |
---|
18 | // | it under the terms of the GNU General Public License as published by | |
---|
19 | // | the Free Software Foundation | |
---|
20 | // | | |
---|
21 | // | This program is distributed in the hope that it will be useful, but | |
---|
22 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
23 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
24 | // | General Public License for more details. | |
---|
25 | // | | |
---|
26 | // | You should have received a copy of the GNU General Public License | |
---|
27 | // | along with this program; if not, write to the Free Software | |
---|
28 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
29 | // | USA. | |
---|
30 | // +-----------------------------------------------------------------------+ |
---|
31 | |
---|
32 | |
---|
33 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
34 | |
---|
35 | global $prefixeTable; |
---|
36 | |
---|
37 | define('ADD_PROP_PHOTO_DIR' , basename(dirname(__FILE__))); |
---|
38 | define('ADD_PROP_PHOTO_PATH' , PHPWG_PLUGINS_PATH . ADD_PROP_PHOTO_DIR . '/'); |
---|
39 | if (!defined('ADD_PROP_PHOTO_TABLE')) define('ADD_PROP_PHOTO_TABLE', $prefixeTable.'add_properties_photos'); |
---|
40 | if (!defined('ADD_PROP_PHOTO_DATA_TABLE')) define('ADD_PROP_PHOTO_DATA_TABLE', $prefixeTable.'add_properties_photos_data'); |
---|
41 | if (!defined('ADD_PROP_PHOTO_DATADATE_TABLE')) define('ADD_PROP_PHOTO_DATADATE_TABLE', $prefixeTable.'add_properties_photos_datadate'); |
---|
42 | define('ADD_PROP_PHOTO_ADMIN',get_root_url().'admin.php?page=plugin-'.ADD_PROP_PHOTO_DIR); |
---|
43 | |
---|
44 | include_once(ADD_PROP_PHOTO_PATH . 'include/function.aip.inc.php'); |
---|
45 | |
---|
46 | add_event_handler('loading_lang', 'manage_properties_photos_loading_lang'); |
---|
47 | function manage_properties_photos_loading_lang(){ |
---|
48 | load_language('plugin.lang', ADD_PROP_PHOTO_PATH); |
---|
49 | } |
---|
50 | |
---|
51 | // Plugin on picture page |
---|
52 | if (script_basename() == 'picture'){ |
---|
53 | include_once(dirname(__FILE__).'/initpicture.php'); |
---|
54 | } |
---|
55 | |
---|
56 | // Plugin for admin |
---|
57 | if (script_basename() == 'admin'){ |
---|
58 | include_once(dirname(__FILE__).'/initadmin.php'); |
---|
59 | } |
---|
60 | |
---|
61 | /*delete photo*/ |
---|
62 | $datedelete = pwg_db_fetch_assoc(pwg_query("SELECT id_prop_pho FROM " . ADD_PROP_PHOTO_TABLE . " WHERE dataprop = 'DeletePhoto' AND Typ = 2 LIMIT 1;")); |
---|
63 | if ($datedelete != NULL){ |
---|
64 | $photodelete = pwg_query(' |
---|
65 | SELECT id_img |
---|
66 | FROM '.ADD_PROP_PHOTO_DATADATE_TABLE.' |
---|
67 | WHERE datadate <= NOW() |
---|
68 | AND id_prop_pho = '.$datedelete['id_prop_pho'].' |
---|
69 | ;'); |
---|
70 | if (pwg_db_num_rows($photodelete)) { |
---|
71 | include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); |
---|
72 | while ($delete_photos = pwg_db_fetch_assoc($photodelete)) { |
---|
73 | $tab_delete_photos[]=$delete_photos['id_img']; |
---|
74 | } |
---|
75 | global $user,$conf; |
---|
76 | $user['id']=$conf['webmaster_id']; |
---|
77 | delete_elements($tab_delete_photos, true); |
---|
78 | pwg_query('DELETE FROM '.ADD_PROP_PHOTO_DATA_TABLE.' WHERE id_img IN ('.implode(',', $tab_delete_photos).');'); |
---|
79 | pwg_query('DELETE FROM '.ADD_PROP_PHOTO_DATADATE_TABLE.' WHERE id_img IN ('.implode(',', $tab_delete_photos).');'); |
---|
80 | invalidate_user_cache(); |
---|
81 | unset($user); |
---|
82 | } |
---|
83 | } |
---|
84 | |
---|
85 | /*end delete photo*/ |
---|
86 | |
---|
87 | ?> |
---|