lastToken)) { $errors = array(getlocal("thread.error.wrong_thread")); start_html_output(); expand("../styles/dialogs", getchatstyle(), "error.tpl"); exit; } $viewonly = verifyparam("viewonly", "/^true$/", false); $forcetake = verifyparam("force", "/^true$/", false); if (!$viewonly && $thread->state == Thread::STATE_CHATTING && $operator['operatorid'] != $thread->agentId) { if (!is_capable($can_takeover, $operator)) { $errors = array(getlocal("thread.error.cannot_take_over")); start_html_output(); expand("../styles/dialogs", getchatstyle(), "error.tpl"); exit; } if ($forcetake == false) { $page = array( 'user' => topage($thread->userName), 'agent' => topage($thread->agentName), 'link' => $_SERVER['PHP_SELF'] . "?thread=$threadid&force=true" ); start_html_output(); require('../view/confirm.php'); exit; } } if (!$viewonly) { if(! $thread->take($operator)){ $errors = array(getlocal("thread.error.cannot_take")); start_html_output(); expand("../styles/dialogs", getchatstyle(), "error.tpl"); exit; } } else if (!is_capable($can_viewthreads, $operator)) { $errors = array(getlocal("thread.error.cannot_view")); start_html_output(); expand("../styles/dialogs", getchatstyle(), "error.tpl"); exit; } $token = $thread->lastToken; header("Location: $webimroot/operator/agent.php?thread=$threadid&token=$token&level=$remote_level"); exit; } $token = verifyparam("token", "/^\d{1,8}$/"); $thread = Thread::load($threadid, $token); if (!$thread) { die("wrong thread"); } if ($thread->agentId != $operator['operatorid'] && !is_capable($can_viewthreads, $operator)) { $errors = array("Cannot view threads"); start_html_output(); expand("../styles/dialogs", getchatstyle(), "error.tpl"); exit; } setup_chatview_for_operator($thread, $operator); start_html_output(); $pparam = verifyparam("act", "/^(redirect)$/", "default"); if ($pparam == "redirect") { setup_redirect_links($threadid, $operator, $token); expand("../styles/dialogs", getchatstyle(), "redirect.tpl"); } else { // Load JavaScript plugins and JavaScripts, CSS files required by them $page['additional_css'] = get_additional_css('chatWindow'); $page['additional_js'] = get_additional_js('chatWindow'); $page['js_plugins'] = get_js_plugins('chatWindow'); // Expand page expand("../styles/dialogs", getchatstyle(), "chat.tpl"); } ?>