source: extensions/manage_properties_photos/main.inc.php @ 32135

Last change on this file since 32135 was 32135, checked in by ddtddt, 4 years ago

[manage_properties_photos]

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