From 8a29936bf03ede5412d83d5541ba802259a3fc7a Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Wed, 1 Jun 2016 22:08:17 -0400 Subject: Implement add group form handler Added handler function to common model to create new use groups from the modal view. --- app/model/common.mod.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'app/model') diff --git a/app/model/common.mod.php b/app/model/common.mod.php index 3d8c200..07b86df 100644 --- a/app/model/common.mod.php +++ b/app/model/common.mod.php @@ -18,6 +18,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"; +require_once "class/group.class.php"; class CommonModel extends MasterModel { @@ -68,6 +69,7 @@ class CommonModel extends MasterModel { switch ($input['action']) { + case "common-group-add": $this->addNewGroup($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; @@ -76,6 +78,24 @@ class CommonModel extends MasterModel } } + /* + * Create a new user group + */ + function addNewGroup($input) + { + $form = new Form(); + $form->field_text("name"); + + if (!$form->populate($input)) + { + $this->logFormErrors($form); + return; + } + + $group = new Group(); + $group->createNewGroup($form->name, $this->getCurrentUser()); + } + /* * Save changes to user account settings */ -- cgit v1.2.3 From 1b24ddb6b12bd85d15beed45476d72678b758128 Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Wed, 8 Jun 2016 20:21:12 -0400 Subject: Add new MVC, 'Obj' This MVC will be used to browse scrott datastructures. --- app/model/obj.mod.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 app/model/obj.mod.php (limited to 'app/model') diff --git a/app/model/obj.mod.php b/app/model/obj.mod.php new file mode 100644 index 0000000..bccef93 --- /dev/null +++ b/app/model/obj.mod.php @@ -0,0 +1,23 @@ + -- cgit v1.2.3 From d8f7264898d59a261c0e65e525502143259415ad Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Wed, 8 Jun 2016 21:29:32 -0400 Subject: Create blank view for groups Finish initializing the Obj MVC by writing an empty view/action for groups. --- app/model/obj.mod.php | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'app/model') diff --git a/app/model/obj.mod.php b/app/model/obj.mod.php index bccef93..07be4b4 100644 --- a/app/model/obj.mod.php +++ b/app/model/obj.mod.php @@ -15,9 +15,17 @@ */ require_once "model/common.mod.php"; +require_once "class/group.class.php"; class ObjModel extends CommonModel { + /* + * Initialize a group view + */ + function initGroup($guid) + { + $this->group = new Group($guid); + } } ?> -- cgit v1.2.3 From 6c9c352c91814775c6b56c43dd4837a8f3718e86 Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Wed, 8 Jun 2016 23:50:42 -0400 Subject: Start design for group view --- app/model/obj.mod.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'app/model') diff --git a/app/model/obj.mod.php b/app/model/obj.mod.php index 07be4b4..f412e3c 100644 --- a/app/model/obj.mod.php +++ b/app/model/obj.mod.php @@ -25,6 +25,8 @@ class ObjModel extends CommonModel function initGroup($guid) { $this->group = new Group($guid); + $this->owner = $this->group->getOwner(); + $this->members = $this->group->getMembers(); } } -- cgit v1.2.3 From 112a510bb7ba358fd4195b5b2f3c8203ab4fb91d Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Sat, 11 Jun 2016 00:51:46 -0400 Subject: Rename variable In the Obj MVC, rename group in the model to obj. This will help with referencing the active object from template views without knowing what type of object it is. --- app/model/obj.mod.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'app/model') diff --git a/app/model/obj.mod.php b/app/model/obj.mod.php index f412e3c..426e1ac 100644 --- a/app/model/obj.mod.php +++ b/app/model/obj.mod.php @@ -24,9 +24,9 @@ class ObjModel extends CommonModel */ function initGroup($guid) { - $this->group = new Group($guid); - $this->owner = $this->group->getOwner(); - $this->members = $this->group->getMembers(); + $this->obj = new Group($guid); + $this->owner = $this->obj->getOwner(); + $this->members = $this->obj->getMembers(); } } -- cgit v1.2.3 From f8126b70cf8e4c9a744a99a3eb41de158a26a517 Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Sun, 12 Jun 2016 19:11:04 -0400 Subject: Add functions to Common model for assigning CSS to setting tabs The setting modal window will need to support showing unknown tabs at the beginning of the tab list. These functions handle assigning specific CSS classes to tab-panes ONLY if that tab will appear in the left-most position in the modal's tab list. --- app/model/common.mod.php | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'app/model') diff --git a/app/model/common.mod.php b/app/model/common.mod.php index 07b86df..e478e9d 100644 --- a/app/model/common.mod.php +++ b/app/model/common.mod.php @@ -34,6 +34,8 @@ class CommonModel extends MasterModel function __construct() { parent::__construct(); + $this->first_setting_tab_active = 0; + $this->first_setting_tab_disp = 0; $this->common_handleFormSubmissions($_REQUEST['input'], $_FILES['attachment']); $this->common_deflt(); } @@ -363,6 +365,34 @@ class CommonModel extends MasterModel $this->redirectTo($this->ar() . "/"); } } + + /* + * Set CSS class for the first tab title in the setting modal only + */ + function getSettingModalTabActiveClass() + { + if (!$this->first_setting_tab_active) + { + $this->first_setting_tab_active = 1; + return "active"; + } + + return ""; + } + + /* + * Set CSS classes for the first tab in the setting modal only + */ + function getSettingModalTabDispClasses() + { + if (!$this->first_setting_tab_disp) + { + $this->first_setting_tab_disp = 1; + return "in active"; + } + + return ""; + } } ?> -- cgit v1.2.3 From 2adba6a387ac93f750cb795bb39a36077aa7b0de Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Sun, 12 Jun 2016 20:27:57 -0400 Subject: Move initialization logic from Obj model into Common model Some logic to initialize the current system object, its owner, and members has been moved into the Common model since this code will be relevant to other views and to support a new feature being added to display additional tabs in the setting modal box. --- app/model/common.mod.php | 11 ++++++++++- app/model/obj.mod.php | 9 +++------ 2 files changed, 13 insertions(+), 7 deletions(-) (limited to 'app/model') diff --git a/app/model/common.mod.php b/app/model/common.mod.php index e478e9d..232f0c2 100644 --- a/app/model/common.mod.php +++ b/app/model/common.mod.php @@ -17,6 +17,7 @@ require_once "model/master.mod.php"; require_once "class/form.class.php"; require_once "class/setting.class.php"; +require_once "class/object.class.php"; require_once "class/user.class.php"; require_once "class/group.class.php"; @@ -31,12 +32,20 @@ class CommonModel extends MasterModel /* * Constructor */ - function __construct() + function __construct($guid = null) { parent::__construct(); $this->first_setting_tab_active = 0; $this->first_setting_tab_disp = 0; $this->common_handleFormSubmissions($_REQUEST['input'], $_FILES['attachment']); + + if (!is_null($guid)) + { + $this->obj = new DBObject($guid); + $this->owner = $this->obj->getOwner(); + $this->members = $this->obj->getMembers(); + } + $this->common_deflt(); } diff --git a/app/model/obj.mod.php b/app/model/obj.mod.php index 426e1ac..159c962 100644 --- a/app/model/obj.mod.php +++ b/app/model/obj.mod.php @@ -15,18 +15,15 @@ */ require_once "model/common.mod.php"; -require_once "class/group.class.php"; class ObjModel extends CommonModel { /* - * Initialize a group view + * Constructor */ - function initGroup($guid) + function __construct($guid) { - $this->obj = new Group($guid); - $this->owner = $this->obj->getOwner(); - $this->members = $this->obj->getMembers(); + parent::__construct($guid); } } -- cgit v1.2.3 From 076a86c663870be3c4cf6da8059f0f978a7eb3ce Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Sun, 12 Jun 2016 21:33:50 -0400 Subject: Add group tab to setting modal Created empty
for the group setting tab. Also added code to the common model for initializing the $mod->group variable and setting a flag marking what tabs to include in the setting modal (group tab in this case). Added logic to the main setting modal view file for picking up these flags and including appropriate additional content. --- app/model/common.mod.php | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'app/model') diff --git a/app/model/common.mod.php b/app/model/common.mod.php index 232f0c2..459c53a 100644 --- a/app/model/common.mod.php +++ b/app/model/common.mod.php @@ -71,6 +71,16 @@ class CommonModel extends MasterModel /* Admin all-users settings tab */ $userTbl = new User(); $this->common_settingAllUsers = $userTbl->getAllUsers_orderByAdminByName(); + + /* Setting modal - what tabs to display? */ + if (isset($this->obj)) + { + if ($this->obj->type == "group") + { + $this->group = new Group($this->obj->guid); + $this->common_settingShowTab['group'] = true; + } + } } /* -- cgit v1.2.3 From 63ca3ee23edd66cae4a2cc621cfc1352ea958a27 Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Sun, 18 Sep 2016 02:56:31 -0400 Subject: Add form submission handler for group settings tab --- app/model/common.mod.php | 80 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) (limited to 'app/model') 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; @@ -117,6 +118,85 @@ class CommonModel extends MasterModel $group->createNewGroup($form->name, $this->getCurrentUser()); } + /* + * 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 */ -- cgit v1.2.3