From 95c2e697b33b7ed28b7de6202a10af846dea9250 Mon Sep 17 00:00:00 2001 From: Evgeny Gryaznov Date: Mon, 6 Oct 2008 00:45:25 +0000 Subject: [PATCH] use operator id in management instead of login git-svn-id: https://webim.svn.sourceforge.net/svnroot/webim/trunk@159 c66351dc-e62f-0410-b875-e3a5c0b9693f --- src/messenger/webim/operator/avatar.php | 54 +++++++++-------------- src/messenger/webim/operator/operator.php | 29 ++++++------ src/messenger/webim/view/agent.php | 6 +-- src/messenger/webim/view/agents.php | 2 +- src/messenger/webim/view/avatar.php | 4 +- 5 files changed, 42 insertions(+), 53 deletions(-) diff --git a/src/messenger/webim/operator/avatar.php b/src/messenger/webim/operator/avatar.php index 0cc7d047..3e296b5a 100644 --- a/src/messenger/webim/operator/avatar.php +++ b/src/messenger/webim/operator/avatar.php @@ -17,27 +17,27 @@ require_once('../libs/operator.php'); $operator = check_login(); -$page = array('agentId' => '', 'avatar' => ''); +$opId = verifyparam( "op","/^\d{1,9}$/"); +$page = array('op' => $opId, 'avatar' => ''); $page['operator'] = topage(get_operator_name($operator)); $errors = array(); -if( isset($_POST['agentId']) ) { - $avatar = ''; - $agentId = verifyparam( "agentId", "/^(\d{1,9})?$/", ""); - $op = operator_by_id($agentId); - $login = $op ? $op['vclogin'] : ''; +$op = operator_by_id($opId); - if( !$op ) { - $errors[] = getlocal("no_such_operator"); +if( !$op ) { + $errors[] = getlocal("no_such_operator"); - } else if( isset($_FILES['avatarFile']) && $_FILES['avatarFile']['name']) { +} else if( isset($_POST['op']) ) { + $avatar = $op['vcavatar']; + + if( isset($_FILES['avatarFile']) && $_FILES['avatarFile']['name']) { $valid_types = array("gif","jpg", "png", "tif"); $orig_filename = $_FILES['avatarFile']['name']; $tmp_file_name = $_FILES['avatarFile']['tmp_name']; $ext = substr($orig_filename, 1 + strrpos($orig_filename, ".")); - $new_file_name = "$agentId.$ext"; + $new_file_name = "$opId.$ext"; if ($_FILES['avatarFile']['size'] > $max_uploaded_file_size) { $errors[] = failed_uploading_file($orig_filename, "errors.file.size.exceeded"); @@ -62,40 +62,28 @@ if( isset($_POST['agentId']) ) { if(count($errors) == 0) { update_operator_avatar($op['operatorid'],$avatar); - if ($agentId && $avatar && $_SESSION['operator'] && $operator['operatorid'] == $agentId) { + if ($opId && $avatar && $_SESSION['operator'] && $operator['operatorid'] == $opId) { $_SESSION['operator']['vcavatar'] = $avatar; } - header("Location: $webimroot/operator/avatar.php?op=".topage($op['vclogin'])); + header("Location: $webimroot/operator/avatar.php?op=$opId"); exit; } else { - $page['avatar'] = topage($op ? $op['vcavatar'] : ''); - $page['agentId'] = $agentId; - $page['formlogin'] = topage($login); + $page['avatar'] = topage($op['vcavatar']); } } else { - $login = verifyparam( 'op', "/^[\w_]+$/"); - $op = operator_by_login( $login ); - - if( !$op ) { - $errors[] = getlocal("no_such_operator"); - $page['formlogin'] = topage($login); - } else { - if (isset($_GET['delete']) && $_GET['delete'] == "true") { - update_operator_avatar($op['operatorid'],''); - header("Location: $webimroot/operator/avatar.php?op=".topage($op['vclogin'])); - exit; - } - $page['formlogin'] = topage($op['vclogin']); - $page['agentId'] = topage($op['operatorid']); - $page['avatar'] = topage($op['vcavatar']); + if (isset($_GET['delete']) && $_GET['delete'] == "true") { + update_operator_avatar($op['operatorid'],''); + header("Location: $webimroot/operator/avatar.php?op=$opId"); + exit; } + $page['avatar'] = topage($op['vcavatar']); } -$page['tabs'] = isset($login) ? array( - getlocal("page_agent.tab.main") => "$webimroot/operator/operator.php?op=".topage($login), +$page['tabs'] = array( + getlocal("page_agent.tab.main") => "$webimroot/operator/operator.php?op=$opId", getlocal("page_agent.tab.avatar") => "" -) : array(); +); start_html_output(); require('../view/avatar.php'); diff --git a/src/messenger/webim/operator/operator.php b/src/messenger/webim/operator/operator.php index 4b70a19f..2ac30372 100644 --- a/src/messenger/webim/operator/operator.php +++ b/src/messenger/webim/operator/operator.php @@ -17,11 +17,12 @@ require_once('../libs/operator.php'); $operator = check_login(); -$page = array('agentId' => ''); +$page = array('opid' => ''); $errors = array(); +$opId = ''; if( isset($_POST['login']) && isset($_POST['password']) ) { - $agentId = verifyparam( "agentId", "/^(\d{1,9})?$/", ""); + $opId = verifyparam( "opid", "/^(\d{1,9})?$/", ""); $login = getparam('login'); $password = getparam('password'); $passwordConfirm = getparam('passwordConfirm'); @@ -40,22 +41,22 @@ if( isset($_POST['login']) && isset($_POST['password']) ) { $errors[] = getlocal("page_agent.error.wrong_login"); } - if( !$agentId && !$password ) + if( !$opId && !$password ) $errors[] = no_field("form.field.password"); if( $password != $passwordConfirm ) $errors[] = getlocal("my_settings.error.password_match"); $existing_operator = operator_by_login($login); - if( (!$agentId && $existing_operator) || - ( $agentId && $existing_operator && $agentId != $existing_operator['operatorid']) ) + if( (!$opId && $existing_operator) || + ( $opId && $existing_operator && $opId != $existing_operator['operatorid']) ) $errors[] = getlocal("page_agent.error.duplicate_login"); if( count($errors) == 0 ) { - if (!$agentId) { + if (!$opId) { create_operator($login,$password,$localname,$commonname,""); } else { - update_operator($agentId,$login,$password,$localname,$commonname); + update_operator($opId,$login,$password,$localname,$commonname); } header("Location: $webimroot/operator/operators.php"); exit; @@ -63,29 +64,29 @@ if( isset($_POST['login']) && isset($_POST['password']) ) { $page['formlogin'] = topage($login); $page['formname'] = topage($localname); $page['formcommonname'] = topage($commonname); - $page['agentId'] = topage($agentId); + $page['opid'] = topage($opId); } } else if( isset($_GET['op']) ) { - $login = verifyparam( 'op', "/^[\w_]+$/"); - $op = operator_by_login( $login ); + $opId = verifyparam( 'op', "/^\d{1,9}$/"); + $op = operator_by_id($opId); if( !$op ) { $errors[] = getlocal("no_such_operator"); - $page['formlogin'] = topage($login); + $page['opid'] = topage($opId); } else { $page['formlogin'] = topage($op['vclogin']); $page['formname'] = topage($op['vclocalename']); $page['formcommonname'] = topage($op['vccommonname']); - $page['agentId'] = topage($op['operatorid']); + $page['opid'] = topage($op['operatorid']); } } $page['operator'] = topage(get_operator_name($operator)); -$page['tabs'] = isset($login) ? array( +$page['tabs'] = $opId ? array( getlocal("page_agent.tab.main") => "", - getlocal("page_agent.tab.avatar") => "$webimroot/operator/avatar.php?op=".topage($login) + getlocal("page_agent.tab.avatar") => "$webimroot/operator/avatar.php?op=$opId" ) : array(); start_html_output(); diff --git a/src/messenger/webim/view/agent.php b/src/messenger/webim/view/agent.php index 4edcfe0a..80e415af 100644 --- a/src/messenger/webim/view/agent.php +++ b/src/messenger/webim/view/agent.php @@ -40,10 +40,10 @@
|">|">
- + - +
@@ -99,7 +99,7 @@ - + diff --git a/src/messenger/webim/view/agents.php b/src/messenger/webim/view/agents.php index 568e3f0b..8a4ada09 100644 --- a/src/messenger/webim/view/agents.php +++ b/src/messenger/webim/view/agents.php @@ -79,7 +79,7 @@ - '> + '> diff --git a/src/messenger/webim/view/avatar.php b/src/messenger/webim/view/avatar.php index 14abba01..d704370e 100644 --- a/src/messenger/webim/view/avatar.php +++ b/src/messenger/webim/view/avatar.php @@ -76,7 +76,7 @@
- &delete=true'> + &delete=true'> @@ -89,7 +89,7 @@ - +