From e150bd1d26fcb6858d398eef71e9276941715dde Mon Sep 17 00:00:00 2001 From: Dmitriy Simushev Date: Wed, 5 Aug 2015 14:32:15 +0000 Subject: [PATCH] Mark get_all_groups_for_operator function as deprecated --- .../Controller/CannedMessageController.php | 2 +- .../Mibew/Controller/HistoryController.php | 2 +- .../Controller/Operator/GroupsController.php | 4 +-- src/mibew/libs/groups.php | 34 ++++++++----------- 4 files changed, 18 insertions(+), 24 deletions(-) diff --git a/src/mibew/libs/classes/Mibew/Controller/CannedMessageController.php b/src/mibew/libs/classes/Mibew/Controller/CannedMessageController.php index ecf0bf4e..31faeaab 100644 --- a/src/mibew/libs/classes/Mibew/Controller/CannedMessageController.php +++ b/src/mibew/libs/classes/Mibew/Controller/CannedMessageController.php @@ -72,7 +72,7 @@ class CannedMessageController extends AbstractController // Build list of available groups $all_groups = in_isolation($operator) - ? get_all_groups_for_operator($operator) + ? get_groups_for_operator($operator) : get_all_groups(); $page['groups'] = array(); $page['groups'][] = array( diff --git a/src/mibew/libs/classes/Mibew/Controller/HistoryController.php b/src/mibew/libs/classes/Mibew/Controller/HistoryController.php index 8a348a25..ab4e226a 100644 --- a/src/mibew/libs/classes/Mibew/Controller/HistoryController.php +++ b/src/mibew/libs/classes/Mibew/Controller/HistoryController.php @@ -404,7 +404,7 @@ class HistoryController extends AbstractController // 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 = get_groups_for_operator($operator); $groups_placeholders = array(); $counter = 0; diff --git a/src/mibew/libs/classes/Mibew/Controller/Operator/GroupsController.php b/src/mibew/libs/classes/Mibew/Controller/Operator/GroupsController.php index c969c118..b16dda73 100644 --- a/src/mibew/libs/classes/Mibew/Controller/Operator/GroupsController.php +++ b/src/mibew/libs/classes/Mibew/Controller/Operator/GroupsController.php @@ -53,7 +53,7 @@ class GroupsController extends AbstractController ); $groups = $operator_in_isolation - ? get_all_groups_for_operator($operator) + ? get_groups_for_operator($operator) : get_all_groups(); $can_modify = is_capable(CAN_ADMINISTRATE, $operator); @@ -114,7 +114,7 @@ class GroupsController extends AbstractController // Get all groups that are available for the target operator. $groups = $operator_in_isolation - ? get_all_groups_for_operator($operator) + ? get_groups_for_operator($operator) : get_all_groups(); // Build list of operator's new groups. diff --git a/src/mibew/libs/groups.php b/src/mibew/libs/groups.php index ea8a67b1..1cf1bdf4 100644 --- a/src/mibew/libs/groups.php +++ b/src/mibew/libs/groups.php @@ -514,27 +514,21 @@ function get_all_groups() return get_sorted_child_groups_($groups); } +/** + * Retrieves list of groups the operator can see. + * + * This function keeps in mind groups isolation. + * + * @deprecated since 2.1.1. Use {@link get_groups_for_operator()} function + * instead. + * @param array $operator List of operator's fields. See + * {@link operator_by_id()} for details of its keys. + * @return array List of group arrays. See {@link group_by_id()} for details + * about their structure. + */ function get_all_groups_for_operator($operator) { - $db = Database::getInstance(); - $query = "SELECT DISTINCT g.groupid AS groupid, g.parent, g.vclocalname, g.vclocaldescription " - . "FROM {opgroup} g, " - . "(SELECT {opgroup}.groupid, {opgroup}.parent FROM {opgroup}, {operatortoopgroup} " - . "WHERE {opgroup}.groupid = {operatortoopgroup}.groupid " - . "AND {operatortoopgroup}.operatorid = ?) i " - . "WHERE g.groupid = i.parent " - . "OR g.parent = i.groupid " - . "OR (g.parent = i.parent AND g.parent IS NOT NULL) " - . "OR g.groupid = i.groupid " - . "ORDER BY vclocalname"; - - $groups = $db->query( - $query, - array($operator['operatorid']), - array('return_rows' => Database::RETURN_ALL_ROWS) - ); - - return get_sorted_child_groups_($groups); + return get_groups_for_operator($operator, false); } function get_sorted_child_groups_( @@ -643,7 +637,7 @@ function get_groups($check_away) return get_groups_($check_away, null); } -function get_groups_for_operator($operator, $check_away) +function get_groups_for_operator($operator, $check_away = false) { return get_groups_($check_away, $operator); }