diff options
author | emkael <emkael@tlen.pl> | 2016-03-28 18:50:15 +0200 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2016-03-28 18:50:15 +0200 |
commit | 92438c15ae16765142795605dedb4a203ff5d6c6 (patch) | |
tree | 10c521134819e65e89a2177169dccb8a08059976 | |
parent | b40eca92d8e5cfd561855a440550fecc86ca4bdc (diff) |
* timezone preferences refactored
-rw-r--r-- | app/php/components/TimezoneSelect.php | 5 | ||||
-rw-r--r-- | app/php/user/DbUser.php | 8 |
2 files changed, 10 insertions, 3 deletions
diff --git a/app/php/components/TimezoneSelect.php b/app/php/components/TimezoneSelect.php index 50dc494..3302e2a 100644 --- a/app/php/components/TimezoneSelect.php +++ b/app/php/components/TimezoneSelect.php @@ -12,7 +12,7 @@ class TimezoneSelect extends TTemplateControl { public function setUserToChange(DbUser $user) { if ($user->IsGuest) { throw new TInvalidDataValueException( - 'Password change impossible for guest user' + 'Timezone preference change impossible for guest user' ); } $this->setControlState('user', $user); @@ -30,8 +30,7 @@ class TimezoneSelect extends TTemplateControl { } public function saveTimezone($sender, $param) { - $this->UserToChange->DbRecord->Timezone = $this->Timezones->SelectedValue; - $this->UserToChange->DbRecord->save(); + $this->UserToChange->setTimezonePreference($this->Timezones->SelectedValue); } private function _getTimezones() { diff --git a/app/php/user/DbUser.php b/app/php/user/DbUser.php index f9c8660..896d73d 100644 --- a/app/php/user/DbUser.php +++ b/app/php/user/DbUser.php @@ -63,6 +63,14 @@ class DbUser extends TDbUser { } } + public function setTimezonePreference($timezone) { + if ($this->IsGuest) { + throw new TInvalidDataException('Timezone preference change impossible for guest user'); + } + $this->DbRecord->Timezone = $timezone; + $this->DbRecord->save(); + } + public function getTimezonePreference() { if (!$this->IsGuest) { try { |