source: extensions/posted_date_changer/main.inc.php @ 31930

Last change on this file since 31930 was 30028, checked in by ddtddt, 9 years ago

[posted_date_changer] Check 2.7

File size: 1.6 KB
Line 
1<?php
2/*
3Plugin Name: Posted Date Changer
4Version: auto
5Description: Change the posted date of photos in batch manager.
6Plugin URI: http://piwigo.org/ext/extension_view.php?eid=528
7Author: P@t
8Author URI: http://www.gauchon.com
9*/
10
11if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
12
13add_event_handler('loc_end_element_set_global', 'change_posted_date');
14add_event_handler('element_set_global_action', 'change_posted_date_action', 50, 2);
15
16function change_posted_date()
17{
18  global $template;
19
20  load_language('plugin.lang', dirname(__FILE__).'/');
21
22  $template->set_filename('change_posted_date', dirname(__FILE__).'/change_posted_date.tpl');
23
24  $dateavailable = empty($_POST['date_available']) ? date('Y-m-d').' 00:00:00' : $_POST['date_available'];
25 
26
27  $template->assign(array(
28    'DATE_AVAILABLE'  => $dateavailable
29        )
30  );
31
32  $template->append('element_set_global_plugins_actions', array(
33    'ID' => 'date_available',
34    'NAME' => l10n('Change Posted Date'),
35    'CONTENT' => $template->parse('change_posted_date', true),
36    )
37  );
38}
39
40function change_posted_date_action($action, $collection)
41{
42  if ($action == 'date_available')
43  {
44        if(!empty($_POST['date_available'])){
45     $date_available = $_POST['date_available'];
46        }else{
47         $date_available=null;
48        }
49
50    $datas = array();
51    foreach ($collection as $image_id)
52    {
53      array_push(
54        $datas,
55        array(
56          'id' => $image_id,
57          'date_available' => $date_available
58          )
59        );
60    }
61
62    mass_updates(
63      IMAGES_TABLE,
64      array('primary' => array('id'), 'update' => array('date_available')),
65      $datas
66      );
67  }
68}
69
70?>
Note: See TracBrowser for help on using the repository browser.