source: extensions/manage_properties_photos/initadmin.php @ 31406

Last change on this file since 31406 was 31406, checked in by ddtddt, 8 years ago

[extensions] - manage_properties_photos - updade faiture batch manager

File size: 5.0 KB
RevLine 
[30631]1<?php
[31361]2// +-----------------------------------------------------------------------+
3// | Manage Properties Photos plugin for Piwigo                            |
4// +-----------------------------------------------------------------------+
5// | Copyright(C) 2014-2016 ddtddt                      http://temmii.com |
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
[31360]22//add admin menu
[30631]23add_event_handler('get_admin_plugin_menu_links', 'add_info_photo_admin_menu');
24
25function add_info_photo_admin_menu($menu) {
[30702]26    load_language('plugin.lang', ADD_PROP_PHOTO_PATH);
[30631]27    $menu[] = array(
[30702]28        'NAME' => l10n('Manage properties photos'),
29        'URL' => ADD_PROP_PHOTO_ADMIN,
[30631]30    );
31     return $menu;
32}
33
34add_event_handler('tabsheet_before_select', 'aip_tabsheet_before_select',
35    EVENT_HANDLER_PRIORITY_NEUTRAL);
36
37function aip_tabsheet_before_select($sheets, $id)
38{
39    global $template, $page;
40  if ($id == 'photo')
41  {
42    $sheets['iap'] = array(
[30702]43      'caption' => l10n('Properties additionals'),
44      'url' => ADD_PROP_PHOTO_ADMIN.'-iap&amp;image_id='.$_GET['image_id'],
[30631]45      );
46  }
47  return $sheets;
48}
49
[31361]50//add manage by batch Manager
[31360]51add_event_handler('loc_end_element_set_global', 'MPP_loc_end_element_set_global');
52add_event_handler('element_set_global_action', 'MPP_element_set_global_action', EVENT_HANDLER_PRIORITY_NEUTRAL, 2);
53 
54function MPP_loc_end_element_set_global()
55 {
56 load_language('plugin.lang', ADD_PROP_PHOTO_PATH);
57        global $template;
[31406]58       
59$q = 'SELECT 1 FROM ' . ADD_PROP_PHOTO_TABLE . ' WHERE edit=1';
60        $test = pwg_query($q);
61        $row = pwg_db_fetch_assoc($test);
62        if (count($row) > 0) {
63               
[31360]64  $propertieslist = array();
[31361]65  $propertieslist2 = tab_add_info_by_photo();
[31360]66
[31361]67  $PAED = pwg_db_fetch_assoc(pwg_query("SELECT state FROM " . PLUGINS_TABLE . " WHERE id = 'ExtendedDescription';"));
[31363]68        if($PAED['state'] == 'active'){
69                add_event_handler('AP_render_content', 'get_user_language_desc');
70                $template->assign('useED',1);
71    }else{
72        $template->assign('useED',0);
73    }
[31361]74
[31360]75  while ($row = pwg_db_fetch_assoc($propertieslist2))
76  {
[31361]77    $propertieslist[$row['id_prop_pho']] = trigger_change('AP_render_content', $row['wording']);
[31360]78  }
79$template->set_filename('MMPP', realpath(ADD_PROP_PHOTO_PATH.'mmp.tpl'));
80$template->assign('propertieslist', $propertieslist);
81$template->append('element_set_global_plugins_actions', array(
82    'ID' => 'MPP', 
[31363]83    'NAME' => l10n('Change photos properties'), 
[31360]84    'CONTENT' => $template->parse('MMPP', true)
85        ));
[31406]86        }
[31360]87 }
88 
89 function MPP_element_set_global_action($action, $collection)
90 {
91  load_language('plugin.lang', ADD_PROP_PHOTO_PATH);
92        if ($action == 'MPP')
93  {
94    global $page,$template,$prefixeTable;
95   
[31406]96        $id_prop_pho= $_POST['IDMPP'];
97        $data= $_POST['dataglob'];     
98       
99    if (!empty($_POST['check_MPP']))
[31360]100    {
[31406]101    foreach ($collection as $image_id)
102      {
103                $query = 'DELETE FROM ' . $prefixeTable . 'add_properties_photos_data WHERE id_img=' . $image_id . ' AND id_prop_pho=' . $id_prop_pho;
104                pwg_query($query);
105      }
[31360]106    }
107    else
108    {
109    foreach ($collection as $image_id)
110      {
111            $q = 'SELECT 1 FROM ' . ADD_PROP_PHOTO_DATA_TABLE . ' WHERE id_img=' . $image_id . ' AND id_prop_pho=' . $id_prop_pho;
112        $test = pwg_query($q);
113        $row = pwg_db_fetch_assoc($test);
114        if (count($row) > 0) {
115            if ($data != '') {
116                $query = 'UPDATE ' . $prefixeTable . 'add_properties_photos_data SET data="' . $data . '" WHERE id_img=' . $image_id . ' AND id_prop_pho=' . $id_prop_pho;
117                pwg_query($query);
118            } else {
119                $query = 'DELETE FROM ' . $prefixeTable . 'add_properties_photos_data WHERE id_img=' . $image_id . ' AND id_prop_pho=' . $id_prop_pho;
120                pwg_query($query);
121            }
122        } else if ($data != '') {
123            $query = 'INSERT ' . $prefixeTable . 'add_properties_photos_data(id_img,id_prop_pho,data) VALUES (' . $image_id . ',' . $id_prop_pho . ',"' . $data . '");';
124            pwg_query($query);
125        }
126      }
127    }
128  }
129 }
130 
131 
Note: See TracBrowser for help on using the repository browser.