ForumMessage = $ForumMessage;
$this->Forum = $ForumMessage->getForumThread()->getForum();
}
/**
* getNotificationMessage - construct a string of this message content.
*
* @param User
* @return string
*/
function getNotificationMessage(User $User) {
return $this->getGenericMessage();
}
/**
* This "generic" message will be used for both users and non-users when
* a new post is made
* @return string
*/
private function getGenericMessage() {
$url = GFurl::getUrl();
if ($this->Forum->getSection() != 'project') {
throw new Exception('Tried to notify about a non-project forum');
}
$project = ProjectPeer::retrieveByPk($this->Forum->getRefId());
// make the body
$TrackItemUrl=$url->getFullURL($url->projectUrl($project,'ForumBrowse', 'forum', '', array('_forum_action'=>'MessageReply','message_id' => $this->ForumMessage->getForumMessageId())),true) . "\n";
//$TrackItemUrl=substr($TrackItemUrl,0,31).":81".substr($TrackItemUrl,31,-1);
$TrackItemUrl="" . $TrackItemUrl . "";
$body = "Thread " . $this->ForumMessage->getForumThread()->getThreadName() ." had a new message posted at ". $this->ForumMessage->getPostDate() .
"\n
You can respond by visiting: ".
"\n
" . $TrackItemUrl .
"\n
Or by replying to this e-mail entering your response between the following markers: ".
"\n
".
"\n
".self::FORUM_MAIL_MARKER.
"\n
(enter your response here)".
"\n
".self::FORUM_MAIL_MARKER.
"\n\n
".
"Submitted By: ". $this->ForumMessage->getUser()->getFirstName() . " " . $this->ForumMessage->getUser()->getLastName() .
" (". $this->ForumMessage->getUser()->getUnixName() . ")"."\n\n
";
$body .= $this->ForumMessage->getBody() ." \n
";
$TrackItemUrl=$url->getFullUrl($url->baseUrl('Login', '', 'account')) . "\n";
//$TrackItemUrl=substr($TrackItemUrl,0,31).":81".substr($TrackItemUrl,31,-1);
$TrackItemUrl="" . $TrackItemUrl . "";
$body .= "\n\n
______________________________________________________________________".
"\n
You are receiving this email because you elected to monitor this forum.".
"\n
To stop monitoring this forum, login to ". $TrackItemUrl ." and visit: ".
"\n
";
$TrackItemUrl=$url->getFullUrl($url->getMonitorUrl('forum', $this->Forum->getPrimaryKey(), $url->projectUrl($project, '', 'forum'), false),true) . "\n";
//$TrackItemUrl=substr($TrackItemUrl,0,31).":81".substr($TrackItemUrl,31,-1);
$TrackItemUrl="" . $TrackItemUrl . "";
$body .= $TrackItemUrl;
return $body;
}
/**
* getNotificationSubject - construct a string of this message subject.
*
* @param User
* @return string
*/
function getNotificationSubject(User $User) {
return $this->getGenericSubject();
}
/**
* This "generic" subject will be used for both users and non-users when
* a new post is made
* @return string
*/
private function getGenericSubject() {
$subject = "ForumMessage [".$this->Forum->getForumName()."] ". StringUtils::unHtmlSpecialChars($this->ForumMessage->getSubject());
return $subject;
}
/**
* getUsers - get an array of user objects
* @return array
*/
public function getUsers() {
return $this->ForumMessage->getForumThread()->getForum()->getMonitoringUsers(); // thread or forum or project monitors
}
/**
* getSection - retrieves the section name of the forum message
* @return string
*/
function getSection() {
return ForumMessage::SECTION;
}
/**
* getRefId - retrieves the id of the forum message that the notification belongs to
* @return int
*/
function getRefId() {
return $this->ForumMessage->getForumMessageId();
}
/**
* This will notify of the new message to the addresses defined in
* "send_all_posts_to" field
*/
public function notifyAllPosts() {
$addresses = StringUtils::getAddressesFromList($this->Forum->getSendAllPostsTo());
foreach ($addresses as $address) {
$message = $this->getGenericMessage();
$subject = $this->getGenericSubject().' (forummessage-'.$this->ForumMessage->getPrimaryKey().')';
SystemUtils::sendMail($subject, $message, $address,false,SystemUtils::getFromAddress('gforge-gateway'));
}
}
}
?>