e4863550 by Marty Penner

Clean up Notifications\print_user_notices

1 parent aa4c2aff
......@@ -44,73 +44,49 @@ function get_user_notices($uid)
}
}
function print_user_notices($show_more = true)
function print_user_notices()
{
$user = new User\CurrentAccount();
get_user_notices($user->ID);
if (CBV\on_page('/dashboard')) {
$limit = 5;
} else {
$limit = 10;
}
$notices = Vars::$notices;
$total_rows = count($notices);
$next_id = isset($_POST['last_id']) ? ($_POST['last_id'] + 1) : 0;
$end = (($next_id + $limit) < $total_rows) ? ($next_id + $limit) : $total_rows;
if (count($notices) < 1) {
//print '<tr><td colspan="3">You have no new notices.</td></tr>';
}
$rows = "";
$rows = '';
$last_id = 0;
for ($i = 0; $i < $total_rows; $i++) {
$the_notice = get_post($notices[$i]['notification_id']);
$system = get_post_meta($notices[$i]['notification_id'], 'system', true);
$content = $system['message'];
$id = $the_notice->ID;
if (isset($notices[$i]['args']) && count($notices[$i]['args']) > 0):
foreach ($notices[$i]['args'] as $key => $val) {
if (filter_var($val, FILTER_VALIDATE_URL) !== false) {
$content = str_replace("{".$key."}", "<a href='".$val."'>Click here</a>", $content);
$content = str_replace('{'.$key.'}', "<a href='".$val."'>Click here</a>", $content);
} else {
$content = str_replace("{".$key."}", $val, $content);
$content = str_replace('{'.$key.'}', $val, $content);
}
}
endif;
$rows .= '<tr class="notice-row" id="'.$i.'">';
if ($notices[$i]['status'] == "unread") {
$rows .= '<td width="12" style="padding:0;padding-left:10px;vertical-align:middle;"><a href="#" class="notice '.(($notices[$i]['status'] == "read") ? 'read' : 'unread').'"><img src="assets/images/blank.gif" width="12" height="12" /></a></td>';
if ($notices[$i]['status'] == 'unread') {
$rows .= '<td width="12" style="padding:0;padding-left:10px;vertical-align:middle;"><a href="#" class="notice '
.(($notices[$i]['status'] == 'read') ? 'read' : 'unread')
.'"><img src="assets/images/blank.gif" width="12" height="12" /></a></td>';
} else {
$rows .= '<td width="12" style="padding:0;padding-left:10px;vertical-align:middle;"><img src="assets/images/blank.gif" width="12" height="12" /></td>';
}
/*
if($system['system_message_type']=="none"):
$rows .= '<td colspan="2" style="vertical-align:middle;">'.nl2br($content).'<br /><span class="legal">Sent: '.date("M j, Y @ h:ia",$notices[$i]['sent_date']).'</span></td>';
else:
*/
if ($system['system_message_type'] == "none") {
$system['system_message_type'] = "notice";
}
$rows .= '<td width="80" style="vertical-align:middle;"><span>'.ucfirst(
str_replace("_", "&nbsp;", $system['system_message_type'])).'</span></td>';
$rows .= '<td style="vertical-align:middle;">'.nl2br($content).'<br /><span class="legal">Sent: '.date(
"M j, Y @ h:ia", $notices[$i]['sent_date']).'</span></td>';
/*endif;*/
$rows .= '</tr>';
$last_id = $i;
if ($system['system_message_type'] == 'none') {
$system['system_message_type'] = 'notice';
}
if ($end < $total_rows && CBV\on_page('/notices')) {
//$rows .= '<tr id="TzMoreRows"><td colspan="4"><a onclick="return false;" class="load_more_notices" id="'.$last_id.'" href="#">Show more...</a></td></tr>';
$rows .= '<td width="80" style="vertical-align:middle;"><span>'
.ucfirst(str_replace('_', '&nbsp;', $system['system_message_type']))
.'</span></td>';
$rows .= '<td style="vertical-align:middle;">'.nl2br($content).'<br /><span class="legal">Sent: '
.date('M j, Y @ h:ia', $notices[$i]['sent_date']).'</span></td>';
$rows .= '</tr>';
}
if (isset($_POST['ajax'])) {
......