mirror of
				https://github.com/Mibew/design.git
				synced 2025-10-31 18:41:05 +03:00 
			
		
		
		
	Visitors can reject invitations not only hide
This commit is contained in:
		
							parent
							
								
									29baaa700c
								
							
						
					
					
						commit
						8b025cf8bd
					
				| @ -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<d.length;c++){var g=d[c];if(this.canRunHandler(g))a.APIFunctions[g](e);else g in this.handlers||(this.handlers[g]=function(){a.APIFunctions[g](e)})}this.cleanUpAfterRequest();window.setTimeout(function(){j.makeRequest()},this.requestTimeout)};a.Widget.prototype.cleanUpAfterRequest=function(){document.getElementsByTagName("head")[0].removeChild(document.getElementById("responseScript"))}; | ||||
| a.Widget.prototype.loadScript=function(b){var c=this,a=this.doLoadScript(this.requestedScripts[b].url,b);a.onload=function(){c.scriptReady(b)};a.onreadystatechange=function(){("complete"==this.readyState||"loaded"==this.readyState)&&c.scriptReady(b)}};a.Widget.prototype.doLoadScript=function(b,c){var a=document.createElement("script");a.setAttribute("type","text/javascript");a.setAttribute("src",b);a.setAttribute("id",c);document.getElementsByTagName("head")[0].appendChild(a);return a};a.Widget.prototype.scriptReady= | ||||
| function(b){this.requestedScripts[b].status="ready";for(var a in this.handlers)this.handlers.hasOwnProperty(a)&&this.canRunHandler(a)&&(this.handlers[a](),delete this.handlers[a])};a.Widget.prototype.canRunHandler=function(b){b=this.handlersDependences[b];for(var a=0;a<b.length;a++)if("ready"!=this.requestedScripts[b[a]].status)return!1;return!0};a.Widget.init=function(b){a.Objects.widget=new a.Widget(b);a.Objects.widget.makeRequest()};a.Utils={};a.Utils.createCookie=function(b,a){var d=/([^\.]+\.[^\.]+)$/.exec(document.location.hostname)[1]; | ||||
| 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<a.length;e++)if(-1!=a[e].indexOf(b)){d=a[e].substr(b.length);break}return d};a.APIFunctions={};a.APIFunctions.updateUserId=function(b){a.Utils.createCookie(a.Objects.widget.visitorCookieName,b.user.id)};a.APIFunctions.inviteOnResponse=function(b){var a=b.invitation.message,d=b.invitation.operator,e=b.invitation.avatar;b='<div id="mibewinvitationpopup"><div id="mibewinvitationclose"><a href="javascript:void(0);" onclick="Mibew.Invitation.hide();">×</a></div>'; | ||||
| 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<a.length;e++)if(-1!=a[e].indexOf(b)){d=a[e].substr(b.length);break}return d};a.APIFunctions={};a.APIFunctions.updateUserId=function(b){a.Utils.createCookie(a.Objects.widget.visitorCookieName,b.user.id)};a.APIFunctions.inviteOnResponse=function(b){var a=b.invitation.message,d=b.invitation.operator,e=b.invitation.avatar;b='<div id="mibewinvitationpopup"><div id="mibewinvitationclose"><a href="javascript:void(0);" onclick="Mibew.Invitation.reject();">×</a></div>'; | ||||
| d&&(b+='<h1 onclick="Mibew.Invitation.accept();">'+d+"</h1>");e&&(b+='<img id="mibewinvitationavatar" src="'+e+'" title="'+d+'" alt="'+d+'" onclick="Mibew.Invitation.accept();" />');b=b+('<p onclick="Mibew.Invitation.accept();">'+a+"</p>")+'<div style="clear: both;"></div></div>';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); | ||||
|  | ||||
| @ -386,7 +386,7 @@ var Mibew = {}; | ||||
| 
 | ||||
|         var popuptext = '<div id="mibewinvitationpopup">'; | ||||
|         popuptext += '<div id="mibewinvitationclose">' | ||||
|             + '<a href="javascript:void(0);" onclick="Mibew.Invitation.hide();">' | ||||
|             + '<a href="javascript:void(0);" onclick="Mibew.Invitation.reject();">' | ||||
|             + '×</a></div>'; | ||||
|         if (operator) { | ||||
|             popuptext += '<h1 onclick="Mibew.Invitation.accept();">' | ||||
| @ -435,4 +435,9 @@ var Mibew = {}; | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     Mibew.Invitation.reject = function() { | ||||
|         Mibew.Objects.widget.sendToServer({'invitation_rejected': 1}); | ||||
|         Mibew.Invitation.hide(); | ||||
|     } | ||||
| 
 | ||||
| })(Mibew); | ||||
|  | ||||
| @ -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 | ||||
|  */ | ||||
|  | ||||
| @ -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(); | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user