Annotation of loncom/interface/loncoursegroups.pm, revision 1.132
1.24 www 1: # The LearningOnline Network with CAPA
2: #
1.132 ! raeburn 3: # $Id: loncoursegroups.pm,v 1.131 2020/09/08 23:54:40 raeburn Exp $
1.1 raeburn 4: #
5: # Copyright Michigan State University Board of Trustees
6: #
7: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
8: #
9: # LON-CAPA is free software; you can redistribute it and/or modify
10: # it under the terms of the GNU General Public License as published by
11: # the Free Software Foundation; either version 2 of the License, or
12: # (at your option) any later version.
13: #
14: # LON-CAPA is distributed in the hope that it will be useful,
15: # but WITHOUT ANY WARRANTY; without even the implied warranty of
16: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17: # GNU General Public License for more details.
18: #
19: # You should have received a copy of the GNU General Public License
20: # along with LON-CAPA; if not, write to the Free Software
21: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22: #
23: # /home/httpd/html/adm/gpl.txt
24: #
25: # http://www.lon-capa.org/
26: #
27:
28: package Apache::loncoursegroups;
29:
30: use strict;
31: use Apache::lonnet;
1.63 albertel 32: use Apache::loncommon();
33: use Apache::lonhtmlcommon();
1.121 raeburn 34: use Apache::lonhtmlgateway;
1.1 raeburn 35: use Apache::lonlocal;
1.63 albertel 36: use Apache::lonnavmaps();
37: use Apache::longroup();
38: use Apache::portfolio();
1.132 ! raeburn 39: use Apache::lonuserutils();
1.1 raeburn 40: use Apache::Constants qw(:common :http);
1.130 raeburn 41: use HTML::Entities;
1.63 albertel 42: use LONCAPA::map();
1.24 www 43: use lib '/home/httpd/lib/perl/';
44: use LONCAPA;
1.1 raeburn 45:
46: sub handler {
47: my ($r) = @_;
1.3 raeburn 48:
1.1 raeburn 49: &Apache::loncommon::content_type($r,'text/html');
50: $r->send_http_header;
1.15 albertel 51:
1.1 raeburn 52: if ($r->header_only) {
53: return OK;
54: }
55:
56: # Needs to be in a course
57: if (! ($env{'request.course.fn'})) {
58: # Not in a course
59: $env{'user.error.msg'}=
1.104 raeburn 60: "/adm/coursegroups:mdg:0:0:Cannot edit or view course/community groups";
1.1 raeburn 61: return HTTP_NOT_ACCEPTABLE;
62: }
63:
1.3 raeburn 64: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
1.5 raeburn 65: ['action','refpage','state','groupname','branch']);
1.3 raeburn 66: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
67: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
68:
1.1 raeburn 69: my $view_permission =
1.52 raeburn 70: &Apache::lonnet::allowed('vcg',$env{'request.course.id'}.($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''));
1.1 raeburn 71: my $manage_permission =
1.52 raeburn 72: &Apache::lonnet::allowed('mdg',$env{'request.course.id'}.($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''));
1.3 raeburn 73: &Apache::lonhtmlcommon::clear_breadcrumbs();
74:
1.29 raeburn 75: my $gpterm = &Apache::loncommon::group_term();
76: my $ucgpterm = $gpterm;
77: $ucgpterm =~ s/^(\w)/uc($1)/e;
78: my $crstype = &Apache::loncommon::course_type();
79:
1.3 raeburn 80: my %functions = (
1.92 schafran 81: email => 'Send Messages',
1.81 schafran 82: discussion => 'Discussion Boards',
1.94 hauer 83: chat => 'Chat Room',
1.96 weissno 84: files => 'Group Portfolio',
1.81 schafran 85: roster => 'Membership Roster',
1.29 raeburn 86: homepage => $ucgpterm.' home page',
1.3 raeburn 87: );
88:
89: my %idx = ();
90: $idx{id} = &Apache::loncoursedata::CL_ID();
91: $idx{fullname} = &Apache::loncoursedata::CL_FULLNAME();
92: $idx{udom} = &Apache::loncoursedata::CL_SDOM();
93: $idx{uname} = &Apache::loncoursedata::CL_SNAME();
1.31 albertel 94: $idx{section} = &Apache::loncoursedata::CL_SECTION();
1.3 raeburn 95:
96: my $action = $env{'form.action'};
1.21 raeburn 97: my $state = $env{'form.state'};
1.65 raeburn 98: if ((!defined($action)) || ($action eq 'view') || ($action eq 'modify') || ($action eq 'delete') || ($action eq 'reenable')) {
1.21 raeburn 99: if (!defined($state)) {
100: $state = 'view';
101: }
102: }
1.64 raeburn 103: if ($action eq 'create' || $action eq 'modify' || $action eq 'view' ||
1.65 raeburn 104: $action eq 'delete' || $action eq 'reenable') {
1.3 raeburn 105: if ($view_permission || $manage_permission) {
1.53 raeburn 106: if ($state eq 'view') {
107: &print_main_menu($r,$cdom,$cnum,\%functions,\%idx,
108: $view_permission,$manage_permission,
109: $action,$state,$gpterm,$ucgpterm,$crstype);
110: } else {
111: &group_administration($r,$action,$state,$cdom,$cnum,
112: \%functions,\%idx,$view_permission,
113: $manage_permission,$gpterm,$ucgpterm,
114: $crstype);
115: }
1.3 raeburn 116: } else {
1.79 bisitz 117: $r->print('<div class="LC_warning">'
118: .&mt('You do not have '.$gpterm.' administration '
119: .'privileges in this '.lc($crstype).'.')
120: .'</div>');
1.3 raeburn 121: }
122: } else {
1.39 albertel 123: &print_main_menu($r,$cdom,$cnum,\%functions,\%idx,$view_permission,
124: $manage_permission,$action,$state,$gpterm,$ucgpterm,
125: $crstype);
1.3 raeburn 126: }
127: return OK;
128: }
129:
130: sub print_main_menu {
1.39 albertel 131: my ($r,$cdom,$cnum,$functions,$idx,$view_permission,$manage_permission,
132: $action,$state,$gpterm,$ucgpterm,$crstype) = @_;
1.21 raeburn 133: my $jscript = qq|
134: function changeSort(caller) {
135: document.$state.sortby.value = caller;
136: document.$state.submit();
1.60 raeburn 137: }
138: function openGroupRoster(group,status) {
139: var url = '/adm/grouproster?';
1.130 raeburn 140: url += 'group='+group+'&status='+status+'&ref=popup';
1.112 raeburn 141: var title = 'Group_Membership';
1.60 raeburn 142: var options = 'scrollbars=1,resizable=1,menubar=0';
143: options += ',width=700,height=600';
144: rosterbrowser = open(url,title,options,'1');
145: rosterbrowser.focus();
1.21 raeburn 146: }\n|;
1.95 schafran 147: $r->print(&header('My Space',$jscript,$action,$state));
1.71 raeburn 148: if ($env{'form.refpage'} eq 'cusr') {
1.53 raeburn 149: &Apache::lonhtmlcommon::add_breadcrumb
1.71 raeburn 150: ({href=>"/adm/createuser",
151: text=>"User Management"});
1.53 raeburn 152: }
1.3 raeburn 153: &Apache::lonhtmlcommon::add_breadcrumb
154: ({href=>"/adm/coursegroups",
1.53 raeburn 155: text=>"Groups"});
1.72 raeburn 156: my $helpitem;
157: if ($manage_permission) {
158: $helpitem = 'Creating_Groups';
159: }
160: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Groups',$helpitem));
1.39 albertel 161: &display_groups($r,$cdom,$cnum,$functions,$idx,$view_permission,
162: $manage_permission,$action,$state,$gpterm,$ucgpterm,
163: $crstype);
1.3 raeburn 164: $r->print(&footer());
165: return;
166: }
167:
168: sub display_groups {
1.39 albertel 169: my ($r,$cdom,$cnum,$functions,$idx,$view_permission,
170: $manage_permission,$action,$state,$gpterm,$ucgpterm,$crstype) = @_;
1.3 raeburn 171: my %curr_groups = ();
172: my %grp_info = ();
1.5 raeburn 173: my %actionlinks = (
1.130 raeburn 174: modify => '/adm/coursegroups?action=modify&refpage='.
175: $env{'form.refpage'}.'&state=pick_task&groupname=',
176: view => '',
177: delete => '/adm/coursegroups?action=delete&refpage='.
178: $env{'form.refpage'}.'&state=verify&groupname=',
179: reenable => '/adm/coursegroups?action=reenable&refpage='.
180: $env{'form.refpage'}.'&state=verify&groupname=',
1.5 raeburn 181: );
1.6 raeburn 182: my %lt = &Apache::lonlocal::texthash(
1.5 raeburn 183: modify => 'Modify',
1.6 raeburn 184: view => 'View',
1.5 raeburn 185: delete => 'Delete',
1.65 raeburn 186: reenable => 'Re-enable',
1.6 raeburn 187: act => 'Action',
1.53 raeburn 188: gname => 'Group Name',
189: desc => 'Group Title',
1.6 raeburn 190: crea => 'Creator',
191: crtd => 'Created',
192: last => 'Last Modified',
1.53 raeburn 193: func => 'Collaborative Tools',
1.122 raeburn 194: quot => 'Quota (MB)',
1.6 raeburn 195: memb => 'Members',
196: file => 'Files',
197: dibd => 'Discussion Boards',
1.29 raeburn 198: dius => 'Disk Use (%)',
1.53 raeburn 199: nogr => 'No groups exist.',
200: crng => 'Create a new group',
1.71 raeburn 201: redg => 'Re-enable a deleted group',
1.7 raeburn 202: alth => 'Although your current role has privileges'.
1.62 banghart 203: ' to view any existing groups in this '.
204: lc($crstype).', you do not have privileges '.
1.53 raeburn 205: 'to create new groups.',
1.7 raeburn 206: );
1.3 raeburn 207: if ($view_permission) {
1.5 raeburn 208: if (!defined($action)) {
209: $action = 'view';
210: }
1.71 raeburn 211: my ($status,$reenable_link);
1.65 raeburn 212: if ($action eq 'reenable') {
213: $status = 'deleted_groups';
1.71 raeburn 214: } else {
215: if ($manage_permission) {
216: my %deleted_groups =
217: &Apache::longroup::coursegroups($cdom,$cnum,undef,'deleted_groups');
218: if (keys(%deleted_groups) > 0) {
219: $reenable_link = ' <a href="/adm/coursegroups?action=reenable&refpage='.$env{'form.refpage'}.'">'.$lt{'redg'}.'</a>';
220: }
221: }
1.65 raeburn 222: }
223: my %curr_groups = &Apache::longroup::coursegroups($cdom,$cnum,undef,
224: $status);
1.71 raeburn 225:
1.15 albertel 226: if (%curr_groups) {
1.110 raeburn 227: my $navmap=Apache::lonnavmaps::navmap->new();
228: if (!defined($navmap)) {
229: $r->print('<div class="LC_error">'.
230: &mt('An error occurred retrieving information about resources in the course.').'<br />'.
1.130 raeburn 231: &mt('It is recommended that you [_1]re-initialize the course[_2] and then return to this page.','<a href="/adm/roles?selectrole=1&newrole='.$env{'request.role'}.'&orgurl=%2fadm%2fcoursegroups">','</a>').
1.110 raeburn 232: '</div>');
233: return;
234: }
1.29 raeburn 235: if ($manage_permission) {
1.71 raeburn 236: if ($action ne 'reenable') {
237: $r->print('<br /><a href="/adm/coursegroups?action=create&refpage='.$env{'form.refpage'}.'">'.$lt{'crng'}.'</a>');
238: }
239: if ($reenable_link) {
240: $r->print($reenable_link);
1.53 raeburn 241: }
1.29 raeburn 242: }
1.7 raeburn 243: $r->print('<br /><br />');
1.39 albertel 244: $r->print(&Apache::loncommon::start_data_table().
245: &Apache::loncommon::start_data_table_header_row());
246:
1.4 raeburn 247: $r->print(<<"END");
1.39 albertel 248: <th>$lt{'act'}</th>
249: <th><a href="javascript:changeSort('groupname')">$lt{'gname'}</a></th>
250: <th><a href="javascript:changeSort('description')">$lt{'desc'}</a></th>
251: <th><a href="javascript:changeSort('creator')">$lt{'crea'}</a></th>
252: <th><a href="javascript:changeSort('creation')">$lt{'crtd'}</a></th>
253: <th><a href="javascript:changeSort('modified')">$lt{'last'}</a></th>
1.130 raeburn 254: <th>$lt{'func'}</th>
1.39 albertel 255: <th><a href="javascript:changeSort('quota')">$lt{'quot'}</a></th>
256: <th><a href="javascript:changeSort('totalmembers')">$lt{'memb'}</a></th>
257: <th><a href="javascript:changeSort('totalfiles')">$lt{'file'}</a></th>
258: <th><a href="javascript:changeSort('boards')">$lt{'dibd'}</a></th>
259: <th><a href="javascript:changeSort('diskuse')">$lt{'dius'}</a></th>
1.3 raeburn 260: END
1.39 albertel 261: $r->print(&Apache::loncommon::end_data_table_header_row());
1.4 raeburn 262: my %Sortby = ();
263: foreach my $group (sort(keys(%curr_groups))) {
264: %{$grp_info{$group}} =
1.17 raeburn 265: &Apache::longroup::get_group_settings(
1.3 raeburn 266: $curr_groups{$group});
1.5 raeburn 267: my $members_result = &group_members($cdom,$cnum,$group,
268: \%grp_info);
1.29 raeburn 269: my $port_path = '/userfiles/groups/'.$group.'/portfolio';
270: my $totaldirs = 0;
271: my $totalfiles = 0;
1.74 raeburn 272: &group_files($group,$port_path,\$totalfiles,\$totaldirs);
1.29 raeburn 273: $grp_info{$group}{'totalfiles'} = $totalfiles;
274: $grp_info{$group}{'totaldirs'} = $totaldirs;
1.74 raeburn 275: my $getpropath = 1;
276: my $diskuse = &Apache::lonnet::diskusage($cdom,$cnum,$port_path, $getpropath);
1.29 raeburn 277: if ($grp_info{$group}{'quota'} > 0) {
278: my $pct_use = 0.1 * $diskuse/$grp_info{$group}{'quota'};
279: $grp_info{$group}{'diskuse'} = sprintf("%.0f",$pct_use);
280: } else {
281: $grp_info{$group}{'diskuse'} = 'N/A';
1.33 raeburn 282: }
283: my ($groupboards,$boardshash)=&Apache::longroup::get_group_bbinfo(
284: $cdom,$cnum,$group);
285: $grp_info{$group}{'boards'} = scalar(@{$groupboards});
1.4 raeburn 286: if ($env{'form.sortby'} eq 'groupname') {
287: push(@{$Sortby{$group}},$group);
288: } elsif ($env{'form.sortby'} eq 'description') {
1.29 raeburn 289: push(@{$Sortby{$grp_info{$group}{'description'}}},$group);
1.4 raeburn 290: } elsif ($env{'form.sortby'} eq 'creator') {
291: push(@{$Sortby{$grp_info{$group}{'creator'}}},$group);
292: } elsif ($env{'form.sortby'} eq 'creation') {
293: push(@{$Sortby{$grp_info{$group}{'creation'}}},$group);
294: } elsif ($env{'form.sortby'} eq 'modified') {
295: push(@{$Sortby{$grp_info{$group}{'modified'}}},$group);
296: } elsif ($env{'form.sortby'} eq 'quota') {
297: push(@{$Sortby{$grp_info{$group}{'quota'}}},$group);
298: } elsif ($env{'form.sortby'} eq 'totalmembers') {
299: push(@{$Sortby{$grp_info{$group}{'totalmembers'}}},
1.3 raeburn 300: $group);
1.4 raeburn 301: } elsif ($env{'form.sortby'} eq 'totalfiles') {
1.5 raeburn 302: push(@{$Sortby{$grp_info{$group}{'totalfiles'}}},$group);
1.4 raeburn 303: } elsif ($env{'form.sortby'} eq 'boards') {
304: push(@{$Sortby{$grp_info{$group}{'boards'}}},$group);
305: } elsif ($env{'form.sortby'} eq 'diskuse') {
306: push(@{$Sortby{$grp_info{$group}{'diskuse'}}},$group);
307: } else {
308: push(@{$Sortby{$group}},$group);
309: }
310: }
311: foreach my $key (sort(keys(%Sortby))) {
312: foreach my $group (@{$Sortby{$key}}) {
313: my $description =
1.39 albertel 314: &unescape($grp_info{$group}{'description'});
1.4 raeburn 315: my $creator = $grp_info{$group}{'creator'};
316: my $creation = $grp_info{$group}{'creation'};
317: my $modified = $grp_info{$group}{'modified'};
318: my $quota = $grp_info{$group}{'quota'};
319: my $totalmembers = $grp_info{$group}{'totalmembers'};
320: my $totalfiles = $grp_info{$group}{'totalfiles'};
1.29 raeburn 321: my $totaldirs = $grp_info{$group}{'totaldirs'};
1.4 raeburn 322: my $boards = $grp_info{$group}{'boards'};
323: my $diskuse = $grp_info{$group}{'diskuse'};
324: my $functionality;
1.5 raeburn 325: foreach my $tool (sort(keys(%{$functions}))) {
1.6 raeburn 326: if ($grp_info{$group}{functions}{$tool} eq 'on') {
1.4 raeburn 327: $functionality .= ' '.$tool;
1.3 raeburn 328: }
329: }
1.4 raeburn 330: if (!$functionality) {
1.6 raeburn 331: $functionality = &mt('None available');
1.4 raeburn 332: }
1.128 raeburn 333: my $link;
1.65 raeburn 334: if ($action eq 'modify' || $action eq 'delete' ||
335: $action eq 'reenable') {
1.130 raeburn 336: $link = '<a href="'.&HTML::Entities::encode($actionlinks{$action}.$group,'<>&"').
337: '">'.$lt{$action}.'</a>';
1.5 raeburn 338: } else {
1.128 raeburn 339: $link =
1.130 raeburn 340: &Apache::longroup::get_group_link($cdom,$cnum,$group,$navmap,
341: $view_permission);
1.128 raeburn 342: if ($link) {
1.130 raeburn 343: $link = '<a href="'.$link;
1.128 raeburn 344: $link .= (($link=~/\?/)?'&':'?').'ref=grouplist';
345: if (exists($env{'form.refpage'})) {
346: $link .= '&refpage='.$env{'form.refpage'};
347: }
348: $link .= '">'.$lt{$action}.'</a>';
1.130 raeburn 349: }
1.5 raeburn 350: }
1.21 raeburn 351: if ($action eq 'view') {
1.71 raeburn 352: if ($manage_permission) {
1.130 raeburn 353: $link .= ' <a href="'.
354: &HTML::Entities::encode($actionlinks{'modify'}.$group,'<>&"').
355: '">'.$lt{'modify'}.'</a> <a href="'.
356: &HTML::Entities::encode($actionlinks{'delete'}.$group,'<>&"').
357: '">'.$lt{'delete'}.'</a>';
1.21 raeburn 358: }
359: }
1.39 albertel 360: $r->print(&Apache::loncommon::start_data_table_row('LC_data_table_dense').
361: '<td>'.$link.'</td>'.
362: '<td>'.$group.'</td>'.
363: '<td>'.$description.'</td>'.
364: '<td>'.$creator.'</td>'.
365: '<td>'. &Apache::lonnavmaps::timeToHumanString($creation).'</td>'.
366: '<td>'. &Apache::lonnavmaps::timeToHumanString($modified).'</td>'.
367: '<td>'.$functionality.'</td>'.
368: '<td align="right">'.$quota.'</td>'.
369: '<td align="right">'.$totalmembers.'</td>'.
1.79 bisitz 370: '<td align="right">'.
1.88 raeburn 371: '<span class="LC_nobreak">'.&mt('Files: [_1]',$totalfiles).'</span><br />'.
372: '<span class="LC_nobreak">'.&mt('Folders: [_1]',$totaldirs).'</span>'.
1.79 bisitz 373: '</td>'.
1.39 albertel 374: '<td align="right">'.$boards.'</td>'.
375: '<td align="right">'.$diskuse.'</td>'.
376: &Apache::loncommon::end_data_table_row());
1.3 raeburn 377: }
1.4 raeburn 378: }
1.39 albertel 379: $r->print(&Apache::loncommon::end_data_table());
1.21 raeburn 380: $r->print('<input type="hidden" name="refpage" '.
381: 'value="'.$env{'form.refpage'}.'" />');
382: if ($action eq 'view') {
383: if (!defined($state)) {
384: $state = 'view';
385: }
386: $r->print('<input type="hidden" name="state" value="'.
387: $state.'" />');
388: }
1.3 raeburn 389: } else {
1.7 raeburn 390: $r->print($lt{'nogr'});
391: if ($manage_permission) {
1.71 raeburn 392: $r->print('<br /><br /><a href="/adm/coursegroups?action=create&refpage='.$env{'form.refpage'}.'">'.$lt{'crng'}.'</a>');
393: if ($action ne 'reenable') {
394: if ($reenable_link) {
395: $r->print($reenable_link);
396: }
1.53 raeburn 397: }
1.7 raeburn 398: } else {
1.29 raeburn 399: $r->print('<br /><br />'.$lt{'alth'});
1.7 raeburn 400: }
1.3 raeburn 401: }
402: } else {
1.4 raeburn 403: my @coursegroups = split(/:/,$env{'request.course.groups'});
404: if (@coursegroups > 0) {
1.128 raeburn 405: my $numlinks = 0;
1.7 raeburn 406: $r->print('<br /><br />');
1.17 raeburn 407: my %curr_groups = &Apache::longroup::coursegroups($cdom,$cnum);
1.15 albertel 408: if (%curr_groups) {
1.110 raeburn 409: my $navmap=Apache::lonnavmaps::navmap->new();
410: if (!defined($navmap)) {
411: $r->print('<div class="LC_error">'.
412: &mt('An error occurred retrieving information about resources in the course.').'<br />'.
1.130 raeburn 413: &mt('It is recommended that you [_1]re-initialize the course[_2] and then return to this page.','<a href="/adm/roles?selectrole=1&newrole='.$env{'request.role'}.'&orgurl=%2fadm%2fcoursegroups">','</a>').
1.110 raeburn 414: '</div>');
415: return;
416: }
1.4 raeburn 417: foreach my $group (@coursegroups) {
1.17 raeburn 418: my %group_info = &Apache::longroup::get_group_settings(
1.5 raeburn 419: $curr_groups{$group});
1.24 www 420: my $description = &unescape(
1.5 raeburn 421: $group_info{description});
1.128 raeburn 422: my ($link,$hidden) =
1.130 raeburn 423: &Apache::longroup::get_group_link($cdom,$cnum,$group,$navmap,
424: $view_permission);
1.128 raeburn 425: if ($link) {
426: $link .= '&ref=grouplist';
427: $r->print('<span style="font-size: larger"><a href="'.$link.'">'.
428: $description.'</a></span><br /><br />');
429: $numlinks ++;
430: } elsif ($hidden) {
431: my $numtools = 0;
432: my $refarg = '&ref=grouplist';
433: my $output =
434: &Apache::longroup::display_group_links($r,$env{'form.grade_target'},$group,'view',
435: $refarg,\$numtools,$hidden,%group_info);
436: if ($numtools) {
437: $r->print('<span style="font-size: larger">'.$description.'</a></span>'.
438: '<br />'.$output.'<br /><br />');
439: $numlinks ++;
440: }
441: }
1.4 raeburn 442: }
443: }
1.128 raeburn 444: if (!$numlinks) {
445: $r->print(
446: '<p class="LC_info">'
447: .&mt('You do not currently have access to any '.$gpterm.'s'
448: .' in this '.lc($crstype).'.')
449: .'</p>'
450: );
451: }
1.4 raeburn 452: } else {
1.115 bisitz 453: $r->print(
454: '<p class="LC_info">'
455: .&mt('You are not currently a member of any active '.$gpterm.'s'
456: .' in this '.lc($crstype).'.')
457: .'</p>'
458: );
1.4 raeburn 459: }
1.3 raeburn 460: }
461: return;
462: }
463:
464: sub group_administration {
1.48 albertel 465: my ($r,$action,$state,$cdom,$cnum,$functions,$idx,$view_permission,
466: $manage_permission,$gpterm,$ucgpterm,$crstype) = @_;
1.3 raeburn 467: my %sectioncount = ();
468: my @tools = ();
469: my @types = ();
470: my @roles = ();
471: my @sections = ();
472: my %users = ();
473: my %userdata = ();
474: my @members = ();
475: my %usertools = ();
1.5 raeburn 476: my %stored = ();
477: my %memchg;
1.6 raeburn 478: my @member_changes = ('deletion','expire','activate','reenable',
1.5 raeburn 479: 'changefunc','changepriv');
1.29 raeburn 480: my ($groupname,$description,$startdate,$enddate,$granularity,$specificity,
1.37 raeburn 481: $quota,$validate_script);
1.5 raeburn 482:
483: if (defined($env{'form.groupname'})) {
484: $groupname = $env{'form.groupname'};
485: }
486:
487: if (($action eq 'create') && ($state eq '')) {
488: $state = 'pick_name';
489: }
490: if (($action eq 'create') ||
491: (($action eq 'modify') && ($state eq 'chgresult'))) {
492: ($startdate,$enddate) = &get_dates_from_form();
493: if (defined($env{'form.description'})) {
494: $description = $env{'form.description'};
495: }
496: if (defined($env{'form.tool'})) {
497: @tools=&Apache::loncommon::get_env_multiple('form.tool');
498: }
499: if (defined($env{'form.granularity'})) {
500: $granularity=$env{'form.granularity'};
501: }
502: if (defined($env{'form.specificity'})) {
503: $specificity=$env{'form.specificity'};
504: }
1.29 raeburn 505: if (defined($env{'form.quota'})) {
506: $quota=$env{'form.quota'};
507: }
1.5 raeburn 508: }
509: if (($action eq 'create') || (($action eq 'modify')
510: && (($state eq 'pick_privs') || ($state eq 'addresult')))) {
511: if (defined($env{'form.member'})) {
512: @members = &Apache::loncommon::get_env_multiple('form.member');
513: foreach my $user (@members) {
514: %{$usertools{$user}} = ();
515: }
516: }
517: }
1.3 raeburn 518:
1.5 raeburn 519: if ($action eq 'modify') {
1.3 raeburn 520: if ($state eq '') {
1.21 raeburn 521: if (defined($env{'form.groupname'})) {
522: $state = 'pick_task';
523: }
1.3 raeburn 524: } else {
1.65 raeburn 525: %stored = &retrieve_settings($cdom,$cnum,$groupname,$action);
1.5 raeburn 526: if (ref($stored{'types'}) eq 'ARRAY') {
527: @types = @{$stored{'types'}};
528: }
529: if (ref($stored{'roles'}) eq 'ARRAY') {
530: @roles = @{$stored{'roles'}};
531: }
532: if (ref($stored{'sectionpick'}) eq 'ARRAY') {
533: @sections = @{$stored{'sectionpick'}};
534: }
535: unless ($state eq 'chgresult') {
536: if (ref($stored{'tool'}) eq 'ARRAY') {
537: @tools = @{$stored{'tool'}};
1.3 raeburn 538: }
1.5 raeburn 539: $startdate = $stored{'startdate'};
540: $enddate = $stored{'enddate'};
541: $description = $stored{'description'};
542: $granularity = $stored{'granularity'};
543: $specificity = $stored{'specificity'};
1.29 raeburn 544: $quota = $stored{'quota'};
1.3 raeburn 545: }
546: }
547: }
548:
1.36 raeburn 549: my $toolprivs = &Apache::longroup::get_tool_privs($gpterm);
1.22 albertel 550:
1.36 raeburn 551: my $fixedprivs = &Apache::longroup::get_fixed_privs();
1.22 albertel 552:
553: my %elements =
554: (
555: create => {
556: pick_name => {
557: startdate_month => 'selectbox',
558: startdate_hour => 'selectbox',
559: enddate_month => 'selectbox',
560: enddate_hour => 'selectbox',
561: startdate_day => 'text',
562: startdate_year => 'text',
563: startdate_minute => 'text',
564: startdate_second => 'text',
565: enddate_day => 'text',
566: enddate_year => 'text',
567: enddate_minute => 'text',
568: enddate_second => 'text',
569: groupname => 'text',
570: description => 'text',
1.29 raeburn 571: quota => 'text',
1.22 albertel 572: tool => 'checkbox',
573: granularity => 'radio',
574: no_end_date => 'checkbox',
575: },
576: pick_members => {
577: member => 'checkbox',
578: defpriv => 'checkbox',
579: },
580: },
581: );
582:
583: $elements{'modify'} = {
584: change_settings => {
585: %{$elements{'create'}{'pick_name'}},
586: specificity => 'radio',
587: defpriv => 'checkbox',
588: autorole => 'checkbox',
589: autoadd => 'radio',
590: autodrop => 'radio',
591: },
592: add_members => {
593: types => 'selectbox',
594: roles => 'selectbox',
595: },
596: };
597:
1.5 raeburn 598: if (ref($stored{'autorole'}) eq 'ARRAY') {
599: foreach my $role (@{$stored{'autorole'}}) {
1.104 raeburn 600: unless (($role eq 'cc') || ($role eq 'co')) {
1.17 raeburn 601: $elements{'modify'}{'change_settings'}{'sec_'.$role} =
602: 'selectbox';
603: }
1.5 raeburn 604: }
605: }
606:
1.3 raeburn 607: if (($action eq 'create') && ($state eq 'pick_name')) {
1.5 raeburn 608: $elements{'create'}{'pick_name'}{'types'} = 'selectbox';
609: $elements{'create'}{'pick_name'}{'roles'} = 'selectbox';
610: }
611: if ((($action eq 'create') &&
612: (($state eq 'pick_name') || ($state eq 'pick_privs'))) ||
613: (($action eq 'modify') && (($state eq 'change_settings') ||
614: ($state eq 'add_members')))) {
1.16 albertel 615: %sectioncount = &Apache::loncommon::get_sections($cdom,$cnum);
1.53 raeburn 616: $elements{'create'}{'pick_name'}{'sectionpick'} = 'selectbox';
617: $elements{'modify'}{'change_mapping'}{'sectionpick'} = 'selectbox';
618: $elements{'modify'}{'add_members'}{'sectionpick'} = 'selectbox';
1.3 raeburn 619: }
1.5 raeburn 620:
1.12 raeburn 621: if (($action eq 'create') ||
622: ($action eq 'modify' && $state eq 'pick_members')) {
1.3 raeburn 623: if (defined($env{'form.types'})) {
624: @types=&Apache::loncommon::get_env_multiple('form.types');
625: }
626: if (defined($env{'form.roles'})) {
627: @roles=&Apache::loncommon::get_env_multiple('form.roles');
628: }
629: if (defined($env{'form.sectionpick'})) {
630: @sections=&Apache::loncommon::get_env_multiple('form.sectionpick');
631: }
1.5 raeburn 632: }
633:
1.6 raeburn 634: if (($state eq 'pick_members') || ($state eq 'pick_privs') || ($state eq 'change_privs')) {
1.78 raeburn 635: &build_members_list($cdom,$cnum,\@types,\@roles,\@sections,\%users,
1.6 raeburn 636: \%userdata);
637: }
638: if ($state eq 'pick_members') {
1.3 raeburn 639: if ((keys(%users) > 0) && (@tools > 0)) {
1.7 raeburn 640: if ($granularity eq 'Yes') {
641: $elements{$action}{'pick_members'}{'togglefunc'} = 'checkbox';
642: }
1.3 raeburn 643: foreach my $tool (@tools) {
1.5 raeburn 644: if ($granularity eq 'Yes') {
645: $elements{$action}{'pick_members'}{'user_'.$tool} = 'checkbox';
1.3 raeburn 646: }
647: }
1.5 raeburn 648: $elements{$action}{'pick_members'}{'specificity'} = 'radio';
1.3 raeburn 649: }
650: }
1.6 raeburn 651: if ($state eq 'change_members') {
652: my %membership = &Apache::lonnet::get_group_membership($cdom,$cnum,
653: $groupname);
654: my $now = time;
655: my $num_expire = 0;
656: my $num_activate = 0;
657: my $num_reenable = 0;
658: my $num_deletion = 0;
659: my $numusers = 0;
660: foreach my $key (sort(keys(%membership))) {
661: if ($key =~ /^\Q$groupname\E:([^:]+:[^:]+)$/) {
662: my $user = $1;
663: my($end,$start,@userprivs) = split(/:/,$membership{$key});
664: unless ($start == -1) {
665: $numusers ++;
666: $num_deletion ++;
667: if (($end > 0) && ($end < $now)) {
668: $num_reenable ++;
669: next;
670: } elsif (($start > $now)) {
1.52 raeburn 671: $num_activate ++;
1.6 raeburn 672: next;
673: } else {
674: $num_expire ++;
675: next;
676: }
677: next;
678: }
679: if ($num_reenable && $num_activate && $num_expire) {
680: last;
681: }
682: }
683: }
684: if ($num_deletion) {
685: $elements{$action}{'change_members'}{'deletion'} = 'checkbox';
686: }
687: if ($num_expire) {
688: $elements{$action}{'change_members'}{'expire'} = 'checkbox';
689: }
690: if ($num_activate) {
691: $elements{$action}{'change_members'}{'activate'} = 'checkbox';
692: }
693: if ($num_reenable) {
694: $elements{$action}{'change_members'}{'reenable'} = 'checkbox';
695: }
696: if ($numusers) {
1.7 raeburn 697: if ($granularity eq 'Yes') {
698: $elements{$action}{'change_members'}{'togglefunc'} = 'checkbox';
699: }
1.6 raeburn 700: foreach my $tool (@tools) {
701: if ($granularity eq 'Yes') {
702: $elements{$action}{'change_members'}{'user_'.$tool} = 'checkbox';
703: }
704: }
705: if ($specificity eq 'Yes') {
706: $elements{$action}{'change_members'}{'changepriv'} = 'checkbox';
707: }
708: }
709: }
1.3 raeburn 710:
1.5 raeburn 711: if (($state eq 'pick_privs') || ($state eq 'change_privs') ||
1.21 raeburn 712: (($specificity eq 'No') &&
713: ($state eq 'memresult' || $state eq 'result' || $state eq 'addresult'))) {
1.3 raeburn 714: foreach my $tool (@tools) {
715: my @values = &Apache::loncommon::get_env_multiple('form.user_'.$tool);
716: foreach my $user (@values) {
1.21 raeburn 717: if ($state eq 'pick_privs' || $state eq 'result'
718: || $state eq 'addresult') {
719: if (!grep(/^\Q$user\E$/,@members)) {
720: next;
721: }
722: }
1.3 raeburn 723: unless(exists($usertools{$user}{$tool})) {
724: $usertools{$user}{$tool} = 1;
725: }
726: }
727: }
1.6 raeburn 728: }
729:
730: if (($action eq 'modify') && (($state eq 'change_privs') || ($state eq 'memresult'))) {
731: foreach my $chg (@member_changes) {
732: if (defined($env{'form.'.$chg})) {
733: @{$memchg{$chg}} = &Apache::loncommon::get_env_multiple('form.'.$chg);
734: }
735: }
736:
737: if ($state eq 'change_privs') {
738: my %membership = &Apache::lonnet::get_group_membership($cdom,$cnum,
739: $groupname);
740: my $now = time;
741: foreach my $key (sort(keys(%membership))) {
742: if ($key =~ /^\Q$groupname\E:([^:]+:[^:]+)$/) {
743: my $user = $1;
744: my $changefunc = 0;
745: my ($end,$start,@userprivs) = split(/:/,$membership{$key});
746: unless ($start == -1) {
747: if (($end > 0) && ($end < $now)) {
748: unless (grep/^$user$/,$memchg{'reenable'}) {
749: next;
750: }
751: }
752: my @currtools = ();
753: if (@userprivs > 0) {
1.36 raeburn 754: foreach my $tool (sort(keys(%{$fixedprivs}))) {
755: foreach my $priv (keys(%{$$fixedprivs{$tool}})) {
1.6 raeburn 756: if (grep/^$priv$/,@userprivs) {
757: push(@currtools,$tool);
758: last;
759: }
760: }
761: }
1.3 raeburn 762: }
1.6 raeburn 763: foreach my $tool (@currtools) {
764: if (keys(%{$usertools{$user}}) > 0) {
765: if (!$usertools{$user}{$tool}) {
766: push(@{$memchg{'changefunc'}},$user);
767: $changefunc = 1;
768: last;
769: }
770: } else {
771: push(@{$memchg{'changefunc'}},$user);
772: $changefunc = 1;
773: }
774: }
775: if ($changefunc) {
776: next;
777: }
778: if (keys(%{$usertools{$user}}) > 0) {
779: foreach my $tool (keys(%{$usertools{$user}})) {
780: if (!grep/^$tool$/,@currtools) {
781: push(@{$memchg{'changefunc'}},$user);
782: $changefunc = 1;
783: last;
784: }
785: }
786: }
787: }
788: }
789: }
790: &check_changes(\@member_changes,\%memchg);
791: my %temptools;
792: foreach my $change (@member_changes) {
793: if (($change eq 'deletion') || ($change eq 'expire')) {
794: next;
795: }
796: foreach my $user (@{$memchg{$change}}) {
797: unless (exists($usertools{$user})) {
798: %{$usertools{$user}} = ();
799: }
800: %{$temptools{$user}} = %{$usertools{$user}};
801: }
802: }
803: %usertools = %temptools;
804: } elsif ($state eq 'memresult') {
805: foreach my $change (@member_changes) {
806: if ($change eq 'expire' || $change eq 'deletion') {
807: next;
808: }
809: if (ref($memchg{$change}) eq 'ARRAY') {
810: my @users = @{$memchg{$change}};
811: foreach my $user (@users) {
812: unless (exists($usertools{$user})) {
813: %{$usertools{$user}} = ();
814: }
815: }
816: }
817: }
818: }
819: }
820:
821: if ((($state eq 'pick_privs') || ($state eq 'change_privs'))
822: && ($specificity eq 'Yes')) {
823: foreach my $user (sort(keys(%usertools))) {
824: foreach my $tool (keys(%{$usertools{$user}})) {
1.36 raeburn 825: foreach my $priv (keys(%{$$toolprivs{$tool}})) {
826: unless (exists($$fixedprivs{$tool}{$priv})) {
1.6 raeburn 827: $elements{$action}{$state}{'userpriv_'.$priv} = 'checkbox';
1.3 raeburn 828: }
829: }
830: }
831: }
832: }
1.37 raeburn 833:
834: if (($action eq 'create' && $state eq 'pick_name') ||
835: ($action eq 'modify' && $state eq 'change_settings')) {
836: my ($crsquota,$freespace,$maxposs) = &get_quota_constraints($action,\%stored);
837: my $space_trim = '/^\s*|\s*\$/g,""';
838: my $float_check = '/^([0-9]*\.?[0-9]*)$/';
839: $validate_script = '
1.53 raeburn 840: var newquota = new String(document.'.$state.'.quota.value);
1.37 raeburn 841: newquota.replace('.$space_trim.');
842: if (newquota == "" ) {
843: document.'.$state.'.quota.value = 0;
1.53 raeburn 844: newquota = "0";
1.37 raeburn 845: }
1.53 raeburn 846: var maxposs = '.sprintf("%.2f",$maxposs).';
1.37 raeburn 847: if (newquota > maxposs) {
1.122 raeburn 848: alert("The group portfolio quota you entered for this group ("+newquota+" MB) exceeds the maximum possible ("+maxposs+" MB). Please enter a smaller number.");
1.37 raeburn 849: return;
850: }
851: var re_quota = '.$float_check.';
852: var check_quota = newquota.match(re_quota);
853: if (check_quota == null) {
854: alert("The quota you entered contains invalid characters, the quota should only include numbers, with or without a decimal point.");
855: return;
856: }
857: if (newquota == 0) {
858: var warn_zero = 0;
859: for (var i=0; i<document.'.$state.'.tool.length; i++) {
860: if (document.'.$state.'.tool[i].value == "files") {
861: if (document.'.$state.'.tool[i].checked) {
862: warn_zero = 1;
863: }
864: }
865: }
866: if (warn_zero == 1) {
1.125 bisitz 867: alert("You have indicated that the group portfolio should be enabled, but you have set the repository quota to 0 MB.\nThis will prevent any upload of files.\nPlease set a value or disable the repository feature.");
1.37 raeburn 868: return;
869: }
870: }
871: ';
872: }
1.5 raeburn 873: my $jscript = &Apache::loncommon::check_uncheck_jscript();
1.3 raeburn 874: $jscript .= qq|
875: function nextPage(formname,nextstate) {
876: formname.state.value= nextstate;
1.37 raeburn 877: $validate_script
1.3 raeburn 878: formname.submit();
879: }
880: function backPage(formname,prevstate) {
881: formname.state.value = prevstate;
882: formname.submit();
883: }
1.6 raeburn 884: function changeSort(caller) {
885: document.$state.state.value = '$state';
886: document.$state.sortby.value = caller;
887: document.$state.submit();
888: }
1.15 albertel 889:
1.3 raeburn 890: |;
891: $jscript .= &Apache::lonhtmlcommon::set_form_elements(
1.5 raeburn 892: \%{$elements{$action}{$state}},\%stored);
893: my $page = 0;
894: my %states = ();
895: my %branchstates = ();
896: @{$states{'create'}} = ('pick_name','pick_members','pick_privs','result');
1.53 raeburn 897: @{$states{'modify'}} = ('pick_task');
1.64 raeburn 898: @{$states{'delete'}} = ('verify','result');
1.65 raeburn 899: @{$states{'reenable'}} = ('verify','result');
1.5 raeburn 900: @{$branchstates{'noprivs'}} = ('result');
901: @{$branchstates{'settings'}} = ('change_settings','chgresult');
902: @{$branchstates{'members'}} = ('change_members','change_privs','memresult');
903: @{$branchstates{'adds'}} = ('add_members','pick_members','pick_privs',
904: 'addresult');
1.21 raeburn 905:
1.5 raeburn 906: if (defined($env{'form.branch'})) {
907: push (@{$states{$action}},@{$branchstates{$env{'form.branch'}}});
908: }
909:
1.65 raeburn 910: if (($action eq 'create') || ($action eq 'modify') || ($action eq 'delete') || ($action eq 'reenable')) {
1.5 raeburn 911: my $done = 0;
912: my $i=0;
913: while ($i<@{$states{$action}} && !$done) {
914: if ($states{$action}[$i] eq $state) {
915: $page = $i;
916: $done = 1;
917: }
918: $i++;
919: }
920: }
1.3 raeburn 921:
922: my $loaditems = &onload_action($action,$state);
1.53 raeburn 923: $r->print(&header("Groups Manager",
1.39 albertel 924: $jscript,$action,$state,$page,$loaditems));
1.1 raeburn 925:
1.71 raeburn 926: if ($env{'form.refpage'} eq 'cusr') {
1.3 raeburn 927: &Apache::lonhtmlcommon::add_breadcrumb
1.71 raeburn 928: ({href=>"/adm/createuser",
929: text=>"User Management",
1.3 raeburn 930: faq=>9,bug=>'Instructor Interface',});
1.64 raeburn 931: if ($action eq 'modify' || $action eq 'delete') {
1.53 raeburn 932: &Apache::lonhtmlcommon::add_breadcrumb
1.130 raeburn 933: ({href=>"/adm/coursegroups?refpage=cusr&action=$action",
1.53 raeburn 934: text=>"Groups",
935: faq=>9,bug=>'Instructor Interface',});
936: }
937: } else {
1.1 raeburn 938: &Apache::lonhtmlcommon::add_breadcrumb
1.53 raeburn 939: ({href=>"/adm/coursegroups",
940: text=>"Groups",
941: faq=>9,bug=>'Instructor Interface',});
1.54 raeburn 942: if ($env{'form.refpage'} eq 'grouplist') {
943: &Apache::lonhtmlcommon::add_breadcrumb
944: ({href=>"/adm/$cdom/$cnum/$env{'form.groupname'}/smppg?ref=grouplist",
1.131 raeburn 945: text=>&mt('Group').": $description",
946: no_mt=>1});
1.54 raeburn 947: }
1.3 raeburn 948: }
949:
950: my %trail = ();
1.5 raeburn 951: %{$trail{'create'}} = &Apache::lonlocal::texthash (
1.29 raeburn 952: pick_name => $ucgpterm.' Settings',
1.3 raeburn 953: pick_members => 'Select Members',
954: pick_privs => 'Choose Privileges',
955: result => 'Creation Complete',
956: );
1.5 raeburn 957: %{$trail{'modify'}} = &Apache::lonlocal::texthash(
958: pick_task => 'Choose Task',
1.29 raeburn 959: change_settings => "$ucgpterm Settings",
1.5 raeburn 960: change_members => 'Modify/Delete Members',
961: change_privs => 'Change Privileges',
962: change_mapping => 'Membership Mapping',
963: add_members => 'Add Members',
964: pick_members => 'Select Members',
965: pick_privs => 'Choose Privileges',
966: chgresult => 'Setting Changes Complete',
967: memresult => 'Modifications Complete',
968: addresult => 'Additions Complete',
969: );
1.64 raeburn 970: %{$trail{'delete'}} = &Apache::lonlocal::texthash(
971: verify => 'Verify deletion',
972: result => 'Deletion Complete'
973: );
1.65 raeburn 974: %{$trail{'reenable'}} = &Apache::lonlocal::texthash(
975: verify => 'Verify Re-enable',
976: result => 'Re-enabled'
977: );
1.5 raeburn 978: my %navbuttons = &Apache::lonlocal::texthash(
1.91 schafran 979: gtns => 'Next',#'Go to next step',
1.93 schafran 980: gtps => 'Back',#'Go to previous step',
1.29 raeburn 981: crgr => 'Create '.$gpterm,
1.91 schafran 982: mose => 'Save',#'Modify settings',
1.93 schafran 983: gtpp => 'Back',#'Go to previous page',
1.5 raeburn 984: adme => 'Add members',
985: );
1.65 raeburn 986: if ((($action eq 'create') || ($action eq 'modify') || ($action eq 'delete') || ($action eq 'reenable')) &&
1.3 raeburn 987: ($manage_permission)) {
988: for (my $i=0; $i<@{$states{$action}}; $i++) {
989: if ($state eq $states{$action}[$i]) {
990: &Apache::lonhtmlcommon::add_breadcrumb(
991: {text=>"$trail{$action}{$state}"});
992: $r->print(&Apache::lonhtmlcommon::breadcrumbs
1.61 raeburn 993: ("Groups Manager","Creating_Groups"));
1.48 albertel 994: &display_control($r,$cdom,$cnum,$action,$state,$page,
1.5 raeburn 995: \%sectioncount,$groupname,$description,$functions,
1.36 raeburn 996: \@tools,$toolprivs,$fixedprivs,$startdate,$enddate,
1.5 raeburn 997: \%users,\%userdata,$idx,\%memchg,\%usertools,
1.45 albertel 998: $view_permission,$manage_permission,
1.29 raeburn 999: \%stored,$granularity,$quota,$specificity,\@types,\@roles,
1.48 albertel 1000: \@sections,\%states,\%navbuttons,$gpterm,$ucgpterm,
1001: $crstype);
1.3 raeburn 1002: last;
1003: } else {
1.64 raeburn 1004: if (($action eq 'create') || ($action eq 'modify')) {
1005: if (($state eq 'result') && ($i > 0)) {
1006: &Apache::lonhtmlcommon::add_breadcrumb(
1.3 raeburn 1007: {href=>"javascript:backPage(document.$state,'$states{$action}[0]')",
1008: text=>"$trail{$action}{$states{$action}[$i]}"});
1.64 raeburn 1009: } else {
1010: &Apache::lonhtmlcommon::add_breadcrumb(
1.3 raeburn 1011: {href=>"javascript:backPage(document.$state,'$states{$action}[$i]')",
1012: text=>"$trail{$action}{$states{$action}[$i]}"});
1.64 raeburn 1013: }
1.3 raeburn 1014: }
1.64 raeburn 1015: }
1.3 raeburn 1016: }
1017: } elsif (($action eq 'view') && ($view_permission)) {
1018: &Apache::lonhtmlcommon::add_breadcrumb(
1.29 raeburn 1019: {text=>"View $gpterm".'s'});
1.1 raeburn 1020: $r->print(&Apache::lonhtmlcommon::breadcrumbs
1.53 raeburn 1021: ('Groups Manager'));
1.39 albertel 1022: &display_groups($r,$cdom,$cnum,$functions,$idx,$view_permission,
1023: $manage_permission,$action,$state,$gpterm,$ucgpterm,
1024: $crstype);
1.3 raeburn 1025: }
1026: $r->print(&footer());
1027: return;
1028: }
1029:
1.5 raeburn 1030: sub retrieve_settings {
1.65 raeburn 1031: my ($cdom,$cnum,$groupname,$action) = @_;
1032: my %curr_groups;
1033: my $namespace;
1034: if ($action eq 'reenable') {
1035: $namespace = 'deleted_groups';
1036: } else {
1037: $namespace = 'coursegroups';
1038: }
1039: %curr_groups = &Apache::longroup::coursegroups($cdom,$cnum,$groupname,
1040: $namespace);
1.15 albertel 1041:
1042: return if (!%curr_groups);
1043:
1044: my %groupinfo =
1.17 raeburn 1045: &Apache::longroup::get_group_settings($curr_groups{$groupname});
1.15 albertel 1046:
1.5 raeburn 1047: my %stored;
1.15 albertel 1048:
1049: $stored{'description'} =
1.24 www 1050: &unescape($groupinfo{'description'});
1.15 albertel 1051: $stored{'startdate'} = $groupinfo{'startdate'};
1052: $stored{'enddate'} = $groupinfo{'enddate'};
1053: if ($stored{'enddate'} == 0) {
1054: $stored{'no_end_date'} = 1;
1055: }
1056: $stored{'granularity'} = $groupinfo{'granularity'};
1057: $stored{'specificity'} = $groupinfo{'specificity'};
1058: $stored{'creation'} = $groupinfo{'creation'};
1059: $stored{'creator'} = $groupinfo{'creator'};
1.29 raeburn 1060: $stored{'quota'} = $groupinfo{'quota'};
1.15 albertel 1061:
1062: foreach my $tool (sort(keys(%{$groupinfo{'functions'}}))) {
1063: if ($groupinfo{functions}{$tool} eq 'on') {
1064: push(@{$stored{tool}},$tool);
1065: }
1066: }
1067: foreach my $role (@{$groupinfo{'roles'}}) {
1068: push(@{$stored{roles}},$role);
1069: }
1070: foreach my $type (@{$groupinfo{'types'}}) {
1071: push(@{$stored{types}},$type);
1072: }
1073: foreach my $section (@{$groupinfo{'sectionpick'}}) {
1074: push(@{$stored{sectionpick}},$section);
1075: }
1076: foreach my $defpriv (@{$groupinfo{'defpriv'}}) {
1077: push(@{$stored{defpriv}},$defpriv);
1078: }
1079: $stored{'autoadd'} = $groupinfo{'autoadd'};
1080: $stored{'autodrop'} = $groupinfo{'autodrop'};
1081: if (exists($groupinfo{'autosec'})) {
1082: foreach my $role (sort(keys(%{$groupinfo{'autosec'}}))) {
1.17 raeburn 1083: if (ref($groupinfo{'autosec'}{$role}) eq 'ARRAY') {
1084: foreach my $section (@{$groupinfo{'autosec'}{$role}}) {
1.58 raeburn 1085:
1.17 raeburn 1086: push (@{$stored{'sec_'.$role}},$section);
1087: }
1088: if (@{$groupinfo{'autosec'}{$role}} > 0) {
1089: push(@{$stored{'autorole'}},$role);
1090: }
1091: }
1.15 albertel 1092: }
1.5 raeburn 1093: }
1094: return %stored;
1095: }
1096:
1.3 raeburn 1097: sub display_control {
1.48 albertel 1098: my ($r,$cdom,$cnum,$action,$state,$page,$sectioncount,$groupname,
1.3 raeburn 1099: $description,$functions,$tools,$toolprivs,$fixedprivs,$startdate,
1.45 albertel 1100: $enddate,$users,$userdata,$idx,$memchg,$usertools,
1.29 raeburn 1101: $view_permission,$manage_permission,$stored,$granularity,$quota,
1.48 albertel 1102: $specificity,$types,$roles,$sections,$states,$navbuttons,
1103: $gpterm,$ucgpterm,$crstype) = @_;
1.3 raeburn 1104: if ($action eq 'create') {
1105: if ($state eq 'pick_name') {
1.46 albertel 1106: &general_settings_form($r,$cdom,$cnum,$action,$state,$page,
1.5 raeburn 1107: $functions,$tools,$toolprivs,$fixedprivs,
1108: $sectioncount,$stored,$states,$navbuttons,
1.46 albertel 1109: $gpterm,$ucgpterm,$crstype);
1.3 raeburn 1110: } elsif ($state eq 'pick_members') {
1.46 albertel 1111: &choose_members_form($r,$cdom,$cnum,$action,$state,$page,
1.29 raeburn 1112: $groupname,$description,$granularity,$quota,
1.5 raeburn 1113: $startdate,$enddate,$tools,$fixedprivs,
1114: $toolprivs,$functions,$users,$userdata,$idx,
1.46 albertel 1115: $stored,$states,$navbuttons,$gpterm,$ucgpterm,
1116: $crstype);
1.3 raeburn 1117: } elsif ($state eq 'pick_privs') {
1.45 albertel 1118: &choose_privs_form($r,$cdom,$cnum,$action,$state,$page,
1.5 raeburn 1119: $startdate,$enddate,$tools,$functions,
1120: $toolprivs,$fixedprivs,$userdata,$usertools,
1121: $idx,$states,$stored,$sectioncount,$navbuttons,
1.45 albertel 1122: $gpterm,$ucgpterm,$crstype);
1.3 raeburn 1123: } elsif ($state eq 'result') {
1.45 albertel 1124: &process_request($r,$cdom,$cnum,$action,$state,$page,
1.5 raeburn 1125: $groupname,$description,$specificity,$userdata,
1126: $startdate,$enddate,$tools,$functions,
1127: $toolprivs,$usertools,$idx,$types,$roles,
1128: $sections,$states,$navbuttons,$memchg,
1.45 albertel 1129: $sectioncount,$stored,$gpterm,$ucgpterm,$crstype);
1.5 raeburn 1130: }
1131: } elsif ($action eq 'modify') {
1132: my $groupname = $env{'form.groupname'};
1.53 raeburn 1133: if ($state eq 'pick_task') {
1.29 raeburn 1134: &modify_menu($r,$groupname,$page,$gpterm);
1.5 raeburn 1135: } elsif ($state eq 'change_settings') {
1.46 albertel 1136: &general_settings_form($r,$cdom,$cnum,$action,$state,$page,
1.5 raeburn 1137: $functions,$tools,$toolprivs,$fixedprivs,
1138: $sectioncount,$stored,$states,$navbuttons,
1.46 albertel 1139: $gpterm,$ucgpterm,$crstype);
1.5 raeburn 1140: } elsif ($state eq 'change_members') {
1.48 albertel 1141: &change_members_form($r,$cdom,$cnum,$action,$state,$page,
1.5 raeburn 1142: $groupname,$description,$startdate,$enddate,
1143: $tools,$fixedprivs,$functions,$users,
1.29 raeburn 1144: $userdata,$granularity,$quota,$specificity,
1.48 albertel 1145: $idx,$states,$navbuttons,$gpterm,$ucgpterm);
1.5 raeburn 1146: } elsif ($state eq 'add_members') {
1.59 raeburn 1147: &add_members_form($r,$cdom,$cnum,$action,$state,$page,$startdate,
1.5 raeburn 1148: $enddate,$groupname,$description,$granularity,
1.29 raeburn 1149: $quota,$sectioncount,$tools,$functions,$stored,
1.104 raeburn 1150: $states,$navbuttons,$gpterm,$ucgpterm,$crstype);
1.5 raeburn 1151: } elsif ($state eq 'pick_members') {
1.46 albertel 1152: &choose_members_form($r,$cdom,$cnum,$action,$state,$page,
1.29 raeburn 1153: $groupname,$description,$granularity,$quota,
1.5 raeburn 1154: $startdate,$enddate,$tools,$fixedprivs,
1155: $toolprivs,$functions,$users,$userdata,$idx,
1.46 albertel 1156: $stored,$states,$navbuttons,$gpterm,$ucgpterm,
1157: $crstype);
1.5 raeburn 1158: } elsif ($state eq 'pick_privs') {
1.46 albertel 1159: &choose_privs_form($r,$cdom,$cnum,$action,$state,$page,
1.5 raeburn 1160: $startdate,$enddate,$tools,$functions,
1161: $toolprivs,$fixedprivs,$userdata,$usertools,
1162: $idx,$states,$stored,$sectioncount,$navbuttons,
1.46 albertel 1163: $gpterm,$ucgpterm,$crstype);
1.5 raeburn 1164: } elsif ($state eq 'change_privs') {
1.45 albertel 1165: &change_privs_form($r,$cdom,$cnum,$action,$state,$page,
1.5 raeburn 1166: $startdate,$enddate,$tools,$functions,
1167: $toolprivs,$fixedprivs,$userdata,$usertools,
1168: $memchg,$idx,$states,$stored,$sectioncount,
1.45 albertel 1169: $navbuttons,$gpterm,$ucgpterm);
1.5 raeburn 1170: } elsif ($state eq 'chgresult' || $state eq 'memresult' ||
1171: $state eq 'addresult') {
1.45 albertel 1172: &process_request($r,$cdom,$cnum,$action,$state,$page,
1.5 raeburn 1173: $groupname,$description,$specificity,$userdata,
1174: $startdate,$enddate,$tools,$functions,
1175: $toolprivs,$usertools,$idx,$types,$roles,
1176: $sections,$states,$navbuttons,$memchg,
1.45 albertel 1177: $sectioncount,$stored,$gpterm,$ucgpterm,$crstype);
1.1 raeburn 1178: }
1.64 raeburn 1179: } elsif ($action eq 'delete') {
1.65 raeburn 1180: my %stored = &retrieve_settings($cdom,$cnum,$groupname,$action);
1.64 raeburn 1181: if ($state eq 'verify') {
1182: &verify_delete($r,$groupname,$state,$action,$page,$states,
1.104 raeburn 1183: \%stored,$crstype);
1.64 raeburn 1184: } elsif ($state eq 'result') {
1.104 raeburn 1185: &delete_group($r,$cdom,$cnum,$groupname,$crstype);
1.64 raeburn 1186: }
1.65 raeburn 1187: } elsif ($action eq 'reenable') {
1188: my %stored = &retrieve_settings($cdom,$cnum,$groupname,$action);
1189: if ($state eq 'verify') {
1190: &verify_reenable($r,$groupname,$state,$action,$page,$states,
1.104 raeburn 1191: \%stored,$crstype);
1.65 raeburn 1192: } elsif ($state eq 'result') {
1.104 raeburn 1193: &reenable_group($r,$cdom,$cnum,$groupname,$crstype);
1.65 raeburn 1194: }
1.64 raeburn 1195: }
1196: }
1197:
1198: sub verify_delete {
1.104 raeburn 1199: my ($r,$groupname,$formname,$action,$page,$states,$stored,$crstype) = @_;
1.64 raeburn 1200: $r->print(&Apache::lonhtmlcommon::echo_form_input([]));
1.79 bisitz 1201: $r->print(&mt('You have requested deletion of the group [_1].'
1202: ,'<i>'.$stored->{'description'}.'</i>').
1.64 raeburn 1203: '<br /><br />'.&mt('When a group is deleted the following occurs:').'<ul>'.
1204: '<li>'.&mt('All group membership is terminated.').'</li>'.
1.104 raeburn 1205: '<li>'.&mt('The group ceases to be available either for viewing or for modification of group settings and membership.').'</li>');
1206: if ($crstype eq 'Community') {
1207: $r->print( '<li>'.&mt("The group folder is removed from the folder containing it - normally this is the 'Community Groups' folder which contains folders for all groups in the community.").'</li>'.
1208: '</ul>'.&mt("Although a deleted group is no longer accessible, the group name used for the group will be reserved, and will not be available for assignment to a new group in the same community in the future."));
1209: } else {
1210: $r->print( '<li>'.&mt("The group folder is removed from the folder containing it - normally this is the 'Course Groups' folder which contains folders for all groups in the course.").'</li>'.
1211: '</ul>'.&mt("Although a deleted group is no longer accessible, the group name used for the group will be reserved, and will not be available for assignment to a new group in the same course in the future."));
1212: }
1.64 raeburn 1213: my $prevtext = &mt('Go back');
1214: my $nexttext = &mt('Delete group');
1215: my $prev;
1.71 raeburn 1216: if ($env{'form.refpage'} eq 'cusr') {
1.64 raeburn 1217: $prev = 'view';
1218: }
1219: &display_navbuttons($r,$formname,$prev,$prevtext,
1220: $$states{$action}[$page+1],$nexttext);
1221: return;
1222: }
1223:
1224: sub delete_group {
1.104 raeburn 1225: my ($r,$cdom,$cnum,$groupname,$crstype) = @_;
1.64 raeburn 1226: my %membership = &Apache::lonnet::get_group_membership($cdom,$cnum,
1227: $groupname);
1228: my $now = time;
1229: my $num_users = 0;
1230: my $num_fail = 0;
1231: my $num_ok = 0;
1232: my @deleted;
1233: my @undeleted;
1234: my %usersettings;
1.77 raeburn 1235: my $context = 'deletegroup';
1.64 raeburn 1236: foreach my $key (sort(keys(%membership))) {
1237: if ($key =~ /^\Q$groupname\E:([^:]+:[^:]+)$/) {
1238: my $user = $1;
1.65 raeburn 1239: my($end,$start,$userprivs) = split(/:/,$membership{$key},3);
1.64 raeburn 1240: if ($start != -1) {
1241: $num_users ++;
1.65 raeburn 1242: $usersettings{$groupname.':'.$user} = $now.':-1:'.$userprivs;
1.64 raeburn 1243: if (&Apache::lonnet::modify_group_roles($cdom,$cnum,
1244: $groupname,$user,
1.76 raeburn 1245: $now,'-1',$userprivs,
1246: '',$context)
1.64 raeburn 1247: eq 'ok') {
1248: $num_ok ++;
1249: push(@deleted,$user);
1250: } else {
1251: push(@undeleted,$user);
1252: $num_fail ++;
1253: }
1254: }
1255: }
1256: }
1257: if ($num_ok > 0) {
1258: my $roster_result =
1259: &Apache::lonnet::modify_coursegroup_membership($cdom,$cnum,
1260: \%usersettings);
1261: }
1262: if ($num_fail > 0) {
1.79 bisitz 1263: $r->print('<div class="LC_error">'
1264: .&mt('Group deletion failed because deletion of [_1] out of [_2] members failed.'
1265: ,$num_fail,$num_users)
1266: .'</div>');
1.64 raeburn 1267: } else {
1268: my ($result,$message) =
1.65 raeburn 1269: &Apache::lonnet::toggle_coursegroup_status($cdom,$cnum,
1270: $groupname,'delete');
1.64 raeburn 1271: if ($result eq 'ok') {
1.104 raeburn 1272: my $outcome = &modify_folders($cdom,$cnum,$groupname,$crstype);
1.64 raeburn 1273: if ($outcome eq '') {
1.109 wenzelju 1274: my $message = &Apache::lonhtmlcommon::confirm_success(&mt('Group successfully deleted.'));
1275: $message = &Apache::loncommon::confirmwrapper($message);
1276: $r->print($message);
1.64 raeburn 1277: } else {
1.104 raeburn 1278: $r->print('<div class="LC_error">');
1.105 bisitz 1279: if ($crstype eq 'Community') {
1.104 raeburn 1280: $r->print(&mt("Although the group was deleted, an error occurred when removing the group's folder from the 'Community Groups' folder: [_1]",$outcome));
1281: } else {
1282: $r->print(&mt("Although the group was deleted, an error occurred when removing the group's folder from the 'Course Groups' folder: [_1]",$outcome));
1283: }
1284: $r->print('</div>');
1.64 raeburn 1285: }
1286: } else {
1.109 wenzelju 1287: my $msg = &Apache::lonhtmlcommon::confirm_success(&mt('Group deletion failed.'),1);
1288: $msg = &Apache::loncommon::confirmwrapper($msg);
1289: $r->print($msg);
1.64 raeburn 1290: }
1.1 raeburn 1291: }
1.64 raeburn 1292: return;
1293: }
1294:
1.65 raeburn 1295: sub reenable_folder {
1.104 raeburn 1296: my ($cdom,$cnum,$groupname,$description,$crstype) = @_;
1.65 raeburn 1297: my $outcome;
1298: my $crspath = '/uploaded/'.$cdom.'/'.$cnum.'/';
1299: my $allgrpsmap = $crspath.'group_allfolders.sequence';
1.104 raeburn 1300: my $foldertitle;
1301: if ($crstype eq 'Community') {
1302: $foldertitle = &mt("Community Folder -[_1]",$description);
1303: } else {
1304: $foldertitle = &mt("Course Folder -[_1]",$description);
1305: }
1.65 raeburn 1306: my $mapurl = $crspath.'group_folder_'.
1307: $groupname.'.sequence';
1308: my ($errtext,$fatal)=&LONCAPA::map::mapread($allgrpsmap);
1309: if ($fatal) {
1.79 bisitz 1310: $outcome='<div class="LC_error">'
1311: .&mt('An error occurred when reading contents of parent folder to group:')
1312: ."<br />($allgrpsmap): $errtext"
1313: .'</div>';
1.65 raeburn 1314: } else {
1315: my $idx=&LONCAPA::map::getresidx($mapurl);
1316: $LONCAPA::map::resources[$idx] = $foldertitle.':'.$mapurl.
1317: ':false:normal:res';
1318: $LONCAPA::map::order[1+$#LONCAPA::map::order]=$idx;
1.114 raeburn 1319: my ($outtext,$errtext) = &LONCAPA::map::storemap($allgrpsmap,1,1);
1.65 raeburn 1320: if ($errtext) {
1.79 bisitz 1321: $outcome='<div class="LC_error">'
1322: .&mt('An error occurred when saving updated parent folder to group:'
1323: ,"<br />$allgrpsmap - $errtext")
1324: .'</div>';
1.65 raeburn 1325: } else {
1326: my ($furl,$ferr) =
1327: &Apache::lonuserstate::readmap($cdom.'/'.$cnum);
1328: }
1329: }
1330: return $outcome;
1331: }
1332:
1.64 raeburn 1333: sub modify_folders {
1.104 raeburn 1334: my ($cdom,$cnum,$groupname,$crstype) = @_;
1.85 raeburn 1335: my ($outcome,$groupmap,$groupmapres,$map,$id,$src);
1.64 raeburn 1336: my $navmap = Apache::lonnavmaps::navmap->new();
1.85 raeburn 1337: if (!defined($navmap)) {
1.104 raeburn 1338: $outcome = '<div class="LC_error">';
1339: if ($crstype eq 'Community') {
1340: $outcome .= &mt("Error reading community contents.").' '.
1341: &mt("You need to re-initialize the community.");
1342: } else {
1343: $outcome .= &mt("Error reading course contents.").' '.
1344: &mt("You need to re-initialize the course.");
1345: }
1346: $outcome .= '</div>';
1.85 raeburn 1347: return $outcome;
1348: }
1349: $groupmap = '/uploaded/'.$cdom.'/'.$cnum.'/'.'group_folder_'.
1.64 raeburn 1350: $groupname.'.sequence';
1.85 raeburn 1351: $groupmapres = $navmap->getResourceByUrl($groupmap);
1.64 raeburn 1352: if ($groupmapres) {
1.65 raeburn 1353: ($map,$id,$src)=&Apache::lonnet::decode_symb($groupmapres->symb());
1354: }
1355: undef($navmap);
1356: if ($map) {
1.64 raeburn 1357: $map = '/'.$map;
1358: my ($errtext,$fatal) = &LONCAPA::map::mapread($map);
1359: if ($fatal) {
1.79 bisitz 1360: $outcome='<div class="LC_error">'
1361: .&mt('An error occurred when reading contents of parent folder to group:')
1362: ."<br />($map): $errtext"
1363: .'</div>';
1.64 raeburn 1364: } else {
1365: my $idx = 0;
1366: my $grpidx;
1367: foreach my $item (@LONCAPA::map::order) {
1368: my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$item]);
1369: $url=&LONCAPA::map::qtescape($url);
1370: if ($url eq $groupmap) {
1371: $grpidx = $idx;
1372: last;
1373: } else {
1374: $idx++;
1375: }
1376: }
1377:
1378: if ($grpidx ne '') {
1379: &LONCAPA::map::makezombie($LONCAPA::map::order[$grpidx]);
1380: for (my $i=$grpidx;$i<$#LONCAPA::map::order;$i++) {
1381: $LONCAPA::map::order[$i] = $LONCAPA::map::order[$i+1];
1382: }
1383: $#LONCAPA::map::order--;
1.114 raeburn 1384: my ($outtext,$errtext) = &LONCAPA::map::storemap($map,1,1);
1.65 raeburn 1385: if ($errtext) {
1.79 bisitz 1386: $outcome='<div class="LC_error">'
1387: .&mt('An error occurred when saving updated parent folder to group:')
1388: ."<br />$map - $errtext"
1389: .'</div>';
1.65 raeburn 1390: } else {
1391: my ($furl,$ferr) =
1392: &Apache::lonuserstate::readmap($cdom.'/'.$cnum);
1393: }
1394: }
1395: }
1396: }
1397: return $outcome;
1398: }
1399:
1400: sub verify_reenable {
1.104 raeburn 1401: my ($r,$groupname,$formname,$action,$page,$states,$stored,$crstype) = @_;
1.65 raeburn 1402: $r->print(&Apache::lonhtmlcommon::echo_form_input([]));
1.79 bisitz 1403: $r->print(&mt('You have requested enabling the previously deleted group [_1].'
1404: ,'<i>'.$stored->{'description'}.'</i>').
1.65 raeburn 1405: '<br /><br />'.&mt('When a deleted group is re-enabled the following occurs:').'<ul>'.
1.104 raeburn 1406: '<li>'.&mt('Group settings and membership at the time the group was deleted are reinstated.').'</li><li>');
1407: if ($crstype eq 'Community') {
1408: $r->print(&mt("A group folder is added to the 'Community Groups' folder which contains folders for all groups in the community."));
1409: } else {
1410: $r->print(&mt("A group folder is added to the 'Course Groups' folder which contains folders for all groups in the course."));
1411: }
1412: $r->print('</li></ul>');
1.65 raeburn 1413: my $prevtext = &mt('Go back');
1414: my $nexttext = &mt('Reenable group');
1415: my $prev;
1.71 raeburn 1416: if ($env{'form.refpage'} eq 'cusr') {
1.65 raeburn 1417: $prev = 'view';
1418: }
1419: &display_navbuttons($r,$formname,$prev,$prevtext,
1420: $$states{$action}[$page+1],$nexttext);
1421: return;
1422: }
1423:
1424: sub reenable_group {
1.104 raeburn 1425: my ($r,$cdom,$cnum,$groupname,$crstype) = @_;
1.65 raeburn 1426: my %groups =
1427: &Apache::longroup::coursegroups($cdom,$cnum,$groupname,
1428: 'deleted_groups');
1.66 raeburn 1429: if (keys(%groups) == 0) {
1.79 bisitz 1430: $r->print(&mt('The group [_1] was not re-enabled, because it is not a deleted group.[_2]Perhaps it has already been re-enabled?','<i>'.$groupname.'</i>'),'<br />');
1.66 raeburn 1431: return;
1432: }
1.65 raeburn 1433: my %groupinfo =
1434: &Apache::longroup::get_group_settings($groups{$groupname});
1435: my $defstart = $groupinfo{'startdate'};
1436: my $defend = $groupinfo{'enddate'};
1437: my $showstart = &Apache::lonlocal::locallocaltime($defstart);
1438: my $showend;
1439: if ($defend == 0) {
1440: $showend = &mt('No end date set');
1441: } else {
1442: $showend = &Apache::lonlocal::locallocaltime($defend);
1443: }
1444: my $description = &unescape($groupinfo{'description'});
1445: my $num_users = 0;
1446: my $num_ok = 0;
1447: my $num_fail = 0;
1.77 raeburn 1448: my $context = 'reenablegroup';
1.65 raeburn 1449: my (%usersettings,@enabled,@unenabled);
1450: my ($result,$message) =
1451: &Apache::lonnet::toggle_coursegroup_status($cdom,$cnum,$groupname,
1452: 'reenable');
1453: if ($result eq 'ok') {
1454: my %membership = &Apache::lonnet::get_group_membership($cdom,$cnum,
1455: $groupname);
1456: foreach my $key (sort(keys(%membership))) {
1457: if ($key =~ /^\Q$groupname\E:([^:]+:[^:]+)$/) {
1458: my $user = $1;
1459: my($end,$start,$userprivs) = split(/:/,$membership{$key},3);
1460: if (($start == -1) && ($end == $groupinfo{'modified'})) {
1461: $num_users ++;
1462: $usersettings{$groupname.':'.$user} = $defend.':'.
1463: $defstart.':'.
1464: $userprivs;
1465: if (&Apache::lonnet::modify_group_roles($cdom,$cnum,
1466: $groupname,$user,
1467: $defend,$defstart,
1.76 raeburn 1468: $userprivs,'',
1469: $context) eq 'ok') {
1.65 raeburn 1470: $num_ok ++;
1471: push(@enabled,$user);
1472: } else {
1473: push(@unenabled,$user);
1474: $num_fail ++;
1475: }
1.64 raeburn 1476: }
1477: }
1478: }
1.65 raeburn 1479: if ($num_users > 0) {
1480: if ($num_ok > 0) {
1481: my $roster_result =
1482: &Apache::lonnet::modify_coursegroup_membership($cdom,$cnum,
1483: \%usersettings);
1484: if ($roster_result eq 'ok') {
1.79 bisitz 1485: $r->print('<div class="LC_success">'
1486: .&mt('Membership reinstated for [quant,_1,user], each with start and end dates for group access set to defaults: [_2] and [_3]',$num_ok,$showstart,$showend)
1487: .'</div>');
1.65 raeburn 1488: }
1489: } else {
1.79 bisitz 1490: $r->print('<div class="LC_error">'
1491: .&mt('A problem occurred when trying to reinstate [_1] of the [_2] members of the pre-existing group.',$num_fail,$num_users)
1492: .'</div>');
1.65 raeburn 1493: }
1494: } else {
1.79 bisitz 1495: $r->print('<div class="LC_info">'
1496: .&mt('There were no group members to reinstate, as none were removed when the group was deleted.')
1497: .'</div>');
1.65 raeburn 1498: }
1.104 raeburn 1499: my $outcome = &reenable_folder($cdom,$cnum,$groupname,$description,$crstype);
1.65 raeburn 1500: if ($outcome eq '') {
1.109 wenzelju 1501: my $message = &Apache::lonhtmlcommon::confirm_success(&mt('Group successfully re-enabled.'));
1502: $message = &Apache::loncommon::confirmwrapper($message);
1503: $r->print($message);
1.79 bisitz 1504: } else {
1.104 raeburn 1505: $r->print('<div class="LC_error">');
1.105 bisitz 1506: if ($crstype eq 'Community') {
1.104 raeburn 1507: $r->print(&mt("Although the group was re-enabled, an error occurred when adding the group's folder to the 'Community Groups' folder: [_1]",$outcome));
1508: } else {
1509: $r->print(&mt("Although the group was re-enabled, an error occurred when adding the group's folder to the 'Course Groups' folder: [_1]",$outcome));
1510: }
1511: $r->print('</div>');
1.65 raeburn 1512: }
1513: } else {
1.109 wenzelju 1514: my $message = &Apache::lonhtmlcommon::confirm_success(&mt('Re-enabling group failed.'),1);
1515: $message = &Apache::loncommon::confirmwrapper($message);
1516: $r->print($message);
1.64 raeburn 1517: }
1.66 raeburn 1518: return;
1.1 raeburn 1519: }
1520:
1521: sub header {
1.39 albertel 1522: my ($bodytitle,$jscript,$action,$state,$page,$loaditems) = @_;
1.9 albertel 1523: my $start_page=
1.11 albertel 1524: &Apache::loncommon::start_page($bodytitle,
1525: '<script type="text/javascript">'.
1526: $jscript.'</script>',
1.39 albertel 1527: {'add_entries' => $loaditems,});
1.3 raeburn 1528: my $output = <<"END";
1.11 albertel 1529: $start_page
1.117 bisitz 1530: <form method="post" name="$state" action="">
1.3 raeburn 1531:
1532: END
1533: if ($action eq 'create' || $action eq 'modify') {
1534: $output .= <<"END";
1535: <input type="hidden" name="action" value="$action" />
1536: <input type="hidden" name="state" value="" />
1537: <input type="hidden" name="origin" value="$state" />
1.5 raeburn 1538: <input type="hidden" name="page" value="$page" />
1.3 raeburn 1539: END
1540: }
1541: return $output;
1.1 raeburn 1542: }
1543:
1.3 raeburn 1544: sub onload_action {
1545: my ($action,$state) = @_;
1.13 albertel 1546: my %loaditems;
1.3 raeburn 1547: if ((defined($env{'form.origin'})) && ($action eq 'create') &&
1548: ($state eq 'pick_name' || $state eq 'pick_members' ||
1549: $state eq 'pick_privs')) {
1550: unless ($env{'form.origin'} eq '') {
1.13 albertel 1551: $loaditems{'onload'} =
1552: 'javascript:setFormElements(document.'.$state.')';
1.1 raeburn 1553: }
1554: }
1.5 raeburn 1555: if (($action eq 'modify') &&
1556: ($state eq 'change_settings' || $state eq 'change_members' ||
1.53 raeburn 1557: $state eq 'change_privs' || $state eq 'add_members')) {
1.13 albertel 1558: $loaditems{'onload'} =
1559: 'javascript:setFormElements(document.'.$state.')';
1.5 raeburn 1560: }
1.13 albertel 1561: return \%loaditems;
1.1 raeburn 1562: }
1563:
1564: sub footer {
1.9 albertel 1565: my $end_page = &Apache::loncommon::end_page();
1.1 raeburn 1566: return(<<ENDFOOT);
1.6 raeburn 1567: <input type="hidden" name="sortby" value="$env{'form.sortby'}" />
1.1 raeburn 1568: </form>
1.9 albertel 1569: $end_page
1.1 raeburn 1570: ENDFOOT
1571: }
1572:
1.3 raeburn 1573: sub build_members_list {
1574: my ($cdom,$cnum,$types,$roles,$sections,$users,$userdata) = @_;
1575: my %access = ();
1576: foreach my $role (@{$roles}) {
1577: %{$$users{$role}} = ();
1578: }
1579: foreach my $type (@{$types}) {
1580: $access{$type} = $type;
1581: }
1582: &Apache::loncommon::get_course_users($cdom,$cnum,\%access,$roles,
1.5 raeburn 1583: $sections,$users,$userdata);
1.3 raeburn 1584: return;
1585: }
1586:
1587: sub group_files {
1.74 raeburn 1588: my ($group,$portpath,$numfiles,$numdirs) = @_;
1.29 raeburn 1589: my $dirptr=16384;
1.113 raeburn 1590: my ($dirlistref,$listerror) =
1591: &Apache::portfolio::get_dir_list($portpath,undef,$group);
1592: if (ref($dirlistref) eq 'ARRAY') {
1593: foreach my $line (@{$dirlistref}) {
1594: my ($filename,$dom,undef,$testdir,undef,undef,undef,undef,$size,undef,$mtime,undef,undef,undef,$obs,undef)=split(/\&/,$line,16);
1595: if (($filename !~ /^\.\.?$/) && ($filename !~ /\.meta$/ ) && ($filename !~ /(.*)\.(\d+)\.([^\.]*)$/) && ($filename ne 'no_such_dir')) {
1596: if ($dirptr&$testdir) {
1597: $portpath .= '/'.$filename;
1598: $$numdirs ++;
1599: &group_files($group,$portpath,$numfiles,$numdirs)
1600: } else {
1601: $$numfiles ++;
1602: }
1.29 raeburn 1603: }
1604: }
1605: }
1.3 raeburn 1606: return;
1607: }
1608:
1609: sub group_members {
1.4 raeburn 1610: my ($cdom,$cnum,$group,$group_info) = @_;
1611: my %memberhash = &Apache::lonnet::get_group_membership($cdom,$cnum,$group);
1612: my $now = time;
1.60 raeburn 1613: my %lt = &Apache::lonlocal::texthash (
1614: active => 'active',
1615: previous => 'previous',
1616: future => 'future',
1617: );
1618: my %membercounts = (
1619: active => 0,
1620: previous => 0,
1621: future => 0,
1622: );
1.4 raeburn 1623: my $totalmembers = 0;
1.127 raeburn 1624: foreach my $member (keys(%memberhash)) {
1.4 raeburn 1625: $totalmembers ++;
1626: my ($end,$start) = split(/:/,$memberhash{$member});
1.6 raeburn 1627: unless ($start == -1) {
1628: if (($end!=0) && ($end<$now)) {
1.60 raeburn 1629: $membercounts{previous} ++;
1.6 raeburn 1630: } elsif (($start!=0) && ($start>$now)) {
1.60 raeburn 1631: $membercounts{future} ++;
1.6 raeburn 1632: } else {
1.60 raeburn 1633: $membercounts{active} ++;
1.6 raeburn 1634: }
1.4 raeburn 1635: }
1636: }
1637: if ($totalmembers == 0) {
1638: $$group_info{$group}{'totalmembers'} = 'None';
1639: } else {
1.60 raeburn 1640: foreach my $type ('active','previous','future') {
1641: $$group_info{$group}{'totalmembers'} .=
1642: &open_list_window($group,$type,$membercounts{$type},$lt{$type});
1643: }
1.4 raeburn 1644: }
1645: return 'ok';
1.3 raeburn 1646: }
1647:
1.60 raeburn 1648: sub open_list_window {
1649: my ($group,$status,$count,$text) = @_;
1650: my $entry;
1651: if ($count > 0) {
1.83 bisitz 1652: $entry = '<span class="LC_nobreak"><a href="javascript:openGroupRoster('.
1.60 raeburn 1653: "'$group','$status'".')">'.$text.'</a> - '.$count.
1.83 bisitz 1654: '</span><br />';
1.60 raeburn 1655: } else {
1.83 bisitz 1656: $entry = '<span class="LC_nobreak">'.$text.' - '.$count.'</span><br />';
1.60 raeburn 1657: }
1658: return $entry;
1659: }
1660:
1.3 raeburn 1661:
1.5 raeburn 1662: sub general_settings_form {
1.46 albertel 1663: my ($r,$cdom,$cnum,$action,$formname,$page,$functions,$tools,
1.5 raeburn 1664: $toolprivs,$fixedprivs,$sectioncount,$stored,$states,$navbuttons,
1.46 albertel 1665: $gpterm,$ucgpterm,$crstype) = @_;
1.5 raeburn 1666: my ($nexttext,$prevtext);
1.42 albertel 1667: &groupsettings_options($r,$functions,$action,$formname,$stored,1,
1.29 raeburn 1668: $gpterm,$ucgpterm,$crstype);
1.41 albertel 1669: &access_date_settings($r,$action,$formname,$stored,2,$gpterm,$ucgpterm);
1.5 raeburn 1670: if ($action eq 'create') {
1.59 raeburn 1671: &membership_options($r,$cdom,$cnum,$action,$formname,$sectioncount,3,
1.104 raeburn 1672: $gpterm,$ucgpterm,$crstype);
1.5 raeburn 1673: $nexttext = $$navbuttons{'gtns'};
1674: } else {
1675: my @available = ();
1676: my @unavailable = ();
1677: &check_tools($functions,$tools,\@available,\@unavailable);
1678: @{$tools} = sort(keys(%{$functions}));
1.46 albertel 1679: &privilege_specificity($r,$action,3,$tools,$stored,$toolprivs,
1680: $fixedprivs,\@available,$formname,
1.104 raeburn 1681: $gpterm,$ucgpterm,$functions,$crstype);
1.44 albertel 1682: &mapping_options($r,$action,$formname,$page,$sectioncount,
1683: $states,$stored,$navbuttons,4,5,
1.58 raeburn 1684: $gpterm,$ucgpterm,$crstype,$cdom,$cnum);
1.5 raeburn 1685: $nexttext = $$navbuttons{'mose'};
1686: }
1687: $prevtext = $$navbuttons{'gtpp'};
1688: &display_navbuttons($r,$formname,$$states{$action}[$page-1],$prevtext,
1689: $$states{$action}[$page+1],$nexttext);
1690: return;
1691: }
1692:
1693: sub groupsettings_options {
1.42 albertel 1694: my ($r,$functions,$action,$formname,$stored,$image,$gpterm,
1.29 raeburn 1695: $ucgpterm,$crstype) = @_;
1.1 raeburn 1696: my %lt = &Apache::lonlocal::texthash(
1.53 raeburn 1697: 'gdat' => "Group access start and end dates",
1698: 'gnde' => "Group name, title and available collaborative tools",
1699: 'desc' => 'Group Title',
1700: 'func' => 'Collaborative Tools',
1701: 'gnam' => 'Group Name',
1702: 'lett' => 'Letters, numbers and underscore only',
1703: 'doyo' => 'Different subsets of the chosen collaborative tools '.
1704: 'for different group members?',
1.97 bisitz 1705: 'gran' => 'Granularity',
1706: 'dquo' => 'Disk quota',
1.1 raeburn 1707: );
1.37 raeburn 1708: my ($crsquota,$freespace,$maxposs) = &get_quota_constraints($action,$stored);
1.97 bisitz 1709: $r->print(&Apache::lonhtmlcommon::topic_bar($image,$lt{'gnde'}));
1710:
1711: # Group Name
1712: $r->print(&Apache::lonhtmlcommon::start_pick_box()
1713: .&Apache::lonhtmlcommon::row_title($lt{'gnam'})
1714: );
1.5 raeburn 1715: if ($action eq 'create') {
1.97 bisitz 1716: $r->print('<input type="text" name="groupname" size="25" />'
1717: .' <span class="LC_nobreak">('
1718: .$lt{'lett'}.')</span>'
1719: );
1.5 raeburn 1720: } else {
1721: $r->print('<input type="hidden" name="groupname" value="'.
1722: $env{'form.groupname'}.'" />'.$env{'form.groupname'});
1723: }
1.97 bisitz 1724: $r->print(&Apache::lonhtmlcommon::row_closure());
1725:
1726: # Group Title
1727: $r->print(&Apache::lonhtmlcommon::row_title($lt{'desc'})
1728: .'<input type="text" name="description" size="40" value="" />'
1729: .&Apache::lonhtmlcommon::row_closure()
1730: );
1731:
1732: # Collaborative Tools
1.3 raeburn 1733: my $numitems = keys(%{$functions});
1734: my $halfnum = int($numitems/2);
1735: my $remnum = $numitems%2;
1736: if ($remnum) {
1737: $halfnum ++;
1738: }
1.127 raeburn 1739: my @allfunctions = sort(keys(%{$functions}));
1.97 bisitz 1740:
1741: $r->print(&Apache::lonhtmlcommon::row_title($lt{'func'})
1742: .'<div>'
1743: .'<input type="button" value="'.&mt('check all').'"'
1744: .' onclick="javascript:checkAll(document.'.$formname.'.tool)" />'
1745: .' <input type="button" value="'.&mt('uncheck all').'"'
1746: .' onclick="javascript:uncheckAll(document.'.$formname.'.tool)" />'
1747: .'</div>'
1748: .'<table cellpadding="5px"><tr>' # FIXME Get rid of inflexible table (-> float)
1749: );
1750: for (my $i=0; $i<@allfunctions; $i++) {
1751: $r->print('<td><label><span class="LC_nobreak">'
1752: .'<input type="checkbox" name="tool" value="'
1753: .$allfunctions[$i].'" /> '
1754: .&mt($$functions{$allfunctions[$i]})
1755: .'</span></label></td>'
1756: );
1757: if ($i == $halfnum - 1) {
1758: $r->print('</tr><tr>');
1759: }
1.3 raeburn 1760: }
1.97 bisitz 1761: $r->print('</tr></table>'
1762: .&Apache::lonhtmlcommon::row_closure()
1763: );
1764:
1765: # Granularity
1766: $r->print(&Apache::lonhtmlcommon::row_title($lt{'gran'})
1767: .$lt{'doyo'}.'<br />'
1768: .'<label>'
1769: .'<input type="radio" name="granularity" value="Yes" />'.&mt('Yes')
1770: .'</label> <label>'
1771: .'<input type="radio" name="granularity" value="No" checked="checked" />'.&mt('No')
1772: .'</label>'
1773: );
1.5 raeburn 1774: if ($action eq 'modify') {
1.97 bisitz 1775: $r->print(' <span class="LC_nobreak">('
1776: .&mt('Currently set to [_1].'
1777: ,'"'.&mt($$stored{'granularity'}).'"')
1778: .')</span>'
1779: );
1.5 raeburn 1780: }
1.97 bisitz 1781: $r->print(&Apache::lonhtmlcommon::row_closure());
1782:
1783: # Disk Quota
1784: $r->print(&Apache::lonhtmlcommon::row_title($lt{'dquo'}));
1.29 raeburn 1785: if ($action eq 'create') {
1.97 bisitz 1786: $r->print('<span class="LC_info">'
1787: .&mt('If you enable the group portfolio for the '.$gpterm
1788: .', allocate a disk quota.')
1789: .'</span>'
1790: );
1.29 raeburn 1791: } else {
1.96 weissno 1792: $r->print(&mt('Quota allocated to group portfolio:'));
1.29 raeburn 1793: }
1.122 raeburn 1794: $r->print(' '.&mt('[_1] MB','<input type="text" name="quota" size="4" />'));
1.29 raeburn 1795: if ($action eq 'create') {
1.79 bisitz 1796: $r->print('<br />'
1.122 raeburn 1797: .&mt('A total of [_1] MB can be divided amongst all '.$gpterm.'s in the '
1798: .lc($crstype).', and [_2] MB are currently unallocated.'
1.79 bisitz 1799: ,$crsquota,sprintf("%.2f",$freespace))
1800: );
1.29 raeburn 1801: } else {
1.122 raeburn 1802: $r->print(' ('.&mt('The quota is currently [_1] MB',
1.29 raeburn 1803: $$stored{'quota'}).').');
1804:
1.79 bisitz 1805: $r->print('<br />'
1.122 raeburn 1806: .&mt('The quota can be increased to [_1] MB, '
1.79 bisitz 1807: .'by adding all unallocated space for '.$gpterm.'s in the '.lc($crstype).'.'
1808: ,sprintf("%.2f",$maxposs)));
1.29 raeburn 1809: }
1.97 bisitz 1810: $r->print(&Apache::lonhtmlcommon::row_closure(1));
1811:
1812: $r->print(&Apache::lonhtmlcommon::end_pick_box());
1813:
1.5 raeburn 1814: return;
1815: }
1816:
1.37 raeburn 1817: sub get_quota_constraints {
1818: my ($action,$stored) = @_;
1819: my ($crsquota,$freespace,$maxposs);
1820: $crsquota = $env{'course.'.$env{'request.course.id'}.'.internal.coursequota'};
1821: if ($crsquota eq '') {
1.132 ! raeburn 1822: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
! 1823: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
! 1824: my $crstype = &Apache::loncommon::course_type();
! 1825: my %domdefs = &Apache::lonnet::get_domain_defaults($cdom);
! 1826: my %coursehash = (
! 1827: 'internal.coursecode' => $env{'course.'.$env{'request.course.id'}.'.internal.coursecode'},
! 1828: 'internal.textbook' => $env{'course.'.$env{'request.course.id'}.'.internal.textbook'},
! 1829: );
! 1830: my %staticdefaults = (
! 1831: coursequota => 20,
! 1832: );
! 1833: my $quotatype = &Apache::lonuserutils::get_extended_type($cdom,$cnum,$crstype,\%coursehash);
! 1834: if ($crsquota eq '') {
! 1835: $crsquota = $domdefs{$quotatype.'coursequota'};
! 1836: if ($crsquota eq '') {
! 1837: $crsquota = $staticdefaults{'coursequota'};
! 1838: }
! 1839: }
1.37 raeburn 1840: }
1841: $freespace = $crsquota - &Apache::longroup::sum_quotas();
1842: if ($action eq 'create') {
1843: $maxposs = $freespace;
1844: } else {
1845: $maxposs = $$stored{'quota'} + $freespace;
1846: }
1847: return ($crsquota,$freespace,$maxposs);
1848: }
1849:
1.5 raeburn 1850: sub membership_options {
1.104 raeburn 1851: my ($r,$cdom,$cnum,$action,$state,$sectioncount,$image,$gpterm,$ucgpterm,$crstype)=@_;
1.5 raeburn 1852: my %lt = &Apache::lonlocal::texthash(
1.53 raeburn 1853: 'pipa' => 'Build a list of users for selection of group members',
1.104 raeburn 1854: 'gmem' => 'Group membership selection list criteria:',
1855: 'picr' => 'Pick the criteria to use to build a list of course users from which you will select members of the new group.',
1856: 'pica' => 'Pick the criteria to use to build a list of course users from which you will select additional members of the group.',
1857: 'ifno' => 'If you do not wish to add members when you first create the group, there is no need to pick any criteria.',
1.5 raeburn 1858: 'acty' => 'Access types',
1.104 raeburn 1859: 'coro' => 'Course roles',
1860: 'cose' => 'Course sections',
1.5 raeburn 1861: );
1.104 raeburn 1862: if ($crstype eq 'Community') {
1863: $lt{'picr'} = &mt('Pick the criteria to use to build a list of community participants from which you will select ');
1864: $lt{'asub'} = &mt('A subsequent step will also allow you to specify automatic adding/dropping of group members triggered by specified user role and section [_1]changes[_2] in the course.','<i>','</i>');
1865: $lt{'coro'} = &mt('Community roles');
1866: $lt{'cose'} = &mt('Community sections');
1867: } else {
1868: $lt{'asub'} = &mt('A subsequent step will also allow you to specify automatic adding/dropping of group members triggered by specified user role and section [_1]changes[_2] in the course.','<i>','</i>');
1869: }
1.5 raeburn 1870: my %status_types = (
1871: active => &mt('Currently has access'),
1872: previous => &mt('Previously had access'),
1873: future => &mt('Will have future access'),
1874: );
1.15 albertel 1875:
1.104 raeburn 1876: my @roles = ('st');
1877: if ($crstype eq 'Community') {
1878: push(@roles,'co');
1879: } else {
1880: push(@roles,'cc');
1881: }
1882: push (@roles,('in','ta','ep','ad','cr'));
1.5 raeburn 1883:
1884: my @sections = keys(%{$sectioncount});
1885:
1.78 raeburn 1886: $r->print(&Apache::lonhtmlcommon::topic_bar($image,$lt{'pipa'}).'
1.104 raeburn 1887: <b>'.$lt{'gmem'}.'</b><br />');
1.5 raeburn 1888: if ($action eq 'create') {
1.104 raeburn 1889: $r->print($lt{'picr'}.'<br />'.$lt{'ifno'}.'<br />'.$lt{'asub'});
1.5 raeburn 1890: } else {
1.104 raeburn 1891: $r->print($lt{'pica'});
1.5 raeburn 1892: }
1893: $r->print('
1894: <br />
1895: <br />
1.40 albertel 1896: <table class="LC_status_selector">
1.3 raeburn 1897: <tr>
1.40 albertel 1898: <th>'.$lt{'acty'}.'</th>
1.53 raeburn 1899: <th>'.$lt{'coro'}.'</th>
1900: <th>'.$lt{'cose'}.'</th>
1901: </tr><tr><td>');
1.3 raeburn 1902: $r->print(&Apache::lonhtmlcommon::status_select_row(\%status_types));
1.40 albertel 1903: $r->print('</td><td>');
1.59 raeburn 1904: $r->print(&Apache::lonhtmlcommon::role_select_row(\@roles,undef,undef,1,$cdom,$cnum));
1.3 raeburn 1905: if (@sections > 0) {
1.5 raeburn 1906: @sections = sort {$a cmp $b} @sections;
1.31 albertel 1907: unshift(@sections,'none'); # Put 'no sections' next
1.17 raeburn 1908: unshift(@sections,'all'); # Put 'all' at the front of the list
1.53 raeburn 1909: } else {
1910: @sections = ('all','none');
1.3 raeburn 1911: }
1.53 raeburn 1912: $r->print('</td><td>'.
1913: §ions_selection(\@sections,'sectionpick').'</td>
1.3 raeburn 1914: </tr>
1.40 albertel 1915: </table>');
1.5 raeburn 1916: return;
1917: }
1918:
1919: sub sections_selection {
1920: my ($sections,$elementname) = @_;
1921: my $section_sel;
1922: my $numvisible = 4;
1923: if (@{$sections} < 4) {
1924: $numvisible = @{$sections};
1925: }
1926: foreach my $sec (@{$sections}) {
1.17 raeburn 1927: if ($sec eq 'all') {
1.53 raeburn 1928: $section_sel .= ' <option value="'.$sec.'">'.&mt('all sections').'</option>'."\n";
1.17 raeburn 1929: } elsif ($sec eq 'none') {
1.31 albertel 1930: $section_sel .= ' <option value="'.$sec.'">'.&mt('no section').'</option>'."\n";
1.5 raeburn 1931: } else {
1.31 albertel 1932: $section_sel .= ' <option value="'.$sec.'">'.$sec."</option>\n";
1.5 raeburn 1933: }
1934: }
1935: my $output = '
1.89 bisitz 1936: <select name="'.$elementname.'" multiple="multiple" size="'.$numvisible.'">
1.5 raeburn 1937: '.$section_sel.'
1938: </select>';
1939: return $output;
1940: }
1941:
1942: sub access_date_settings {
1.41 albertel 1943: my ($r,$action,$formname,$stored,$image,$gpterm,$ucgpterm) = @_;
1.80 bisitz 1944: my $sten = &mt("Default start and end dates for $gpterm access");
1.5 raeburn 1945: my $starttime = time;
1946: my $endtime = time+(6*30*24*60*60); # 6 months from now, approx
1947: if ($action eq 'modify') {
1948: $starttime = $$stored{'startdate'};
1949: unless ($$stored{'enddate'} == 0) {
1950: $endtime = $$stored{'enddate'};
1951: }
1952: }
1.41 albertel 1953: my ($table) = &date_setting_table($starttime,$endtime,$formname);
1.80 bisitz 1954: $r->print(&Apache::lonhtmlcommon::topic_bar($image,$sten).'
1.41 albertel 1955: '.$table.'
1956: ');
1.3 raeburn 1957: return;
1958: }
1959:
1.5 raeburn 1960: sub choose_members_form {
1.46 albertel 1961: my ($r,$cdom,$cnum,$action,$formname,$page,$groupname,$description,
1.29 raeburn 1962: $granularity,$quota,$startdate,$enddate,$tools,$fixedprivs,$toolprivs,
1.5 raeburn 1963: $functions,$users,$userdata,$idx,$stored,$states,$navbuttons,
1.46 albertel 1964: $gpterm,$ucgpterm,$crstype) = @_;
1.5 raeburn 1965: my @regexps = ('user_','userpriv_','sec_');
1966: my %origmembers;
1.3 raeburn 1967: $r->print(&Apache::lonhtmlcommon::echo_form_input(
1.5 raeburn 1968: ['origin','action','state','page','member','specificity','branch',
1.7 raeburn 1969: 'defpriv','autorole','autoadd','autodrop','sortby','togglefunc'],
1.5 raeburn 1970: \@regexps));
1.29 raeburn 1971: my $earlyout = &validate_groupname($groupname,$action,$cdom,$cnum,$gpterm,
1972: $ucgpterm,$crstype);
1.5 raeburn 1973: if ($earlyout) {
1.47 raeburn 1974: $r->print($earlyout);
1.5 raeburn 1975: &display_navbuttons($r,$formname,$$states{$action}[$page-1],
1976: $$navbuttons{'gtps'});
1.3 raeburn 1977: return;
1.5 raeburn 1978: }
1979: my ($specimg,$memimg);
1980: my @available = ();
1981: my @unavailable = ();
1982: &check_tools($functions,$tools,\@available,\@unavailable);
1983: if ($action eq 'create') {
1.40 albertel 1984: &print_current_settings($r,$action,$functions,$startdate,$enddate,
1985: $groupname,$description,$granularity,$quota,
1986: \@available,\@unavailable,$gpterm,$ucgpterm);
1.5 raeburn 1987: $specimg = 4;
1988: $memimg = 5;
1989: } else {
1990: $specimg = 2;
1991: $memimg = 3;
1992: my %membership = &Apache::lonnet::get_group_membership($cdom,$cnum,
1993: $groupname);
1994: foreach my $key (sort(keys(%membership))) {
1995: if ($key =~ /^\Q$groupname\E:([^:]+):([^:]+)$/) {
1.6 raeburn 1996: my ($end,$start,@userprivs) = split(/:/,$membership{$key});
1997: unless ($start == -1) {
1998: my $uname = $1;
1999: my $udom = $2;
2000: my $user = $uname.':'.$udom;
2001: $origmembers{$user} = 1;
2002: }
1.5 raeburn 2003: }
2004: }
2005: }
1.46 albertel 2006: &privilege_specificity($r,$action,$specimg,$tools,$stored,$toolprivs,
1.103 raeburn 2007: $fixedprivs,\@available,$formname,$gpterm,$ucgpterm,
1.104 raeburn 2008: $functions,$crstype);
1.44 albertel 2009: my $newusers = &pick_new_members($r,$action,$formname,\@available,$idx,
2010: $stored,$memimg,$users,$userdata,
2011: $granularity,\%origmembers,$gpterm,
2012: $ucgpterm);
1.5 raeburn 2013: if ($newusers || $action eq 'create') {
2014: &display_navbuttons($r,$formname,$$states{$action}[$page-1],
2015: $$navbuttons{'gtps'},$$states{$action}[$page+1],
2016: $$navbuttons{'gtns'});
2017: } else {
2018: &display_navbuttons($r,$formname,$$states{$action}[$page-1],
2019: $$navbuttons{'gtps'});
1.3 raeburn 2020: }
1.5 raeburn 2021: return;
2022: }
2023:
2024: sub display_navbuttons {
2025: my ($r,$formname,$prev,$prevtext,$next,$nexttext) = @_;
1.42 albertel 2026: $r->print('<div class="LC_navbuttons">');
1.5 raeburn 2027: if ($prev) {
2028: $r->print('
2029: <input type="button" name="previous" value = "'.$prevtext.'"
2030: onclick="javascript:backPage(document.'.$formname.','."'".$prev."'".')"/>
2031: ');
1.64 raeburn 2032: } elsif ($prevtext) {
2033: $r->print('
2034: <input type="button" name="previous" value = "'.$prevtext.'"
2035: onclick="javascript:history.back()"/>
2036: ');
1.5 raeburn 2037: }
2038: if ($next) {
2039: $r->print('
2040: <input type="button" name="next" value="'.$nexttext.'"
2041: onclick="javascript:nextPage(document.'.$formname.','."'".$next."'".')" />');
2042: }
1.42 albertel 2043: $r->print('</div>');
1.5 raeburn 2044: }
2045:
2046: sub check_tools {
2047: my ($functions,$tools,$available,$unavailable) = @_;
2048: foreach my $item (sort(keys(%{$functions}))) {
2049: if (grep/^$item$/,@{$tools}) {
2050: push(@{$available},$item);
2051: } else {
2052: push(@{$unavailable},$item);
2053: }
2054: }
2055: return;
2056: }
2057:
2058: sub print_current_settings {
1.40 albertel 2059: my ($r,$action,$functions,$startdate,$enddate,$groupname,$description,
2060: $granularity,$quota,$available,$unavailable,$gpterm,$ucgpterm) = @_;
1.5 raeburn 2061:
2062: my %lt = &Apache::lonlocal::texthash(
1.53 raeburn 2063: grna => 'Group Name',
2064: desc => 'Group Title',
2065: grfn => "Collaborative Tools",
1.5 raeburn 2066: gran => 'Granularity',
1.29 raeburn 2067: quot => 'File quota',
1.5 raeburn 2068: dfac => 'Default access dates',
1.53 raeburn 2069: ygrs => "Your group selections - ",
2070: tfwa => "The following settings will apply to the group:",
1.80 bisitz 2071: stda => 'Start date:',
1.5 raeburn 2072: enda => 'End date:',
2073: );
1.118 bisitz 2074: $lt{'difn'} = &mt('Different collaborative tools[_1]for different members:','<br />');
1.3 raeburn 2075: my $showstart = &Apache::lonlocal::locallocaltime($startdate);
1.5 raeburn 2076: my $showend;
2077: if ($enddate == 0) {
2078: $showend = &mt('No end date set');
2079: } else {
2080: $showend = &Apache::lonlocal::locallocaltime($enddate);
2081: }
2082: if ($action eq 'create') {
2083: $r->print('
1.42 albertel 2084: <div><span style="font-size: larger">'.$lt{'ygrs'}.'</span>
1.5 raeburn 2085: <br />'.$lt{'tfwa'}.'
1.40 albertel 2086: </div>');
1.5 raeburn 2087: }
1.40 albertel 2088: $r->print(&Apache::loncommon::start_data_table('LC_course_group_status').
2089: &Apache::loncommon::start_data_table_header_row());
2090: $r->print('
2091: <th>'.$lt{'grna'}.'</th>
2092: <th>'.$lt{'desc'}.'</th>
2093: <th>'.$lt{'grfn'}.'</th>
2094: <th>'.$lt{'gran'}.'</th>
2095: <th>'.$lt{'quot'}.'</th>
2096: <th>'.$lt{'dfac'}.'</th>
2097: ');
2098: $r->print(&Apache::loncommon::end_data_table_header_row().
2099: &Apache::loncommon::start_data_table_row('LC_data_table_dense'));
1.3 raeburn 2100: $r->print('
1.40 albertel 2101: <td valign="top">'.$groupname.'</td>
2102: <td valign="top">'.$description.'</td>
1.3 raeburn 2103: <td>
2104: ');
1.99 bisitz 2105:
1.5 raeburn 2106: if (@{$available} > 0) {
1.99 bisitz 2107: $r->print('<b>'.&mt('Available for assignment to members:').'</b>');
2108: $r->print('<ul>');
1.5 raeburn 2109: for (my $i=0; $i<@{$available}; $i++) {
1.99 bisitz 2110: $r->print('<li>'.&mt($$functions{$$available[$i]}).'</li>');
1.3 raeburn 2111: }
1.99 bisitz 2112: $r->print('</ul>');
1.3 raeburn 2113: }
1.99 bisitz 2114:
1.5 raeburn 2115: if (@{$unavailable} > 0) {
1.99 bisitz 2116: $r->print('<b>'.&mt('Unavailable for assignment:').'</b>');
2117: $r->print('<ul>');
2118: for (my $i=0; $i<@{$unavailable}; $i++) {
2119: $r->print('<li>'.&mt($$functions{$$unavailable[$i]}).'</li>');
1.3 raeburn 2120: }
1.99 bisitz 2121: $r->print('</ul>');
1.3 raeburn 2122: }
1.99 bisitz 2123:
1.122 raeburn 2124: my $quota_text=&mt('[_1] MB',$quota);
1.80 bisitz 2125: my $granu_text=&mt($granularity);
1.3 raeburn 2126: $r->print(<<"END");
2127: </td>
1.80 bisitz 2128: <td valign="top"><b>$lt{'difn'}</b> $granu_text</td>
1.79 bisitz 2129: <td valign="top">$quota_text</td>
1.40 albertel 2130: <td valign="top"><b>$lt{'stda'}</b> $showstart<br />
2131: <b>$lt{'enda'}</b> $showend
1.3 raeburn 2132: </td>
2133: END
1.40 albertel 2134: $r->print(&Apache::loncommon::end_data_table_row().
2135: &Apache::loncommon::end_data_table());
1.5 raeburn 2136: return;
2137: }
2138:
2139: sub pick_new_members {
1.44 albertel 2140: my ($r,$action,$formname,$available,$idx,$stored,$img,$users,$userdata,
2141: $granularity,$origmembers,$gpterm,$ucgpterm) = @_;
1.5 raeburn 2142: my %lt = &Apache::lonlocal::texthash(
1.53 raeburn 2143: 'gpme' => "Group membership",
1.5 raeburn 2144: 'addm' => 'Add members',
1.53 raeburn 2145: 'setf' => 'Assign collaborative tools',
2146: 'func' => 'Tools',
2147: 'nome' => 'No members to add at this time, as there are no users '.
2148: 'matching the specified type(s), role(s) and section(s).',
1.29 raeburn 2149: 'nnew' => "There are no users to add as new members, as all users".
1.53 raeburn 2150: " matching the specified type(s), role(s), and ".
2151: "section(s) are already affiliated with this group.",
1.79 bisitz 2152: 'yoma' => "You may need to use the 'modify existing, past or ".
2153: "future members' page if you need to re-enable ".
2154: "or activate access for previous or future members.",
1.5 raeburn 2155: );
2156: my %members;
2157: my $totalusers = 0;
2158: my $newusers = 0;
1.3 raeburn 2159: foreach my $role (keys(%{$users})) {
2160: foreach my $user (keys(%{$$users{$role}})) {
1.5 raeburn 2161: $totalusers ++;
2162: if (ref($origmembers) eq 'HASH') {
2163: if (exists($$origmembers{$user})) {
2164: next;
2165: }
2166: }
1.3 raeburn 2167: unless (defined($members{$user})) {
2168: @{$members{$user}} = @{$$userdata{$user}};
1.5 raeburn 2169: $newusers ++;
1.3 raeburn 2170: }
2171: }
2172: }
2173: if (keys(%members) > 0) {
1.5 raeburn 2174: if (@{$available} > 0 && $granularity eq 'Yes') {
2175: $r->print(&check_uncheck_tools($r,$available));
2176: }
2177: }
1.78 raeburn 2178: $r->print(&Apache::lonhtmlcommon::topic_bar($img,$lt{'gpme'}));
1.5 raeburn 2179: if (keys(%members) > 0) {
2180: $r->print('
1.3 raeburn 2181: <table>
1.5 raeburn 2182: <tr>');
2183: &check_uncheck_buttons($r,$formname,'member',$lt{'addm'});
2184: if (@{$available} > 0 && $granularity eq 'Yes') {
1.48 albertel 2185: $r->print('<td>
1.102 bisitz 2186: <fieldset><legend>'.$lt{'setf'}.'</legend>
1.83 bisitz 2187: <span class="LC_nobreak">
1.80 bisitz 2188: <input type="button" value="'.&mt('check all').'"
1.5 raeburn 2189: onclick="javascript:checkAllTools(document.'.$formname.')" />
2190:
1.80 bisitz 2191: <input type="button" value="'.&mt('uncheck all').'"
1.3 raeburn 2192: onclick="javascript:uncheckAllTools(document.'.$formname.')" />
1.83 bisitz 2193: </span>
1.48 albertel 2194: </fieldset></td>');
1.3 raeburn 2195: }
2196: $r->print('</tr></table>
2197: ');
1.43 albertel 2198: $r->print(&Apache::loncommon::start_data_table().
2199: &Apache::loncommon::start_data_table_header_row());
1.5 raeburn 2200: $r->print('
1.43 albertel 2201: <th>'.&mt('Add?').'</b></td>
2202: <th><a href="javascript:changeSort('."'fullname'".')">'.&mt('Name').'</a></td>
2203: <th><a href="javascript:changeSort('."'username'".')">'.&mt('Username').'</a></td>
2204: <th><a href="javascript:changeSort('."'domain'".')">'.&mt('Domain').'</a></td>
2205: <th><a href="javascript:changeSort('."'id'".')">'.&mt('ID').'</a></td>
2206: <th><a href="javascript:changeSort('."'section'".')">'.&mt('Section').'</a></td>
1.5 raeburn 2207: ');
2208: if (@{$available} > 0) {
1.43 albertel 2209: $r->print('<th>'.$lt{'func'}.'</th>');
1.3 raeburn 2210: }
1.43 albertel 2211: $r->print(&Apache::loncommon::end_data_table_header_row());
1.5 raeburn 2212: if (@{$available} > 0) {
2213: if ($granularity eq 'Yes') {
1.43 albertel 2214: $r->print(&Apache::loncommon::start_data_table_row('LC_data_table_dense LC_data_table_highlight').'
1.35 raeburn 2215: <td colspan="6"> </td>
1.83 bisitz 2216: <td align="center"><span class="LC_nobreak"><b>'.&mt('All:').'</b> ');
1.5 raeburn 2217: foreach my $tool (@{$available}) {
1.7 raeburn 2218: $r->print('<label><input type="checkbox" name="togglefunc" '.
2219: 'onclick="javascript:toggleTools(document.'.$formname.'.user_'.$tool.',this);"'.
2220: ' value="'.$tool.'">'.'<b>'.$tool.'</b></label> ');
1.5 raeburn 2221: }
1.83 bisitz 2222: $r->print('</span></td></tr>');
1.5 raeburn 2223: }
2224: }
1.3 raeburn 2225: my %Sortby = ();
2226: foreach my $user (sort(keys(%members))) {
2227: if ($env{'form.sortby'} eq 'fullname') {
2228: push(@{$Sortby{$members{$user}[$$idx{fullname}]}},$user);
2229: } elsif ($env{'form.sortby'} eq 'username') {
2230: push(@{$Sortby{$members{$user}[$$idx{uname}]}},$user);
2231: } elsif ($env{'form.sortby'} eq 'domain') {
2232: push(@{$Sortby{$members{$user}[$$idx{udom}]}},$user);
2233: } elsif ($env{'form.sortby'} eq 'id') {
2234: push(@{$Sortby{$members{$user}[$$idx{id}]}},$user);
1.31 albertel 2235: } elsif ($env{'form.sortby'} eq 'section') {
2236: push(@{$Sortby{$members{$user}[$$idx{section}]}},$user);
1.3 raeburn 2237: } else {
2238: push(@{$Sortby{$members{$user}[$$idx{fullname}]}},$user);
2239: }
2240: }
2241: foreach my $key (sort(keys(%Sortby))) {
2242: foreach my $user (@{$Sortby{$key}}) {
2243: my $id = $members{$user}[$$idx{id}];
2244: my $fullname = $members{$user}[$$idx{fullname}];
2245: my $udom = $members{$user}[$$idx{udom}];
2246: my $uname = $members{$user}[$$idx{uname}];
1.31 albertel 2247: my $section = $members{$user}[$$idx{section}];
1.43 albertel 2248: $r->print(&Apache::loncommon::start_data_table_row('LC_data_table_dense').
2249: '<td align="right"><input type="checkbox" name="member" value="'.$user.'" /></td>'.
2250: '<td>'.$fullname.'</td>'.
2251: '<td>'.$uname.'</td>'.
2252: '<td>'.$udom.'</td>'.
2253: '<td>'.$id.'</td>'.
2254: '<td>'.$section.'</td>');
1.5 raeburn 2255: if (@{$available} > 0) {
1.83 bisitz 2256: $r->print('<td align="center"><span class="LC_nobreak">'.
1.5 raeburn 2257: ' ');
2258: foreach my $tool (@{$available}) {
2259: if ($granularity eq 'Yes') {
1.3 raeburn 2260: $r->print('<input type="checkbox" name="user_'.
2261: $tool.'" value="'.$user.'" />'.$tool.' ');
2262: } else {
2263: $r->print('<input type="hidden" name="user_'.
2264: $tool.'" value="'.$user.'" />'.$tool.' ');
2265: }
2266: }
1.83 bisitz 2267: $r->print('</span></td>');
1.3 raeburn 2268: }
1.43 albertel 2269: $r->print(&Apache::loncommon::end_data_table_row()."\n");
1.3 raeburn 2270: }
2271: }
1.43 albertel 2272: $r->print(&Apache::loncommon::end_data_table());
1.5 raeburn 2273: } else {
2274: if ($totalusers > 0) {
2275: $r->print($lt{'nnew'}.'<br /><br />'.$lt{'yoma'});
2276: } else {
2277: $r->print($lt{'nome'});
2278: }
2279: }
2280: return $newusers;
2281: }
2282:
2283: sub privilege_specificity {
1.46 albertel 2284: my ($r,$action,$img,$tools,$stored,$toolprivs,$fixedprivs,$available,
1.104 raeburn 2285: $formname,$gpterm,$ucgpterm,$functions,$crstype) = @_;
1.5 raeburn 2286: my %lt = &Apache::lonlocal::texthash (
1.53 raeburn 2287: 'uprv' => 'User privileges for collaborative tools',
2288: 'frty' => 'For each collaborative tool you have chosen to include, '.
2289: 'there is a set of core privileges which all group members '.
2290: 'assigned use of the tool will receive.',
2291: 'thar' => 'For some tools there are also additional optional '.
2292: 'privileges which can be set.',
2293: 'plch' => 'Choose one of the following:',
2294: 'fort' => 'For the collaborative tools you have chosen to include '.
2295: 'only core privileges are available, '.
2296: 'so there are no optional privileges to assign.',
2297: 'eaty' => 'Each collaborative tool includes core '.
2298: 'privileges assigned to all members with access to the '.
2299: 'tool. Some tools may also feature additional privileges '.
1.5 raeburn 2300: 'which can be set for specific members.',
1.53 raeburn 2301: 'cutg' => 'Currently the group is configured ',
2302: 'sdif' => 'so different members can receive different optional privileges for a particular tool.',
2303: 'sall' => 'so all members will receive the same optional privileges for a particular tool.',
2304: 'algm' => 'All group members will receive the same privileges for any tool assigned to them, including the default set of optional privileges.',
2305: 'smgp' => 'Different group members may receive different privileges from '.
2306: 'others for the tools they have been assigned.',
2307: 'thwi' => 'These will be the privileges all group members receive for a particular assigned tool, '.
2308: 'if you selected the first option above.',
1.29 raeburn 2309: 'thes' => "These will be the privileges given to members assigned ".
1.53 raeburn 2310: "in the future via automatic group assignment ".
2311: "for users who receive specific sections/roles in the course ",
2312: 'asyo' => "As you have chosen not to include any collaborative tools ".
2313: "in the group, no default optional privileges need to be set.",
2314: 'will receive by default for a specific tool.',
1.5 raeburn 2315: 'oppr' => 'Optional privileges',
2316: 'defp' => 'The default privileges new members will receive are:',
2317: );
1.116 raeburn 2318: $lt{'plin'} = &mt('Indicate which [_1]optional[_2] privileges members '.
2319: 'will receive by default for a specific tool.','<b>','</b>');
1.104 raeburn 2320: if ($crstype eq 'Community') {
2321: $lt{'thes'} = &mt('These will be the privileges given to members assigned in the future via automatic group assignment for users who receive specific sections/roles in the community ');
2322: }
1.5 raeburn 2323: my $totaloptionalprivs = 0;
2324: foreach my $tool (@{$tools}) {
2325: foreach my $priv (sort(keys(%{$$toolprivs{$tool}}))) {
2326: if (!exists($$fixedprivs{$tool}{$priv})) {
2327: $totaloptionalprivs ++;
2328: }
2329: }
2330: }
1.78 raeburn 2331: $r->print(&Apache::lonhtmlcommon::topic_bar($img,$lt{'uprv'}));
1.5 raeburn 2332: if ((($action eq 'create') && (@{$available} > 0)) ||
1.55 raeburn 2333: (($action eq 'modify') && ($formname eq 'change_settings'))) {
1.5 raeburn 2334: my %specific = (
2335: 'No' => 'checked="checked"',
2336: 'Yes' => '',
2337: );
2338: if ($action eq 'create') {
2339: $r->print($lt{'frty'}.'<br />');
2340: if ($totaloptionalprivs) {
1.53 raeburn 2341: $r->print($lt{'thar'}.'<br /><br />'.$lt{'plch'});
1.5 raeburn 2342: } else {
2343: $r->print($lt{'fort'});
2344: }
2345: } else {
2346: $r->print($lt{'eaty'}.' '.$lt{cutg});
2347: if ($$stored{'specificity'} eq 'Yes') {
2348: $r->print($lt{'sdif'});
2349: $specific{'Yes'} = $specific{'No'};
2350: $specific{'No'} = '';
2351: } else {
2352: $r->print($lt{'sall'});
2353: }
2354: }
2355: if ($totaloptionalprivs) {
2356: $r->print('
1.53 raeburn 2357: <br />
1.83 bisitz 2358: <label><span class="LC_nobreak"><input type="radio" name="specificity" value="No" '.$specific{'No'}.' /> '.$lt{'algm'}.'</span></label><br />
2359: <label><span class="LC_nobreak"><input type="radio" name="specificity" value="Yes" '.$specific{'Yes'}.' /> '.$lt{'smgp'}.'</span></label><br /><br />');
1.5 raeburn 2360: } else {
2361: $r->print('<input type="hidden" name="specificity" value="No" />');
2362: }
2363: if ($totaloptionalprivs) {
1.40 albertel 2364: $r->print($lt{'plin'});
1.5 raeburn 2365: if ($action eq 'create') {
1.53 raeburn 2366: $r->print('<br />'.$lt{'thwi'});
1.5 raeburn 2367: }
2368: $r->print('<br />'.$lt{'thes'});
2369: if ($action eq 'create') {
2370: $r->print('('.&mt('if enabled on the next page').').');
2371: } else {
2372: $r->print('('.&mt('if enabled below').').');
2373: }
2374: $r->print('<br /><br />
1.40 albertel 2375: <table><tr>');
1.5 raeburn 2376: &check_uncheck_buttons($r,$formname,'defpriv',$lt{'oppr'});
2377: $r->print('
2378: </tr>
2379: </table>
1.3 raeburn 2380: <br />
2381: ');
1.5 raeburn 2382: } else {
1.40 albertel 2383: $r->print($lt{'algm'}.'<br /><br />');
1.3 raeburn 2384: }
1.42 albertel 2385: &default_privileges($r,$action,$tools,$toolprivs,$fixedprivs,
1.92 schafran 2386: $available,$functions);
1.3 raeburn 2387: } else {
1.5 raeburn 2388: if ($action eq 'create') {
2389: $r->print($lt{'asyo'});
1.55 raeburn 2390: $r->print('<input type="hidden" name="specificity" value="No" />');
1.5 raeburn 2391: } elsif ($action eq 'modify' && $formname eq 'pick_members') {
2392: my @defprivs;
2393: if (ref($$stored{'defpriv'}) eq 'ARRAY') {
2394: @defprivs = @{$$stored{'defpriv'}};
2395: }
2396: $r->print($lt{'eaty'}.' '.$lt{cutg});
2397: if ($$stored{'specificity'} eq 'Yes') {
2398: $r->print($lt{'sdif'});
2399: } else {
2400: $r->print($lt{'sall'});
2401: }
2402: $r->print(' '.$lt{'defp'}.'<br /><br />');
1.45 albertel 2403: &display_defprivs($r,$tools,$toolprivs,\@defprivs);
1.5 raeburn 2404: }
1.3 raeburn 2405: }
2406: return;
2407: }
2408:
1.5 raeburn 2409: sub default_privileges {
1.92 schafran 2410: my ($r,$action,$tools,$toolprivs,$fixedprivs,$available,$functions) = @_;
1.5 raeburn 2411: my %lt = &Apache::lonlocal::texthash(
2412: 'addp' => 'Additional privileges',
2413: 'fixp' => 'Fixed privileges',
2414: 'oppr' => 'Optional privileges',
1.53 raeburn 2415: 'func' => 'Collaborative Tool',
1.5 raeburn 2416: );
1.42 albertel 2417: $r->print(&Apache::lonhtmlcommon::start_pick_box('LC_group_priv_box').
2418: &Apache::lonhtmlcommon::row_title($lt{'func'},undef,
1.90 schafran 2419: 'LC_groups_functionality'));
1.92 schafran 2420: my @tableHeader;
1.107 raeburn 2421: if ((ref($functions) eq 'HASH') && (ref($tools) eq 'ARRAY')) {
2422: @tableHeader = map { $functions->{$_}; } @{$tools};
2423: }
1.92 schafran 2424: $r->print(join('</td><td class="LC_groups_functionality">', @tableHeader));
1.42 albertel 2425: $r->print(&Apache::lonhtmlcommon::row_closure(1));
2426: my $fixed = '';
2427: my $dynamic = '';
1.3 raeburn 2428: foreach my $tool (@{$tools}) {
1.5 raeburn 2429: my $privcount = 0;
1.42 albertel 2430: if ($dynamic ne '') {
2431: $dynamic .= '</td><td class="LC_groups_optional">';
2432: }
2433: $dynamic .= '<table class="LC_group_priv"><tr>';
1.5 raeburn 2434: foreach my $priv (sort(keys(%{$$toolprivs{$tool}}))) {
2435: if (exists($$fixedprivs{$tool}{$priv})) {
1.42 albertel 2436: if ($fixed ne '') {
2437: $fixed .= '</td><td class="LC_groups_fixed">';
2438: }
1.79 bisitz 2439: $fixed .= '<input type="hidden" name="defpriv" value="'.$priv.'" />'
1.90 schafran 2440: .'<span class="LC_nobreak">'.&mt($$toolprivs{$tool}{$priv}).' ';
1.5 raeburn 2441: if ($action eq 'modify') {
1.42 albertel 2442: if (grep(/^$tool$/,@{$available})) {
1.5 raeburn 2443: $fixed .= '<small>'.&mt('(on)').'<small> ';
2444: } else {
2445: $fixed .= '<small>'.&mt('(off)').'<small> ';
1.3 raeburn 2446: }
2447: }
1.79 bisitz 2448: $fixed .= '</span>';
1.5 raeburn 2449: } else {
1.42 albertel 2450: $privcount++;
1.5 raeburn 2451: if ($privcount == 3) {
2452: $dynamic .= '</tr>
1.42 albertel 2453: <tr>'."\n";
1.5 raeburn 2454: }
1.90 schafran 2455: $dynamic .= '<td><span class="LC_nobreak"><label><input type="checkbox" name="defpriv" value="'.$priv.'" />'.&mt($$toolprivs{$tool}{$priv}).'</label></span></td>'."\n";
1.3 raeburn 2456: }
2457: }
1.42 albertel 2458: if ($privcount == 0) {
1.79 bisitz 2459: $dynamic .= '<td>'.&mt('None').'</td>'."\n";
1.5 raeburn 2460: }
2461: if ($privcount < 3) {
1.53 raeburn 2462: $dynamic .= '<td> </td>'."\n";
1.5 raeburn 2463: } elsif ($privcount%2) {
2464: $dynamic = '<td> </td>'."\n";
2465: }
1.42 albertel 2466: $dynamic .= '</tr></table>';
1.3 raeburn 2467: }
1.42 albertel 2468: $r->print(&Apache::lonhtmlcommon::row_title($lt{'fixp'},undef,
2469: 'LC_groups_fixed').
2470: $fixed.
2471: &Apache::lonhtmlcommon::row_closure(1));
2472: $r->print(&Apache::lonhtmlcommon::row_title($lt{'oppr'},undef,
2473: 'LC_groups_optional').
2474: $dynamic.
2475: &Apache::lonhtmlcommon::end_pick_box());
1.5 raeburn 2476: $r->print('<br />');
2477: return;
1.42 albertel 2478:
1.5 raeburn 2479: }
2480:
2481: sub display_defprivs {
1.45 albertel 2482: my ($r,$tools,$toolprivs,$defprivs) = @_;
2483: my $function = &Apache::loncommon::get_users_function();
2484: my $tabcol = &Apache::loncommon::designparm($function.'.tabbg');
2485: my $rowColor1 = "#dddddd";
2486: my $rowColor2 = "#eeeeee";
1.5 raeburn 2487: my %lt = &Apache::lonlocal::texthash(
2488: 'priv' => 'Privileges',
1.53 raeburn 2489: 'func' => 'Collaborative Tool',
1.5 raeburn 2490: );
2491: $r->print(&Apache::lonhtmlcommon::start_pick_box());
2492: $r->print('<tr>');
2493: my $numrows = 0;
2494: my %currprivs;
2495: foreach my $tool (@{$tools}) {
2496: @{$currprivs{$tool}} = ();
2497: foreach my $priv (sort(keys(%{$$toolprivs{$tool}}))) {
2498: if (ref($defprivs) eq 'ARRAY') {
1.45 albertel 2499: if (grep(/^\Q$priv\E$/,@{$defprivs})) {
1.5 raeburn 2500: push(@{$currprivs{$tool}},$priv);
2501: }
1.3 raeburn 2502: }
2503: }
1.5 raeburn 2504: my $rowcount = int(@{$currprivs{$tool}}/3);
2505: if (@{$currprivs{$tool}}%3 > 0) {
2506: $rowcount ++;
2507: }
2508: if ($rowcount > $numrows) {
2509: $numrows = $rowcount;
2510: }
2511: }
2512: my @rowCols = ($rowColor1,$rowColor2);
2513: foreach my $tool (@{$tools}) {
2514: $r->print('<td align="center" valign="top">
2515: <table cellspacing="0" cellpadding="5">
2516: <tr bgcolor="#cccccc">
2517: <td colspan="3" align="center"><b>'.$tool.'</b></td>
2518: </tr>
2519: ');
2520: my $rownum = 1;
2521: my $privcount = 0;
2522: $r->print('<tr bgcolor="'.$rowColor1.'">');
2523: foreach my $priv (@{$currprivs{$tool}}) {
2524: $privcount ++;
2525: if ($privcount%4 == 0) {
2526: $rownum ++;
2527: my $bgcol = $rownum%2;
2528: $r->print('</tr>
2529: <tr bgcolor="'.$rowCols[$bgcol].'">'."\n");
2530: }
2531: $r->print('<td>'.$$toolprivs{$tool}{$priv}.'</td>'."\n");
2532: }
2533: if ($privcount%3 > 0) {
2534: my $emptycells = 3-($privcount%3);
2535: while($emptycells > 0) {
2536: $r->print('<td> </td>'."\n");
2537: $emptycells --;
2538: }
2539: }
2540: while ($rownum < $numrows) {
2541: $rownum ++;
2542: my $bgcol = $rownum%2;
2543: $r->print('<tr bgcolor="'.$rowCols[$bgcol].'"><td colspan="3"> </td></tr>');
1.3 raeburn 2544: }
1.5 raeburn 2545: $r->print('</table>'."\n".'</td>');
2546: }
2547: $r->print('</tr>'."\n");
2548: $r->print(&Apache::lonhtmlcommon::end_pick_box());
2549: $r->print('<br />');
2550: return;
1.3 raeburn 2551: }
1.5 raeburn 2552:
2553:
2554: sub change_members_form {
1.48 albertel 2555: my ($r,$cdom,$cnum,$action,$formname,$page,$groupname,$description,
1.5 raeburn 2556: $startdate,$enddate,$tools,$fixedprivs,$functions,$users,$userdata,
1.48 albertel 2557: $granularity,$quota,$specificity,$idx,$states,$navbuttons,$gpterm,
2558: $ucgpterm) = @_;
1.5 raeburn 2559: my %lt = &Apache::lonlocal::texthash(
1.29 raeburn 2560: grse => "$ucgpterm settings",
2561: mogm => "Modify $gpterm membership",
1.5 raeburn 2562: );
2563: my @regexps = ('user_','userpriv_');
2564: $r->print(&Apache::lonhtmlcommon::echo_form_input(
1.6 raeburn 2565: ['origin','action','state','page','expire','deletion',
1.7 raeburn 2566: 'reenable','activate','changepriv','sortby',
2567: 'togglefunc'],\@regexps));
1.5 raeburn 2568: my $rowimg = 1;
2569: my @available = ();
2570: my @unavailable = ();
2571: &check_tools($functions,$tools,\@available,\@unavailable);
2572: my $nexttext = $$navbuttons{'gtns'};
2573: my $prevtext = $$navbuttons{'gtpp'};
2574: $r->print('
1.3 raeburn 2575: <br />
1.5 raeburn 2576: ');
1.78 raeburn 2577: $r->print(&Apache::lonhtmlcommon::topic_bar(1,$lt{'grse'}));
1.40 albertel 2578: &print_current_settings($r,$action,$functions,$startdate,$enddate,
2579: $groupname,$description,$granularity,$quota,
2580: \@available,\@unavailable,$gpterm,$ucgpterm);
1.78 raeburn 2581: $r->print(&Apache::lonhtmlcommon::topic_bar(2,$lt{'mogm'}));
1.53 raeburn 2582: my $numcurrent = ¤t_membership($r,$cdom,$cnum,$formname,$groupname,
2583: \@available,\@unavailable,$fixedprivs,
2584: $granularity,$specificity);
2585: if ($numcurrent > 0) {
2586: &display_navbuttons($r,$formname,$$states{$action}[$page-1],$prevtext,
2587: $$states{$action}[$page+1],$nexttext);
2588: } else {
2589: &display_navbuttons($r,$formname,$$states{$action}[$page-1],$prevtext);
2590: }
1.5 raeburn 2591: return;
2592: }
2593:
2594: sub current_membership {
1.48 albertel 2595: my ($r,$cdom,$cnum,$formname,$groupname,$available,$unavailable,
2596: $fixedprivs,$granularity,$specificity) = @_;
1.5 raeburn 2597: my %membership = &Apache::lonnet::get_group_membership($cdom,$cnum,
2598: $groupname);
2599: my %lt = &Apache::lonlocal::texthash(
1.6 raeburn 2600: 'actn' => 'Action?',
2601: 'name' => 'Name',
2602: 'usnm' => 'Username',
1.123 bisitz 2603: 'stid' => 'ID',
1.6 raeburn 2604: 'doma' => 'Domain',
2605: 'stda' => 'Start Date',
2606: 'enda' => 'End Date',
1.5 raeburn 2607: 'expi' => 'Expire',
2608: 'reen' => 'Re-enable',
2609: 'acti' => 'Activate',
2610: 'dele' => 'Delete',
1.53 raeburn 2611: 'curf' => 'Current Tool Set',
1.5 raeburn 2612: 'chpr' => 'Change Privileges'
2613: );
1.52 raeburn 2614: my ($current,$num_items,$hastools,$addtools) =
1.36 raeburn 2615: &Apache::longroup::group_memberlist($cdom,$cnum,$groupname,$fixedprivs,
2616: $available);
1.53 raeburn 2617: my $numcurrent = scalar(keys(%{$current}));
2618: if ($numcurrent > 0) {
1.36 raeburn 2619: $r->print('
1.5 raeburn 2620: <table>
2621: <tr>');
1.52 raeburn 2622: if ($num_items->{'active'}) {
1.36 raeburn 2623: &check_uncheck_buttons($r,$formname,'expire',$lt{'expi'});
2624: }
1.52 raeburn 2625: if ($num_items->{'previous'}) {
1.36 raeburn 2626: &check_uncheck_buttons($r,$formname,'reenable',$lt{'reen'});
2627: }
1.52 raeburn 2628: if ($num_items->{'future'}) {
1.36 raeburn 2629: &check_uncheck_buttons($r,$formname,'activate',$lt{'acti'});
2630: }
2631: &check_uncheck_buttons($r,$formname,'deletion',$lt{'dele'});
2632: if (@{$available} > 0) {
2633: if ($specificity eq 'Yes') {
2634: &check_uncheck_buttons($r,$formname,'changepriv',$lt{'chpr'});
1.5 raeburn 2635: }
1.36 raeburn 2636: if ($granularity eq 'Yes') {
2637: $r->print(&check_uncheck_tools($r,$available));
2638: $r->print('
1.5 raeburn 2639: <td>
1.83 bisitz 2640: <span class="LC_nobreak">
1.102 bisitz 2641: <fieldset><legend>'.$lt{'curf'}.'</legend>
1.80 bisitz 2642: <input type="button" value="'.&mt('check all').'"
1.5 raeburn 2643: onclick="javascript:checkAllTools(document.'.$formname.')" />
2644:
1.80 bisitz 2645: <input type="button" value="'.&mt('uncheck all').'"
1.5 raeburn 2646: onclick="javascript:uncheckAllTools(document.'.$formname.')" />
2647: </fieldset>
1.83 bisitz 2648: </span>
1.5 raeburn 2649: </td>
2650: ');
1.3 raeburn 2651: }
1.36 raeburn 2652: }
2653: $r->print(<<"END");
1.5 raeburn 2654: </tr>
2655: </table>
1.48 albertel 2656: <br />
1.5 raeburn 2657: END
1.48 albertel 2658: $r->print(&Apache::loncommon::start_data_table().
2659: &Apache::loncommon::start_data_table_header_row());
1.36 raeburn 2660: $r->print(<<"END");
1.48 albertel 2661: <th>$lt{'actn'}</th>
2662: <th><a href="javascript:changeSort('fullname')">$lt{'name'}</a></th>
2663: <th><a href="javascript:changeSort('username')">$lt{'usnm'}</a></th>
2664: <th><a href="javascript:changeSort('domain')">$lt{'doma'}</a></th>
1.123 bisitz 2665: <th><a href="javascript:changeSort('id')">$lt{'ID'}</a></th>
1.48 albertel 2666: <th><a href="javascript:changeSort('start')">$lt{'stda'}</a></th>
2667: <th><a href="javascript:changeSort('end')">$lt{'enda'}</a></th>
1.5 raeburn 2668: END
1.36 raeburn 2669: my $colspan = 0;
2670: if ($hastools) {
1.48 albertel 2671: $r->print('<th>'.$lt{'curf'}.'</th>');
2672: $colspan++;
1.36 raeburn 2673: }
2674: if ($addtools) {
1.53 raeburn 2675: $r->print('<th>'.&mt('Additional Tools').'</th>');
1.48 albertel 2676: $colspan++;
1.36 raeburn 2677: }
1.48 albertel 2678: $r->print(&Apache::loncommon::end_data_table_header_row());
1.36 raeburn 2679: if ($colspan) {
2680: if ($granularity eq 'Yes') {
1.48 albertel 2681: $r->print(&Apache::loncommon::start_data_table_row('LC_data_table_dense LC_data_table_highlight').'
1.6 raeburn 2682: <td colspan="7"> </td>
1.83 bisitz 2683: <td colspan="'.$colspan.'" align="center"><span class="LC_nobreak"><b>'.&mt('All:').
1.6 raeburn 2684: '</b> ');
1.36 raeburn 2685: foreach my $tool (@{$available}) {
2686: $r->print('<label><input type="checkbox" name="togglefunc"'.
1.7 raeburn 2687: ' onclick="javascript:toggleTools(document.'.$formname.'.user_'.$tool.',this);"'.
1.48 albertel 2688: ' value="'.$tool.'" />'.'<b>'.$tool.'</b></label> ');
1.6 raeburn 2689: }
1.83 bisitz 2690: $r->print('</span></td></tr>');
1.6 raeburn 2691: }
1.36 raeburn 2692: }
2693: my %Sortby = ();
2694: foreach my $user (sort(keys(%{$current}))) {
2695: if ($env{'form.sortby'} eq 'fullname') {
2696: push(@{$Sortby{$$current{$user}{fullname}}},$user);
2697: } elsif ($env{'form.sortby'} eq 'username') {
2698: push(@{$Sortby{$$current{$user}{uname}}},$user);
2699: } elsif ($env{'form.sortby'} eq 'domain') {
2700: push(@{$Sortby{$$current{$user}{udom}}},$user);
2701: } elsif ($env{'form.sortby'} eq 'id') {
2702: push(@{$Sortby{$$current{$user}{id}}},$user);
2703: } else {
2704: push(@{$Sortby{$$current{$user}{fullname}}},$user);
2705: }
2706: }
2707: foreach my $key (sort(keys(%Sortby))) {
2708: foreach my $user (@{$Sortby{$key}}) {
2709: my $id = $$current{$user}{id};
2710: my $fullname = $$current{$user}{fullname};
2711: my $udom = $$current{$user}{udom};
2712: my $uname = $$current{$user}{uname};
2713: my $start = $$current{$user}{start};
2714: my $end = $$current{$user}{end};
1.48 albertel 2715: $r->print(&Apache::loncommon::start_data_table_row('LC_data_table_dense').'
2716: <td>');
1.36 raeburn 2717: if ($$current{$user}{changestate} eq 'reenable') {
1.83 bisitz 2718: $r->print('<span class="LC_nobreak"><label>'.
1.5 raeburn 2719: '<input type="checkbox" name="reenable" value="'.$user.'" />'.
1.83 bisitz 2720: $lt{'reen'}.'</label></span><br />');
1.36 raeburn 2721: } elsif ($$current{$user}{changestate} eq 'expire') {
1.83 bisitz 2722: $r->print('<span class="LC_nobreak"><label>'.
1.5 raeburn 2723: '<input type="checkbox" name="expire" value="'.$user.'" />'.
1.83 bisitz 2724: $lt{'expi'}.'</label></span><br />');
1.36 raeburn 2725: } elsif ($$current{$user}{changestate} eq 'activate') {
1.83 bisitz 2726: $r->print('<span class="LC_nobreak"><label>'.
1.5 raeburn 2727: '<input type="checkbox" name="activate" value="'.$user.'" />'.
1.83 bisitz 2728: $lt{'acti'}.'</label></span><br />');
1.36 raeburn 2729: }
1.83 bisitz 2730: $r->print('<span class="LC_nobreak"><label>'.
1.6 raeburn 2731: '<input type="checkbox" name="deletion" value="'.$user.'" />'.
1.83 bisitz 2732: $lt{'dele'}.'</label></span>');
1.36 raeburn 2733: if ($specificity eq 'Yes') {
1.83 bisitz 2734: $r->print('<br /><span class="LC_nobreak"><label>'.
1.5 raeburn 2735: '<input type="checkbox" name="changepriv" value="'.$user.'" />'.$lt{'chpr'}.
1.83 bisitz 2736: '</label></span>');
1.36 raeburn 2737: }
2738: $r->print('
1.48 albertel 2739: </td>'.
2740: '<td>'.$fullname.'</td>'.
2741: '<td>'.$uname.'</td>'.
2742: '<td>'. $udom.'</td>'.
2743: '<td>'.$id.'</td>'.
2744: '<td>'.$start.'</td>'.
2745: '<td>'.$end.'</td>');
1.36 raeburn 2746: if ($hastools) {
1.83 bisitz 2747: $r->print('<td align="left"><span class="LC_nobreak">'.
1.6 raeburn 2748: ' ');
1.36 raeburn 2749: foreach my $tool (@{$$current{$user}{currtools}}) {
2750: if ($granularity eq 'Yes') {
2751: $r->print('<label><input type="checkbox" '.
1.7 raeburn 2752: 'checked="checked" '.
2753: 'name="user_'.$tool.'" value="'.
2754: $user.'" />'.$tool.'</label>');
1.36 raeburn 2755: } else {
2756: $r->print('<input type="hidden" '.
1.7 raeburn 2757: 'checked="checked" '.
2758: 'name="user_'.$tool.'" value="'.
2759: $user.'" />'.$tool);
1.36 raeburn 2760: }
2761: $r->print(' ');
1.5 raeburn 2762: }
1.83 bisitz 2763: $r->print('</span></td>');
1.36 raeburn 2764: }
2765: if ($addtools) {
1.48 albertel 2766: $r->print('<td align="left">');
1.36 raeburn 2767: if ($granularity eq 'Yes') {
2768: foreach my $tool (@{$$current{$user}{newtools}}) {
1.83 bisitz 2769: $r->print('<span class="LC_nobreak"><label><input type="checkbox"
1.5 raeburn 2770: name="user_'.$tool.'" value="'.
2771: $user.'" />'.$tool.
1.83 bisitz 2772: '</label></span> ');
1.36 raeburn 2773: }
2774: } else {
2775: foreach my $tool (@{$$current{$user}{newtools}}) {
1.83 bisitz 2776: $r->print('<span class="LC_nobreak"><input type="hidden"
1.5 raeburn 2777: name="user_'. $tool.'" value="'.
2778: $user.'" />'.$tool.
1.83 bisitz 2779: '</span> ');
1.5 raeburn 2780: }
2781: }
1.48 albertel 2782: $r->print('</td>');
1.5 raeburn 2783: }
1.48 albertel 2784: $r->print(&Apache::loncommon::end_data_table_row()."\n");
1.5 raeburn 2785: }
1.36 raeburn 2786: }
1.48 albertel 2787: $r->print(&Apache::loncommon::end_data_table());
1.53 raeburn 2788: } else {
1.123 bisitz 2789: $r->print(
2790: '<p class="LC_info">'
2791: .&mt('There are no active, future or previous group members to modify.')
2792: .'</p>');
1.5 raeburn 2793: }
1.53 raeburn 2794: return $numcurrent;
1.5 raeburn 2795: }
2796:
2797: sub check_uncheck_buttons {
2798: my ($r,$formname,$field,$title,$colspan) = @_;
2799: $r->print('
2800: <td '.$colspan.'>
2801: <fieldset>
1.102 bisitz 2802: <legend>'.$title.'</legend>
1.83 bisitz 2803: <span class="LC_nobreak">
1.80 bisitz 2804: <input type="button" value="'.&mt('check all').'"
1.5 raeburn 2805: onclick="javascript:checkAll(document.'.$formname.'.'.$field.')" />
2806:
1.80 bisitz 2807: <input type="button" value="'.&mt('uncheck all').'"
1.5 raeburn 2808: onclick="javascript:uncheckAll(document.'.$formname.'.'.$field.')" />
1.83 bisitz 2809: </span>
1.5 raeburn 2810: </fieldset>
2811: </td>
2812: ');
2813: }
2814:
2815:
2816: sub change_privs_form {
1.45 albertel 2817: my ($r,$cdom,$cnum,$action,$formname,$page,$startdate,$enddate,
2818: $tools,$functions,$toolprivs,$fixedprivs,$userdata,$usertools,
2819: $memchg,$idx,$states,$stored,$sectioncount,$navbuttons,$gpterm,
2820: $ucgpterm) = @_;
1.5 raeburn 2821: my @regexps = ('userpriv_');
2822: my $nexttext;
1.6 raeburn 2823: my %lt = &Apache::lonlocal::texthash(
2824: 'tode' => 'To be deleted',
2825: 'toex' => 'To be expired',
1.29 raeburn 2826: 'nome' => "No members to be deleted or expired from the $gpterm.",
1.6 raeburn 2827: );
1.5 raeburn 2828: $r->print(&Apache::lonhtmlcommon::echo_form_input(
1.6 raeburn 2829: ['origin','action','state','page','sortby'],\@regexps));
2830: if ($env{'form.branch'} eq 'adds') {
2831: $nexttext = $$navbuttons{'adme'};
2832: } else {
2833: $nexttext = $$navbuttons{'mose'};
2834: }
1.78 raeburn 2835: $r->print(&Apache::lonhtmlcommon::topic_bar(3,&mt('Members to delete or expire')));
1.6 raeburn 2836: my $exp_or_del = 0;
2837: if (ref($$memchg{'deletion'}) eq 'ARRAY') {
2838: if (@{$$memchg{'deletion'}} > 0) {
1.50 albertel 2839: $r->print('<b>'.$lt{'tode'}.':</b><br /><ul>');
1.6 raeburn 2840: foreach my $user (@{$$memchg{'deletion'}}) {
2841: $r->print('<li>'.$$userdata{$user}[$$idx{fullname}].
2842: ' ('.$user.')</li>');
2843: }
1.45 albertel 2844: $r->print('</ul>');
1.6 raeburn 2845: $exp_or_del += @{$$memchg{'deletion'}};
2846: }
2847: }
2848: if (ref($$memchg{'expire'}) eq 'ARRAY') {
2849: if (@{$$memchg{'expire'}} > 0) {
1.50 albertel 2850: $r->print('<b>'.$lt{'toex'}.':</b><br /><ul>');
1.6 raeburn 2851: foreach my $user (@{$$memchg{'expire'}}) {
2852: $r->print('<li>'.$$userdata{$user}[$$idx{fullname}].
2853: ' ('.$user.')</li>');
2854: }
1.45 albertel 2855: $r->print('</ul>');
1.6 raeburn 2856: $exp_or_del += @{$$memchg{'expire'}};
2857: }
2858: }
2859: if (!$exp_or_del) {
1.123 bisitz 2860: $r->print('<p class="LC_info">'.$lt{'nome'}.'</p>');
1.6 raeburn 2861: }
1.5 raeburn 2862:
1.78 raeburn 2863: $r->print(&Apache::lonhtmlcommon::topic_bar(4,&mt('Setting optional privileges for specific group members')));
1.6 raeburn 2864:
1.45 albertel 2865: my $numchgs = &member_privileges_form($r,$action,$formname,$tools,
1.6 raeburn 2866: $toolprivs,$fixedprivs,$userdata,
2867: $usertools,$idx,$memchg,$states,
1.45 albertel 2868: $stored,$gpterm);
1.5 raeburn 2869: my $prevtext = $$navbuttons{'gtps'};
1.6 raeburn 2870: if ($numchgs || $exp_or_del) {
2871: &display_navbuttons($r,$formname,$$states{$action}[$page-1],$prevtext,
2872: $$states{$action}[$page+1],$nexttext);
2873: } else {
2874: &display_navbuttons($r,$formname,$$states{$action}[$page-1],$prevtext);
2875: }
1.5 raeburn 2876: return;
2877: }
2878:
2879: sub add_members_form {
1.59 raeburn 2880: my ($r,$cdom,$cnum,$action,$formname,$page,$startdate,$enddate,$groupname,
1.29 raeburn 2881: $description,$granularity,$quota,$sectioncount,$tools,$functions,
1.104 raeburn 2882: $stored,$states,$navbuttons,$gpterm,$ucgpterm,$crstype)=@_;
1.40 albertel 2883: $r->print(' <br />');
1.5 raeburn 2884: my @available = ();
2885: my @unavailable = ();
2886: &check_tools($functions,$tools,\@available,\@unavailable);
1.40 albertel 2887: &print_current_settings($r,$action,$functions,$startdate,$enddate,
2888: $groupname,$description,$granularity,$quota,
2889: \@available,\@unavailable,$gpterm,$ucgpterm);
1.59 raeburn 2890: &membership_options($r,$cdom,$cnum,$action,$formname,$sectioncount,1,$gpterm,
1.104 raeburn 2891: $ucgpterm,$crstype);
1.5 raeburn 2892: my $nexttext = $$navbuttons{'gtns'};
2893: my $prevtext = $$navbuttons{'gtpp'};
2894: &display_navbuttons($r,$formname,$$states{$action}[$page-1],$prevtext,
2895: $$states{$action}[$page+1],$nexttext);
2896: return;
2897: }
2898:
2899: sub choose_privs_form {
1.45 albertel 2900: my ($r,$cdom,$cnum,$action,$formname,$page,$startdate,$enddate,
2901: $tools,$functions,$toolprivs,$fixedprivs,$userdata,$usertools,$idx,
2902: $states,$stored,$sectioncount,$navbuttons,$gpterm,$ucgpterm,
2903: $crstype) = @_;
1.5 raeburn 2904:
2905: my @regexps = ('userpriv_');
2906: my $nexttext;
2907:
2908: if ($action eq 'create') {
2909: push(@regexps,'sec_');
2910: $r->print(&Apache::lonhtmlcommon::echo_form_input(
1.6 raeburn 2911: ['origin','action','state','page','sortby','autoadd','autodrop'],
1.5 raeburn 2912: \@regexps));
2913: $nexttext = $$navbuttons{'crgr'};
2914: } else {
2915: $r->print(&Apache::lonhtmlcommon::echo_form_input(
1.6 raeburn 2916: ['origin','action','state','page','sortby'],\@regexps));
1.5 raeburn 2917: $nexttext = $$navbuttons{'adme'};
2918: }
2919:
1.78 raeburn 2920: $r->print(&Apache::lonhtmlcommon::topic_bar(6,&mt('Setting optional privileges for specific group members')));
1.5 raeburn 2921:
1.45 albertel 2922: &member_privileges_form($r,$action,$formname,$tools,$toolprivs,
1.5 raeburn 2923: $fixedprivs,$userdata,$usertools,$idx,undef,
1.45 albertel 2924: $states,$stored,$gpterm);
1.5 raeburn 2925:
2926: if ($action eq 'create') {
1.53 raeburn 2927: my $img1 = 7;
2928: my $img2 = 8;
2929: &mapping_options($r,$action,$formname,$page,$sectioncount,
2930: $states,$stored,$navbuttons,$img1,$img2,
1.58 raeburn 2931: $gpterm,$ucgpterm,$crstype,$cdom,$cnum);
1.5 raeburn 2932: }
2933: my $prevtext = $$navbuttons{'gtps'};
2934: &display_navbuttons($r,$formname,$$states{$action}[$page-1],$prevtext,
2935: $$states{$action}[$page+1],$nexttext);
2936: return;
2937: }
2938:
2939: sub build_boxes {
2940: my ($r,$tools,$usertools,$fixedprivs,$toolprivs,$showtools,
1.6 raeburn 2941: $showboxes,$prefix,$specificity,$excluded) = @_;
1.5 raeburn 2942: my $totalboxes = 0;
2943: if (@{$tools} > 0) {
2944: if ($specificity eq 'Yes') {
2945: foreach my $tool (@{$tools}) {
2946: @{$$showboxes{$tool}} = ();
2947: foreach my $user (sort(keys(%{$usertools}))) {
1.6 raeburn 2948: if (ref($excluded) eq 'ARRAY') {
2949: if (grep/^$user$/,@{$excluded}) {
2950: next;
2951: }
1.5 raeburn 2952: }
1.6 raeburn 2953: if ($$usertools{$user}{$tool}) {
2954: unless (grep/^$tool$/,@{$showtools}) {
2955: push(@{$showtools},$tool);
2956: }
2957: foreach my $priv (sort(keys(%{$$toolprivs{$tool}}))) {
2958: unless (exists($$fixedprivs{$tool}{$priv})) {
2959: unless(grep(/^$priv$/,@{$$showboxes{$tool}})) {
2960: push(@{$$showboxes{$tool}},$priv);
2961: $totalboxes ++;
2962: }
1.5 raeburn 2963: }
2964: }
2965: }
2966: }
2967: }
2968: if ($totalboxes > 0) {
2969: $r->print('
2970: <script type="text/javascript">
2971: function checkAllTools(formname) {
2972: ');
2973: foreach my $tool (sort(keys(%{$showboxes}))) {
2974: foreach my $priv (@{$$showboxes{$tool}}) {
2975: $r->print(' checkAll(formname.'.$prefix.$priv.');'."\n");
2976: }
2977: }
2978: $r->print('
2979: }
2980: function uncheckAllTools(formname) {
2981: ');
2982: foreach my $tool (sort(keys(%{$showboxes}))) {
2983: foreach my $priv (@{$$showboxes{$tool}}) {
2984: $r->print(' uncheckAll(formname'.$prefix.$priv.');'."\n");
2985: }
2986: }
2987: $r->print('
2988: }
2989: </script>
2990: ');
2991: }
2992: }
2993: }
2994: return $totalboxes;
2995: }
2996:
2997: sub member_privileges_form {
1.45 albertel 2998: my ($r,$action,$formname,$tools,$toolprivs,$fixedprivs,$userdata,
2999: $usertools,$idx,$memchg,$states,$stored,$gpterm) = @_;
1.5 raeburn 3000: my %lt = &Apache::lonlocal::texthash(
3001: 'addp' => 'Additional privileges',
1.53 raeburn 3002: 'fixp' => 'Core privileges',
1.5 raeburn 3003: 'oppr' => 'Optional privileges',
1.53 raeburn 3004: 'func' => 'Tool',
3005: 'forf' => 'For the collaborative tools included for group '.
3006: 'members being added or modified, '.
3007: 'there are no optional privileges to set '.
3008: 'for specific members.',
1.80 bisitz 3009: 'algr' => 'All new group members will receive the same privileges.',
3010: 'ifex' => 'If previously expired members are being re-enabled, or '.
1.54 raeburn 3011: 'if access for future members is being activated now, '.
3012: 'previously set privileges will be preserved.',
1.53 raeburn 3013: 'asno' => 'As no group members are being added, '.
3014: 'there are no specific user privileges to set.',
3015: 'asng' => 'As no group tools will be made available to users, '.
3016: 'there are no specific user privileges to set.',
3017: 'nogm' => 'No group member privileges to display or set, '.
3018: 'as you have not indicated that you will be activating,'.
3019: ' re-enabling, changing privileges, or adding/removing '.
3020: 'tools for any current members.',
1.5 raeburn 3021: 'full' => 'Fullname',
3022: 'user' => 'Username',
3023: 'doma' => 'Domain',
3024: );
3025: my @defprivs;
3026: my $specificity;
3027: if ($action eq 'create') {
3028: if (defined($env{'form.defpriv'})) {
3029: @defprivs = &Apache::loncommon::get_env_multiple('form.defpriv');
3030: }
3031: $specificity = $env{'form.specificity'};
3032: } else {
1.17 raeburn 3033: if (defined($$stored{'defpriv'})) {
3034: @defprivs = @{$$stored{'defpriv'}};
3035: }
1.5 raeburn 3036: $specificity = $$stored{'specificity'};
3037: }
3038: my @showtools;
3039: my %showboxes = ();
3040: my $numtools = 1 + @{$tools};
1.3 raeburn 3041:
1.6 raeburn 3042: my @excluded = ();
3043: my $numchgs = 0;
3044: if ($formname eq 'change_privs') {
3045: my @currmembers = ();
3046: if (ref($$memchg{'deletion'}) eq 'ARRAY') {
3047: push(@excluded,@{$$memchg{'deletion'}});
3048: }
3049: if (ref($$memchg{'expire'}) eq 'ARRAY') {
3050: push(@excluded,@{$$memchg{'expire'}});
3051: }
3052: if (@excluded > 0) {
3053: foreach my $user (sort(keys(%{$usertools}))) {
3054: if (grep/^$user$/,@excluded) {
3055: next;
3056: }
3057: push(@currmembers,$user);
3058: }
3059: } else {
3060: @currmembers = sort(keys(%{$usertools}));
3061: }
3062: $numchgs = @currmembers;
3063: if (!$numchgs) {
1.45 albertel 3064: $r->print($lt{'nogm'});
1.6 raeburn 3065: return $numchgs;
3066: }
3067: }
3068:
3069: my $totalboxes = &build_boxes($r,$tools,$usertools,$fixedprivs,
3070: $toolprivs,\@showtools,\%showboxes,
3071: 'userpriv_',$specificity,\@excluded);
1.5 raeburn 3072: if (@{$tools} > 0) {
3073: if ($specificity eq 'Yes') {
3074: if ($totalboxes > 0) {
3075: my $numcells = 2;
3076: my $colspan = $numcells + 1;
3077: my %total;
1.6 raeburn 3078: if (keys(%{$usertools}) > 1) {
3079: $r->print('
1.45 albertel 3080: <table border="0" cellspacing="2" cellpadding="2">
1.5 raeburn 3081: <tr>
3082: ');
1.6 raeburn 3083: foreach my $tool (@{$tools}) {
3084: if (@{$showboxes{$tool}} > 0) {
3085: $r->print('<td valign="top">');
1.100 bisitz 3086: $r->print('<fieldset><legend>'.&mt($tool).'</legend>');
3087: $r->print('<table><tr>');
1.6 raeburn 3088: my $privcount = 0;
3089: foreach my $priv (@{$showboxes{$tool}}) {
3090: $privcount ++;
3091: if (($privcount == @{$showboxes{$tool}}) &&
3092: ($privcount > 1)) {
3093: if ($privcount%$numcells) {
3094: $r->print('<td colspan="'.$colspan.'">');
3095: } else {
3096: $r->print('<td>');
3097: }
1.5 raeburn 3098: } else {
3099: $r->print('<td>');
3100: }
1.80 bisitz 3101: $r->print(
1.102 bisitz 3102: '<fieldset><legend>'.&mt($$toolprivs{$tool}{$priv}).'</legend>'
1.80 bisitz 3103: .'<span class="LC_nobreak">'
3104: .' <input type="button" value="'.&mt('check all').'"'
3105: .' onclick="javascript:checkAll(document.'.$formname.'.userpriv_'.$priv.')" />'
3106: .' '
3107: .'<input type="button" value="'.&mt('uncheck all').'"'
3108: .' onclick="javascript:uncheckAll(document.'.$formname.'.userpriv_'.$priv.')" />'
3109: .'</span></fieldset><br />'
3110: );
1.6 raeburn 3111: $r->print('</td>');
3112: if ($privcount < @{$showboxes{$tool}}) {
3113: if (@{$showboxes{$tool}} > 2) {
3114: if ($privcount%$numcells == 0) {
3115: $r->print('</tr><tr>');
3116: }
3117: } else {
3118: $r->print('<tr></tr>');
1.5 raeburn 3119: }
3120: }
3121: }
1.100 bisitz 3122: $r->print('</tr></table></fieldset></td><td> </td>');
1.5 raeburn 3123: }
3124: }
1.45 albertel 3125: $r->print('</tr></table>');
1.5 raeburn 3126: }
1.45 albertel 3127: $r->print(&Apache::loncommon::start_data_table().
3128: &Apache::loncommon::start_data_table_header_row());
1.5 raeburn 3129: $r->print(<<"END");
1.45 albertel 3130: <th>$lt{'full'}</th>
3131: <th>$lt{'user'}</th>
1.5 raeburn 3132: <th>$lt{'doma'}</th>
3133: <th colspan="$numtools">$lt{'addp'}</th>
3134: END
1.45 albertel 3135: $r->print(&Apache::loncommon::end_data_table_header_row());
3136: &member_privs_entries($r,$usertools,$toolprivs,$fixedprivs,
1.6 raeburn 3137: $userdata,$idx,\@showtools,\@defprivs,
3138: \@excluded);
1.45 albertel 3139: $r->print(&Apache::loncommon::end_data_table());
1.5 raeburn 3140: } else {
1.43 albertel 3141: $r->print($lt{'forf'}.'<br />');
1.45 albertel 3142: &display_defprivs($r,$tools,$toolprivs,\@defprivs);
1.5 raeburn 3143: }
3144: } else {
3145: if (keys(%{$usertools}) > 0) {
1.54 raeburn 3146: $r->print($lt{'algr'}.'<br />'.$lt{'ifex'}.'<br /><br />');
1.45 albertel 3147: &display_defprivs($r,$tools,$toolprivs,\@defprivs);
1.5 raeburn 3148: } else {
1.43 albertel 3149: $r->print($lt{'asno'}.'<br />');
1.5 raeburn 3150: }
3151: }
3152: } else {
1.43 albertel 3153: $r->print($lt{'asng'});
1.5 raeburn 3154: }
1.6 raeburn 3155: return $numchgs;
1.1 raeburn 3156: }
3157:
1.5 raeburn 3158: sub process_request {
1.45 albertel 3159: my ($r,$cdom,$cnum,$action,$state,$page,$groupname,$description,
1.5 raeburn 3160: $specificity,$userdata,$startdate,$enddate,$tools,$functions,$toolprivs,
3161: $usertools,$idx,$types,$roles,$sections,$states,$navbuttons,$memchg,
1.45 albertel 3162: $sectioncount,$stored,$gpterm,$ucgpterm,$crstype) = @_;
1.3 raeburn 3163:
3164: $r->print(&Apache::lonhtmlcommon::echo_form_input(
1.6 raeburn 3165: ['origin','action','state','page','sortby']));
1.5 raeburn 3166:
1.29 raeburn 3167: my $earlyout = &validate_groupname($groupname,$action,$cdom,$cnum,$gpterm,
3168: $ucgpterm,$crstype);
1.5 raeburn 3169: if ($earlyout) {
3170: $r->print('
3171: <table width="100%" cellpadding="0" cellspacing="0" border="0">
3172: <tr>
3173: <td> </td>
3174: <td colspan="3">
3175: '.$earlyout.'</td></tr>');
3176: &display_navbuttons($r,$state,$$states{$action}[$page-1],
3177: $$navbuttons{'gtps'});
3178: $r->print('</table>');
3179: return;
3180: }
3181:
3182: my @defprivs = ();
3183: if ($action eq 'create' || $state eq 'chgresult') {
3184: if (defined($env{'form.defpriv'})) {
3185: @defprivs = &Apache::loncommon::get_env_multiple('form.defpriv');
3186: }
3187: if ($state eq 'chgresult') {
3188: my @okprivs = ();
3189: foreach my $tool (@{$tools}) {
3190: foreach my $priv (sort(keys(%{$$toolprivs{$tool}}))) {
3191: push(@okprivs,$priv);
3192: }
3193: }
3194: my @temp = ();
3195: foreach my $defpriv (@defprivs) {
3196: if (grep/^$defpriv$/,@okprivs) {
3197: push(@temp,$defpriv);
3198: }
3199: }
3200: @defprivs = @temp;
3201: }
3202: } else {
1.17 raeburn 3203: if (defined($$stored{'defpriv'})) {
3204: @defprivs = @{$$stored{'defpriv'}};
3205: }
1.5 raeburn 3206: }
3207:
3208: my $outcome;
3209: if ($action eq 'create' || $state eq 'chgresult') {
3210: $outcome = &write_group_data($r,$cdom,$cnum,$action,$state,$groupname,
3211: $description,$startdate,$enddate,
3212: $specificity,$functions,$tools,
3213: $sectioncount,$roles,$types,$sections,
1.29 raeburn 3214: \@defprivs,$stored,$gpterm,$ucgpterm,
3215: $crstype);
1.5 raeburn 3216: }
3217: if (($action eq 'create' && $outcome eq 'ok') || (($action eq 'modify') &&
3218: (($state eq 'memresult') || ($state eq 'addresult')))) {
1.6 raeburn 3219: &process_membership($r,$cdom,$cnum,$action,$state,$groupname,$tools,
3220: $enddate,$startdate,$userdata,$idx,$toolprivs,
1.29 raeburn 3221: $usertools,$specificity,\@defprivs,$memchg,$gpterm,
1.104 raeburn 3222: $ucgpterm,$crstype);
1.5 raeburn 3223: }
3224: return;
3225: }
3226:
3227: sub write_group_data {
3228: my ($r,$cdom,$cnum,$action,$state,$groupname,$description,$startdate,
3229: $enddate,$specificity,$functions,$tools,$sectioncount,$roles,$types,
1.29 raeburn 3230: $sections,$defprivs,$stored,$gpterm,$ucgpterm,$crstype) = @_;
1.5 raeburn 3231: my $now = time;
3232: my $creation = $now;
3233: my $creator = $env{'user.name'}.':'.$env{'user.domain'};
3234: if ($state eq 'chgresult') {
3235: $creation = $$stored{'creation'};
3236: $creator = $$stored{'creator'};
3237: }
1.24 www 3238: my $esc_description = &escape($description);
1.5 raeburn 3239: my @single_attributes = ('description','functions','startdate','enddate',
3240: 'creation','modified','creator','granularity',
1.29 raeburn 3241: 'specificity','autoadd','autodrop','quota');
1.5 raeburn 3242: my @mult_attributes = ('roles','types','sectionpick','defpriv');
1.15 albertel 3243:
1.37 raeburn 3244: my ($crsquota,$freespace,$maxposs) = &get_quota_constraints($action,
3245: $stored);
3246: my $quota = $env{'form.quota'};
3247:
3248: $quota =~ s/^\s*([^\s]*)\s*$/$1/;
3249: if ($quota eq '') {
3250: $quota = 0;
3251: }
3252: if ($quota !~ /^\d*\.?\d*$/) {
3253: $quota = 0;
1.79 bisitz 3254: $r->print('<div class="LC_warning">'
1.96 weissno 3255: .&mt('The value you entered for the quota for the group portfolio in this '.$gpterm
1.122 raeburn 3256: .' contained invalid characters, so it has been set to 0 MB. You can change this by'
1.79 bisitz 3257: .' modifying the '.$gpterm.' settings.')
3258: .'</div>');
1.37 raeburn 3259: }
3260: if ($quota > $maxposs) {
3261: $quota = $maxposs;
1.79 bisitz 3262: $r->print('<div class="LC_warning">'
1.96 weissno 3263: .&mt('The value you entered for the quota for the group portfolio in this '.$gpterm
1.122 raeburn 3264: .' exceeded the maximum possible value, so it has been set to [_1] MB '
1.79 bisitz 3265: .'(the maximum possible value).',sprintf("%.2f",$maxposs))
3266: .'</div>');
1.37 raeburn 3267: }
1.5 raeburn 3268: my %groupinfo = (
3269: description => $esc_description,
3270: startdate => $startdate,
3271: enddate => $enddate,
3272: creation => $creation,
3273: modified => $now,
3274: creator => $creator,
3275: granularity => $env{'form.granularity'},
3276: specificity => $specificity,
3277: autoadd => $env{'form.autoadd'},
3278: autodrop => $env{'form.autodrop'},
1.37 raeburn 3279: quota => $quota,
1.5 raeburn 3280: );
1.37 raeburn 3281:
1.5 raeburn 3282: foreach my $func (keys(%{$functions})) {
3283: my $status;
3284: if (grep(/^$func$/,@{$tools})) {
3285: $status = 'on';
3286: } else {
3287: $status = 'off';
3288: }
3289: $groupinfo{'functions'} .= qq|<name id="$func">$status</name>|;
3290: }
3291:
3292: $groupinfo{'roles'} = $roles;
3293: $groupinfo{'types'} = $types;
3294: $groupinfo{'sectionpick'} = $sections;
3295: $groupinfo{'defpriv'} = $defprivs;
3296:
3297: my %groupsettings = ();
3298: foreach my $item (@single_attributes) {
3299: $groupsettings{$groupname} .= qq|<$item>$groupinfo{$item}</$item>|;
3300: }
3301: foreach my $item (@mult_attributes) {
3302: foreach my $entry (@{$groupinfo{$item}}) {
3303: $groupsettings{$groupname} .= qq|<$item>$entry</$item>|;
3304: }
3305: }
3306: my $autosec;
3307: my @autorole = &Apache::loncommon::get_env_multiple('form.autorole');
1.15 albertel 3308:
1.5 raeburn 3309: foreach my $role (@autorole) {
3310: if (defined($env{'form.sec_'.$role})) {
3311: my @autosections=&Apache::loncommon::get_env_multiple('form.sec_'.
3312: $role);
3313: $autosec .= '<role id="'.$role.'">';
3314: foreach my $sec (@autosections) {
3315: $autosec .= '<section>'.$sec.'</section>';
3316: }
3317: $autosec .= '</role>';
3318: }
3319: }
3320: if ($autosec) {
3321: $groupsettings{$groupname} .= qq|<autosec>$autosec</autosec>|;
3322: }
3323: my $result = &Apache::lonnet::modify_coursegroup($cdom,$cnum,
3324: \%groupsettings);
3325:
3326: if ($result eq 'ok') {
3327: if ($action eq 'create') {
1.32 raeburn 3328: my $result = &add_group_folder($cdom,$cnum,$now,$groupname,$action,
3329: $description,$tools,\%groupinfo,
3330: $gpterm,$ucgpterm,$crstype);
1.79 bisitz 3331: if ($result eq 'ok') {
1.109 wenzelju 3332: my $msg = &Apache::lonhtmlcommon::confirm_success(&mt($ucgpterm.' [_1] was created.','<i>'.$groupname.'</i>'));
3333: $msg = &Apache::loncommon::confirmwrapper($msg);
3334: $r->print($msg);
1.79 bisitz 3335: } else {
1.109 wenzelju 3336: my $msg = &Apache::lonhtmlcommon::confirm_success(&mt('A problem occurred when creating folders for the new '.$gpterm.' [_1]:'
3337: ,'<i>'.$groupname.'</i>')
3338: .'<br />'.$result,1);
3339: $msg = &Apache::loncommon::confirmwrapper($msg);
3340: $r->print($msg);
1.32 raeburn 3341: }
1.56 raeburn 3342: } elsif ($action eq 'modify') {
3343: my (@oldtools,@newtools);
3344: if (ref($$stored{'tool'}) eq 'ARRAY') {
3345: @oldtools = @{$$stored{'tool'}};
3346: }
3347: if (ref($tools) eq 'ARRAY') {
3348: @newtools = @{$tools};
3349: }
3350: if (!grep(/^discussion$/,@oldtools) &&
3351: grep(/^discussion$/,@newtools)) {
3352: my $crspath = '/uploaded/'.$cdom.'/'.$cnum.'/';
3353: my $boardsmap = $crspath.'group_boards_'.$groupname.'.sequence';
3354: my $navmap = Apache::lonnavmaps::navmap->new();
1.85 raeburn 3355: my ($bbmapres,$error);
3356: if (defined($navmap)) {
3357: $bbmapres = $navmap->getResourceByUrl($boardsmap);
3358: undef($navmap);
3359: if (!$bbmapres) {
3360: my $grpmap = $crspath.'group_folder_'.$groupname.'.sequence';
3361: my $disctitle = &mt('Discussion Boards');
3362: my $outcome = &map_updater($cdom,$cnum,'group_boards_'.
3363: $groupname.'.sequence','bbseq',
3364: $disctitle,$grpmap);
3365: my ($furl,$ferr) =
3366: &Apache::lonuserstate::readmap($cdom.'/'.$cnum);
3367: # modify parameter
3368: if ($outcome eq 'ok') {
3369: $navmap = Apache::lonnavmaps::navmap->new();
3370: if (defined($navmap)) {
3371: my $parm_result = &parm_setter($navmap,$cdom,$boardsmap,
3372: $groupname);
3373: if ($parm_result) {
3374: $error = &mt('An error occurred while setting parameters '
3375: .'for Discussion Boards folder: '
3376: .'[_1]',$parm_result);
3377: } else {
3378: $r->print('<div class="LC_success">'.
3379: &mt('Discussion Boards Folder created.')
3380: .'</div>');
3381: }
3382: undef($navmap);
3383: } else {
1.104 raeburn 3384: if ($crstype eq 'Community') {
3385: $error = &mt("An error occurred while setting parameters '.
1.85 raeburn 3386: 'for Discussion Boards folder: '.
1.104 raeburn 3387: 'Could not retrieve community information");
3388: } else {
3389: $error = &mt("An error occurred while setting parameters '.
3390: 'for Discussion Boards folder: '.
3391: 'Could not retrieve course information");
3392: }
1.85 raeburn 3393: }
1.56 raeburn 3394: } else {
1.85 raeburn 3395: $r->print($outcome);
1.56 raeburn 3396: }
3397: }
1.85 raeburn 3398: } else {
1.104 raeburn 3399: $error = &mt("An error occurred while retrieving the contents of the group's folder.").'<br />';
3400: if ($crstype eq 'Community') {
3401: $error .= &mt("You need to re-initialize the community.");
3402:
3403: } else {
3404: $error .= &mt("You need to re-initialize the course.");
3405: }
1.85 raeburn 3406: }
3407: if ($error ne '') {
3408: $r->print('<div class="LC_error">'.$error.'</div>');
1.56 raeburn 3409: }
3410: }
1.109 wenzelju 3411: my $message = &Apache::lonhtmlcommon::confirm_success(&mt($ucgpterm.' [_1] was updated.','<i>'.$groupname.'</i>'));
3412: $message = &Apache::loncommon::confirmwrapper($message);
3413: $r->print($message);
1.5 raeburn 3414: }
3415: } else {
3416: my %actiontype = (
3417: 'create' => 'creating',
3418: 'modify' => 'modifying',
3419: );
1.29 raeburn 3420: &Apache::lonnet::logthis("Failed to store $gpterm $groupname ".
3421: 'in '.lc($crstype).': '.$cnum.
3422: ' in domain: '.$cdom);
1.123 bisitz 3423: $r->print('<p class="LC_error">'
3424: .&mt('An error occurred when '.$actiontype{$action}.' the '.$gpterm.'. '
3425: .'Please try again.')
3426: .'</p');
1.5 raeburn 3427: }
3428: return $result;
3429: }
3430:
3431: sub process_membership {
1.6 raeburn 3432: my ($r,$cdom,$cnum,$action,$state,$groupname,$tools,$enddate,$startdate,
1.29 raeburn 3433: $userdata,$idx,$toolprivs,$usertools,$specificity,$defprivs,$memchg,
1.104 raeburn 3434: $gpterm,$ucgpterm,$crstype)=@_;
1.5 raeburn 3435: my %usersettings = ();
1.6 raeburn 3436: my %added= ();
3437: my %failed = ();
3438: my $num_ok = 0;
3439: my $num_fail = 0;
1.3 raeburn 3440: my %group_privs = ();
1.20 raeburn 3441: my %curr_privs = ();
1.21 raeburn 3442: my %curr_start = ();
3443: my %curr_end = ();
1.3 raeburn 3444: my %tooltype = ();
1.77 raeburn 3445: my $context = 'processgroupmembership';
1.5 raeburn 3446:
1.3 raeburn 3447: foreach my $tool (@{$tools}) {
3448: foreach my $priv (sort(keys(%{$$toolprivs{$tool}}))) {
3449: $tooltype{$priv} = $tool;
1.5 raeburn 3450: if ($specificity eq 'Yes') {
1.3 raeburn 3451: my @users =
3452: &Apache::loncommon::get_env_multiple('form.userpriv_'.$priv);
3453: foreach my $user (@users) {
3454: $group_privs{$user} .= $priv.':';
1.8 raeburn 3455: if ($state eq 'memresult') {
3456: unless (exists($$usertools{$user}{$tool})) {
3457: $$usertools{$user}{$tool} = 1;
3458: }
3459: }
1.3 raeburn 3460: }
3461: } else {
1.5 raeburn 3462: if (@{$defprivs} > 0) {
1.26 raeburn 3463: if (grep/^\Q$priv\E$/,@{$defprivs}) {
1.5 raeburn 3464: foreach my $user (sort(keys(%{$usertools}))) {
3465: if ($$usertools{$user}{$tool}) {
3466: $group_privs{$user} .= $priv.':';
3467: }
1.3 raeburn 3468: }
3469: }
3470: }
3471: }
3472: }
3473: }
3474: foreach my $user (keys(%group_privs)) {
3475: $group_privs{$user} =~ s/:$//;
3476: }
1.5 raeburn 3477:
1.6 raeburn 3478: my $now = time;
3479: my @activate = ();
3480: my @expire = ();
3481: my @deletion = ();
3482: my @reenable = ();
1.20 raeburn 3483: my @unchanged = ();
1.6 raeburn 3484: if ($state eq 'memresult') {
3485: if (ref($$memchg{'activate'}) eq 'ARRAY') {
3486: @activate = @{$$memchg{'activate'}};
3487: }
3488: if (ref($$memchg{'expire'}) eq 'ARRAY') {
3489: @expire = @{$$memchg{'expire'}};
3490: }
3491: if (ref($$memchg{'deletion'}) eq 'ARRAY') {
3492: @deletion = @{$$memchg{'deletion'}};
3493: }
3494: if (ref($$memchg{'reenable'}) eq 'ARRAY') {
3495: @reenable = @{$$memchg{'reenable'}};
3496: }
1.20 raeburn 3497: my %membership = &Apache::lonnet::get_group_membership($cdom,$cnum,
3498: $groupname);
3499: foreach my $key (sort(keys(%membership))) {
3500: if ($key =~ /^\Q$groupname\E:([^:]+:[^:]+)$/) {
1.21 raeburn 3501: ($curr_end{$1},$curr_start{$1},$curr_privs{$1}) =
3502: split(/:/,$membership{$key},3);
1.20 raeburn 3503: }
3504: }
1.6 raeburn 3505: if (@expire + @deletion > 0) {
3506: foreach my $user (@expire) {
1.21 raeburn 3507: my $savestart = $curr_start{$user};
3508: if ($savestart > $now) {
3509: $savestart = $now;
1.6 raeburn 3510: }
1.21 raeburn 3511: $usersettings{$groupname.':'.$user} = $now.':'.$savestart.':'.
3512: $curr_privs{$user};
1.6 raeburn 3513: if (&Apache::lonnet::modify_group_roles($cdom,$cnum,$groupname,
1.21 raeburn 3514: $user,$now,$savestart,
1.77 raeburn 3515: $curr_privs{$user},'',$context) eq 'ok') {
1.6 raeburn 3516: push(@{$added{'expired'}},$user);
3517: $num_ok ++;
3518: } else {
3519: push(@{$failed{'expired'}},$user);
3520: $num_fail ++;
3521: }
3522: }
3523: foreach my $user (@deletion) {
3524: $usersettings{$groupname.':'.$user} = $now.':-1:';
3525: if (&Apache::lonnet::modify_group_roles($cdom,$cnum,$groupname,
1.76 raeburn 3526: $user,$now,'-1','','',$context)
1.6 raeburn 3527: eq 'ok') {
3528: push(@{$added{'deleted'}},$user);
3529: $num_ok ++;
3530: } else {
3531: push(@{$failed{'deleted'}},$user);
3532: $num_fail ++;
3533: }
3534: }
3535: }
1.8 raeburn 3536: }
1.6 raeburn 3537:
1.5 raeburn 3538: foreach my $user (sort(keys(%{$usertools}))) {
1.20 raeburn 3539: if ((grep(/^$user$/,@expire)) || (grep(/^$user$/,@deletion))) {
3540: next;
3541: }
1.6 raeburn 3542: my $type;
3543: my $start = $startdate;
3544: my $end = $enddate;
3545: if ($state eq 'memresult') {
3546: if (@activate > 0) {
3547: if (grep/^$user$/,@activate) {
3548: $start = $now;
1.21 raeburn 3549: $end = $enddate;
1.6 raeburn 3550: $type = 'activated';
3551: }
3552: }
3553: if (@reenable > 0) {
3554: if (grep/^$user$/,@reenable) {
1.21 raeburn 3555: $start = $startdate;
3556: $end = $enddate;
1.125 bisitz 3557: $type = 're-enabled';
1.6 raeburn 3558: }
3559: }
1.38 raeburn 3560: if ($type eq '') {
3561: if ($curr_privs{$user} eq $group_privs{$user}) {
3562: push(@unchanged,$user);
3563: next;
3564: }
3565: if (exists($curr_start{$user})) {
3566: $start = $curr_start{$user};
3567: }
3568: if (exists($curr_end{$user})) {
3569: $end = $curr_end{$user};
3570: }
3571: $type = 'modified';
3572: }
1.6 raeburn 3573: } else {
3574: $type = 'added';
3575: }
3576: $usersettings{$groupname.':'.$user} = $end.':'.$start.':'.
1.5 raeburn 3577: $group_privs{$user};
3578: if (&Apache::lonnet::modify_group_roles($cdom,$cnum,$groupname,
1.6 raeburn 3579: $user,$end,$start,
1.76 raeburn 3580: $group_privs{$user},'',$context) eq 'ok') {
1.6 raeburn 3581: push(@{$added{$type}},$user);
3582: $num_ok ++;
1.3 raeburn 3583: } else {
1.6 raeburn 3584: push(@{$failed{$type}},$user);
3585: $num_fail ++;
1.5 raeburn 3586: }
3587: }
3588: my $roster_result = &Apache::lonnet::modify_coursegroup_membership($cdom,
3589: $cnum,\%usersettings);
1.6 raeburn 3590: if ($num_ok) {
1.109 wenzelju 3591: my $msgall ='';
3592: foreach my $type (sort(keys(%added))) {
1.123 bisitz 3593: my $message;
3594: my $tmsg = "The following users were successfully $type";
1.20 raeburn 3595: if (!($type eq 'deleted' || $type eq 'expired')) {
1.123 bisitz 3596: $tmsg .= ' with the following privileges';
1.6 raeburn 3597: }
1.123 bisitz 3598: $message .= &mt($tmsg.':').'<br/>';
1.6 raeburn 3599: foreach my $user (@{$added{$type}}) {
1.8 raeburn 3600: my $privlist = '';
3601: if (!($type eq 'deleted' || $type eq 'expired')) {
3602: $privlist = ': ';
1.6 raeburn 3603: my @privs = split(/:/,$group_privs{$user});
3604: my $curr_tool = '';
3605: foreach my $priv (@privs) {
3606: unless ($curr_tool eq $tooltype{$priv}) {
3607: $curr_tool = $tooltype{$priv};
3608: $privlist .= '<b>'.$curr_tool.'</b>: ';
3609: }
3610: $privlist .= $$toolprivs{$curr_tool}{$priv}.', ';
3611: }
3612: $privlist =~ s/, $//;
3613: }
1.109 wenzelju 3614: $message .= $$userdata{$user}[$$idx{fullname}].' - '.$user.$privlist.'<br />';
1.6 raeburn 3615: }
1.109 wenzelju 3616: $message .= '<br/>';
3617: $message = &Apache::lonhtmlcommon::confirm_success($message);
3618: $msgall .= $message;
1.6 raeburn 3619: }
1.109 wenzelju 3620: $msgall = &Apache::loncommon::confirmwrapper($msgall);
3621: $r->print($msgall);
1.6 raeburn 3622: }
3623: if ($num_fail) {
3624: foreach my $type (sort(keys(%failed))) {
1.79 bisitz 3625: $r->print('<div class="LC_error">'
3626: .&mt("The following users could not be $type, because an error occurred:")
3627: .'</div>');
1.6 raeburn 3628: foreach my $user (@{$failed{$type}}) {
3629: $r->print($$userdata{$user}[$$idx{fullname}].' - '.$user.'<br />');
3630: }
1.5 raeburn 3631: }
1.20 raeburn 3632: $r->print('<br />');
3633: }
1.109 wenzelju 3634: # Is that really needed?
3635: #
3636: # if (@unchanged > 0) {
3637: # $r->print(&mt('No change occurred for the following users:').'<br />');
3638: # foreach my $user (sort(@unchanged)) {
3639: # $r->print($$userdata{$user}[$$idx{fullname}].' - '.$user.'<br />');
3640: # }
3641: # $r->print('<br />');
3642: # }
1.5 raeburn 3643: if ($roster_result eq 'ok') {
1.80 bisitz 3644: $r->print('<div class="LC_success">'
3645: .&mt($ucgpterm.' membership list updated.')
3646: .'</div>');
1.104 raeburn 3647: $r->print('<p class="LC_info">');
3648: if ($crstype eq 'Community') {
3649: $r->print(&mt("Any currently logged in community users affected by the changes you made"
1.80 bisitz 3650: .' to group membership or privileges for the [_1] group will need to log out'
3651: .' and log back in for their LON-CAPA sessions to reflect these changes.'
1.104 raeburn 3652: ,'<i>'.$groupname.'</i>'));
3653:
3654: } else {
3655: $r->print(&mt("Any currently logged in course users affected by the changes you made"
3656: .' to group membership or privileges for the [_1] group will need to log out'
3657: .' and log back in for their LON-CAPA sessions to reflect these changes.'
3658: ,'<i>'.$groupname.'</i>'));
3659: }
3660: $r->print('</p>');
1.5 raeburn 3661: } else {
1.80 bisitz 3662: $r->print('<div class="LC_error">'
3663: .&mt("An error occurred while updating the $gpterm membership list:")
3664: .'<br />'.$roster_result
3665: .'</div>');
1.5 raeburn 3666: }
3667: return;
3668: }
3669:
3670: sub mapping_options {
1.44 albertel 3671: my ($r,$action,$formname,$page,$sectioncount,$states,$stored,
1.58 raeburn 3672: $navbuttons,$img1,$img2,$gpterm,$ucgpterm,$crstype,$cdom,$cnum) = @_;
1.5 raeburn 3673: my %lt = &Apache::lonlocal::texthash(
1.29 raeburn 3674: 'auto' => "Settings for automatic $gpterm enrollment",
3675: 'gmma' => "$ucgpterm membership mapping to specific sections/roles",
3676: 'endi' => "Enable/disable automatic $gpterm enrollment for ".
3677: "users in specified roles and sections",
1.53 raeburn 3678: 'adds' => "If automatic $gpterm enrollment is enabled, when a user is newly assigned a ".lc($crstype)."-wide or section-specific role, he/she will automatically be added as a member of the $gpterm, with start and end access dates defined by the default dates set for the $gpterm, unless he/she is already a $gpterm member, with access dates that permit either current or future $gpterm access.",
1.29 raeburn 3679: 'drops' => "If automatic $gpterm disenrollment is enabled, when a user's role is expired, access to the $gpterm will be terminated unless the user continues to have other ".lc($crstype)."-wide or section-specific active or future roles which receive automatic membership in the $gpterm.",
3680: 'pirs' => "Pick roles and sections for automatic $gpterm enrollment",
1.5 raeburn 3681: 'on' => 'on',
3682: 'off' => 'off',
1.29 raeburn 3683: 'auad' => "Automatically enable $gpterm membership when roles are added?",
3684: 'auex' => "Automatically expire $gpterm membership when roles are removed?",
3685: 'mapr' => "Mapping of roles and sections affected by automatic $gpterm enrollment/disenrollment follows scheme chosen below.",
1.5 raeburn 3686: );
1.44 albertel 3687: &automapping($r,$action,$stored,\%lt,$img1);
1.58 raeburn 3688: &mapping_settings($r,$sectioncount,\%lt,$stored,$img2,$crstype,$cdom,$cnum,
3689: $action);
1.5 raeburn 3690: return;
3691: }
3692:
3693: sub automapping {
1.44 albertel 3694: my ($r,$action,$stored,$lt,$image) = @_;
1.5 raeburn 3695: my $add = 'off';
3696: my $drop = 'off';
3697: if (exists($$stored{'autoadd'})) {
3698: $add = $$stored{'autoadd'};
3699: }
3700: if (exists($$stored{'autodrop'})) {
3701: $drop = $$stored{'autodrop'};
3702: }
1.78 raeburn 3703: $r->print(&Apache::lonhtmlcommon::topic_bar($image,$$lt{'endi'}).'
1.44 albertel 3704: <b>'.$$lt{'gmma'}.':</b><br />'.$$lt{'adds'}.'<br />'.$$lt{'drops'}.'<br /><br />
1.83 bisitz 3705: <span class="LC_nobreak">'.$$lt{'auad'}.':
1.80 bisitz 3706: <label><input type="radio" name="autoadd" value="on" />'.&mt('on').' </label><label><input type="radio" name="autoadd" value="off" checked="checked" />'.&mt('off').'</label>');
1.5 raeburn 3707: if ($action eq 'modify') {
1.82 bisitz 3708: $r->print(' ('.&mt('Currently set to [_1].','<b>'.$$lt{$add}.'</b>').')');
1.5 raeburn 3709: }
3710: $r->print('
1.83 bisitz 3711: </span><br />
3712: <span class="LC_nobreak">'.$$lt{'auex'}.':
1.80 bisitz 3713: <label><input type="radio" name="autodrop" value="on" />'.&mt('on').' </label><label><input type="radio" name="autodrop" value="off" checked="checked" />'.&mt('off').'</label>');
1.5 raeburn 3714: if ($action eq 'modify') {
1.82 bisitz 3715: $r->print(' ('.&mt('Currently set to [_1].','<b>'.$$lt{$drop}.'</b>').')');
1.3 raeburn 3716: }
1.83 bisitz 3717: $r->print('</span><br /><br />'.$$lt{'mapr'});
1.5 raeburn 3718: }
1.3 raeburn 3719:
1.5 raeburn 3720: sub mapping_settings {
1.58 raeburn 3721: my ($r,$sectioncount,$lt,$stored,$image,$crstype,$cdom,$cnum,$action) = @_;
1.5 raeburn 3722: my @sections = keys(%{$sectioncount});
3723: if (@sections > 0) {
3724: @sections = sort {$a cmp $b} @sections;
1.17 raeburn 3725: unshift(@sections,'none'); # Put 'no sections' next
3726: unshift(@sections,'all'); # Put 'all' at the front of the list
1.53 raeburn 3727: } else {
3728: @sections = ('all','none');
1.3 raeburn 3729: }
1.78 raeburn 3730: $r->print(&Apache::lonhtmlcommon::topic_bar($image,$$lt{'pirs'}));
1.104 raeburn 3731: my @roles = &standard_roles($crstype);
1.59 raeburn 3732: my %customroles = &Apache::lonhtmlcommon::course_custom_roles($cdom,$cnum);
1.44 albertel 3733: $r->print(&Apache::loncommon::start_data_table().
3734: &Apache::loncommon::start_data_table_header_row());
1.5 raeburn 3735: $r->print('
3736: <th>'.&mt('Active?').'</th>
3737: <th>'.&mt('Role').'</th>');
3738: if (@sections > 0) {
1.44 albertel 3739: $r->print('<th>'.&mt('Sections').'</th>');
1.3 raeburn 3740: }
1.44 albertel 3741: $r->print(&Apache::loncommon::end_data_table_header_row()."\n");
1.5 raeburn 3742: foreach my $role (@roles) {
1.58 raeburn 3743: my $roletitle=&Apache::lonnet::plaintext($role,$crstype);
3744: $r->print(&print_autorole_item($role,$roletitle,\@sections));
1.5 raeburn 3745: }
1.58 raeburn 3746: my @customs;
1.5 raeburn 3747: foreach my $role (sort(keys(%customroles))) {
1.58 raeburn 3748: my ($roletitle) = ($role =~ m|^cr/[^/]+/[^/]+/(.+)$|);
3749: push (@customs,$role);
3750: $r->print(&print_autorole_item($role,$roletitle,\@sections));
3751: }
3752: if ($action eq 'modify') {
3753: foreach my $role (@{$$stored{'autorole'}}) {
3754: if ((!grep(/^\Q$role\E$/,@customs)) &&
3755: (!grep(/^\Q$role\E$/,@roles))) {
3756: my $roletitle;
3757: if ($role =~ /^cr/) {
3758: ($roletitle) = ($role =~ m|_([^_]+)$|);
3759: } else {
3760: $roletitle = &Apache::lonnet::plaintext($role,$crstype);
3761: }
3762: $r->print(&print_autorole_item($role,$roletitle,\@sections));
3763: }
3764: }
1.5 raeburn 3765: }
1.44 albertel 3766: $r->print(&Apache::loncommon::end_data_table());
1.5 raeburn 3767: return;
3768: }
1.3 raeburn 3769:
1.58 raeburn 3770: sub print_autorole_item {
3771: my ($role,$roletitle,$sections) = @_;
3772: my $sections_sel;
3773: if (@{$sections} > 0) {
1.104 raeburn 3774: if (($role eq 'cc') || ($role eq 'co')) {
1.58 raeburn 3775: $sections_sel = '<td align="right">'.
3776: &mt('all sections').'<input type="hidden" '.
1.104 raeburn 3777: 'name="sec_'.$role.'" value="all" /></td>';
1.58 raeburn 3778: } else {
3779: $sections_sel='<td align="right">'.
3780: §ions_selection($sections,'sec_'.$role).
3781: '</td>';
3782: }
3783: }
3784: my $output = &Apache::loncommon::start_data_table_row().
3785: '<td><input type="checkbox" '.
3786: 'name="autorole" value="'.$role.'" />'.
3787: '</td><td>'.$roletitle.'</td>'.$sections_sel.
3788: &Apache::loncommon::end_data_table_row();
3789: return $output;
3790: }
3791:
1.5 raeburn 3792: sub standard_roles {
1.104 raeburn 3793: my ($crstype) = @_;
3794: my @roles = qw(in ta ep ad st);
3795: if ($crstype eq 'Community') {
3796: unshift(@roles,'co');
3797: } else {
3798: unshift(@roles,'cc');
3799: }
1.5 raeburn 3800: return @roles;
3801: }
3802:
3803: sub modify_menu {
1.29 raeburn 3804: my ($r,$groupname,$page,$gpterm) = @_;
1.5 raeburn 3805: my @menu =
1.106 wenzelju 3806: ( { categorytitle =>'Group Actions',
3807: items => [
3808:
3809: { linktext => "Modify default $gpterm settings",
1.130 raeburn 3810: url => '/adm/coursegroups?action=modify&refpage='.$env{'form.refpage'}.'&groupname='.$groupname.'&state=change_settings&branch=settings',
1.106 wenzelju 3811: icon => 'grp_settings.png',
3812: alttext => "Modify default $gpterm settings",
3813: permission => '1',
3814: help => 'Course_Modify_Group',
1.5 raeburn 3815: },
1.106 wenzelju 3816: { linktext => 'Modify access, tools and privileges for members',
1.130 raeburn 3817: url => '/adm/coursegroups?action=modify&refpage='.$env{'form.refpage'}.'&groupname='.$groupname.'&state=change_members&branch=members',
1.106 wenzelju 3818: icon => 'grp_tools.png',
3819: alttext => 'Modify access, tools and privileges for members',
3820: permission => '1',
1.5 raeburn 3821: help => 'Course_Modify_Group_Membership',
3822: },
1.106 wenzelju 3823: { linktext => "Add member(s) to the $gpterm",
1.130 raeburn 3824: url => '/adm/coursegroups?action=modify&refpage='.$env{'form.refpage'}.'&groupname='.$groupname.'&state=add_members&branch=adds',
1.106 wenzelju 3825: icon => 'grp_add.png',
3826: alttext => "Add member(s) to the $gpterm",
3827: permission => '1',
1.5 raeburn 3828: help => 'Course_Group_Add_Members',
1.106 wenzelju 3829: }]}
3830: );
3831: $r->print(&Apache::lonhtmlcommon::generate_menu(@menu));
1.3 raeburn 3832: return;
3833: }
3834:
3835: sub member_privs_entries {
1.45 albertel 3836: my ($r,$usertools,$toolprivs,$fixedprivs,$userdata,$idx,$showtools,
3837: $defprivs,$excluded) = @_;
1.5 raeburn 3838: foreach my $user (sort(keys(%{$usertools}))) {
1.6 raeburn 3839: if (defined($excluded)) {
3840: if (ref($excluded) eq 'ARRAY') {
3841: if (grep/^$user$/,@{$excluded}) {
3842: next;
3843: }
3844: }
3845: }
1.5 raeburn 3846: my ($uname,$udom) = split(/:/,$user);
1.45 albertel 3847: $r->print(&Apache::loncommon::start_data_table_row().'
1.5 raeburn 3848: <td>'.$$userdata{$user}[$$idx{fullname}].'</td>
1.3 raeburn 3849: <td>'.$uname.'</td>
3850: <td>'.$udom.'</td>
1.53 raeburn 3851: <td valign="top">
3852: <table>
3853: <tr>
3854: <td><b>'.
3855: &mt('Collaborative Tool').'</b></td>
3856: </tr>
3857: <tr>
3858: <td><b>'.&mt('Fixed').'</b></td>
3859: </tr>
3860: <tr>
3861: <td><b>'.&mt('Optional').'</b></td>
3862: </tr>
3863: </table>
3864: </td>');
1.5 raeburn 3865: foreach my $tool (@{$showtools}) {
3866: if (exists($$usertools{$user}{$tool})) {
1.45 albertel 3867: $r->print('<td valign="top"><table><tr><th colspan="2">'.$tool.'</th></tr>');
1.3 raeburn 3868: my $privcount = 0;
3869: my $fixed = '';
3870: my $dynamic = '';
3871: foreach my $priv (sort(keys(%{$$toolprivs{$tool}}))) {
3872: if (exists($$fixedprivs{$tool}{$priv})) {
1.5 raeburn 3873: $fixed .= '<input type="hidden" name="userpriv_'.$priv.'" value="'.$user.'" />'.$$toolprivs{$tool}{$priv}.' ';
1.3 raeburn 3874: } else {
3875: $privcount ++;
3876: if ($privcount == 3) {
3877: $dynamic .= '</tr><tr>';
3878: }
1.83 bisitz 3879: $dynamic .='<td><span class="LC_nobreak"><label><input type="checkbox" '.
1.5 raeburn 3880: 'name="userpriv_'.$priv.'" value="'.$user.'"';
3881: if (grep/^\Q$priv\E$/,@{$defprivs}) {
3882: $dynamic .= ' checked="checked" ';
3883: }
3884: $dynamic .= ' />'.$$toolprivs{$tool}{$priv}.
1.83 bisitz 3885: '</label></span></td>';
1.3 raeburn 3886: }
3887: }
1.83 bisitz 3888: $r->print('<tr><td colspan="2"><span class="LC_nobreak">'.$fixed.'</span></td></tr><tr>'.$dynamic.'</tr></table></td>');
1.3 raeburn 3889: } else {
1.45 albertel 3890: $r->print('<td valign="top"><table width="100%"><tr><th colspan="2">'.$tool.'</th></tr><tr><td> </td></tr><tr><td> </td></tr></table></td>');
1.3 raeburn 3891: }
3892: }
1.45 albertel 3893: $r->print(&Apache::loncommon::end_data_table_row());
1.3 raeburn 3894: }
3895: }
3896:
3897: sub get_dates_from_form {
3898: my $startdate;
3899: my $enddate;
3900: $startdate = &Apache::lonhtmlcommon::get_date_from_form('startdate');
3901: $enddate = &Apache::lonhtmlcommon::get_date_from_form('enddate');
3902: if ( exists ($env{'form.no_end_date'}) ) {
3903: $enddate = 0;
3904: }
3905: return ($startdate,$enddate);
1.5 raeburn 3906: }
3907:
1.3 raeburn 3908: sub date_setting_table {
3909: my ($starttime,$endtime,$formname) = @_;
3910: my $startform = &Apache::lonhtmlcommon::date_setter($formname,
3911: 'startdate',$starttime);
3912: my $endform = &Apache::lonhtmlcommon::date_setter($formname,
3913: 'enddate',$endtime);
1.98 bisitz 3914: my $perpetual = ' <span class="LC_nobreak"><label>'
3915: .'<input type="checkbox" name="no_end_date" />'
3916: .&mt('No end date')
3917: .'</label></span>';
3918: my $table = &Apache::lonhtmlcommon::start_pick_box()
3919: .&Apache::lonhtmlcommon::row_title(&mt('Start Date'))
3920: .$startform
3921: .&Apache::lonhtmlcommon::row_closure()
3922: .&Apache::lonhtmlcommon::row_title(&mt('End Date'))
3923: .$endform
3924: .$perpetual
3925: .&Apache::lonhtmlcommon::row_closure(1)
3926: .&Apache::lonhtmlcommon::end_pick_box();
1.41 albertel 3927: return $table;
1.1 raeburn 3928: }
3929:
1.32 raeburn 3930: sub add_group_folder {
3931: my ($cdom,$cnum,$now,$groupname,$action,$description,$tools,$groupinfo,
3932: $gpterm,$ucgpterm,$crstype) = @_;
3933: if ($cdom eq '' || $cnum eq '') {
1.104 raeburn 3934: my $error = '<span class="LC_error">';
3935: if ($crstype eq 'Community') {
3936: $error .= &mt("Error: invalid community domain or number - group folder creation failed.");
3937: } else {
3938: $error .= &mt("Error: invalid course domain or number - group folder creation failed.");
3939: }
3940: $error .= '</span>';
3941: return $error;
1.32 raeburn 3942: }
1.67 raeburn 3943: my ($outcome,$allgrpsmap,$grpmap,$boardsmap,$grppage,$warning);
1.32 raeburn 3944: my $crspath = '/uploaded/'.$cdom.'/'.$cnum.'/';
1.47 raeburn 3945: $allgrpsmap = $crspath.'group_allfolders.sequence';
1.32 raeburn 3946: if ($action eq 'create') {
1.67 raeburn 3947: if (&get_folder_lock($cdom,$cnum,'group_allfolders',$now) eq 'ok') {
3948: # check if group_allfolders.sequence exists.
1.69 raeburn 3949: my $mapcontents = &Apache::lonnet::getfile($allgrpsmap);
3950: if ($mapcontents eq '-1') { #file does not exist;
1.80 bisitz 3951: my $grpstitle = &mt("$crstype $ucgpterm".'s');
1.67 raeburn 3952: my $topmap_url = '/'.$env{'course.'.$env{'request.course.id'}.'.url'};
3953: $topmap_url =~ s|/+|/|g;
3954: if ($topmap_url =~ m|^/uploaded|) {
3955: $outcome = &map_updater($cdom,$cnum,'group_allfolders.sequence',
3956: 'toplevelgroup',$grpstitle,$topmap_url);
3957: } else {
1.80 bisitz 3958: $outcome = '<span class="LC_warning">'
3959: .&mt('Non-standard course - folder for all groups not added.')
3960: .'</span>';
1.67 raeburn 3961: }
1.32 raeburn 3962: if ($outcome ne 'ok') {
1.67 raeburn 3963: my $delresult = &release_folder_lock($cdom,$cnum,'group_allfolders');
3964: if ($delresult ne 'ok') {
3965: $warning = $delresult;
3966: }
1.84 raeburn 3967: return $outcome.$warning;
1.32 raeburn 3968: }
3969: }
1.67 raeburn 3970: my $delresult = &release_folder_lock($cdom,$cnum,'group_allfolders');
3971: if ($delresult ne 'ok') {
3972: $warning = $delresult ;
3973: }
3974: } else {
1.80 bisitz 3975: $outcome = '<span class="LC_error">'
3976: .&mt('Could not obtain exclusive lock to check status of the folder for all groups. No group folder added.')
1.84 raeburn 3977: .'</span>';
1.67 raeburn 3978: return $outcome;
1.32 raeburn 3979: }
1.75 bisitz 3980: my $grpfolder = &mt($ucgpterm.' Folder - [_1]',$description);
1.49 raeburn 3981: $grppage='/adm/'.$cdom.'/'.$cnum.'/'.$groupname.'/smppg';
1.75 bisitz 3982: my $grptitle = &mt('Group homepage - [_1]',$description);
1.55 raeburn 3983: my ($discussions,$disctitle);
1.47 raeburn 3984: my $outcome = &map_updater($cdom,$cnum,'group_folder_'.$groupname.'.sequence',
1.32 raeburn 3985: 'grpseq',$grpfolder,$allgrpsmap,$grppage,
3986: $grptitle);
3987: if ($outcome ne 'ok') {
1.67 raeburn 3988: return $outcome.$warning;
1.32 raeburn 3989: }
3990: my $pageout = &create_homepage($cdom,$cnum,$groupname,$groupinfo,
3991: $tools,$gpterm,$ucgpterm,$now);
3992: # Link to folder for bulletin boards
1.47 raeburn 3993: $grpmap = $crspath.'group_folder_'.$groupname.'.sequence';
1.32 raeburn 3994: if (grep/^discussion$/,@{$tools}) {
3995: $disctitle = &mt('Discussion Boards');
1.47 raeburn 3996: my $outcome = &map_updater($cdom,$cnum,'group_boards_'.$groupname.
1.32 raeburn 3997: '.sequence','bbseq',$disctitle,$grpmap);
3998: if ($outcome ne 'ok') {
1.67 raeburn 3999: return $outcome.$warning;
1.32 raeburn 4000: }
1.47 raeburn 4001: $boardsmap = $crspath.'group_boards_'.$groupname.'.sequence';
1.32 raeburn 4002: }
4003: } else {
4004: #modify group folder if status of discussions tools is changed
4005: }
4006: my ($furl,$ferr)= &Apache::lonuserstate::readmap($cdom.'/'.$cnum);
1.67 raeburn 4007: my $navmap = Apache::lonnavmaps::navmap->new();
1.85 raeburn 4008: if (!defined($navmap)) {
1.104 raeburn 4009: $warning .= '<span class="LC_error">';
4010: if ($crstype eq 'Community') {
4011: $warning .= &mt("Error retrieving community contents").
4012: ' '.&mt("You need to re-initialize the community.");
4013: } else {
4014: $warning .= &mt("Error retrieving course contents").
4015: ' '.&mt("You need to re-initialize the course.");
4016: }
4017: $warning .= '</span>';
4018: return $warning;
1.85 raeburn 4019: }
1.32 raeburn 4020: # modify parameters
4021: my $parm_result;
4022: if ($action eq 'create') {
4023: if ($grpmap) {
4024: $parm_result .= &parm_setter($navmap,$cdom,$grpmap,$groupname);
4025: }
4026: if ($grppage) {
4027: $parm_result .= &parm_setter($navmap,$cdom,$grppage,$groupname);
4028: }
4029: if ($boardsmap) {
4030: $parm_result .= &parm_setter($navmap,$cdom,$boardsmap,$groupname);
4031: }
4032: }
1.67 raeburn 4033: undef($navmap);
1.32 raeburn 4034: if ($parm_result) {
1.67 raeburn 4035: return $warning.$parm_result;
4036: } else {
4037: return 'ok';
4038: }
4039: }
4040:
4041: sub get_folder_lock {
4042: my ($cdom,$cnum,$folder_name,$now) = @_;
4043: # get lock for folder being edited.
4044: my $lockhash = {
4045: $folder_name."\0".'locked_folder' => $now.':'.$env{'user.name'}.
4046: ':'.$env{'user.domain'},
4047: };
4048: my $tries = 0;
4049: my $gotlock = &Apache::lonnet::newput('coursegroups',$lockhash,$cdom,$cnum);
4050:
4051: while (($gotlock ne 'ok') && $tries <3) {
4052: $tries ++;
1.68 albertel 4053: sleep(1);
1.67 raeburn 4054: $gotlock = &Apache::lonnet::newput('coursegroups',$lockhash,$cdom,$cnum);
4055: }
4056: return $gotlock;
4057: }
4058:
4059: sub release_folder_lock {
4060: my ($cdom,$cnum,$folder_name) = @_;
4061: # remove lock
4062: my @del_lock = ($folder_name."\0".'locked_folder');
4063: my $dellockoutcome=&Apache::lonnet::del('coursegroups',\@del_lock,$cdom,$cnum);
4064: if ($dellockoutcome ne 'ok') {
1.80 bisitz 4065: return ('<div class="LC_error">'
4066: .&mt('Warning: failed to release lock for folder: [_1].','<tt>'.$folder_name.'</tt>')
4067: .'</div>'
4068: );
1.32 raeburn 4069: } else {
4070: return 'ok';
4071: }
4072: }
4073:
4074: sub map_updater {
4075: my ($cdom,$cnum,$newfile,$itemname,$itemtitle,$parentmap,$startsrc,
4076: $starttitle,$endsrc,$endtitle) = @_;
4077: my $outcome;
4078: $env{'form.'.$itemname} = &new_map($startsrc,$starttitle,$endsrc,
4079: $endtitle);
4080: my $newmapurl=&Apache::lonnet::finishuserfileupload($cnum,$cdom,$itemname,
4081: $newfile);
4082: if ($newmapurl !~ m|^/uploaded|) {
1.80 bisitz 4083: $outcome = '<div class="LC_error">'
4084: .&mt('Error uploading new folder.')." ($newfile): $newmapurl"
4085: .'</div>';
1.32 raeburn 4086: return $outcome;
1.67 raeburn 4087: }
1.63 albertel 4088: my ($errtext,$fatal)=&LONCAPA::map::mapread($parentmap);
1.32 raeburn 4089: if ($fatal) {
1.80 bisitz 4090: $outcome = '<div class="LC_error">'
4091: .&mt('Error reading contents of parent folder.')." ($parentmap): $errtext"
4092: .'</div>';
1.32 raeburn 4093: return $outcome;
4094: } else {
1.63 albertel 4095: my $newidx=&LONCAPA::map::getresidx($newmapurl);
4096: $LONCAPA::map::resources[$newidx] = $itemtitle.':'.$newmapurl.
1.32 raeburn 4097: ':false:normal:res';
1.63 albertel 4098: $LONCAPA::map::order[1+$#LONCAPA::map::order]=$newidx;
1.114 raeburn 4099: my ($outtext,$errtext) = &LONCAPA::map::storemap($parentmap,1,1);
1.67 raeburn 4100: if ($errtext) {
1.80 bisitz 4101: $outcome = '<div class="LC_error">'
4102: .&mt('Error saving updated parent folder.')." ($parentmap): $errtext"
4103: .'</div>';
1.32 raeburn 4104: return $outcome;
4105: }
4106: }
4107: return 'ok';
4108: }
4109:
4110: sub new_map {
4111: my ($startsrc,$starttitle,$endsrc,$endtitle) = @_;
4112: my $newmapstr = '
4113: <map>
4114: <resource id="1" src="'.$startsrc.'" type="start" title="'.$starttitle.'"></resource>
4115: <link from="1" to="2" index="1"></link>
4116: <resource id="2" src="'.$endsrc.'" type="finish" title="'.$endtitle.'"></resource>
4117: </map>
4118: ';
4119: return $newmapstr;
4120: }
4121:
4122: sub parm_setter {
1.104 raeburn 4123: my ($navmap,$cdom,$url,$groupname,$crstype) = @_;
1.85 raeburn 4124: if (!defined($navmap)) {
1.104 raeburn 4125: my $allresults;
4126: if ($crstype eq 'Community') {
4127: $allresults = &mt("Parameters not set for [_1] because the contents of the community could not be retrieved.",$url).' '.
4128: &mt("You need to reinitialize the community.");
4129: } else {
4130: $allresults = &mt("Parameters not set for [_1] because the contents of the course could not be retrieved.",$url).' '.
4131: &mt("You need to reinitialize the course.");
4132:
4133: }
4134: return '<div class="LC_warning">'.$allresults.'</div>';
1.85 raeburn 4135: }
1.32 raeburn 4136: my %hide_settings = (
4137: 'course' => {
4138: 'num' => 13,
4139: 'set' => 'yes',
4140: },
4141: 'group' => {
4142: 'num' => 5,
4143: 'set' => 'no',
4144: 'extra' => $groupname,
4145: },
4146: );
4147: my $res = $navmap->getResourceByUrl($url);
1.104 raeburn 4148: my $allresults;
1.67 raeburn 4149: if ($res) {
4150: my $symb = $res->symb();
4151: foreach my $level (keys(%hide_settings)) {
4152: my $parmresult =
4153: &Apache::lonparmset::storeparm_by_symb($symb,
1.32 raeburn 4154: '0_hiddenresource',
4155: $hide_settings{$level}{'num'},
4156: $hide_settings{$level}{'set'},
4157: 'string_yesno',undef,$cdom,
4158: undef,undef,
4159: $hide_settings{$level}{'extra'});
1.67 raeburn 4160: if ($parmresult) {
4161: $allresults .= $level.': '.$parmresult;
4162: }
1.37 raeburn 4163: }
1.67 raeburn 4164: } else {
1.104 raeburn 4165: $allresults = '<div class="LC_warning">';
4166: if ($crstype eq 'Community') {
4167: $allresults .= &mt("Parameters not set for [_1] because the resource was not recognized as part of the community.",'<tt>'.$url.'</tt>');
4168: } else {
4169: $allresults .= &mt('Parameters not set for [_1] because the resource was not recognized as part of the course.','<tt>'.$url.'</tt>');
4170: }
4171: $allresults .= '</div>';
1.32 raeburn 4172: }
1.37 raeburn 4173: return $allresults;
1.32 raeburn 4174: }
4175:
1.3 raeburn 4176: sub create_homepage {
1.32 raeburn 4177: my ($cdom,$cnum,$name,$groupinfo,$tools,$gpterm,$ucgpterm,$now) = @_;
1.3 raeburn 4178: my $functionality = join(',',@{$tools});
1.24 www 4179: my $content = &unescape($$groupinfo{description});
1.121 raeburn 4180: chomp($content);
4181: my $gateway = Apache::lonhtmlgateway->new();
4182: $content = $gateway->process_incoming_html($content,1);
1.3 raeburn 4183:
4184: my %pageinfo = (
1.29 raeburn 4185: 'aaa_title' => "$ucgpterm: $name",
1.3 raeburn 4186: 'abb_links' => $functionality,
4187: 'bbb_content' => $content,
4188: 'ccc_webreferences' => '',
1.32 raeburn 4189: 'uploaded.lastmodified' => $now,
1.3 raeburn 4190: );
4191: my $putresult = &Apache::lonnet::put('grppage_'.$name,\%pageinfo,$cdom,$cnum);
4192: return $putresult;
1.1 raeburn 4193: }
4194:
1.5 raeburn 4195: sub check_uncheck_tools {
4196: my ($r,$available) = @_;
4197: if (ref($available) eq 'ARRAY') {
4198: $r->print('
4199: <script type="text/javascript">
4200: function checkAllTools(formname) {
4201: ');
4202: foreach my $tool (@{$available}) {
4203: $r->print(' checkAll(formname.user_'.$tool.');'."\n");
4204: }
4205: $r->print(' checkAll(formname.togglefunc);'."\n");
4206: $r->print('
4207: }
4208: function uncheckAllTools(formname) {
4209: ');
4210: foreach my $tool (@{$available}) {
4211: $r->print(' uncheckAll(formname.user_'.$tool.');'."\n");
4212: }
4213: $r->print(' uncheckAll(formname.togglefunc);'."\n");
4214: $r->print('
4215: }
4216: function toggleTools(field,caller) {
4217: if (caller.checked) {
4218: checkAll(field);
4219: } else {
4220: uncheckAll(field);
4221: }
4222: return;
4223: }
4224: </script>
4225: ');
4226: }
4227: return;
4228: }
4229:
4230: sub validate_groupname {
1.29 raeburn 4231: my ($groupname,$action,$cdom,$cnum,$gpterm,$ucgpterm,$crstype) = @_;
1.16 albertel 4232: my %sectioncount = &Apache::loncommon::get_sections($cdom,$cnum);
1.17 raeburn 4233: my %curr_groups = &Apache::longroup::coursegroups($cdom,$cnum);
1.65 raeburn 4234: my %deleted_groups = &Apache::longroup::coursegroups($cdom,$cnum,undef,
4235: 'deleted_groups');
1.64 raeburn 4236: if (my $tmp = &Apache::lonnet::error(%deleted_groups)) {
4237: undef(%deleted_groups);
4238: &Apache::lonnet::logthis('Error retrieving groups: '.$tmp.' in '.$cnum.':'.$cdom);
4239: }
1.5 raeburn 4240: my %lt = &Apache::lonlocal::texthash (
1.29 raeburn 4241: igna => "Invalid $gpterm name",
4242: grna => "$ucgpterm names and section names used in a ".
4243: "$crstype must be unique.",
4244: gnmo => "$ucgpterm names may only contain letters, ".
4245: "numbers or underscores.",
1.5 raeburn 4246: );
1.15 albertel 4247:
1.126 raeburn 4248: my $exitmsg = '<span class="LC_error">'.$lt{'igna'}.'</span><br /><br />';
4249: my $nameshown = &Apache::loncommon::cleanup_html($groupname);
1.5 raeburn 4250: if (($groupname eq '') || ($groupname =~ /\W/)) {
1.126 raeburn 4251: return $exitmsg.
4252: &mt("The $gpterm name entered '[_1]' is not a valid name.",$nameshown).
4253: '<br />'.$lt{'gnmo'};
4254: } elsif ($groupname eq 'syllabus') {
4255: return $exitmsg.
4256: &mt("The $gpterm name entered '[_1]' is reserved for use by LON-CAPA.",$nameshown);
1.5 raeburn 4257: }
1.16 albertel 4258: if (exists($sectioncount{$groupname})) {
1.126 raeburn 4259: return $exitmsg.
4260: &mt("The $gpterm name entered '[_1]' can not be used as it is the name of a section in this $crstype.",$nameshown).
4261: '<br />'.$lt{'grna'};
1.5 raeburn 4262: }
1.64 raeburn 4263: if ($action eq 'create') {
4264: if (exists($curr_groups{$groupname})) {
1.126 raeburn 4265: return $exitmsg.
4266: &mt("The $gpterm name entered '[_1]' can not be used as it is the name of an existing $gpterm in this $crstype.",$nameshown).
4267: '<br />'.$lt{'grna'};
1.64 raeburn 4268: } elsif (exists($deleted_groups{$groupname})) {
1.126 raeburn 4269: return $exitmsg.
4270: &mt("The $gpterm name entered '[_1]' can not be used as it is the name of a $gpterm which previously existed in this $crstype.",$nameshown).
4271: '<br />'.$lt{'grna'};
1.64 raeburn 4272: }
1.5 raeburn 4273: } elsif ($action eq 'modify') {
4274: unless(exists($curr_groups{$groupname})) {
1.126 raeburn 4275: return &mt("$ucgpterm name: [_1] does not correspond to the name of an existing $gpterm in this $crstype.",$nameshown);
1.5 raeburn 4276: }
4277: }
4278: return;
4279: }
4280:
4281: sub check_changes {
4282: my ($member_changes,$memchg) = @_;
4283: my %exclusions;
4284: @{$exclusions{'changefunc'}} = ('expire');
4285: @{$exclusions{'changepriv'}} = ('expire','changefunc');
4286:
4287: foreach my $change (@{$member_changes}) {
1.6 raeburn 4288: if ($change eq 'deletion') {
1.5 raeburn 4289: next;
4290: }
1.6 raeburn 4291: my @checks = ('deletion');
1.5 raeburn 4292: if (exists($exclusions{$change})) {
4293: push(@checks,@{$exclusions{$change}});
4294: }
4295: my @temp = ();
4296: foreach my $item (@{$$memchg{$change}}) {
4297: my $match = 0;
4298: foreach my $check (@checks) {
1.6 raeburn 4299: if (defined($$memchg{$check})) {
4300: if (ref(@{$$memchg{$check}}) eq 'ARRAY') {
4301: if (@{$$memchg{$check}} > 0) {
4302: if (grep/^$item$/,@{$$memchg{$check}}) {
4303: $match = 1;
4304: last;
4305: }
4306: }
1.5 raeburn 4307: }
4308: }
4309: }
4310: if ($match) {
4311: next;
4312: }
4313: push(@temp,$item);
4314: }
4315: @{$$memchg{$change}} = @temp;
4316: }
4317: }
1.3 raeburn 4318:
1.1 raeburn 4319: 1;
1.106 wenzelju 4320:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>