コード例 #1
0
 /**
  * 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();
 }
コード例 #2
0
 public function sendMessage($content, $fromAdmin = false, $idAutoMsg = false)
 {
     $hexVisitorId = Common::convertVisitorIdToBin($this->idvisitor);
     $sanitizeContent = Common::sanitizeInputValues($content);
     $additionnalParams = "";
     $microtime = microtime(true);
     $arguments = array($this->idsite, $hexVisitorId, $sanitizeContent, $microtime);
     if ($idAutoMsg) {
         $additionnalParams .= ", idautomsg = ?";
         $arguments[] = $idAutoMsg;
     }
     if ($fromAdmin) {
         $additionnalParams .= ", answerfrom = ?";
         $arguments[] = $fromAdmin;
     }
     $queryResult = Db::query("INSERT INTO " . Common::prefixTable('chat') . " SET idsite = ?, idvisitor = ?, content = ?, microtime = ?{$additionnalParams}", $arguments);
     if (!$fromAdmin) {
         ChatAcknowledgment::setLastSent($this->idsite, $this->idvisitor, $microtime);
         //ChatMail::sendNotificationToAdmin($this->idsite, $this->idvisitor, $sanitizeContent);
     }
     $insertedRow = Db::fetchRow("SELECT idmessage,microtime FROM " . Common::prefixTable('chat') . " WHERE idvisitor = ? AND microtime = ?", array($hexVisitorId, $microtime));
     return $insertedRow;
 }
コード例 #3
0
ファイル: API.php プロジェクト: WHATNEXTLIMITED/piwik-chat
 public function getUnreadConversations($idSite)
 {
     $this->authenticate($idSite);
     return ChatAcknowledgment::getUnreadConversations(Piwik::getCurrentUserLogin());
 }