getUserPreference() public méthode

Gets a user preference
public getUserPreference ( string $userLogin, string $preferenceName ) : boolean | string
$userLogin string
$preferenceName string
Résultat boolean | string
 public function testGetUserPreferenceDefault()
 {
     $this->addSites(1);
     $defaultReportPref = API::PREFERENCE_DEFAULT_REPORT;
     $defaultReportDatePref = API::PREFERENCE_DEFAULT_REPORT_DATE;
     $this->assertEquals(1, $this->api->getUserPreference('someUser', $defaultReportPref));
     $this->assertEquals('yesterday', $this->api->getUserPreference('someUser', $defaultReportDatePref));
 }
 public function getDefaultPeriodWithoutValidation($defaultDate = null)
 {
     if (empty($defaultDate)) {
         $defaultDate = $this->api->getUserPreference(Piwik::getCurrentUserLogin(), APIUsersManager::PREFERENCE_DEFAULT_REPORT_DATE);
     }
     if (empty($defaultDate)) {
         return $this->getSystemDefaultPeriod();
     }
     if (in_array($defaultDate, array('today', 'yesterday'))) {
         return 'day';
     }
     if (strpos($defaultDate, 'last') === 0 || strpos($defaultDate, 'previous') === 0) {
         return 'range';
     }
     return $defaultDate;
 }
Exemple #3
0
 public function test_getUserPreference_ShouldReturnASetreference_IfNoneIsSet()
 {
     $this->api->setUserPreference($this->login, API::PREFERENCE_DEFAULT_REPORT, 5);
     $siteId = $this->api->getUserPreference($this->login, API::PREFERENCE_DEFAULT_REPORT);
     $this->assertEquals('5', $siteId);
 }