This repository was archived by the owner on Jan 5, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfilter.php
More file actions
63 lines (53 loc) · 1.67 KB
/
filter.php
File metadata and controls
63 lines (53 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
add_event_handler('get_batch_manager_prefilters', 'PB_add_bm_filter');
add_event_handler('perform_batch_manager_prefilters', 'PB_perform_bm_filter', 50, 2);
add_event_handler('element_set_global_action', 'PB_element_set_bm_global_action');
// Add the filter to the list
function PB_add_bm_filter($prefilters)
{
load_language('plugin.lang', dirname(__FILE__).'/');
array_push($prefilters,
array('ID' => 'avec auteur', 'NAME' => l10n('sans auteur')),
array('ID' => 'sans auteur', 'NAME' => l10n('sans auteur'))
);
return $prefilters;
}
// Put the right photos in the prefilter array
function PB_perform_bm_filter($filter_sets, $prefilter)
{
if ('avec auteur' == $prefilter) {
// Select all photos in the copyrights table who´s CR not is 0
$query = sprintf('
SELECT media_id
FROM %s
WHERE pb_id <> 0
;',
PRODUCEDBY_MEDIA);
array_push($filter_sets, array_from_query($query, 'media_id'));
}
if ('sans auteur' == $prefilter) {
// Select all photo's, except the ones that have a copyright
$query = sprintf('
SELECT id
FROM %s
WHERE id NOT IN (
SELECT media_id
FROM %s
WHERE pb_id <> 0
)
;',
IMAGES_TABLE, PRODUCEDBY_MEDIA);
array_push($filter_sets, array_from_query($query, 'id'));
}
return $filter_sets;
}
// Test if the filters aren't set incorrectly
function PB_element_set_bm_global_action($action)
{
if (in_array(@$_SESSION['bulk_manager_filter']['prefilter'], array('avec auteur', 'sans auteur')) and $action == 'produced_by') {
// let's refresh the page because we the current set might be modified
redirect(get_root_url().'admin.php?page='.$_GET['page']);
}
}
?>