X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Fuserdesignsettings.php;h=8ce5e1f8f3abc9386f54fa01f3988caa6bb7de1a;hb=b7d07466943a73e1c009467c8daa6e499810080f;hp=b82dea8dd6ab44266e40f40a0de13433cfb0f5af;hpb=99db745f9d8746e3170bf779746d855c44f0b951;p=quix0rs-gnu-social.git diff --git a/actions/userdesignsettings.php b/actions/userdesignsettings.php index b82dea8dd6..8ce5e1f8f3 100644 --- a/actions/userdesignsettings.php +++ b/actions/userdesignsettings.php @@ -115,6 +115,20 @@ class UserDesignSettingsAction extends DesignSettingsAction $this->showDesignForm($design); } + /** + * 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 * @@ -122,6 +136,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(); @@ -158,7 +174,8 @@ class UserDesignSettingsAction extends DesignSettingsAction $tile = true; } - $user = common_current_user(); + $user = common_current_user(); + $design = $user->getDesign(); if (!empty($design)) { @@ -271,4 +288,65 @@ 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(); + } }