From 147beb3ed2673ef5eeaaff38dfb31ef05ea62052 Mon Sep 17 00:00:00 2001 From: Evgeny Gryaznov Date: Fri, 10 Apr 2009 14:12:57 +0000 Subject: [PATCH] fix date_diff, profile git-svn-id: https://webim.svn.sourceforge.net/svnroot/webim/trunk@467 c66351dc-e62f-0410-b875-e3a5c0b9693f --- src/messenger/webim/images/dash/profile.gif | Bin 0 -> 1159 bytes src/messenger/webim/libs/chat.php | 2 +- src/messenger/webim/libs/common.php | 2 +- src/messenger/webim/libs/operator.php | 1 + src/messenger/webim/locales/en/properties | 5 +- src/messenger/webim/locales/ru/properties | 3 ++ src/messenger/webim/operator/avatar.php | 9 ++-- src/messenger/webim/operator/operator.php | 7 ++- src/messenger/webim/operator/opgroups.php | 28 +++++++---- src/messenger/webim/operator/permissions.php | 16 ++++-- src/messenger/webim/view/agent.php | 2 +- src/messenger/webim/view/avatar.php | 6 +-- src/messenger/webim/view/inc_menu.php | 11 ++-- src/messenger/webim/view/menu.php | 50 +++++++++++-------- src/messenger/webim/view/operator_groups.php | 4 +- src/messenger/webim/view/permissions.php | 9 ++-- src/messenger/webim/view/thread_log.php | 2 +- src/messenger/webim/view/thread_search.php | 2 +- src/messenger/webim/view/userhistory.php | 2 +- 19 files changed, 101 insertions(+), 60 deletions(-) create mode 100644 src/messenger/webim/images/dash/profile.gif diff --git a/src/messenger/webim/images/dash/profile.gif b/src/messenger/webim/images/dash/profile.gif new file mode 100644 index 0000000000000000000000000000000000000000..8f9bf9b509db90c76f7d146f5d9a2047d719a652 GIT binary patch literal 1159 zcmdth{WIGK0LSq!tBQyAx?HT*xt`Kf9NSK<-3+Tym4tW*njGq()+zPSZnN{#B7Hn= zckQm*S?{tV1c|4RR7h=$67kfvQ4ggQ8JaCD#FCImKD+)Kd;bToAKvGvu^)eu>q&SL zW*HG%w;fUoxm?cdN1VX)lK+YiYl*k_eqjitbW-DJq@g&lF zkRrj=1*FN4@CZd}d{%G!wr!rJLdLJi9za?*m=Y{3EM)$M)B$@+FJ@k?B(x)xkHmIR z8+WJzGhJk5b|bYH@h!GgDYBj*O98rQFS!$i&%kaqB(~X$6IY%i^LHq;=JY<~j^l&xm#&U% zB*>s#v5Cg#>7B?KgMJ5zVib?)le>^CK}H{Prl8b=*eY>;R`XZG*48;Jo9yQwA&h5e zSwTj_+Kg_mbOHJ8o6&U!h8RV?mh8vS>-B;eJGE)|p z=-AC$e{XJw|GW->_@8!ccb@}6$cUgfzBf-0BoL)8UUA~u{_FczdklZZCh<;_-hRI# z>I9cZ;#}ZVv7XV6`g~=DYVf1DR zC?2Osj7bi$T=@;@BSr&T!jJP!c0Aybe $userId, 'name' => $userName ); } -?> +?> \ No newline at end of file diff --git a/src/messenger/webim/libs/common.php b/src/messenger/webim/libs/common.php index c3504b90..dbef183d 100644 --- a/src/messenger/webim/libs/common.php +++ b/src/messenger/webim/libs/common.php @@ -436,7 +436,7 @@ function div($a,$b) { return ($a-($a % $b)) / $b; } -function date_diff($seconds) { +function date_diff_to_text($seconds) { $minutes = div($seconds,60); $seconds = $seconds % 60; if( $minutes < 60 ) { diff --git a/src/messenger/webim/libs/operator.php b/src/messenger/webim/libs/operator.php index 540da5ee..8aa14328 100644 --- a/src/messenger/webim/libs/operator.php +++ b/src/messenger/webim/libs/operator.php @@ -271,6 +271,7 @@ function prepare_menu($operator,$hasright=true) { $page['showgroups'] = $settings['enablegroups'] == "1"; $page['showstat'] = $settings['enablestatistics'] == "1"; $page['showadmin'] = is_capable($can_administrate, $operator); + $page['currentopid'] = $operator['operatorid']; } } diff --git a/src/messenger/webim/locales/en/properties b/src/messenger/webim/locales/en/properties index 327b7137..5862fb26 100644 --- a/src/messenger/webim/locales/en/properties +++ b/src/messenger/webim/locales/en/properties @@ -94,7 +94,7 @@ clients.title=List of awaiting visitors common.asterisk_explanation=* - mandatory fields company.title=Web Messenger Community confirm.take.head=Change operator -confirm.take.message=Visitor {0} already assisted by {1}.
Are your really sure you want to start chatting the visitor? +confirm.take.message=Visitor {0} already assisted by {1}.
Are you really sure you want to start chatting the visitor? confirm.take.no=No, close the window confirm.take.yes=Yes, I'm sure content.blocked=Here you can defend from malicious visitors. @@ -205,6 +205,8 @@ menu.locale.content=Change locale. menu.locale=Language menu.main=Main menu.operator=You are {0} +menu.profile.content=You can change your personal information on this page. +menu.profile=Profile menu.translate=Localize menu.updates.content=Check for news and updates. menu.updates=Updates @@ -271,6 +273,7 @@ page.translate.descr=If you don't like the translation, please send us an update page.translate.done=Your translation is saved. page.translate.one=Enter you translation. page.translate.title=Localization wizard +page_agent.cannot_modify=You are not allowed to change this person's profile. page_agent.clear_avatar=Remove avatar page_agent.create_new=Here you can create new operator page_agent.error.duplicate_login=Please choose another login, because operator with entered login is already registered in the system. diff --git a/src/messenger/webim/locales/ru/properties b/src/messenger/webim/locales/ru/properties index f499f454..feec1ebe 100644 --- a/src/messenger/webim/locales/ru/properties +++ b/src/messenger/webim/locales/ru/properties @@ -205,6 +205,8 @@ menu.locale.content= menu.locale=Язык menu.main=Главная menu.operator=Вы {0} +menu.profile.content=На этой странице вы можете отредактировать свою персональную информацию. +menu.profile=Профиль menu.translate=Локализация menu.updates.content=Проверить наличие обновлений мессенджера. menu.updates=Обновления @@ -271,6 +273,7 @@ page.translate.descr= page.translate.done=Ваш перевод сохранен. page.translate.one=Введите ваш вариант перевода. page.translate.title=Локализация +page_agent.cannot_modify=Вы не можете изменять профиль этого оператора. page_agent.clear_avatar=Удалить аватарку page_agent.create_new=Создание нового оператора. page_agent.error.duplicate_login=Выберите другой логин, т.к. оператор с введенным логином уже зарегистрирован в системе. diff --git a/src/messenger/webim/operator/avatar.php b/src/messenger/webim/operator/avatar.php index a09c16b4..e593a7a9 100644 --- a/src/messenger/webim/operator/avatar.php +++ b/src/messenger/webim/operator/avatar.php @@ -19,7 +19,7 @@ require_once('../libs/operator_settings.php'); $operator = check_login(); $opId = verifyparam( "op","/^\d{1,9}$/"); -$page = array('op' => $opId, 'avatar' => ''); +$page = array('opid' => $opId, 'avatar' => ''); $errors = array(); $op = operator_by_id($opId); @@ -30,7 +30,10 @@ if( !$op ) { } else if( isset($_POST['op']) ) { $avatar = $op['vcavatar']; - if( isset($_FILES['avatarFile']) && $_FILES['avatarFile']['name']) { + if($opId != $operator['operatorid'] && !is_capable($can_administrate, $operator)) { + $errors[] = getlocal('page_agent.cannot_modify'); + + } else if( isset($_FILES['avatarFile']) && $_FILES['avatarFile']['name']) { $valid_types = array("gif","jpg", "png", "tif"); $orig_filename = $_FILES['avatarFile']['name']; @@ -82,7 +85,7 @@ if( !$op ) { $page['avatar'] = topage($op['vcavatar']); } -$page['currentop'] = topage(get_operator_name($op))." (".$op['vclogin'].")"; +$page['currentop'] = $op ? topage(get_operator_name($op))." (".$op['vclogin'].")" : "-not found-"; prepare_menu($operator); setup_operator_settings_tabs($opId,1); diff --git a/src/messenger/webim/operator/operator.php b/src/messenger/webim/operator/operator.php index f16c2ef9..7cb6134e 100644 --- a/src/messenger/webim/operator/operator.php +++ b/src/messenger/webim/operator/operator.php @@ -52,7 +52,12 @@ if( isset($_POST['login']) && isset($_POST['password']) ) { if( (!$opId && $existing_operator) || ( $opId && $existing_operator && $opId != $existing_operator['operatorid']) ) $errors[] = getlocal("page_agent.error.duplicate_login"); - + + + if($opId != $operator['operatorid'] && !is_capable($can_administrate, $operator)) { + $errors[] = getlocal('page_agent.cannot_modify'); + } + if( count($errors) == 0 ) { if (!$opId) { $newop = create_operator($login,$password,$localname,$commonname,""); diff --git a/src/messenger/webim/operator/opgroups.php b/src/messenger/webim/operator/opgroups.php index 9ccfd09c..4119eeda 100644 --- a/src/messenger/webim/operator/opgroups.php +++ b/src/messenger/webim/operator/opgroups.php @@ -28,7 +28,7 @@ function update_operator_groups($operatorid,$newvalue) { } $opId = verifyparam( "op","/^\d{1,9}$/"); -$page = array('op' => $opId); +$page = array('opid' => $opId); $page['groups'] = get_groups(false); $errors = array(); @@ -39,22 +39,28 @@ if( !$op ) { } else if( isset($_POST['op']) ) { - $new_groups = array(); - foreach($page['groups'] as $group) { - if( verifyparam("group".$group['groupid'],"/^on$/", "") == "on") { - $new_groups[] = $group['groupid']; - } + if($opId != $operator['operatorid'] && !is_capable($can_administrate, $operator)) { + $errors[] = getlocal('page_agent.cannot_modify'); } - update_operator_groups($op['operatorid'],$new_groups); - header("Location: $webimroot/operator/opgroups.php?op=$opId&stored"); - exit; + if(count($errors) == 0) { + $new_groups = array(); + foreach($page['groups'] as $group) { + if( verifyparam("group".$group['groupid'],"/^on$/", "") == "on") { + $new_groups[] = $group['groupid']; + } + } + + update_operator_groups($op['operatorid'],$new_groups); + header("Location: $webimroot/operator/opgroups.php?op=$opId&stored"); + exit; + } } $page['formgroup'] = array(); -$page['currentop'] = $opId ? topage(get_operator_name($op))." (".$op['vclogin'].")" : ""; +$page['currentop'] = $op ? topage(get_operator_name($op))." (".$op['vclogin'].")" : "-not found-"; -if($opId) { +if($op) { foreach(get_operator_groupids($opId) as $rel) { $page['formgroup'][] = $rel['groupid']; } diff --git a/src/messenger/webim/operator/permissions.php b/src/messenger/webim/operator/permissions.php index a03ccfaa..eb7c109a 100644 --- a/src/messenger/webim/operator/permissions.php +++ b/src/messenger/webim/operator/permissions.php @@ -27,7 +27,7 @@ function update_operator_permissions($operatorid,$newvalue) { } $opId = verifyparam( "op","/^\d{1,9}$/"); -$page = array('op' => $opId); +$page = array('opid' => $opId, 'canmodify' => is_capable($can_administrate, $operator) ? "1" : ""); $errors = array(); $op = operator_by_id($opId); @@ -37,6 +37,10 @@ if( !$op ) { } else if( isset($_POST['op']) ) { + if(!is_capable($can_administrate, $operator)) { + $errors[] = getlocal('page_agent.cannot_modify'); + } + $new_permissions = isset($op['iperm']) ? $op['iperm'] : 0; foreach($permission_ids as $perm => $id) { @@ -61,11 +65,13 @@ if( !$op ) { $page['permissionsList'] = get_permission_list(); $page['formpermissions'] = array(""); -$page['currentop'] = topage(get_operator_name($op))." (".$op['vclogin'].")"; +$page['currentop'] = $op ? topage(get_operator_name($op))." (".$op['vclogin'].")" : "-not found-"; -foreach($permission_ids as $perm => $id) { - if(is_capable($perm,$op)) { - $page['formpermissions'][] = $id; +if($op) { + foreach($permission_ids as $perm => $id) { + if(is_capable($perm,$op)) { + $page['formpermissions'][] = $id; + } } } diff --git a/src/messenger/webim/view/agent.php b/src/messenger/webim/view/agent.php index 36fd875e..8361499f 100644 --- a/src/messenger/webim/view/agent.php +++ b/src/messenger/webim/view/agent.php @@ -14,7 +14,7 @@ require_once("inc_menu.php"); $page['title'] = getlocal("page_agent.title"); -$page['menuid'] = "operators"; +$page['menuid'] = $page['opid'] == $page['currentopid'] ? "profile" : "operators"; function tpl_content() { global $page, $webimroot, $errors; ?> diff --git a/src/messenger/webim/view/avatar.php b/src/messenger/webim/view/avatar.php index 2457ecee..ffa4ad22 100644 --- a/src/messenger/webim/view/avatar.php +++ b/src/messenger/webim/view/avatar.php @@ -14,7 +14,7 @@ require_once("inc_menu.php"); $page['title'] = getlocal("page_avatar.title"); -$page['menuid'] = "operators"; +$page['menuid'] = $page['opid'] == $page['currentopid'] ? "profile" : "operators"; function tpl_content() { global $page, $webimroot, $errors; ?> @@ -27,7 +27,7 @@ require_once('inc_errors.php'); ?>
- +
    @@ -51,7 +51,7 @@ require_once('inc_errors.php');
    diff --git a/src/messenger/webim/view/inc_menu.php b/src/messenger/webim/view/inc_menu.php index 52ef5ddf..9f34a378 100644 --- a/src/messenger/webim/view/inc_menu.php +++ b/src/messenger/webim/view/inc_menu.php @@ -23,22 +23,25 @@ function tpl_menu() { global $page, $webimroot, $errors;
-
  • -
  • diff --git a/src/messenger/webim/view/thread_log.php b/src/messenger/webim/view/thread_log.php index 750ee3cf..0aa3931e 100644 --- a/src/messenger/webim/view/thread_log.php +++ b/src/messenger/webim/view/thread_log.php @@ -73,7 +73,7 @@ $chatthread = $page['thread']; :
    - + ()

    diff --git a/src/messenger/webim/view/thread_search.php b/src/messenger/webim/view/thread_search.php index e38a757b..f6ae0ed6 100644 --- a/src/messenger/webim/view/thread_search.php +++ b/src/messenger/webim/view/thread_search.php @@ -86,7 +86,7 @@ if( $page['pagination.items'] ) { - , + , - , + ,