summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorMalf Furious <m@lfurio.us>2017-06-13 22:35:17 -0400
committerMalf Furious <m@lfurio.us>2017-06-19 23:57:39 -0400
commit1162f87e4326868160cfddaa524efd1386b34133 (patch)
tree01ff261599c41eb928fe89c502965e5aae2cfe54 /app
parentd178d05272863bb8d920a993b7d6fc4b1f275dcf (diff)
downloadscrott-1162f87e4326868160cfddaa524efd1386b34133.tar.gz
scrott-1162f87e4326868160cfddaa524efd1386b34133.zip
Add mesg function emailMesg()
Diffstat (limited to '')
-rw-r--r--app/class/mesg.class.php50
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;
+ }
}
?>