]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/profilesettings.php
fix url for redirect
[quix0rs-gnu-social.git] / actions / profilesettings.php
index dff91d5601c35ad0e5a42cc6142d7ebdc9811d6c..75e3758aba9da48900adbdf2967ed167cb13574f 100644 (file)
@@ -23,18 +23,25 @@ require_once(INSTALLDIR.'/lib/settingsaction.php');
 
 class ProfilesettingsAction extends SettingsAction {
 
-       function show_form($msg=NULL, $success=false) {
-               $user = common_current_user();
-               $profile = $user->getProfile();
-               common_show_header(_t('Profile settings'), NULL, NULL, array($this, 'settings_menu'));
-
+       function show_top($arr) {
+               $msg = $arr[0];
+               $success = $arr[1];
                if ($msg) {
                        $this->message($msg, $success);
                } else {
                        common_element('div', 'instructions',
                                                   _t('You can update your personal profile info here '.
-                                                         'so people know more about you. '));
+                                                         'so people know more about you.'));
                }
+               $this->settings_menu();
+       }
+       
+       function show_form($msg=NULL, $success=false) {
+               $user = common_current_user();
+               $profile = $user->getProfile();
+               common_show_header(_t('Profile settings'), NULL, array($msg, $success),
+                                                  array($this, 'show_top'));
+
                common_element_start('form', array('method' => 'POST',
                                                                                   'id' => 'profilesettings',
                                                                                   'action' =>
@@ -105,16 +112,16 @@ class ProfilesettingsAction extends SettingsAction {
                $user = common_current_user();
                assert(!is_null($user)); # should already be checked
 
-               # FIXME: transaction!
-
+               $user->query('BEGIN');
+               
                $original = clone($user);
 
                $user->nickname = $nickname;
                $user->email = $email;
 
-               common_debug('Updating, nickname ="'.$user->nickname.'" and email ="'.$user->email.'"');
+               $result = $user->update($original);
                
-               if (FALSE === $user->update($original)) {
+               if (!$result) {
                        common_server_error(_t('Couldnt update user.'));
                        return;
                }
@@ -130,12 +137,16 @@ class ProfilesettingsAction extends SettingsAction {
                $profile->location = $location;
                $profile->profileurl = common_profile_url($nickname);
 
-               if (FALSE === $profile->update($orig_profile)) {
+               $result = $profile->update($orig_profile);
+               
+               if (!$result) {
                        common_server_error(_t('Couldnt save profile.'));
                        return;
                }
 
                common_broadcast_profile($profile);
+
+               $user->query('COMMIT');
                
                $this->show_form(_t('Settings saved.'), TRUE);
        }