]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/passwordsettings.php
Remove more contractions
[quix0rs-gnu-social.git] / actions / passwordsettings.php
index e7cd0ab510b39034fb87d454afadedf6dad973b4..6658d279f29f19ff1dad35eceffa0b3d861018d5 100644 (file)
@@ -28,7 +28,7 @@
  * @link      http://status.net/
  */
 
-if (!defined('STATUSNET')) {
+if (!defined('STATUSNET') && !defined('LACONICA')) {
     exit(1);
 }
 
@@ -69,6 +69,12 @@ class PasswordsettingsAction extends AccountSettingsAction
         return _('Change your password.');
     }
 
+    function showScripts()
+    {
+        parent::showScripts();
+        $this->autofocus('oldpassword');
+    }
+
     /**
      * Content area of the page
      *
@@ -91,7 +97,7 @@ class PasswordsettingsAction extends AccountSettingsAction
 
 
         $this->elementStart('ul', 'form_data');
-        // Users who logged in with OpenID won't have a pwd
+        // Users who logged in with OpenID will not have a pwd
         if ($user->password) {
             $this->elementStart('li');
             $this->password('oldpassword', _('Old password'));
@@ -158,23 +164,32 @@ class PasswordsettingsAction extends AccountSettingsAction
                 $this->showForm(_('Incorrect old password'));
                 return;
             }
+        }else{
+            $oldpassword = null;
         }
 
-        $original = clone($user);
+        $errormsg = false;
+        if(! Event::handle('ChangePassword', array($user->nickname, $oldpassword, $newpassword, &$errormsg))){
+            //no handler changed the password, so change the password internally
+            $original = clone($user);
 
-        $user->password = common_munge_password($newpassword, $user->id);
+            $user->password = common_munge_password($newpassword, $user->id);
 
-        $val = $user->validate();
-        if ($val !== true) {
-            $this->showForm(_('Error saving user; invalid.'));
-            return;
-        }
+            $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;
+            if (!$user->update($original)) {
+                $this->serverError(_('Can\'t save new password.'));
+                return;
+            }
         }
 
-        $this->showForm(_('Password saved.'), true);
+        if($errormsg === false)
+            $this->showForm(_('Password saved.'), true);
+        else
+            $this->showForm($errormsg);
     }
 }