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

Last change on this file since 32436 was 32436, checked in by ddtddt, 3 years ago

[posted_date_changer] piwigo 11

File size: 1.7 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         $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?>
Note: See TracBrowser for help on using the repository browser.