diff --git a/src/messenger/webim/client.php b/src/messenger/webim/client.php index 612030bb..936a09f4 100644 --- a/src/messenger/webim/client.php +++ b/src/messenger/webim/client.php @@ -25,6 +25,7 @@ require_once('libs/operator.php'); require_once('libs/groups.php'); require_once('libs/expand.php'); require_once('libs/captcha.php'); +require_once('libs/invitation.php'); loadsettings(); if($settings['enablessl'] == "1" && $settings['forcessl'] == "1") { @@ -114,7 +115,14 @@ if( !isset($_GET['token']) || !isset($_GET['thread']) ) { } $thread = create_thread($groupid,$visitor['name'], $remoteHost, $referrer,$current_locale,$visitor['id'], $userbrowser,$state_loading,$link); $_SESSION['threadid'] = $thread['threadid']; - + + $operator = invitation_accept($_SESSION['visitorid'], $thread['threadid'], $link); + if ($operator) { + $operator = operator_by_id_($operator, $link); + $operatorName = ($current_locale == $home_locale) ? $operator['vclocalename'] : $operator['vccommonname']; + post_message_($thread['threadid'], $kind_for_agent, getstring2('chat.visitor.invitation.accepted', array($operatorName)), $link); + } + if( $referrer ) { post_message_($thread['threadid'],$kind_for_agent,getstring2('chat.came.from',array($referrer)),$link); } diff --git a/src/messenger/webim/default.css b/src/messenger/webim/default.css index da66fc0a..2625fea5 100644 --- a/src/messenger/webim/default.css +++ b/src/messenger/webim/default.css @@ -899,3 +899,17 @@ table.awaiting td.visitor { float:left; padding-left:10px; } + +/* invitation wait */ + +.ajaxWait { + z-index: -1; + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + background-image: url(images/ajax-loader.gif); + background-repeat: no-repeat; + background-position: center; +} diff --git a/src/messenger/webim/images/ajax-loader.gif b/src/messenger/webim/images/ajax-loader.gif new file mode 100644 index 00000000..2f6eff25 Binary files /dev/null and b/src/messenger/webim/images/ajax-loader.gif differ diff --git a/src/messenger/webim/images/tblictrack.gif b/src/messenger/webim/images/tblictrack.gif new file mode 100644 index 00000000..c0bf7f1f Binary files /dev/null and b/src/messenger/webim/images/tblictrack.gif differ diff --git a/src/messenger/webim/install/dbinfo.php b/src/messenger/webim/install/dbinfo.php index 502cf682..919effb9 100644 --- a/src/messenger/webim/install/dbinfo.php +++ b/src/messenger/webim/install/dbinfo.php @@ -109,7 +109,24 @@ $dbtables = array( "locale" => "varchar(8)", "groupid" => "int references ${mysqlprefix}chatgroup(groupid)", "vcvalue" => "varchar(1024) NOT NULL", - ) + ), + + "${mysqlprefix}chatsitevisitor" => array( + "visitorid" => "INT NOT NULL auto_increment PRIMARY KEY", + "userid" => "varchar(64) NOT NULL", + "username" => "varchar(255)", + "firsttime" => "datetime NOT NULL DEFAULT 0", + "lasttime" => "datetime NOT NULL DEFAULT 0", + "entry" => "text NOT NULL", + "path" => "text NOT NULL", + "details" => "text NOT NULL", + "invited" => "tinyint(1) NOT NULL DEFAULT 0", + "invitationtime" => "datetime", + "invitedby" => "INT references ${mysqlprefix}chatoperator(operatorid) on delete set null", + "invitations" => "INT NOT NULL DEFAULT 0", + "chats" => "INT NOT NULL DEFAULT 0", + "threadid" => "INT references ${mysqlprefix}chatthread(threadid) on delete set null" + ), ); $memtables = array(); @@ -122,6 +139,7 @@ $dbtables_can_update = array( "${mysqlprefix}chatgroup" => array("vcemail"), "${mysqlprefix}chatgroupoperator" => array(), "${mysqlprefix}chatresponses" => array(), + "${mysqlprefix}chatsitevisitor" => array(), ); function show_install_err($text) diff --git a/src/messenger/webim/install/dbperform.php b/src/messenger/webim/install/dbperform.php index 9f5c3ae8..c5e5d118 100644 --- a/src/messenger/webim/install/dbperform.php +++ b/src/messenger/webim/install/dbperform.php @@ -158,6 +158,11 @@ if ($act == "silentcreateall") { if ($res && mysql_num_rows($res) == 0) { runsql("ALTER TABLE ${mysqlprefix}chatmessage ADD INDEX idx_agentid (agentid)", $link); } + + $res = mysql_query("select null from information_schema.statistics where table_name = '${mysqlprefix}chatsitevisitor' and index_name = 'threadid'", $link); + if ($res && mysql_num_rows($res) == 0) { + runsql("ALTER TABLE ${mysqlprefix}chatsitevisitor ADD INDEX (threadid)", $link); + } } } diff --git a/src/messenger/webim/invite.css b/src/messenger/webim/invite.css new file mode 100644 index 00000000..ef968af0 --- /dev/null +++ b/src/messenger/webim/invite.css @@ -0,0 +1,65 @@ +/* + This file is part of Mibew Messenger project. + + Copyright (c) 2005-2011 Mibew Messenger Community + 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 + + 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. +*/ + +#mibewinvitationpopup { + border: 1px solid #aaa; + background-color: #ddd; + padding: 5px; + position: fixed; + top: 50%; + left: 0; + width: 400px; +} + +#mibewinvitationpopup h1, #mibewinvitationpopup p, #mibewinvitationclose a { + cursor: pointer; +} + +#mibewinvitationclose { + float: right; + background-color: red; + padding: 1px; + margin: 0; +} + +#mibewinvitationclose a { + font-family: "Trebuchet MS", Arial, Helvetica, sans-serif; + font-size: 20px; + font-weight: bold; + color: white; + margin: 0 4px 0 4px; +} + +#mibewinvitationclose a, #mibewinvitationclose a:link, #mibewinvitationclose a:hover { + text-decoration: none; +} + +#mibewinvitationpopup h1 { + text-align: center; +} + +#mibewinvitationpopup p { + padding: 2px; + margin: 2px; +} + +#mibewinvitationavatar { + margin: 2px; + margin-right: 5px; + cursor: pointer; + float: left; +} diff --git a/src/messenger/webim/invite.php b/src/messenger/webim/invite.php new file mode 100644 index 00000000..9c0471c1 --- /dev/null +++ b/src/messenger/webim/invite.php @@ -0,0 +1,68 @@ +" . htmlspecialchars($operatorName) . "" . getlocal("invitation.message") . "" . htmlspecialchars($operator['vcavatar']) . ""; +} +else { + echo ""; +} + +exit; +?> \ No newline at end of file diff --git a/src/messenger/webim/js/164/chat.js b/src/messenger/webim/js/164/chat.js index 479d2ba9..c29c3d2f 100644 --- a/src/messenger/webim/js/164/chat.js +++ b/src/messenger/webim/js/164/chat.js @@ -15,7 +15,7 @@ update:function(){this.updateOptions("refresh");this.updater=new Ajax.Request(th var b={}.extend(this._options);b.parameters+="&message="+encodeURIComponent(a);b.onComplete=function(a){this.requestComplete(a);if(this._options.message)this._options.message.value="",this._options.message.focus()}.bind(this);myRealAgent!="opera"&&this.enableInput(!1);this.updater=new Ajax.Request(this._options.servl,b)}},changeName:function(a){this.skipNextsound=!0;new Ajax.Request(this._options.servl,{parameters:"act=rename&thread="+(this._options.threadid||0)+"&token="+(this._options.token||0)+ "&name="+encodeURIComponent(a)})},onThreadClosed:function(a){var b=Ajax.getXml(a);b&&b.tagName=="closed"?setTimeout("window.close()",2E3):this.handleError(a,b,"cannot close")},closeThread:function(){var a="act=close&thread="+(this._options.threadid||0)+"&token="+(this._options.token||0);this._options.user&&(a+="&user=true");new Ajax.Request(this._options.servl,{parameters:a,onComplete:this.onThreadClosed.bind(this)})},processMessage:function(a,b){var c=NodeUtils.getNodeText(b);FrameUtils.insertIntoFrame(a, c)},showTyping:function(a){if($("typingdiv"))$("typingdiv").style.display=a?"inline":"none"},setupAvatar:function(a){a=NodeUtils.getNodeText(a);if(this._options.avatar&&this._options.user)this._options.avatar.innerHTML=a!=""?'':""},updateContent:function(a){var b=!1,c=this._options.container,d=NodeUtils.getAttrValue(a,"lastid");if(d)this._options.lastid=d;(d=NodeUtils.getAttrValue(a, -"typing"))&&this.showTyping(d=="1");if((d=NodeUtils.getAttrValue(a,"canpost"))&&(d=="1"&&!this.ownThread||this.ownThread&&d!="1"))window.location.href=window.location.href;for(d=0;d=0?(a="updated",this.lastupdate>0&&(c=((new Date).getTime()-this.lastupdate)/1E3,a=a+", "+c+" secs",c>10&&alert(a)),this.lastupdate=(new Date).getTime(), +"typing"))&&this.showTyping(d=="1");if((d=NodeUtils.getAttrValue(a,"canpost"))&&(d=="1"&&!this.ownThread||this.ownThread&&d!="1"))window.location.href=window.location.href;for(d=0;d=0?(a="updated",this.lastupdate>0&&(c=((new Date).getTime()-this.lastupdate)/1E3,a=a+", "+c+" secs",c>10&&alert(a)),this.lastupdate=(new Date).getTime(), this.setStatus(a)):this.clearStatus();b&&(FrameUtils.scrollDown(this._options.container),this.skipNextsound||(b=$("soundimg"),(b==null||b.className.match(/\bisound\b/))&&playSound(Chat.webimRoot+"/sounds/new_message.wav")),this.focused||window.focus())},isSendkey:function(a,b){return b==13&&(a||this._options.ignorectrl)||b==10},handleKeyDown:function(a){a?(ctrl=a.ctrlKey,a=a.which):(a=event.keyCode,ctrl=event.ctrlKey);if(this._options.message&&this.isSendkey(ctrl,a))return a=this._options.message.value, this._options.ignorectrl&&(a=a.replace(/[\r\n]+$/,"")),this.postMessage(a),!1;return!0},handleError:function(a,b){b&&b.tagName=="error"?this.setStatus(NodeUtils.getNodeValue(b,"descr")):this.setStatus("reconnecting")},showStatusDiv:function(a){if($("engineinfo"))$("engineinfo").style.display="inline",$("engineinfo").innerHTML=a},setStatus:function(a){this.statusTimeout&&clearTimeout(this.statusTimeout);this.showStatusDiv(a);this.statusTimeout=setTimeout(this.clearStatus.bind(this),4E3)},clearStatus:function(){$("engineinfo").style.display= "none"}});var Chat={threadUpdater:{},applyName:function(){Chat.threadUpdater.changeName($("uname").value);$("changename1").style.display="none";$("changename2").style.display="inline";$("unamelink").innerHTML=htmlescape($("uname").value)},showNameField:function(){$("changename1").style.display="inline";$("changename2").style.display="none"}}; diff --git a/src/messenger/webim/js/164/common.js b/src/messenger/webim/js/164/common.js index a1cb644b..4355c244 100644 --- a/src/messenger/webim/js/164/common.js +++ b/src/messenger/webim/js/164/common.js @@ -18,8 +18,8 @@ setTimeout(this.handleTimeout.bind(this),this._options.timeout);this.setRequestH clearTimeout(this.transportTimer),(this._options.onComplete||Ajax.emptyFunction)(this.transport)}catch(b){this.dispatchException(b)}this.transport.onreadystatechange=Ajax.emptyFunction}},dispatchException:function(a){(this._options.onException||Ajax.emptyFunction)(this,a)}}); var EventHelper={register:function(a,b,c){var d=a[b];a[b]=typeof d!="function"?c:function(){d();c()}}},Behaviour={list:[],register:function(a){Behaviour.list.push(a)},init:function(){EventHelper.register(window,"onload",function(){Behaviour.apply()})},apply:function(){for(h=0;sheet=Behaviour.list[h];h++)for(selector in sheet)if(list=document.getElementsBySelector(selector))for(i=0;element=list[i];i++)sheet[selector](element)}};Behaviour.init(); function getAllChildren(a){return a.all?a.all:a.getElementsByTagName("*")} -document.getElementsBySelector=function(a){if(!document.getElementsByTagName)return[];for(var a=a.split(" "),b=Array(document),c=0;c-1){var d=token.split("#"),e=d[0],b=document.getElementById(d[1]);if(b==null||e&&b.nodeName.toLowerCase()!=e)return[];b=Array(b)}else if(token.indexOf(".")>-1){d=token.split(".");e=d[0];d=d[1];e||(e="*");for(var l=[],j=0,n=0;n-1){var d=token.split("#"),f=d[0],b=document.getElementById(d[1]);if(b==null||f&&b.nodeName.toLowerCase()!=f)return[];b=Array(b)}else if(token.indexOf(".")>-1){d=token.split(".");f=d[0];d=d[1];f||(f="*");for(var g=[],j=0,n=0;n