diff options
| -rw-r--r-- | app/class/mesg.class.php | 27 | 
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; +    }  }  ?> | 
