3 * Laconica - a distributed open-source microblogging tool
4 * Copyright (C) 2008, Controlez-Vous, Inc.
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Affero General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Affero General Public License for more details.
16 * You should have received a copy of the GNU Affero General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 if (!defined('LACONICA')) { exit(1); }
22 class ProfilesettingsAction extends SettingsAction {
24 function show_form($msg=NULL, $success=false) {
25 common_show_header(_t('Profile settings'));
26 $this->settings_menu();
27 $this->message($msg, $success);
28 common_start_element('form', array('method' => 'POST',
29 'id' => 'profilesettings',
31 common_local_url('profilesettings')));
32 common_input('nickname', _t('Nickname'));
33 common_input('fullname', _t('Full name'));
34 common_input('email', _t('Email address'));
35 common_input('homepage', _t('Homepage'));
36 common_input('bio', _t('Bio'));
37 common_input('location', _t('Location'));
38 common_element('input', array('name' => 'submit',
42 common_element('input', array('name' => 'cancel',
49 function handle_post() {
50 $nickname = $this->arg('nickname');
51 $fullname = $this->arg('fullname');
52 $email = $this->arg('email');
53 $homepage = $this->arg('homepage');
54 $bio = $this->arg('bio');
55 $location = $this->arg('location');
57 $user = common_current_user();
58 assert(!is_null($user)); # should already be checked
63 $user->nickname = $this->arg('nickname');
64 $user->email = $this->arg('email');
66 if (!$user->update()) {
67 common_server_error(_t('Couldnt update user.'));
71 $profile = $user->getProfile();
73 $profile->nickname = $user->nickname;
74 $profile->fullname = $this->arg('fullname');
75 $profile->homepage = $this->arg('homepage');
76 $profile->bio = $this->arg('bio');
77 $profile->location = $this->arg('location');
79 if (!$profile->update()) {
80 common_server_error(_t('Couldnt save profile.'));
84 $this->show_form(_t('Settings saved.'), TRUE);