Location: PHPKode > projects > ACollab > index.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                                                               */
/* Heidi Hazelton  - ATRC                                                               */
/****************************************************************************************/
// $Id: index.php 484 2005-04-01 14:59:55Z shozubq $

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

require(AC_INCLUDE_PATH.'vitals.inc.php');
/*echo '<pre>';
print_r($_SESSION);*/
authenticate(USER_CLIENT, USER_GROUP_ADMIN);

if (isset($_GET['id'])) {
	$id = intval($_GET['id']);

	if (authenticate(USER_ADMIN, USER_RETURN_CHECK)) {
		$_SESSION['group_id'] = $id;
		$_SESSION['course_id'] = intval($_GET['cid']);
		//update online users list
		addd_user_online();

		if (isset($_GET['p'])) {
			header('Location: '.urldecode($_GET['p']));
		} else {
			header('Location: home.php');
		}
		exit;

	} else {
		$sql	= "SELECT M.privileges FROM ".TABLE_PREFIX."groups_members M WHERE M.member_id=$_SESSION[member_id] AND M.group_id=$id";
		$result	= mysql_query($sql, $db);
		if ($row = mysql_fetch_assoc($result)) {
			$_SESSION['group_id'] = $id;
			//update online users list
			addd_user_online();
			
			if ($row['privileges'] > 0) {
				$_SESSION['status']   = $row['privileges'];
			} else {
				$_SESSION['status'] = USER_CLIENT;
			}
			
			header('Location: home.php');
			exit;
		} else if (($_SESSION['courtyard_priv'] == COURTYARD_PRIV_GROUP_ACCESS) 
			|| ($_SESSION['courtyard_priv'] == COURTYARD_PRIV_ADMIN) 
			|| ($_SESSION['courtyard_priv'] == COURTYARD_PRIV_GROUP_ACCESS_CREATE) ) {

			$_SESSION['group_id'] = $id;
			$_SESSION['status'] = USER_GROUP_ADMIN;

			header('Location: home.php');
			exit;
		}
	}
}

$_SESSION['status'] = USER_CLIENT;

$_SECTION[0][0] = _AC('groups');
$_SECTION[0][1] = 'index.php';

require(AC_INCLUDE_PATH.'pub/header.inc.php');

?>
<br /><br /><br />
<?php
if (isset($_GET['f'])) {
	print_feedback($_GET['f']);
}

if (!$_SESSION['course_id']) {
?>

<table border="0" cellspacing="0" cellpadding="0" align="center" width="70%">
	<tr><td>
		<a href="sign_out.php" onfocus="this.className='highlight'" onblur="this.className=''"><?php echo _AC('sign_out'); ?></a>
	</td></tr>
</table>
<?php
} //end if
?>

<table border="0" cellspacing="0" cellpadding="0" align="center" class="box" width="70%">

	<tr>
		<th colspan="4" class="box"><h3>
		<?php 
			if (defined('AT_PATH') && AT_PATH) {
				$sql = 'SELECT title FROM '.AT_TABLE_PREFIX.'courses WHERE course_id='.$_SESSION['course_id'];
				$result	= mysql_query($sql, $db);
				if ($row = mysql_fetch_assoc($result)) {
					echo $row['title'].' ';
				}
			}

			echo _AC('groups'); 
		?></h3></th>
	</tr>
<?php 
if ($_SESSION['course_id']) {
	require('atutor/include/user_bar.inc.php'); 
}	
?>
	<tr>
		<td><table border="0" cellspacing="0" cellpadding="4" class="border" width="100%"><?php

			if ($_SESSION['courtyard_priv'] == COURTYARD_PRIV_ADMIN) {
				$order  = 'title';
				$sql	= "SELECT *, 2 AS `privileges`, $_SESSION[member_id] AS member_id FROM ".TABLE_PREFIX."groups WHERE course_id=$_SESSION[course_id] ORDER BY $order";
				//debug('is admin');
			} else if ($_SESSION['courtyard_priv'] == COURTYARD_PRIV_GROUP_CREATE) {
				$order  = 'title';
				$sql	= "SELECT H.*, M.privileges FROM ".TABLE_PREFIX."groups_members M, ".TABLE_PREFIX."groups H WHERE M.member_id=$_SESSION[member_id] AND M.group_id=H.group_id AND H.course_id=$_SESSION[course_id] ORDER BY $order";
				//debug('is create');
			} else if (($_SESSION['courtyard_priv'] == COURTYARD_PRIV_GROUP_ACCESS) || ($_SESSION['courtyard_priv'] == COURTYARD_PRIV_GROUP_ACCESS_CREATE)) {
				$order  = 'title';
				$sql	= "SELECT * FROM ".TABLE_PREFIX."groups WHERE course_id=$_SESSION[course_id] ORDER BY $order";

				$sql	= "SELECT H.group_id, H.title, H.image_name, M.member_id, M.privileges FROM ".TABLE_PREFIX."groups H LEFT JOIN ".TABLE_PREFIX."groups_members M ON H.group_id=M.group_id WHERE H.course_id=$_SESSION[course_id] ORDER BY $order";

				//debug('is access');
			} else {
				$order  = 'title';
				$sql	= "SELECT H.*, M.member_id, M.privileges FROM ".TABLE_PREFIX."groups_members M, ".TABLE_PREFIX."groups H WHERE M.member_id=$_SESSION[member_id] AND M.group_id=H.group_id AND H.course_id=$_SESSION[course_id] ORDER BY $order";
				//debug('is client');
			}

			$result	= mysql_query($sql, $db);

			while ($row = mysql_fetch_assoc($result)) {
				if (isset($groups[$row['group_id']]) && ($row['member_id'] == $_SESSION['member_id'])) {
					$groups[$row['group_id']] = $row;
				} else if (!isset($groups[$row['group_id']]) && ($row['member_id'] == $_SESSION['member_id'])) {
					$groups[$row['group_id']] = $row;
				} else if (!isset($groups[$row['group_id']])) {
					$row['privileges'] = 0;
					$groups[$row['group_id']] = $row;

				}
			}

			if (isset($groups)) {
				$count=1;
				foreach ($groups as $row) {
					if ($count % 2) {
						if ($count > 1) {
							echo '</tr>';
						}
						echo '<tr>';
					}
					echo '<td align="center" valign="top" width="50%">';
					echo '<a href="'.$_SERVER['PHP_SELF'].'?id='.$row['group_id'].'" onfocus="this.className=\'highlight\'" onblur="this.className=\'\'"><img src="images/group_icons/'.$row['image_name'].'" height="79" width="79" alt="" border="0" class="img3"/><br /><strong>';
					echo $row['title'];
					echo '</strong></a><br />';
					if (query_bit( $row['privileges'], USER_GROUP_ADMIN) && !$_SESSION['course_id']) {
						echo '<small><strong>('._AC('group_admin').')</strong></small>';
					} else {
						echo '<br />';
					}
					echo '</td>';

					$count++;

				}
			} else {
				echo '<tr>';
				echo '<td>';
				echo _AC('not_in_groups');
				echo '</td>';
				echo '</tr>';
			}
		
		if ($count % 2) {
			if ($count > 1) {
				echo '</tr>';
			}
			echo '<tr>';
		}

		if (!$_SESSION['course_id']) {
			echo '<td align="center" width="50%" valign="top"><a href="prefs/" onfocus="this.className=\'highlight\'" onblur="this.className=\'\'"><img src="images/options.gif" border="0" height="80" width="80" alt="" class="img3" /><br /><b>'._AC('options').'</b></a></td>';
	
			$count++;

			if (authenticate(USER_ADMIN, USER_RETURN_CHECK)) {
				if ($count % 2) {
					if ($count > 1) {
						echo '</tr>';
					}
					echo '<tr>';
				}
				echo '<td align="center" width="50%" valign="top"><a href="admin/index.php" onfocus="this.className=\'highlight\'" onblur="this.className=\'\'"><img src="images/super.gif" border="0" height="80" width="80" alt="" class="img3" /><br /><b>'._AC('system_settings').'</b></a>';
				echo '<br /><small><b>('._AC('admin').')</b></small>';
				echo '</td>';
			}
		} else {
			if (($_SESSION['courtyard_priv'] == COURTYARD_PRIV_GROUP_CREATE) 
					|| ($_SESSION['courtyard_priv'] == COURTYARD_PRIV_ADMIN) 
					|| ($_SESSION['courtyard_priv'] == COURTYARD_PRIV_GROUP_ACCESS_CREATE) ) {
				echo '<td align="center" width="50%" valign="top"><a href="admin/groups_create.php" onfocus="this.className=\'highlight\'" onblur="this.className=\'\'"><img src="images/super.gif" border="0" height="80" width="80" alt="" class="img3" /><br /><strong>'._AC('create_group').'</strong></a>';
				echo '</td>';
			} 
		}
		if ($count % 2) {
			echo '<td>&nbsp;</td>';
		}
		echo '</tr>';
		echo '</table>';

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