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/model/common.mod.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'app/model/common.mod.php') 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); } /* -- 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/model/common.mod.php') 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 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'app/model/common.mod.php') 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); } } -- cgit v1.2.3 From e9189928e1108d0c1330eb47cc5de20d67f5de51 Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Sat, 30 Apr 2016 22:34:01 -0400 Subject: Update setting modal to allow user to remove their own head image --- app/model/common.mod.php | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'app/model/common.mod.php') diff --git a/app/model/common.mod.php b/app/model/common.mod.php index 080c78e..32bdb44 100644 --- a/app/model/common.mod.php +++ b/app/model/common.mod.php @@ -79,6 +79,16 @@ class CommonModel extends MasterModel return; } + if (isset($input['rmImage'])) + { + if ($user->rmHeadImage()) + $this->logNotice("Image removed"); + else + $this->logError("Error removing user image"); + + return; + } + if ($form->setPasswd) { if ($user->validatePassword($form->curPasswd)) -- cgit v1.2.3 From 190a7d81155bc08fd9533f53f1f2154e2cca2c7a Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Sun, 1 May 2016 00:45:37 -0400 Subject: Update setting modal to allow admins to remove other users' head images --- app/model/common.mod.php | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'app/model/common.mod.php') diff --git a/app/model/common.mod.php b/app/model/common.mod.php index 32bdb44..7630dfa 100644 --- a/app/model/common.mod.php +++ b/app/model/common.mod.php @@ -239,6 +239,16 @@ class CommonModel extends MasterModel return; } + if (isset($input['rmImage'])) + { + if ($user->rmHeadImage()) + $this->logNotice("Image removed"); + else + $this->logError("Error removing user image"); + + return; + } + if ($form->setPasswd) { if ($form->newPasswd == $form->confPasswd) -- cgit v1.2.3