From 135927e42a36e2accce557419f8c7d9cb8b999c0 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Mon, 29 Jun 2009 14:52:38 -0700 Subject: Allow users and groups to reset their design to system default colors --- lib/designsettings.php | 41 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/designsettings.php b/lib/designsettings.php index 5def5053f..0b5a76b91 100644 --- a/lib/designsettings.php +++ b/lib/designsettings.php @@ -272,8 +272,8 @@ class DesignSettingsAction extends AccountSettingsAction if ($this->arg('save')) { $this->saveDesign(); - } else if ($this->arg('reset')) { - $this->resetDesign(); + } else if ($this->arg('defaults')) { + $this->restoreDefaults(); } else { $this->showForm(_('Unexpected form submission.')); } @@ -359,6 +359,12 @@ class DesignSettingsAction extends AccountSettingsAction return $design; } + /** + * Save the background image, if any, and set its disposition + * + * @return nothing + */ + function saveBackgroundImage($design) { // Now that we have a Design ID we can add a file to the design. @@ -404,4 +410,35 @@ class DesignSettingsAction extends AccountSettingsAction } } + /** + * Restore the user or group design to system defaults + * + * @return nothing + */ + + function restoreDefaults() + { + $design = $this->getWorkingDesign(); + $default = $this->defaultDesign(); + $original = clone($design); + + $design->backgroundcolor = $default->backgroundcolor; + $design->contentcolor = $default->contentcolor; + $design->sidebarcolor = $default->sidebarcolor; + $design->textcolor = $default->textcolor; + $design->linkcolor = $default->linkcolor; + + $design->setDisposition(false, true, false); + + $result = $design->update($original); + + if ($result === false) { + common_log_db_error($design, 'UPDATE', __FILE__); + $this->showForm(_('Couldn\'t update your design.')); + return; + } + + $this->showForm(_('Design defaults restored.'), true); + } + } -- cgit v1.2.3-54-g00ecf