/** * Echo's HTML for visitor profile popup. */ public function getVisitorProfilePopup() { Piwik::checkUserHasSomeAdminAccess(); $idSite = Common::getRequestVar('idSite', null, 'int'); $gotoChat = Common::getRequestVar('chat', '0', 'int'); $idvisitor = Common::getRequestVar('visitorId', null, 'string'); if (!$gotoChat) { $gotoChat = isset($_SESSION['chatViewByDefault']) ? $_SESSION['chatViewByDefault'] : false; } $conversation = new ChatConversation($idSite, $idvisitor); $messages = $conversation->getAllMessages(); $infos = ChatPersonnalInformation::get($idvisitor); if (count($messages) > 0) { $lastMsgIndex = count($messages) - 1; ChatAcknowledgment::setLastViewed($idvisitor, $messages[$lastMsgIndex]['microtime'], Piwik::getCurrentUserLogin()); } $view = new View('@Chat/getVisitorProfilePopup.twig'); $view->idSite = $idSite; $view->chat = $gotoChat; $view->goals = APIGoals::getInstance()->getGoals($idSite); $view->visitorData = Request::processRequest('Live.getVisitorProfile', array('checkForLatLong' => true)); $view->exportLink = $this->getVisitorProfileExportLink(); $view->messages = $messages; $view->infos = $infos; if (Common::getRequestVar('showMap', 1) == 1 && !empty($view->visitorData['hasLatLong']) && \Piwik\Plugin\Manager::getInstance()->isPluginLoaded('UserCountryMap')) { $view->userCountryMapUrl = $this->getUserCountryMapUrlForVisitorProfile(); } $this->setWidgetizedVisitorProfileUrl($view); return $view->render(); }
public function getMessages($idSite, $visitorId = false, $microtimeFrom = false) { header("Access-Control-Allow-Origin: *"); $conversation = new ChatConversation($idSite, $visitorId); return $conversation->getAllMessages($microtimeFrom); }