<?php

// -----------------------------------------------------------------------
// This file is part of AROUNDMe
//
// Copyright (C) 2003 - 2007 Barnraiser
// http://www.barnraiser.org/
// info@barnraiser.org
//
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2, or (at your option) any
// later version.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with program; see the file COPYING. If not, write to the Free
// Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
// 02110-1301, USA.
// -----------------------------------------------------------------------

$menu_section = "structure";


if (!isset($_SESSION['md5'])) {
	header("Location: index.php?http_referer=" . urlencode($_SERVER['REQUEST_URI']) . "&" . strip_tags(SID));
	exit;
}

// SETUP ANNOUNCE
require_once ("class/Announce.class.php");
$announce = new Announce($db, $_SESSION['user_id']);
// Get the specific or latest announcement
if (isset($_REQUEST['announce_id'])) {
	$output_announcement = $announce->selAnnouncement($_REQUEST['announce_id']);
}
else {
	$output_announcement = $announce->selAnnouncement();
}

if (!empty($output_announcement[0])) {
	// Get maximum 20 announcements
	$output_announcements = $announce->selAnnouncements(20);

	// Send the list of announcements to the body
	if (isset($output_announcements) && !empty($output_announcements)) {
		$body->set('announcements', $output_announcements);
	}

	if (isset($output_announcement[0])) {
		$output_announcement[0]['announce_body'] = str_replace("SYS_KEYWORD_NAME", $_SESSION['user_firstname'], $output_announcement[0]['announce_body']);
		$body->set('announcement', $output_announcement[0]);
	}
}
else {
	header("Location: index.php?amn=core_ann_list&" . strip_tags(SID));
	exit;
}

?>