예제 #1
0
파일: API.php 프로젝트: dorelljames/piwik
 /**
  * Returns an array describing a visitor using her last visits (uses a maximum of 100).
  *
  * @param int $idSite Site ID
  * @param bool|false|string $visitorId The ID of the visitor whose profile to retrieve.
  * @param bool|false|string $segment
  * @return array
  */
 public function getVisitorProfile($idSite, $visitorId = false, $segment = false)
 {
     Piwik::checkUserHasViewAccess($idSite);
     if ($visitorId === false) {
         $visitorId = $this->getMostRecentVisitorId($idSite, $segment);
     }
     $newSegment = ($segment === false ? '' : $segment . ';') . 'visitorId==' . $visitorId;
     $visits = $this->loadLastVisitorDetailsFromDatabase($idSite, $period = false, $date = false, $newSegment, $offset = 0, $limit = self::VISITOR_PROFILE_MAX_VISITS_TO_AGGREGATE);
     $this->addFilterToCleanVisitors($visits, $idSite, $flat = false, $doNotFetchActions = false, $filterNow = true);
     if ($visits->getRowsCount() == 0) {
         return array();
     }
     $profile = new VisitorProfile($idSite);
     $result = $profile->makeVisitorProfile($visits, $visitorId, $segment);
     /**
      * Triggered in the Live.getVisitorProfile API method. Plugins can use this event
      * to discover and add extra data to visitor profiles.
      *
      * For example, if an email address is found in a custom variable, a plugin could load the
      * gravatar for the email and add it to the visitor profile, causing it to display in the
      * visitor profile popup.
      *
      * The following visitor profile elements can be set to augment the visitor profile popup:
      *
      * - **visitorAvatar**: A URL to an image to display in the top left corner of the popup.
      * - **visitorDescription**: Text to be used as the tooltip of the avatar image.
      *
      * @param array &$visitorProfile The unaugmented visitor profile info.
      */
     Piwik::postEvent('Live.getExtraVisitorDetails', array(&$result));
     return $result;
 }
예제 #2
0
 public function getSingleVisitSummary()
 {
     $view = new View('@Live/getSingleVisitSummary.twig');
     $visits = Request::processRequest('Live.getLastVisitsDetails', array('segment' => 'visitId==' . Common::getRequestVar('visitId'), 'period' => false, 'date' => false));
     $view->visitData = $visits->getFirstRow()->getColumns();
     $view->visitReferralSummary = VisitorProfile::getReferrerSummaryForVisit($visits->getFirstRow());
     $view->showLocation = true;
     $this->setWidgetizedVisitorProfileUrl($view);
     $view->exportLink = $this->getVisitorProfileExportLink();
     return $view->render();
 }