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 | $datas = array(); |
---|
47 | foreach ($collection as $image_id) |
---|
48 | { |
---|
49 | array_push( |
---|
50 | $datas, |
---|
51 | array( |
---|
52 | 'id' => $image_id, |
---|
53 | 'date_available' => $date_available |
---|
54 | ) |
---|
55 | ); |
---|
56 | } |
---|
57 | mass_updates( |
---|
58 | IMAGES_TABLE, |
---|
59 | array('primary' => array('id'), 'update' => array('date_available')), |
---|
60 | $datas |
---|
61 | ); |
---|
62 | }else{ |
---|
63 | load_language('plugin.lang', dirname(__FILE__).'/');; |
---|
64 | $_SESSION['page_errors'] = array(l10n('Date can\'t be empty')); |
---|
65 | } |
---|
66 | } |
---|
67 | } |
---|
68 | |
---|
69 | ?> |
---|