if a user post a answer to a subscribed topic there will be also send a email to the Subscribers. How can i change this to send only emails if there is post a new Topic? Not for Answers only for Topics?
I want to ask with Php, if the post was a Topic not a reply.
Code:
public function emailToSubscribers($LastPostUrl = false, $mailsubs = false, $mailmods = false, $mailadmins = false) {
if ($LastPostUrl === false) {
jimport ( 'joomla.environment.uri' );
$uri = JURI::getInstance ( JURI::base () );
$LastPostUrl = $uri->toString ( array ('scheme', 'host', 'port' ) ) . CKunenaLink::GetMessageURL($this->get ( 'id' ), $this->get ( 'catid' ), 0, false);
}
//get all subscribers, moderators and admins who will get the email
$emailToList = CKunenaTools::getEMailToList ( $this->get ( 'catid' ), $this->get ( 'thread' ), $mailsubs, $mailmods, $mailadmins, $this->_my->id );
if (count ( $emailToList )) {
jimport('joomla.mail.helper');
if (! $this->_config->email || ! JMailHelper::isEmailAddress ( $this->_config->email )) {
$this->_app->enqueueMessage ( JText::_ ( 'COM_KUNENA_EMAIL_INVALID' ), 'notice' );
return false;
} else if ($_SERVER ["REMOTE_ADDR"] == '127.0.0.1') {
$this->_app->enqueueMessage ( JText::_ ( 'COM_KUNENA_EMAIL_DISABLED' ), 'notice' );
return false;
}
// clean up the message for review
$authorname = $this->get ( 'name' );
$message = smile::purify ( $this->get ( 'message' ) );
$subject = $this->get ( 'subject' );
$mailsender = JMailHelper::cleanAddress ( $this->_config->board_title . " " . JText::_ ( 'COM_KUNENA_GEN_FORUM' ) );
$mailsubject = JMailHelper::cleanSubject ( "[" . $this->_config->board_title . " " . JText::_ ( 'COM_KUNENA_GEN_FORUM' ) . "] " . $subject . " (" . $this->parent->catname . ")" );
foreach ( $emailToList as $emailTo ) {
if (! $emailTo->email || ! JMailHelper::isEmailAddress ( $emailTo->email ))
continue;
if ($emailTo->subscription) {
$msg1 = JText::_ ( 'COM_KUNENA_POST_EMAIL_NOTIFICATION1' );
$msg2 = JText::_ ( 'COM_KUNENA_POST_EMAIL_NOTIFICATION2' );
} else {
$msg1 = JText::_ ( 'COM_KUNENA_POST_EMAIL_MOD1' );
$msg2 = JText::_ ( 'COM_KUNENA_POST_EMAIL_MOD2' );
}
$msg = "$emailTo->name,\n\n";
$msg .= $msg1 . " " . $this->_config->board_title . " " . JText::_ ( 'COM_KUNENA_GEN_FORUM' ) . "\n\n";
$msg .= JText::_ ( 'COM_KUNENA_MESSAGE_SUBJECT' ) . ": " . $subject . "\n";
$msg .= JText::_ ( 'COM_KUNENA_GEN_FORUM' ) . ": " . $this->parent->catname . "\n";
$msg .= JText::_ ( 'COM_KUNENA_VIEW_POSTED' ) . ": " . $authorname . "\n\n";
$msg .= $msg2 . "\n";
$msg .= "URL: $LastPostUrl\n\n";
if ($this->_config->mailfull == 1) {
$msg .= JText::_ ( 'COM_KUNENA_GEN_MESSAGE' ) . ":\n-----\n";
$msg .= $message;
$msg .= "\n-----";
}
$msg .= "\n\n";
$msg .= JText::_ ( 'COM_KUNENA_POST_EMAIL_NOTIFICATION3' ) . "\n";
$msg .= "\n\n\n\n";
$msg .= "** Powered by Kunena! - http://www.kunena.org **";
$msg = JMailHelper::cleanBody ( $msg );
JUtility::sendMail ( $this->_config->email, $mailsender, $emailTo->email, $mailsubject, $msg );
}
}
}