From 4670851505d1e55ee4920d7408b8a40766f8a2ba Mon Sep 17 00:00:00 2001 From: Dmitriy Simushev Date: Mon, 28 Jul 2014 09:32:15 +0000 Subject: [PATCH] Localize permission descriptions Fixes #50 --- src/mibew/libs/operator.php | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/mibew/libs/operator.php b/src/mibew/libs/operator.php index 98d08794..4aa87abd 100644 --- a/src/mibew/libs/operator.php +++ b/src/mibew/libs/operator.php @@ -52,7 +52,7 @@ define('CAN_MODIFYPROFILE', 3); /** * Map numerical permissions ids onto string names. - * @return array Associativa array whose keys are numerical permission ids and + * @return array Associative array whose keys are numerical permission ids and * values are string permission names. */ function permission_ids() @@ -65,6 +65,24 @@ function permission_ids() ); } +/** + * Map numerical permissions ids onto its descriptions. + * + * The descriptions are NOT localized. + * + * @return array Array whose keys are numerical permission ids and values are + * permission descriptions. + */ +function permission_descriptions() +{ + return array( + CAN_ADMINISTRATE => 'System administration: settings, operators management, button generation', + CAN_TAKEOVER => 'Take over chat thread', + CAN_VIEWTHREADS => 'View another operator\'s chat thread', + CAN_MODIFYPROFILE => 'Ability to modify profile', + ); +} + /** * Set new permissions to operator * @param int $operator_id Operator ID @@ -606,10 +624,11 @@ function get_permission_list() static $permission_list = array(); if (count($permission_list) == 0) { - foreach (permission_ids() as $perm_id) { + $descriptions = permission_descriptions(); + foreach (permission_ids() as $perm_code => $perm_id) { $permission_list[] = array( 'id' => $perm_id, - 'descr' => getlocal("permission.$perm_id"), + 'descr' => getlocal($descriptions[$perm_code]), ); } }