Show history for group's related threads when isolation is on

This commit is contained in:
Dmitriy Simushev 2015-06-10 08:37:54 +00:00
parent 5363698020
commit 896f090aba

View File

@ -384,18 +384,35 @@ class HistoryController extends AbstractController
'isolated_operator_id' => $operator['operatorid'], 'isolated_operator_id' => $operator['operatorid'],
)); ));
$values = array(); $operators_placeholders = array();
$counter = 0; $counter = 0;
foreach ($operators as $op) { foreach ($operators as $op) {
$values[':_access_op_' . $counter] = $op['operatorid']; $operators_placeholders[':_access_op_' . $counter] = $op['operatorid'];
$counter++; $counter++;
} }
$in_statement = implode(', ', array_keys($values)); $operators_in_statement = implode(', ', array_keys($operators_placeholders));
// Also the operator can view threads for the groups he belongs too.
// These threads include ones that had no related operator but were
// started for a specified group.
$groups = get_all_groups_for_operator($operator);
$groups_placeholders = array();
$counter = 0;
foreach ($groups as $group) {
$groups_placeholders[':_access_grp_' . $counter] = $group['groupid'];
$counter++;
}
$groups_in_statement = implode(', ', array_keys($groups_placeholders));
return array( return array(
'condition' => ' AND {thread}.agentid IN (' . $in_statement . ') ', 'condition' => (' AND ('
'values' => $values, . '{thread}.agentid IN (' . $operators_in_statement . ') '
. 'OR {thread}.groupid IN (' . $groups_in_statement . ')'
. ') '),
'values' => $operators_placeholders + $groups_placeholders,
); );
} }