From 8e9beac9888e894c8db46401b0d5b4c4cb18407d Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Sun, 4 Jun 2017 20:25:35 -0400 Subject: Add mesg function makeIssue() This feature allows a pad-level discussion to be promoted to an issue. A new object is created, but all content is preserved. However, if the thread OP message had an attachment, that attachment cannot be retained. --- app/class/mesg.class.php | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'app/class/mesg.class.php') diff --git a/app/class/mesg.class.php b/app/class/mesg.class.php index 5d6ba4d..6c84d4f 100644 --- a/app/class/mesg.class.php +++ b/app/class/mesg.class.php @@ -15,6 +15,8 @@ require_once "class/object.class.php"; require_once "class/user.class.php"; require_once "class/pad.class.php"; +require_once "class/stage.class.php"; +require_once "class/issue.class.php"; /* * This class models issue activity, private messaging, pad discussions, @@ -255,6 +257,31 @@ class mesg extends object return $ret; } + + /* + * Promote a pad discussion thread to an issue. This message object + * must be the top-level message (op) of the discussion thread (ie: + * its parent must be a pad). All reply messages to this one are + * retained and will be messages left on the new issue. A new issue + * object is created and this message object will be destroyed. If + * this is not an eligible message for promotion, NULL is returned. + */ + public function makeIssue(stage $parent) : ?issue + { + if ($this->getParent()->objtype != "pad") + return NULL; + + $issue = issue::initNew($this->name, $this->getOwner(), $parent); + $issue->created = $this->created; + $issue->description = $this->mesg; + $issue->saveObj(); + + foreach ($this->getMesgs_ordByDatetime() as $mesg) + $mesg->setParent($issue); + + $this->delObj(); + return $issue; + } } ?> -- cgit v1.2.3