diff options
author | Malf Furious <m@lfurio.us> | 2016-05-01 01:42:30 -0400 |
---|---|---|
committer | Malf Furious <m@lfurio.us> | 2016-05-01 01:42:30 -0400 |
commit | d431ef2954455ad38454d27f5be866061794b4bf (patch) | |
tree | ceb03f3c9cf27e5c388cbc923476d9df5b49c10b /app/model/common.mod.php | |
parent | 93fa361ba63c8afa2370c43b7918c9dd513a4586 (diff) | |
parent | 395f7ed73b0b868027285512040fbfe3d0adf347 (diff) | |
download | scrott-d431ef2954455ad38454d27f5be866061794b4bf.tar.gz scrott-d431ef2954455ad38454d27f5be866061794b4bf.zip |
Merge branch 'feature/user-img-mgmt' into dev
Diffstat (limited to 'app/model/common.mod.php')
-rw-r--r-- | app/model/common.mod.php | 50 |
1 files changed, 43 insertions, 7 deletions
diff --git a/app/model/common.mod.php b/app/model/common.mod.php index b1aa0a0..7630dfa 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 */ @@ -34,21 +40,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, $attachment); break; } } /* * Save changes to user account settings */ - function saveSettingUser($input) + function saveSettingUser($input, $attachment) { $form = new Form(); $form->field_bool("setPasswd"); @@ -73,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)) @@ -102,6 +118,11 @@ class CommonModel extends MasterModel } $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); } /* @@ -185,7 +206,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"); @@ -218,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) @@ -236,6 +267,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); } } |