function setup_chatview_for_operator($thread, $operator) { global $page, $webimroot, $company_logo_link, $company_name, $settings; loadsettings(); $page = array(); $page['agent'] = true; $page['user'] = false; $page['canpost'] = $thread['agentId'] == $operator['operatorid']; $page['ct.chatThreadId'] = $thread['threadid']; $page['ct.token'] = $thread['ltoken']; $page['ct.user.name'] = htmlspecialchars(topage(get_user_name($thread['userName'], $thread['remote'], $thread['userid']))); $page['chat.title'] = topage($settings['chattitle']); setup_logo(); if ($settings['sendmessagekey'] == 'enter') { $page['send_shortcut'] = "Enter"; $page['ignorectrl'] = 1; } else { $page['send_shortcut'] = is_mac_opera() ? "⌘-Enter" : "Ctrl-Enter"; $page['ignorectrl'] = 0; } if ($settings['enablessl'] == "1" && !is_secure_request()) { $page['sslLink'] = get_app_location(true, true) . "/operator/agent.php?thread=" . $thread['threadid'] . "&token=" . $thread['ltoken']; } $page['isOpera95'] = is_agent_opera95(); $page['neediframesrc'] = needsFramesrc(); $page['historyParams'] = array("userid" => "" . $thread['userid']); $page['historyParamsLink'] = add_params($webimroot . "/operator/userhistory.php", $page['historyParams']); $predefinedres = ""; $canned_messages = load_canned_messages($thread['locale'], $thread['groupid']); foreach ($canned_messages as $answer) { $predefinedres .= "<option>" . htmlspecialchars(topage($answer['vcvalue'])) . "</option>"; } $page['predefinedAnswers'] = $predefinedres; $params = "thread=" . $thread['threadid'] . "&token=" . $thread['ltoken']; $page['redirectLink'] = "{$webimroot}/operator/agent.php?" . $params . "&act=redirect"; $page['namePostfix'] = ""; $page['frequency'] = $settings['updatefrequency_chat']; }
function setup_redirect_links($threadid, $token) { global $page, $mibewroot, $settings, $mysqlprefix; loadsettings(); $link = connect(); $operatorscount = db_rows_count("{$mysqlprefix}chatoperator", array(), "", $link); $groupscount = 0; $groups = array(); if ($settings['enablegroups'] == "1") { foreach (get_groups($link, true) as $group) { if ($group['inumofagents'] == 0) { continue; } $groups[] = $group; } $groupscount = count($groups); } prepare_pagination(max($operatorscount, $groupscount), 8); $p = $page['pagination']; $limit = $p['limit']; $operators = select_multi_assoc(db_build_select("operatorid, vclogin, vclocalename, vccommonname, istatus, (unix_timestamp(CURRENT_TIMESTAMP)-unix_timestamp(dtmlastvisited)) as time", "{$mysqlprefix}chatoperator", array(), "order by vclogin " . $limit), $link); $groups = array_slice($groups, $p['start'], $p['end'] - $p['start']); mysql_close($link); $agent_list = ""; $params = array('thread' => $threadid, 'token' => $token); foreach ($operators as $agent) { $params['nextAgent'] = $agent['operatorid']; $status = $agent['time'] < $settings['online_timeout'] ? $agent['istatus'] == 0 ? getlocal("char.redirect.operator.online_suff") : getlocal("char.redirect.operator.away_suff") : ""; $agent_list .= "<li><a href=\"" . add_params($mibewroot . "/operator/redirect.php", $params) . "\" title=\"" . safe_htmlspecialchars(topage(get_operator_name($agent))) . "\">" . safe_htmlspecialchars(topage(get_operator_name($agent))) . "</a> {$status}</li>"; } $page['redirectToAgent'] = $agent_list; $group_list = ""; if ($settings['enablegroups'] == "1") { $params = array('thread' => $threadid, 'token' => $token); foreach ($groups as $group) { $params['nextGroup'] = $group['groupid']; $status = $group['ilastseen'] !== NULL && $group['ilastseen'] < $settings['online_timeout'] ? getlocal("char.redirect.operator.online_suff") : ($group['ilastseenaway'] !== NULL && $group['ilastseenaway'] < $settings['online_timeout'] ? getlocal("char.redirect.operator.away_suff") : ""); $group_list .= "<li><a href=\"" . add_params($mibewroot . "/operator/redirect.php", $params) . "\" title=\"" . safe_htmlspecialchars(topage(get_group_name($group))) . "\">" . safe_htmlspecialchars(topage(get_group_name($group))) . "</a> {$status}</li>"; } } $page['redirectToGroup'] = $group_list; }