2 /************************************************************************/
4 /************************************************************************/
5 /* Copyright (c) 2002-2010 */
6 /* Inclusive Design Institute */
8 /* This program is free software. You can redistribute it and/or */
9 /* modify it under the terms of the GNU General Public License */
10 /* as published by the Free Software Foundation. */
11 /************************************************************************/
13 if (!defined('AT_INCLUDE_PATH')) { exit; }
17 //if user wants to cancel action
18 if (isset($_POST['cancel'])) {
19 $msg->addFeedback('CANCELLED');
20 header('Location: index.php?course_id='.$course_id);
22 } else if (isset($_POST['submit'])) {
25 $mid = $_POST['dmid'];
26 $privs = $_POST['privs'];
27 $role = $_POST['role'];
29 //loop through selected users to perform update
32 change_privs(intval($mid[$i]), $privs[$i]);
36 $msg->addFeedback('PRIVS_CHANGED');
37 header('Location: index.php?tab=1'.SEP.'course_id='.$course_id);
41 require(AT_INCLUDE_PATH.'header.inc.php');
45 <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
46 <input type="hidden" name="course_id" value="<?php echo $course_id; ?>"/>
47 <div class="input-form">
49 //Store id's into a hidden element for use by functions
51 while ($_GET['mid'.$j]) {
52 echo '<input type="hidden" name="dmid[]" value="'.$_GET['mid'.$j].'" />';
56 //loop through all the students
57 for ($k = 0; $k < $j; $k++) {
58 $mem_id = intval($_GET['mid'.$k]);
60 //NO!!! extra check to ensure that user doesnt send in instructor for change privs
61 $sql = "SELECT CE.privileges, M.login FROM ".TABLE_PREFIX."course_enrollment CE INNER JOIN ".TABLE_PREFIX."members M USING (member_id) WHERE M.member_id=$mem_id AND CE.course_id=$course_id AND CE.approved='y'";
63 $result = mysql_query($sql, $db);
64 $student_row = mysql_fetch_assoc($result);
67 <h3><?php echo $student_row['login']; ?></h3>
71 <?php echo _AT('privileges'); ?><br />
72 <table width="100%" border="0" cellspacing="5" cellpadding="0" summary="">
76 $student_row['privileges'] = intval($student_row['privileges']);
77 $module_list = $moduleFactory->getModules(AT_MODULE_STATUS_ENABLED, 0, TRUE);
78 $keys = array_keys($module_list);
79 foreach ($keys as $module_name) {
80 $module =& $module_list[$module_name];
81 if (!($module->getPrivilege() > 1)) {
85 echo '<td><label><input type="checkbox" name="privs['.$k.'][]" value="'.$module->getPrivilege().'" ';
87 if (query_bit($student_row['privileges'], $module->getPrivilege())) {
88 echo 'checked="checked"';
91 echo ' />'.$module->getName().'</label></td>';
93 if (!($count % $num_cols)) {
97 if ($count % $num_cols) {
98 echo '<td colspan="'.($num_cols-($count % $num_cols)).'"> </td>';
100 echo '<td colspan="'.$num_cols.'"> </td>';
109 <div class="row buttons">
110 <input type="submit" name="submit" value="<?php echo _AT('save'); ?>" accesskey="s" />
111 <input type="submit" name="cancel" value="<?php echo _AT('cancel'); ?>" />
119 * Updates the Role & Priviliges of users
121 * @param int $member The member_id of the user whose values are to be updated
122 * @param int $privs value of the privileges of the user
123 * @author Joel Kronenberg
125 function change_privs ($member, $privs) {
126 global $db, $course_id;
128 //calculate privileges
130 if (!(empty($privs))) {
131 foreach ($privs as $priv) {
132 $privilege += intval($priv);
137 * if we're making a student a GROUP TA then we have to remove them
138 * from all the groups they may belong to.
140 if (query_bit($privilege, AT_PRIV_GROUPS)) {
141 $group_list = implode(',', $_SESSION['groups']);
143 $sql = "DELETE FROM ".TABLE_PREFIX."groups_members WHERE group_id IN ($group_list) AND member_id=$member";
144 $result = mysql_query($sql,$db);
148 $sql = "UPDATE ".TABLE_PREFIX."course_enrollment SET `privileges`=$privilege WHERE member_id=$member AND course_id=$course_id AND `approved`='y'";
149 $result = mysql_query($sql,$db);
152 //print error or confirm change
154 $msg->printErrors('DB_NOT_UPDATED');
159 require(AT_INCLUDE_PATH.'footer.inc.php'); ?>