Db
5 years ago
Handler
5 years ago
TableLogAction
5 years ago
Visit
5 years ago
Action.php
5 years ago
ActionPageview.php
5 years ago
Cache.php
5 years ago
Db.php
5 years ago
Failures.php
6 years ago
FingerprintSalt.php
6 years ago
GoalManager.php
5 years ago
Handler.php
5 years ago
IgnoreCookie.php
5 years ago
LogTable.php
5 years ago
Model.php
5 years ago
PageUrl.php
5 years ago
Request.php
5 years ago
RequestProcessor.php
5 years ago
RequestSet.php
5 years ago
Response.php
5 years ago
ScheduledTasksRunner.php
5 years ago
Settings.php
5 years ago
TableLogAction.php
5 years ago
TrackerCodeGenerator.php
5 years ago
TrackerConfig.php
5 years ago
Visit.php
5 years ago
VisitExcluded.php
5 years ago
VisitInterface.php
5 years ago
Visitor.php
5 years ago
VisitorNotFoundInDb.php
5 years ago
VisitorRecognizer.php
5 years ago
Visitor.php
81 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Matomo - free/libre analytics platform |
| 4 | * |
| 5 | * @link https://matomo.org |
| 6 | * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later |
| 7 | * |
| 8 | */ |
| 9 | namespace Piwik\Tracker; |
| 10 | |
| 11 | use Piwik\Tracker\Visit\VisitProperties; |
| 12 | |
| 13 | class Visitor |
| 14 | { |
| 15 | private $visitorKnown = false; |
| 16 | |
| 17 | /** |
| 18 | * @var VisitProperties |
| 19 | */ |
| 20 | public $visitProperties; |
| 21 | |
| 22 | /** |
| 23 | * @var VisitProperties |
| 24 | */ |
| 25 | public $previousVisitProperties; |
| 26 | |
| 27 | public function __construct(VisitProperties $visitProperties, $isVisitorKnown = false, VisitProperties $previousVisitProperties = null) |
| 28 | { |
| 29 | $this->visitProperties = $visitProperties; |
| 30 | $this->previousVisitProperties = $previousVisitProperties; |
| 31 | $this->setIsVisitorKnown($isVisitorKnown); |
| 32 | } |
| 33 | |
| 34 | public static function makeFromVisitProperties(VisitProperties $visitProperties, Request $request, VisitProperties $previousVisitProperties = null) |
| 35 | { |
| 36 | $isKnown = $request->getMetadata('CoreHome', 'isVisitorKnown'); |
| 37 | return new Visitor($visitProperties, $isKnown, $previousVisitProperties); |
| 38 | } |
| 39 | |
| 40 | public function setVisitorColumn($column, $value) |
| 41 | { |
| 42 | $this->visitProperties->setProperty($column, $value); |
| 43 | } |
| 44 | |
| 45 | public function getVisitorColumn($column) |
| 46 | { |
| 47 | if (array_key_exists($column, $this->visitProperties->getProperties())) { |
| 48 | return $this->visitProperties->getProperty($column); |
| 49 | } |
| 50 | |
| 51 | return false; |
| 52 | } |
| 53 | |
| 54 | public function getPreviousVisitColumn($column) |
| 55 | { |
| 56 | if (empty($this->previousVisitProperties)) { |
| 57 | return false; |
| 58 | } |
| 59 | |
| 60 | if (array_key_exists($column, $this->previousVisitProperties->getProperties())) { |
| 61 | return $this->previousVisitProperties->getProperty($column); |
| 62 | } |
| 63 | |
| 64 | return false; |
| 65 | } |
| 66 | |
| 67 | public function isVisitorKnown() |
| 68 | { |
| 69 | return $this->visitorKnown === true; |
| 70 | } |
| 71 | |
| 72 | public function isNewVisit() |
| 73 | { |
| 74 | return !$this->isVisitorKnown(); |
| 75 | } |
| 76 | |
| 77 | private function setIsVisitorKnown($isVisitorKnown) |
| 78 | { |
| 79 | return $this->visitorKnown = $isVisitorKnown; |
| 80 | } |
| 81 | } |