diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/class/mesg.class.php | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/app/class/mesg.class.php b/app/class/mesg.class.php index 6c84d4f..da52fa6 100644 --- a/app/class/mesg.class.php +++ b/app/class/mesg.class.php @@ -282,6 +282,56 @@ class mesg extends object $this->delObj(); return $issue; } + + /* + * Email this message to parents, owners, members. In the case that + * this is an issue message or a reply message, the assignee or original + * author is also included. Attachments are included in mailing. Any + * duplicates in the rcpt list are removed before sending. Success + * or failure is returned. + */ + public function emailMesg() : bool + { + $parent = $this->getParent(); + + if (!$parent) + return true; + + $rcpt = $this->getMembers(); + $rcpt[] = $this->getOwner(); + + switch ($parent->objtype) + { + case "user": + $rcpt[] = $parent; + $subj = $this->author . " PM from " . $this->getAuthor()->getDisplayName(); + break; + + case "issue": + $rcpt[] = $parent->getAssignee(); + $pad = $parent->getPad(); + $subj = $parent->guid . " " . $pad->name . " [#" . $parent->numb . "] " . $parent->name; + break; + + case "mesg": + case "log": + $rcpt[] = $parent->getAuthor(); + $pad = $parent->getParent(); + $subj = $parent->guid . " " . $pad->name . " // " . $parent->name; + break; + } + + $rcpt = object::arrayUnique($rcpt); + $attachPath = ($this->getAttachment() ? "dynmic/attach/" . $this->guid : NULL); + + foreach ($rcpt as $r) + { + if (!$r->sendEmail($subj, $this->mesg, $attachPath, $this->attachment)) + return false; + } + + return true; + } } ?> |