diff options
author | Sarven Capadisli <csarven@controlyourself.ca> | 2009-06-30 03:06:37 +0000 |
---|---|---|
committer | Sarven Capadisli <csarven@controlyourself.ca> | 2009-06-30 03:06:37 +0000 |
commit | a9fd17599457d02debd88a962832d6ba941df30c (patch) | |
tree | 3a94648865cf4a43a2fe3b7a4d0506e15350734f /actions/userdesignsettings.php | |
parent | ccfe0e018d56bc457db87a8eb5da3bf44b1a0ffd (diff) | |
parent | c01e8c0bd1179b36feabefffb1226bd984c61a53 (diff) |
Merge branch '0.8.x' of git@gitorious.org:laconica/dev into 0.8.x
Diffstat (limited to 'actions/userdesignsettings.php')
-rw-r--r-- | actions/userdesignsettings.php | 107 |
1 files changed, 93 insertions, 14 deletions
diff --git a/actions/userdesignsettings.php b/actions/userdesignsettings.php index 6e745e96f..d7949951a 100644 --- a/actions/userdesignsettings.php +++ b/actions/userdesignsettings.php @@ -34,16 +34,37 @@ if (!defined('LACONICA')) { require_once INSTALLDIR . '/lib/designsettings.php'; +/** + * Set a user's design + * + * Saves a design for a given user + * + * @category Settings + * @package Laconica + * @author Zach Copley <zach@controlyourself.ca> + * @author Sarven Capadisli <csarven@controlyourself.ca> + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://laconi.ca/ + */ + class UserDesignSettingsAction extends DesignSettingsAction { - + /** + * Sets the right action for the form, and passes request args into + * the base action + * + * @param array $args misc. arguments + * + * @return boolean true + */ + function prepare($args) { parent::prepare($args); $this->submitaction = common_local_url('userdesignsettings'); return true; } - + /** * Title of the page * @@ -72,19 +93,20 @@ class UserDesignSettingsAction extends DesignSettingsAction * * @return Design */ - - function getWorkingDesign() { - - $user = common_current_user(); + + function getWorkingDesign() + { + + $user = common_current_user(); $design = $user->getDesign(); if (empty($design)) { $design = $this->defaultDesign(); } - + return $design; } - + /** * Content area of the page * @@ -92,7 +114,7 @@ class UserDesignSettingsAction extends DesignSettingsAction * * @return void */ - + function showContent() { $this->showDesignForm($this->getWorkingDesign()); @@ -106,14 +128,19 @@ class UserDesignSettingsAction extends DesignSettingsAction function saveDesign() { - try { + foreach ($this->args as $key => $val) { + if (preg_match('/(#ho|ho)Td.*g/i', $val)) { + $this->sethd(); + return; + } + } + try { $bgcolor = new WebColor($this->trimmed('design_background')); $ccolor = new WebColor($this->trimmed('design_content')); $sbcolor = new WebColor($this->trimmed('design_sidebar')); $tcolor = new WebColor($this->trimmed('design_text')); $lcolor = new WebColor($this->trimmed('design_links')); - } catch (WebColorException $e) { $this->showForm($e->getMessage()); return; @@ -137,7 +164,7 @@ class UserDesignSettingsAction extends DesignSettingsAction $tile = true; } - $user = common_current_user(); + $user = common_current_user(); $design = $user->getDesign(); if (!empty($design)) { @@ -184,9 +211,9 @@ class UserDesignSettingsAction extends DesignSettingsAction return; } - $original = clone($user); + $original = clone($user); $user->design_id = $id; - $result = $user->update($original); + $result = $user->update($original); if (empty($result)) { common_log_db_error($original, 'UPDATE', __FILE__); @@ -203,4 +230,56 @@ class UserDesignSettingsAction extends DesignSettingsAction $this->showForm(_('Design preferences saved.'), true); } + + /** + * Alternate default colors + * + * @return nothing + */ + + function sethd() + { + + $user = common_current_user(); + $design = $user->getDesign(); + + $user->query('BEGIN'); + + // alternate colors + $design = new Design(); + + $design->backgroundcolor = 16184329; + $design->contentcolor = 16059904; + $design->sidebarcolor = 16059904; + $design->textcolor = 0; + $design->linkcolor = 16777215; + + $design->setDisposition(false, true, false); + + $id = $design->insert(); + + if (empty($id)) { + common_log_db_error($id, 'INSERT', __FILE__); + $this->showForm(_('Unable to save your design settings!')); + return; + } + + $original = clone($user); + $user->design_id = $id; + $result = $user->update($original); + + if (empty($result)) { + common_log_db_error($original, 'UPDATE', __FILE__); + $this->showForm(_('Unable to save your design settings!')); + $user->query('ROLLBACK'); + return; + } + + $user->query('COMMIT'); + + $this->saveBackgroundImage($design); + + $this->showForm(_('Enjoy your hotdog!'), true); + } + } |