/** * Generates JavaScript code that starts client side application. * * @param Request $request Incoming request. * @param array $operator Current operator. * @return string JavaScript code that starts "users" client side * application. */ protected function startJsApplication(Request $request, $operator) { // Load dialogs style options $chat_style = new ChatStyle(ChatStyle::getCurrentStyle()); $chat_style_config = $style_config = $chat_style->getConfigurations(); // Load page style options $page_style_config = $style_config = $this->getStyle()->getConfigurations(); return sprintf('jQuery(document).ready(function() {Mibew.Application.start(%s);});', json_encode(array('server' => array('url' => $this->generateUrl('users_update'), 'requestsFrequency' => Settings::get('updatefrequency_operator')), 'agent' => array('id' => $operator['operatorid']), 'page' => array('mibewBasePath' => $request->getBasePath(), 'mibewBaseUrl' => $request->getBaseUrl(), 'showOnlineOperators' => Settings::get('showonlineoperators') == '1', 'showVisitors' => Settings::get('enabletracking') == '1', 'showPopup' => Settings::get('enablepopupnotification') == '1', 'threadTag' => $page_style_config['users']['thread_tag'], 'visitorTag' => $page_style_config['users']['visitor_tag'], 'agentLink' => $request->getBaseUrl() . '/operator/chat', 'geoLink' => Settings::get('geolink'), 'trackedLink' => $request->getBaseUrl() . '/operator/history/user-track', 'banLink' => $request->getBaseUrl() . '/operator/ban', 'inviteLink' => $request->getBaseUrl() . '/operator/invite', 'chatWindowParams' => $chat_style_config['chat']['window'], 'geoWindowParams' => Settings::get('geolinkparams'), 'trackedUserWindowParams' => $page_style_config['tracked']['user_window'], 'trackedVisitorWindowParams' => $page_style_config['tracked']['visitor_window'], 'banWindowParams' => $page_style_config['ban']['window'], 'inviteWindowParams' => $chat_style_config['chat']['window'])))); }
/** * Prepare some data for chat for both user and operator * * @param Thread $thread thread object * @return array Array of chat view data */ function setup_chatview(Thread $thread) { $data = prepare_chat_app_data(); // Get group info if (!empty($thread->groupId)) { $group = group_by_id($thread->groupId); $group = get_top_level_group($group); } else { $group = array(); } // Create some empty arrays $data['chat'] = array('messageForm' => array(), 'links' => array(), 'windowsParams' => array()); // Set thread params $data['chat']['thread'] = array('id' => $thread->id, 'token' => $thread->lastToken, 'agentId' => $thread->agentId, 'userId' => $thread->userId); $data['page.title'] = empty($group['vcchattitle']) ? Settings::get('chattitle') : $group['vcchattitle']; $data['chat']['page'] = array('title' => $data['page.title']); // Setup logo $data = array_merge_recursive($data, setup_logo($group)); // Set enter key shortcut if (Settings::get('sendmessagekey') == 'enter') { $data['chat']['messageForm']['ignoreCtrl'] = true; } else { $data['chat']['messageForm']['ignoreCtrl'] = false; } // Load dialogs style options $chat_style = new ChatStyle(ChatStyle::getCurrentStyle()); $style_config = $chat_style->getConfigurations(); $data['chat']['windowsParams']['mail'] = $style_config['mail']['window']; // Load core style options $page_style = new PageStyle(PageStyle::getCurrentStyle()); $style_config = $page_style->getConfigurations(); $data['chat']['windowsParams']['history'] = $style_config['history']['window']; $data['startFrom'] = 'chat'; return $data; }