Exemplo n.º 1
0
 public static function sendReport(&$comment, $name, $reason = '')
 {
     $app = JCommentsFactory::getApplication('site');
     $user = JCommentsFactory::getUser();
     $config = JCommentsFactory::getConfig();
     if ($config->get('notification_email') != '') {
         $objectInfo = JCommentsObjectHelper::getObjectInfo($comment->object_id, $comment->object_group, $comment->lang);
         $commentText = $comment->comment;
         $bbcode = JCommentsFactory::getBBCode();
         $txt = JCommentsText::censor($comment->comment);
         $txt = $bbcode->replace($txt);
         if ($config->getInt('enable_custom_bbcode')) {
             $customBBCode = JCommentsFactory::getCustomBBCode();
             // TODO: add control for replacement mode from CustomBBCode parameters
             $txt = $customBBCode->replace($txt, true);
         }
         $comment->comment = trim(preg_replace('/(\\s){2,}/i', '\\1', $txt));
         $comment->author = JComments::getCommentAuthorName($comment);
         $tmpl = JCommentsFactory::getTemplate($comment->object_id, $comment->object_group);
         $tmpl->load('tpl_email_report');
         $tmpl->addVar('tpl_email_report', 'comment-object_title', $objectInfo->title);
         $tmpl->addVar('tpl_email_report', 'comment-object_link', JCommentsFactory::getAbsLink($objectInfo->link));
         $tmpl->addVar('tpl_email_report', 'report-name', $name);
         $tmpl->addVar('tpl_email_report', 'report-reason', $reason);
         $tmpl->addVar('tpl_email_report', 'quick-moderation', $config->getInt('enable_quick_moderation'));
         $tmpl->addVar('tpl_email_report', 'enable-blacklist', $config->getInt('enable_blacklist'));
         $tmpl->addObject('tpl_email_report', 'comment', $comment);
         $message = $tmpl->renderTemplate('tpl_email_report');
         $tmpl->freeTemplate('tpl_email_report');
         $subject = JText::sprintf('REPORT_NOTIFICATION_SUBJECT', $comment->author);
         if (isset($subject) && isset($message)) {
             $emails = explode(',', $config->get('notification_email'));
             $mailFrom = $app->getCfg('mailfrom');
             $fromName = $app->getCfg('fromname');
             foreach ($emails as $email) {
                 $email = trim((string) $email);
                 // don't send notification to message author
                 if ($user->email != $email) {
                     JCommentsMail::send($mailFrom, $fromName, $email, $subject, $message, true);
                 }
             }
         }
         unset($emails, $objectInfo);
         $comment->comment = $commentText;
     }
 }
Exemplo n.º 2
0
 /**
  * Prepares data for notification
  *
  * @param array $data An associative array of notification data
  * @param string $type Type of notification
  *
  * @return mixed
  */
 private static function prepareData($data, $type)
 {
     require_once JPATH_ROOT . '/components/com_jcomments/jcomments.php';
     $object = JCommentsObjectHelper::getObjectInfo($data['comment']->object_id, $data['comment']->object_group, $data['comment']->lang);
     $data['notification-type'] = $type;
     $data['object_title'] = $object->title;
     $data['object_link'] = JCommentsFactory::getAbsLink($object->link);
     $data['comment']->author = JComments::getCommentAuthorName($data['comment']);
     $data['comment']->title = JCommentsText::censor($data['comment']->title);
     $data['comment']->comment = JCommentsText::censor($data['comment']->comment);
     $data['comment']->comment = JCommentsFactory::getBBCode()->replace($data['comment']->comment);
     if (JCommentsFactory::getConfig()->getInt('enable_custom_bbcode')) {
         $data['comment']->comment = JCommentsFactory::getCustomBBCode()->replace($data['comment']->comment, true);
     }
     $data['comment']->comment = trim(preg_replace('/(\\s){2,}/i', '\\1', $data['comment']->comment));
     return $data;
 }