Ignore:
Timestamp:
Apr 17, 2013, 1:34:12 PM (11 years ago)
Author:
ddtddt
Message:

[extensions] - Batch Manager Prefiltre description - add action

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/bmp_description/initadmin.php

    r22247 r22253  
    1010
    1111function BMPD_add_batch_manager_prefilters($prefilters)
    12 {
     12{load_language('plugin.lang', BMPD_PATH);
    1313        array_push($prefilters, array(
    1414    'ID' => 'BMPD',
    15     'NAME' => l10n('Without description'),
     15    'NAME' => l10n('With no description'),
    1616  ));
    1717        return $prefilters;
     
    6060}
    6161
     62
     63 add_event_handler('loc_end_element_set_global', 'BMPD_loc_end_element_set_global');
     64 add_event_handler('element_set_global_action', 'BMPD_element_set_global_action', EVENT_HANDLER_PRIORITY_NEUTRAL, 2);
     65 
     66function BMPD_loc_end_element_set_global()
     67 {
     68        global $template;
     69       
     70        $template->append('element_set_global_plugins_actions', array(
     71    'ID' => 'BMPD3',
     72    'NAME' => l10n('Set description'),
     73    'CONTENT' => '
     74                                        <input type="checkbox" name="check_BMPD4"> '.l10n('remove description').'<br>
     75                                        <textarea rows="5" cols="50" class="description" name="BMPD3" id="BMPD3">'.l10n('Type here the description').'</textarea>
     76                                        <input type="checkbox" name="check_BMPD"> '.l10n('confirm').'
     77        ',
     78        ));
     79 }
     80
     81function BMPD_element_set_global_action($action, $collection)
     82 {
     83        if ($action == 'BMPD3')
     84  {
     85    global $page;
     86   
     87    if (empty($_POST['check_BMPD']))
     88    {
     89      array_push($page['warnings'], l10n('You need to confirm'));
     90    }
     91    else
     92    {
     93
     94if (isset($_POST['check_BMPD4']))
     95    {
     96      $_POST['BMPD3'] = null;
     97    }
     98   
     99$datas = array();
     100    foreach ($collection as $image_id)
     101    {
     102      array_push(
     103        $datas,
     104        array(
     105          'id' => $image_id,
     106          'comment' => $_POST['BMPD3']
     107          )
     108        );
     109    }
     110
     111    mass_updates(
     112      IMAGES_TABLE,
     113      array('primary' => array('id'), 'update' => array('comment')),
     114      $datas
     115      );
     116               
     117    }
     118  }
     119 }
     120
    62121?>
Note: See TracChangeset for help on using the changeset viewer.