From 8fc9b85bfa39e7f1dec66052f9ffc0f02e781174 Mon Sep 17 00:00:00 2001
From: Dmitriy Simushev <simushevds@ossg.ru>
Date: Tue, 19 Feb 2013 12:13:01 +0000
Subject: [PATCH] Do not support old browsers at all

---
 src/messenger/webim/client.php         | 21 ++++++++++++++-------
 src/messenger/webim/libs/chat.php      | 14 ++++----------
 src/messenger/webim/operator/agent.php |  2 +-
 3 files changed, 19 insertions(+), 18 deletions(-)

diff --git a/src/messenger/webim/client.php b/src/messenger/webim/client.php
index 1647f9f1..eede8ff2 100644
--- a/src/messenger/webim/client.php
+++ b/src/messenger/webim/client.php
@@ -36,6 +36,17 @@ if(Settings::get('enablessl') == "1" && Settings::get('forcessl') == "1") {
 	}
 }
 
+
+// Do not support old browsers at all
+if (get_remote_level($_SERVER['HTTP_USER_AGENT']) == 'old') {
+	// Create page array
+	$page = array_merge_recursive(
+		setup_logo()
+	);
+	expand("styles/dialogs", getchatstyle(), "nochat.tpl");
+	exit;
+}
+
 $page = array();
 
 if( !isset($_GET['token']) || !isset($_GET['thread']) ) {
@@ -160,15 +171,13 @@ if( !isset($_GET['token']) || !isset($_GET['thread']) ) {
 	}
 	$threadid = $thread->id;
 	$token = $thread->lastToken;
-	$level = get_remote_level($_SERVER['HTTP_USER_AGENT']);
 	$chatstyle = verifyparam( "style", "/^\w+$/", "");
-	header("Location: $webimroot/client.php?thread=$threadid&token=$token&level=$level".($chatstyle ? "&style=$chatstyle" : ""));
+	header("Location: $webimroot/client.php?thread=$threadid&token=$token".($chatstyle ? "&style=$chatstyle" : ""));
 	exit;
 }
 
 $token = verifyparam( "token", "/^\d{1,8}$/");
 $threadid = verifyparam( "thread", "/^\d{1,8}$/");
-$level = verifyparam( "level", "/^(ajaxed|old)$/");
 
 $thread = Thread::load($threadid, $token);
 if (! $thread) {
@@ -177,13 +186,13 @@ if (! $thread) {
 
 $page = array_merge_recursive(
 	$page,
-	setup_chatview_for_user($thread, $level)
+	setup_chatview_for_user($thread)
 );
 
 $pparam = verifyparam( "act", "/^(mailthread)$/", "default");
 if( $pparam == "mailthread" ) {
 	expand("styles/dialogs", getchatstyle(), "mail.tpl");
-} else if( $level == "ajaxed" ) {
+} else {
 	// Load JavaScript plugins and JavaScripts, CSS files required by them
 	$page['additional_css'] = get_additional_css('client_chat_window');
 	$page['additional_js'] = get_additional_js('client_chat_window');
@@ -192,8 +201,6 @@ if( $pparam == "mailthread" ) {
 	$page['chatModule'] = json_encode($page['chat']);
 	// Expand page
 	expand("styles/dialogs", getchatstyle(), "chat.tpl");
-} else if( $level == "old" ) {
-	expand("styles/dialogs", getchatstyle(), "nochat.tpl");
 }
 
 ?>
\ No newline at end of file
diff --git a/src/messenger/webim/libs/chat.php b/src/messenger/webim/libs/chat.php
index 9329caad..d3ed177b 100644
--- a/src/messenger/webim/libs/chat.php
+++ b/src/messenger/webim/libs/chat.php
@@ -99,7 +99,7 @@ function get_remote_level($useragent)
 			}
 		}
 	}
-	return "simple";
+	return "ajaxed";
 }
 
 function is_agent_opera95()
@@ -354,17 +354,14 @@ function setup_chatview(Thread $thread) {
  *
  * @global string $webimroot Root URL path for Mibew
  * @param Thread $thread thread object
- * @param string $level Chat level. Indicates ajax or old chat window should
  * be used
  * @return array Array of chat view data
  */
-function setup_chatview_for_user(Thread $thread, $level) {
+function setup_chatview_for_user(Thread $thread) {
 	global $webimroot;
 
 	$data = setup_chatview($thread);
 
-	$data['level'] = $level;
-
 	// Set user info
 	$data['chat']['user'] = array(
 		'name' => htmlspecialchars(topage($thread->userName)),
@@ -380,14 +377,13 @@ function setup_chatview_for_user(Thread $thread, $level) {
 	// Set link to send mail page
 	$data['chat']['links']['mail'] = "$webimroot/client.php?"
 		. $params
-		. "&amp;level=$level&amp;act=mailthread";
+		. "&amp;act=mailthread";
 
 	// Set SSL link
 	if (Settings::get('enablessl') == "1" && !is_secure_request()) {
 		$data['chat']['links']['ssl'] = get_app_location(true, true)
 			. "/client.php?"
-			. $params
-			. "&amp;level=$level";
+			. $params;
 	}
 
 	return $data;
@@ -399,8 +395,6 @@ function setup_chatview_for_user(Thread $thread, $level) {
  * @global string $webimroot Root URL path for Mibew
  * @global string $webim_encoding Current Mibew encoding
  * @param Thread $thread thread object
- * @param string $level Chat level. Indicates ajax or old chat window should
- * be used
  * @return array Array of chat view data
  */
 function setup_chatview_for_operator(Thread $thread, $operator) {
diff --git a/src/messenger/webim/operator/agent.php b/src/messenger/webim/operator/agent.php
index e92bc5a2..7a14ba06 100644
--- a/src/messenger/webim/operator/agent.php
+++ b/src/messenger/webim/operator/agent.php
@@ -98,7 +98,7 @@ if (!isset($_GET['token'])) {
 	}
 
 	$token = $thread->lastToken;
-	header("Location: $webimroot/operator/agent.php?thread=$threadid&token=$token&level=$remote_level");
+	header("Location: $webimroot/operator/agent.php?thread=$threadid&token=$token");
 	exit;
 }