From ac5410de94127d7fe139de0e9bf4fd1c20bdae2b Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Fri, 1 Apr 2016 00:46:17 -0400 Subject: Add function getHeadImage() to User class This function will return the path to the head image (user image) for the user object. This path should be something like: /file.php?d=img/heads&f= --- app/class/user.class.php | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'app') diff --git a/app/class/user.class.php b/app/class/user.class.php index 1130396..ab9ecf5 100644 --- a/app/class/user.class.php +++ b/app/class/user.class.php @@ -187,6 +187,14 @@ class User extends Object return "glyphicon glyphicon-user"; } + + /* + * Get this user's head image + */ + function getHeadImage() + { + return $this->ar() . "/file.php?d=img/heads&f=" . $this->guid; + } } ?> -- cgit v1.2.3 From 679ab64e465f610ae70aff8a1b491191863f7033 Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Fri, 1 Apr 2016 00:56:34 -0400 Subject: Update setting modal, user tab to display user head image Also restructured the web form a little and added the form-group to select a new image to upload --- app/view/common/setting.modal.view.php | 47 ++++++++++++++++++++++++++-------- 1 file changed, 36 insertions(+), 11 deletions(-) (limited to 'app') diff --git a/app/view/common/setting.modal.view.php b/app/view/common/setting.modal.view.php index 11adc69..2415e18 100644 --- a/app/view/common/setting.modal.view.php +++ b/app/view/common/setting.modal.view.php @@ -27,21 +27,46 @@

 

- getCurrentUser()->admin == 1) { ?> -

getCurrentUser()->getDisplayName()?> is a Scrott Administrator

- -
-
- - + +
+
+ getCurrentUser()->admin == 1) { ?> +

getCurrentUser()->getDisplayName()?> is a Scrott Administrator

+ + +
+ + +
+ +
+ +
+
+ +
+ <?=$mod->getCurrentUser()->getDisplayName()?> +
+
+ +
+ +
-
- +
+
+ + +
-- cgit v1.2.3 From 0ad5c4d29ca5d4109a7fe33cdfc9b8e6b01ace6b Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Mon, 4 Apr 2016 23:35:23 -0400 Subject: Add view markup for showing user head images to the all users collapse panes --- app/view/common/setting.modal.view.php | 38 +++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) (limited to 'app') diff --git a/app/view/common/setting.modal.view.php b/app/view/common/setting.modal.view.php index 2415e18..19bcf5c 100644 --- a/app/view/common/setting.modal.view.php +++ b/app/view/common/setting.modal.view.php @@ -223,15 +223,39 @@ -
- - +
+
+
+ + +
+ +
+ +
+
+ +
+ <?=$user->getDisplayName()?> +
+
+ +
+ +
-
- +
+
+ + +
-- cgit v1.2.3 From 423fa09e3f524c8139d18c3e8652f542bcf2cd44 Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Wed, 27 Apr 2016 23:38:49 -0400 Subject: Update form handler for common/setting-modal, user tab Now supports file upload to replace the user's head image --- app/controller/dashboard.control.php | 2 +- app/model/common.mod.php | 17 +++++++++++------ app/view/common/setting.modal.view.php | 4 ++-- 3 files changed, 14 insertions(+), 9 deletions(-) (limited to 'app') diff --git a/app/controller/dashboard.control.php b/app/controller/dashboard.control.php index 53ca160..aa1c0bd 100644 --- a/app/controller/dashboard.control.php +++ b/app/controller/dashboard.control.php @@ -14,7 +14,7 @@ class Dashboard extends Controller function handle($argv) { $mod = new DashboardModel(); - $mod->common_handleFormSubmissions($_REQUEST['input']); + $mod->common_handleFormSubmissions($_REQUEST['input'], $_FILES['attachment']); $mod->common_deflt(); $this->action_default($mod); } diff --git a/app/model/common.mod.php b/app/model/common.mod.php index b1aa0a0..96326dc 100644 --- a/app/model/common.mod.php +++ b/app/model/common.mod.php @@ -34,21 +34,21 @@ class CommonModel extends MasterModel /* * Handle form submissions from common views */ - function common_handleFormSubmissions($input) + function common_handleFormSubmissions($input, $attachment) { 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-allusers-edituser": $this->saveSettingAllusersEdituser($input); break; + case "common-setting-user": $this->saveSettingUser($input, $attachment); 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; } } /* * Save changes to user account settings */ - function saveSettingUser($input) + function saveSettingUser($input, $attachment) { $form = new Form(); $form->field_bool("setPasswd"); @@ -102,6 +102,11 @@ class CommonModel extends MasterModel } $user->saveObj(); + + if ($form->saveFile($attachment, 5242880, array("image/jpg", "image/jpeg"), "assets/img/heads/" . $user->guid)) + $this->logNotice("Image uploaded"); + else + $this->logFormErrors($form); } /* diff --git a/app/view/common/setting.modal.view.php b/app/view/common/setting.modal.view.php index 19bcf5c..1d7951a 100644 --- a/app/view/common/setting.modal.view.php +++ b/app/view/common/setting.modal.view.php @@ -27,7 +27,7 @@

 

- +
@@ -65,7 +65,7 @@
- +
-- cgit v1.2.3 From ae7ab126733f1d2c59e327f6120a2bbe792b3476 Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Sat, 30 Apr 2016 16:04:00 -0400 Subject: Define constants for head-image upload parameters Created class-scope vars to define allowable sizes and types for uploaded user images --- app/model/common.mod.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'app') diff --git a/app/model/common.mod.php b/app/model/common.mod.php index 96326dc..a177c13 100644 --- a/app/model/common.mod.php +++ b/app/model/common.mod.php @@ -7,6 +7,12 @@ require_once "class/user.class.php"; class CommonModel extends MasterModel { + var $HEAD_IMG_MAX_SIZE = 1048576; // 1MB + var $HEAD_IMG_MIME = array( + "image/jpg", + "image/jpeg" + ); + /* * Default action */ @@ -103,7 +109,7 @@ class CommonModel extends MasterModel $user->saveObj(); - if ($form->saveFile($attachment, 5242880, array("image/jpg", "image/jpeg"), "assets/img/heads/" . $user->guid)) + if ($form->saveFile($attachment, $this->HEAD_IMG_MAX_SIZE, $this->HEAD_IMG_MIME, "assets/img/heads/" . $user->guid)) $this->logNotice("Image uploaded"); else $this->logFormErrors($form); -- cgit v1.2.3 From be1a82affdaa1e87015a0a49979e9230cdc61b4d Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Sat, 30 Apr 2016 16:18:24 -0400 Subject: Update form handler for common/setting-modal, all users tab Now supports file upload to replace the user's head image --- app/model/common.mod.php | 15 ++++++++++----- app/view/common/setting.modal.view.php | 4 ++-- 2 files changed, 12 insertions(+), 7 deletions(-) (limited to 'app') diff --git a/app/model/common.mod.php b/app/model/common.mod.php index a177c13..080c78e 100644 --- a/app/model/common.mod.php +++ b/app/model/common.mod.php @@ -44,10 +44,10 @@ class CommonModel extends MasterModel { switch ($input['action']) { - case "common-setting-user": $this->saveSettingUser($input, $attachment); 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; + case "common-setting-user": $this->saveSettingUser($input, $attachment); 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, $attachment); break; } } @@ -196,7 +196,7 @@ class CommonModel extends MasterModel /* * Allow an admin to edit user accounts */ - function saveSettingAllusersEdituser($input) + function saveSettingAllusersEdituser($input, $attachment) { $form = new Form(); $form->field_text("guid"); @@ -247,6 +247,11 @@ class CommonModel extends MasterModel $user->setEmail($form->email); $user->saveObj(); + + if ($form->saveFile($attachment, $this->HEAD_IMG_MAX_SIZE, $this->HEAD_IMG_MIME, "assets/img/heads/" . $user->guid)) + $this->logNotice("Image uploaded"); + else + $this->logFormErrors($form); } } diff --git a/app/view/common/setting.modal.view.php b/app/view/common/setting.modal.view.php index 1d7951a..369a789 100644 --- a/app/view/common/setting.modal.view.php +++ b/app/view/common/setting.modal.view.php @@ -219,7 +219,7 @@
- + @@ -254,7 +254,7 @@
- +
-- cgit v1.2.3 From ed2af3a874417b8317bb6def9b40189b1d5d05e8 Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Sat, 30 Apr 2016 16:57:11 -0400 Subject: Fix to Form::saveFile() Only log an error if we get an upload error besides err code 4 (No file uploaded) --- app/class/form.class.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'app') diff --git a/app/class/form.class.php b/app/class/form.class.php index 907c0a2..fd85638 100644 --- a/app/class/form.class.php +++ b/app/class/form.class.php @@ -191,7 +191,9 @@ class Form { if ($file['error'] > 0) { - $this->logError("An unknown error occurred"); + if ($file['error'] != UPLOAD_ERR_NO_FILE) + $this->logError("An unknown error occurred"); + return false; } -- cgit v1.2.3 From 519035a6eb28dd36ce898a80d652c08138b110c5 Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Sat, 30 Apr 2016 20:18:10 -0400 Subject: Add global javascript file scrott.js Included initial function assertConfirm(), function to present user an "Are you sure?" prompt before submitting a web form. --- app/assets/js/scrott.js | 8 ++++++++ app/view/master/foot.view.php | 1 + 2 files changed, 9 insertions(+) create mode 100644 app/assets/js/scrott.js (limited to 'app') diff --git a/app/assets/js/scrott.js b/app/assets/js/scrott.js new file mode 100644 index 0000000..675597b --- /dev/null +++ b/app/assets/js/scrott.js @@ -0,0 +1,8 @@ +/* + * Common Javascript logic for the Scrott application + */ + +function assertConfirm() +{ + return confirm("Are you sure?"); +} diff --git a/app/view/master/foot.view.php b/app/view/master/foot.view.php index 6220f89..c749ad0 100644 --- a/app/view/master/foot.view.php +++ b/app/view/master/foot.view.php @@ -1,5 +1,6 @@ + isError() || $mod->isWarning() || $mod->isNotice()) { ?>