Do not use global $page array in setup_operator_settings_tabs func

This commit is contained in:
Dmitriy Simushev 2014-01-15 15:23:49 +00:00
parent 3f667e8fa6
commit 4aff809fcb
5 changed files with 22 additions and 15 deletions

View File

@ -15,20 +15,27 @@
* limitations under the License.
*/
function setup_operator_settings_tabs($opId, $active)
{
global $page;
if ($opId) {
$page['tabs'] = array(
getlocal("page_agent.tab.main") => $active != 0 ? (MIBEW_WEB_ROOT . "/operator/operator.php?op=$opId") : "",
getlocal("page_agent.tab.avatar") => $active != 1 ? (MIBEW_WEB_ROOT . "/operator/avatar.php?op=$opId") : "",
getlocal("page_agent.tab.groups") => $active != 2 ? (MIBEW_WEB_ROOT . "/operator/opgroups.php?op=$opId") : "",
getlocal("page_agent.tab.permissions") => $active != 3 ? (MIBEW_WEB_ROOT . "/operator/permissions.php?op=$opId") : ""
/**
* Builds list of operator settings tabs. The keys of the resulting array are
* tabs titles and the values are tabs URLs.
*
* @param int $operator_id ID of the operator whose settings page uis displayed
* @param int $active Number of the active tab
*/
function setup_operator_settings_tabs($operator_id, $active) {
$tabs = array();
if ($operator_id) {
$tabs = array(
getlocal("page_agent.tab.main") => $active != 0 ? (MIBEW_WEB_ROOT . "/operator/operator.php?op=" . $operator_id) : "",
getlocal("page_agent.tab.avatar") => $active != 1 ? (MIBEW_WEB_ROOT . "/operator/avatar.php?op=" . $operator_id) : "",
getlocal("page_agent.tab.groups") => $active != 2 ? (MIBEW_WEB_ROOT . "/operator/opgroups.php?op=" . $operator_id) : "",
getlocal("page_agent.tab.permissions") => $active != 3 ? (MIBEW_WEB_ROOT . "/operator/permissions.php?op=" . $operator_id) : ""
);
} else {
$page['tabs'] = array();
}
return $tabs;
}
?>

View File

@ -102,7 +102,7 @@ $page['title'] = getlocal("page_avatar.title");
$page['menuid'] = ($operator['operatorid'] == $opId) ? "profile" : "operators";
prepare_menu($operator);
setup_operator_settings_tabs($opId, 1);
$page['tabs'] = setup_operator_settings_tabs($opId, 1);
$page_style = new PageStyle(PageStyle::currentStyle());
$page_style->render('avatar');

View File

@ -158,7 +158,7 @@ $page['title'] = getlocal("page_agent.title");
$page['menuid'] = ($opId == $operator['operatorid']) ? "profile" : "operators";
prepare_menu($operator);
setup_operator_settings_tabs($opId, 0);
$page['tabs'] = setup_operator_settings_tabs($opId, 0);
$page_style = new PageStyle(PageStyle::currentStyle());
$page_style->render('agent');

View File

@ -92,7 +92,7 @@ $page['title'] = getlocal("operator.groups.title");
$page['menuid'] = ($page['operatorid'] == $opId) ? "profile" : "operators";
prepare_menu($operator);
setup_operator_settings_tabs($opId, 2);
$page['tabs'] = setup_operator_settings_tabs($opId, 2);
$page_style = new PageStyle(PageStyle::currentStyle());
$page_style->render('operator_groups');

View File

@ -80,7 +80,7 @@ $page['title'] = getlocal("permissions.title");
$page['menuid'] = ($operator['operatorid'] == $opId) ? "profile" : "operators";
prepare_menu($operator);
setup_operator_settings_tabs($opId, 3);
$page['tabs'] = setup_operator_settings_tabs($opId, 3);
$page_style = new PageStyle(PageStyle::currentStyle());
$page_style->render('permissions');