diff options
Diffstat (limited to 'actions')
-rw-r--r-- | actions/urlsettings.php (renamed from actions/othersettings.php) | 21 | ||||
-rw-r--r-- | actions/userdesignsettings.php | 79 |
2 files changed, 85 insertions, 15 deletions
diff --git a/actions/othersettings.php b/actions/urlsettings.php index 4dfc5c284..7b2fc3f55 100644 --- a/actions/othersettings.php +++ b/actions/urlsettings.php @@ -46,17 +46,18 @@ require_once INSTALLDIR.'/lib/accountsettingsaction.php'; * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ */ -class OthersettingsAction extends AccountSettingsAction + +class UrlsettingsAction extends AccountSettingsAction { /** * Title of the page * * @return string Title of the page */ + function title() { - // Page title for a tab in user profile settings. - return _('Other settings'); + return _('URL settings'); } /** @@ -93,7 +94,7 @@ class OthersettingsAction extends AccountSettingsAction 'id' => 'form_settings_other', 'class' => 'form_settings', 'action' => - common_local_url('othersettings'))); + common_local_url('urlsettings'))); $this->elementStart('fieldset'); $this->hidden('token', common_session_token()); $this->elementStart('ul', 'form_data'); @@ -130,19 +131,14 @@ class OthersettingsAction extends AccountSettingsAction _('URL longer than'), (!is_null($this->arg('maxurllength'))) ? $this->arg('maxurllength') : User_urlshortener_prefs::maxUrlLength($user), - _('URLs longer than this will be shortened.')); + _('URLs longer than this will be shortened, 0 means always shorten.')); $this->elementEnd('li'); $this->elementStart('li'); $this->input('maxnoticelength', _('Text longer than'), (!is_null($this->arg('maxnoticelength'))) ? $this->arg('maxnoticelength') : User_urlshortener_prefs::maxNoticeLength($user), - _('URLs in notices longer than this will be shortened.')); - $this->elementEnd('li'); - $this->elementStart('li'); - // TRANS: Label for checkbox. - $this->checkbox('viewdesigns', _('View profile designs'), - - $user->viewdesigns, _('Show or hide profile designs.')); + _('URLs in notices longer than this will be shortened, 0 means always shorten.')); $this->elementEnd('li'); $this->elementEnd('ul'); // TRANS: Button text for saving "Other settings" in profile. @@ -178,8 +174,6 @@ class OthersettingsAction extends AccountSettingsAction return; } - $viewdesigns = $this->boolean('viewdesigns'); - $maxurllength = $this->trimmed('maxurllength'); if (!Validate::number($maxurllength, array('min' => 0))) { @@ -201,7 +195,6 @@ class OthersettingsAction extends AccountSettingsAction $original = clone($user); $user->urlshorteningservice = $urlshorteningservice; - $user->viewdesigns = $viewdesigns; $result = $user->update($original); diff --git a/actions/userdesignsettings.php b/actions/userdesignsettings.php index 1cf878000..e6caea3a1 100644 --- a/actions/userdesignsettings.php +++ b/actions/userdesignsettings.php @@ -121,6 +121,20 @@ class UserDesignSettingsAction extends DesignSettingsAction } /** + * Shows the design settings form + * + * @param Design $design a working design to show + * + * @return nothing + */ + + function showDesignForm($design) + { + $form = new UserDesignForm($this, $design, $this->submitaction); + $form->show(); + } + + /** * Save or update the user's design settings * * @return void @@ -128,6 +142,8 @@ class UserDesignSettingsAction extends DesignSettingsAction function saveDesign() { + $this->saveDesignPreferences(); + foreach ($this->args as $key => $val) { if (preg_match('/(#ho|ho)Td.*g/i', $val)) { $this->sethd(); @@ -164,7 +180,8 @@ class UserDesignSettingsAction extends DesignSettingsAction $tile = true; } - $user = common_current_user(); + $user = common_current_user(); + $design = $user->getDesign(); if (!empty($design)) { @@ -282,4 +299,64 @@ class UserDesignSettingsAction extends DesignSettingsAction $this->showForm(_('Enjoy your hotdog!'), true); } + function saveDesignPreferences() + { + $viewdesigns = $this->boolean('viewdesigns'); + + $user = common_current_user(); + + $original = clone($user); + + $user->viewdesigns = $viewdesigns; + + $result = $user->update($original); + + if ($result === false) { + common_log_db_error($user, 'UPDATE', __FILE__); + throw new ServerException(_('Couldn\'t update user.')); + } + } +} + +class UserDesignForm extends DesignForm +{ + function __construct($out, $design, $actionurl) + { + parent::__construct($out, $design, $actionurl); + } + + /** + * Legend of the Form + * + * @return void + */ + function formLegend() + { + $this->out->element('legend', null, _('Design settings')); + } + + /** + * Data elements of the form + * + * @return void + */ + + function formData() + { + $user = common_current_user(); + + $this->out->elementStart('ul', 'form_data'); + $this->out->elementStart('li'); + $this->out->checkbox('viewdesigns', _('View profile designs'), + - $user->viewdesigns, _('Show or hide profile designs.')); + $this->out->elementEnd('li'); + $this->out->elementEnd('ul'); + + $this->out->elementEnd('fieldset'); + + $this->out->elementStart('fieldset'); + $this->out->element('legend', null, _('Background file')); + + parent::formData(); + } } |