function announcements_render_announcements

4.x announcements.module announcements_render_announcements()
5.x announcements.module announcements_render_announcements()

Return the HTML rendering the announcements we have in the database.

1 call to announcements_render_announcements()
announcements_render_block in modules/announcements/announcements.module
Called when it is time to render the block in question. Expected to return an array which looks like this: array( "title" => "Some title goes here.", "body" => "this is the primary body of the block", );

File

modules/announcements/announcements.module, line 60

Code

function announcements_render_announcements() {

  global $user;

  $rtn = "";

  $res = db_query("SELECT * FROM content WHERE type = 'announcement'
                    ORDER BY updated DESC");
  while ($cur = db_fetch_array($res)) {

    $announcement = content_load($cur ["cid"]);
    $title = $announcement ["title"];
    if (strstr($title, "[hide]")) {
      $title = "";
    }


    // Visibility?
    if ($announcement ["settings"]["visibility"] == "hidden") {
      continue;
    }

    if ($announcement ["settings"]["visibility"] == "faculty") {
      if (!user_has_permission("view_faculty_announcements")) {
        continue;
      }
    }


    $rtn .= "<div class='announcement'>";
    if ($title) {
      $rtn .= "
                <div class='announcement-title'>" . filter_markup($title) . "</div>
                ";
    }
    $rtn .= "<div class='announcement-text'>" . filter_markup($announcement ["body"], "full") . "</div>
                <div class='announcement-posted'>";

    // If we have not updated this announcement before, then print "posted",
    // else, print "updated" date.
    if ($announcement ["updated"] > $announcement ["posted"]) {
      $rtn .= t("Updated") . " " . date("D, M jS Y - g:ia", $announcement ["updated"]);
    }
    else {
      $rtn .= t("Posted") . " " . date("D, M jS Y - g:ia", $announcement ["posted"]);
    }

    $rtn .= "</div>";

    $rtn .= "</div>";
  }

  return $rtn;
}