diff options
author | Malf Furious <m@lfurio.us> | 2016-03-10 19:37:31 -0500 |
---|---|---|
committer | Malf Furious <m@lfurio.us> | 2016-03-27 20:16:32 -0400 |
commit | a543d599d211d897e1ed22dcde8794b9cf8072fd (patch) | |
tree | 81fdd1ae9666722bf08bf4c41b5b442477336ef5 /app/model/common.mod.php | |
parent | f270bc774776dd5733ed4d76095281fa9210bac2 (diff) | |
download | scrott-a543d599d211d897e1ed22dcde8794b9cf8072fd.tar.gz scrott-a543d599d211d897e1ed22dcde8794b9cf8072fd.zip |
Add function CommonModel::saveSettingUser()
This is a webform handler for the setting modal, user setting tab.
Diffstat (limited to 'app/model/common.mod.php')
-rw-r--r-- | app/model/common.mod.php | 57 |
1 files changed, 57 insertions, 0 deletions
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 @@ <?php require_once "model/master.mod.php"; +require_once "class/form.class.php"; class CommonModel extends MasterModel { @@ -17,6 +18,62 @@ class CommonModel extends MasterModel else return "glyphicon glyphicon-user"; } + + /* + * Save changes to user account settings + */ + function saveSettingUser($input) + { + $form = new Form(); + $form->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(); + } } ?> |