<?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: groups_create.php 250 2004-06-08 15:23:30Z boonhau $
define('AC_INCLUDE_PATH', '../include/');
require(AC_INCLUDE_PATH.'vitals.inc.php');
if(defined('AT_PATH') && AT_PATH) {
if (!(($_SESSION['courtyard_priv'] == COURTYARD_PRIV_GROUP_ACCESS_CREATE) || ($_SESSION['courtyard_priv'] == COURTYARD_PRIV_GROUP_CREATE))) {
exit('permission denied');
}
$_SECTION[0][0] = _AC('create_group');
$_SECTION[0][1] = 'admin/groups_create.php';
} else {
authenticate(USER_ADMIN);
$_SECTION[0][0] = _AC('administration');
$_SECTION[0][1] = 'admin/';
$_SECTION[1][0] = _AC('groups');
$_SECTION[1][1] = 'admin/groups.php';
$_SECTION[2][0] = _AC('create_group');
$_SECTION[2][1] = 'admin/groups_create.php';
}
if ($_POST['cancel']) {
if (defined('AT_PATH') && AT_PATH) {
Header('Location: ../index.php');
} else {
Header('Location: groups.php');
}
exit;
}
if ($_POST['submit']) {
$_POST['title'] = trim($_POST['title']);
if ($_POST['title'] == '') {
$error[] = E_GROUP_EMPTY_TITLE;
}
if (!$error) {
$_POST['title'] = $addslashes($_POST['title']);
$sql = "INSERT INTO ".TABLE_PREFIX."groups VALUES (0, $_SESSION[course_id], '$_POST[title]','$_POST[image_name]')";
if (mysql_query($sql, $db)) {
$id = mysql_insert_id($db);
@mkdir('../chat/msgs/'.$id); // chat msgs
@mkdir('../chat/tran/'.$id); // chat transcripts
$sql = "INSERT INTO ".TABLE_PREFIX."groups_members VALUES ($id, $_SESSION[member_id], ".USER_GROUP_ADMIN.")";
mysql_query($sql, $db);
if (authenticate(USER_ADMIN, USER_RETURN_CHECK)) {
header('Location: groups.php?f='.F_GROUP_CREATED);
} else {
header('Location: ../index.php?id='.$id.'f='.F_GROUP_CREATED);
}
exit;
} else {
$error[] = E_GROUP_CREATE;
}
}
}
require(AC_INCLUDE_PATH.'admin/header.inc.php');
if (isset($error)) {
print_errors($error);
}
?>
<br />
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<table border="0" cellspacing="0" cellpadding="2" align="center" class="box2">
<tr>
<th colspan="5" class="box"><h3><?php echo _AC('create_group'); ?></h3></th>
</tr>
<tr>
<td class="row1"> </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"> </td>
</tr>
<tr>
<td class="row1"> </td>
<td class="row1" align="right"><label for="title"><b><?php echo _AC('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="40" maxlength="100" id="title" value="<?php echo $_POST['title']; ?>" onfocus="this.className='input highlight'" onblur="this.className='input'" /></td>
<td class="row1"> </td>
</tr>
<tr>
<td class="row1"> </td>
<td valign="top" class="row1" align="right"><label for="image"><b><?php echo _AC('image'); ?>:</b></label></td>
<td valign="top" class="row1"><img src="images/required.gif" height="14" width="14" alt="<?php echo _AC('required_field'); ?>" /></td>
<td class="row1">
<table border="0" cellspacing="0" cellpadding="2" align="center" id="image"><tr>
<?php
$files = scandir('../images/group_icons');
$count=0;
$checked = 'checked="checked"';
foreach ($files as $file) {
$ftype = explode('.', $file);
if (($ftype[1] == "gif") || ($ftype[1]=="jpg") || ($ftype[1]=="jpeg")) {
if (!($count % 4) && $count > 0) {
echo '</tr><tr>';
}
echo '<td align="center"><label for="image'.$count.'"><img src="images/group_icons/'.$file.'" alt="'.$file.'" /></label>';
echo '<br /><input type="radio" name="image_name" id="image'.$count.'" value="'.$file.'" '.$checked.' /></td>';
$count++;
$checked='';
}
}
?>
</tr></table>
</td>
<td class="row1"> </td>
</tr>
<tr>
<td class="row1"> </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'" /> <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"> </td>
</tr>
</table>
</form>
<?php
require(AC_INCLUDE_PATH.'admin/footer.inc.php');
?>