Location: PHPKode > projects > ACollab > group_admin/news.php
<?php
/****************************************************************************************/
/* ACollab                                                                              */
/****************************************************************************************/
/* Copyright (c) 2002-2004  Adaptive Technology Resource Centre / University of Toronto */
/*                                                                                      */
/* http://atutor.ca/acollab                                                             */
/*                                                                                      */
/* This program is free software. You may 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 of the License,       */
/* 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 may access the GNU General Public License at:                                    */
/* http://www.opensource.org/licenses/gpl-license.php                                   */
/*                                                                                      */
/* You may contact the Adaptive Technology Resource Centre at                           */
/* Robarts Library, University of Toronto                                               */
/* 130 St. George Street, Toronto, Ontario, Canada M5S 1A5                              */
/* Further contact information is available at http://www.utoronto.ca/atrc/             */
/****************************************************************************************/
/* Programmer:                                                                          */
/* Joel Kronenberg - ATRC                                                               */
/****************************************************************************************/
// $Id: news.php 236 2004-06-07 20:08:32Z boonhau $

define('AC_INCLUDE_PATH', '../include/');

require(AC_INCLUDE_PATH.'vitals.inc.php');
authenticate(USER_GROUP_ADMIN);


if (authenticate(USER_ADMIN, USER_RETURN_CHECK)) {
	$group_info = get_group($_SESSION['group_id']);

	$_SECTION[0][0] = _AC('administration');
	$_SECTION[0][1] = 'admin/index.php';
	$_SECTION[1][0] = _AC('groups');
	$_SECTION[1][1] = 'admin/groups.php';
	$_SECTION[2][0] = $group_info['title'];
	$_SECTION[2][1] = 'group_admin/index.php';
	$_SECTION[3][0] = _AC('news_and_announcements');
	$_SECTION[3][1] = 'group_admin/news.php';

	require(AC_INCLUDE_PATH.'admin/header.inc.php');
} else {
	$_SECTION[0][0] = _AC('home');
	$_SECTION[0][1] = 'home.php';
	$_SECTION[1][0] = _AC('administration');
	$_SECTION[1][1] = 'group_admin/';
	$_SECTION[2][0] = _AC('news_and_announcements');
	$_SECTION[2][1] = 'group_admin/news.php';

	require(AC_INCLUDE_PATH.'header.inc.php');
}

print_popup_help('help_post_news');
echo '<p align="center"><a href="group_admin/news_create.php" onfocus="this.className=\'highlight\'" onblur="this.className=\'\'">ยป '._AC('create_news').'</a></p>';

if ($_GET['f']) {
	print_feedback($_GET['f']);
}

if ($_GET['col']) {
	$col = addslashes($_GET['col']);
} else {
	$col = 'date';
}

if ($_GET['order']) {
	$order = addslashes($_GET['order']);
} else {
	$order = 'desc';
}

${'highlight_'.$col} = ' u';

$sql	= "SELECT * FROM ".TABLE_PREFIX."news WHERE group_id=$_SESSION[group_id] ORDER BY $col $order";
$result	= mysql_query($sql, $db);

if ($row = mysql_fetch_array($result)) {
	echo '<table cellspacing="0" cellpadding="2" border="0" bgcolor="white" width="99%" align="center" summary="" class="box2">';
	echo '<tr>';

	echo '<th scope="col" class="box" align="left"><small><a href="'.$_SERVER['PHP_SELF'].'?col=subject'.SEP.'order=asc" class="nav'.$highlight_subject.'" title="'._AC('subject_asc').'" onfocus="this.className=\'highlight\'" onblur="this.className=\'nav'.$highlight_subject.'\'">'._AC('subject').'</a> ';
		if (($col == 'subject') && ($order == 'asc')) {
			echo '<a href="'.$_SERVER['PHP_SELF'].'?col=subject'.SEP.'order=desc"><img src="images/desc.gif" height="7" width="11" alt="'._AC('subject_desc').'" border="0" class="img4" /></a>';
		} else if (($col == 'subject') && ($order == 'desc')) {
			echo '<a href="'.$_SERVER['PHP_SELF'].'?col=subject'.SEP.'order=asc"><img src="images/asc.gif" height="7" width="11" alt="'._AC('subject_asc').'" border="0"  class="img4" /></a>';
		} else {
			echo '<img src="images/clr.gif" height="7" width="11" alt="" />';
		}
	echo '</small></th>';

	echo '<th scope="col" class="box" align="left"><small><a href="'.$_SERVER['PHP_SELF'].'?col=date'.SEP.'order=desc" class="nav'.$highlight_date.'" title="'._AC('date_desc').'" onfocus="this.className=\'highlight\'" onblur="this.className=\'nav'.$highlight_date.'\'">'._AC('date').'</a> ';
		if (($col == 'date') && ($order == 'asc')) {
			echo '<a href="'.$_SERVER['PHP_SELF'].'?col=date'.SEP.'order=desc"><img src="images/desc.gif" height="7" width="11" alt="'._AC('date_desc').'" border="0"  class="img4" /></a>';
		} else if (($col == 'date') && ($order == 'desc')) {
			echo '<a href="'.$_SERVER['PHP_SELF'].'?col=date'.SEP.'order=asc"><img src="images/asc.gif" height="7" width="11" alt="'._AC('date_asc').'" border="0"  class="img4" /></a>';
		} else {
			echo '<img src="images/clr.gif" height="7" width="11" alt="" />';
		}
	echo '</small></th>';
	echo '<th scope="col" class="box">&nbsp;</th>';

	echo '</tr>';
	do {
		$counter++;
		$col = ($counter-1)%2;
		echo '<tr>';
		echo '<td class="row'.$col.'"><small>'.$row['subject'].'</small></td>';
		echo '<td class="row'.$col.'"><small>'.$row['date'].'</small></td>';

		echo '<td class="row'.$col.'" align="right"><small><a href="group_admin/news_edit.php?id='.$row['news_id'].'" onfocus="this.className=\'highlight\'" onblur="this.className=\'\'">'._AC('edit').'</a> | <a href="group_admin/news_delete.php?id='.$row['news_id'].'" onfocus="this.className=\'highlight\'" onblur="this.className=\'\'">'._AC('delete').'</a></small></td>';

		echo '</tr>';
	} while ($row = mysql_fetch_array($result));
	echo '</table>';
	echo '<p><small>'._AC('use_col_headings').'</small></p>';
} else {
	echo '<p>'._AC('no_news_found').'</p>';
}

require(AC_INCLUDE_PATH.'footer.inc.php');
?>
Return current item: ACollab