getControlState('user'); } public function setUserToChange(DbUser $user) { if ($user->IsGuest) { throw new TInvalidDataValueException( 'Password change impossible for guest user' ); } $this->setControlState('user', $user); } public function onPreRender($param) { parent::onPreRender($param); $this->Timezones->DataSource = $this->_getTimezones(); $this->Timezones->DataValueField = 'Name'; $this->Timezones->DataTextField = 'Label'; $this->Timezones->dataBind(); $this->Timezones->setSelectedValue( $this->UserToChange->getTimezonePreference()->Name ); } public function saveTimezone($sender, $param) { $this->UserToChange->DbRecord->Timezone = $this->Timezones->SelectedValue; $this->UserToChange->DbRecord->save(); } private function _getTimezones() { $timezones = array_map( function($tz) { return new TimezoneDTO($tz); }, DateTimeZone::listIdentifiers() ); usort( $timezones, function($tz1, $tz2) { $diff = $tz1->Offset - $tz2->Offset; return ($diff == 0) ? strcmp($tz1->Name, $tz2->Name) : $diff; } ); return $timezones; } } ?>