2008-10-06 03:46:54 +04:00
|
|
|
<?php
|
|
|
|
/*
|
2009-06-04 02:44:32 +04:00
|
|
|
* This file is part of Mibew Messenger project.
|
2008-10-06 03:46:54 +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
|
2008-10-06 03:46:54 +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.
|
|
|
|
*
|
2008-10-06 03:46:54 +04:00
|
|
|
* Contributors:
|
|
|
|
* Evgeny Gryaznov - initial API and implementation
|
|
|
|
*/
|
|
|
|
|
|
|
|
require_once('../libs/common.php');
|
|
|
|
require_once('../libs/operator.php');
|
2009-03-23 00:22:51 +03:00
|
|
|
require_once('../libs/operator_settings.php');
|
2008-10-06 03:46:54 +04:00
|
|
|
|
|
|
|
$operator = check_login();
|
|
|
|
|
2008-10-06 04:45:25 +04:00
|
|
|
$opId = verifyparam( "op","/^\d{1,9}$/");
|
2009-04-10 18:12:57 +04:00
|
|
|
$page = array('opid' => $opId, 'avatar' => '');
|
2008-10-06 03:46:54 +04:00
|
|
|
$errors = array();
|
|
|
|
|
2009-05-31 20:13:22 +04:00
|
|
|
$canmodify = ($opId == $operator['operatorid'] && is_capable($can_modifyprofile, $operator))
|
|
|
|
|| is_capable($can_administrate, $operator);
|
|
|
|
|
2008-10-06 04:45:25 +04:00
|
|
|
$op = operator_by_id($opId);
|
2008-10-06 03:46:54 +04:00
|
|
|
|
2008-10-06 04:45:25 +04:00
|
|
|
if( !$op ) {
|
|
|
|
$errors[] = getlocal("no_such_operator");
|
2008-10-06 03:46:54 +04:00
|
|
|
|
2008-10-06 04:45:25 +04:00
|
|
|
} else if( isset($_POST['op']) ) {
|
|
|
|
$avatar = $op['vcavatar'];
|
|
|
|
|
2009-05-31 20:13:22 +04:00
|
|
|
if(!$canmodify) {
|
2009-04-10 18:12:57 +04:00
|
|
|
$errors[] = getlocal('page_agent.cannot_modify');
|
|
|
|
|
|
|
|
} else if( isset($_FILES['avatarFile']) && $_FILES['avatarFile']['name']) {
|
2008-10-06 03:46:54 +04:00
|
|
|
$valid_types = array("gif","jpg", "png", "tif");
|
|
|
|
|
|
|
|
$orig_filename = $_FILES['avatarFile']['name'];
|
|
|
|
$tmp_file_name = $_FILES['avatarFile']['tmp_name'];
|
|
|
|
|
2009-01-14 01:19:12 +03:00
|
|
|
$ext = strtolower(substr($orig_filename, 1 + strrpos($orig_filename, ".")));
|
2008-10-06 04:45:25 +04:00
|
|
|
$new_file_name = "$opId.$ext";
|
2009-01-14 01:19:12 +03:00
|
|
|
loadsettings();
|
2008-10-06 03:46:54 +04:00
|
|
|
|
2009-01-14 01:19:12 +03:00
|
|
|
$file_size = $_FILES['avatarFile']['size'];
|
|
|
|
if ($file_size == 0 || $file_size > $settings['max_uploaded_file_size']) {
|
2008-10-06 03:46:54 +04:00
|
|
|
$errors[] = failed_uploading_file($orig_filename, "errors.file.size.exceeded");
|
|
|
|
} elseif(!in_array($ext, $valid_types)) {
|
|
|
|
$errors[] = failed_uploading_file($orig_filename, "errors.invalid.file.type");
|
|
|
|
} else {
|
|
|
|
$avatar_local_dir = "../images/avatar/";
|
|
|
|
$full_file_path = $avatar_local_dir.$new_file_name;
|
|
|
|
if (file_exists($full_file_path)) {
|
|
|
|
unlink($full_file_path);
|
|
|
|
}
|
|
|
|
if (!move_uploaded_file($_FILES['avatarFile']['tmp_name'], $full_file_path)) {
|
|
|
|
$errors[] = failed_uploading_file($orig_filename, "errors.file.move.error");
|
|
|
|
} else {
|
|
|
|
$avatar = "$webimroot/images/avatar/$new_file_name";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$errors[] = "No file selected";
|
|
|
|
}
|
|
|
|
|
|
|
|
if(count($errors) == 0) {
|
|
|
|
update_operator_avatar($op['operatorid'],$avatar);
|
|
|
|
|
2008-10-06 04:45:25 +04:00
|
|
|
if ($opId && $avatar && $_SESSION['operator'] && $operator['operatorid'] == $opId) {
|
2008-10-06 03:46:54 +04:00
|
|
|
$_SESSION['operator']['vcavatar'] = $avatar;
|
|
|
|
}
|
2008-10-06 04:45:25 +04:00
|
|
|
header("Location: $webimroot/operator/avatar.php?op=$opId");
|
2008-10-06 03:46:54 +04:00
|
|
|
exit;
|
|
|
|
} else {
|
2008-10-06 04:45:25 +04:00
|
|
|
$page['avatar'] = topage($op['vcavatar']);
|
2008-10-06 03:46:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
2009-05-31 20:13:22 +04:00
|
|
|
if (isset($_GET['delete']) && $_GET['delete'] == "true" && $canmodify) {
|
2008-10-06 04:45:25 +04:00
|
|
|
update_operator_avatar($op['operatorid'],'');
|
|
|
|
header("Location: $webimroot/operator/avatar.php?op=$opId");
|
|
|
|
exit;
|
2008-10-06 03:46:54 +04:00
|
|
|
}
|
2008-10-06 04:45:25 +04:00
|
|
|
$page['avatar'] = topage($op['vcavatar']);
|
2008-10-06 03:46:54 +04:00
|
|
|
}
|
|
|
|
|
2009-04-10 18:12:57 +04:00
|
|
|
$page['currentop'] = $op ? topage(get_operator_name($op))." (".$op['vclogin'].")" : "-not found-";
|
2009-05-31 20:13:22 +04:00
|
|
|
$page['canmodify'] = $canmodify ? "1" : "";
|
2008-10-06 03:46:54 +04:00
|
|
|
|
2009-03-16 04:20:04 +03:00
|
|
|
prepare_menu($operator);
|
2009-03-23 00:22:51 +03:00
|
|
|
setup_operator_settings_tabs($opId,1);
|
2008-10-06 03:46:54 +04:00
|
|
|
start_html_output();
|
|
|
|
require('../view/avatar.php');
|
|
|
|
?>
|