X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Fdesignsettings.php;h=b70ba0dfcaab6eba7e7eb913baed85f5e6abe8d0;hb=f6bf9529805cd58fdd1671dd9b133bde05e8ae87;hp=820d534f23eadc4d9ecb60d8a3d54e7067c6611e;hpb=b4b992bca77d34b8643910e8d590b5be7fede94b;p=quix0rs-gnu-social.git diff --git a/lib/designsettings.php b/lib/designsettings.php index 820d534f23..b70ba0dfca 100644 --- a/lib/designsettings.php +++ b/lib/designsettings.php @@ -107,7 +107,7 @@ class DesignSettingsAction extends AccountSettingsAction 'type' => 'file', 'id' => 'design_background-image_file')); $this->element('p', 'form_guide', _('You can upload your personal ' . - 'background image. The maximum file size is 2Mb.')); + 'background image. The maximum file size is 2MB.')); $this->element('input', array('name' => 'MAX_FILE_SIZE', 'type' => 'hidden', 'id' => 'MAX_FILE_SIZE', @@ -271,17 +271,20 @@ class DesignSettingsAction extends AccountSettingsAction function handlePost() { - // XXX: Robin's workaround for a bug in PHP where $_POST - // and $_FILE are empty in the case that the uploaded - // file is bigger than PHP is configured to handle. - if ($_SERVER['REQUEST_METHOD'] == 'POST') { - if (empty($_POST) && $_SERVER['CONTENT_LENGTH']) { + // Workaround for PHP returning empty $_POST and $_FILES when POST + // length > post_max_size in php.ini + + if (empty($_FILES) + && empty($_POST) + && ($_SERVER['CONTENT_LENGTH'] > 0) + ) { $msg = _('The server was unable to handle that much POST ' . 'data (%s bytes) due to its current configuration.'); $this->showForm(sprintf($msg, $_SERVER['CONTENT_LENGTH'])); + return; } } @@ -330,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 * @@ -442,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);