diff options
Diffstat (limited to 'app')
-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 +} + ?> |