reformat designsettings.php

This commit is contained in:
Evan Prodromou 2009-05-22 20:50:08 -04:00
parent 677434b113
commit 3a44885b7f

View File

@ -33,8 +33,6 @@ if (!defined('LACONICA')) {
require_once INSTALLDIR.'/lib/accountsettingsaction.php';
class DesignsettingsAction extends AccountSettingsAction
{
/**
@ -83,7 +81,7 @@ class DesignsettingsAction extends AccountSettingsAction
$this->elementStart('ul', 'form_data');
$this->elementStart('li');
$this->element('label', array('for' => 'design_ background-image_file'),
_('Upload file'));
_('Upload file'));
$this->element('input', array('name' => 'design_background-image_file',
'type' => 'file',
'id' => 'design_background-image_file'));
@ -101,11 +99,11 @@ class DesignsettingsAction extends AccountSettingsAction
$this->elementStart('ul', 'form_data');
//This is a JSON object in the DB field. Here for testing. Remove later.
$userSwatch = '{"body":{"background-color":"#F0F2F5"},
"#content":{"background-color":"#FFFFFF"},
"#aside_primary":{"background-color":"#CEE1E9"},
"html body":{"color":"#000000"},
"a":{"color":"#002E6E"}}';
$userSwatch = '{"body":{"background-color":"#F0F2F5"},'.
'"#content":{"background-color":"#FFFFFF"},'.
'"#aside_primary":{"background-color":"#CEE1E9"},'.
'"html body":{"color":"#000000"},'.
'"a":{"color":"#002E6E"}}';
//Default theme swatch -- Where should this be stored?
$defaultSwatch = array('body' => array('background-color' => '#F0F2F5'),
@ -147,14 +145,13 @@ class DesignsettingsAction extends AccountSettingsAction
'title' => _('Reset back to default')));
$this->submit('save', _('Save'), 'submit form_action-secondary', 'save', _('Save design'));
/*TODO: Check submitted form values:
json_encode(form values)
if submitted Swatch == DefaultSwatch, don't store in DB.
else store in BD
*/
/*TODO: Check submitted form values:
json_encode(form values)
if submitted Swatch == DefaultSwatch, don't store in DB.
else store in BD
*/
$this->elementEnd('fieldset');
$this->elementEnd('form');
}
/**
@ -168,63 +165,10 @@ else store in BD
function handlePost()
{
/*
// CSRF protection
$token = $this->trimmed('token');
if (!$token || $token != common_session_token()) {
$this->showForm(_('There was a problem with your session token. '.
'Try again, please.'));
return;
}
$user = common_current_user();
assert(!is_null($user)); // should already be checked
// FIXME: scrub input
$newpassword = $this->arg('newpassword');
$confirm = $this->arg('confirm');
# Some validation
if (strlen($newpassword) < 6) {
$this->showForm(_('Password must be 6 or more characters.'));
return;
} else if (0 != strcmp($newpassword, $confirm)) {
$this->showForm(_('Passwords don\'t match.'));
return;
}
if ($user->password) {
$oldpassword = $this->arg('oldpassword');
if (!common_check_user($user->nickname, $oldpassword)) {
$this->showForm(_('Incorrect old password'));
return;
}
}
$original = clone($user);
$user->password = common_munge_password($newpassword, $user->id);
$val = $user->validate();
if ($val !== true) {
$this->showForm(_('Error saving user; invalid.'));
return;
}
if (!$user->update($original)) {
$this->serverError(_('Can\'t save new password.'));
return;
}
$this->showForm(_('Password saved.'), true);
*/
// TODO: implement this
return;
}
/**
* Add the Farbtastic stylesheet
*