source: extensions/batch_manager_prefilters/main.inc.php @ 22278

Revision 22278, 1.9 KB checked in by ddtddt, 7 years ago (diff)

[extensions] - batch_manager_prefilters - Checked compatibility with Piwigo 2.5 / delete filter HD

Line 
1<?php
2/*
3Plugin Name: Batch Manager Prefilters
4Version: auto
5Description: Add some prefilters in Batch Manager.
6Plugin URI: auto
7Author: P@t
8Author URI: http://www.gauchon.com
9*/
10
11if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
12
13add_event_handler('get_batch_manager_prefilters', 'add_bmp');
14add_event_handler('perform_batch_manager_prefilters', 'perform_bmp', 50, 2);
15add_event_handler('element_set_global_action', 'element_set_global_action_bmp');
16
17function add_bmp($prefilters)
18{
19  load_language('plugin.lang', dirname(__FILE__).'/');
20
21  array_push($prefilters,
22    array('ID' => 'with tags', 'NAME' => l10n('with tags')),
23    array('ID' => 'with author', 'NAME' => l10n('with author')),
24    array('ID' => 'without author', 'NAME' => l10n('without author'))
25  );
26
27  return $prefilters;
28}
29
30function perform_bmp($filter_sets, $prefilter)
31{
32  if ('with tags' == $prefilter)
33  {
34    $query = 'SELECT DISTINCT image_id FROM '.IMAGE_TAG_TABLE.';';
35    array_push($filter_sets, array_from_query($query, 'image_id'));
36  }
37
38  if ('with author' == $prefilter)
39  {
40    $query = 'SELECT id FROM '.IMAGES_TABLE.' WHERE author IS NOT NULL;';
41    array_push($filter_sets, array_from_query($query, 'id'));
42  }
43
44  if ('without author' == $prefilter)
45  {
46    $query = 'SELECT id FROM '.IMAGES_TABLE.' WHERE author IS NULL;';
47    array_push($filter_sets, array_from_query($query, 'id'));
48  }
49
50  return $filter_sets;
51}
52
53function element_set_global_action_bmp($action)
54{
55  if ((@$_SESSION['bulk_manager_filter']['prefilter'] == 'with tags' and in_array($action, array('add_tags', 'del_tags')))
56    or (in_array(@$_SESSION['bulk_manager_filter']['prefilter'], array('with author', 'without author')) and $action == 'author'))
57  {
58    // let's refresh the page because we the current set might be modified
59    redirect(get_root_url().'admin.php?page='.$_GET['page']);
60  }
61}
62
63?>
Note: See TracBrowser for help on using the repository browser.