mirror of
https://github.com/Mibew/mibew.git
synced 2025-05-12 06:43:08 +03:00
Fix history for operator without colleagues whose threads he can view
Fixes #132
This commit is contained in:
parent
fcd3cacfbc
commit
9d81661cfe
@ -377,6 +377,9 @@ class HistoryController extends AbstractController
|
|||||||
|
|
||||||
// Operators who have "view threads" permission can be in isolation.
|
// Operators who have "view threads" permission can be in isolation.
|
||||||
if (in_isolation($operator)) {
|
if (in_isolation($operator)) {
|
||||||
|
$query_conditions = array();
|
||||||
|
$query_values = array();
|
||||||
|
|
||||||
// This is not the best way of getting operators from adjacent
|
// This is not the best way of getting operators from adjacent
|
||||||
// groups, but it's the only way that does not break encapsulation
|
// groups, but it's the only way that does not break encapsulation
|
||||||
// of operators storage.
|
// of operators storage.
|
||||||
@ -391,7 +394,12 @@ class HistoryController extends AbstractController
|
|||||||
$counter++;
|
$counter++;
|
||||||
}
|
}
|
||||||
|
|
||||||
$operators_in_statement = implode(', ', array_keys($operators_placeholders));
|
if (count($operators_placeholders) > 0) {
|
||||||
|
// Make sure at least one operator was loaded.
|
||||||
|
$operators_in_statement = implode(', ', array_keys($operators_placeholders));
|
||||||
|
$query_conditions[] = '{thread}.agentid IN (' . $operators_in_statement . ')';
|
||||||
|
$query_values = $operators_placeholders;
|
||||||
|
}
|
||||||
|
|
||||||
// Also the operator can view threads for the groups he belongs too.
|
// Also the operator can view threads for the groups he belongs too.
|
||||||
// These threads include ones that had no related operator but were
|
// These threads include ones that had no related operator but were
|
||||||
@ -405,14 +413,28 @@ class HistoryController extends AbstractController
|
|||||||
$counter++;
|
$counter++;
|
||||||
}
|
}
|
||||||
|
|
||||||
$groups_in_statement = implode(', ', array_keys($groups_placeholders));
|
if (count($groups_placeholders) > 0) {
|
||||||
|
// Make sure at least one group was loaded.
|
||||||
|
$groups_in_statement = implode(', ', array_keys($groups_placeholders));
|
||||||
|
$query_conditions[] = '{thread}.groupid IN (' . $groups_in_statement . ')';
|
||||||
|
$query_values += $groups_placeholders;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($query_conditions) == 0) {
|
||||||
|
// It seems that the does not belong to any groups or there is
|
||||||
|
// just no another operators in adjuscent groups. Thus the
|
||||||
|
// operator can view only his own threads.
|
||||||
|
return array(
|
||||||
|
'condition' => ' AND {thread}.agentid = :operator_id ',
|
||||||
|
'values' => array(
|
||||||
|
':operator_id' => $operator['operatorid'],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'condition' => (' AND ('
|
'condition' => ' AND (' . implode(' OR ', $query_conditions) . ') ',
|
||||||
. '{thread}.agentid IN (' . $operators_in_statement . ') '
|
'values' => $query_values,
|
||||||
. 'OR {thread}.groupid IN (' . $groups_in_statement . ')'
|
|
||||||
. ') '),
|
|
||||||
'values' => $operators_placeholders + $groups_placeholders,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user