1 | <?php |
---|
2 | |
---|
3 | |
---|
4 | // Copied and adapted from official ./admin/element_set.php |
---|
5 | |
---|
6 | |
---|
7 | /** |
---|
8 | * Management of elements set. Elements can belong to a category or to the |
---|
9 | * user caddie. |
---|
10 | * |
---|
11 | */ |
---|
12 | |
---|
13 | if (!defined('PHPWG_ROOT_PATH')) |
---|
14 | { |
---|
15 | die('Hacking attempt!'); |
---|
16 | } |
---|
17 | load_language('plugin.lang', UTG_PATH); |
---|
18 | |
---|
19 | include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); |
---|
20 | |
---|
21 | // +-----------------------------------------------------------------------+ |
---|
22 | // | Check Access and exit when user status is not ok | |
---|
23 | // +-----------------------------------------------------------------------+ |
---|
24 | check_status(ACCESS_ADMINISTRATOR); |
---|
25 | |
---|
26 | check_input_parameter('selection', $_POST, true, PATTERN_ID); |
---|
27 | |
---|
28 | // +-----------------------------------------------------------------------+ |
---|
29 | // | caddie management | |
---|
30 | // +-----------------------------------------------------------------------+ |
---|
31 | |
---|
32 | if (isset($_POST['submit_caddie'])) |
---|
33 | { |
---|
34 | if (isset($_POST['caddie_action'])) |
---|
35 | { |
---|
36 | switch ($_POST['caddie_action']) |
---|
37 | { |
---|
38 | case 'empty_all' : |
---|
39 | { |
---|
40 | $query = ' |
---|
41 | DELETE FROM '.CADDIE_TABLE.' |
---|
42 | WHERE user_id = '.$user['id'].' |
---|
43 | ;'; |
---|
44 | pwg_query($query); |
---|
45 | break; |
---|
46 | } |
---|
47 | case 'empty_selected' : |
---|
48 | { |
---|
49 | if (isset($_POST['selection']) and count($_POST['selection']) > 0) |
---|
50 | { |
---|
51 | $query = ' |
---|
52 | DELETE |
---|
53 | FROM '.CADDIE_TABLE.' |
---|
54 | WHERE element_id IN ('.implode(',', $_POST['selection']).') |
---|
55 | AND user_id = '.$user['id'].' |
---|
56 | ;'; |
---|
57 | pwg_query($query); |
---|
58 | } |
---|
59 | else |
---|
60 | { |
---|
61 | // TODO : add error |
---|
62 | } |
---|
63 | break; |
---|
64 | } |
---|
65 | case 'add_selected' : |
---|
66 | { |
---|
67 | if (isset($_POST['selection']) and count($_POST['selection']) > 0) |
---|
68 | { |
---|
69 | fill_caddie($_POST['selection']); |
---|
70 | } |
---|
71 | else |
---|
72 | { |
---|
73 | // TODO : add error |
---|
74 | } |
---|
75 | break; |
---|
76 | } |
---|
77 | } |
---|
78 | } |
---|
79 | else |
---|
80 | { |
---|
81 | // TODO : add error |
---|
82 | } |
---|
83 | } |
---|
84 | |
---|
85 | // +-----------------------------------------------------------------------+ |
---|
86 | // | initialize info about category | |
---|
87 | // +-----------------------------------------------------------------------+ |
---|
88 | |
---|
89 | // To element_set_(global|unit).php, we must provide the elements id of the |
---|
90 | // managed category in $page['cat_elements_id'] array. |
---|
91 | |
---|
92 | // Adaptions for unTagged |
---|
93 | |
---|
94 | $page['cat_elements_id'] = array(); |
---|
95 | //else if ('duplicates' == $_GET['cat']) |
---|
96 | if (true) |
---|
97 | { |
---|
98 | $page['title'] = l10n('Untagged elements'); |
---|
99 | |
---|
100 | // Retrieves ids from images tables |
---|
101 | // 1 - Retrieve Files |
---|
102 | $query = ' |
---|
103 | SELECT id |
---|
104 | FROM '.IMAGES_TABLE.' AS Img |
---|
105 | LEFT OUTER JOIN '.IMAGE_TAG_TABLE.' AS iTag ON Img.id = iTag.image_id |
---|
106 | WHERE iTag.image_id IS NULL;'; |
---|
107 | |
---|
108 | $page['cat_elements_id'] = array_from_query($query, 'id'); |
---|
109 | } |
---|
110 | |
---|
111 | // +-----------------------------------------------------------------------+ |
---|
112 | // | first element to display | |
---|
113 | // +-----------------------------------------------------------------------+ |
---|
114 | |
---|
115 | // $page['start'] contains the number of the first element in its |
---|
116 | // category. For exampe, $page['start'] = 12 means we must show elements #12 |
---|
117 | // and $page['nb_images'] next elements |
---|
118 | |
---|
119 | if (!isset($_GET['start']) |
---|
120 | or !is_numeric($_GET['start']) |
---|
121 | or $_GET['start'] < 0 |
---|
122 | or (isset($_GET['display']) and 'all' == $_GET['display'])) |
---|
123 | { |
---|
124 | $page['start'] = 0; |
---|
125 | } |
---|
126 | else |
---|
127 | { |
---|
128 | $page['start'] = $_GET['start']; |
---|
129 | } |
---|
130 | |
---|
131 | // +-----------------------------------------------------------------------+ |
---|
132 | // | open specific mode | |
---|
133 | // +-----------------------------------------------------------------------+ |
---|
134 | |
---|
135 | $_GET['mode'] = !empty($_GET['mode']) ? $_GET['mode'] : 'global'; |
---|
136 | |
---|
137 | switch ($_GET['mode']) |
---|
138 | { |
---|
139 | case 'global' : |
---|
140 | { |
---|
141 | include(PHPWG_ROOT_PATH.'admin/element_set_global.php'); |
---|
142 | break; |
---|
143 | } |
---|
144 | case 'unit' : |
---|
145 | { |
---|
146 | include(PHPWG_ROOT_PATH.'admin/element_set_unit.php'); |
---|
147 | break; |
---|
148 | } |
---|
149 | } |
---|
150 | |
---|
151 | if ( !function_exists( 'untagged_tools_menu' ) ) |
---|
152 | { |
---|
153 | function untagged_tools_menu() |
---|
154 | { |
---|
155 | global $template; |
---|
156 | $template->assign('ACTIVE_MENU', 4); |
---|
157 | } |
---|
158 | } |
---|
159 | |
---|
160 | add_event_handler('loc_end_admin', 'untagged_tools_menu'); |
---|
161 | // $template->assign('ACTIVE_MENU', 4); |
---|
162 | |
---|
163 | ?> |
---|