mirror of
https://github.com/Mibew/mibew.git
synced 2025-02-14 19:35:46 +03:00
Deny access to history for operators without CAN_VIEWTHREADS permission
This commit is contained in:
parent
b340206d3a
commit
5009f51342
@ -95,6 +95,19 @@ class HistoryController extends AbstractController
|
|||||||
$search_conditions[] = "({thread}.remote LIKE :query)";
|
$search_conditions[] = "({thread}.remote LIKE :query)";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Build access condition:
|
||||||
|
$operator = $this->getOperator();
|
||||||
|
$access_condition = '';
|
||||||
|
// Operators without "view threads" permission can view only their
|
||||||
|
// own history. Administrators can view anything.
|
||||||
|
$can_view_others = is_capable(CAN_VIEWTHREADS, $operator)
|
||||||
|
|| is_capable(CAN_ADMINISTRATE, $operator);
|
||||||
|
|
||||||
|
if (!$can_view_others) {
|
||||||
|
$access_condition = ' AND {thread}.agentid = :operator_id ';
|
||||||
|
$values[':operator_id'] = $operator['operatorid'];
|
||||||
|
}
|
||||||
|
|
||||||
// Load threads
|
// Load threads
|
||||||
list($threads_count) = $db->query(
|
list($threads_count) = $db->query(
|
||||||
("SELECT COUNT(DISTINCT {thread}.dtmcreated) "
|
("SELECT COUNT(DISTINCT {thread}.dtmcreated) "
|
||||||
@ -102,7 +115,8 @@ class HistoryController extends AbstractController
|
|||||||
. "WHERE {message}.threadid = {thread}.threadid "
|
. "WHERE {message}.threadid = {thread}.threadid "
|
||||||
. "AND ({thread}.invitationstate = :invitation_accepted "
|
. "AND ({thread}.invitationstate = :invitation_accepted "
|
||||||
. "OR {thread}.invitationstate = :invitation_not_invited) "
|
. "OR {thread}.invitationstate = :invitation_not_invited) "
|
||||||
. "AND (" . implode(' OR ', $search_conditions) . ")"),
|
. "AND (" . implode(' OR ', $search_conditions) . ") "
|
||||||
|
. $access_condition),
|
||||||
$values,
|
$values,
|
||||||
array(
|
array(
|
||||||
'return_rows' => Database::RETURN_ONE_ROW,
|
'return_rows' => Database::RETURN_ONE_ROW,
|
||||||
@ -125,6 +139,7 @@ class HistoryController extends AbstractController
|
|||||||
. "AND ({thread}.invitationstate = :invitation_accepted "
|
. "AND ({thread}.invitationstate = :invitation_accepted "
|
||||||
. "OR {thread}.invitationstate = :invitation_not_invited) "
|
. "OR {thread}.invitationstate = :invitation_not_invited) "
|
||||||
. "AND (" . implode(' OR ', $search_conditions) . ") "
|
. "AND (" . implode(' OR ', $search_conditions) . ") "
|
||||||
|
. $access_condition
|
||||||
. "ORDER BY {thread}.dtmcreated DESC "
|
. "ORDER BY {thread}.dtmcreated DESC "
|
||||||
. "LIMIT " . $limit_start . ", " . $limit_end),
|
. "LIMIT " . $limit_start . ", " . $limit_end),
|
||||||
$values,
|
$values,
|
||||||
|
Loading…
Reference in New Issue
Block a user