summaryrefslogtreecommitdiffstats
path: root/app/class/mesg.class.php
diff options
context:
space:
mode:
authorMalf Furious <m@lfurio.us>2017-06-20 00:17:17 -0400
committerMalf Furious <m@lfurio.us>2017-06-20 00:17:17 -0400
commita4d96f0c1e9dd89df3dd189664f400680eb4e8fa (patch)
treeba0e0b0c02a7c3384306a38106ac6eebdb80b4f4 /app/class/mesg.class.php
parent2376aabe74528b018189982224d61a643325b114 (diff)
parent2564b9953bb7bd8e90a9865962cb9e88d4cfd218 (diff)
downloadscrott-a4d96f0c1e9dd89df3dd189664f400680eb4e8fa.tar.gz
scrott-a4d96f0c1e9dd89df3dd189664f400680eb4e8fa.zip
Merge branch 'feature/email' into dev
Diffstat (limited to 'app/class/mesg.class.php')
-rw-r--r--app/class/mesg.class.php54
1 files changed, 54 insertions, 0 deletions
diff --git a/app/class/mesg.class.php b/app/class/mesg.class.php
index 6c84d4f..2512d03 100644
--- a/app/class/mesg.class.php
+++ b/app/class/mesg.class.php
@@ -282,6 +282,60 @@ 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 = $parent->getMembers();
+ $rcpt[] = $parent->getOwner();
+
+ switch ($parent->objtype)
+ {
+ case "user":
+ $rcpt[] = $parent;
+ $subj = $this->author . " " . $this->getAuthor()->getDisplayName() . " // " . $this->name;
+ 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);
+ $author = $this->author;
+ $rcpt = array_filter($rcpt, function ($val) use($author) { return $val->guid != $author; });
+ $attachPath = ($this->getAttachment() ? "dynmic/attach/" . $this->guid : NULL);
+ $mesg = $this->getAuthor()->getDisplayName() . " wrote on " . $this->created . "\n\n";
+ $mesg .= $this->renderMesg();
+
+ foreach ($rcpt as $r)
+ {
+ if (!$r->sendEmail($subj, $mesg, $attachPath, $this->attachment))
+ return false;
+ }
+
+ return true;
+ }
}
?>