MDL-9265:
[moodle-linuxchix.git] / course / groups-edit.html
blob6d43f92e534e9c36104ace37b3d7296ba2c23df7
1 <script type="text/javascript">
2 //<![CDATA[
3 <?php
4 $roleoptions = array(0 => get_string('all'));
5 $roles = get_all_roles();
6 foreach ($roles as $rolex) {
7 $roleoptions[$rolex->id] = $rolex->name;
10 foreach ($listmembers as $groupid => $listmember) {
11 echo "group$groupid = new Object();\n";
12 $useridstring = "group$groupid.userid = new Array(";
13 $usernamestring = "group$groupid.username = new Array(";
14 $max = count($listmember);
15 $count = 0;
16 foreach ($listmember as $userid => $username) {
17 $count++;
18 $useridstring .= "\"$userid\"";
19 $usernamestring .= '"'.addslashes($username).'"';
20 if ($count < $max) {
21 $useridstring .= ', ';
22 $usernamestring .= ', ';
25 $useridstring .= ");\n";
26 $usernamestring .= ");\n";
28 echo $useridstring;
29 echo $usernamestring;
33 function updateGroup() {
34 document.getElementById("form1").groupid.value = document.getElementById("form2").groups.value;
35 document.getElementById("form3").groupid.value = document.getElementById("form2").groups.value;
39 function updateMembers(selectgroup) {
40 eval('group=group'+selectgroup.value);
42 username = group.username;
43 userid = group.userid;
45 document.getElementById("form3")['members[]'].length = username.length;
47 for (i=0;i<username.length;i++) {
48 document.getElementById("form3")['members[]'].options[i].value = userid[i];
49 document.getElementById("form3")['members[]'].options[i].text = username[i];
52 updateGroup();
55 function userWindow(selectuser) {
56 num = 0;
57 for (var i=0; i<selectuser.options.length; i++) {
58 if (selectuser.options[i].selected) {
59 num++;
60 user = selectuser.options[i].value;
61 openpopup('/user/view.php?id='+user+'&course=<?php echo $courseid ?>','userinfo'+num,'','');
64 return false;
67 function groupWindow(selectgroup) {
68 num = 0;
69 for (var i=0; i<selectgroup.options.length; i++) {
70 if (selectgroup.options[i].selected) {
71 num++;
72 group = selectgroup.options[i].value;
73 openpopup('/course/group.php?id=<?php echo $courseid ?>&group='+group,'groupinfo'+num,'menubar=0,directory=0,location=0,scrollbars,resizable,width=600,height=480','');
76 return false;
80 //]]>
81 </script>
83 <form id="rolesform1" action="groups.php" method="get">
84 <input type="hidden" name="id" value="<?php echo $courseid ?>" />
85 <div align="center"><?php echo get_string('currentrole', 'role') ?>:
86 <?php choose_from_menu ($roleoptions, 'roleid', $roleid, '', 'document.getElementById(\'rolesform1\').submit()') ?>
87 </div></form>
89 <table cellspacing="0" cellpadding="10" align="center" class="generaltable generalbox">
90 <tr align="center" valign="top">
91 <td class="generalboxcontent">
92 <label for="nonmembers"><?php p($strmemberincourse) ?></label>
93 <form id="form1" method="post" action="groups.php">
94 <input type="hidden" name="id" value="<?php p($course->id) ?>" />
95 <input type="hidden" name="groupid" value="<?php p($selectedgroup) ?>" />
96 <input type="hidden" name="sesskey" value="<?php p($sesskey) ?>" />
97 <input type="hidden" name="roleid" value="<?php p($roleid) ?>" />
99 <select name="nonmembers[]" size="15" id="nonmembers" multiple="multiple">
100 <?php
101 if (!empty($nonmembers)) {
102 foreach ($nonmembers as $id => $nonmembername) {
103 if (!is_array($ugroups = user_group($course->id, $id))) {
104 $numgroups = 0;
106 else {
107 $numgroups = count($ugroups);
109 echo "<option value=\"$id\" title=\"$nonmembername is in $numgroups groups\">$nonmembername ($numgroups)</option>\n";
113 </select>
114 <br />
115 <input type="submit" name="nonmembersadd" value="<?php p($strgroupaddusers) ?> -&gt;"
116 onclick="updateGroup()" />
117 <br />
118 <!--
119 <input type="submit" name="nonmembersrandom" value="<?php p($strgrouprandomassign) ?> -&gt;" />
120 <br /> -->
121 <input type="submit" name="nonmembersinfo" value="<?php p($strgroupinfopeople) ?>"
122 onclick="return userWindow(document.getElementById('form1')['nonmembers[]']);" />
123 </form>
124 </td>
125 <td class="generalboxcontent">
126 <label for="groups"><?php p($strgroups) ?></label>
127 <form id="form2" method="post" action="groups.php">
128 <input type="hidden" name="id" value="<?php p($course->id) ?>" />
129 <input type="hidden" name="sesskey" value="<?php p($sesskey) ?>" />
130 <input type="hidden" name="roleid" value="<?php p($roleid) ?>" />
131 <select name="groups" size="15" id="groups" onchange="updateMembers(this)">
132 <?php
133 if (!empty($listgroups)) {
134 foreach ($listgroups as $id => $listgroup) {
135 $selected = '';
136 if ($id == $selectedgroup) {
137 $selected = 'selected="selected"';
139 echo "<option $selected value=\"$id\">$listgroup</option>";
143 </select>
144 <br />
145 <input type="submit" name="groupsinfo" value="<?php p($strgroupinfoedit) ?>"
146 onclick="return groupWindow(document.getElementById('form2').groups);" />
147 <br />
148 <input type="submit" name="groupsremove" value="<?php p($strgroupremove) ?>" />
149 <br />
150 <label for="groupadd" class="accesshide"><?php p($strgroupadd) ?></label>
151 <input name="newgroupname" id="groupadd" type="text" size="10" />
152 <input type="submit" name="groupsadd" value="<?php p($strgroupadd) ?>" />
153 </form>
154 </td>
157 <td class="generalboxcontent">
158 <label for="members"><?php p($strgroupmembersselected) ?></label>
159 <form id="form3" method="post" action="groups.php">
160 <input type="hidden" name="id" value="<?php p($course->id) ?>" />
161 <input type="hidden" name="groupid" value="<?php p($selectedgroup) ?>" />
162 <input type="hidden" name="sesskey" value="<?php p($sesskey) ?>" />
163 <input type="hidden" name="roleid" value="<?php p($roleid) ?>" />
164 <select name="members[]" size="15" id="members" multiple="multiple">
165 <?php
166 if (!empty($members)) {
167 foreach ($members as $id => $membername) {
168 echo "<option value=\"$id\">$membername</option>";
172 </select>
173 <br />
174 <input type="submit" name="membersinfo" value="<?php p($strgroupinfomembers) ?>"
175 onclick="return userWindow(document.getElementById('form3')['members[]']);" />
176 <br />
177 <input type="submit" name="membersremove" value="<?php p($strgroupremovemembers) ?>"
178 onclick="updateGroup()" />
179 </form>
180 </td>
181 </tr>
182 </table>