Example #1
0
 public static function sendNotificationToAdmin($args)
 {
     list($idsite, $idvisitor, $message) = $args;
     $visitorInfo = ChatPersonnalInformation::get($idvisitor);
     $subject = "New message on " . ChatSite::getSiteName($idsite);
     $mail = new Mail();
     $mail->setFrom(Config::getInstance()->General['noreply_email_address'], "Piwik Chat");
     $mail->setSubject($subject);
     $mail->setBodyHtml("Name : " . $visitorInfo['name'] . "<br />\n        Email : " . $visitorInfo['email'] . "<br />\n        Phone : " . $visitorInfo['phone'] . "<br />\n        Comments : " . $visitorInfo['comments'] . "<br />\n        <br /><br />\n        Message:<br />{$message}");
     foreach (ChatCommon::getUsersBySite($idsite) as $user) {
         if (empty($user['email'])) {
             continue;
         }
         if (ChatPiwikUser::isStaffOnline($user['login'])) {
             continue;
         }
         $mail->addTo($user['email']);
         try {
             $mail->send();
         } catch (Exception $e) {
             throw new Exception("An error occured while sending '{$subject}' " . " to " . implode(', ', $mail->getRecipients()) . ". Error was '" . $e->getMessage() . "'");
         }
         $mail->clearRecipients();
     }
 }
Example #2
0
 public function updatePersonnalInformations($idSite, $visitorId, $name = false, $email = false, $phone = false, $comments = false)
 {
     if ($phone || $comments) {
         $this->authenticate($idSite);
     }
     return ChatPersonnalInformation::update($visitorId, $name, $email, $phone, $comments);
 }
 /**
  * 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();
 }