/** * Process chat pages. * * @param Request $request Incoming request. * @return string|\Symfony\Component\HttpFoundation\RedirectResponse Rendered * page content or a redirect response. * @throws NotFoundException If the thread with specified ID and token is * not found. */ public function indexAction(Request $request) { // Check if we should force the user to use SSL $ssl_redirect = $this->sslRedirect($request); if ($ssl_redirect !== false) { return $ssl_redirect; } $operator = $this->getOperator(); $thread_id = $request->attributes->getInt('thread_id'); $token = $request->attributes->get('token'); $thread = Thread::load($thread_id, $token); if (!$thread) { throw new NotFoundException('The thread is not found.'); } // Check if the current operator has enough permissions to use the thread if ($thread->agentId != $operator['operatorid'] && !is_capable(CAN_VIEWTHREADS, $operator)) { return $this->showErrors(array('Cannot view threads')); } $page = setup_chatview_for_operator($this->getRouter(), $request, $thread, $operator); // Build js application options $page['chatOptions'] = $page['chat']; // Initialize client side application $this->getAssetManager()->attachJs('js/compiled/chat_app.js'); $this->getAssetManager()->attachJs($this->startJsApplication($request, $page), AssetManagerInterface::INLINE, 1000); // Render the page with chat. return $this->render('chat', $page); }
/** * Renders a page with redirections links. * * @param Request $request Incoming request. * @return string|\Symfony\Component\HttpFoundation\RedirectResponse Rendered * page content or a redirect response. * @throws NotFoundException If the thread with specified ID and token is * not found. */ public function showRedirectionLinksAction(Request $request) { // Check if we should force the user to use SSL $ssl_redirect = $this->sslRedirect($request); if ($ssl_redirect !== false) { return $ssl_redirect; } $operator = $this->getOperator(); $thread_id = $request->attributes->get('thread_id'); $token = $request->attributes->get('token'); $thread = Thread::load($thread_id, $token); if (!$thread) { throw new NotFoundException('The thread is not found.'); } if ($thread->agentId != $operator['operatorid']) { $page = array('errors' => array('Can redirect only own threads.')); return $this->render('error', $page); } $page = array_merge_recursive( setup_chatview_for_operator( $this->getRouter(), $request, $thread, $operator ), setup_redirect_links( $this->getRouter(), $thread_id, $operator, $token ) ); // Render the page with redirection links. return $this->render('redirect', $page); }
} if ($show == 'survey') { loadsettings(); setup_survey("Visitor", "", "", "", "http://google.com"); setup_logo(); expand("../styles", "{$preview}", "{$show}.tpl"); exit; } if ($show == 'mailsent' || $show == 'error') { $page['email'] = "*****@*****.**"; setup_logo(); expand("../styles", "{$preview}", "{$show}.tpl"); exit; } if ($show == 'redirect' || $show == 'redirected' || $show == 'agentchat' || $show == 'agentrochat') { setup_chatview_for_operator(array('threadid' => 0, 'userName' => getstring("chat.default.username"), 'remote' => "1.2.3.4", 'agentId' => 1, 'groupid' => 0, 'userid' => 'visitor1', 'locale' => $current_locale, 'ltoken' => $show == 'agentrochat' ? 124 : 123), array('operatorid' => $show == 'agentrochat' ? 2 : 1)); if ($show == 'redirect') { setup_redirect_links(0, $show == 'agentrochat' ? 124 : 123); } elseif ($show == 'redirected') { $page['message'] = getlocal2("chat.redirected.content", array("Administrator")); } $page['redirectLink'] = "{$webimroot}/operator/themes.php?preview={$preview}&show=redirect"; expand("../styles", "{$preview}", "{$show}.tpl"); exit; } $templateList = array(array('label' => getlocal("page.preview.userchat"), 'id' => 'chat', 'h' => 480, 'w' => 640), array('label' => getlocal("page.preview.chatsimple"), 'id' => 'chatsimple', 'h' => 480, 'w' => 640), array('label' => getlocal("page.preview.nochat"), 'id' => 'nochat', 'h' => 480, 'w' => 640), array('label' => getlocal("page.preview.survey"), 'id' => 'survey', 'h' => 480, 'w' => 640), array('label' => getlocal("page.preview.leavemessage"), 'id' => 'leavemessage', 'h' => 480, 'w' => 640), array('label' => getlocal("page.preview.leavemessagesent"), 'id' => 'leavemessagesent', 'h' => 480, 'w' => 640), array('label' => getlocal("page.preview.mail"), 'id' => 'mail', 'h' => 254, 'w' => 603), array('label' => getlocal("page.preview.mailsent"), 'id' => 'mailsent', 'h' => 254, 'w' => 603), array('label' => getlocal("page.preview.redirect"), 'id' => 'redirect', 'h' => 480, 'w' => 640), array('label' => getlocal("page.preview.redirected"), 'id' => 'redirected', 'h' => 480, 'w' => 640), array('label' => getlocal("page.preview.agentchat"), 'id' => 'agentchat', 'h' => 480, 'w' => 640), array('label' => getlocal("page.preview.agentrochat"), 'id' => 'agentrochat', 'h' => 480, 'w' => 640), array('label' => getlocal("page.preview.error"), 'id' => 'error', 'h' => 480, 'w' => 640)); $template = verifyparam("template", "/^\\w+\$/", "chat"); $page['formpreview'] = $preview; $page['formtemplate'] = $template; $page['canshowerrors'] = $template == 'leavemessage' || $template == 'mail' || $template == 'all'; $page['formshowerr'] = $showerrors;
if (!is_capable($can_viewthreads, $operator)) { $errors = array("Cannot view threads"); start_html_output(); expand("../styles", getchatstyle(), "error.tpl"); exit; } } $token = $thread['ltoken']; header("Location: {$mibewroot}/operator/agent.php?thread=" . intval($threadid) . "&token=" . intval($token) . "&level=" . urlencode($remote_level)); exit; } $token = verifyparam("token", "/^\\d{1,10}\$/"); $thread = thread_by_id($threadid); if (!$thread || !isset($thread['ltoken']) || $token != $thread['ltoken']) { die("wrong thread"); } if ($thread['agentId'] != $operator['operatorid'] && !is_capable($can_viewthreads, $operator)) { $errors = array("Cannot view threads"); start_html_output(); expand("../styles", 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, $token); expand("../styles", getchatstyle(), "redirect.tpl"); } else { expand("../styles", getchatstyle(), "chat.tpl"); }