2007-10-10 19:15:47 +04:00
|
|
|
<?php
|
|
|
|
/*
|
2009-06-04 02:44:32 +04:00
|
|
|
* This file is part of Mibew Messenger project.
|
2009-08-04 20:30:39 +04:00
|
|
|
*
|
2009-06-04 02:44:32 +04:00
|
|
|
* Copyright (c) 2005-2009 Mibew Messenger Community
|
2009-08-04 19:03:27 +04:00
|
|
|
* All rights reserved. The contents of this file are subject to the terms of
|
|
|
|
* the Eclipse Public License v1.0 which accompanies this distribution, and
|
|
|
|
* is available at http://www.eclipse.org/legal/epl-v10.html
|
2009-08-04 20:30:39 +04:00
|
|
|
*
|
2009-08-04 17:38:37 +04:00
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* the GNU General Public License Version 2 or later (the "GPL"), in which case
|
|
|
|
* the provisions of the GPL are applicable instead of those above. If you wish
|
|
|
|
* to allow use of your version of this file only under the terms of the GPL, and
|
|
|
|
* not to allow others to use your version of this file under the terms of the
|
|
|
|
* EPL, indicate your decision by deleting the provisions above and replace them
|
|
|
|
* with the notice and other provisions required by the GPL.
|
2009-08-04 20:30:39 +04:00
|
|
|
*
|
2007-10-10 19:15:47 +04:00
|
|
|
* Contributors:
|
|
|
|
* Evgeny Gryaznov - initial API and implementation
|
|
|
|
*/
|
|
|
|
|
2008-06-05 01:36:54 +04:00
|
|
|
require_once('../libs/common.php');
|
|
|
|
require_once('../libs/operator.php');
|
2009-03-23 00:22:51 +03:00
|
|
|
require_once('../libs/operator_settings.php');
|
2007-10-10 19:15:47 +04:00
|
|
|
|
|
|
|
$operator = check_login();
|
|
|
|
|
2008-10-06 04:45:25 +04:00
|
|
|
$page = array('opid' => '');
|
2007-10-10 19:15:47 +04:00
|
|
|
$errors = array();
|
2008-10-06 04:45:25 +04:00
|
|
|
$opId = '';
|
2007-10-10 19:15:47 +04:00
|
|
|
|
|
|
|
if( isset($_POST['login']) && isset($_POST['password']) ) {
|
2008-10-06 04:45:25 +04:00
|
|
|
$opId = verifyparam( "opid", "/^(\d{1,9})?$/", "");
|
2007-10-10 19:15:47 +04:00
|
|
|
$login = getparam('login');
|
|
|
|
$password = getparam('password');
|
|
|
|
$passwordConfirm = getparam('passwordConfirm');
|
2008-05-06 01:08:57 +04:00
|
|
|
$localname = getparam('name');
|
2007-10-10 19:15:47 +04:00
|
|
|
$commonname = getparam('commonname');
|
|
|
|
|
2008-05-06 01:08:57 +04:00
|
|
|
if( !$localname )
|
2007-10-10 19:15:47 +04:00
|
|
|
$errors[] = no_field("form.field.agent_name");
|
|
|
|
|
|
|
|
if( !$commonname )
|
|
|
|
$errors[] = no_field("form.field.agent_commonname");
|
|
|
|
|
2008-05-07 01:30:15 +04:00
|
|
|
if( !$login ) {
|
2007-10-10 19:15:47 +04:00
|
|
|
$errors[] = no_field("form.field.login");
|
2009-06-05 15:47:04 +04:00
|
|
|
} else if( !preg_match( "/^[\w_\.]+$/",$login) ) {
|
2008-05-07 01:30:15 +04:00
|
|
|
$errors[] = getlocal("page_agent.error.wrong_login");
|
|
|
|
}
|
2007-10-10 19:15:47 +04:00
|
|
|
|
2008-10-06 04:45:25 +04:00
|
|
|
if( !$opId && !$password )
|
2007-10-10 19:15:47 +04:00
|
|
|
$errors[] = no_field("form.field.password");
|
|
|
|
|
|
|
|
if( $password != $passwordConfirm )
|
2008-05-06 15:14:48 +04:00
|
|
|
$errors[] = getlocal("my_settings.error.password_match");
|
2007-10-10 19:15:47 +04:00
|
|
|
|
2008-05-06 01:08:57 +04:00
|
|
|
$existing_operator = operator_by_login($login);
|
2008-10-06 04:45:25 +04:00
|
|
|
if( (!$opId && $existing_operator) ||
|
|
|
|
( $opId && $existing_operator && $opId != $existing_operator['operatorid']) )
|
2008-05-06 15:14:48 +04:00
|
|
|
$errors[] = getlocal("page_agent.error.duplicate_login");
|
2009-04-10 18:12:57 +04:00
|
|
|
|
2009-05-31 20:13:22 +04:00
|
|
|
$canmodify = ($opId == $operator['operatorid'] && is_capable($can_modifyprofile, $operator))
|
|
|
|
|| is_capable($can_administrate, $operator);
|
|
|
|
if(!$canmodify) {
|
2009-04-10 18:12:57 +04:00
|
|
|
$errors[] = getlocal('page_agent.cannot_modify');
|
|
|
|
}
|
2009-05-31 20:13:22 +04:00
|
|
|
|
2007-10-10 19:15:47 +04:00
|
|
|
if( count($errors) == 0 ) {
|
2008-10-06 04:45:25 +04:00
|
|
|
if (!$opId) {
|
2008-12-09 02:47:40 +03:00
|
|
|
$newop = create_operator($login,$password,$localname,$commonname,"");
|
|
|
|
header("Location: $webimroot/operator/avatar.php?op=".$newop['operatorid']);
|
|
|
|
exit;
|
2007-10-10 19:15:47 +04:00
|
|
|
} else {
|
2008-10-06 04:45:25 +04:00
|
|
|
update_operator($opId,$login,$password,$localname,$commonname);
|
2009-03-25 02:34:57 +03:00
|
|
|
header("Location: $webimroot/operator/operator.php?op=$opId&stored");
|
2008-12-09 02:47:40 +03:00
|
|
|
exit;
|
2007-10-10 19:15:47 +04:00
|
|
|
}
|
|
|
|
} else {
|
2008-05-06 15:14:48 +04:00
|
|
|
$page['formlogin'] = topage($login);
|
|
|
|
$page['formname'] = topage($localname);
|
|
|
|
$page['formcommonname'] = topage($commonname);
|
2008-10-06 04:45:25 +04:00
|
|
|
$page['opid'] = topage($opId);
|
2007-10-10 19:15:47 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
} else if( isset($_GET['op']) ) {
|
2008-10-06 04:45:25 +04:00
|
|
|
$opId = verifyparam( 'op', "/^\d{1,9}$/");
|
|
|
|
$op = operator_by_id($opId);
|
2007-10-10 19:15:47 +04:00
|
|
|
|
|
|
|
if( !$op ) {
|
2008-05-06 15:14:48 +04:00
|
|
|
$errors[] = getlocal("no_such_operator");
|
2008-10-06 04:45:25 +04:00
|
|
|
$page['opid'] = topage($opId);
|
2007-10-10 19:15:47 +04:00
|
|
|
} else {
|
2008-05-06 15:14:48 +04:00
|
|
|
$page['formlogin'] = topage($op['vclogin']);
|
|
|
|
$page['formname'] = topage($op['vclocalename']);
|
|
|
|
$page['formcommonname'] = topage($op['vccommonname']);
|
2008-10-06 04:45:25 +04:00
|
|
|
$page['opid'] = topage($op['operatorid']);
|
2007-10-10 19:15:47 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-31 20:13:22 +04:00
|
|
|
if(!$opId && !is_capable($can_administrate, $operator)) {
|
|
|
|
$errors[] = "You are not allowed to create operators";
|
|
|
|
}
|
|
|
|
|
|
|
|
$canmodify = ($opId == $operator['operatorid'] && is_capable($can_modifyprofile, $operator))
|
|
|
|
|| is_capable($can_administrate, $operator);
|
|
|
|
|
2009-03-25 02:34:57 +03:00
|
|
|
$page['stored'] = isset($_GET['stored']);
|
2009-05-31 20:13:22 +04:00
|
|
|
$page['canmodify'] = $canmodify ? "1" : "";
|
|
|
|
|
2009-03-16 04:20:04 +03:00
|
|
|
prepare_menu($operator);
|
2009-03-23 00:22:51 +03:00
|
|
|
setup_operator_settings_tabs($opId,0);
|
2007-10-10 19:15:47 +04:00
|
|
|
start_html_output();
|
|
|
|
require('../view/agent.php');
|
2007-05-10 21:31:10 +04:00
|
|
|
?>
|