diff options
author | Malf Furious <m@lfurio.us> | 2018-10-23 01:31:19 -0400 |
---|---|---|
committer | Malf Furious <m@lfurio.us> | 2018-10-23 01:31:19 -0400 |
commit | 9733a06af32e6b409558795f69f89b7c59487a55 (patch) | |
tree | 3eb589f8fd18b35ee7f774e1f2f4c44613c05c33 /app/model/datamods.php | |
parent | 4d132743eb82ddae2b8c0541d216815e523955d4 (diff) | |
download | scrott-9733a06af32e6b409558795f69f89b7c59487a55.tar.gz scrott-9733a06af32e6b409558795f69f89b7c59487a55.zip |
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 <m@lfurio.us>
Diffstat (limited to '')
-rw-r--r-- | app/model/datamods.php | 38 |
1 files changed, 38 insertions, 0 deletions
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 +} + ?> |