1 | <?php |
---|
2 | /* |
---|
3 | Plugin Name: Posted Date Changer |
---|
4 | Version: auto |
---|
5 | Description: Change the posted date of photos in batch manager. |
---|
6 | Plugin URI: http://piwigo.org/ext/extension_view.php?eid=528 |
---|
7 | Author: P@t |
---|
8 | Author URI: http://www.gauchon.com |
---|
9 | */ |
---|
10 | |
---|
11 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
12 | |
---|
13 | add_event_handler('loc_end_element_set_global', 'change_posted_date'); |
---|
14 | add_event_handler('element_set_global_action', 'change_posted_date_action', 50, 2); |
---|
15 | |
---|
16 | function 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 | |
---|
40 | function 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 | ?> |
---|