summaryrefslogtreecommitdiffstats
path: root/app/class
diff options
context:
space:
mode:
authorMalf Furious <m@lfurio.us>2017-06-04 20:25:35 -0400
committerMalf Furious <m@lfurio.us>2017-06-04 20:25:35 -0400
commit8e9beac9888e894c8db46401b0d5b4c4cb18407d (patch)
tree01f01e9c2c315c7b7b54f9d720b8bacee80c257f /app/class
parentd52b67bbc212f85cc6e80e107029bda4d4445b94 (diff)
downloadscrott-8e9beac9888e894c8db46401b0d5b4c4cb18407d.tar.gz
scrott-8e9beac9888e894c8db46401b0d5b4c4cb18407d.zip
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.
Diffstat (limited to 'app/class')
-rw-r--r--app/class/mesg.class.php27
1 files changed, 27 insertions, 0 deletions
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;
+ }
}
?>