From 70bcac2648a51989e1184d9eeead766def999f8b Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Sat, 21 Jul 2018 21:43:20 -0400 Subject: Add new group modal view/model code --- app/model/datamods.php | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 app/model/datamods.php (limited to 'app/model/datamods.php') diff --git a/app/model/datamods.php b/app/model/datamods.php new file mode 100644 index 0000000..01311a8 --- /dev/null +++ b/app/model/datamods.php @@ -0,0 +1,32 @@ +text("name"); + + if (!$form->populate(input())) + return; + + $group = group::initNew($form->name, user::getCurrent()); +} + +?> -- cgit v1.2.3 From 19bf1194556bcc1ba4be4704a297c67d03e58ef5 Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Sat, 15 Sep 2018 09:55:44 -0400 Subject: Implement dm-pad-add form handler --- app/model/datamods.php | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'app/model/datamods.php') diff --git a/app/model/datamods.php b/app/model/datamods.php index 01311a8..b658314 100644 --- a/app/model/datamods.php +++ b/app/model/datamods.php @@ -13,7 +13,10 @@ */ require_once "class/form.class.php"; +require_once "class/agent.class.php"; +require_once "class/user.class.php"; require_once "class/group.class.php"; +require_once "class/pad.class.php"; /* * Action: dm-group-add - New group modal @@ -29,4 +32,28 @@ if (isAction("dm-group-add")) $group = group::initNew($form->name, user::getCurrent()); } +/* + * Action: dm-pad-add - New pad modal + */ +if (isAction("dm-pad-add")) +{ + $form = new form(); + $form->text("owner"); + $form->text("name"); + + if (!$form->populate(input())) + return; + + $owner = agent::getAgentObj($form->owner); + $user = user::getCurrent(); + + if (!$user->canCreateSub($owner)) + { + logError(ERROR, "You do not have permission to create a pad for '" . $owner->getDisplayName() . "'"); + return; + } + + $pad = pad::initNew($form->name, $owner); +} + ?> -- cgit v1.2.3 From defac79722307d68191e9d28346a9fd8502319da Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Wed, 19 Sep 2018 18:06:24 -0400 Subject: datamods: Add default stages to new pads As a convenience, I'm adding a basic set of stages to new pads. These stages are "To Do", "In Progress" ('Done' being closed issues). This implements a very simple workflow for new pads. --- app/model/datamods.php | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'app/model/datamods.php') diff --git a/app/model/datamods.php b/app/model/datamods.php index b658314..8eaff23 100644 --- a/app/model/datamods.php +++ b/app/model/datamods.php @@ -17,6 +17,7 @@ require_once "class/agent.class.php"; require_once "class/user.class.php"; require_once "class/group.class.php"; require_once "class/pad.class.php"; +require_once "class/stage.class.php"; /* * Action: dm-group-add - New group modal @@ -54,6 +55,11 @@ if (isAction("dm-pad-add")) } $pad = pad::initNew($form->name, $owner); + $td = stage::initNew("To Do", $pad); + $ip = stage::initNew("In Progress", $pad); + + $pad->insertStage($td); + $td->insertStage($ip); } ?> -- cgit v1.2.3 From 9733a06af32e6b409558795f69f89b7c59487a55 Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Tue, 23 Oct 2018 01:31:19 -0400 Subject: datamods: Implement new issue modal form handler POSTs to the dm-issue-add form are handled by this new handler. Pad data is passed via the form, we create the new issue in the pad's first stage, crediting the current logged in user. New issue is unassigned. I call `location()` at the bottom, since not doing so leaves the page in a weird state. The reason being that most of the page rendering logic operates off of the 'pageObj', which is instanciated and assigned prior to the invocation of this handler. This is to be fleshed-out during the v0.2-v0.3 development iteration. Signed-off-by: Malf Furious --- app/model/datamods.php | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'app/model/datamods.php') diff --git a/app/model/datamods.php b/app/model/datamods.php index 8eaff23..c7c7da1 100644 --- a/app/model/datamods.php +++ b/app/model/datamods.php @@ -18,6 +18,8 @@ require_once "class/user.class.php"; require_once "class/group.class.php"; require_once "class/pad.class.php"; require_once "class/stage.class.php"; +require_once "class/issue.class.php"; +require_once "class/mesg.class.php"; /* * Action: dm-group-add - New group modal @@ -62,4 +64,40 @@ if (isAction("dm-pad-add")) $td->insertStage($ip); } +/* + * Action: dm-issue-add - New issue modal + */ +if (isAction("dm-issue-add")) +{ + $form = new form(); + $form->text("pad"); + $form->text("name"); + $form->text("mesg", false); + + if (!$form->populate(input())) + return; + + $pad = new pad($form->pad); + $user = user::getCurrent(); + + if (!$user->canCreateSub($pad)) + { + logError(ERROR, "You do not have permission to open an issue for '" . $pad->name . "'"); + return; + } + + $stages = $pad->getStages(); + + if (count($stages) == 0) + { + logError(ERROR, "Cannot create new issue, '" . $pad->name . "' doesn't have any stages"); + return; + } + + $mesg = mesg::initNewDiscussion($form->name, $form->mesg, $user, $pad); + $issue = issue::initNew($mesg, $user, $stages[0]); + + location(); // bug mitigation +} + ?> -- cgit v1.2.3 From 1449564793347f4e34f433f4620834e9c6db290f Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Tue, 23 Oct 2018 20:40:49 -0400 Subject: Fix bug in various form handlers Some form handlers use the current logged in user (user::getCurrent()), however do so without asserting that we are _actually_ logged in. This is probably due to that fact that index.php (usually) catches all page requests that are logged out and diverts control before any other handler can be invoked. But a few handlers sneak through the cracks. In the future, the app will be better about supportting logged out browsing, the alpha was not written with this in the forground. Signed-off-by: Malf Furious --- app/model/datamods.php | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'app/model/datamods.php') diff --git a/app/model/datamods.php b/app/model/datamods.php index c7c7da1..e2051f3 100644 --- a/app/model/datamods.php +++ b/app/model/datamods.php @@ -32,7 +32,13 @@ if (isAction("dm-group-add")) if (!$form->populate(input())) return; - $group = group::initNew($form->name, user::getCurrent()); + if (!($user = user::getCurrent())) + { + logError(ERROR, "You must be logged in to create a group"); + return; + } + + $group = group::initNew($form->name, $user); } /* @@ -48,7 +54,12 @@ if (isAction("dm-pad-add")) return; $owner = agent::getAgentObj($form->owner); - $user = user::getCurrent(); + + if (!($user = user::getCurrent())) + { + logError(ERROR, "You must be logged in to create a pad"); + return; + } if (!$user->canCreateSub($owner)) { @@ -78,7 +89,12 @@ if (isAction("dm-issue-add")) return; $pad = new pad($form->pad); - $user = user::getCurrent(); + + if (!($user = user::getCurrent())) + { + logError(ERROR, "You must be logged in to open an issue"); + return; + } if (!$user->canCreateSub($pad)) { -- cgit v1.2.3 From bcc3ef4a22a17cf888e71078f2881715c466b6dc Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Fri, 26 Oct 2018 21:17:41 -0400 Subject: issue: Add logging events for issue open and close Signed-off-by: Malf Furious --- app/model/datamods.php | 1 + 1 file changed, 1 insertion(+) (limited to 'app/model/datamods.php') diff --git a/app/model/datamods.php b/app/model/datamods.php index e2051f3..0b7f3da 100644 --- a/app/model/datamods.php +++ b/app/model/datamods.php @@ -112,6 +112,7 @@ if (isAction("dm-issue-add")) $mesg = mesg::initNewDiscussion($form->name, $form->mesg, $user, $pad); $issue = issue::initNew($mesg, $user, $stages[0]); + $log = mesg::initNewLog("%s opened issue", $user, $issue); location(); // bug mitigation } -- cgit v1.2.3