1 | <?php |
---|
2 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
3 | |
---|
4 | load_language('plugin.lang', BMPD_PATH); |
---|
5 | |
---|
6 | global $prefilter; |
---|
7 | |
---|
8 | add_event_handler('get_batch_manager_prefilters', 'BMPD_add_batch_manager_prefilters'); |
---|
9 | add_event_handler('perform_batch_manager_prefilters', 'BMPD_perform_batch_manager_prefilters', EVENT_HANDLER_PRIORITY_NEUTRAL, 2); |
---|
10 | |
---|
11 | function BMPD_add_batch_manager_prefilters($prefilters) |
---|
12 | {load_language('plugin.lang', BMPD_PATH); |
---|
13 | array_push($prefilters, array( |
---|
14 | 'ID' => 'BMPD', |
---|
15 | 'NAME' => l10n('With no description'), |
---|
16 | )); |
---|
17 | return $prefilters; |
---|
18 | } |
---|
19 | |
---|
20 | function BMPD_perform_batch_manager_prefilters($filter_sets, $prefilter) |
---|
21 | { |
---|
22 | if ($prefilter == 'BMPD') |
---|
23 | { |
---|
24 | $query = ' |
---|
25 | SELECT id |
---|
26 | FROM '.IMAGES_TABLE.' |
---|
27 | WHERE comment is null |
---|
28 | ;'; |
---|
29 | $filter_sets[] = array_from_query($query, 'id'); |
---|
30 | } |
---|
31 | |
---|
32 | return $filter_sets; |
---|
33 | } |
---|
34 | |
---|
35 | add_event_handler('get_batch_manager_prefilters', 'BMPD2_add_batch_manager_prefilters'); |
---|
36 | add_event_handler('perform_batch_manager_prefilters', 'BMPD2_perform_batch_manager_prefilters', EVENT_HANDLER_PRIORITY_NEUTRAL, 2); |
---|
37 | |
---|
38 | function BMPD2_add_batch_manager_prefilters($prefilters) |
---|
39 | { |
---|
40 | array_push($prefilters, array( |
---|
41 | 'ID' => 'BMPD2', |
---|
42 | 'NAME' => l10n('With description'), |
---|
43 | )); |
---|
44 | return $prefilters; |
---|
45 | } |
---|
46 | |
---|
47 | function BMPD2_perform_batch_manager_prefilters($filter_sets, $prefilter) |
---|
48 | { |
---|
49 | if ($prefilter == 'BMPD2') |
---|
50 | { |
---|
51 | $query = ' |
---|
52 | SELECT id |
---|
53 | FROM '.IMAGES_TABLE.' |
---|
54 | WHERE comment is not null |
---|
55 | ;'; |
---|
56 | $filter_sets[] = array_from_query($query, 'id'); |
---|
57 | } |
---|
58 | |
---|
59 | return $filter_sets; |
---|
60 | } |
---|
61 | |
---|
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 | |
---|
66 | function 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 | |
---|
81 | function 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 | |
---|
94 | if (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 | |
---|
121 | ?> |
---|