X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Fprofilesettings.php;h=f2fe89826eae19749c83e8287778a892ea4a7f04;hb=506843e55d1381172c7a8e629a2447588dba67fe;hp=09b5b5abc3b427124c66412d5d91362e772d412b;hpb=f4936d7c5876bdb9d11ebab7cf9268d176c1f8bd;p=quix0rs-gnu-social.git diff --git a/actions/profilesettings.php b/actions/profilesettings.php index 09b5b5abc3..f2fe89826e 100644 --- a/actions/profilesettings.php +++ b/actions/profilesettings.php @@ -52,6 +52,16 @@ class ProfilesettingsAction extends SettingsAction { common_input('location', _('Location'), ($this->arg('location')) ? $this->arg('location') : $profile->location, _('Where you are, like "City, State (or Region), Country"')); + + $language = common_language(); + common_dropdown('language', _('Language'), get_nice_language_list(), _('Preferred language'), TRUE, $language); + $timezone = common_timezone(); + $timezones = array(); + foreach(DateTimeZone::listIdentifiers() as $k => $v) { + $timezones[$v] = $v; + } + common_dropdown('timezone', _('Timezone'), $timezones, _('What timezone are you normally in?'), TRUE, $timezone); + common_checkbox('autosubscribe', _('Automatically subscribe to whoever subscribes to me (best for non-humans)'), ($this->arg('autosubscribe')) ? $this->boolean('autosubscribe') : $user->autosubscribe); common_submit('submit', _('Save')); @@ -67,7 +77,9 @@ class ProfilesettingsAction extends SettingsAction { $bio = $this->trimmed('bio'); $location = $this->trimmed('location'); $autosubscribe = $this->boolean('autosubscribe'); - + $language = $this->trimmed('language'); + $timezone = $this->trimmed('timezone'); + # Some validation if (!Validate::string($nickname, array('min_length' => 1, @@ -91,23 +103,36 @@ class ProfilesettingsAction extends SettingsAction { } else if (!is_null($location) && strlen($location) > 255) { $this->show_form(_('Location is too long (max 255 chars).')); return; + } else if (is_null($timezone) || !in_array($timezone, DateTimeZone::listIdentifiers())) { + $this->show_form(_('Timezone not selected.')); + return; } else if ($this->nickname_exists($nickname)) { $this->show_form(_('Nickname already in use. Try another one.')); return; + } else if (!is_null($language) && strlen($language) > 50) { + $this->show_form(_('Language is too long (max 50 chars).')); } $user = common_current_user(); $user->query('BEGIN'); - if ($user->nickname != $nickname) { + if ($user->nickname != $nickname || + $user->language != $language || + $user->timezone != $timezone) { common_debug('Updating user nickname from ' . $user->nickname . ' to ' . $nickname, __FILE__); + common_debug('Updating user language from ' . $user->language . ' to ' . $language, + __FILE__); + common_debug('Updating user timezone from ' . $user->timezone . ' to ' . $timezone, + __FILE__); $original = clone($user); $user->nickname = $nickname; + $user->language = $language; + $user->timezone = $timezone; $result = $user->updateKeys($original); @@ -118,18 +143,19 @@ class ProfilesettingsAction extends SettingsAction { } } - # XOR + # XXX: XOR if ($user->autosubscribe ^ $autosubscribe) { + $original = clone($user); - $user->nickname = $nickname; + $user->autosubscribe = $autosubscribe; $result = $user->update($original); if ($result === FALSE) { common_log_db_error($user, 'UPDATE', __FILE__); - common_server_error(_('Couldn\'t update user.')); + common_server_error(_('Couldn\'t update user for autosubscribe.')); return; } }