Clean up Notifications\print_user_notices
Showing
1 changed file
with
16 additions
and
40 deletions
| ... | @@ -44,73 +44,49 @@ function get_user_notices($uid) | ... | @@ -44,73 +44,49 @@ function get_user_notices($uid) |
| 44 | } | 44 | } |
| 45 | } | 45 | } |
| 46 | 46 | ||
| 47 | function print_user_notices($show_more = true) | 47 | function print_user_notices() |
| 48 | { | 48 | { |
| 49 | $user = new User\CurrentAccount(); | 49 | $user = new User\CurrentAccount(); |
| 50 | 50 | ||
| 51 | get_user_notices($user->ID); | 51 | get_user_notices($user->ID); |
| 52 | 52 | ||
| 53 | if (CBV\on_page('/dashboard')) { | ||
| 54 | $limit = 5; | ||
| 55 | } else { | ||
| 56 | $limit = 10; | ||
| 57 | } | ||
| 58 | |||
| 59 | $notices = Vars::$notices; | 53 | $notices = Vars::$notices; |
| 60 | $total_rows = count($notices); | 54 | $total_rows = count($notices); |
| 61 | $next_id = isset($_POST['last_id']) ? ($_POST['last_id'] + 1) : 0; | 55 | $rows = ''; |
| 62 | $end = (($next_id + $limit) < $total_rows) ? ($next_id + $limit) : $total_rows; | ||
| 63 | |||
| 64 | if (count($notices) < 1) { | ||
| 65 | //print '<tr><td colspan="3">You have no new notices.</td></tr>'; | ||
| 66 | } | ||
| 67 | 56 | ||
| 68 | $rows = ""; | ||
| 69 | |||
| 70 | $last_id = 0; | ||
| 71 | for ($i = 0; $i < $total_rows; $i++) { | 57 | for ($i = 0; $i < $total_rows; $i++) { |
| 72 | |||
| 73 | $the_notice = get_post($notices[$i]['notification_id']); | ||
| 74 | $system = get_post_meta($notices[$i]['notification_id'], 'system', true); | 58 | $system = get_post_meta($notices[$i]['notification_id'], 'system', true); |
| 75 | $content = $system['message']; | 59 | $content = $system['message']; |
| 76 | $id = $the_notice->ID; | ||
| 77 | 60 | ||
| 78 | if (isset($notices[$i]['args']) && count($notices[$i]['args']) > 0): | 61 | if (isset($notices[$i]['args']) && count($notices[$i]['args']) > 0): |
| 79 | foreach ($notices[$i]['args'] as $key => $val) { | 62 | foreach ($notices[$i]['args'] as $key => $val) { |
| 80 | if (filter_var($val, FILTER_VALIDATE_URL) !== false) { | 63 | if (filter_var($val, FILTER_VALIDATE_URL) !== false) { |
| 81 | $content = str_replace("{".$key."}", "<a href='".$val."'>Click here</a>", $content); | 64 | $content = str_replace('{'.$key.'}', "<a href='".$val."'>Click here</a>", $content); |
| 82 | } else { | 65 | } else { |
| 83 | $content = str_replace("{".$key."}", $val, $content); | 66 | $content = str_replace('{'.$key.'}', $val, $content); |
| 84 | } | 67 | } |
| 85 | } | 68 | } |
| 86 | endif; | 69 | endif; |
| 87 | 70 | ||
| 88 | $rows .= '<tr class="notice-row" id="'.$i.'">'; | 71 | $rows .= '<tr class="notice-row" id="'.$i.'">'; |
| 89 | if ($notices[$i]['status'] == "unread") { | 72 | if ($notices[$i]['status'] == 'unread') { |
| 90 | $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>'; | 73 | $rows .= '<td width="12" style="padding:0;padding-left:10px;vertical-align:middle;"><a href="#" class="notice ' |
| 74 | .(($notices[$i]['status'] == 'read') ? 'read' : 'unread') | ||
| 75 | .'"><img src="assets/images/blank.gif" width="12" height="12" /></a></td>'; | ||
| 91 | } else { | 76 | } else { |
| 92 | $rows .= '<td width="12" style="padding:0;padding-left:10px;vertical-align:middle;"><img src="assets/images/blank.gif" width="12" height="12" /></td>'; | 77 | $rows .= '<td width="12" style="padding:0;padding-left:10px;vertical-align:middle;"><img src="assets/images/blank.gif" width="12" height="12" /></td>'; |
| 93 | } | 78 | } |
| 94 | /* | 79 | |
| 95 | if($system['system_message_type']=="none"): | 80 | if ($system['system_message_type'] == 'none') { |
| 96 | $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>'; | 81 | $system['system_message_type'] = 'notice'; |
| 97 | else: | ||
| 98 | */ | ||
| 99 | if ($system['system_message_type'] == "none") { | ||
| 100 | $system['system_message_type'] = "notice"; | ||
| 101 | } | 82 | } |
| 102 | 83 | ||
| 103 | $rows .= '<td width="80" style="vertical-align:middle;"><span>'.ucfirst( | 84 | $rows .= '<td width="80" style="vertical-align:middle;"><span>' |
| 104 | str_replace("_", " ", $system['system_message_type'])).'</span></td>'; | 85 | .ucfirst(str_replace('_', ' ', $system['system_message_type'])) |
| 105 | $rows .= '<td style="vertical-align:middle;">'.nl2br($content).'<br /><span class="legal">Sent: '.date( | 86 | .'</span></td>'; |
| 106 | "M j, Y @ h:ia", $notices[$i]['sent_date']).'</span></td>'; | 87 | $rows .= '<td style="vertical-align:middle;">'.nl2br($content).'<br /><span class="legal">Sent: ' |
| 107 | /*endif;*/ | 88 | .date('M j, Y @ h:ia', $notices[$i]['sent_date']).'</span></td>'; |
| 108 | $rows .= '</tr>'; | 89 | $rows .= '</tr>'; |
| 109 | $last_id = $i; | ||
| 110 | } | ||
| 111 | |||
| 112 | if ($end < $total_rows && CBV\on_page('/notices')) { | ||
| 113 | //$rows .= '<tr id="TzMoreRows"><td colspan="4"><a onclick="return false;" class="load_more_notices" id="'.$last_id.'" href="#">Show more...</a></td></tr>'; | ||
| 114 | } | 90 | } |
| 115 | 91 | ||
| 116 | if (isset($_POST['ajax'])) { | 92 | if (isset($_POST['ajax'])) { | ... | ... |
-
Please register or sign in to post a comment