예제 #1
0
 /**
  * @group Plugins
  */
 public function test_AddAndGet_AnotherSegment()
 {
     $name = 'name';
     $definition = 'searches>1,visitIp!=127.0.0.1';
     $idSegment = API::getInstance()->add($name, $definition, $idSite = 1, $autoArchive = 1, $enabledAllUsers = 1);
     $this->assertEquals($idSegment, 1);
     // Testing get()
     $segment = API::getInstance()->get($idSegment);
     $expected = array('idsegment' => '1', 'name' => $name, 'definition' => $definition, 'login' => 'superUserLogin', 'enable_all_users' => '1', 'enable_only_idsite' => '1', 'auto_archive' => '1', 'ts_last_edit' => null, 'deleted' => '0');
     unset($segment['ts_created']);
     $this->assertEquals($segment, $expected);
     // There is a segment to process for this particular site
     $model = new Model();
     $segments = $model->getSegmentsToAutoArchive($idSite);
     unset($segments[0]['ts_created']);
     $this->assertEquals($segments, array($expected));
     // There is no segment to process for a non existing site
     try {
         $segments = $model->getSegmentsToAutoArchive(33);
         $this->fail();
     } catch (Exception $e) {
         // expected
     }
     // There is no segment to process across all sites
     $segments = $model->getSegmentsToAutoArchive($idSite = false);
     $this->assertEquals($segments, array());
 }
예제 #2
0
 /**
  * Adds the pre-processed segments to the list of Segments.
  * Used by CronArchive, ArchiveProcessor\Rules, etc.
  *
  * @param $segments
  * @param $idSite
  */
 public function getKnownSegmentsToArchiveForSite(&$segments, $idSite)
 {
     $model = new Model();
     $segmentToAutoArchive = $model->getSegmentsToAutoArchive($idSite);
     foreach ($segmentToAutoArchive as $segmentInfo) {
         $segments[] = $segmentInfo['definition'];
     }
     $segments = array_unique($segments);
 }
예제 #3
0
 /**
  * Returns all stored segments that haven't been deleted.
  *
  * @return array
  */
 public function getAllSegmentsAndIgnoreVisibility()
 {
     $cacheKey = 'SegmentEditor.getAllSegmentsAndIgnoreVisibility';
     if (!$this->transientCache->contains($cacheKey)) {
         $result = $this->model->getAllSegmentsAndIgnoreVisibility();
         $this->transientCache->save($cacheKey, $result);
     }
     return $this->transientCache->fetch($cacheKey);
 }
 private function getAllSegments()
 {
     if (!$this->segmentListCache->contains('all')) {
         $segments = $this->segmentEditorModel->getAllSegmentsAndIgnoreVisibility();
         $this->segmentListCache->save('all', $segments);
     }
     return $this->segmentListCache->fetch('all');
 }
예제 #5
0
 public function install()
 {
     Model::install();
 }
예제 #6
0
파일: API.php 프로젝트: brienomatty/elmsln
 /**
  * Returns all stored segments.
  *
  * @param bool|int $idSite Whether to return stored segments for a specific idSite, or all of them. If supplied, must be a valid site ID.
  * @return array
  */
 public function getAll($idSite = false)
 {
     if (!empty($idSite)) {
         Piwik::checkUserHasViewAccess($idSite);
     } else {
         Piwik::checkUserHasSomeViewAccess();
     }
     $userLogin = Piwik::getCurrentUserLogin();
     $model = new Model();
     if (empty($idSite)) {
         $segments = $model->getAllSegments($userLogin);
     } else {
         $segments = $model->getAllSegmentsForSite($idSite, $userLogin);
     }
     return $segments;
 }