diff options
author | Zach Copley <zach@status.net> | 2009-12-03 00:54:46 +0000 |
---|---|---|
committer | Zach Copley <zach@status.net> | 2009-12-03 00:54:46 +0000 |
commit | bf63734359976a0bc32a45687fcda190b693b9d1 (patch) | |
tree | f195cf1e92641b447e59c9bd1da72377119952ae | |
parent | f55b0e9b3da3e88c30dc7823f9fd46e50917b89c (diff) | |
parent | 4f359d2a8baa89f3ced8b9d7ac2c9dd1b4cfb73b (diff) |
Merge branch 'fix-default-design' into 0.9.x
-rw-r--r-- | actions/groupdesignsettings.php | 13 | ||||
-rw-r--r-- | actions/userdesignsettings.php | 14 | ||||
-rw-r--r-- | lib/api.php | 3 | ||||
-rw-r--r-- | lib/designsettings.php | 66 |
4 files changed, 23 insertions, 73 deletions
diff --git a/actions/groupdesignsettings.php b/actions/groupdesignsettings.php index b87b7d156..1c998efe1 100644 --- a/actions/groupdesignsettings.php +++ b/actions/groupdesignsettings.php @@ -173,17 +173,12 @@ class GroupDesignSettingsAction extends DesignSettingsAction function getWorkingDesign() { - $design = null; if (isset($this->group)) { $design = $this->group->getDesign(); } - if (empty($design)) { - $design = $this->defaultDesign(); - } - return $design; } @@ -197,7 +192,13 @@ class GroupDesignSettingsAction extends DesignSettingsAction function showContent() { - $this->showDesignForm($this->getWorkingDesign()); + $design = $this->getWorkingDesign(); + + if (empty($design)) { + $design = Design::siteDesign(); + } + + $this->showDesignForm($design); } /** diff --git a/actions/userdesignsettings.php b/actions/userdesignsettings.php index 568c1d624..31a097970 100644 --- a/actions/userdesignsettings.php +++ b/actions/userdesignsettings.php @@ -96,14 +96,8 @@ class UserDesignSettingsAction extends DesignSettingsAction function getWorkingDesign() { - $user = common_current_user(); $design = $user->getDesign(); - - if (empty($design)) { - $design = $this->defaultDesign(); - } - return $design; } @@ -117,7 +111,13 @@ class UserDesignSettingsAction extends DesignSettingsAction function showContent() { - $this->showDesignForm($this->getWorkingDesign()); + $design = $this->getWorkingDesign(); + + if (empty($design)) { + $design = Design::siteDesign(); + } + + $this->showDesignForm($design); } /** diff --git a/lib/api.php b/lib/api.php index e2ea87b43..5a3bb5ee4 100644 --- a/lib/api.php +++ b/lib/api.php @@ -134,7 +134,6 @@ class ApiAction extends Action $twitter_user['protected'] = false; # not supported by StatusNet yet $twitter_user['followers_count'] = $profile->subscriberCount(); - $defaultDesign = Design::siteDesign(); $design = null; $user = $profile->getUser(); @@ -145,7 +144,7 @@ class ApiAction extends Action } if (empty($design)) { - $design = $defaultDesign; + $design = Design::siteDesign(); } $color = Design::toWebColor(empty($design->backgroundcolor) ? $defaultDesign->backgroundcolor : $design->backgroundcolor); diff --git a/lib/designsettings.php b/lib/designsettings.php index 99f44b5b7..b70ba0dfc 100644 --- a/lib/designsettings.php +++ b/lib/designsettings.php @@ -334,49 +334,6 @@ class DesignSettingsAction extends AccountSettingsAction } /** - * Get a default design - * - * @return Design design - */ - - function defaultDesign() - { - $defaults = common_config('site', 'design'); - - $design = new Design(); - - try { - - $color = new WebColor(); - - $color->parseColor($defaults['backgroundcolor']); - $design->backgroundcolor = $color->intValue(); - - $color->parseColor($defaults['contentcolor']); - $design->contentcolor = $color->intValue(); - - $color->parseColor($defaults['sidebarcolor']); - $design->sidebarcolor = $color->intValue(); - - $color->parseColor($defaults['textcolor']); - $design->textcolor = $color->intValue(); - - $color->parseColor($defaults['linkcolor']); - $design->linkcolor = $color->intValue(); - - $design->backgroundimage = $defaults['backgroundimage']; - - $design->disposition = $defaults['disposition']; - - } catch (WebColorException $e) { - common_log(LOG_ERR, _('Bad default color settings: ' . - $e->getMessage())); - } - - return $design; - } - - /** * Save the background image, if any, and set its disposition * * @param Design $design a working design to attach the img to @@ -445,24 +402,17 @@ class DesignSettingsAction extends AccountSettingsAction 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 = $this->getWorkingDesign(); - $design->setDisposition(false, true, false); + if (!empty($design)) { - $result = $design->update($original); + $result = $design->delete(); - if ($result === false) { - common_log_db_error($design, 'UPDATE', __FILE__); - $this->showForm(_('Couldn\'t update your design.')); - return; + if ($result === false) { + common_log_db_error($design, 'DELETE', __FILE__); + $this->showForm(_('Couldn\'t update your design.')); + return; + } } $this->showForm(_('Design defaults restored.'), true); |