From e0d80f3c61ccf215208db682c460693629abe2fd Mon Sep 17 00:00:00 2001 From: Evgeny Gryaznov Date: Sun, 12 Oct 2008 01:21:37 +0000 Subject: [PATCH] usernamepattern, usercanchangename options in db, done git-svn-id: https://webim.svn.sourceforge.net/svnroot/webim/trunk@177 c66351dc-e62f-0410-b875-e3a5c0b9693f --- src/messenger/webim/libs/chat.php | 9 +++++---- src/messenger/webim/libs/common.php | 2 +- src/messenger/webim/libs/config.php | 10 ---------- src/messenger/webim/operator/update.php | 1 + src/messenger/webim/thread.php | 3 ++- 5 files changed, 9 insertions(+), 16 deletions(-) diff --git a/src/messenger/webim/libs/chat.php b/src/messenger/webim/libs/chat.php index 3117b7e7..1c497ee0 100644 --- a/src/messenger/webim/libs/chat.php +++ b/src/messenger/webim/libs/chat.php @@ -182,10 +182,11 @@ function print_thread_messages($thread, $token, $lastid, $isuser, $format, $agen } function get_user_name($username, $addr, $id) { - global $presentable_name_pattern; + global $settings; + loadsettings(); return str_replace("{addr}", $addr, str_replace("{id}", $id, - str_replace("{name}", $username, $presentable_name_pattern))); + str_replace("{name}", $username, $settings['usernamepattern']))); } function is_ajax_browser($browserid,$ver,$useragent) { @@ -254,7 +255,7 @@ function needsFramesrc() { } function setup_chatview_for_user($thread,$level) { - global $page, $webimroot, $user_can_change_name, $settings; + global $page, $webimroot, $settings; loadsettings(); $page = array(); $page['agent'] = false; @@ -267,7 +268,7 @@ function setup_chatview_for_user($thread,$level) { $page['ct.chatThreadId'] = $thread['threadid']; $page['ct.token'] = $thread['ltoken']; $page['ct.user.name'] = topage($thread['userName']); - $page['canChangeName'] = $user_can_change_name; + $page['canChangeName'] = $settings['usercanchangename'] == "1"; $page['ct.company.name'] = topage($settings['title']); $page['ct.company.chatLogoURL'] = topage($settings['logo']); diff --git a/src/messenger/webim/libs/common.php b/src/messenger/webim/libs/common.php index 11d2005a..5caa4e77 100644 --- a/src/messenger/webim/libs/common.php +++ b/src/messenger/webim/libs/common.php @@ -433,7 +433,7 @@ $settings = array( 'logo' => '', 'enableban' => '0', 'usernamepattern' => '{name}', - 'usercanchangename' => true + 'usercanchangename' => '1' ); $settingsloaded = false; $settings_in_db = array(); diff --git a/src/messenger/webim/libs/config.php b/src/messenger/webim/libs/config.php index 8e9c6cfb..a6ec574d 100644 --- a/src/messenger/webim/libs/config.php +++ b/src/messenger/webim/libs/config.php @@ -62,16 +62,6 @@ $available_locales = array("en", "ru"); $home_locale = "ru"; /* native name will be used in this locale */ $default_locale = "en"; /* if user does not provide known lang */ -/* - * Allows users to change their names - */ -$user_can_change_name = true; - -/* - * How to build presentable visitor name from {name}, {id} or {addr}. Default: {name} - */ -$presentable_name_pattern = "{name}"; - /* * Method of getting information about remote user. For example, you could * have user name or id in session. Default value: visitor_from_request diff --git a/src/messenger/webim/operator/update.php b/src/messenger/webim/operator/update.php index f0b22193..1046759e 100644 --- a/src/messenger/webim/operator/update.php +++ b/src/messenger/webim/operator/update.php @@ -144,6 +144,7 @@ function print_pending_threads($since) { $since = verifyparam( "since", "/^\d{1,9}$/", 0); +loadsettings(); print_pending_threads($since); notify_operator_alive($operator['operatorid']); exit; diff --git a/src/messenger/webim/thread.php b/src/messenger/webim/thread.php index b00c6616..6803916b 100644 --- a/src/messenger/webim/thread.php +++ b/src/messenger/webim/thread.php @@ -74,7 +74,8 @@ if( $act == "refresh" ) { } else if( $act == "rename" ) { - if( !$user_can_change_name ) { + loadsettings(); + if( $settings['usercanchangename'] != "1" ) { show_error("server: forbidden to change name"); }