From a543d599d211d897e1ed22dcde8794b9cf8072fd Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Thu, 10 Mar 2016 19:37:31 -0500 Subject: Add function CommonModel::saveSettingUser() This is a webform handler for the setting modal, user setting tab. --- app/model/common.mod.php | 57 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/app/model/common.mod.php b/app/model/common.mod.php index e52230d..a3e9258 100644 --- a/app/model/common.mod.php +++ b/app/model/common.mod.php @@ -1,6 +1,7 @@ field_bool("setPasswd"); + $form->field_text("curPasswd", null, false); + $form->field_text("newPasswd", null, false); + $form->field_text("confPasswd", null, false); + $form->field_text("alias", null, false); + $form->field_text("email", null, false); + $form->field_text("emailConfKey", null, false); + + if (!$form->populate($input)) + { + $this->logFormErrors($form); + return; + } + + $user = $this->getCurrentUser(); + + if (!$user) + { + $this->logError("Not logged in"); + return; + } + + if ($form->setPasswd == "true") + { + if ($user->validatePassword($form->curPassword)) + { + if ($form->newPasswd == $form->confPassword) + $user->setPassword($form->newPasswd); + else + $this->logWarning("Password not changed -- Passwords did not match"); + } + + else + $this->logWarning("Password not changed -- Current password was incorrect"); + } + + $user->alias = $form->alias; + + if ($form->email != $user->email) + $user->setEmail($form->email); + + else if ($form->emailConfKey != "") + { + if (!$user->confirmEmailKey($form->emailConfKey)) + $this->logWarning("Email not confirmed -- Key was incorrect"); + } + + $user->saveObj(); + } } ?> -- cgit v1.2.3