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); } $once = false; if ($mailsubs) { if (!$this->get('parent')) { // New topic: Send email only to category subscribers $mailsubs = $this->_config->category_subscriptions != 'disabled' ? 3 : 0; $once = $this->_config->category_subscriptions == 'topic'; } elseif ($this->_config->category_subscriptions != 'post') { // Existing topic: Send email only to topic subscribers $mailsubs = $this->_config->topic_subscriptions != 'disabled' ? 2 : 0; $once = $this->_config->topic_subscriptions == 'first'; } else { // Existing topic: Send email to both category and topic subscribers $mailsubs = $this->_config->topic_subscriptions == 'disabled' ? 3 : 1; // FIXME: category subcription can override topic $once = $this->_config->topic_subscriptions == 'first'; } } // Fetch 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'); kimport('html.parser'); if (!$this->_config->email) { KunenaError::warning(JText::_('COM_KUNENA_EMAIL_DISABLED')); return false; } else { if (!JMailHelper::isEmailAddress($this->_config->email)) { KunenaError::warning(JText::_('COM_KUNENA_EMAIL_INVALID')); return false; } } // clean up the message for review $authorname = $this->get('name'); $message = KunenaParser::stripBBCode($this->get('message'), 0, false); $subject = $this->get('subject'); $topicsubject = $this->parent->subject ? $this->parent->subject : $subject; $mailsender = JMailHelper::cleanAddress($this->_config->board_title); $mailsubject = JMailHelper::cleanSubject("[" . $this->_config->board_title . "] " . $topicsubject . " (" . $this->parent->catname . ")"); // Make a list from all receivers $sentusers = array(); $receivers = array(0 => array(), 1 => array()); foreach ($emailToList as $emailTo) { if (!$emailTo->email || !JMailHelper::isEmailAddress($emailTo->email)) { continue; } $receivers[$emailTo->subscription][] = $emailTo->email; $sentusers[] = $emailTo->id; } // Create email $mail = JFactory::getMailer(); $mail->setSubject($mailsubject); $mail->setSender(array($this->_config->email, $mailsender)); // Send email to all subscribers $mail->setBody($this->createEmailBody(1, $subject, $authorname, $LastPostUrl, $message, $once)); $this->sendEmail($mail, $receivers[1]); // Send email to all moderators $mail->setBody($this->createEmailBody(0, $subject, $authorname, $LastPostUrl, $message, $once)); $this->sendEmail($mail, $receivers[0]); // Update subscriptions if ($once && $sentusers) { $sentusers = implode(',', $sentusers); $db = JFactory::getDBO(); $query = "UPDATE #__kunena_subscriptions\n\t\t\t\t\tSET future1=1 WHERE thread={$this->get('thread')} AND userid IN ({$sentusers})"; $db->setQuery($query); $db->query(); KunenaError::checkDatabaseError(); } } }
function ReportMessage($id, $catid, $reporter, $reason, $text, $type) { $kunena_my =& JFactory::getUser(); $kunena_db =& JFactory::getDBO(); $fbConfig =& CKunenaConfig::getInstance(); if (!$kunena_my->id) { JError::raiseError(403, JText::_("ALERTNOTAUTH")); return; } if (!empty($reason) && !empty($text)) { $kunena_db->setQuery("SELECT a.*, b.mesid, b.message AS msg_text FROM #__fb_messages AS a" . " LEFT JOIN #__fb_messages_text AS b ON b.mesid = a.id" . " WHERE a.id='{$id}'"); $row = $kunena_db->loadObject(); $kunena_db->setQuery("SELECT username FROM #__users WHERE id={$row->userid}"); $baduser = $kunena_db->loadResult(); $kunena_db->setQuery("SELECT username FROM #__users WHERE id={$reporter}"); $sender = $kunena_db->loadResult(); if ($reason) { $subject = "[" . stripslashes($fbConfig->board_title) . " " . _GEN_FORUM . "] " . _KUNENA_REPORT_MSG . ": " . $reason; } else { $subject = "[" . stripslashes($fbConfig->board_title) . " " . _GEN_FORUM . "] " . _KUNENA_REPORT_MSG . ": " . stripslashes($row->subject); } jimport('joomla.environment.uri'); $uri =& JURI::getInstance(JURI::base()); $msglink = $uri->toString(array('scheme', 'host', 'port')) . str_replace('&', '&', JRoute::_(KUNENA_LIVEURLREL . "&func=view&catid=" . $row->catid . "&id=" . $row->id) . '#' . $row->id); $message = "" . _KUNENA_REPORT_RSENDER . " " . $sender; $message .= "\n"; $message .= "" . _KUNENA_REPORT_RREASON . " " . $reason; $message .= "\n"; $message .= "" . _KUNENA_REPORT_RMESSAGE . " " . $text; $message .= "\n\n"; $message .= "" . _KUNENA_REPORT_POST_POSTER . " " . $baduser; $message .= "\n"; $message .= "" . _KUNENA_REPORT_POST_SUBJECT . " " . stripslashes($row->subject); $message .= "\n"; $message .= "" . _KUNENA_REPORT_POST_MESSAGE . "\n-----\n" . stripslashes($row->msg_text); $message .= "\n-----\n\n"; $message .= "" . _KUNENA_REPORT_POST_LINK . " " . $msglink; $message .= "\n\n\n\n** Powered by Kunena! - http://www.Kunena.com **"; $message = strtr($message, array(' ' => '')); $emailToList = CKunenaTools::getEMailToList($row->catid, $row->thread, false, true, true, $kunena_my->id); switch ($type) { default: case '0': SendReportToMail($sender, $subject, $message, $emailToList); break; case '1': SendReporttoPM($reporter, $subject, $message, $msglink, $mods, $admins); break; } echo '<div align="center">' . _KUNENA_REPORT_SUCCESS; echo CKunenaLink::GetAutoRedirectHTML(JRoute::_(KUNENA_LIVEURLREL . '&func=view&catid=' . $catid . '&id=' . $id) . '#' . $id, 3500); } else { echo '<div align="center">'; if (empty($reason)) { echo _POST_FORGOT_SUBJECT; } else { if (empty($text)) { echo _POST_FORGOT_MESSAGE; } } } echo '<br /><br />'; echo '<a href="' . JRoute::_(KUNENA_LIVEURLREL . '&func=view&catid=' . $catid . '&id=' . $id) . '#' . $id . '">' . _POST_SUCCESS_VIEW . '</a><br />'; echo '<a href="' . JRoute::_(KUNENA_LIVEURLREL . '&func=showcat&catid=' . $catid) . '">' . _POST_SUCCESS_FORUM . '</a><br />'; echo '</div>'; }
protected function _sendPrepareReport($type) { if (!$this->reportAllowed()) { return false; } if (!JRequest::checkToken()) { while (@ob_end_clean()) { } $this->app->redirect(CKunenaLink::GetThreadPageURL('view', $this->catid, $this->id, NULL, NULL, $this->id, false), COM_KUNENA_ERROR_TOKEN, 'error'); return false; } if (!empty($this->reason) && !empty($this->text)) { if ($this->id) { $query = "SELECT a.id, a.thread, a.name AS nickname, a.catid, a.userid, a.subject, b.mesid, b.message AS msg_text, c.username, c.name, c.id AS userid\n\t\t\t\t\t\t\tFROM #__kunena_messages AS a\n\t\t\t\t\t\t\tINNER JOIN #__kunena_messages_text AS b ON b.mesid = a.id\n\t\t\t\t\t\t\tLEFT JOIN #__users AS c ON c.id = a.userid\n\t\t\t\t\t\t\tWHERE a.id={$this->_db->Quote($this->id)}"; $this->_db->setQuery($query); $row = $this->_db->loadObject(); if (KunenaError::checkDatabaseError()) { return; } if ($row->userid && $row->username) { $baduser = $this->config->username ? $row->username : $row->name; } else { $baduser = $row->nickname; } if ($this->reason) { $subject = "[" . $this->config->board_title . " " . JText::_('COM_KUNENA_GEN_FORUM') . "] " . JText::_('COM_KUNENA_REPORT_MSG') . ": " . $this->reason; } else { $subject = "[" . $this->config->board_title . " " . JText::_('COM_KUNENA_GEN_FORUM') . "] " . JText::_('COM_KUNENA_REPORT_MSG') . ": " . $row->subject; } jimport('joomla.environment.uri'); $uri =& JURI::getInstance(JURI::base()); $msglink = $uri->toString(array('scheme', 'host', 'port')) . str_replace('&', '&', CKunenaLink::GetThreadPageURL('view', $row->catid, $row->id, NULL, NULL, $row->id)); $message = "" . JText::_('COM_KUNENA_REPORT_RSENDER') . " " . $this->_getSenderName(); $message .= "\n"; $message .= "" . JText::_('COM_KUNENA_REPORT_RREASON') . " " . $this->reason; $message .= "\n"; $message .= "" . JText::_('COM_KUNENA_REPORT_RMESSAGE') . " " . $this->text; $message .= "\n\n"; $message .= "" . JText::_('COM_KUNENA_REPORT_POST_POSTER') . " " . $baduser; $message .= "\n"; $message .= "" . JText::_('COM_KUNENA_REPORT_POST_SUBJECT') . " " . $row->subject; $message .= "\n"; $message .= "" . JText::_('COM_KUNENA_REPORT_POST_MESSAGE') . "\n-----\n" . $row->msg_text; $message .= "\n-----\n\n"; $message .= "" . JText::_('COM_KUNENA_REPORT_POST_LINK') . " " . $msglink; $message .= "\n\n\n\n** Powered by Kunena! - http://www.kunena.org **"; $message = strtr($message, array(' ' => '')); $emailToList = CKunenaTools::getEMailToList($row->catid, $row->thread, false, true, true, $this->my->id); if ($type == '0') { // send by mail $this->_sendReportToMail($message, $subject, $emailToList); } else { if ($type == '1') { // send by PM // Function not yet implemented } else { // send by PM and mail // Function not yet implemented } } } } else { // Do nothing empty subject or reason is empty $this->app->enqueueMessage(JText::_('COM_KUNENA_REPORT_FORG0T_SUB_MES')); while (@ob_end_clean()) { } $this->app->redirect(CKunenaLink::GetReportURL()); } }
if (strlen($message) > $fbConfig->alphauserpointsnumchars) { AlphaUserPointsHelper::newpoints('plgaup_reply_kunena', '', $pid, $datareference); } else { $app->enqueueMessage(_KUNENA_AUP_MESSAGE_TOO_SHORT); } } else { AlphaUserPointsHelper::newpoints('plgaup_reply_kunena', '', $pid, $datareference); } } } } // end insertion AlphaUserPoints //clean up the message for review $mailmessage = smile::purify(stripslashes($message)); //get all subscriptions and moderators $emailToList = CKunenaTools::getEMailToList($catid, $querythread, $fbConfig->allowsubscriptions && !$holdPost, $fbConfig->mailmod, $fbConfig->mailadmin, $kunena_my->id); //Now manage the subscriptions (only if subscriptions are allowed) if (count($emailToList)) { jimport('joomla.mail.helper'); if (!$fbConfig->email || !JMailHelper::isEmailAddress($fbConfig->email)) { $app->enqueueMessage(_KUNENA_EMAIL_INVALID, 'error'); } else { $mailsender = JMailHelper::cleanAddress(stripslashes($board_title) . " " . _GEN_FORUM); $mailsubject = JMailHelper::cleanSubject("[" . stripslashes($board_title) . " " . _GEN_FORUM . "] " . stripslashes($messagesubject) . " (" . stripslashes($catName) . ")"); foreach ($emailToList as $emailTo) { if (!$emailTo->email || !JMailHelper::isEmailAddress($emailTo->email)) { continue; } if ($emailTo->subscription) { $msg1 = $_COM_A_NOTIFICATION1; $msg2 = $_COM_A_NOTIFICATION2;