]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Delete design when user chooses to restore default design, instead
authorZach Copley <zach@status.net>
Thu, 3 Dec 2009 00:44:23 +0000 (16:44 -0800)
committerZach Copley <zach@status.net>
Thu, 3 Dec 2009 00:56:53 +0000 (00:56 +0000)
of saving a design with site defaults.

actions/groupdesignsettings.php
actions/userdesignsettings.php
lib/api.php
lib/designsettings.php

index b87b7d156a3f9ae511da3e037a1c2531f4fa5aa1..1c998efe1e215772beb8e96facbd4084341ab7ff 100644 (file)
@@ -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);
     }
 
     /**
index 568c1d62424ea047bb601f66f479ef7718899251..31a097970dc6bd5f63024c783c53156694a78311 100644 (file)
@@ -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);
     }
 
     /**
index e2ea87b43eb3d934d7c1d2d9bfa653fabcbe5037..5a3bb5ee451011aaec324399da0e6755929e70fc 100644 (file)
@@ -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);
index 5ce9ddedadf5529c516e94f372d06024f242b67c..7b8c78c3029a5250c2b7f940d21f518c65adf252 100644 (file)
@@ -333,49 +333,6 @@ class DesignSettingsAction extends AccountSettingsAction
         $this->autofocus('design_background-image_file');
     }
 
-    /**
-     * 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
      *
@@ -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);