From 75c8a6d4ee00ba9b7040697c4de65620f27b9728 Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Thu, 1 Nov 2018 04:27:05 -0400 Subject: Make issue reply message optional The 'iss-mesg-add' form will now allow a mesg to be omitted, since it will also be handling other events. These events are part of the same form since the UI allows users to post a message and trigger these other actions at the same time. We now only create a mesg object if a mesg is given. Note that an attachment requires a message. IE: any attachment is ignored if no message is created. Signed-off-by: Malf Furious --- app/model/issue.php | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'app/model') diff --git a/app/model/issue.php b/app/model/issue.php index 4300bbb..0954ad9 100644 --- a/app/model/issue.php +++ b/app/model/issue.php @@ -23,7 +23,7 @@ if (isAction("iss-mesg-add")) { $form = new form(); $form->text("issue"); - $form->text("mesg"); + $form->text("mesg", false); if (!$form->populate(input())) return; @@ -36,16 +36,19 @@ if (isAction("iss-mesg-add")) return; } - if (!$user->canCreateSub($issue)) + if (isset($form->mesg) && $form->mesg != "") { - logError(ERROR, "You do not have permission to post to this issue"); - return; - } + if (!$user->canCreateSub($issue)) + { + logError(ERROR, "You do not have permission to post to this issue"); + return; + } - $mesg = mesg::initNew($form->mesg, $user, $issue); + $mesg = mesg::initNew($form->mesg, $user, $issue); - if ($mesg->setAttachment("attachment")) - logError(NOTICE, "Saved attachment " . $mesg->attachment); + if ($mesg->setAttachment("attachment")) + logError(NOTICE, "Saved attachment " . $mesg->attachment); + } if (isset(input()['closeIssue'])) { -- cgit v1.2.3 From d8e6fc09df73e4165fa5503b713f8958e1599175 Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Thu, 1 Nov 2018 04:35:26 -0400 Subject: Fix 'closeIssue' form submission I was failing to assert user has modify permissions for the issue. Signed-off-by: Malf Furious --- app/model/issue.php | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'app/model') diff --git a/app/model/issue.php b/app/model/issue.php index 0954ad9..403e82e 100644 --- a/app/model/issue.php +++ b/app/model/issue.php @@ -52,6 +52,12 @@ if (isAction("iss-mesg-add")) if (isset(input()['closeIssue'])) { + if (!$user->canModify($issue)) + { + logError(ERROR, "You do not have permission to close this issue"); + return; + } + $issue->close($user); logError(NOTICE, "Issue #" . $issue->numb . " closed"); $log = mesg::initNewLog("% closed issue", $user, $issue); -- cgit v1.2.3 From dc99ab0c0a0603d5efc1e07cf690c53260528820 Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Thu, 1 Nov 2018 04:43:55 -0400 Subject: Implement iss-mesg-add 'advIssue' submission Handler now includes logic for optionally advancing the issue through the pipeline. If this happens, 'closeIssue' (for example) will not be checked, as only one submission can be used. Signed-off-by: Malf Furious --- app/model/issue.php | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'app/model') diff --git a/app/model/issue.php b/app/model/issue.php index 403e82e..910cb14 100644 --- a/app/model/issue.php +++ b/app/model/issue.php @@ -50,7 +50,28 @@ if (isAction("iss-mesg-add")) logError(NOTICE, "Saved attachment " . $mesg->attachment); } - if (isset(input()['closeIssue'])) + if (isset(input()['advIssue'])) + { + if (!$user->canModify($issue)) + { + logError(ERROR, "You do not have permission to move this issue"); + return; + } + + $issue->advance($user); + + if ($issue->isOpen()) + { + $sgename = $issue->getParent()->name; + $log = mesg::initNewLog("%s advanced issue to '" . $sgename . "'", $user, $issue); + } + else + { + $log = mesg::initNewLog("%s closed issue", $user, $issue); + } + } + + else if (isset(input()['closeIssue'])) { if (!$user->canModify($issue)) { -- cgit v1.2.3