diff options
author | Malf Furious <m@lfurio.us> | 2016-09-18 02:56:31 -0400 |
---|---|---|
committer | Malf Furious <m@lfurio.us> | 2016-09-18 02:56:31 -0400 |
commit | 63ca3ee23edd66cae4a2cc621cfc1352ea958a27 (patch) | |
tree | bce8580136e6d850b3498b66dfd9abbb691841a4 /app | |
parent | 98ba4abeff20ae83de84451c4aeb0c68d043ab45 (diff) | |
download | scrott-63ca3ee23edd66cae4a2cc621cfc1352ea958a27.tar.gz scrott-63ca3ee23edd66cae4a2cc621cfc1352ea958a27.zip |
Add form submission handler for group settings tab
Diffstat (limited to 'app')
-rw-r--r-- | app/model/common.mod.php | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/app/model/common.mod.php b/app/model/common.mod.php index 459c53a..6cba871 100644 --- a/app/model/common.mod.php +++ b/app/model/common.mod.php @@ -91,6 +91,7 @@ class CommonModel extends MasterModel switch ($input['action']) { case "common-group-add": $this->addNewGroup($input); break; + case "common-setting-group": $this->saveSettingGroup($input, $attachment); 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; @@ -118,6 +119,85 @@ class CommonModel extends MasterModel } /* + * Save changes to user group settings + */ + function saveSettingGroup($input, $attachment) + { + $form = new Form(); + $form->field_text("guid"); + $form->field_text("name"); + $form->field_bool("perm0"); + $form->field_bool("perm1"); + $form->field_bool("perm2"); + $form->field_bool("perm3"); + $form->field_bool("perm4"); + $form->field_bool("perm5"); + $form->field_bool("perm6"); + $form->field_bool("perm7"); + $form->field_bool("perm8"); + + if (!$form->populate($input)) + { + $this->logFormErrors($form); + return; + } + + $user = $this->getCurrentUser(); + $group = new Group($form->guid); + + if (!$user || $group->type != "group" || !$group->canModify($user)) + { + $this->logError("You do not have permission to modify this group"); + return; + } + + if (isset($input['rmImage'])) + { + if ($group->rmHeadImage()) + $this->logNotice("Image removed"); + else + $this->logError("Error removing group image"); + + return; + } + + $group->name = $form->name; + + if ($group->canModifyPermissions($user)) + { + $perms = 0; + + if ($form->perm0) + $perms |= 0x100; + if ($form->perm1) + $perms |= 0x080; + if ($form->perm2) + $perms |= 0x040; + if ($form->perm3) + $perms |= 0x020; + if ($form->perm4) + $perms |= 0x010; + if ($form->perm5) + $perms |= 0x008; + if ($form->perm6) + $perms |= 0x004; + if ($form->perm7) + $perms |= 0x002; + if ($form->perm8) + $perms |= 0x001; + + $group->perms = $perms; + } + + $group->saveObj(); + + if ($form->saveFile($attachment, $this->HEAD_IMG_MAX_SIZE, $this->HEAD_IMG_MIME, "assets/img/heads/" . $group->guid)) + $this->logNotice("Image uploaded"); + else + $this->logFormErrors($form); + } + + /* * Save changes to user account settings */ function saveSettingUser($input, $attachment) |