fix eol, add agentId into chatmessage and chatthread, minor changes in html, several utility functions

git-svn-id: https://webim.svn.sourceforge.net/svnroot/webim/trunk@27 c66351dc-e62f-0410-b875-e3a5c0b9693f
This commit is contained in:
Evgeny Gryaznov 2007-10-10 15:15:47 +00:00
parent 77f19d14bc
commit f168f1baaf
41 changed files with 4299 additions and 4369 deletions

View File

@ -28,11 +28,18 @@ function create_tables() {
global $dbencoding;
$link = connect();
// to update from v1
// ALTER TABLE chatthread ADD agentId int NOT NULL DEFAULT 0 AFTER agentName
// update chatthread,chatoperator set agentId = operatorid where agentId = 0 AND (vclocalename = agentName OR vccommonname = agentName)
// ALTER TABLE chatmessage ADD agentId int NOT NULL DEFAULT 0 AFTER ikind
// update chatmessage,chatoperator set agentId = operatorid where agentId = 0 AND ikind = 2 AND (vclocalename = tname OR vccommonname = tname)
$query =
"CREATE TABLE chatthread (\n".
" threadid int NOT NULL auto_increment PRIMARY KEY ,\n".
" userName varchar(64) NOT NULL,\n".
" agentName varchar(64),\n".
" agentId int NOT NULL DEFAULT 0,\n".
" dtmcreated datetime DEFAULT 0,\n".
" dtmmodified datetime DEFAULT 0,\n".
" lrevision int NOT NULL DEFAULT 0,\n".
@ -53,6 +60,7 @@ function create_tables() {
" messageid int NOT NULL auto_increment PRIMARY KEY,\n".
" threadid int NOT NULL references chatthread(threadid),\n".
" ikind int NOT NULL,\n".
" agentId int NOT NULL DEFAULT 0,\n".
" tmessage text NOT NULL,\n".
" dtmcreated datetime DEFAULT 0,\n".
" tname varchar(64)\n".

View File

@ -20,9 +20,6 @@
<link rel="stylesheet" type="text/css" media="all" href="/webim/styles.css" />
<link rel="shortcut icon" href="/webim/images/favicon.ico" type="image/x-icon"/>
<title>
<?php echo getstring("app.title") ?> - <?php echo getstring("install.title") ?>
@ -30,10 +27,6 @@
<meta http-equiv="keywords" content="<?php echo getstring("page.main_layout.meta_keyword") ?>">
<meta http-equiv="description" content="<?php echo getstring("page.main_layout.meta_description") ?>">
</head>
<body bgcolor="#FFFFFF" text="#000000" link="#2971C1" vlink="#2971C1" alink="#2971C1">

View File

@ -20,9 +20,6 @@
<link rel="stylesheet" type="text/css" media="all" href="/webim/styles.css" />
<link rel="shortcut icon" href="/webim/images/favicon.ico" type="image/x-icon"/>
<title>
<?php echo getstring("app.title") ?> - <?php echo getstring("installed.title") ?>
@ -30,10 +27,6 @@
<meta http-equiv="keywords" content="<?php echo getstring("page.main_layout.meta_keyword") ?>">
<meta http-equiv="description" content="<?php echo getstring("page.main_layout.meta_description") ?>">
</head>
<body bgcolor="#FFFFFF" text="#000000" link="#2971C1" vlink="#2971C1" alink="#2971C1">

View File

@ -44,21 +44,22 @@ function next_revision($link) {
return $val;
}
function post_message_($threadid,$kind,$message,$link,$from=null,$time=null) {
function post_message_($threadid,$kind,$message,$link,$from=null,$time=null,$opid=null) {
$query = sprintf(
"insert into chatmessage (threadid,ikind,tmessage,tname,dtmcreated) values (%s, %s,'%s',%s,%s)",
"insert into chatmessage (threadid,ikind,tmessage,tname,agentId,dtmcreated) values (%s, %s,'%s',%s,%s,%s)",
$threadid,
$kind,
quote_smart($message,$link),
$from ? "'".quote_smart($from,$link)."'" : "null",
$opid ? $opid : "0",
$time ? "FROM_UNIXTIME($time)" : "CURRENT_TIMESTAMP" );
perform_query($query,$link);
}
function post_message($threadid,$kind,$message,$from=null) {
function post_message($threadid,$kind,$message,$from=null,$agentid=null) {
$link = connect();
post_message_($threadid,$kind,$message,$link,$from);
post_message_($threadid,$kind,$message,$link,$from,null,$agentid);
mysql_close($link);
}
@ -347,11 +348,12 @@ function create_thread($username,$remote,$referer,$lang) {
return $newthread;
}
function do_take_thread($threadid,$operatorName) {
function do_take_thread($threadid,$operatorId,$operatorName) {
global $state_chatting;
$link = connect();
commit_thread( $threadid,
array("istate" => $state_chatting,
"agentId" => $operatorId,
"agentName" => "'".mysql_real_escape_string($operatorName)."'"), $link);
mysql_close($link);
}
@ -387,7 +389,7 @@ function take_thread($thread,$operator) {
$operatorName = ($thread['locale'] == $home_locale) ? $operator['vclocalename'] : $operator['vccommonname'];
if( $state == $state_queue || $state == $state_waiting) {
do_take_thread($threadid, $operatorName);
do_take_thread($threadid, $operator['operatorid'], $operatorName);
if( $state == $state_waiting ) {
$message_to_post = getstring2_("chat.status.operator.changed", array($operatorName,$thread['agentName']), $thread['locale']);
@ -395,24 +397,25 @@ function take_thread($thread,$operator) {
$message_to_post = getstring2_("chat.status.operator.joined", array($operatorName), $thread['locale']);
}
} else if( $state == $state_chatting ) {
if( $operatorName != $thread['agentName'] ) {
do_take_thread($threadid, $operatorName);
if( $operator['operatorid'] != $thread['agentId'] ) {
do_take_thread($threadid, $operator['operatorid'], $operatorName);
$message_to_post = getstring2_("chat.status.operator.changed", array($operatorName, $thread['agentName']), $thread['locale']);
}
} else {
die("cannot take thread");
}
if( $message_to_post )
if( $message_to_post ) {
post_message($threadid,$kind_events,$message_to_post);
}
}
function check_for_reassign($thread,$operator) {
global $state_waiting, $home_locale, $kind_events;
$operatorName = ($thread['locale'] == $home_locale) ? $operator['vclocalename'] : $operator['vccommonname'];
if( $thread['istate'] == $state_waiting &&
( $thread['agentName'] == $operatorName )) {
do_take_thread($thread['threadid'], $operatorName);
( $thread['agentId'] == $operator['operatorid'] )) {
do_take_thread($thread['threadid'], $operator['operatorid'], $operatorName);
$message_to_post = getstring2_("chat.status.operator.changed", array($operatorName,$thread['agentName']), $thread['locale']);
post_message($thread['threadid'],$kind_events,$message_to_post);
}

View File

@ -188,6 +188,18 @@ function select_one_row($query,$link) {
return $line;
}
function select_multi_assoc($query,$link) {
$sqlresult = mysql_query($query,$link) or die(' Query failed: ' .
mysql_error().": ".$query);
$result = array();
while ($row = mysql_fetch_array($sqlresult, MYSQL_ASSOC)) {
$result[] = $row;
}
mysql_free_result($sqlresult);
return $result;
}
function start_xml_output() {
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Content-type: text/xml");
@ -290,4 +302,34 @@ function get_app_location($showhost,$issecure) {
}
}
function get_month_selection($fromtime,$totime) {
$start = getdate($fromtime);
$month = $start['mon'];
$year = $start['year'];
$result = array();
do {
$current = mktime(0,0,0,$month,1,$year);
$result[date("m.y",$current)] = date("M, Y",$current);
$month++;
if( $month > 12 ) {
$month = 1;
$year++;
}
} while( $current < $totime );
return $result;
}
function get_form_date($day,$month) {
if( preg_match('/^(\d{2}).(\d{2})$/', $month, $matches)) {
return mktime(0,0,0,$matches[1],$day,$matches[2]);
}
return 0;
}
function set_form_date($time,$prefix) {
global $page;
$page["form${prefix}day"] = date("d", $time);
$page["form${prefix}month"] = date("m.y", $time);
}
?>

View File

@ -49,7 +49,7 @@ if( $act == "refresh" ) {
$kind = $isuser ? $kind_user : $kind_agent;
$from = $isuser ? $thread['userName'] : $thread['agentName'];
post_message($threadid,$kind,$message,$from);
post_message($threadid,$kind,$message,$from, $isuser ? null : $operator['operatorid'] );
print_thread_mesages($threadid, $token, $lastid, $isuser, $outformat);
exit;

View File

@ -20,9 +20,6 @@
<link rel="stylesheet" type="text/css" media="all" href="/webim/styles.css" />
<link rel="shortcut icon" href="/webim/images/favicon.ico" type="image/x-icon"/>
<title>
<?php echo getstring("app.title") ?> - <?php echo getstring("page_agent.title") ?>
@ -30,10 +27,6 @@
<meta http-equiv="keywords" content="<?php echo getstring("page.main_layout.meta_keyword") ?>">
<meta http-equiv="description" content="<?php echo getstring("page.main_layout.meta_description") ?>">
</head>
<body bgcolor="#FFFFFF" text="#000000" link="#2971C1" vlink="#2971C1" alink="#2971C1">
@ -55,14 +48,6 @@
<?php } ?>
<br />
<br />
<?php if( isset($errors) && count($errors) > 0 ) { ?>
<table cellspacing="0" cellpadding="0" border="0">
<tr>

View File

@ -20,9 +20,6 @@
<link rel="stylesheet" type="text/css" media="all" href="/webim/styles.css" />
<link rel="shortcut icon" href="/webim/images/favicon.ico" type="image/x-icon"/>
<title>
<?php echo getstring("app.title") ?> - <?php echo getstring("page_agents.title") ?>
@ -30,10 +27,6 @@
<meta http-equiv="keywords" content="<?php echo getstring("page.main_layout.meta_keyword") ?>">
<meta http-equiv="description" content="<?php echo getstring("page.main_layout.meta_description") ?>">
</head>
<body bgcolor="#FFFFFF" text="#000000" link="#2971C1" vlink="#2971C1" alink="#2971C1">

View File

@ -24,10 +24,6 @@
<tr>
<td valign="top">
<table width="100%" height="100%" cellspacing="0" cellpadding="0" border="0">
<tr>
<td height="75"></td>

View File

@ -24,10 +24,6 @@
<tr>
<td valign="top">
<table width="100%" height="100%" cellspacing="0" cellpadding="0" border="0">
<tr>
<td height="75"></td>

View File

@ -24,10 +24,6 @@
<tr>
<td valign="top">
<form name="mailThreadForm" method="post" action="/webim/mail.php">
<input type="hidden" name="thread" value="<?php echo $page['ct.chatThreadId'] ?>"/><input type="hidden" name="token" value="<?php echo $page['ct.token'] ?>"/><input type="hidden" name="level" value="<?php echo $page['level'] ?>"/>

View File

@ -24,10 +24,6 @@
<tr>
<td valign="top">
<table width="100%" height="100%" cellspacing="0" cellpadding="0" border="0">
<tr>
<td height="20"></td>

View File

@ -20,9 +20,6 @@
<link rel="stylesheet" type="text/css" media="all" href="/webim/styles.css" />
<link rel="shortcut icon" href="/webim/images/favicon.ico" type="image/x-icon"/>
<title>
<?php echo getstring("app.title") ?> - <?php echo getstring("page.gen_button.title") ?>
@ -30,10 +27,6 @@
<meta http-equiv="keywords" content="<?php echo getstring("page.main_layout.meta_keyword") ?>">
<meta http-equiv="description" content="<?php echo getstring("page.main_layout.meta_description") ?>">
</head>
<body bgcolor="#FFFFFF" text="#000000" link="#2971C1" vlink="#2971C1" alink="#2971C1">

View File

@ -20,9 +20,6 @@
<link rel="stylesheet" type="text/css" media="all" href="/webim/styles.css" />
<link rel="shortcut icon" href="/webim/images/favicon.ico" type="image/x-icon"/>
<title>
<?php echo getstring("app.title") ?> - <?php echo getstring("page_login.title") ?>
@ -30,10 +27,6 @@
<meta http-equiv="keywords" content="<?php echo getstring("page.main_layout.meta_keyword") ?>">
<meta http-equiv="description" content="<?php echo getstring("page.main_layout.meta_description") ?>">
</head>
<body bgcolor="#FFFFFF" text="#000000" link="#2971C1" vlink="#2971C1" alink="#2971C1">
@ -48,18 +41,6 @@
<?php if( isset($errors) && count($errors) > 0 ) { ?>
<table cellspacing="0" cellpadding="0" border="0">
<tr>

View File

@ -20,9 +20,6 @@
<link rel="stylesheet" type="text/css" media="all" href="/webim/styles.css" />
<link rel="shortcut icon" href="/webim/images/favicon.ico" type="image/x-icon"/>
<title>
<?php echo getstring("app.title") ?> - <?php echo getstring("topMenu.admin") ?>
@ -30,10 +27,6 @@
<meta http-equiv="keywords" content="<?php echo getstring("page.main_layout.meta_keyword") ?>">
<meta http-equiv="description" content="<?php echo getstring("page.main_layout.meta_description") ?>">
</head>
<body bgcolor="#FFFFFF" text="#000000" link="#2971C1" vlink="#2971C1" alink="#2971C1">

View File

@ -19,14 +19,6 @@
<link rel="stylesheet" type="text/css" media="all" href="/webim/styles.css" />
<script type="text/javascript" language="javascript" src="/webim/js/common.js"></script>
<script><!--
var localized = new Array(
"<?php echo getstring("pending.table.speak") ?>",
@ -41,9 +33,6 @@ var updaterOptions = {
//--></script>
<script type="text/javascript" language="javascript" src="/webim/js/page_pendingclients.js"></script>
<link rel="shortcut icon" href="/webim/images/favicon.ico" type="image/x-icon"/>
<title>
<?php echo getstring("app.title") ?> - <?php echo getstring("clients.title") ?>
@ -51,10 +40,6 @@ var updaterOptions = {
<meta http-equiv="keywords" content="<?php echo getstring("page.main_layout.meta_keyword") ?>">
<meta http-equiv="description" content="<?php echo getstring("page.main_layout.meta_description") ?>">
</head>
<body bgcolor="#FFFFFF" text="#000000" link="#2971C1" vlink="#2971C1" alink="#2971C1">
@ -68,11 +53,6 @@ var updaterOptions = {
</td><td align="right" class="text" valign="top"><table cellspacing="0" cellpadding="0" border="0"><tr><td class="textform"><?php echo getstring2("menu.operator",array($page['operator'])) ?></td><td class="textform"><img src='/webim/images/topdiv.gif' width="25" height="15" border="0" alt="|" /></td><td class="textform"><a href="/webim/operator/index.php" title="<?php echo getstring("menu.main") ?>"><?php echo getstring("menu.main") ?></a></td></tr></table></td></tr></table>
<?php echo getstring("clients.intro") ?><br>
<?php echo getstring("clients.how_to") ?><br>

View File

@ -103,7 +103,7 @@ page.gen_button.sample=Example
page.gen_button.code.description=<strong>Caution!</strong> Please don't change<br/> the code manually because<br/> we don't guarantee that<br/> it will work!
mail.user.history.subject=Web Messenger: dialog history
mail.user.history.body=Hello, {0}!\n\nYour chat history: \n\n{1}\n--- \nKind Regards,\nThe I-Services Support Team
errors.header=<font color="#c13030"><b>Correct the mistakes:</b><br/><br/><ul>
errors.header=<font color="#c13030"><b>Correct the mistakes:</b><br/><ul>
errors.prefix=<li class="error">
errors.suffix=</li>
errors.footer=</ul></font>

View File

@ -103,7 +103,7 @@ page.gen_button.sample=
page.gen_button.code.description=<strong>Внимание!</strong> При внесении<br/> каких-либо изменений<br/> в этот код работоспособность<br/> кнопки не гарантируется!
mail.user.history.subject=Вэб Мессенджер: история диалога
mail.user.history.body=Здраствуйте, {0}!\n\nПо Вашему запросу, высылаем историю: \n\n{1}\n--- \nС уважением,\nСлужба поддержки i-services.ru
errors.header=<font color="#c13030"><b>Èñïðàâüòå îøèáêè:</b><br/><br/><ul>
errors.header=<font color="#c13030"><b>Èñïðàâüòå îøèáêè:</b><br/><ul>
errors.prefix=<li class="error">
errors.suffix=</li>
errors.footer=</ul></font>

View File

@ -21,9 +21,6 @@
<link rel="stylesheet" type="text/css" media="all" href="/webim/chat.css" />
<link rel="shortcut icon" href="/webim/images/favicon.ico" type="image/x-icon"/>
<title>
<?php echo getstring("app.title") ?> - <?php echo getstring("thread.chat_log") ?>
@ -31,10 +28,6 @@
<meta http-equiv="keywords" content="<?php echo getstring("page.main_layout.meta_keyword") ?>">
<meta http-equiv="description" content="<?php echo getstring("page.main_layout.meta_description") ?>">
</head>
<body bgcolor="#FFFFFF" text="#000000" link="#2971C1" vlink="#2971C1" alink="#2971C1">
@ -47,11 +40,6 @@
<?php echo getstring("thread.intro") ?>
<br/><br/>

View File

@ -20,9 +20,6 @@
<link rel="stylesheet" type="text/css" media="all" href="/webim/styles.css" />
<link rel="shortcut icon" href="/webim/images/favicon.ico" type="image/x-icon"/>
<title>
<?php echo getstring("app.title") ?> - <?php echo getstring("page_analysis.search.title") ?>
@ -30,10 +27,6 @@
<meta http-equiv="keywords" content="<?php echo getstring("page.main_layout.meta_keyword") ?>">
<meta http-equiv="description" content="<?php echo getstring("page.main_layout.meta_description") ?>">
</head>
<body bgcolor="#FFFFFF" text="#000000" link="#2971C1" vlink="#2971C1" alink="#2971C1">
@ -59,6 +52,7 @@
<tr>
<td class="formauth" colspan="3"><?php echo getstring("page_analysis.full.text.search") ?></td>
</tr>
<tr><td colspan="3" height="2"></td></tr>
<tr>
<td class="formauth"><input type="text" name="q" size="80" value="<?php echo form_value('q') ?>" class="formauth"/></td>
<td width="10"><img src="/webim/images/free.gif" width="10" height="1" border="0" alt=""></td>