function get_announcements_block() { $buffer = ''; if (is_user_granted_permission(PERM_ADMIN_ANNOUNCEMENTS)) { // include a login warning if user password and email are still the defaults if (get_opendb_session_var('user_id') == 'admin') { $announcements_rs = get_admin_announcements_rs(); while (list(, $announcement_r) = each($announcements_rs)) { $buffer .= "<li><h4>" . $announcement_r['heading'] . "</h4>\n\t\t\t\t\t<p class=\"content\">" . $announcement_r['message'] . "<a class=\"adminLink\" href=\"" . $announcement_r['link'] . "\">" . $announcement_r['link_text'] . "</a></p>"; } } } if (get_opendb_config_var('welcome.announcements', 'enable') !== FALSE && is_user_granted_permission(PERM_VIEW_ANNOUNCEMENTS)) { $results = fetch_announcement_rs('submit_on', 'DESC', 0, get_opendb_config_var('welcome.announcements', 'display_count'), 'Y', 'Y'); if ($results) { while ($announcement_r = db_fetch_assoc($results)) { $buffer .= "<li><h4>" . $announcement_r['title'] . "</h4>"; $buffer .= "<small class=\"submitDate\">" . get_localised_timestamp(get_opendb_config_var('welcome.announcements', 'datetime_mask'), $announcement_r['submit_on']) . "</small>"; $buffer .= "<p class=\"content\">" . nl2br($announcement_r['content']) . "</p></li>"; } db_free_result($results); } } if (strlen($buffer) > 0) { return "\n<div id=\"announcements\">" . "<h3>" . get_opendb_lang_var('announcements') . "</h3>" . "\n<ul>" . $buffer . "\n</ul></div>"; } else { return NULL; } }
} $HTTP_VARS['op'] = 'list'; } else { echo "<h3>Delete Announcement</h3>"; echo get_op_confirm_form($PHP_SELF, 'Are you sure you want to permanently delete announcement "' . fetch_announcement_title($HTTP_VARS['announcement_id']) . '"?', $HTTP_VARS); } } } } } if ($HTTP_VARS['op'] == 'list') { echo "<p>[<a href=\"{$PHP_SELF}?type={$ADMIN_TYPE}&op=new\">New Announcement</a>]</p>"; if (is_not_empty_array($errors)) { echo format_error_block($errors); } $result = fetch_announcement_rs(); if ($result) { $submitted_datetime_mask = get_opendb_config_var('welcome.announcements', 'datetime_mask'); echo "<table>"; echo "<tr class=\"navbar\">" . "<th>Title</th>" . "<th>Content</th>" . "<th>Submitted</th>" . "<th>Display Days</th>" . "<th>Closed</th>" . "<th></th>" . "</tr>"; while ($announcement_r = db_fetch_assoc($result)) { echo "<tr>"; echo "\n<td class=\"data\">" . $announcement_r['title'] . ""; echo "\n<td class=\"data\">" . nl2br($announcement_r['content']) . "</td>"; echo "<td class=\"data\">" . get_localised_timestamp($submitted_datetime_mask, $announcement_r['submit_on']) . '</td>' . "<td class=\"data\">" . $announcement_r['display_days'] . '</td>' . "<td class=\"data\">" . $announcement_r['closed_ind'] . '</td>'; echo "<td class=\"data\"><a href=\"{$PHP_SELF}?type={$ADMIN_TYPE}&op=edit&announcement_id=" . $announcement_r['sequence_number'] . "\">Edit</a>"; echo " / <a href=\"{$PHP_SELF}?type={$ADMIN_TYPE}&op=delete&announcement_id=" . $announcement_r['sequence_number'] . "\">Delete</a></td>"; echo "</tr>"; } db_free_result($result); echo "</table>";
function build_announcements_feed($URL, $datemask) { $rssout = ''; $last_items_list_conf_r = get_opendb_config_var('feeds.announcements'); // TODO - make the options here configurable $result = fetch_announcement_rs(NULL, "DESC", 0, $last_items_list_conf_r['total_num_items'], "N", "Y"); //$limit_closed // Create the RSS item tags if ($result && db_num_rows($result) > 0) { while ($item_instance_r = db_fetch_assoc($result)) { $rssout .= "\n\t<item>" . "\n\t\t<title>" . rss_encoded($item_instance_r['title']) . "</title>" . "\n\t\t<link>" . rss_encoded($URL) . "</link>" . "\n\t\t<pubDate>" . get_localised_timestamp($datemask, $item_instance_r['submit_on']) . " " . date('T') . "</pubDate>" . "\n\t\t<guid>" . rss_encoded($URL) . "</guid>" . "\n\t\t<description>" . rss_encoded(nl2br($item_instance_r['content'])) . "</description>" . "\n\t</item>"; } db_free_result($result); } return $rssout; }