mirror of
https://github.com/Mibew/tray.git
synced 2025-01-22 18:10:34 +03:00
Added short titles for canned messages
This commit is contained in:
parent
4ae2ea9a65
commit
6d87e5e1a6
@ -393,6 +393,13 @@ textarea.wide {
|
||||
width: 95%;
|
||||
}
|
||||
|
||||
input.wide {
|
||||
border: 1px solid #878787;
|
||||
color: #333;
|
||||
line-height: normal;
|
||||
width: 95%;
|
||||
}
|
||||
|
||||
input.formauth {
|
||||
border: 1px solid #878787;
|
||||
color: #333;
|
||||
|
@ -110,6 +110,7 @@ $dbtables = array(
|
||||
"id" => "INT NOT NULL auto_increment PRIMARY KEY",
|
||||
"locale" => "varchar(8)",
|
||||
"groupid" => "int references ${mysqlprefix}chatgroup(groupid)",
|
||||
"vctitle" => "varchar(100) NOT NULL DEFAULT ''",
|
||||
"vcvalue" => "varchar(1024) NOT NULL",
|
||||
),
|
||||
|
||||
@ -158,7 +159,7 @@ $dbtables_can_update = array(
|
||||
"${mysqlprefix}chatban" => array(),
|
||||
"${mysqlprefix}chatgroup" => array("vcemail"),
|
||||
"${mysqlprefix}chatgroupoperator" => array(),
|
||||
"${mysqlprefix}chatresponses" => array(),
|
||||
"${mysqlprefix}chatresponses" => array("vctitle"),
|
||||
"${mysqlprefix}chatsitevisitor" => array(),
|
||||
"${mysqlprefix}visitedpage" => array(),
|
||||
);
|
||||
|
@ -151,6 +151,10 @@ if ($act == "silentcreateall") {
|
||||
runsql("ALTER TABLE ${mysqlprefix}chatoperator ADD vcrestoretoken varchar(64)", $link);
|
||||
}
|
||||
|
||||
if (in_array("${mysqlprefix}chatresponses.vctitle", $absent)) {
|
||||
runsql("ALTER TABLE ${mysqlprefix}chatresponses ADD vctitle varchar(100) NOT NULL DEFAULT '' AFTER groupid", $link);
|
||||
}
|
||||
|
||||
if (in_array("${mysqlprefix}chatthread.groupid", $absent)) {
|
||||
runsql("ALTER TABLE ${mysqlprefix}chatthread ADD groupid int references ${mysqlprefix}chatgroup(groupid)", $link);
|
||||
}
|
||||
|
@ -258,23 +258,31 @@ function check_admin($link)
|
||||
|
||||
function add_canned_messages($link){
|
||||
global $mysqlprefix;
|
||||
$localesresult = mysql_query("select locale from ${mysqlprefix}chatresponses", $link);
|
||||
$existlocales = array();
|
||||
for ($i = 0; $i < mysql_num_rows($localesresult); $i++) {
|
||||
$existlocales[] = mysql_result($localesresult, $i, 'locale');
|
||||
}
|
||||
$result = array();
|
||||
foreach (get_available_locales() as $locale) {
|
||||
$result = array();
|
||||
foreach (explode("\n", getstring_('chat.predefined_answers', $locale)) as $answer) {
|
||||
$result[] = array('id' => '', 'vcvalue' => $answer);
|
||||
}
|
||||
if (count($result) > 0) {
|
||||
$updatequery = "insert into ${mysqlprefix}chatresponses (vcvalue,locale,groupid) values ";
|
||||
for ($i = 0; $i < count($result); $i++) {
|
||||
if ($i > 0) {
|
||||
$updatequery .= ", ";
|
||||
}
|
||||
$updatequery .= "('" . db_escape_string($result[$i]['vcvalue'], $link) . "','$locale', NULL)";
|
||||
if (! in_array($locale, $existlocales)) {
|
||||
foreach (explode("\n", getstring_('chat.predefined_answers', $locale)) as $answer) {
|
||||
$result[] = array('locale' => $locale, 'vctitle' => cutstring($answer, 97, '...'), 'vcvalue' => $answer);
|
||||
}
|
||||
mysql_query($updatequery, $link);
|
||||
}
|
||||
}
|
||||
return;
|
||||
if (count($result) > 0) {
|
||||
$updatequery = "insert into ${mysqlprefix}chatresponses (vctitle,vcvalue,locale,groupid) values ";
|
||||
for ($i = 0; $i < count($result); $i++) {
|
||||
if ($i > 0) {
|
||||
$updatequery .= ", ";
|
||||
}
|
||||
$updatequery .= "('" . mysql_real_escape_string($result[$i]['vctitle'], $link) . "', "
|
||||
. "'" . mysql_real_escape_string($result[$i]['vcvalue'], $link) . "', "
|
||||
. "'" . mysql_real_escape_string($result[$i]['locale'], $link) . "', NULL)";
|
||||
}
|
||||
mysql_query($updatequery, $link);
|
||||
}
|
||||
}
|
||||
|
||||
function check_status()
|
||||
|
@ -6,19 +6,19 @@
|
||||
License: http://mibew.org/license.php
|
||||
*/
|
||||
var FrameUtils={getDocument:function(a){return a.contentDocument?a.contentDocument:a.contentWindow?a.contentWindow.document:a.document?a.document:null},initFrame:function(a){var b=this.getDocument(a);b.open();b.write("<html><head>");b.write('<link rel="stylesheet" type="text/css" media="all" href="'+Chat.cssfile+'">');b.write("</head><body bgcolor='#FFFFFF' text='#000000' link='#C28400' vlink='#C28400' alink='#C28400'>");b.write("<table width='100%' cellspacing='0' cellpadding='0' border='0'><tr><td valign='top' class='message' id='content'></td></tr></table><a id='bottom' name='bottom'></a>");
|
||||
b.write("</body></html>");b.close();a.onload=function(){a.myHtml&&(FrameUtils.getDocument(a).getElementById("content").innerHTML+=a.myHtml,FrameUtils.scrollDown(a))}},insertIntoFrame:function(a,b){var c=this.getDocument(a).getElementById("content");if(c==null){if(!a.myHtml)a.myHtml="";a.myHtml+=b}else c.innerHTML+=b},scrollDown:function(a){var b=this.getDocument(a).getElementById("bottom");if(myAgent=="opera")try{a.contentWindow.scrollTo(0,this.getDocument(a).getElementById("content").clientHeight)}catch(c){}b&&
|
||||
b.write("</body></html>");b.close();a.onload=function(){a.myHtml&&(FrameUtils.getDocument(a).getElementById("content").innerHTML+=a.myHtml,FrameUtils.scrollDown(a))}},insertIntoFrame:function(a,b){var c=this.getDocument(a).getElementById("content");if(null==c){if(!a.myHtml)a.myHtml="";a.myHtml+=b}else c.innerHTML+=b},scrollDown:function(a){var b=this.getDocument(a).getElementById("bottom");if("opera"==myAgent)try{a.contentWindow.scrollTo(0,this.getDocument(a).getElementById("content").clientHeight)}catch(c){}b&&
|
||||
b.scrollIntoView(!1)}};Ajax.ChatThreadUpdater=Class.create();
|
||||
Class.inherit(Ajax.ChatThreadUpdater,Ajax.Base,{initialize:function(a){this.setOptions(a);this._options.onComplete=this.requestComplete.bind(this);this._options.onException=this.handleException.bind(this);this._options.onTimeout=this.handleTimeout.bind(this);this._options.timeout=5E3;this.updater={};this.frequency=this._options.frequency||2;this.lastupdate=0;this.focused=this.skipNextsound=this.cansend=!0;this.ownThread=this._options.message!=null;FrameUtils.initFrame(this._options.container);if(this._options.message)this._options.message.onkeydown=
|
||||
Class.inherit(Ajax.ChatThreadUpdater,Ajax.Base,{initialize:function(a){this.setOptions(a);this._options.onComplete=this.requestComplete.bind(this);this._options.onException=this.handleException.bind(this);this._options.onTimeout=this.handleTimeout.bind(this);this._options.timeout=5E3;this.updater={};this.frequency=this._options.frequency||2;this.lastupdate=0;this.focused=this.skipNextsound=this.cansend=!0;this.ownThread=null!=this._options.message;FrameUtils.initFrame(this._options.container);if(this._options.message)this._options.message.onkeydown=
|
||||
this.handleKeyDown.bind(this),this._options.message.onfocus=function(){this.focused=!0}.bind(this),this._options.message.onblur=function(){this.focused=!1}.bind(this);this.update()},handleException:function(){this.setStatus("offline, reconnecting");this.stopUpdate();this.timer=setTimeout(this.update.bind(this),1E3)},handleTimeout:function(){this.setStatus("timeout, reconnecting");this.stopUpdate();this.timer=setTimeout(this.update.bind(this),1E3)},updateOptions:function(a){this._options.parameters=
|
||||
"act="+a+"&thread="+(this._options.threadid||0)+"&token="+(this._options.token||0)+"&lastid="+(this._options.lastid||0);this._options.user&&(this._options.parameters+="&user=true");a=="refresh"&&this._options.message&&this._options.message.value!=""&&(this._options.parameters+="&typed=1")},enableInput:function(a){if(this._options.message)this._options.message.disabled=!a},stopUpdate:function(){this.enableInput(!0);if(this.updater._options)this.updater._options.onComplete=void 0;clearTimeout(this.timer)},
|
||||
update:function(){this.updateOptions("refresh");this.updater=new Ajax.Request(this._options.servl,this._options)},requestComplete:function(a){try{this.enableInput(!0);this.cansend=!0;var b=Ajax.getXml(a);b&&b.tagName=="thread"?this.updateContent(b):this.handleError(a,b,"refresh messages failed")}catch(c){}this.skipNextsound=!1;this.timer=setTimeout(this.update.bind(this),this.frequency*1E3)},postMessage:function(a){if(a!=""&&this.cansend){this.cansend=!1;this.stopUpdate();this.skipNextsound=!0;this.updateOptions("post");
|
||||
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(){if(!confirm(localized[0]))return!1;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!=""?'<img src="'+Chat.webimRoot+'/images/free.gif" width="7" height="1" border="0" alt="" /><img src="'+a+'" border="0" alt=""/>':""},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<a.childNodes.length;d++){var f=a.childNodes[d];f.tagName=="message"?(b=!0,this.processMessage(c,f)):f.tagName=="avatar"&&this.setupAvatar(f)}window.location.search.indexOf("trace=on")>=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"}};
|
||||
Behaviour.register({"#postmessage a":function(a){a.onclick=function(){var a=$("msgwnd");a&&Chat.threadUpdater.postMessage(a.value)}},"select#predefined":function(a){a.onchange=function(){var a=$("msgwnd");if(this.selectedIndex!=0)a.value=this.options[this.selectedIndex].innerText||this.options[this.selectedIndex].innerHTML;this.selectedIndex=0;a.focus()}},"div#changename2 a":function(a){a.onclick=function(){Chat.showNameField();return!1}},"div#changename1 a":function(a){a.onclick=function(){Chat.applyName();
|
||||
return!1}},"div#changename1 input#uname":function(a){a.onkeydown=function(a){(a||event).keyCode==13&&Chat.applyName()}},"a#refresh":function(a){a.onclick=function(){Chat.threadUpdater.stopUpdate();Chat.threadUpdater.update()}},"a#togglesound":function(a){a.onclick=function(){var a=$("soundimg");if(a)a.className=a.className.match(/\bisound\b/)?"tplimage inosound":"tplimage isound",(a=$("msgwnd"))&&a.focus()}},"a.closethread":function(a){a.onclick=function(){Chat.threadUpdater.closeThread()}}});
|
||||
EventHelper.register(window,"onload",function(){Chat.webimRoot=threadParams.wroot;Chat.cssfile=threadParams.cssfile;Chat.threadUpdater=new Ajax.ChatThreadUpdater({ignorectrl:-1,container:myRealAgent=="safari"?self.frames[0]:$("chatwnd"),avatar:$("avatarwnd"),message:$("msgwnd")}.extend(threadParams||{}))});
|
||||
"act="+a+"&thread="+(this._options.threadid||0)+"&token="+(this._options.token||0)+"&lastid="+(this._options.lastid||0);this._options.user&&(this._options.parameters+="&user=true");"refresh"==a&&this._options.message&&""!=this._options.message.value&&(this._options.parameters+="&typed=1")},enableInput:function(a){if(this._options.message)this._options.message.disabled=!a},stopUpdate:function(){this.enableInput(!0);if(this.updater._options)this.updater._options.onComplete=void 0;clearTimeout(this.timer)},
|
||||
update:function(){this.updateOptions("refresh");this.updater=new Ajax.Request(this._options.servl,this._options)},requestComplete:function(a){try{this.enableInput(!0);this.cansend=!0;var b=Ajax.getXml(a);b&&"thread"==b.tagName?this.updateContent(b):this.handleError(a,b,"refresh messages failed")}catch(c){}this.skipNextsound=!1;this.timer=setTimeout(this.update.bind(this),1E3*this.frequency)},postMessage:function(a){if(""!=a&&this.cansend){this.cansend=!1;this.stopUpdate();this.skipNextsound=!0;this.updateOptions("post");
|
||||
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);"opera"!=myRealAgent&&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&&"closed"==b.tagName?setTimeout("window.close()",2E3):this.handleError(a,b,"cannot close")},closeThread:function(){if(!confirm(localized[0]))return!1;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?'<img src="'+Chat.webimRoot+'/images/free.gif" width="7" height="1" border="0" alt="" /><img src="'+a+'" border="0" alt=""/>':""},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("1"==d);if((d=NodeUtils.getAttrValue(a,"canpost"))&&("1"==d&&!this.ownThread||this.ownThread&&"1"!=d))window.location.href=window.location.href;for(d=0;d<a.childNodes.length;d++){var e=a.childNodes[d];"message"==e.tagName?(b=!0,this.processMessage(c,e)):"avatar"==e.tagName&&this.setupAvatar(e)}0<=window.location.search.indexOf("trace=on")?(a="updated",0<this.lastupdate&&(c=((new Date).getTime()-this.lastupdate)/1E3,a=a+", "+c+" secs",10<c&&
|
||||
alert(a)),this.lastupdate=(new Date).getTime(),this.setStatus(a)):this.clearStatus();b&&(FrameUtils.scrollDown(this._options.container),this.skipNextsound||(b=$("soundimg"),(null==b||b.className.match(/\bisound\b/))&&playSound(Chat.webimRoot+"/sounds/new_message.wav")),this.focused||window.focus())},isSendkey:function(a,b){return 13==b&&(a||this._options.ignorectrl)||10==b},handleKeyDown:function(a){a?(ctrl=a.ctrlKey,a=a.which):(a=event.keyCode,ctrl=event.ctrlKey);return this._options.message&&this.isSendkey(ctrl,
|
||||
a)?(a=this._options.message.value,this._options.ignorectrl&&(a=a.replace(/[\r\n]+$/,"")),this.postMessage(a),!1):!0},handleError:function(a,b){b&&"error"==b.tagName?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"}};
|
||||
Behaviour.register({"#postmessage a":function(a){a.onclick=function(){var a=$("msgwnd");a&&Chat.threadUpdater.postMessage(a.value)}},"select#predefined":function(a){a.onchange=function(){var a=$("msgwnd");if(0!=this.selectedIndex)a.value=Chat.predefinedAnswers[this.selectedIndex-1];this.selectedIndex=0;a.focus()}},"div#changename2 a":function(a){a.onclick=function(){Chat.showNameField();return!1}},"div#changename1 a":function(a){a.onclick=function(){Chat.applyName();return!1}},"div#changename1 input#uname":function(a){a.onkeydown=
|
||||
function(a){13==(a||event).keyCode&&Chat.applyName()}},"a#refresh":function(a){a.onclick=function(){Chat.threadUpdater.stopUpdate();Chat.threadUpdater.update()}},"a#togglesound":function(a){a.onclick=function(){var a=$("soundimg");if(a)a.className=a.className.match(/\bisound\b/)?"tplimage inosound":"tplimage isound",(a=$("msgwnd"))&&a.focus()}},"a.closethread":function(a){a.onclick=function(){Chat.threadUpdater.closeThread()}}});
|
||||
EventHelper.register(window,"onload",function(){Chat.webimRoot=threadParams.wroot;Chat.cssfile=threadParams.cssfile;Chat.predefinedAnswers="undefined"!=typeof predefinedAnswers?predefinedAnswers:[];Chat.threadUpdater=new Ajax.ChatThreadUpdater({ignorectrl:-1,container:"safari"==myRealAgent?self.frames[0]:$("chatwnd"),avatar:$("avatarwnd"),message:$("msgwnd")}.extend(threadParams||{}))});
|
@ -338,7 +338,7 @@ Behaviour.register({
|
||||
el.onchange = function() {
|
||||
var message = $('msgwnd');
|
||||
if(this.selectedIndex!=0) {
|
||||
message.value = this.options[this.selectedIndex].innerText || this.options[this.selectedIndex].innerHTML;
|
||||
message.value = Chat.predefinedAnswers[this.selectedIndex-1];
|
||||
}
|
||||
this.selectedIndex = 0;
|
||||
message.focus();
|
||||
@ -396,5 +396,6 @@ Behaviour.register({
|
||||
EventHelper.register(window, 'onload', function(){
|
||||
Chat.webimRoot = threadParams.wroot;
|
||||
Chat.cssfile = threadParams.cssfile;
|
||||
Chat.predefinedAnswers = (typeof predefinedAnswers != 'undefined')?predefinedAnswers:Array();
|
||||
Chat.threadUpdater = new Ajax.ChatThreadUpdater(({ignorectrl:-1,container:myRealAgent=='safari'?self.frames[0]:$("chatwnd"),avatar:$("avatarwnd"),message:$("msgwnd")}).extend( threadParams || {} ));
|
||||
});
|
@ -23,7 +23,7 @@ function load_canned_messages($locale, $groupid)
|
||||
{
|
||||
global $mysqlprefix;
|
||||
$link = connect();
|
||||
$query = "select id, vcvalue from ${mysqlprefix}chatresponses " .
|
||||
$query = "select id, vctitle, vcvalue from ${mysqlprefix}chatresponses " .
|
||||
"where locale = '" . $locale . "' AND (" .
|
||||
($groupid
|
||||
? "groupid = $groupid"
|
||||
@ -38,27 +38,29 @@ function load_canned_message($key)
|
||||
{
|
||||
global $mysqlprefix;
|
||||
$link = connect();
|
||||
$result = select_one_row("select vcvalue from ${mysqlprefix}chatresponses where id = $key", $link);
|
||||
$result = select_one_row("select vctitle, vcvalue from ${mysqlprefix}chatresponses where id = $key", $link);
|
||||
close_connection($link);
|
||||
return $result ? $result['vcvalue'] : null;
|
||||
return $result ? $result : null;
|
||||
}
|
||||
|
||||
function save_canned_message($key, $message)
|
||||
function save_canned_message($key, $title, $message)
|
||||
{
|
||||
global $mysqlprefix;
|
||||
$link = connect();
|
||||
perform_query("update ${mysqlprefix}chatresponses set vcvalue = '" . db_escape_string($message, $link) . "' " .
|
||||
"where id = $key", $link);
|
||||
perform_query("update ${mysqlprefix}chatresponses set vcvalue = '" . db_escape_string($message, $link) . "', " .
|
||||
"vctitle = '" . db_escape_string($title, $link) . "' " .
|
||||
"where id = $key", $link);
|
||||
close_connection($link);
|
||||
}
|
||||
|
||||
function add_canned_message($locale, $groupid, $message)
|
||||
function add_canned_message($locale, $groupid, $title, $message)
|
||||
{
|
||||
global $mysqlprefix;
|
||||
$link = connect();
|
||||
perform_query("insert into ${mysqlprefix}chatresponses (locale,groupid,vcvalue) values ('$locale'," .
|
||||
($groupid ? "$groupid, " : "null, ") .
|
||||
"'" . db_escape_string($message, $link) . "')", $link);
|
||||
perform_query("insert into ${mysqlprefix}chatresponses (locale,groupid,vctitle,vcvalue) values ('$locale'," .
|
||||
($groupid ? "$groupid, " : "null, ") .
|
||||
"'" . db_escape_string($title, $link) . "', " .
|
||||
"'" . db_escape_string($message, $link) . "')", $link);
|
||||
close_connection($link);
|
||||
}
|
||||
|
||||
|
@ -401,7 +401,7 @@ function setup_chatview_for_user($thread, $level)
|
||||
|
||||
function setup_chatview_for_operator($thread, $operator)
|
||||
{
|
||||
global $page, $webimroot, $company_logo_link, $company_name, $settings;
|
||||
global $page, $webimroot, $company_logo_link, $webim_encoding, $company_name, $settings;
|
||||
loadsettings();
|
||||
$page = array();
|
||||
$page['agent'] = true;
|
||||
@ -445,9 +445,11 @@ function setup_chatview_for_operator($thread, $operator)
|
||||
);
|
||||
};
|
||||
foreach ($canned_messages as $answer) {
|
||||
$predefinedres .= "<option>" . htmlspecialchars(topage($answer['vcvalue'])) . "</option>";
|
||||
$predefinedres .= "<option>" . htmlspecialchars(topage($answer['vctitle']?$answer['vctitle']:cutstring($answer['vcvalue'], 97, '...'))) . "</option>";
|
||||
$fullAnswers[] = myiconv($webim_encoding, getoutputenc(), $answer['vcvalue']);
|
||||
}
|
||||
$page['predefinedAnswers'] = $predefinedres;
|
||||
$page['fullPredefinedAnswers'] = json_encode($fullAnswers);
|
||||
$params = "thread=" . $thread['threadid'] . "&token=" . $thread['ltoken'];
|
||||
$page['redirectLink'] = "$webimroot/operator/agent.php?" . $params . "&act=redirect";
|
||||
|
||||
|
@ -342,6 +342,18 @@ function getgetparam($name, $default = '')
|
||||
return $value;
|
||||
}
|
||||
|
||||
function cutstring($string, $length = 75, $ellipsis = '')
|
||||
{
|
||||
$result = '';
|
||||
if (strlen($string) > $length) {
|
||||
$splitstring = explode("[__cut__]", wordwrap($string, $length, "[__cut__]", true));
|
||||
$result = $splitstring[0] . $ellipsis;
|
||||
}else{
|
||||
$result = $string;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
function connect()
|
||||
{
|
||||
global $mysqlhost, $mysqllogin, $mysqlpass, $mysqldb, $dbencoding, $force_charset_in_connection, $use_persistent_connection;
|
||||
|
@ -26,6 +26,7 @@ canned.add=Add message...
|
||||
canned.descr=Edit messages that you frequently type into the chat.
|
||||
canned.group=For group:
|
||||
canned.locale=For language:
|
||||
canned.message_title=Title
|
||||
canned.title=Canned Messages
|
||||
cannededit.descr=Edit an existing message.
|
||||
cannededit.done=Saved
|
||||
@ -162,6 +163,7 @@ form.field.password.description=Enter a new password or leave the field empty to
|
||||
form.field.password=Password
|
||||
form.field.password_confirm.description=Confirm new password.
|
||||
form.field.password_confirm=Confirmation
|
||||
form.field.title=Title
|
||||
form.field.translation=Translation
|
||||
harderrors.header=<b>Cannot execute:</b><br/><ul>
|
||||
image.button.login=/locales/en/images/login.gif
|
||||
|
@ -26,6 +26,7 @@ canned.add=
|
||||
canned.descr=Создавайте текстовые сообщения, которыми будете часто пользоваться в чате.
|
||||
canned.group=Для группы:
|
||||
canned.locale=Для языка:
|
||||
canned.message_title=Çàãîëîâîê
|
||||
canned.title=Шаблоны ответов
|
||||
cannededit.descr=Отредактируйте существующее сообщение.
|
||||
cannededit.done=Сохранено
|
||||
@ -161,6 +162,7 @@ form.field.password.description=
|
||||
form.field.password=Пароль
|
||||
form.field.password_confirm.description=Подтвердите введенный пароль.
|
||||
form.field.password_confirm=Подтверждение
|
||||
form.field.title=Çàãîëîâîê
|
||||
form.field.translation=Текст перевода
|
||||
harderrors.header=<b>Невозможно выполнить:</b><br/><ul>
|
||||
image.button.login=/locales/ru/images/login.gif
|
||||
|
@ -33,19 +33,28 @@ $errors = array();
|
||||
$page = array();
|
||||
|
||||
if ($stringid) {
|
||||
$message = load_canned_message($stringid);
|
||||
if (!$message) {
|
||||
$canned_message = load_canned_message($stringid);
|
||||
if (!$canned_message) {
|
||||
$errors[] = getlocal("cannededit.no_such");
|
||||
$stringid = "";
|
||||
}else{
|
||||
$title = $canned_message['vctitle'];
|
||||
$message = $canned_message['vcvalue'];
|
||||
}
|
||||
} else {
|
||||
$message = "";
|
||||
$message = '';
|
||||
$title = '';
|
||||
$page['locale'] = verifyparam("lang", "/^[\w-]{2,5}$/", "");
|
||||
$page['groupid'] = "";
|
||||
$page['groupid'] = verifyparam("group", "/^\d{0,8}$/");
|
||||
}
|
||||
|
||||
if (isset($_POST['message'])) {
|
||||
if (isset($_POST['message']) && isset($_POST['title'])) {
|
||||
$title = getparam('title');
|
||||
if (!$title) {
|
||||
$errors[] = no_field("form.field.title");
|
||||
}
|
||||
|
||||
$message = getparam('message');
|
||||
if (!$message) {
|
||||
$errors[] = no_field("form.field.message");
|
||||
@ -53,9 +62,9 @@ if (isset($_POST['message'])) {
|
||||
|
||||
if (count($errors) == 0) {
|
||||
if ($stringid) {
|
||||
save_canned_message($stringid, $message);
|
||||
save_canned_message($stringid, $title, $message);
|
||||
} else {
|
||||
add_canned_message($page['locale'], $page['groupid'], $message);
|
||||
add_canned_message($page['locale'], $page['groupid'], $title, $message);
|
||||
}
|
||||
$page['saved'] = true;
|
||||
prepare_menu($operator, false);
|
||||
@ -67,6 +76,7 @@ if (isset($_POST['message'])) {
|
||||
|
||||
$page['saved'] = false;
|
||||
$page['key'] = $stringid;
|
||||
$page['formtitle'] = topage($title);
|
||||
$page['formmessage'] = topage($message);
|
||||
prepare_menu($operator, false);
|
||||
start_html_output();
|
||||
|
@ -10,6 +10,9 @@
|
||||
var localized = new Array(
|
||||
"${page:chat.close.confirmation}"
|
||||
);
|
||||
${if:agent}${if:canpost}
|
||||
var predefinedAnswers = ${page:fullPredefinedAnswers};
|
||||
${endif:canpost}${endif:agent}
|
||||
var threadParams = { servl:"${webimroot}/thread.php",wroot:"${webimroot}",frequency:${page:frequency},${if:user}user:"true",${endif:user}threadid:${page:ct.chatThreadId},token:${page:ct.token},cssfile:"${tplroot}/chat.css",ignorectrl:${page:ignorectrl} };
|
||||
//-->
|
||||
</script>
|
||||
|
@ -10,6 +10,9 @@
|
||||
var localized = new Array(
|
||||
"${page:chat.close.confirmation}"
|
||||
);
|
||||
${if:agent}${if:canpost}
|
||||
var predefinedAnswers = ${page:fullPredefinedAnswers};
|
||||
${endif:canpost}${endif:agent}
|
||||
var threadParams = { servl:"${webimroot}/thread.php",wroot:"${webimroot}",frequency:${page:frequency},${if:user}user:"true",${endif:user}threadid:${page:ct.chatThreadId},token:${page:ct.token},cssfile:"${tplroot}/chat.css",ignorectrl:${page:ignorectrl} };
|
||||
//-->
|
||||
</script>
|
||||
|
@ -12,6 +12,9 @@
|
||||
var localized = new Array(
|
||||
"${page:chat.close.confirmation}"
|
||||
);
|
||||
${if:agent}${if:canpost}
|
||||
var predefinedAnswers = ${page:fullPredefinedAnswers};
|
||||
${endif:canpost}${endif:agent}
|
||||
var threadParams = {
|
||||
servl:"${webimroot}/thread.php",wroot:"${webimroot}",frequency:${page:frequency},${if:user}user:"true",${endif:user}threadid:${page:ct.chatThreadId},token:${page:ct.token},cssfile:"${tplroot}/chat.css",ignorectrl:${page:ignorectrl}
|
||||
};
|
||||
|
@ -10,6 +10,9 @@
|
||||
var localized = new Array(
|
||||
"${page:chat.close.confirmation}"
|
||||
);
|
||||
${if:agent}${if:canpost}
|
||||
var predefinedAnswers = ${page:fullPredefinedAnswers};
|
||||
${endif:canpost}${endif:agent}
|
||||
var threadParams = { servl:"${webimroot}/thread.php",wroot:"${webimroot}",frequency:${page:frequency},${if:user}user:"true",${endif:user}threadid:${page:ct.chatThreadId},token:${page:ct.token},cssfile:"${tplroot}/chat.css",ignorectrl:${page:ignorectrl} };
|
||||
//-->
|
||||
</script>
|
||||
|
@ -74,6 +74,8 @@ require_once('inc_errors.php');
|
||||
<table class="translate">
|
||||
<thead>
|
||||
<tr class="header"><th>
|
||||
<?php echo getlocal("canned.message_title") ?>
|
||||
</th><th>
|
||||
<?php echo getlocal("cannededit.message") ?>
|
||||
</th><th>
|
||||
<?php echo getlocal("canned.actions") ?>
|
||||
@ -84,6 +86,9 @@ require_once('inc_errors.php');
|
||||
if( $page['pagination.items'] ) {
|
||||
foreach( $page['pagination.items'] as $localstr ) { ?>
|
||||
<tr>
|
||||
<td>
|
||||
<?php echo str_replace("\n", "", htmlspecialchars(topage($localstr['vctitle']))) ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php echo str_replace("\n", "<br/>",htmlspecialchars(topage($localstr['vcvalue']))) ?>
|
||||
</td>
|
||||
|
@ -52,6 +52,13 @@ require_once('inc_errors.php');
|
||||
<div class="mform"><div class="formtop"><div class="formtopi"></div></div><div class="forminner">
|
||||
|
||||
<div class="fieldForm">
|
||||
<div class="field">
|
||||
<div class="flabel"><?php echo getlocal("canned.message_title") ?></div>
|
||||
<div class="fvaluenodesc">
|
||||
<input type="text" name="title" class="wide" maxlength="100" value="<?php echo form_value('title') ?>"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<div class="flabel"><?php echo getlocal("cannededit.message") ?></div>
|
||||
<div class="fvaluenodesc">
|
||||
|
Loading…
Reference in New Issue
Block a user