gruffen commited on 2011-06-08 15:50:24
Showing 1 changed files, with 50 additions and 30 deletions.
... | ... |
@@ -76,33 +76,7 @@ function shd_load_action_log_entries($start = 0, $items_per_page = 10, $sort = ' |
76 | 76 |
$loaded_users = array(); |
77 | 77 |
|
78 | 78 |
// We may have to exclude some items from this depending on who the user is or is not. Forum/HD admins can always see everything. |
79 |
- $exclude = array(); |
|
80 |
- if (!$user_info['is_admin'] && !shd_allowed_to('admin_helpdesk', 0)) |
|
81 |
- { |
|
82 |
- // First, custom field changes only available to admins. |
|
83 |
- $exclude = array('cf_tktchange_admin', 'cf_rplchange_admin', 'cf_tktchgdef_admin', 'cf_rplchgdef_admin'); |
|
84 |
- // Next, staff only things |
|
85 |
- if (!shd_allowed_to('shd_staff', 0)) |
|
86 |
- { |
|
87 |
- $exclude[] = 'cf_tktchange_staffadmin'; |
|
88 |
- $exclude[] = 'cf_rplchange_staffadmin'; |
|
89 |
- $exclude[] = 'cf_tktchgdef_staffadmin'; |
|
90 |
- $exclude[] = 'cf_rplchgdef_staffadmin'; |
|
91 |
- } |
|
92 |
- else |
|
93 |
- // Next, user only things (that staff can't see) |
|
94 |
- { |
|
95 |
- $exclude[] = 'cf_tktchange_useradmin'; |
|
96 |
- $exclude[] = 'cf_rplchange_useradmin'; |
|
97 |
- $exclude[] = 'cf_tktchgdef_useradmin'; |
|
98 |
- $exclude[] = 'cf_rplchgdef_useradmin'; |
|
99 |
- } |
|
100 |
- |
|
101 |
- // Can they see multiple departments? If not, exclude dept move notices too. |
|
102 |
- $dept = shd_allowed_to('access_helpdesk', false); |
|
103 |
- if (count($dept) == 1) |
|
104 |
- $exclude[] = 'move_dept'; |
|
105 |
- } |
|
79 |
+ $exclude = shd_action_log_exclusions(); |
|
106 | 80 |
|
107 | 81 |
if (!empty($exclude)) |
108 | 82 |
{ |
... | ... |
@@ -331,16 +305,26 @@ function shd_count_action_log_entries($clause = '') |
331 | 305 |
{ |
332 | 306 |
global $smcFunc; |
333 | 307 |
|
308 |
+ $exclude = shd_action_log_exclusions(); |
|
309 |
+ |
|
310 |
+ if (!empty($exclude)) |
|
311 |
+ { |
|
312 |
+ if (empty($clause)) |
|
313 |
+ $clause = 'la.action NOT IN ({array_string:exclude})'; |
|
314 |
+ else |
|
315 |
+ $clause .= ' AND la.action NOT IN ({array_string:exclude})'; |
|
316 |
+ } |
|
317 |
+ |
|
334 | 318 |
// Without further screaming and waving, fetch the actions. |
335 | 319 |
$request = shd_db_query('',' |
336 | 320 |
SELECT COUNT(*) |
337 | 321 |
FROM {db_prefix}helpdesk_log_action AS la |
338 | 322 |
LEFT JOIN {db_prefix}members AS mem ON(mem.id_member = la.id_member) |
339 |
- LEFT JOIN {db_prefix}membergroups AS mg ON (mg.id_group = CASE WHEN mem.id_group = {int:reg_group_id} THEN mem.id_post_group ELSE mem.id_group END) |
|
340 |
- {raw:clause}', |
|
323 |
+ LEFT JOIN {db_prefix}membergroups AS mg ON (mg.id_group = CASE WHEN mem.id_group = {int:reg_group_id} THEN mem.id_post_group ELSE mem.id_group END)' . (empty($clause) ? '' : ' |
|
324 |
+ WHERE ' . $clause), |
|
341 | 325 |
array( |
342 | 326 |
'reg_group_id' => 0, |
343 |
- 'clause' => empty($clause) ? '' : 'WHERE ' . $clause, |
|
327 |
+ 'exclude' => $exclude, |
|
344 | 328 |
) |
345 | 329 |
); |
346 | 330 |
|
... | ... |
@@ -350,6 +334,42 @@ function shd_count_action_log_entries($clause = '') |
350 | 334 |
return $entry_count; |
351 | 335 |
} |
352 | 336 |
|
337 |
+function shd_action_log_exclusions() |
|
338 |
+{ |
|
339 |
+ global $user_info; |
|
340 |
+ |
|
341 |
+ $exclude = array(); |
|
342 |
+ |
|
343 |
+ if (!$user_info['is_admin'] && !shd_allowed_to('admin_helpdesk', 0)) |
|
344 |
+ { |
|
345 |
+ // First, custom field changes only available to admins. |
|
346 |
+ $exclude = array('cf_tktchange_admin', 'cf_rplchange_admin', 'cf_tktchgdef_admin', 'cf_rplchgdef_admin'); |
|
347 |
+ // Next, staff only things |
|
348 |
+ if (!shd_allowed_to('shd_staff', 0)) |
|
349 |
+ { |
|
350 |
+ $exclude[] = 'cf_tktchange_staffadmin'; |
|
351 |
+ $exclude[] = 'cf_rplchange_staffadmin'; |
|
352 |
+ $exclude[] = 'cf_tktchgdef_staffadmin'; |
|
353 |
+ $exclude[] = 'cf_rplchgdef_staffadmin'; |
|
354 |
+ } |
|
355 |
+ else |
|
356 |
+ // Next, user only things (that staff can't see) |
|
357 |
+ { |
|
358 |
+ $exclude[] = 'cf_tktchange_useradmin'; |
|
359 |
+ $exclude[] = 'cf_rplchange_useradmin'; |
|
360 |
+ $exclude[] = 'cf_tktchgdef_useradmin'; |
|
361 |
+ $exclude[] = 'cf_rplchgdef_useradmin'; |
|
362 |
+ } |
|
363 |
+ |
|
364 |
+ // Can they see multiple departments? If not, exclude dept move notices too. |
|
365 |
+ $dept = shd_allowed_to('access_helpdesk', false); |
|
366 |
+ if (count($dept) == 1) |
|
367 |
+ $exclude[] = 'move_dept'; |
|
368 |
+ } |
|
369 |
+ |
|
370 |
+ return $exclude; |
|
371 |
+} |
|
372 |
+ |
|
353 | 373 |
/** |
354 | 374 |
* Perform all the operations required for SimpleDesk to safely start operations inside the admin panel. |
355 | 375 |
* |
356 | 376 |