public function test_rememberToInvalidateArchivedReportsLater_shouldNotCreateEntryTwice()
 {
     $this->rememberReport(2, '2014-04-05');
     $this->rememberReport(2, '2014-04-05');
     $this->rememberReport(2, '2014-04-05');
     $this->assertCount(1, Option::getLike('report_to_invalidate%'));
 }
예제 #2
0
 /**
  * @param  string $componentPrefix eg 'version_log_visit.'
  * @return array An array of column names that are marked as installed. eg array('idvist', 'server_time', ...)
  */
 private static function getMarkedAsInstalledColumns($componentPrefix)
 {
     $installedVisitColumns = Option::getLike($componentPrefix . '%');
     $installedVisitColumns = array_keys($installedVisitColumns);
     $installedVisitColumns = array_map(function ($entry) use($componentPrefix) {
         return str_replace($componentPrefix, '', $entry);
     }, $installedVisitColumns);
     return $installedVisitColumns;
 }
예제 #3
0
 public function getRememberedArchivedReportsThatShouldBeInvalidated()
 {
     $reports = Option::getLike($this->rememberArchivedReportIdStart . '%_%');
     $sitesPerDay = array();
     foreach ($reports as $report => $value) {
         $report = str_replace($this->rememberArchivedReportIdStart, '', $report);
         $report = explode('_', $report);
         $siteId = (int) $report[0];
         $date = $report[1];
         if (empty($sitesPerDay[$date])) {
             $sitesPerDay[$date] = array();
         }
         $sitesPerDay[$date][] = $siteId;
     }
     return $sitesPerDay;
 }
예제 #4
0
 /**
  * Returns an array of Preferences
  * @param $preferenceNames array of preference names
  * @return array
  * @ignore
  */
 public function getAllUsersPreferences(array $preferenceNames)
 {
     Piwik::checkUserHasSuperUserAccess();
     $userPreferences = array();
     foreach ($preferenceNames as $preferenceName) {
         $optionNameMatchAllUsers = $this->getPreferenceId('%', $preferenceName);
         $preferences = Option::getLike($optionNameMatchAllUsers);
         foreach ($preferences as $optionName => $optionValue) {
             $lastUnderscore = strrpos($optionName, self::OPTION_NAME_PREFERENCE_SEPARATOR);
             $userName = substr($optionName, 0, $lastUnderscore);
             $preference = substr($optionName, $lastUnderscore + 1);
             $userPreferences[$userName][$preference] = $optionValue;
         }
     }
     return $userPreferences;
 }