This repository has been archived on 2024-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
mybb-digest/email.php
Alexander Yakovlev de9ab2aa5f Numerous fixes
- Hyperlinks in the digest
- No deleted, closed or moved threads in the digest
- No "Last update" column for threads with 0 replies
- Changed date format to 17/05/2017
- Set the timzeone explicitly
2017-05-09 16:46:02 +07:00

64 lines
2.3 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
// forbidden: forbidden forums IDs
// skips over threads made by this user with 0 replies
function print_email($username, $unsubscription, $threads, $forbidden, $url) {
$th_style = "font-family: Arial, Helvetica, sans-serif;padding: 0.5em; border: 1px solid #eee;";
$td_style = "font-family: Arial, Helvetica, sans-serif;padding: 0.5em; border: 1px solid #eee;";
$message = <<<END
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<head>
<title>Daily digest from Olympic Business Forum</title>
</head>
<body style="font-family: Arial, Helvetica, sans-serif;font-size: 11pt;">
<p>$username,</p>
<p>Heres a daily update of activity on the Olympic Business forum.</p>
<p><table style="padding: 1em; border: 1px solid #eee;border-collapse: collapse;">
<thead>
<th style="$th_style">Forum</th>
<th style="$th_style">Thread</th>
<th style="$th_style">Started by</th>
<th style="$th_style">Replies</th>
<th style="$th_style">Last update</th>
</thead>
<tbody>
END;
foreach ($threads as $thread) {
if (in_array($thread['fid'], $forbidden))
continue;
if ($thread['replies'] === '0' && $thread['username'] === $username)
continue;
$lastupdate = $thread['lastposter'].', '.date(DATE_FORMAT, $thread['lastpost']);
if ($thread['replies'] === '0') {
$lastupdate = '&nbsp;';
}
$message .= '
<tr>
<td style="'.$td_style.'">'.$thread['forumname'].'</td>
<td style="'.$td_style.'"><a href="'.$url.'/showthread.php?tid='.$thread['tid'].'">'.$thread['subject'].'</a></td>
<td style="'.$td_style.'">'.
$thread['username'].', '.
date(DATE_FORMAT, $thread['dateline']).'
</td>
<td style="'.$td_style.'">'.$thread['replies'].'</td>
<td style="'.$td_style.'">'.$lastupdate.'</td>
</tr>
';
}
$message .= <<<END
</tbody>
</table></p>
<p>Thank you,<br>
Olympic Business Forum Staff</p>
<p>To unsubscribe from these daily digests, <a href="$unsubscription">click here.</a></p>
</body>
</html>
END;
return $message;
} ?>