Skip to content
Permalink
Browse files

Issue: Tickets Visibility

This commit ensures that an Agent with the 'See all tickets in search results, regardless of access' permission checked can see all Tickets in a search or a saved search, but does NOT see all Tickets within queues.
  • Loading branch information...
aydreeihn committed Apr 23, 2019
1 parent f6823c8 commit 60aa7b876f8df5a83e0c650f93eb190df8611192
Showing with 22 additions and 7 deletions.
  1. +1 −1 include/class.search.php
  2. +16 −5 include/class.staff.php
  3. +5 −1 include/staff/templates/queue-tickets.tmpl.php
@@ -900,7 +900,7 @@ static function counts($agent, $cached=true, $criteria=array()) {
$counts = array();
$query = Ticket::objects();
// Apply tickets visibility for the agent
$query = $agent->applyVisibility($query);
$query = $agent->applyVisibility($query, true);
// Aggregate constraints
foreach ($queues as $queue) {
$Q = $queue->getBasicQuery();
@@ -584,7 +584,7 @@ function getTeams() {
return $this->_teams;
}
function getTicketsVisibility() {
function getTicketsVisibility($exclude_archived=false) {
// -- Open and assigned to me
$assigned = Q::any(array(
@@ -607,15 +607,26 @@ function getTicketsVisibility() {
// -- Routed to a department of mine
if (($depts=$this->getDepts()) && count($depts)) {
$visibility->add(array('dept_id__in' => $depts));
$visibility->add(array('thread__referrals__dept__id__in' => $depts));
$in_dept = Q::any(array(
'dept_id__in' => $depts,
'thread__referrals__dept__id__in' => $depts,
));
if ($exclude_archived) {
$in_dept = Q::all(array(
'status__state__in' => ['open', 'closed'],
$in_dept,
));
}
$visibility->add($in_dept);
}
return $visibility;
}
function applyVisibility($query) {
return $query->filter($this->getTicketsVisibility());
function applyVisibility($query, $exclude_archived=false) {
return $query->filter($this->getTicketsVisibility($exclude_archived));
}
/* stats */
@@ -6,7 +6,11 @@
// Impose visibility constraints
// ------------------------------------------------------------
if (!$queue->ignoreVisibilityConstraints($thisstaff))
//filter if limited visibility or if unlimited visibility and in a queue
$ignoreVisibility = $queue->ignoreVisibilityConstraints($thisstaff);
if (!$ignoreVisibility || //limited visibility
($ignoreVisibility && ($queue->isAQueue() || $queue->isASubQueue())) //unlimited visibility + not a search
)
$tickets->filter($thisstaff->getTicketsVisibility());
// Make sure the cdata materialized view is available

0 comments on commit 60aa7b8

Please sign in to comment.
You can’t perform that action at this time.