function show_announcements($template_name) { global $TPL; $people =& get_cached_table("person"); $query = "SELECT announcement.* \n FROM announcement \n ORDER BY displayFromDate DESC"; $db = new db_alloc(); $db->query($query); while ($db->next_record()) { $announcement = new announcement(); $announcement->read_db_record($db); $announcement->set_values(); $TPL["personName"] = $people[$announcement->get_value("personID")]["name"]; $TPL["odd_even"] = $TPL["odd_even"] == "odd" ? "even" : "odd"; include_template($template_name); } }
*/ // initialise the request require_once "../alloc.php"; // create an object to hold an announcement $announcement = new announcement(); // load the announcement from the database $announcementID = $_POST["announcementID"] or $announcementID = $_GET["announcementID"]; if ($announcementID) { $announcement->set_id($announcementID); $announcement->select(); } // read announcement variables set by the request $announcement->read_globals(); // process submission of the form using the save button if ($_POST["save"]) { $announcement->set_value("personID", $current_user->get_id()); $announcement->save(); alloc_redirect($TPL["url_alloc_announcementList"]); // process submission of the form using the delete button } else { if ($_POST["delete"]) { $announcement->delete(); alloc_redirect($TPL["url_alloc_announcementList"]); exit; } } // load data for display in the template $announcement->set_values(); $TPL["main_alloc_title"] = "Edit Announcement - " . APPLICATION_NAME; // invoke the page's main template include_template("templates/announcementM.tpl");