3 * Laconica, the distributed open-source microblogging tool
9 * LICENCE: This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU Affero General Public License as published by
11 * the Free Software Foundation, either version 3 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Affero General Public License for more details.
19 * You should have received a copy of the GNU Affero General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 * @author Sarven Capadisli <csarven@controlyourself.ca>
25 * @copyright 2008-2009 Control Yourself, Inc.
26 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
27 * @link http://laconi.ca/
30 if (!defined('LACONICA')) {
34 require_once INSTALLDIR.'/lib/accountsettingsaction.php';
38 class DesignsettingsAction extends AccountSettingsAction
43 * @return string Title of the page
48 return _('Profile design');
52 * Instructions for use
54 * @return instructions for use
57 function getInstructions()
59 return _('Customize the way your profile looks with a background image and a colour palette of your choice.');
63 * Content area of the page
65 * Shows a form for changing the password
70 function showContent()
72 $user = common_current_user();
73 $this->elementStart('form', array('method' => 'POST',
74 'id' => 'form_settings_design',
75 'class' => 'form_settings',
77 common_local_url('designsettings')));
78 $this->elementStart('fieldset');
79 // $this->element('legend', null, _('Design settings'));
80 $this->hidden('token', common_session_token());
82 $this->elementStart('fieldset', array('id' => 'settings_design_background-image'));
83 $this->element('legend', null, _('Change background image'));
84 $this->elementStart('ul', 'form_data');
85 $this->elementStart('li');
86 $this->element('p', null, _('Upload background image'));
87 $this->elementEnd('li');
88 $this->elementEnd('ul');
89 $this->elementEnd('fieldset');
91 $this->elementStart('fieldset', array('id' => 'settings_design_color'));
92 $this->element('legend', null, _('Change colours'));
93 $this->elementStart('ul', 'form_data');
94 $this->elementStart('li');
95 $this->input('color-1', _('Background color'), '#F0F2F5', null);
96 $this->elementEnd('li');
97 $this->elementStart('li');
98 $this->input('color-2', _('Content background color'), '#FFFFFF', null);
99 $this->elementEnd('li');
100 $this->elementStart('li');
101 $this->input('color-3', _('Sidebar background color'), '#CEE1E9', null);
102 $this->elementEnd('li');
103 $this->elementStart('li');
104 $this->input('color-4', _('Text color'), '#000000', null);
105 $this->elementEnd('li');
106 $this->elementStart('li');
107 $this->input('color-5', _('Link color'), '#002E6E', null);
108 $this->elementEnd('li');
109 $this->elementEnd('ul');
110 $this->element('div', array('id' => 'color-picker'));
111 $this->elementEnd('fieldset');
114 $this->submit('save', _('Save'));
116 $this->elementEnd('fieldset');
117 $this->elementEnd('form');
124 * Validate input and save changes. Reload the form with a success
130 function handlePost()
135 $token = $this->trimmed('token');
136 if (!$token || $token != common_session_token()) {
137 $this->showForm(_('There was a problem with your session token. '.
138 'Try again, please.'));
142 $user = common_current_user();
143 assert(!is_null($user)); // should already be checked
145 // FIXME: scrub input
147 $newpassword = $this->arg('newpassword');
148 $confirm = $this->arg('confirm');
152 if (strlen($newpassword) < 6) {
153 $this->showForm(_('Password must be 6 or more characters.'));
155 } else if (0 != strcmp($newpassword, $confirm)) {
156 $this->showForm(_('Passwords don\'t match.'));
160 if ($user->password) {
161 $oldpassword = $this->arg('oldpassword');
163 if (!common_check_user($user->nickname, $oldpassword)) {
164 $this->showForm(_('Incorrect old password'));
169 $original = clone($user);
171 $user->password = common_munge_password($newpassword, $user->id);
173 $val = $user->validate();
175 $this->showForm(_('Error saving user; invalid.'));
179 if (!$user->update($original)) {
180 $this->serverError(_('Can\'t save new password.'));
184 $this->showForm(_('Password saved.'), true);
190 * Add the jCrop stylesheet
195 function showStylesheets()
197 parent::showStylesheets();
199 common_path('theme/base/css/farbtastic.css?version='.LACONICA_VERSION);
201 $this->element('link', array('rel' => 'stylesheet',
202 'type' => 'text/css',
203 'href' => $farbtasticStyle,
204 'media' => 'screen, projection, tv'));
208 * Add the jCrop scripts
213 function showScripts()
215 parent::showScripts();
217 // if ($this->mode == 'crop') {
218 $farbtasticPack = common_path('js/farbtastic/farbtastic.js');
219 $farbtasticGo = common_path('js/farbtastic/farbtastic.go.js');
221 $this->element('script', array('type' => 'text/javascript',
222 'src' => $farbtasticPack));
223 $this->element('script', array('type' => 'text/javascript',
224 'src' => $farbtasticGo));