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