From 3b2b46aaefc3c98969173debfb3ee8e59ab6e5fd Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Sat, 5 Mar 2016 22:40:57 -0500 Subject: Add Dashboard model --- app/model/dashboard.mod.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 app/model/dashboard.mod.php (limited to 'app/model') diff --git a/app/model/dashboard.mod.php b/app/model/dashboard.mod.php new file mode 100644 index 0000000..845a56a --- /dev/null +++ b/app/model/dashboard.mod.php @@ -0,0 +1,15 @@ + -- cgit v1.2.3 From 3168dceb5434ac8a6f0bd397712019597ea2dd4c Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Sun, 6 Mar 2016 14:30:01 -0500 Subject: Add function getCurrentUserGlyphicon() to Common model This helps render data for the common topp view (navbar). This function will return the glyphicon to use next to the current user's name. --- app/model/common.mod.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'app/model') diff --git a/app/model/common.mod.php b/app/model/common.mod.php index d4270d8..e52230d 100644 --- a/app/model/common.mod.php +++ b/app/model/common.mod.php @@ -4,6 +4,19 @@ require_once "model/master.mod.php"; class CommonModel extends MasterModel { + /* + * Get the glyphicon to use for the logged in user (user or admin) + */ + function getCurrentUserGlyphicon() + { + if (!$this->getCurrentUser()) + return ""; + + if ($this->getCurrentUser()->admin == 1) + return "glyphicon glyphicon-sunglasses"; + else + return "glyphicon glyphicon-user"; + } } ?> -- cgit v1.2.3 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(+) (limited to 'app/model') 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 From c93ae572abf32262137cce69f1c020e9a5b46d9f Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Thu, 10 Mar 2016 20:35:32 -0500 Subject: Add function CommonModel::common_handleFormSubmissions() This helper func to all implementing MVC controllers is used to check for submission of any web-form defined within a common MVC view file. If detected, the appropriate handler function is called. --- app/model/common.mod.php | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'app/model') diff --git a/app/model/common.mod.php b/app/model/common.mod.php index a3e9258..9289c21 100644 --- a/app/model/common.mod.php +++ b/app/model/common.mod.php @@ -19,6 +19,17 @@ class CommonModel extends MasterModel return "glyphicon glyphicon-user"; } + /* + * Handle form submissions from common views + */ + function common_handleFormSubmissions($input) + { + switch ($input['action']) + { + case "common-setting-user": $this->saveSettingUser($input); break; + } + } + /* * Save changes to user account settings */ -- cgit v1.2.3 From e14bce5a9de98df6d19ea4ce7243bc7b19c7904b Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Thu, 10 Mar 2016 20:41:23 -0500 Subject: Fix function CommonModel::saveSettingUser() Farious fixes for this form submission handler * missspelled variable names (*Password => *Passwd) * Added a notice message for password change success --- app/model/common.mod.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'app/model') diff --git a/app/model/common.mod.php b/app/model/common.mod.php index 9289c21..cbcbd4b 100644 --- a/app/model/common.mod.php +++ b/app/model/common.mod.php @@ -40,8 +40,8 @@ class CommonModel extends MasterModel $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("alias", "", false); + $form->field_text("email", "", false); $form->field_text("emailConfKey", null, false); if (!$form->populate($input)) @@ -60,10 +60,13 @@ class CommonModel extends MasterModel if ($form->setPasswd == "true") { - if ($user->validatePassword($form->curPassword)) + if ($user->validatePassword($form->curPasswd)) { - if ($form->newPasswd == $form->confPassword) + if ($form->newPasswd == $form->confPasswd) + { $user->setPassword($form->newPasswd); + $this->logNotice("Password updated successfully"); + } else $this->logWarning("Password not changed -- Passwords did not match"); } -- cgit v1.2.3 From 3bd0d2779534221af0db22e5b5bc86faaa3b2957 Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Fri, 11 Mar 2016 22:25:00 -0500 Subject: Populate admin setting fields on page load Added logic to set initial state of fields on the setting modal's admin tab --- app/model/common.mod.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'app/model') diff --git a/app/model/common.mod.php b/app/model/common.mod.php index cbcbd4b..a0bf6ae 100644 --- a/app/model/common.mod.php +++ b/app/model/common.mod.php @@ -2,6 +2,7 @@ require_once "model/master.mod.php"; require_once "class/form.class.php"; +require_once "class/setting.class.php"; class CommonModel extends MasterModel { @@ -19,6 +20,26 @@ class CommonModel extends MasterModel return "glyphicon glyphicon-user"; } + /* + * Default action + */ + function common_deflt() + { + global $_SCROTT; + + /* Admin settings tab */ + if ($_SCROTT['settSSL'] != "neither") + { + $this->common_settingAdminSettSSLChecked[$_SCROTT['settSSL']] = "checked"; + $this->common_settingAdminSettSSLDisabled = "disabled"; + } + else + $this->common_settingAdminSettSSLChecked[Setting::settSSL()] = "checked"; + + if (Setting::allowPublicSignup()) + $this->common_settingAdminAllowPublicSignupChecked = "checked"; + } + /* * Handle form submissions from common views */ -- cgit v1.2.3 From cc755e3756e43109d0db0de963b3a132039456b1 Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Sat, 12 Mar 2016 15:05:12 -0500 Subject: Alter representation of form boolean values Changed how Form() objects model true and false for boolean fields. Was "true" and "false", is now "1" and "0", respectivly. This is to address how Mysql handles these values as they are pushed to the db. --- app/model/common.mod.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/model') diff --git a/app/model/common.mod.php b/app/model/common.mod.php index a0bf6ae..33acb1b 100644 --- a/app/model/common.mod.php +++ b/app/model/common.mod.php @@ -79,7 +79,7 @@ class CommonModel extends MasterModel return; } - if ($form->setPasswd == "true") + if ($form->setPasswd) { if ($user->validatePassword($form->curPasswd)) { -- cgit v1.2.3 From 587bdef47abbf4545508cac95a0495be0d5ddaa5 Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Sat, 12 Mar 2016 16:21:41 -0500 Subject: Handle submissions to setting modal, admin tab --- app/model/common.mod.php | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'app/model') diff --git a/app/model/common.mod.php b/app/model/common.mod.php index 33acb1b..34ac17d 100644 --- a/app/model/common.mod.php +++ b/app/model/common.mod.php @@ -47,7 +47,8 @@ class CommonModel extends MasterModel { switch ($input['action']) { - case "common-setting-user": $this->saveSettingUser($input); break; + case "common-setting-user": $this->saveSettingUser($input); break; + case "common-setting-admin": $this->saveSettingAdmin($input); break; } } @@ -109,6 +110,33 @@ class CommonModel extends MasterModel $user->saveObj(); } + + /* + * Save changes to admin settings + */ + function saveSettingAdmin($input) + { + $form = new Form(); + $form->field_enum("settSSL", array("force", "neither", "forbid")); + $form->field_bool("allowPublicSignup"); + + if (!$form->populate($input)) + { + $this->logFormErrors($form); + return; + } + + $user = $this->getCurrentUser(); + + if (!$user || $user->admin == 0) + { + $this->logError("Admin permissions required"); + return; + } + + Setting::settSSL($form->settSSL); + Setting::allowPublicSignup($form->allowPublicSignup); + } } ?> -- cgit v1.2.3 From 2936f0d151fb52bd2649edc37abd2e1d559d1f0f Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Sat, 12 Mar 2016 23:38:18 -0500 Subject: Move getUserGlyphicon function from common model into user class --- app/model/common.mod.php | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'app/model') diff --git a/app/model/common.mod.php b/app/model/common.mod.php index 34ac17d..7f0302f 100644 --- a/app/model/common.mod.php +++ b/app/model/common.mod.php @@ -6,20 +6,6 @@ require_once "class/setting.class.php"; class CommonModel extends MasterModel { - /* - * Get the glyphicon to use for the logged in user (user or admin) - */ - function getCurrentUserGlyphicon() - { - if (!$this->getCurrentUser()) - return ""; - - if ($this->getCurrentUser()->admin == 1) - return "glyphicon glyphicon-sunglasses"; - else - return "glyphicon glyphicon-user"; - } - /* * Default action */ -- cgit v1.2.3 From 92e255cf02de8dc34f1221c952b3dd3bec9cc62b Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Sun, 13 Mar 2016 17:59:37 -0400 Subject: Alter admin setting form handler Set a default value for field 'settSSL'. If this value is locked in the system-level configuration, then the disabled radio buttons don't assume a value during POST submission to the page and the field appears to the $form object as being unset. I use the currently set value for this option as the default. --- app/model/common.mod.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/model') diff --git a/app/model/common.mod.php b/app/model/common.mod.php index 7f0302f..8d1ea7e 100644 --- a/app/model/common.mod.php +++ b/app/model/common.mod.php @@ -103,7 +103,7 @@ class CommonModel extends MasterModel function saveSettingAdmin($input) { $form = new Form(); - $form->field_enum("settSSL", array("force", "neither", "forbid")); + $form->field_enum("settSSL", array("force", "neither", "forbid"), Setting::settSSL()); $form->field_bool("allowPublicSignup"); if (!$form->populate($input)) -- cgit v1.2.3 From 99ec6644fc93ee4d6bd8569148de6a03d64f69cb Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Sat, 26 Mar 2016 17:18:08 -0400 Subject: Add collapsable panel for editing each user's settings to admin setting tab Also, added relevant initialization code to common model --- app/model/common.mod.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'app/model') diff --git a/app/model/common.mod.php b/app/model/common.mod.php index 8d1ea7e..1398598 100644 --- a/app/model/common.mod.php +++ b/app/model/common.mod.php @@ -3,6 +3,7 @@ require_once "model/master.mod.php"; require_once "class/form.class.php"; require_once "class/setting.class.php"; +require_once "class/user.class.php"; class CommonModel extends MasterModel { @@ -24,6 +25,10 @@ class CommonModel extends MasterModel if (Setting::allowPublicSignup()) $this->common_settingAdminAllowPublicSignupChecked = "checked"; + + /* Admin all-users settings tab */ + $userTbl = new User(); + $this->common_settingAllUsers = $userTbl->getAllUsers_orderByAdminByName(); } /* -- cgit v1.2.3 From 4fef70c3afd276c8509efdf06d41cedb467ababe Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Sat, 26 Mar 2016 23:23:39 -0400 Subject: Add form handler for setting modal, all users, create new user pane This handler is requires admin status and allows you to create a new application user --- app/model/common.mod.php | 56 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 54 insertions(+), 2 deletions(-) (limited to 'app/model') diff --git a/app/model/common.mod.php b/app/model/common.mod.php index 1398598..1d5f036 100644 --- a/app/model/common.mod.php +++ b/app/model/common.mod.php @@ -38,8 +38,9 @@ class CommonModel extends MasterModel { switch ($input['action']) { - case "common-setting-user": $this->saveSettingUser($input); break; - case "common-setting-admin": $this->saveSettingAdmin($input); break; + case "common-setting-user": $this->saveSettingUser($input); break; + case "common-setting-admin": $this->saveSettingAdmin($input); break; + case "common-setting-allusers-adduser": $this->saveSettingAllusersAdduser($input); break; } } @@ -128,6 +129,57 @@ class CommonModel extends MasterModel Setting::settSSL($form->settSSL); Setting::allowPublicSignup($form->allowPublicSignup); } + + /* + * Allow an admin to create a new user account + */ + function saveSettingAllusersAdduser($input) + { + $form = new Form(); + $form->field_text("username"); + $form->field_text("password", null, false); + $form->field_text("cPassword", null, false); + $form->field_bool("admin"); + $form->field_text("alias", "", false); + $form->field_text("email", "", false); + + if (!$form->populate($input)) + { + $this->logFormErrors($form); + return; + } + + $user = $this->getCurrentUser(); + + if (!$user || $user->admin == 0) + { + $this->logError("Admin permissions required"); + return; + } + + if ($form->password != $form->cPassword) + { + $this->logError("Passwords do not match"); + return; + } + + $user = new User(); + + if (!$user->createNewUser($form->username, $form->password)) + { + $this->logError("Username " . $form->username . " is not available"); + return; + } + + if ($form->admin) + $user->admin = 1; + + $user->alias = $form->alias; + $user->setEmail($form->email); + $user->saveObj(); + + $this->logNotice("Created new user " . $form->username); + } } ?> -- cgit v1.2.3 From e55a32c647cab450c2a6c6a3156c798dc0f70256 Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Sun, 27 Mar 2016 17:28:44 -0400 Subject: Add form handler for setting modal, admin/all users tab, for edit user action --- app/model/common.mod.php | 63 +++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 60 insertions(+), 3 deletions(-) (limited to 'app/model') diff --git a/app/model/common.mod.php b/app/model/common.mod.php index 1d5f036..b1aa0a0 100644 --- a/app/model/common.mod.php +++ b/app/model/common.mod.php @@ -38,9 +38,10 @@ class CommonModel extends MasterModel { switch ($input['action']) { - case "common-setting-user": $this->saveSettingUser($input); break; - case "common-setting-admin": $this->saveSettingAdmin($input); break; - case "common-setting-allusers-adduser": $this->saveSettingAllusersAdduser($input); break; + case "common-setting-user": $this->saveSettingUser($input); break; + case "common-setting-admin": $this->saveSettingAdmin($input); break; + case "common-setting-allusers-adduser": $this->saveSettingAllusersAdduser($input); break; + case "common-setting-allusers-edituser": $this->saveSettingAllusersEdituser($input); break; } } @@ -180,6 +181,62 @@ class CommonModel extends MasterModel $this->logNotice("Created new user " . $form->username); } + + /* + * Allow an admin to edit user accounts + */ + function saveSettingAllusersEdituser($input) + { + $form = new Form(); + $form->field_text("guid"); + $form->field_bool("setPasswd"); + $form->field_text("newPasswd", null, false); + $form->field_text("confPasswd", null, false); + $form->field_bool("admin"); + $form->field_text("alias", "", false); + $form->field_text("email", "", false); + + if (!$form->populate($input)) + { + $this->logFormErrors($form); + return; + } + + $user = $this->getCurrentUser(); + + if (!$user || $user->admin == 0) + { + $this->logError("Admin permissions required"); + return; + } + + $user = new User($form->guid); + + if ($user->type != "user") + { + $this->logError("Invalid user GUID"); + return; + } + + if ($form->setPasswd) + { + if ($form->newPasswd == $form->confPasswd) + { + $user->setPassword($form->newPasswd); + $this->logNotice("Password for " . $user->name . " updated successfully"); + } + else + $this->logWarning("Password not changed -- Passwords did not match"); + } + + $user->admin = $form->admin; + $user->alias = $form->alias; + + if ($form->email != $user->email) + $user->setEmail($form->email); + + $user->saveObj(); + } } ?> -- cgit v1.2.3