mirror of
				https://github.com/Mibew/i18n.git
				synced 2025-10-31 09:21:04 +03:00 
			
		
		
		
	redirect to groups
git-svn-id: https://webim.svn.sourceforge.net/svnroot/webim/trunk@443 c66351dc-e62f-0410-b875-e3a5c0b9693f
This commit is contained in:
		
							parent
							
								
									e409810a0f
								
							
						
					
					
						commit
						b887941d14
					
				| @ -267,6 +267,14 @@ function perform_query($query,$link) { | ||||
| 		or die(' Query failed: '.mysql_error()/*.": ".$query*/); | ||||
| } | ||||
| 
 | ||||
| function rows_count($link,$table,$whereclause="") { | ||||
| 	$result = mysql_query("SELECT count(*) FROM $table $whereclause",$link) | ||||
| 			or die(' Count query failed: '.mysql_error()); | ||||
| 	$line = mysql_fetch_array($result, MYSQL_NUM); | ||||
| 	mysql_free_result($result); | ||||
| 	return $line[0]; | ||||
| } | ||||
| 
 | ||||
| function select_one_row($query,$link) { | ||||
| 	$result = mysql_query($query,$link) or die(' Query failed: ' . | ||||
| 		mysql_error().": ".$query); | ||||
|  | ||||
| @ -20,6 +20,14 @@ function group_by_id($id) { | ||||
| 	return $group; | ||||
| } | ||||
| 
 | ||||
| function get_group_name($group) { | ||||
| 	global $home_locale, $current_locale; | ||||
| 	if( $home_locale == $current_locale || !$group['vccommonname'] ) | ||||
| 		return $group['vclocalname']; | ||||
| 	else | ||||
| 		return $group['vccommonname']; | ||||
| } | ||||
| 
 | ||||
| function setup_group_settings_tabs($gid, $active) { | ||||
| 	global $page, $webimroot, $settings; | ||||
| 	if($gid) { | ||||
|  | ||||
| @ -194,19 +194,52 @@ function logout_operator() { | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| function get_redirect_links($threadid,$token) { | ||||
| 	global $page, $webimroot; | ||||
| 	$found = get_operators(); | ||||
| 	setup_pagination($found); | ||||
| function setup_redirect_links($threadid,$token) { | ||||
| 	global $page, $webimroot, $settings; | ||||
| 	loadsettings(); | ||||
| 	$link = connect(); | ||||
| 
 | ||||
| 	$operatorscount = rows_count($link, "chatoperator"); | ||||
| 	$groupscount = $settings['enablegroups'] == "1" ? rows_count($link, "chatgroup") : 0; | ||||
| 	 | ||||
| 	prepare_pagination(max($operatorscount,$groupscount),8); | ||||
| 	$limit = $page['pagination']['limit']; | ||||
| 
 | ||||
| 	$query = "select operatorid, vclogin, vclocalename, vccommonname, (unix_timestamp(CURRENT_TIMESTAMP)-unix_timestamp(dtmlastvisited)) as time ". | ||||
| 			 "from chatoperator order by vclogin $limit"; | ||||
| 	$operators = select_multi_assoc($query, $link); | ||||
| 
 | ||||
| 	if($settings['enablegroups'] == "1") { | ||||
| 		$query = "select groupid, vclocalname, vccommonname from chatgroup order by vclocalname $limit"; | ||||
| 		$groups = select_multi_assoc($query, $link); | ||||
| 	} | ||||
| 	 | ||||
| 	mysql_close($link); | ||||
| 
 | ||||
| 	$agent_list = ""; | ||||
| 	$params = array('thread' => $threadid, 'token' => $token); | ||||
| 	for( $indagent = 0; $indagent < count($page['pagination.items']); $indagent += 1 ) { | ||||
| 		$agent = $page['pagination.items'][$indagent]; | ||||
| 	foreach($operators as $agent) { | ||||
| 		$params['nextAgent'] = $agent['operatorid']; | ||||
| 		$agent_list .= "<li><a href=\"".add_params($webimroot."/operator/redirect.php",$params)."\" title=\"".topage($agent['vclocalename'])."\">".topage($agent['vclocalename'])."</a>"; | ||||
| 		$online = $agent['time'] < $settings['online_timeout'] ? getlocal("char.redirect.operator.online_suff") : ""; | ||||
| 		$agent_list .= "<li><a href=\"".add_params($webimroot."/operator/redirect.php",$params). | ||||
| 						"\" title=\"".topage(get_operator_name($agent))."\">". | ||||
| 						    topage(get_operator_name($agent)). | ||||
| 						"</a> $online</li>"; | ||||
| 	} | ||||
| 	return $agent_list; | ||||
| 	$page['redirectToAgent'] = $agent_list; | ||||
| 
 | ||||
| 	$group_list = ""; | ||||
| 	if($settings['enablegroups'] == "1") { | ||||
| 		$params = array('thread' => $threadid, 'token' => $token); | ||||
| 		foreach($groups as $group) { | ||||
| 			$params['nextGroup'] = $group['groupid']; | ||||
| 			$group_list .= "<li><a href=\"".add_params($webimroot."/operator/redirect.php",$params). | ||||
| 								"\" title=\"".topage(get_group_name($group))."\">". | ||||
| 								topage(get_group_name($group)). | ||||
| 							"</a></li>"; | ||||
| 		} | ||||
| 	} | ||||
| 	$page['redirectToGroup'] = $group_list; | ||||
| } | ||||
| 
 | ||||
| $permission_list = array(); | ||||
|  | ||||
| @ -27,15 +27,15 @@ function generate_pagination_image($id,$alt) { | ||||
| 	return "<img src=\"$webimroot/images/$id.gif\" border=\"0\" alt=\"".htmlspecialchars($alt)."\"/>"; | ||||
| } | ||||
| 
 | ||||
| function setup_pagination($items,$default_items_per_page=15) { | ||||
| function prepare_pagination($items_count,$default_items_per_page=15) { | ||||
| 	global $page; | ||||
| 
 | ||||
| 	if( $items ) { | ||||
| 	if( $items_count ) { | ||||
| 		$items_per_page = verifyparam("items", "/^\d{1,3}$/", $default_items_per_page); | ||||
| 		if( $items_per_page < 2 ) | ||||
| 			$items_per_page = 2; | ||||
| 
 | ||||
| 		$total_pages = div(count($items) + $items_per_page - 1, $items_per_page); | ||||
| 		$total_pages = div($items_count + $items_per_page - 1, $items_per_page); | ||||
| 		$curr_page = verifyparam("page", "/^\d{1,6}$/", 1); | ||||
| 
 | ||||
| 		if( $curr_page < 1 ) | ||||
| @ -44,14 +44,24 @@ function setup_pagination($items,$default_items_per_page=15) { | ||||
| 			$curr_page = $total_pages; | ||||
| 
 | ||||
| 		$start_index = ($curr_page-1)*$items_per_page; | ||||
| 		$end_index = min($start_index+$items_per_page, count($items)); | ||||
| 		$page['pagination.items'] = array_slice($items, $start_index, $end_index-$start_index); | ||||
| 		$end_index = min($start_index+$items_per_page, $items_count); | ||||
| 		$page['pagination'] = | ||||
| 			array(  "page" => $curr_page, "items" => $items_per_page, "total" => $total_pages, | ||||
| 					"count" => count($items), "start" => $start_index, "end" => $end_index ); | ||||
| 					"count" => $items_count, "start" => $start_index, "end" => $end_index, | ||||
| 					"limit" => "LIMIT $start_index,".($end_index - $start_index) ); | ||||
| 	} else { | ||||
| 		$page['pagination'] = true; | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| function setup_pagination($items,$default_items_per_page=15) { | ||||
| 	global $page; | ||||
| 	prepare_pagination($items ? count($items) : 0, $default_items_per_page); | ||||
| 	if($items && count($items) > 0) { | ||||
| 		$p = $page['pagination']; | ||||
| 		$page['pagination.items'] = array_slice($items, $p['start'], $p['end']-$p['start']); | ||||
| 	} else { | ||||
| 		$page['pagination.items'] = false; | ||||
| 		$page['pagination'] = true; | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
|  | ||||
| @ -27,11 +27,16 @@ chat.mailthread.sent.content=History of your chat was sent on address {0} | ||||
| chat.mailthread.sent.title=Sent | ||||
| chat.predefined_answers=Hello, how may I help you?\nHello! Welcome to our support. How may I help you? | ||||
| chat.redirect.back=Back... | ||||
| chat.redirect.choose_operator=Choose an operator: | ||||
| chat.redirect.operator=Operator: | ||||
| char.redirect.operator.online_suff=(online) | ||||
| chat.redirect.group=Group: | ||||
| chat.redirect.cannot=You are not chatting with visitor. | ||||
| chat.redirect.choose=Choose: | ||||
| chat.redirect.title=Redirect to<br>another operator | ||||
| chat.redirected.close=Close... | ||||
| chat.redirected.closewindow=Click to close the window | ||||
| chat.redirected.content=The visitor placed in priorty queue of the operator {0}. | ||||
| chat.redirected.group.content=The visitor placed in priorty queue of the group {0}. | ||||
| chat.redirected.title=The visitor redirected to another operator | ||||
| chat.status.operator.changed=Operator {0} changed operator {1} | ||||
| chat.status.operator.dead=Operator has connection issues, we temporarily moved you to foreground queue. Sorry for keeping you waiting. | ||||
|  | ||||
| @ -14,6 +14,7 @@ | ||||
| 
 | ||||
| require_once('../libs/common.php'); | ||||
| require_once('../libs/chat.php'); | ||||
| require_once('../libs/groups.php'); | ||||
| require_once('../libs/operator.php'); | ||||
| require_once('../libs/pagination.php'); | ||||
| require_once('../libs/expand.php'); | ||||
| @ -90,7 +91,7 @@ start_html_output(); | ||||
| 
 | ||||
| $pparam = verifyparam( "act", "/^(redirect)$/", "default"); | ||||
| if( $pparam == "redirect" ) { | ||||
| 	$page['pagination_list'] = get_redirect_links($threadid,$token); | ||||
| 	setup_redirect_links($threadid,$token); | ||||
| 	expand("../styles", getchatstyle(), "redirect.tpl"); | ||||
| } else { | ||||
| 	expand("../styles", getchatstyle(), "chat.tpl"); | ||||
|  | ||||
| @ -16,6 +16,7 @@ require_once('../libs/common.php'); | ||||
| require_once('../libs/chat.php'); | ||||
| require_once('../libs/pagination.php'); | ||||
| require_once('../libs/operator.php'); | ||||
| require_once('../libs/groups.php'); | ||||
| require_once('../libs/expand.php'); | ||||
| require_once('../libs/settings.php'); | ||||
| 
 | ||||
| @ -71,9 +72,9 @@ if($show == 'redirect' || $show == 'redirected' || $show == 'agentchat' || $show | ||||
| 			'operatorid' => ($show=='agentrochat' ? 2 : 1), | ||||
| 			)); | ||||
| 	if($show=='redirect') { | ||||
| 		$page['pagination_list'] = get_redirect_links( 0,$show=='agentrochat' ? 124 : 123); | ||||
| 		setup_redirect_links( 0,$show=='agentrochat' ? 124 : 123); | ||||
| 	} elseif($show=='redirected') { | ||||
| 		$page['nextAgent'] = "Administrator"; | ||||
| 		$page['message'] = getlocal2("chat.redirected.content",array("Administrator")); | ||||
| 	} | ||||
| 	$page['redirectLink'] = "$webimroot/operator/preview.php?preview=$preview&show=redirect"; | ||||
| 	expand("../styles", "$preview", "$show.tpl"); | ||||
|  | ||||
| @ -16,6 +16,7 @@ require_once('../libs/common.php'); | ||||
| require_once('../libs/operator.php'); | ||||
| require_once('../libs/chat.php'); | ||||
| require_once('../libs/expand.php'); | ||||
| require_once('../libs/groups.php'); | ||||
| 
 | ||||
| $operator = check_login(); | ||||
| 
 | ||||
| @ -27,27 +28,50 @@ if( !$thread || !isset($thread['ltoken']) || $token != $thread['ltoken'] ) { | ||||
| 	die("wrong thread"); | ||||
| } | ||||
| 
 | ||||
| $nextid = verifyparam( "nextAgent", "/^\d{1,8}$/"); | ||||
| $nextOperator = operator_by_id($nextid); | ||||
| 
 | ||||
| $page = array(); | ||||
| $errors = array(); | ||||
| 
 | ||||
| if( $nextOperator ) { | ||||
| 	$page['nextAgent'] = topage(get_operator_name($nextOperator)); | ||||
| 	if( $thread['istate'] == $state_chatting ) { | ||||
| 		$link = connect(); | ||||
| 		commit_thread( $threadid, | ||||
| 			array("istate" => $state_waiting, "nextagent" => $nextid, "agentId" => 0), $link); | ||||
| 		post_message_($thread['threadid'], $kind_events, | ||||
| 			getstring2_("chat.status.operator.redirect", | ||||
| 				array(get_operator_name($operator)),$thread['locale']), $link); | ||||
| 		mysql_close($link); | ||||
| if(isset($_GET['nextGroup'])) { | ||||
| 	$nextid = verifyparam( "nextGroup", "/^\d{1,8}$/"); | ||||
| 	$nextGroup = group_by_id($nextid); | ||||
| 	 | ||||
| 	if( $nextGroup ) { | ||||
| 		$page['message'] = getlocal2("chat.redirected.group.content",array(topage(get_group_name($nextGroup)))); | ||||
| 		if( $thread['istate'] == $state_chatting ) { | ||||
| 			$link = connect(); | ||||
| 			commit_thread( $threadid, | ||||
| 				array("istate" => $state_waiting, "nextagent" => 0, "groupid" => $nextid, "agentId" => 0, "agentName" => "''"), $link); | ||||
| 			post_message_($thread['threadid'], $kind_events, | ||||
| 				getstring2_("chat.status.operator.redirect", | ||||
| 					array(get_operator_name($operator)),$thread['locale']), $link); | ||||
| 			mysql_close($link); | ||||
| 		} else { | ||||
| 			$errors[] = getlocal("chat.redirect.cannot"); | ||||
| 		} | ||||
| 	} else { | ||||
| 		$errors[] = "You are not chatting with visitor";  // FIXME
 | ||||
| 		$errors[] = "Unknown group"; | ||||
| 	} | ||||
| 
 | ||||
| } else { | ||||
| 	$errors[] = "Unknown operator";	// FIXME
 | ||||
| 	$nextid = verifyparam( "nextAgent", "/^\d{1,8}$/"); | ||||
| 	$nextOperator = operator_by_id($nextid); | ||||
| 
 | ||||
| 	if( $nextOperator ) { | ||||
| 		$page['message'] = getlocal2("chat.redirected.content",array(topage(get_operator_name($nextOperator)))); | ||||
| 		if( $thread['istate'] == $state_chatting ) { | ||||
| 			$link = connect(); | ||||
| 			commit_thread( $threadid, | ||||
| 				array("istate" => $state_waiting, "nextagent" => $nextid, "agentId" => 0), $link); | ||||
| 			post_message_($thread['threadid'], $kind_events, | ||||
| 				getstring2_("chat.status.operator.redirect", | ||||
| 					array(get_operator_name($operator)),$thread['locale']), $link); | ||||
| 			mysql_close($link); | ||||
| 		} else { | ||||
| 			$errors[] = getlocal("chat.redirect.cannot"); | ||||
| 		} | ||||
| 	} else { | ||||
| 		$errors[] = "Unknown operator"; | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| setup_logo(); | ||||
|  | ||||
| @ -72,7 +72,7 @@ | ||||
| 			<table cellspacing="0" cellpadding="0" border="0" id="header" class="bg_domain"> | ||||
| 			<tr> | ||||
| 				<td style="padding-left:20px;width:612px;color:white;" class="mmimg"> | ||||
| 					${msg:chat.redirect.choose_operator} | ||||
| 					${msg:chat.redirect.choose} | ||||
| 				</td> | ||||
| 				<td align="right" style="padding-right:17px;"> | ||||
| 					<table cellspacing="0" cellpadding="0" border="0"> | ||||
| @ -89,13 +89,32 @@ | ||||
| </tr> | ||||
| <tr> | ||||
| 	<td valign="top" style="padding:0px 0px 0px 24px;"> | ||||
|     	<ul class="agentlist"> | ||||
| 	    	${page:pagination_list} | ||||
|     	</ul> | ||||
| 
 | ||||
| 			<table width="100%" cellpadding="0"> | ||||
| 			<tr> | ||||
| 	    	<td width="50%" valign="top"> | ||||
| ${if:redirectToAgent} | ||||
| 	    	${msg:chat.redirect.operator}<br/> | ||||
| 	    	<ul class="agentlist"> | ||||
| 		    	${page:redirectToAgent} | ||||
| 	    	</ul> | ||||
| ${endif:redirectToAgent} | ||||
| 	    	</td> | ||||
| 	    	<td width="50%" valign="top"> | ||||
| ${if:redirectToGroup} | ||||
| 	    	${msg:chat.redirect.group}<br/> | ||||
| 	    	<ul class="agentlist"> | ||||
| 		    	${page:redirectToGroup} | ||||
| 	    	</ul> | ||||
| ${endif:redirectToGroup} | ||||
| 	    	</td> | ||||
| 	    	</tr></table> | ||||
| 
 | ||||
| 	</td> | ||||
| </tr> | ||||
| <tr> | ||||
| 	<td valign="top" style="padding:24px"> | ||||
| 		${pagination} | ||||
| 	</td> | ||||
| </tr> | ||||
| </table> | ||||
|  | ||||
| @ -48,7 +48,7 @@ | ||||
| 		<table cellspacing="0" cellpadding="0" border="0" id="header" class="bg_domain"> | ||||
| 		<tr> | ||||
| 			<td style="padding-left:20px;color:white;" class="mmimg" width="770"> | ||||
| 				${msg:chat.redirected.content,nextAgent} | ||||
| 				${page:message} | ||||
| 			</td> | ||||
| 			<td align="right" style="padding-right:17px;"> | ||||
| 				<table cellspacing="0" cellpadding="0" border="0"> | ||||
|  | ||||
| @ -32,7 +32,7 @@ | ||||
| 	<tr> | ||||
|     <td width="50%" height="90" class="window"><h1>${msg:chat.redirect.title}</h1></td> | ||||
| 	<td width="50%" align="right" valign="bottom" class="window"> | ||||
| 		<h2>${msg:chat.redirect.choose_operator}</h2> | ||||
| 		<h2>${msg:chat.redirect.choose}</h2> | ||||
| 		<img src='${webimroot}/images/free.gif' width="1" height="5" border="0" alt="" /><br> | ||||
| 	</td> | ||||
| 	</tr> | ||||
| @ -60,9 +60,25 @@ | ||||
| 		<tr> | ||||
| 	    <td width="100%" valign="top" class="window"> | ||||
| 	     | ||||
| 			<table width="100%" cellpadding="0"> | ||||
| 			<tr> | ||||
| 	    	<td width="50%" valign="top"> | ||||
| ${if:redirectToAgent} | ||||
| 	    	${msg:chat.redirect.operator}<br/> | ||||
| 	    	<ul class="agentlist"> | ||||
| 	    	${page:pagination_list} | ||||
| 		    	${page:redirectToAgent} | ||||
| 	    	</ul> | ||||
| ${endif:redirectToAgent} | ||||
| 	    	</td> | ||||
| 	    	<td width="50%" valign="top"> | ||||
| ${if:redirectToGroup} | ||||
| 	    	${msg:chat.redirect.group}<br/> | ||||
| 	    	<ul class="agentlist"> | ||||
| 		    	${page:redirectToGroup} | ||||
| 	    	</ul> | ||||
| ${endif:redirectToGroup} | ||||
| 	    	</td> | ||||
| 	    	</tr></table> | ||||
| 
 | ||||
| 		</td> | ||||
| 		</tr> | ||||
|  | ||||
| @ -47,7 +47,7 @@ | ||||
|     <td height="100%" bgcolor="#FED840"><img src='${webimroot}/images/free.gif' width="1" height="1" border="0" alt="" /></td> | ||||
| 	<td background="${tplroot}/images/winbg.gif" class="bgcy"> | ||||
| 
 | ||||
| 		${msg:chat.redirected.content,nextAgent}<br/> | ||||
| 		${page:message}<br/> | ||||
| 		<a href="javascript:window.close();">${msg:chat.redirected.closewindow}</a> | ||||
| 
 | ||||
| 	</td> | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user