Location: PHPKode > projects > ACollab > group_admin/forums_create.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: forums_create.php 222 2004-06-07 16:43:06Z boonhau $

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

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

	if (isset($_POST['cancel'])) {
		Header('Location: forums.php');
		exit;
	}

	if (isset($_POST['submit'])) {
		$reg_r = 0;
		switch ($_POST['rights']) {
			case 0:
				$r0		= ' checked="checked"';
				$reg_r	= FORUM_NONE;
				break;

			case 1:
				$r1 = ' checked="checked"';
				$reg_r	= FORUM_VIEW;
				break;

			case 2:
				$r2 = ' checked="checked"';
				$reg_r	= FORUM_VIEW + FORUM_REPLY;
				break;

			case 3:		
				$r3 = ' checked="checked"';
				$reg_r	= FORUM_VIEW + FORUM_REPLY + FORUM_START;
				break;
		}

		$_POST['title'] = str_replace('<', '&lt;', trim($_POST['title']));
		$_POST['description']  = str_replace('<', '&lt;', trim($_POST['description']));

		if ($_POST['title'] == '') {
			$errors[] = E_FORUM_TITLE_EMPTY;
		}

		if (!$errors) {
			$_POST['title'] = $addslashes($_POST['title']);
			$_POST['description'] = $addslashes($_POST['description']);

			$sql	= "INSERT INTO ".TABLE_PREFIX."forums VALUES (0, $_SESSION[group_id], '$_POST[title]', '$_POST[description]', 0, 0, NOW(), $reg_r)";
			$result = mysql_query($sql,$db);

			Header('Location: forums.php?f='.F_FORUM_ADDED);
			exit;
		}
	}

	$onload = 'onload="document.form.title.focus()"';
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('forum_management');
	$_SECTION[3][1] = 'group_admin/forums.php';
	$_SECTION[4][0] = _AC('create_forum');
	$_SECTION[4][1] = 'group_admin/forums/forums_create.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('forum_management');
	$_SECTION[2][1] = 'group_admin/forums.php';
	$_SECTION[3][0] = _AC('create_forum');
	$_SECTION[3][1] = 'group_admin/forums/forums_create.php';

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

 	print_popup_help('help_forum_rights');
	if (isset($errors)) {
		print_errors($errors);
	}

	if (!isset($_POST['title'])) {
		$_POST['title'] = '';
		$r3 = ' checked="checked"';
	}
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="form">
	<table border="0" cellspacing="0" cellpadding="2" align="center" class="box2">
	<tr>
		<th colspan="5" class="box"><h3><?php echo _AC('create_forum'); ?></h3></th>
	</tr>
	<tr>
		<td class="row1">&nbsp;</td>
		<td colspan="3" class="row1"><img src="images/clr.gif" height="1" width="1" alt="" /><br /><?php
			echo _AC('denotes_required', '<img src="images/required.gif" height="14" width="14" alt="'._AC('required_field').'" />');
		?><br /></td>
		<td class="row1">&nbsp;</td>
	</tr>
	<tr bgcolor="white">
		<td class="row1">&nbsp;</td>
		<td class="row1" align="right"><label for="title"><b><?php echo _AC('forum_title'); ?>:</b></label></td>
		<td class="row1"><img src="images/required.gif" height="14" width="14" alt="<?php echo _AC('required_field'); ?>" /></td>
		<td class="row1"><input type="text" name="title" class="input" size="30" maxlength="60" id="title" value="<?php echo $_POST['title']; ?>" onfocus="this.className='input highlight'" onblur="this.className='input'" /></td>
		<td class="row1">&nbsp;</td>
	</tr>
	<tr bgcolor="white">
		<td class="row1">&nbsp;</td>
		<td class="row1" align="right" valign="top"><label for="desc"><b><?php echo _AC('description'); ?>:</b></label></td>
		<td class="row1">&nbsp;</td>
		<td class="row1"><textarea name="description" cols="45" rows="4" class="input" id="desc" onfocus="this.className='input highlight'" onblur="this.className='input'"><?php echo $_POST['description']; ?></textarea></td>
		<td class="row1">&nbsp;</td>
	</tr>
	<tr bgcolor="white">
		<td class="row1">&nbsp;</td>
		<td class="row1" align="right" valign="top"><b><?php echo _AC('regular_member_rights'); ?>:</b></td>
		<td class="row1">&nbsp;</td>
		<td class="row1"><input type="radio" name="rights" value="0" onfocus="this.className='highlight'" onblur="this.className=''" id="r0"<?php echo $r0; ?> /><label for="r0"><?php echo _AC('forum_rights_none'); ?></label><br />
						<input type="radio" name="rights" value="1" onfocus="this.className='highlight'" onblur="this.className=''" id="r1"<?php echo $r1; ?> /><label for="r1"><?php echo _AC('forum_rights_view'); ?></label><br />
						<input type="radio" name="rights" value="2" onfocus="this.className='highlight'" onblur="this.className=''" id="r2"<?php echo $r2; ?> /><label for="r2"><?php echo _AC('forum_rights_reply'); ?></label><br />
						<input type="radio" name="rights" value="3" onfocus="this.className='highlight'" onblur="this.className=''" id="r3"<?php echo $r3; ?> /><label for="r3"><?php echo _AC('forum_rights_start'); ?></label></td>
		<td class="row1">&nbsp;</td>
	</tr>
	<tr bgcolor="white">
		<td class="row1">&nbsp;</td>
		<td class="row1" colspan="3" align="right"><br /><input type="submit" name="submit" value="<?php echo _AC('create'); ?>" class="submitY" onfocus="this.className='submitY highlight'" onblur="this.className='submitY'" /> &nbsp; <input type="submit" name="cancel" value="<?php echo _AC('cancel'); ?>" class="submitN" onfocus="this.className='submitN highlight'" onblur="this.className='submitN'" /><br /><br /></td>
		<td class="row1">&nbsp;</td>
	</tr>
	</table>
</form>

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