diff options
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(); + } } ?> |