diff --git a/src/messenger/webim/js/compiled/widget.js b/src/messenger/webim/js/compiled/widget.js index cc80df2e..330ed252 100644 --- a/src/messenger/webim/js/compiled/widget.js +++ b/src/messenger/webim/js/compiled/widget.js @@ -12,6 +12,6 @@ return b.join("&")};a.Widget.prototype.sendToServer=function(b){for(var c in b)i this.loadScript(f));for(var h in b)b.hasOwnProperty(h)&&(h in this.handlersDependences||(this.handlersDependences[h]=b[h]));for(c=0;c
×
'; +document.cookie=""+b+"="+a+"; path=/; "+(d?"domain="+d+";":"")};a.Utils.readCookie=function(b){var a=document.cookie.split("; ");b+="=";for(var d=!1,e=0;e'; d&&(b+='

'+d+"

");e&&(b+=''+d+'');b=b+('

'+a+"

")+'
';if(a=document.getElementById("mibewinvitation"))a.innerHTML=b};a.Invitation={};a.Invitation.hide=function(){var a=document.getElementById("mibewinvitationpopup");a&&(a.style.display="none")};a.Invitation.accept=function(){document.getElementById("mibewAgentButton")&& -(document.getElementById("mibewAgentButton").onclick(),a.Invitation.hide())}})(Mibew); +(document.getElementById("mibewAgentButton").onclick(),a.Invitation.hide())};a.Invitation.reject=function(){a.Objects.widget.sendToServer({invitation_rejected:1});a.Invitation.hide()}})(Mibew); diff --git a/src/messenger/webim/js/source/widget.js b/src/messenger/webim/js/source/widget.js index f8cdd4bd..8e2fbaec 100644 --- a/src/messenger/webim/js/source/widget.js +++ b/src/messenger/webim/js/source/widget.js @@ -386,7 +386,7 @@ var Mibew = {}; var popuptext = '
'; popuptext += ''; if (operator) { popuptext += '

' @@ -435,4 +435,9 @@ var Mibew = {}; } } + Mibew.Invitation.reject = function() { + Mibew.Objects.widget.sendToServer({'invitation_rejected': 1}); + Mibew.Invitation.hide(); + } + })(Mibew); diff --git a/src/messenger/webim/libs/invitation.php b/src/messenger/webim/libs/invitation.php index 2faf0772..4577835b 100644 --- a/src/messenger/webim/libs/invitation.php +++ b/src/messenger/webim/libs/invitation.php @@ -82,6 +82,21 @@ function invitation_accept($visitorid, $threadid) } } +/** + * Inviation was rejected by visitor + * + * @param int $visitor_id ID of the visitor + */ +function invitation_reject($visitor_id) { + $db = Database::getInstance(); + $db->query( + "UPDATE {chatsitevisitor} SET invited = 0, " . + "invitationtime = NULL, invitedby = NULL " . + "WHERE visitorid = ?", + array($visitor_id) + ); +} + /** * Close old invitations */ diff --git a/src/messenger/webim/widget.php b/src/messenger/webim/widget.php index d57a749d..83a5a504 100644 --- a/src/messenger/webim/widget.php +++ b/src/messenger/webim/widget.php @@ -55,10 +55,6 @@ if (Settings::get('enabletracking') == '1') { $_SESSION['visitorid'] = $visitorid; } - if ($invited !== FALSE) { - $operator = operator_by_id($invited); - } - if ($user_id !== false) { // Update local cookie value at target site $response['handlers'][] = 'updateUserId'; @@ -66,16 +62,25 @@ if (Settings::get('enabletracking') == '1') { $response['data']['user']['id'] = $user_id; } -} + // Check if visitor just invited to chat + if ($invited !== FALSE) { + $operator = operator_by_id($invited); + $response['handlers'][] = 'inviteOnResponse'; + $response['dependences']['inviteOnResponse'] = array(); + $locale = isset($_GET['locale']) ? $_GET['locale'] : ''; + $operatorName = ($locale == $home_locale) + ? $operator['vclocalename'] + : $operator['vccommonname']; + $response['data']['invitation']['operator'] = htmlspecialchars($operatorName); + $response['data']['invitation']['message'] = getlocal("invitation.message"); + $response['data']['invitation']['avatar'] = htmlspecialchars($operator['vcavatar']); + } -if ($invited !== FALSE) { - $response['handlers'][] = 'inviteOnResponse'; - $response['dependences']['inviteOnResponse'] = array(); - $locale = isset($_GET['locale']) ? $_GET['locale'] : ''; - $operatorName = ($locale == $home_locale) ? $operator['vclocalename'] : $operator['vccommonname']; - $response['data']['invitation']['operator'] = htmlspecialchars($operatorName); - $response['data']['invitation']['message'] = getlocal("invitation.message"); - $response['data']['invitation']['avatar'] = htmlspecialchars($operator['vcavatar']); + // Check if visitor reject invitation + $invitation_state = invitation_state($visitorid); + if ($invitation_state['invited'] && ! empty($_GET['invitation_rejected'])) { + invitation_reject($visitorid); + } } start_js_output();