2 /************************************************************************/
\r
4 /************************************************************************/
\r
5 /* Copyright (c) 2002-2010 */
\r
6 /* Inclusive Design Institute */
\r
7 /* http://atutor.ca */
\r
9 /* This program is free software. You can redistribute it and/or */
\r
10 /* modify it under the terms of the GNU General Public License */
\r
11 /* as published by the Free Software Foundation. */
\r
12 /************************************************************************/
\r
15 define('AT_INCLUDE_PATH', '../../../include/');
\r
16 require(AT_INCLUDE_PATH.'vitals.inc.php');
\r
17 authenticate(AT_PRIV_GROUPS);
\r
19 if (isset($_GET['edit'], $_GET['id'])) {
\r
20 $parts = explode('_', $_GET['id'], 2);
\r
21 if (isset($parts[1]) && $parts[1]) {
\r
22 header('Location: edit_group.php?id='.$parts[1]);
\r
24 } else if ($parts[0]) {
\r
25 header('Location: edit_type.php?id='.$parts[0]);
\r
28 } else if (isset($_GET['delete'], $_GET['id'])) {
\r
29 $parts = explode('_', $_GET['id'], 2);
\r
30 if (isset($parts[1]) && $parts[1]) {
\r
31 header('Location: delete_group.php?id='.$parts[1]);
\r
33 } else if ($parts[0]) {
\r
34 header('Location: delete_type.php?id='.$parts[0]);
\r
37 } else if (isset($_GET['members'])) {
\r
38 $parts = explode('_', $_GET['id'], 2);
\r
39 if (isset($parts[1]) && $parts[1]) {
\r
40 header('Location: members.php?id='.$parts[0].SEP.'gid='.$parts[1]);
\r
42 } else if ($parts[0]) {
\r
43 header('Location: members.php?id='.$parts[0]);
\r
46 $msg->addError('NO_ITEM_SELECTED');
\r
48 } else if (isset($_GET['members']) || isset($_GET['delete']) || isset($_GET['edit'])) {
\r
49 $msg->addError('NO_ITEM_SELECTED');
\r
52 require(AT_INCLUDE_PATH.'header.inc.php');
\r
54 $sql = "SELECT type_id, title FROM ".TABLE_PREFIX."groups_types WHERE course_id=$_SESSION[course_id] ORDER BY title";
\r
55 $result = mysql_query($sql, $db);
\r
57 <div class="input-form">
\r
58 <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="get" name="form">
\r
59 <fieldset class="group_form" margin:auto;"><legend class="group_form"><?php echo _AT('groups'); ?></legend>
\r
60 <table class="data" summary="" rules="cols" style="width: 80%">
\r
64 <input type="submit" name="edit" value="<?php echo _AT('edit'); ?>" />
\r
65 <input type="submit" name="members" value="<?php echo _AT('members'); ?>" />
\r
66 <input type="submit" name="delete" value="<?php echo _AT('delete'); ?>" />
\r
71 <?php if ($row = mysql_fetch_assoc($result)): ?>
\r
75 $sql = "SELECT group_id, title FROM ".TABLE_PREFIX."groups WHERE type_id=$row[type_id] ORDER BY title";
\r
76 $group_result = mysql_query($sql, $db);
\r
77 $num_groups = mysql_num_rows($group_result);
\r
79 <tr onmousedown="document.form['g<?php echo $row['type_id']; ?>'].checked = true; rowselect(this);" id="r_<?php echo $row['type_id']; ?>">
\r
81 <input type="radio" id="g<?php echo $row['type_id']; ?>" name="id" value="<?php echo $row['type_id']; ?>" />
\r
82 <label for="g<?php echo $row['type_id']; ?>"><?php echo AT_print($row['title'], 'groups.title'); ?></label> (<?php echo $num_groups.' '._AT('groups'); ?>)</td>
\r
85 <?php if ($num_groups) : ?>
\r
86 <?php while ($group_row = mysql_fetch_assoc($group_result)): ?>
\r
88 $sql = "SELECT COUNT(*) AS cnt FROM ".TABLE_PREFIX."groups_members WHERE group_id=$group_row[group_id]";
\r
89 $group_cnt_result = mysql_query($sql, $db);
\r
90 $group_cnt = mysql_fetch_assoc($group_cnt_result);
\r
92 <tr onmousedown="document.form['g<?php echo $row['type_id'].'_'.$group_row['group_id']; ?>'].checked = true; rowselect(this);" id="r_<?php echo $row['type_id'].'_'.$group_row['group_id']; ?>">
\r
93 <td class="indent"><input type="radio" id="g<?php echo $row['type_id'].'_'.$group_row['group_id']; ?>" name="id" value="<?php echo $row['type_id'].'_'.$group_row['group_id']; ?>" /> <label for="g<?php echo $row['type_id'].'_'.$group_row['group_id']; ?>"><?php echo AT_print($group_row['title'], 'groups.title'); ?></label> (<?php echo $group_cnt['cnt'].' '._AT('members'); ?>)</td>
\r
98 <td class="indent"><strong><?php echo _AT('none_found'); ?></strong></td>
\r
102 <?php } while ($row = mysql_fetch_assoc($result)); ?>
\r
105 <td><strong><?php echo _AT('none_found'); ?></strong></td>
\r
113 <?php require(AT_INCLUDE_PATH.'footer.inc.php'); ?>