/** * Sends a message to a specified recipient(s) * * @param string $messageID Message ID. One of 'Reject', 'Approve', 'TimeOut' or 'Request' * @param mixed $recipientGroup Either a numeric index of the next recipient to send to, or "all" for all * This is used for delayed notification so that failover recipients can be notified. * @return boolean True if successful */ protected function sendMessage($messageID, $recipientGroup = 'all') { // Add additionally configured arguments $arguments = $this->getConfigSetting('ServiceArguments') ?: array(); // Get member who began this request $author = $this->Pipeline()->Author(); // Send message to requester if ($recipientGroup === 'all' || $recipientGroup === 0) { list($subject, $message) = $this->generateMessageTemplate(self::ROLE_REQUESTER, $messageID); if ($subject && $message) { $this->log("{$this->Title} sending {$messageID} message to {$author->Email}"); $extra = array('subject' => $subject); $this->messagingService->sendMessage($this, $message, $author, array_merge($arguments, $extra)); } } // Filter recipients based on group $recipients = $this->getConfigSetting('Recipients'); if (is_array($recipients) && $recipientGroup !== 'all') { $recipients = isset($recipients[$recipientGroup]) ? $recipients[$recipientGroup] : null; } if (empty($recipients)) { $this->log("Skipping sending message to empty recipients"); return; } // Send to recipients list($subject, $message) = $this->generateMessageTemplate(self::ROLE_RECIPIENT, $messageID); if ($subject && $message && $recipients) { $recipientsStr = is_array($recipients) ? implode(',', $recipients) : $recipients; $this->log("{$this->Title} sending {$messageID} message to {$recipientsStr}"); $extra = array('subject' => $subject); $this->messagingService->sendMessage($this, $message, $recipients, array_merge($arguments, $extra)); } }
/** * Sends a specific message to all marked recipients, including the author of this pipeline * * @param string $messageID Message ID. One of 'Abort', 'Success', or 'Failure', or some custom message * @return boolean True if successful */ public function sendMessage($messageID) { // Check message, subject, and additional arguments to include list($subject, $message) = $this->generateMessageTemplate($messageID); if (empty($subject) || empty($message)) { $this->log("Skipping sending message. None configured for {$messageID}"); return true; } // Save last sent message $this->LastMessageSent = $messageID; $this->write(); // Setup messaging arguments $arguments = array_merge($this->getConfigSetting('PipelineConfig', 'ServiceArguments') ?: array(), array('subject' => $subject)); // Send message to author if ($author = $this->Author()) { $this->log("Pipeline sending {$messageID} message to {$author->Email}"); $this->messagingService->sendMessage($this, $message, $author, $arguments); } else { $this->log("Skipping sending message to missing author"); } // Get additional recipients $recipients = $this->getConfigSetting('PipelineConfig', 'Recipients', $messageID); if (empty($recipients)) { $this->log("Skipping sending message to empty recipients"); } else { $recipientsStr = is_array($recipients) ? implode(',', $recipients) : $recipients; $this->log("Pipeline sending {$messageID} message to {$recipientsStr}"); $this->messagingService->sendMessage($this, $message, $recipients, $arguments); } }