You are here

function og_mail_output in Organic groups 5.2

Same name and namespace in other branches
  1. 5 og.module \og_mail_output()
  2. 5.7 og.module \og_mail_output()
1 call to og_mail_output()
og_mail in ./og.module
Send this node/comment via email to all email subscribers. Called from og_nodeapi() and og_comment() TODO: this mail feature is a bit messy. rethink.

File

./og.module, line 1775

Code

function og_mail_output($body, $html = TRUE) {
  static $i = 0;
  if ($html) {
    $pattern = '@(<a href="(.+?)">(.+?)</a>)@ei';
    $body = preg_replace($pattern, "'\\3 ['. og_mail_urls('\\2') .']'", $body);
    $urls = og_mail_urls();
    if (count($urls)) {
      $body .= "\n";
      for ($max = count($urls); $i < $max; $i++) {
        $body .= '[' . ($i + 1) . '] ' . $urls[$i] . "\n";
      }
    }
    $body = preg_replace('!</?blockquote>!i', '"', $body);
    $body = preg_replace('!</?(em|i)>!i', '/', $body);
    $body = preg_replace('!</?(b|strong)>!i', '*', $body);
    $body = preg_replace("@<br />(?!\n)@i", "\n", $body);
    $body = preg_replace("@</p.*>(?!\n\n)@i", "\n\n", $body);
    $body = preg_replace("@</h1>(?!\n\n)@i", " #\n", $body);
    $body = preg_replace("@</h2>(?!\n\n)@i", " ##\n", $body);
    $body = preg_replace("@</h3>(?!\n\n)@i", " ###\n", $body);
    $body = preg_replace("@</h4>(?!\n\n)@i", " ####\n", $body);
    $body = preg_replace("@</(li|dd)>\n?@i", "\n", $body);
    $body = preg_replace("@<h1.*>@i", "\n\n# ", $body);
    $body = preg_replace("@<h2.*>@i", "\n\n## ", $body);
    $body = preg_replace("@<h3.*>@i", "\n\n### ", $body);
    $body = preg_replace("@<h4.*>@i", "\n\n#### ", $body);
    $body = preg_replace("@<li.*>@i", "* ", $body);
    $body = strip_tags($body);
    $body = decode_entities($body);
    $body = wordwrap($body, 72);
  }
  else {
    $body = decode_entities($body);
  }
  return $body;
}