Changeset 31360


Ignore:
Timestamp:
Feb 22, 2016, 11:23:02 AM (4 years ago)
Author:
ddtddt
Message:

[extensions] - manage_properties_photos - add gest by batch Manager

Location:
extensions/manage_properties_photos
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/manage_properties_photos/initadmin.php

    r30702 r31360  
    11<?php
    22
    3 //Ajout du menu admin
     3//add admin menu
    44add_event_handler('get_admin_plugin_menu_links', 'add_info_photo_admin_menu');
    55
     
    2929}
    3030
    31 ?>
     31//add gest by batch Manager
     32add_event_handler('loc_end_element_set_global', 'MPP_loc_end_element_set_global');
     33add_event_handler('element_set_global_action', 'MPP_element_set_global_action', EVENT_HANDLER_PRIORITY_NEUTRAL, 2);
     34 
     35function MPP_loc_end_element_set_global()
     36 {
     37 load_language('plugin.lang', ADD_PROP_PHOTO_PATH);
     38        global $template;
     39  $propertieslist = array();
     40  $propertieslist2 = tab_add_info_by_photo(); 
     41
     42  while ($row = pwg_db_fetch_assoc($propertieslist2))
     43  {
     44    $propertieslist[$row['id_prop_pho']] = $row['wording'];
     45
     46  }
     47$template->set_filename('MMPP', realpath(ADD_PROP_PHOTO_PATH.'mmp.tpl'));
     48$template->assign('propertieslist', $propertieslist);
     49$template->append('element_set_global_plugins_actions', array(
     50    'ID' => 'MPP',
     51    'NAME' => l10n('Change properties'),
     52    'CONTENT' => $template->parse('MMPP', true)
     53        ));
     54 }
     55 
     56 function MPP_element_set_global_action($action, $collection)
     57 {
     58  load_language('plugin.lang', ADD_PROP_PHOTO_PATH);
     59        if ($action == 'MPP')
     60  {
     61    global $page,$template,$prefixeTable;
     62   
     63    if (empty($_POST['check_MPP']))
     64    {
     65
     66          $template->assign('PLUG_MPP', $_POST['dataglob']);
     67          $template->assign('SELECTEDMPP', $_POST['IDMPP']);
     68      array_push($page['warnings'], l10n('You need to confirm'));
     69    }
     70    else
     71    {
     72$id_prop_pho= $_POST['IDMPP'];
     73$data= $_POST['dataglob'];             
     74         
     75    foreach ($collection as $image_id)
     76      {
     77            $q = 'SELECT 1 FROM ' . ADD_PROP_PHOTO_DATA_TABLE . ' WHERE id_img=' . $image_id . ' AND id_prop_pho=' . $id_prop_pho;
     78        $test = pwg_query($q);
     79        $row = pwg_db_fetch_assoc($test);
     80        if (count($row) > 0) {
     81            if ($data != '') {
     82                $query = 'UPDATE ' . $prefixeTable . 'add_properties_photos_data SET data="' . $data . '" WHERE id_img=' . $image_id . ' AND id_prop_pho=' . $id_prop_pho;
     83                pwg_query($query);
     84            } else {
     85                $query = 'DELETE FROM ' . $prefixeTable . 'add_properties_photos_data WHERE id_img=' . $image_id . ' AND id_prop_pho=' . $id_prop_pho;
     86                pwg_query($query);
     87            }
     88        } else if ($data != '') {
     89            $query = 'INSERT ' . $prefixeTable . 'add_properties_photos_data(id_img,id_prop_pho,data) VALUES (' . $image_id . ',' . $id_prop_pho . ',"' . $data . '");';
     90            pwg_query($query);
     91        }
     92      }
     93    }
     94  }
     95 }
     96 
     97 
Note: See TracChangeset for help on using the changeset viewer.