right menu depends on agent rights and features

git-svn-id: https://webim.svn.sourceforge.net/svnroot/webim/trunk@411 c66351dc-e62f-0410-b875-e3a5c0b9693f
This commit is contained in:
Evgeny Gryaznov 2009-03-16 01:20:04 +00:00
parent eb058409e8
commit 5a82434450
19 changed files with 39 additions and 21 deletions

View File

@ -214,4 +214,14 @@ function is_capable($perm,$operator) {
return $perm >= 0 && $perm < 32 && ($permissions & (1 << $perm)) != 0;
}
function prepare_menu($operator,$hasright=true) {
global $page, $settings, $can_administrate;
$page['operator'] = topage(get_operator_name($operator));
if($hasright) {
loadsettings();
$page['showban'] = $settings['enableban'] == "1";
$page['showadmin'] = is_capable($can_administrate, $operator);
}
}
?>

View File

@ -19,7 +19,6 @@ $operator = check_login();
$opId = verifyparam( "op","/^\d{1,9}$/");
$page = array('op' => $opId, 'avatar' => '');
$page['operator'] = topage(get_operator_name($operator));
$errors = array();
$op = operator_by_id($opId);
@ -89,6 +88,7 @@ $page['tabs'] = array(
);
$page['currentop'] = topage(get_operator_name($op))." (".$op['vclogin'].")";
prepare_menu($operator);
start_html_output();
require('../view/avatar.php');
?>

View File

@ -18,7 +18,7 @@ require_once('../libs/operator.php');
require_once('../libs/pagination.php');
$operator = check_login();
$page = array('banId' => '', 'operator' => topage(get_operator_name($operator)) );
$page = array('banId' => '');
$page['saved'] = false;
$page['thread'] = '';
$page['threadid'] = '';
@ -111,6 +111,7 @@ if( isset($_POST['address']) ) {
}
}
prepare_menu($operator, false);
start_html_output();
require('../view/ban.php');
exit;

View File

@ -19,7 +19,6 @@ require_once('../libs/pagination.php');
$operator = check_login();
$page = array();
$page['operator'] = topage(get_operator_name($operator));
$errors = array();
$link = connect();
@ -51,6 +50,7 @@ mysql_close($link);
setup_pagination($blockedList);
prepare_menu($operator);
start_html_output();
require('../view/blocked_visitors.php');
exit;

View File

@ -38,12 +38,12 @@ if (isset($_POST['sent'])) {
exit;
}
$page['operator'] = topage(get_operator_name($operator));
$page['stored'] = isset($_GET['stored']);
foreach($options as $opt) {
$page["form$opt"] = $params[$opt] == "1";
}
prepare_menu($operator);
setup_settings_tabs(1);
start_html_output();
require('../view/features.php');

View File

@ -68,7 +68,6 @@ $size = get_gifimage_size($file);
$message = get_image(get_app_location($showhost,$forcesecure)."/button.php?image=$image&amp;lang=$lang",$size[0],$size[1]);
$page = array();
$page['operator'] = topage(get_operator_name($operator));
$page['buttonCode'] = generate_button("",$lang,$style,$message,$showhost,$forcesecure);
$page['availableImages'] = array_keys($imageLocales);
$page['availableLocales'] = $image_locales;
@ -80,6 +79,7 @@ $page['formlang'] = $lang;
$page['formhostname'] = $showhost;
$page['formsecure'] = $forcesecure;
prepare_menu($operator);
start_html_output();
require('../view/gen_button.php');
?>

View File

@ -21,7 +21,7 @@ require_once('../libs/pagination.php');
$operator = check_login();
loadsettings();
$page = array( 'operator' => topage(get_operator_name($operator)) );
$page = array();
$query = isset($_GET['q']) ? myiconv(getoutputenc(), $webim_encoding, $_GET['q']) : false;
if($query !== false) {
@ -53,6 +53,7 @@ if($query !== false) {
setup_empty_pagination();
}
prepare_menu($operator);
start_html_output();
require('../view/thread_search.php');
?>

View File

@ -19,15 +19,13 @@ $operator = check_login();
loadsettings();
$page = array(
'operator' => topage(get_operator_name($operator)),
'version' => $version,
'localeLinks' => get_locale_links("$webimroot/operator/index.php"),
'showban' => $settings['enableban'] == "1",
'showadmin' => is_capable($can_administrate, $operator),
'needUpdate' => $settings['dbversion'] != $dbversion,
'updateWizard' => "$webimroot/install/",
);
prepare_menu($operator);
start_html_output();
require('../view/menu.php');
?>

View File

@ -84,14 +84,13 @@ if( isset($_POST['login']) && isset($_POST['password']) ) {
}
}
$page['operator'] = topage(get_operator_name($operator));
$page['tabs'] = $opId ? array(
getlocal("page_agent.tab.main") => "",
getlocal("page_agent.tab.avatar") => "$webimroot/operator/avatar.php?op=$opId",
getlocal("page_agent.tab.permissions") => "$webimroot/operator/permissions.php?op=$opId"
) : array();
prepare_menu($operator);
start_html_output();
require('../view/agent.php');
?>

View File

@ -19,8 +19,8 @@ $operator = check_login();
$page = array();
$page['allowedAgents'] = get_operators();
$page['operator'] = topage(get_operator_name($operator));
prepare_menu($operator);
start_html_output();
require('../view/agents.php');
?>

View File

@ -27,7 +27,6 @@ function update_operator_permissions($operatorid,$newvalue) {
$opId = verifyparam( "op","/^\d{1,9}$/");
$page = array('op' => $opId);
$page['operator'] = topage(get_operator_name($operator));
$errors = array();
$op = operator_by_id($opId);
@ -75,6 +74,7 @@ foreach($permission_ids as $perm => $id) {
}
}
prepare_menu($operator);
start_html_output();
require('../view/permissions.php');
?>

View File

@ -109,7 +109,6 @@ $page['availableTemplates'] = array(
"agentchat", "agentrochat",
"all");
$page['operator'] = topage(get_operator_name($operator));
$page['showlink'] = "$webimroot/operator/preview.php?preview=$preview&amp;".($showerrors?"showerr=on&amp;":"")."show=";
$page['previewList'] = array();
@ -119,6 +118,7 @@ foreach($templateList as $tpl) {
}
}
prepare_menu($operator);
start_html_output();
setup_settings_tabs(2);
require('../view/preview.php');

View File

@ -79,7 +79,6 @@ if (isset($_POST['email']) && isset($_POST['title']) && isset($_POST['logo'])) {
}
}
$page['operator'] = topage(get_operator_name($operator));
$page['formemail'] = topage($params['email']);
$page['formtitle'] = topage($params['title']);
$page['formlogo'] = topage($params['logo']);
@ -92,6 +91,7 @@ $page['formchattitle'] = topage($params['chattitle']);
$page['availableStyles'] = $stylelist;
$page['stored'] = isset($_GET['stored']);
prepare_menu($operator);
setup_settings_tabs(0);
start_html_output();
require('../view/settings.php');

View File

@ -19,7 +19,7 @@ require_once('../libs/userinfo.php');
$operator = check_login();
$page = array( 'operator' => topage(get_operator_name($operator)) );
$page = array();
if( isset($_GET['threadid'])) {
$threadid = verifyparam( "threadid", "/^(\d{1,9})?$/", "");
@ -28,6 +28,7 @@ if( isset($_GET['threadid'])) {
$page['thread'] = thread_by_id($threadid);
}
prepare_menu($operator, false);
start_html_output();
require('../view/thread_log.php');
?>

View File

@ -108,7 +108,6 @@ $lang2 = $messages[$target];
$errors = array();
$page = array(
'operator' => topage(get_operator_name($operator)),
'lang1' => $source,
'lang2' => $target,
'title1' => isset($lang1["localeid"]) ? $lang1["localeid"] : $source,
@ -131,6 +130,7 @@ if($stringid) {
save_message($target, $stringid, $translation);
$page['saved'] = true;
prepare_menu($operator, false);
start_html_output();
require('../view/translate.php');
exit;
@ -142,6 +142,7 @@ if($stringid) {
$page['target'] = $target;
$page['formoriginal'] = isset($lang1[$stringid]) ? htmlspecialchars($lang1[$stringid]) : "<b><unknown></b>";
$page['formtranslation'] = htmlspecialchars($translation);
prepare_menu($operator, false);
start_html_output();
require('../view/translate.php');
exit;
@ -195,6 +196,7 @@ $page['showOptions'] = array(
array("id" => "s3", "name" => getlocal("translate.show.foradmin")),
);
$page['formshow'] = $show;
prepare_menu($operator);
start_html_output();
require('../view/translatelist.php');
?>

View File

@ -20,12 +20,12 @@ $operator = check_login();
$errors = array();
$page = array(
'operator' => topage(get_operator_name($operator)),
'localizations' => get_available_locales(),
'phpVersion' => phpversion(),
'version' => $version,
);
prepare_menu($operator);
setup_settings_tabs(3);
start_html_output();
require('../view/updates.php');

View File

@ -21,7 +21,7 @@ require_once('../libs/pagination.php');
$operator = check_login();
loadsettings();
$page = array( 'operator' => topage(get_operator_name($operator)) );
$page = array();
$userid = "";
if( isset($_GET['userid'])) {
@ -53,6 +53,7 @@ function threads_by_userid($userid) {
$found = threads_by_userid($userid);
prepare_menu($operator);
setup_pagination($found,6);
start_html_output();
require('../view/userhistory.php');

View File

@ -19,8 +19,9 @@ $operator = check_login();
notify_operator_alive($operator['operatorid']);
$page = array( 'operator' => topage(get_operator_name($operator)) );
$page = array();
prepare_menu($operator);
start_html_output();
require('../view/pending_users.php');
?>

View File

@ -8,16 +8,19 @@ function menuli($name) {
}
function tpl_menu() { global $page, $webimroot, $errors;
if(isset($page) && isset($page['operator'])) { ?>
if(isset($page['operator'])) { ?>
<li>
<h2><?php echo getlocal('right.main') ?></h2>
<ul class="submenu">
<li<?php menuli("main")?>><a href='<?php echo $webimroot ?>/operator/index.php'><?php echo getlocal('topMenu.main') ?></a></li>
<li<?php menuli("users")?>><a href='<?php echo $webimroot ?>/operator/users.php'><?php echo getlocal('topMenu.users') ?></a></li>
<li<?php menuli("history")?>><a href='<?php echo $webimroot ?>/operator/history.php'><?php echo getlocal('page_analysis.search.title') ?></a></li>
<?php if(isset($page['showban']) && $page['showban']) { ?>
<li<?php menuli("blocked")?>><a href='<?php echo $webimroot ?>/operator/blocked.php'><?php echo getlocal('menu.blocked') ?></a></li>
<?php } ?>
</ul>
</li>
<?php if(isset($page['showadmin']) && $page['showadmin']) { ?>
<li>
<h2><?php echo getlocal('right.administration') ?></h2>
<ul class="submenu">
@ -28,6 +31,7 @@ function tpl_menu() { global $page, $webimroot, $errors;
<li<?php menuli("translate")?>><a href='<?php echo $webimroot ?>/operator/translate.php'><?php echo getlocal('menu.translate') ?></a></li>
</ul>
</li>
<?php } ?>
<li>
<h2><?php echo getlocal('right.other') ?></h2>
<ul class="submenu">