version 1.18, 2006/05/18 14:03:23
|
version 1.37, 2006/07/04 20:50:52
|
Line 1
|
Line 1
|
|
# The LearningOnline Network with CAPA |
|
# |
|
# $Id$ |
# |
# |
# Copyright Michigan State University Board of Trustees |
# Copyright Michigan State University Board of Trustees |
# |
# |
Line 31 use Apache::lonhtmlcommon;
|
Line 34 use Apache::lonhtmlcommon;
|
use Apache::lonlocal; |
use Apache::lonlocal; |
use Apache::lonnavmaps; |
use Apache::lonnavmaps; |
use Apache::longroup; |
use Apache::longroup; |
|
use Apache::portfolio; |
use Apache::Constants qw(:common :http); |
use Apache::Constants qw(:common :http); |
|
use lib '/home/httpd/lib/perl/'; |
|
use LONCAPA; |
|
|
sub handler { |
sub handler { |
my ($r) = @_; |
my ($r) = @_; |
Line 64 sub handler {
|
Line 70 sub handler {
|
&Apache::lonnet::allowed('mdg',$env{'request.course.id'}); |
&Apache::lonnet::allowed('mdg',$env{'request.course.id'}); |
&Apache::lonhtmlcommon::clear_breadcrumbs(); |
&Apache::lonhtmlcommon::clear_breadcrumbs(); |
|
|
|
my $gpterm = &Apache::loncommon::group_term(); |
|
my $ucgpterm = $gpterm; |
|
$ucgpterm =~ s/^(\w)/uc($1)/e; |
|
my $crstype = &Apache::loncommon::course_type(); |
|
|
my %functions = ( |
my %functions = ( |
email => 'E-mail', |
email => 'E-mail', |
discussion => 'Discussion boards', |
discussion => 'Discussion boards', |
chat => 'Chat', |
chat => 'Chat', |
files => 'File repository', |
files => 'File repository', |
roster => 'Membership roster', |
roster => 'Membership roster', |
homepage => 'Group home page', |
homepage => $ucgpterm.' home page', |
); |
); |
|
|
my %idx = (); |
my %idx = (); |
Line 78 sub handler {
|
Line 89 sub handler {
|
$idx{fullname} = &Apache::loncoursedata::CL_FULLNAME(); |
$idx{fullname} = &Apache::loncoursedata::CL_FULLNAME(); |
$idx{udom} = &Apache::loncoursedata::CL_SDOM(); |
$idx{udom} = &Apache::loncoursedata::CL_SDOM(); |
$idx{uname} = &Apache::loncoursedata::CL_SNAME(); |
$idx{uname} = &Apache::loncoursedata::CL_SNAME(); |
|
$idx{section} = &Apache::loncoursedata::CL_SECTION(); |
|
|
my $rowColor1 = "#dddddd"; |
my $rowColor1 = "#dddddd"; |
my $rowColor2 = "#eeeeee"; |
my $rowColor2 = "#eeeeee"; |
|
|
my $action = $env{'form.action'}; |
my $action = $env{'form.action'}; |
|
my $state = $env{'form.state'}; |
|
if ((!defined($action)) || ($action eq 'view')) { |
|
if (!defined($state)) { |
|
$state = 'view'; |
|
} |
|
} |
if ($action eq 'create' || $action eq 'modify' || $action eq 'view') { |
if ($action eq 'create' || $action eq 'modify' || $action eq 'view') { |
if ($view_permission || $manage_permission) { |
if ($view_permission || $manage_permission) { |
&group_administration($r,$action,$cdom,$cnum,$function,$tabcol, |
&group_administration($r,$action,$state,$cdom,$cnum,$function, |
\%functions,\%idx,$view_permission, |
$tabcol,\%functions,\%idx,$view_permission, |
$manage_permission,$rowColor1,$rowColor2); |
$manage_permission,$rowColor1,$rowColor2, |
|
$gpterm,$ucgpterm,$crstype); |
} else { |
} else { |
$r->print(&mt('You do not have group administration '. |
$r->print(&mt('You do not have [_1] administration '. |
'privileges in this course')); |
'privileges in this [_2]',$gpterm,lc($crstype))); |
} |
} |
} else { |
} else { |
&print_main_menu($r,$cdom,$cnum,$function,$tabcol,\%functions,\%idx, |
&print_main_menu($r,$cdom,$cnum,$function,$tabcol,\%functions,\%idx, |
$view_permission,$manage_permission,$action, |
$view_permission,$manage_permission,$action,$state, |
$rowColor1,$rowColor2); |
$rowColor1,$rowColor2,$gpterm,$ucgpterm,$crstype); |
} |
} |
return OK; |
return OK; |
} |
} |
|
|
sub print_main_menu { |
sub print_main_menu { |
my ($r,$cdom,$cnum,$function,$tabcol,$functions,$idx,$view_permission, |
my ($r,$cdom,$cnum,$function,$tabcol,$functions,$idx,$view_permission, |
$manage_permission,$action,$rowColor1,$rowColor2) = @_; |
$manage_permission,$action,$state,$rowColor1,$rowColor2,$gpterm, |
$r->print(&header('Course Groups',undef,undef,undef,undef,$function)); |
$ucgpterm,$crstype) = @_; |
|
my $pagename = "$crstype $ucgpterm".'s'; |
|
my $jscript = qq| |
|
function changeSort(caller) { |
|
document.$state.sortby.value = caller; |
|
document.$state.submit(); |
|
}\n|; |
|
$r->print(&header($pagename,$jscript,$action,$state, |
|
undef,$function)); |
&Apache::lonhtmlcommon::add_breadcrumb |
&Apache::lonhtmlcommon::add_breadcrumb |
({href=>"/adm/coursegroups", |
({href=>"/adm/coursegroups", |
text=>"Course Groups",}); |
text=>"$pagename"}); |
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Course Groups')); |
$r->print(&Apache::lonhtmlcommon::breadcrumbs($pagename)); |
&display_groups($r,$cdom,$cnum,$function,$tabcol,$functions,$idx, |
&display_groups($r,$cdom,$cnum,$function,$tabcol,$functions,$idx, |
$view_permission,$manage_permission,$action,$rowColor1, |
$view_permission,$manage_permission,$action,$state, |
$rowColor2); |
$rowColor1,$rowColor2,$gpterm,$ucgpterm,$crstype); |
$r->print(&footer()); |
$r->print(&footer()); |
return; |
return; |
} |
} |
|
|
sub display_groups { |
sub display_groups { |
my ($r,$cdom,$cnum,$function,$tabcol,$functions,$idx,$view_permission, |
my ($r,$cdom,$cnum,$function,$tabcol,$functions,$idx,$view_permission, |
$manage_permission,$action,$rowColor1,$rowColor2) = @_; |
$manage_permission,$action,$state,$rowColor1,$rowColor2,$gpterm, |
|
$ucgpterm,$crstype) = @_; |
my %curr_groups = (); |
my %curr_groups = (); |
my %grp_info = (); |
my %grp_info = (); |
|
|
my %actionlinks = ( |
my %actionlinks = ( |
modify => '<a href="/adm/coursegroups?action=modify&state=pick_task&refpage='. |
modify => '<a href="/adm/coursegroups?action=modify&refpage='. |
$env{'form.refpage'}.'&groupname=', |
$env{'form.refpage'}.'&groupname=', |
view => '<a href="/adm/'.$cdom.'/'.$cnum.'/', |
view => '<a href="/adm/'.$cdom.'/'.$cnum.'/', |
delete => '<a href="/adm/coursegroups?action=delete&refpage='. |
delete => '<a href="/adm/coursegroups?action=delete&refpage='. |
$env{'form.refpage'}.'&groupname=', |
$env{'form.refpage'}.'&groupname=', |
); |
); |
my %lt = &Apache::lonlocal::texthash( |
my %lt = &Apache::lonlocal::texthash( |
modify => 'Modify', |
modify => 'Modify', |
view => 'View', |
view => 'View', |
delete => 'Delete', |
delete => 'Delete', |
act => 'Action', |
act => 'Action', |
gname => 'Group Name', |
gname => "$ucgpterm Name", |
desc => 'Description', |
desc => 'Description', |
crea => 'Creator', |
crea => 'Creator', |
crtd => 'Created', |
crtd => 'Created', |
Line 143 sub display_groups {
|
Line 170 sub display_groups {
|
memb => 'Members', |
memb => 'Members', |
file => 'Files', |
file => 'Files', |
dibd => 'Discussion Boards', |
dibd => 'Discussion Boards', |
dius => 'Disk Use', |
dius => 'Disk Use (%)', |
nogr => 'No groups exist.', |
nogr => 'No '.$gpterm.'s exist.', |
crng => 'Create a new group', |
crng => 'Create a new '.$gpterm, |
alth => 'Although your current role has privileges'. |
alth => 'Although your current role has privileges'. |
' to view any existing groups in this course,'. |
' to view any existing '.$gpterm.'s in this'. |
' you do not have privileges to create new'. |
lc($crstype).', you do not have privileges'. |
' groups.', |
'to create new '.$gpterm.'s.', |
); |
); |
if ($view_permission) { |
if ($view_permission) { |
if (!defined($action)) { |
if (!defined($action)) { |
Line 157 sub display_groups {
|
Line 184 sub display_groups {
|
} |
} |
my %curr_groups = &Apache::longroup::coursegroups($cdom,$cnum); |
my %curr_groups = &Apache::longroup::coursegroups($cdom,$cnum); |
if (%curr_groups) { |
if (%curr_groups) { |
|
if ($manage_permission) { |
|
$r->print('<br /><a href="/adm/coursegroups?action=create&refpage='.$env{'form.refpage'}.'">'.$lt{'crng'}.'</a>'); |
|
} |
$r->print('<br /><br />'); |
$r->print('<br /><br />'); |
$r->print(&Apache::lonhtmlcommon::start_pick_box()); |
$r->print(&Apache::lonhtmlcommon::start_pick_box()); |
$r->print(<<"END"); |
$r->print(<<"END"); |
Line 174 sub display_groups {
|
Line 204 sub display_groups {
|
<td><b>$lt{'func'}</b> |
<td><b>$lt{'func'}</b> |
</td> |
</td> |
<td><b><a href="javascript:changeSort('quota')">$lt{'quot'}</a></b></td> |
<td><b><a href="javascript:changeSort('quota')">$lt{'quot'}</a></b></td> |
<td><b><a href="javascript:changeSort('totalmembers)">$lt{'memb'}</a></b></td> |
<td><b><a href="javascript:changeSort('totalmembers')">$lt{'memb'}</a></b></td> |
<td><b><a href="javascript:changeSort('totalfiles')">$lt{'file'}</a></b></td> |
<td><b><a href="javascript:changeSort('totalfiles')">$lt{'file'}</a></b></td> |
<td><b><a href="javascript:changeSort('boards')">$lt{'dibd'}</a></b></td> |
<td><b><a href="javascript:changeSort('boards')">$lt{'dibd'}</a></b></td> |
<td><b><a href="javascript:changeSort('diskuse')">$lt{'dius'}</a></b></td> |
<td><b><a href="javascript:changeSort('diskuse')">$lt{'dius'}</a></b></td> |
Line 187 END
|
Line 217 END
|
$curr_groups{$group}); |
$curr_groups{$group}); |
my $members_result = &group_members($cdom,$cnum,$group, |
my $members_result = &group_members($cdom,$cnum,$group, |
\%grp_info); |
\%grp_info); |
my $files_result = &group_files($group,\%grp_info); |
my $port_path = '/userfiles/groups/'.$group.'/portfolio'; |
|
my $port_dir = &Apache::loncommon::propath($cdom,$cnum).$port_path; |
|
my $totaldirs = 0; |
|
my $totalfiles = 0; |
|
&group_files($group,$port_dir,\$totalfiles,\$totaldirs); |
|
$grp_info{$group}{'totalfiles'} = $totalfiles; |
|
$grp_info{$group}{'totaldirs'} = $totaldirs; |
|
my $diskuse = &Apache::lonnet::diskusage($cdom,$cnum,$port_dir); |
|
if ($grp_info{$group}{'quota'} > 0) { |
|
my $pct_use = 0.1 * $diskuse/$grp_info{$group}{'quota'}; |
|
$grp_info{$group}{'diskuse'} = sprintf("%.0f",$pct_use); |
|
} else { |
|
$grp_info{$group}{'diskuse'} = 'N/A'; |
|
} |
|
my ($groupboards,$boardshash)=&Apache::longroup::get_group_bbinfo( |
|
$cdom,$cnum,$group); |
|
$grp_info{$group}{'boards'} = scalar(@{$groupboards}); |
if ($env{'form.sortby'} eq 'groupname') { |
if ($env{'form.sortby'} eq 'groupname') { |
push(@{$Sortby{$group}},$group); |
push(@{$Sortby{$group}},$group); |
} elsif ($env{'form.sortby'} eq 'description') { |
} elsif ($env{'form.sortby'} eq 'description') { |
push(@{$Sortby{$grp_info{$group}{'description'}}}, |
push(@{$Sortby{$grp_info{$group}{'description'}}},$group); |
$group); |
|
} elsif ($env{'form.sortby'} eq 'creator') { |
} elsif ($env{'form.sortby'} eq 'creator') { |
push(@{$Sortby{$grp_info{$group}{'creator'}}},$group); |
push(@{$Sortby{$grp_info{$group}{'creator'}}},$group); |
} elsif ($env{'form.sortby'} eq 'creation') { |
} elsif ($env{'form.sortby'} eq 'creation') { |
Line 224 END
|
Line 269 END
|
$rowColor = $rowColor2; |
$rowColor = $rowColor2; |
} |
} |
my $description = |
my $description = |
&Apache::lonnet::unescape($grp_info{$group}{'description'}); |
&unescape($grp_info{$group}{'description'}); |
my $creator = $grp_info{$group}{'creator'}; |
my $creator = $grp_info{$group}{'creator'}; |
my $creation = $grp_info{$group}{'creation'}; |
my $creation = $grp_info{$group}{'creation'}; |
my $modified = $grp_info{$group}{'modified'}; |
my $modified = $grp_info{$group}{'modified'}; |
my $quota = $grp_info{$group}{'quota'}; |
my $quota = $grp_info{$group}{'quota'}; |
my $totalmembers = $grp_info{$group}{'totalmembers'}; |
my $totalmembers = $grp_info{$group}{'totalmembers'}; |
my $totalfiles = $grp_info{$group}{'totalfiles'}; |
my $totalfiles = $grp_info{$group}{'totalfiles'}; |
|
my $totaldirs = $grp_info{$group}{'totaldirs'}; |
my $boards = $grp_info{$group}{'boards'}; |
my $boards = $grp_info{$group}{'boards'}; |
my $diskuse = $grp_info{$group}{'diskuse'}; |
my $diskuse = $grp_info{$group}{'diskuse'}; |
my $functionality; |
my $functionality; |
Line 246 END
|
Line 292 END
|
if ($action eq 'modify' || $action eq 'delete') { |
if ($action eq 'modify' || $action eq 'delete') { |
$link .= $group; |
$link .= $group; |
} else { |
} else { |
$link .= $group.'/grppg?register=1'; |
$link .= $group.'/grppg'; |
|
} |
|
$link .= '">'.$lt{$action}.'</a>'; |
|
if ($action eq 'view') { |
|
if (($manage_permission) && |
|
($env{'form.refpage'} ne 'enrl')) { |
|
$link .= ' '.$actionlinks{'modify'}. |
|
$group.'">'.$lt{'modify'}.'</a>'; |
|
} |
} |
} |
$link .= '">'.$lt{$action}.'</a>'; |
$r->print('<tr bgcolor="'.$rowColor.'"><td><small>'.$link.'</small></td><td><small>'.$group.'</small></td><td><small>'.$description.'</small></td><td><small>'.$creator.'</small></td><td><small>'. &Apache::lonnavmaps::timeToHumanString($creation).'</small></td><td><small>'. &Apache::lonnavmaps::timeToHumanString($modified).'</small></td><td><small>'.$functionality.'</small></td><td align="right"><small>'.$quota.'</small></td><td align="right"><small>'.$totalmembers.'</small></td><td align="right"><small><nobr>'.&mt('Files: ').$totalfiles.'</nobr><br /><nobr>'.&mt('Folders: ').$totaldirs.'</nobr></small></td><td align="right"><small>'.$boards.'</small></td><td align="right"><small>'.$diskuse.'</small></td></tr>'); |
$r->print('<tr bgcolor="'.$rowColor.'"><td><small>'.$link.'</small></td><td><small>'.$group.'</small></td><td><small>'.$description.'</small></td><td><small>'.$creator.'</small></td><td><small>'. &Apache::lonnavmaps::timeToHumanString($creation).'</small></td><td><small>'. &Apache::lonnavmaps::timeToHumanString($modified).'</small></td><td><small>'.$functionality.'</small></td><td><small>'.$quota.'</small></td><td><small>'.$totalmembers.'</small></td><td><small>'.$totalfiles.'</small></td><td><small>'.$boards.'</small></td><td><small>'.$diskuse.'</small></td></tr>'); |
|
$rowNum ++; |
$rowNum ++; |
} |
} |
} |
} |
$r->print('</table>'); |
$r->print('</table>'); |
$r->print(&Apache::lonhtmlcommon::end_pick_box()); |
$r->print(&Apache::lonhtmlcommon::end_pick_box()); |
|
$r->print('<input type="hidden" name="refpage" '. |
|
'value="'.$env{'form.refpage'}.'" />'); |
|
if ($action eq 'view') { |
|
if (!defined($state)) { |
|
$state = 'view'; |
|
} |
|
$r->print('<input type="hidden" name="state" value="'. |
|
$state.'" />'); |
|
} |
} else { |
} else { |
$r->print($lt{'nogr'}); |
$r->print($lt{'nogr'}); |
if ($manage_permission) { |
if ($manage_permission) { |
$r->print('<br /><br /><a href="/adm/coursegroups?action=create&refpage='.$env{'form.refpage'}.'">'.$lt{'crng'}.'</a>'); |
$r->print('<br /><br /><a href="/adm/coursegroups?action=create&refpage='.$env{'form.refpage'}.'">'.$lt{'crng'}.'</a>'); |
} else { |
} else { |
$r->print('<br /><br />'.$lt{'crng'}); |
$r->print('<br /><br />'.$lt{'alth'}); |
|
|
} |
} |
} |
} |
Line 273 END
|
Line 335 END
|
foreach my $group (@coursegroups) { |
foreach my $group (@coursegroups) { |
my %group_info = &Apache::longroup::get_group_settings( |
my %group_info = &Apache::longroup::get_group_settings( |
$curr_groups{$group}); |
$curr_groups{$group}); |
my $description = &Apache::lonnet::unescape( |
my $description = &unescape( |
$group_info{description}); |
$group_info{description}); |
my ($uname,$udom) = split(/:/,$group_info{creator}); |
my ($uname,$udom) = split(/:/,$group_info{creator}); |
$r->print('<font size="+1"><a href="/adm/'.$udom.'/'.$uname.'/'.$group.'/grppg?register=1">'.$group,'</a><font><br /><small>'.$description.'</small><br /><br />'); |
$r->print('<font size="+1"><a href="/adm/'.$udom.'/'.$uname.'/'.$group.'/grppg">'.$group,'</a><font><br /><small>'.$description.'</small><br /><br />'); |
} |
} |
} |
} |
} else { |
} else { |
$r->print(&mt('You are not currently a member of any '. |
$r->print(&mt('You are not currently a member of any '. |
'active groups in this course')); |
'active [_1]s in this [_2]',$gpterm, |
|
lc($crstype))); |
} |
} |
} |
} |
return; |
return; |
} |
} |
|
|
sub group_administration { |
sub group_administration { |
my ($r,$action,$cdom,$cnum,$function,$tabcol,$functions,$idx, |
my ($r,$action,$state,$cdom,$cnum,$function,$tabcol,$functions,$idx, |
$view_permission,$manage_permission,$rowColor1,$rowColor2) = @_; |
$view_permission,$manage_permission,$rowColor1,$rowColor2,$gpterm, |
|
$ucgpterm,$crstype) = @_; |
my %sectioncount = (); |
my %sectioncount = (); |
my @tools = (); |
my @tools = (); |
my @types = (); |
my @types = (); |
Line 303 sub group_administration {
|
Line 367 sub group_administration {
|
my %memchg; |
my %memchg; |
my @member_changes = ('deletion','expire','activate','reenable', |
my @member_changes = ('deletion','expire','activate','reenable', |
'changefunc','changepriv'); |
'changefunc','changepriv'); |
my $state = $env{'form.state'}; |
my ($groupname,$description,$startdate,$enddate,$granularity,$specificity, |
my ($groupname,$description,$startdate,$enddate,$granularity,$specificity); |
$quota,$validate_script); |
|
|
if (defined($env{'form.groupname'})) { |
if (defined($env{'form.groupname'})) { |
$groupname = $env{'form.groupname'}; |
$groupname = $env{'form.groupname'}; |
Line 328 sub group_administration {
|
Line 392 sub group_administration {
|
if (defined($env{'form.specificity'})) { |
if (defined($env{'form.specificity'})) { |
$specificity=$env{'form.specificity'}; |
$specificity=$env{'form.specificity'}; |
} |
} |
|
if (defined($env{'form.quota'})) { |
|
$quota=$env{'form.quota'}; |
|
} |
} |
} |
if (($action eq 'create') || (($action eq 'modify') |
if (($action eq 'create') || (($action eq 'modify') |
&& (($state eq 'pick_privs') || ($state eq 'addresult')))) { |
&& (($state eq 'pick_privs') || ($state eq 'addresult')))) { |
Line 342 sub group_administration {
|
Line 408 sub group_administration {
|
|
|
if ($action eq 'modify') { |
if ($action eq 'modify') { |
if ($state eq '') { |
if ($state eq '') { |
$state = 'pick_group'; |
if (defined($env{'form.groupname'})) { |
|
$state = 'pick_task'; |
|
} else { |
|
$state = 'pick_group'; |
|
} |
} else { |
} else { |
%stored = &retrieve_settings($cdom,$cnum,$groupname); |
%stored = &retrieve_settings($cdom,$cnum,$groupname); |
if (ref($stored{'types'}) eq 'ARRAY') { |
if (ref($stored{'types'}) eq 'ARRAY') { |
Line 363 sub group_administration {
|
Line 433 sub group_administration {
|
$description = $stored{'description'}; |
$description = $stored{'description'}; |
$granularity = $stored{'granularity'}; |
$granularity = $stored{'granularity'}; |
$specificity = $stored{'specificity'}; |
$specificity = $stored{'specificity'}; |
|
$quota = $stored{'quota'}; |
} |
} |
} |
} |
} |
} |
|
|
my %toolprivs = (); |
my $toolprivs = &Apache::longroup::get_tool_privs($gpterm); |
%{$toolprivs{'email'}} = ( |
|
sgm => 'Send group mail', |
my $fixedprivs = &Apache::longroup::get_fixed_privs(); |
sgb => 'Broadcast mail', |
|
); |
my %elements = |
%{$toolprivs{'discussion'}} = ( |
( |
cgb => 'Create boards', |
create => { |
pgd => 'Post', |
pick_name => { |
pag => 'Anon. posts', |
startdate_month => 'selectbox', |
rgi => 'Get identities', |
startdate_hour => 'selectbox', |
vgb => 'View boards', |
enddate_month => 'selectbox', |
); |
enddate_hour => 'selectbox', |
%{$toolprivs{'chat'}} = ( |
startdate_day => 'text', |
pgc => 'Chat', |
startdate_year => 'text', |
); |
startdate_minute => 'text', |
%{$toolprivs{'files'}} = ( |
startdate_second => 'text', |
rgf => 'Retrieve', |
enddate_day => 'text', |
ugf => 'Upload', |
enddate_year => 'text', |
dgf => 'Delete', |
enddate_minute => 'text', |
); |
enddate_second => 'text', |
%{$toolprivs{'roster'}} = ( |
groupname => 'text', |
vgm => 'View', |
description => 'text', |
); |
quota => 'text', |
%{$toolprivs{'homepage'}} = ( |
tool => 'checkbox', |
vgh => 'View page', |
granularity => 'radio', |
mgh => 'Modify page', |
no_end_date => 'checkbox', |
); |
}, |
my %fixedprivs = (); |
pick_members => { |
%{$fixedprivs{'email'}} = ('sgm' => 1); |
member => 'checkbox', |
%{$fixedprivs{'discussion'}} = ('vgb' => 1); |
defpriv => 'checkbox', |
%{$fixedprivs{'chat'}} = ('pgc' => 1); |
}, |
%{$fixedprivs{'files'}} = ('rgf' => 1); |
}, |
%{$fixedprivs{'roster'}} = ('vgm' => 1); |
); |
%{$fixedprivs{'homepage'}} = ('vgh' => 1); |
|
|
$elements{'modify'} = { |
my %elements = (); |
change_settings => { |
%{$elements{'create'}} = (); |
%{$elements{'create'}{'pick_name'}}, |
%{$elements{'modify'}} = (); |
specificity => 'radio', |
%{$elements{'create'}{'pick_name'}} = ( |
defpriv => 'checkbox', |
startdate_month => 'selectbox', |
autorole => 'checkbox', |
startdate_hour => 'selectbox', |
autoadd => 'radio', |
enddate_month => 'selectbox', |
autodrop => 'radio', |
enddate_hour => 'selectbox', |
}, |
startdate_day => 'text', |
add_members => { |
startdate_year => 'text', |
types => 'selectbox', |
startdate_minute => 'text', |
roles => 'selectbox', |
startdate_second => 'text', |
}, |
enddate_day => 'text', |
}; |
enddate_year => 'text', |
|
enddate_minute => 'text', |
|
enddate_second => 'text', |
|
groupname => 'text', |
|
description => 'text', |
|
tool => 'checkbox', |
|
granularity => 'radio', |
|
no_end_date => 'checkbox', |
|
); |
|
%{$elements{'modify'}{'change_settings'}} = ( |
|
%{$elements{'create'}{'pick_name'}}, |
|
specificity => 'radio', |
|
defpriv => 'checkbox', |
|
autorole => 'checkbox', |
|
autoadd => 'radio', |
|
autodrop => 'radio', |
|
); |
|
if (ref($stored{'autorole'}) eq 'ARRAY') { |
if (ref($stored{'autorole'}) eq 'ARRAY') { |
foreach my $role (@{$stored{'autorole'}}) { |
foreach my $role (@{$stored{'autorole'}}) { |
unless ($role eq 'cc') { |
unless ($role eq 'cc') { |
Line 440 sub group_administration {
|
Line 495 sub group_administration {
|
} |
} |
} |
} |
} |
} |
%{$elements{'create'}{'pick_members'}} = ( |
|
member => 'checkbox', |
|
defpriv => 'checkbox', |
|
); |
|
|
|
%{$elements{'modify'}{'add_members'}} = ( |
|
types => 'selectbox', |
|
roles => 'selectbox', |
|
); |
|
|
|
if (($action eq 'create') && ($state eq 'pick_name')) { |
if (($action eq 'create') && ($state eq 'pick_name')) { |
$elements{'create'}{'pick_name'}{'types'} = 'selectbox'; |
$elements{'create'}{'pick_name'}{'types'} = 'selectbox'; |
Line 476 sub group_administration {
|
Line 522 sub group_administration {
|
} |
} |
if (defined($env{'form.sectionpick'})) { |
if (defined($env{'form.sectionpick'})) { |
@sections=&Apache::loncommon::get_env_multiple('form.sectionpick'); |
@sections=&Apache::loncommon::get_env_multiple('form.sectionpick'); |
if (grep/^_all$/,@sections) { |
if (grep/^all$/,@sections) { |
@sections = sort {$a cmp $b} keys(%sectioncount); |
@sections = sort {$a cmp $b} keys(%sectioncount); |
} |
} |
} |
} |
Line 560 sub group_administration {
|
Line 606 sub group_administration {
|
} |
} |
|
|
if (($state eq 'pick_privs') || ($state eq 'change_privs') || |
if (($state eq 'pick_privs') || ($state eq 'change_privs') || |
(($specificity eq 'No') && |
(($specificity eq 'No') && |
(($state eq 'result') || ($state eq 'memresult')))) { |
($state eq 'memresult' || $state eq 'result' || $state eq 'addresult'))) { |
foreach my $tool (@tools) { |
foreach my $tool (@tools) { |
my @values = &Apache::loncommon::get_env_multiple('form.user_'.$tool); |
my @values = &Apache::loncommon::get_env_multiple('form.user_'.$tool); |
foreach my $user (@values) { |
foreach my $user (@values) { |
|
if ($state eq 'pick_privs' || $state eq 'result' |
|
|| $state eq 'addresult') { |
|
if (!grep(/^\Q$user\E$/,@members)) { |
|
next; |
|
} |
|
} |
unless(exists($usertools{$user}{$tool})) { |
unless(exists($usertools{$user}{$tool})) { |
$usertools{$user}{$tool} = 1; |
$usertools{$user}{$tool} = 1; |
} |
} |
Line 596 sub group_administration {
|
Line 648 sub group_administration {
|
} |
} |
my @currtools = (); |
my @currtools = (); |
if (@userprivs > 0) { |
if (@userprivs > 0) { |
foreach my $tool (sort(keys(%fixedprivs))) { |
foreach my $tool (sort(keys(%{$fixedprivs}))) { |
foreach my $priv (keys(%{$fixedprivs{$tool}})) { |
foreach my $priv (keys(%{$$fixedprivs{$tool}})) { |
if (grep/^$priv$/,@userprivs) { |
if (grep/^$priv$/,@userprivs) { |
push(@currtools,$tool); |
push(@currtools,$tool); |
last; |
last; |
Line 667 sub group_administration {
|
Line 719 sub group_administration {
|
&& ($specificity eq 'Yes')) { |
&& ($specificity eq 'Yes')) { |
foreach my $user (sort(keys(%usertools))) { |
foreach my $user (sort(keys(%usertools))) { |
foreach my $tool (keys(%{$usertools{$user}})) { |
foreach my $tool (keys(%{$usertools{$user}})) { |
foreach my $priv (keys(%{$toolprivs{$tool}})) { |
foreach my $priv (keys(%{$$toolprivs{$tool}})) { |
unless (exists($fixedprivs{$tool}{$priv})) { |
unless (exists($$fixedprivs{$tool}{$priv})) { |
$elements{$action}{$state}{'userpriv_'.$priv} = 'checkbox'; |
$elements{$action}{$state}{'userpriv_'.$priv} = 'checkbox'; |
} |
} |
} |
} |
} |
} |
} |
} |
} |
} |
|
|
|
if (($action eq 'create' && $state eq 'pick_name') || |
|
($action eq 'modify' && $state eq 'change_settings')) { |
|
my ($crsquota,$freespace,$maxposs) = &get_quota_constraints($action,\%stored); |
|
my $space_trim = '/^\s*|\s*\$/g,""'; |
|
my $float_check = '/^([0-9]*\.?[0-9]*)$/'; |
|
$validate_script = ' |
|
var newquota = document.'.$state.'.quota.value; |
|
newquota.replace('.$space_trim.'); |
|
if (newquota == "" ) { |
|
document.'.$state.'.quota.value = 0; |
|
newquota = 0; |
|
} |
|
var maxposs = '.$maxposs.'; |
|
if (newquota > maxposs) { |
|
alert("The file repository quota you entered for this group ("+newquota+" Mb) exceeds the maximum possible ("+maxposs+" Mb). Please enter a smaller number."); |
|
return; |
|
} |
|
var re_quota = '.$float_check.'; |
|
var check_quota = newquota.match(re_quota); |
|
if (check_quota == null) { |
|
alert("The quota you entered contains invalid characters, the quota should only include numbers, with or without a decimal point."); |
|
return; |
|
} |
|
if (newquota == 0) { |
|
var warn_zero = 0; |
|
for (var i=0; i<document.'.$state.'.tool.length; i++) { |
|
if (document.'.$state.'.tool[i].value == "files") { |
|
if (document.'.$state.'.tool[i].checked) { |
|
warn_zero = 1; |
|
} |
|
} |
|
} |
|
if (warn_zero == 1) { |
|
alert("You have indicated that the file repository should be enabled, but you have set the respository quota to 0 Mb.\nThis will prevent any upload of files.\nPlease set a value or disable the repository feature."); |
|
return; |
|
} |
|
} |
|
'; |
|
} |
my $jscript = &Apache::loncommon::check_uncheck_jscript(); |
my $jscript = &Apache::loncommon::check_uncheck_jscript(); |
$jscript .= qq| |
$jscript .= qq| |
function nextPage(formname,nextstate) { |
function nextPage(formname,nextstate) { |
formname.state.value= nextstate; |
formname.state.value= nextstate; |
|
$validate_script |
formname.submit(); |
formname.submit(); |
} |
} |
function backPage(formname,prevstate) { |
function backPage(formname,prevstate) { |
Line 705 function changeSort(caller) {
|
Line 797 function changeSort(caller) {
|
@{$branchstates{'members'}} = ('change_members','change_privs','memresult'); |
@{$branchstates{'members'}} = ('change_members','change_privs','memresult'); |
@{$branchstates{'adds'}} = ('add_members','pick_members','pick_privs', |
@{$branchstates{'adds'}} = ('add_members','pick_members','pick_privs', |
'addresult'); |
'addresult'); |
|
|
if (defined($env{'form.branch'})) { |
if (defined($env{'form.branch'})) { |
push (@{$states{$action}},@{$branchstates{$env{'form.branch'}}}); |
push (@{$states{$action}},@{$branchstates{$env{'form.branch'}}}); |
} |
} |
Line 723 function changeSort(caller) {
|
Line 815 function changeSort(caller) {
|
} |
} |
|
|
my $loaditems = &onload_action($action,$state); |
my $loaditems = &onload_action($action,$state); |
$r->print(&header('Course Groups Manager', |
my $crumbtitle = "$crstype $ucgpterm".'s'; |
|
$r->print(&header("$crumbtitle Manager", |
$jscript,$action,$state,$page,$function,$loaditems)); |
$jscript,$action,$state,$page,$function,$loaditems)); |
|
|
if ($env{'form.refpage'} eq 'enrl') { |
if ($env{'form.refpage'} eq 'enrl') { |
Line 734 function changeSort(caller) {
|
Line 827 function changeSort(caller) {
|
} else { |
} else { |
&Apache::lonhtmlcommon::add_breadcrumb |
&Apache::lonhtmlcommon::add_breadcrumb |
({href=>"/adm/coursegroups", |
({href=>"/adm/coursegroups", |
text=>"Course Groups", |
text=>"$crumbtitle", |
faq=>9,bug=>'Instructor Interface',}); |
faq=>9,bug=>'Instructor Interface',}); |
} |
} |
|
|
my %trail = (); |
my %trail = (); |
%{$trail{'create'}} = &Apache::lonlocal::texthash ( |
%{$trail{'create'}} = &Apache::lonlocal::texthash ( |
pick_name => 'Group Settings', |
pick_name => $ucgpterm.' Settings', |
pick_members => 'Select Members', |
pick_members => 'Select Members', |
pick_privs => 'Choose Privileges', |
pick_privs => 'Choose Privileges', |
result => 'Creation Complete', |
result => 'Creation Complete', |
); |
); |
%{$trail{'modify'}} = &Apache::lonlocal::texthash( |
%{$trail{'modify'}} = &Apache::lonlocal::texthash( |
pick_group => 'Groups', |
pick_group => $ucgpterm.'s', |
pick_task => 'Choose Task', |
pick_task => 'Choose Task', |
change_settings => 'Group Settings', |
change_settings => "$ucgpterm Settings", |
change_members => 'Modify/Delete Members', |
change_members => 'Modify/Delete Members', |
change_privs => 'Change Privileges', |
change_privs => 'Change Privileges', |
change_mapping => 'Membership Mapping', |
change_mapping => 'Membership Mapping', |
Line 762 function changeSort(caller) {
|
Line 855 function changeSort(caller) {
|
my %navbuttons = &Apache::lonlocal::texthash( |
my %navbuttons = &Apache::lonlocal::texthash( |
gtns => 'Go to next step', |
gtns => 'Go to next step', |
gtps => 'Go to previous step', |
gtps => 'Go to previous step', |
crgr => 'Create group', |
crgr => 'Create '.$gpterm, |
mose => 'Modify settings', |
mose => 'Modify settings', |
gtpp => 'Go to previous page', |
gtpp => 'Go to previous page', |
adme => 'Add members', |
adme => 'Add members', |
Line 774 function changeSort(caller) {
|
Line 867 function changeSort(caller) {
|
&Apache::lonhtmlcommon::add_breadcrumb( |
&Apache::lonhtmlcommon::add_breadcrumb( |
{text=>"$trail{$action}{$state}"}); |
{text=>"$trail{$action}{$state}"}); |
$r->print(&Apache::lonhtmlcommon::breadcrumbs |
$r->print(&Apache::lonhtmlcommon::breadcrumbs |
('Course Groups Manager')); |
("$crumbtitle Manager")); |
&display_control($r,$cdom,$cnum,$tabcol,$action,$state,$page, |
&display_control($r,$cdom,$cnum,$tabcol,$action,$state,$page, |
\%sectioncount,$groupname,$description,$functions, |
\%sectioncount,$groupname,$description,$functions, |
\@tools,\%toolprivs,\%fixedprivs,$startdate,$enddate, |
\@tools,$toolprivs,$fixedprivs,$startdate,$enddate, |
\%users,\%userdata,$idx,\%memchg,\%usertools, |
\%users,\%userdata,$idx,\%memchg,\%usertools, |
$function,$view_permission,$manage_permission, |
$function,$view_permission,$manage_permission, |
\%stored,$granularity,$specificity,\@types,\@roles, |
\%stored,$granularity,$quota,$specificity,\@types,\@roles, |
\@sections,\%states,\%navbuttons,$rowColor1,$rowColor2); |
\@sections,\%states,\%navbuttons,$rowColor1,$rowColor2, |
|
$gpterm,$ucgpterm,$crstype); |
last; |
last; |
} else { |
} else { |
if (($state eq 'result') && ($i > 0)) { |
if (($state eq 'result') && ($i > 0)) { |
Line 797 function changeSort(caller) {
|
Line 891 function changeSort(caller) {
|
} |
} |
} elsif (($action eq 'view') && ($view_permission)) { |
} elsif (($action eq 'view') && ($view_permission)) { |
&Apache::lonhtmlcommon::add_breadcrumb( |
&Apache::lonhtmlcommon::add_breadcrumb( |
{text=>"View groups"}); |
{text=>"View $gpterm".'s'}); |
|
my $crumbtitle = "$crstype $ucgpterm".'s Manager'; |
$r->print(&Apache::lonhtmlcommon::breadcrumbs |
$r->print(&Apache::lonhtmlcommon::breadcrumbs |
('Course Groups Manager')); |
(&mt($crumbtitle))); |
&display_groups($r,$cdom,$cnum,$function,$tabcol,$functions,$idx, |
&display_groups($r,$cdom,$cnum,$function,$tabcol,$functions,$idx, |
$view_permission,$manage_permission,$action, |
$view_permission,$manage_permission,$action,$state, |
$rowColor1,$rowColor2); |
$rowColor1,$rowColor2,$gpterm,$ucgpterm,$crstype); |
|
|
} |
} |
$r->print(&footer()); |
$r->print(&footer()); |
Line 821 sub retrieve_settings {
|
Line 916 sub retrieve_settings {
|
my %stored; |
my %stored; |
|
|
$stored{'description'} = |
$stored{'description'} = |
&Apache::lonnet::unescape($groupinfo{'description'}); |
&unescape($groupinfo{'description'}); |
$stored{'startdate'} = $groupinfo{'startdate'}; |
$stored{'startdate'} = $groupinfo{'startdate'}; |
$stored{'enddate'} = $groupinfo{'enddate'}; |
$stored{'enddate'} = $groupinfo{'enddate'}; |
if ($stored{'enddate'} == 0) { |
if ($stored{'enddate'} == 0) { |
Line 831 sub retrieve_settings {
|
Line 926 sub retrieve_settings {
|
$stored{'specificity'} = $groupinfo{'specificity'}; |
$stored{'specificity'} = $groupinfo{'specificity'}; |
$stored{'creation'} = $groupinfo{'creation'}; |
$stored{'creation'} = $groupinfo{'creation'}; |
$stored{'creator'} = $groupinfo{'creator'}; |
$stored{'creator'} = $groupinfo{'creator'}; |
|
$stored{'quota'} = $groupinfo{'quota'}; |
|
|
foreach my $tool (sort(keys(%{$groupinfo{'functions'}}))) { |
foreach my $tool (sort(keys(%{$groupinfo{'functions'}}))) { |
if ($groupinfo{functions}{$tool} eq 'on') { |
if ($groupinfo{functions}{$tool} eq 'on') { |
Line 870 sub display_control {
|
Line 966 sub display_control {
|
my ($r,$cdom,$cnum,$tabcol,$action,$state,$page,$sectioncount,$groupname, |
my ($r,$cdom,$cnum,$tabcol,$action,$state,$page,$sectioncount,$groupname, |
$description,$functions,$tools,$toolprivs,$fixedprivs,$startdate, |
$description,$functions,$tools,$toolprivs,$fixedprivs,$startdate, |
$enddate,$users,$userdata,$idx,$memchg,$usertools,$function, |
$enddate,$users,$userdata,$idx,$memchg,$usertools,$function, |
$view_permission,$manage_permission,$stored,$granularity,$specificity, |
$view_permission,$manage_permission,$stored,$granularity,$quota, |
$types,$roles,$sections,$states,$navbuttons,$rowColor1,$rowColor2)=@_; |
$specificity,$types,$roles,$sections,$states,$navbuttons,$rowColor1, |
|
$rowColor2,$gpterm,$ucgpterm,$crstype) = @_; |
if ($action eq 'create') { |
if ($action eq 'create') { |
if ($state eq 'pick_name') { |
if ($state eq 'pick_name') { |
&general_settings_form($r,$cdom,$cnum,$action,$tabcol,$state,$page, |
&general_settings_form($r,$cdom,$cnum,$action,$tabcol,$state,$page, |
$functions,$tools,$toolprivs,$fixedprivs, |
$functions,$tools,$toolprivs,$fixedprivs, |
$sectioncount,$stored,$states,$navbuttons, |
$sectioncount,$stored,$states,$navbuttons, |
$rowColor1,$rowColor2); |
$rowColor1,$rowColor2,$gpterm,$ucgpterm, |
|
$crstype); |
} elsif ($state eq 'pick_members') { |
} elsif ($state eq 'pick_members') { |
&choose_members_form($r,$cdom,$cnum,$tabcol,$action,$state,$page, |
&choose_members_form($r,$cdom,$cnum,$tabcol,$action,$state,$page, |
$groupname,$description,$granularity, |
$groupname,$description,$granularity,$quota, |
$startdate,$enddate,$tools,$fixedprivs, |
$startdate,$enddate,$tools,$fixedprivs, |
$toolprivs,$functions,$users,$userdata,$idx, |
$toolprivs,$functions,$users,$userdata,$idx, |
$stored,$states,$navbuttons,$rowColor1, |
$stored,$states,$navbuttons,$rowColor1, |
$rowColor2); |
$rowColor2,$gpterm,$ucgpterm,$crstype); |
} elsif ($state eq 'pick_privs') { |
} elsif ($state eq 'pick_privs') { |
&choose_privs_form($r,$cdom,$cnum,$tabcol,$action,$state,$page, |
&choose_privs_form($r,$cdom,$cnum,$tabcol,$action,$state,$page, |
$startdate,$enddate,$tools,$functions, |
$startdate,$enddate,$tools,$functions, |
$toolprivs,$fixedprivs,$userdata,$usertools, |
$toolprivs,$fixedprivs,$userdata,$usertools, |
$idx,$states,$stored,$sectioncount,$navbuttons, |
$idx,$states,$stored,$sectioncount,$navbuttons, |
$rowColor1,$rowColor2); |
$rowColor1,$rowColor2,$gpterm,$ucgpterm, |
|
$crstype); |
} elsif ($state eq 'result') { |
} elsif ($state eq 'result') { |
&process_request($r,$cdom,$cnum,$tabcol,$action,$state,$page, |
&process_request($r,$cdom,$cnum,$tabcol,$action,$state,$page, |
$groupname,$description,$specificity,$userdata, |
$groupname,$description,$specificity,$userdata, |
$startdate,$enddate,$tools,$functions, |
$startdate,$enddate,$tools,$functions, |
$toolprivs,$usertools,$idx,$types,$roles, |
$toolprivs,$usertools,$idx,$types,$roles, |
$sections,$states,$navbuttons,$memchg, |
$sections,$states,$navbuttons,$memchg, |
$sectioncount,$stored,$rowColor1,$rowColor2); |
$sectioncount,$stored,$rowColor1,$rowColor2, |
|
$gpterm,$ucgpterm,$crstype); |
} |
} |
} elsif ($action eq 'modify') { |
} elsif ($action eq 'modify') { |
my $groupname = $env{'form.groupname'}; |
my $groupname = $env{'form.groupname'}; |
if ($state eq 'pick_group') { |
if ($state eq 'pick_group') { |
&display_groups($r,$cdom,$cnum,$function,$tabcol,$functions,$idx, |
&display_groups($r,$cdom,$cnum,$function,$tabcol,$functions,$idx, |
$view_permission,$manage_permission,$action, |
$view_permission,$manage_permission,$action,$state, |
$rowColor1,$rowColor2); |
$rowColor1,$rowColor2,$gpterm,$ucgpterm,$crstype); |
} elsif ($state eq 'pick_task') { |
} elsif ($state eq 'pick_task') { |
&modify_menu($r,$groupname,$page); |
&modify_menu($r,$groupname,$page,$gpterm); |
} elsif ($state eq 'change_settings') { |
} elsif ($state eq 'change_settings') { |
&general_settings_form($r,$cdom,$cnum,$action,$tabcol,$state,$page, |
&general_settings_form($r,$cdom,$cnum,$action,$tabcol,$state,$page, |
$functions,$tools,$toolprivs,$fixedprivs, |
$functions,$tools,$toolprivs,$fixedprivs, |
$sectioncount,$stored,$states,$navbuttons, |
$sectioncount,$stored,$states,$navbuttons, |
$rowColor1,$rowColor2); |
$rowColor1,$rowColor2,$gpterm,$ucgpterm, |
|
$crstype); |
} elsif ($state eq 'change_members') { |
} elsif ($state eq 'change_members') { |
&change_members_form($r,$cdom,$cnum,$tabcol,$action,$state,$page, |
&change_members_form($r,$cdom,$cnum,$tabcol,$action,$state,$page, |
$groupname,$description,$startdate,$enddate, |
$groupname,$description,$startdate,$enddate, |
$tools,$fixedprivs,$functions,$users, |
$tools,$fixedprivs,$functions,$users, |
$userdata,$granularity,$specificity,$idx, |
$userdata,$granularity,$quota,$specificity, |
$states,$navbuttons,$rowColor1,$rowColor2); |
$idx,$states,$navbuttons,$rowColor1,$rowColor2, |
|
$gpterm,$ucgpterm); |
} elsif ($state eq 'add_members') { |
} elsif ($state eq 'add_members') { |
&add_members_form($r,$tabcol,$action,$state,$page,$startdate, |
&add_members_form($r,$tabcol,$action,$state,$page,$startdate, |
$enddate,$groupname,$description,$granularity, |
$enddate,$groupname,$description,$granularity, |
$sectioncount,$tools,$functions,$stored,$states, |
$quota,$sectioncount,$tools,$functions,$stored, |
$navbuttons,$rowColor1,$rowColor2); |
$states,$navbuttons,$rowColor1,$rowColor2,$gpterm, |
|
$ucgpterm); |
} elsif ($state eq 'pick_members') { |
} elsif ($state eq 'pick_members') { |
&choose_members_form($r,$cdom,$cnum,$tabcol,$action,$state,$page, |
&choose_members_form($r,$cdom,$cnum,$tabcol,$action,$state,$page, |
$groupname,$description,$granularity, |
$groupname,$description,$granularity,$quota, |
$startdate,$enddate,$tools,$fixedprivs, |
$startdate,$enddate,$tools,$fixedprivs, |
$toolprivs,$functions,$users,$userdata,$idx, |
$toolprivs,$functions,$users,$userdata,$idx, |
$stored,$states,$navbuttons,$rowColor1, |
$stored,$states,$navbuttons,$rowColor1, |
$rowColor2); |
$rowColor2,$gpterm,$ucgpterm,$crstype); |
} elsif ($state eq 'pick_privs') { |
} elsif ($state eq 'pick_privs') { |
&choose_privs_form($r,$cdom,$cnum,$tabcol,$action,$state,$page, |
&choose_privs_form($r,$cdom,$cnum,$tabcol,$action,$state,$page, |
$startdate,$enddate,$tools,$functions, |
$startdate,$enddate,$tools,$functions, |
$toolprivs,$fixedprivs,$userdata,$usertools, |
$toolprivs,$fixedprivs,$userdata,$usertools, |
$idx,$states,$stored,$sectioncount,$navbuttons, |
$idx,$states,$stored,$sectioncount,$navbuttons, |
$rowColor1,$rowColor2); |
$rowColor1,$rowColor2,$gpterm,$ucgpterm,$crstype); |
} elsif ($state eq 'change_privs') { |
} elsif ($state eq 'change_privs') { |
&change_privs_form($r,$cdom,$cnum,$tabcol,$action,$state,$page, |
&change_privs_form($r,$cdom,$cnum,$tabcol,$action,$state,$page, |
$startdate,$enddate,$tools,$functions, |
$startdate,$enddate,$tools,$functions, |
$toolprivs,$fixedprivs,$userdata,$usertools, |
$toolprivs,$fixedprivs,$userdata,$usertools, |
$memchg,$idx,$states,$stored,$sectioncount, |
$memchg,$idx,$states,$stored,$sectioncount, |
$navbuttons,$rowColor1,$rowColor2); |
$navbuttons,$rowColor1,$rowColor2,$gpterm, |
|
$ucgpterm); |
} elsif ($state eq 'chgresult' || $state eq 'memresult' || |
} elsif ($state eq 'chgresult' || $state eq 'memresult' || |
$state eq 'addresult') { |
$state eq 'addresult') { |
&process_request($r,$cdom,$cnum,$tabcol,$action,$state,$page, |
&process_request($r,$cdom,$cnum,$tabcol,$action,$state,$page, |
Line 949 sub display_control {
|
Line 1053 sub display_control {
|
$startdate,$enddate,$tools,$functions, |
$startdate,$enddate,$tools,$functions, |
$toolprivs,$usertools,$idx,$types,$roles, |
$toolprivs,$usertools,$idx,$types,$roles, |
$sections,$states,$navbuttons,$memchg, |
$sections,$states,$navbuttons,$memchg, |
$sectioncount,$stored,$rowColor1,$rowColor2); |
$sectioncount,$stored,$rowColor1,$rowColor2, |
|
$gpterm,$ucgpterm,$crstype); |
} |
} |
} |
} |
} |
} |
Line 1023 sub build_members_list {
|
Line 1128 sub build_members_list {
|
} |
} |
|
|
sub group_files { |
sub group_files { |
|
my ($group,$currdir,$numfiles,$numdirs) = @_; |
|
my $dirptr=16384; |
|
my @dir_list=&Apache::portfolio::get_dir_list($currdir,$group); |
|
foreach my $line (@dir_list) { |
|
my ($filename,$dom,undef,$testdir,undef,undef,undef,undef,$size,undef,$mtime,undef,undef,undef,$obs,undef)=split(/\&/,$line,16); |
|
if (($filename !~ /^\.\.?$/) && ($filename !~ /\.meta$/ ) && ($filename !~ /(.*)\.(\d+)\.([^\.]*)$/) && ($filename ne 'no_such_dir')) { |
|
if ($dirptr&$testdir) { |
|
$currdir .= '/'.$filename; |
|
$$numdirs ++; |
|
&group_files($numfiles,$numdirs) |
|
} else { |
|
$$numfiles ++; |
|
} |
|
} |
|
} |
return; |
return; |
} |
} |
|
|
Line 1035 sub group_members {
|
Line 1155 sub group_members {
|
$$group_info{'totalmembers'} = 'Unknown - an error occurred'; |
$$group_info{'totalmembers'} = 'Unknown - an error occurred'; |
return $tmp; |
return $tmp; |
} |
} |
my $now = time; |
|
my $totalmembers = 0; |
my $totalmembers = 0; |
my $active = 0; |
my $active = 0; |
my $previous = 0; |
my $previous = 0; |
Line 1065 sub group_members {
|
Line 1184 sub group_members {
|
sub general_settings_form { |
sub general_settings_form { |
my ($r,$cdom,$cnum,$action,$tabcol,$formname,$page,$functions,$tools, |
my ($r,$cdom,$cnum,$action,$tabcol,$formname,$page,$functions,$tools, |
$toolprivs,$fixedprivs,$sectioncount,$stored,$states,$navbuttons, |
$toolprivs,$fixedprivs,$sectioncount,$stored,$states,$navbuttons, |
$rowColor1,$rowColor2) = @_; |
$rowColor1,$rowColor2,$gpterm,$ucgpterm,$crstype) = @_; |
my ($nexttext,$prevtext); |
my ($nexttext,$prevtext); |
$r->print(' <br /> |
$r->print(' <br /> |
<table width="100%" cellpadding="0" cellspacing="0" border="0"> |
<table width="100%" cellpadding="0" cellspacing="0" border="0"> |
'); |
'); |
&groupsettings_options($r,$tabcol,$functions,$action,$formname,$stored,1); |
&groupsettings_options($r,$tabcol,$functions,$action,$formname,$stored,1, |
|
$gpterm,$ucgpterm,$crstype); |
$r->print(' |
$r->print(' |
<tr> |
<tr> |
<td colspan="4"> </td> |
<td colspan="4"> </td> |
</tr>'); |
</tr>'); |
&access_date_settings($r,$tabcol,$action,$formname,$stored,2); |
&access_date_settings($r,$tabcol,$action,$formname,$stored,2,$gpterm, |
|
$ucgpterm); |
$r->print(' |
$r->print(' |
<tr> |
<tr> |
<td colspan="4"> </td> |
<td colspan="4"> </td> |
</tr>'); |
</tr>'); |
if ($action eq 'create') { |
if ($action eq 'create') { |
&membership_options($r,$action,$formname,$tabcol,$sectioncount,3); |
&membership_options($r,$action,$formname,$tabcol,$sectioncount,3, |
|
$gpterm,$ucgpterm); |
$nexttext = $$navbuttons{'gtns'}; |
$nexttext = $$navbuttons{'gtns'}; |
} else { |
} else { |
my @available = (); |
my @available = (); |
Line 1090 sub general_settings_form {
|
Line 1212 sub general_settings_form {
|
@{$tools} = sort(keys(%{$functions})); |
@{$tools} = sort(keys(%{$functions})); |
&privilege_specificity($r,$tabcol,$rowColor1,$rowColor2,$action, |
&privilege_specificity($r,$tabcol,$rowColor1,$rowColor2,$action, |
3,$tools,$stored,$toolprivs,$fixedprivs, |
3,$tools,$stored,$toolprivs,$fixedprivs, |
\@available,$formname); |
\@available,$formname,$gpterm,$ucgpterm); |
$r->print(' |
$r->print(' |
<tr> |
<tr> |
<td colspan="4"> </td> |
<td colspan="4"> </td> |
</tr>'); |
</tr>'); |
&mapping_options($r,$action,$formname,$page,$tabcol,$sectioncount, |
&mapping_options($r,$action,$formname,$page,$tabcol,$sectioncount, |
$states,$stored,$navbuttons,4,5,$rowColor1, |
$states,$stored,$navbuttons,4,5,$rowColor1, |
$rowColor2); |
$rowColor2,$gpterm,$ucgpterm,$crstype); |
$nexttext = $$navbuttons{'mose'}; |
$nexttext = $$navbuttons{'mose'}; |
} |
} |
$prevtext = $$navbuttons{'gtpp'}; |
$prevtext = $$navbuttons{'gtpp'}; |
Line 1109 sub general_settings_form {
|
Line 1231 sub general_settings_form {
|
} |
} |
|
|
sub groupsettings_options { |
sub groupsettings_options { |
my ($r,$tabcol,$functions,$action,$formname,$stored,$image) = @_; |
my ($r,$tabcol,$functions,$action,$formname,$stored,$image,$gpterm, |
|
$ucgpterm,$crstype) = @_; |
my %lt = &Apache::lonlocal::texthash( |
my %lt = &Apache::lonlocal::texthash( |
'gdat' => 'Group open and close dates', |
'gdat' => "$ucgpterm open and close dates", |
'sten' => 'Set a start date/time and end date/time for the group', |
'sten' => "Set a start date/time and end date/time for the $gpterm", |
'gfun' => 'Group functionality', |
'gfun' => "$ucgpterm functionality", |
'gnde' => 'Group name, description and available functionality', |
'gnde' => "$ucgpterm name, description and available functionality", |
'desc' => 'Description', |
'desc' => 'Description', |
'func' => 'Functionality', |
'func' => 'Functionality', |
'gnam' => 'Group Name', |
'gnam' => "$ucgpterm Name", |
'doyo' => 'Do you want to assign different functionality '. |
'doyo' => "Do you want to assign different functionality ". |
'to different group members?', |
"to different $gpterm members?", |
); |
); |
|
my ($crsquota,$freespace,$maxposs) = &get_quota_constraints($action,$stored); |
&topic_bar($r,$tabcol,$image,$lt{'gnde'}); |
&topic_bar($r,$tabcol,$image,$lt{'gnde'}); |
$r->print(' |
$r->print(' |
<tr> |
<tr> |
Line 1181 END
|
Line 1305 END
|
</td> |
</td> |
</tr> |
</tr> |
<tr> |
<tr> |
<td><b>Granularity:</b></td> |
<td><b>'.&mt('Granularity:').'</b></td> |
<td colspan="9">'.$lt{'doyo'}.' <label><input type="radio" name="granularity" value="Yes" />'.&mt('Yes').'</label> <label><input type="radio" name="granularity" value="No" checked="checked" />'.&mt('No').'</label>'); |
<td colspan="10">'.$lt{'doyo'}.' <label><input type="radio" name="granularity" value="Yes" />'.&mt('Yes').'</label> <label><input type="radio" name="granularity" value="No" checked="checked" />'.&mt('No').'</label>'); |
if ($action eq 'modify') { |
if ($action eq 'modify') { |
$r->print(' ('.&mt('Currently set to "[_1]"', |
$r->print(' ('.&mt('Currently set to "[_1]"', |
$$stored{'granularity'}).')'); |
$$stored{'granularity'}).')'); |
Line 1190 END
|
Line 1314 END
|
$r->print(' |
$r->print(' |
</td> |
</td> |
</tr> |
</tr> |
|
<tr> |
|
<td valign="top">'.&mt('<b>Disk quota:</b> ').'</td><td colspan="10">'); |
|
if ($action eq 'create') { |
|
$r->print(&mt('If you enable the file repository for the [_1], allocate a disk quota.',$gpterm)); |
|
} else { |
|
$r->print(&mt('Quota allocated to file repository:')); |
|
} |
|
$r->print(' <input type="text" name="quota" size="4" />Mb'); |
|
if ($action eq 'create') { |
|
$r->print('<br />'. |
|
&mt('A total of [_1] Mb is shared between all [_2]s in the '. |
|
'[_3], and [_4] Mb are currently unallocated.',$crsquota, |
|
$gpterm,lc($crstype),$freespace)); |
|
} else { |
|
$r->print(' ('.&mt('The quota is currently [_1] Mb', |
|
$$stored{'quota'}).').'); |
|
|
|
$r->print('<br />'.&mt('The quota can be increased to [_1] Mb, '. |
|
'by adding all unallocated space for [_2]s in the [_3].', |
|
$maxposs,$gpterm,lc($crstype))); |
|
} |
|
$r->print(' |
|
</td> |
|
</tr> |
</table> |
</table> |
</td> |
</td> |
</tr> |
</tr> |
Line 1197 END
|
Line 1345 END
|
return; |
return; |
} |
} |
|
|
|
sub get_quota_constraints { |
|
my ($action,$stored) = @_; |
|
my ($crsquota,$freespace,$maxposs); |
|
$crsquota = $env{'course.'.$env{'request.course.id'}.'.internal.coursequota'}; |
|
if ($crsquota eq '') { |
|
$crsquota = 20; |
|
} |
|
$freespace = $crsquota - &Apache::longroup::sum_quotas(); |
|
if ($action eq 'create') { |
|
$maxposs = $freespace; |
|
} else { |
|
$maxposs = $$stored{'quota'} + $freespace; |
|
} |
|
return ($crsquota,$freespace,$maxposs); |
|
} |
|
|
sub membership_options { |
sub membership_options { |
my ($r,$action,$state,$tabcol,$sectioncount,$image) = @_; |
my ($r,$action,$state,$tabcol,$sectioncount,$image,$gpterm,$ucgpterm) = @_; |
|
my $crstype = &Apache::loncommon::course_type(); |
my %lt = &Apache::lonlocal::texthash( |
my %lt = &Apache::lonlocal::texthash( |
'pipa' => 'Pick parameters to generate membership list', |
'pipa' => 'Pick parameters to generate membership list', |
'gmem' => 'Group membership options', |
'gmem' => "$ucgpterm membership options", |
'picr' => 'Pick the criteria to use to build a list of '. |
'picr' => 'Pick the criteria to use to build a list of '. |
'course users from which you will select ', |
lc($crstype).' users from which you will select ', |
'meof' => 'members of the new group.', |
'meof' => "members of the new $gpterm.", |
'admg' => 'additional members of the group.', |
'admg' => "additional members of the $gpterm.", |
'ifno' => 'If you do not wish to add members when you first '. |
'ifno' => "If you do not wish to add members when you first ". |
'create the group, do not make any selections', |
"create the $gpterm, do not make any selections.", |
|
'asub' => "A subsequent step will also allow you to specify automatic adding/dropping of $gpterm members triggered by specified role and section changes.", |
'acty' => 'Access types', |
'acty' => 'Access types', |
'coro' => 'Course roles', |
'coro' => $crstype.' roles', |
'cose' => 'Course sections', |
'cose' => $crstype.' sections', |
); |
); |
my %status_types = ( |
my %status_types = ( |
active => &mt('Currently has access'), |
active => &mt('Currently has access'), |
Line 1218 sub membership_options {
|
Line 1384 sub membership_options {
|
future => &mt('Will have future access'), |
future => &mt('Will have future access'), |
); |
); |
|
|
my @roles = ('st','cc','in','ta','ep','cr'); |
#FIXME need to plumb around for the various cr roles defined by the user |
|
my @roles = ('st','cc','in','ta','ep'); |
|
|
my @sections = keys(%{$sectioncount}); |
my @sections = keys(%{$sectioncount}); |
|
|
Line 1229 sub membership_options {
|
Line 1396 sub membership_options {
|
<td colspan="3"> |
<td colspan="3"> |
<b>'.$lt{'gmem'}.'</b><br/>'.$lt{'picr'}); |
<b>'.$lt{'gmem'}.'</b><br/>'.$lt{'picr'}); |
if ($action eq 'create') { |
if ($action eq 'create') { |
$r->print($lt{'meof'}.'<br />'.$lt{'ifno'}); |
$r->print($lt{'meof'}.'<br />'.$lt{'ifno'}.'<br />'.$lt{'asub'}); |
} else { |
} else { |
$r->print($lt{'admg'}); |
$r->print($lt{'admg'}); |
} |
} |
Line 1253 sub membership_options {
|
Line 1420 sub membership_options {
|
$r->print(&Apache::lonhtmlcommon::role_select_row(\@roles)); |
$r->print(&Apache::lonhtmlcommon::role_select_row(\@roles)); |
if (@sections > 0) { |
if (@sections > 0) { |
@sections = sort {$a cmp $b} @sections; |
@sections = sort {$a cmp $b} @sections; |
unshift(@sections,'all'); # Put 'all' at the front of the list |
|
unshift(@sections,'none'); # Put 'no sections' next |
unshift(@sections,'none'); # Put 'no sections' next |
|
unshift(@sections,'all'); # Put 'all' at the front of the list |
$r->print('<td> </td> |
$r->print('<td> </td> |
<td colspan="3" align="center" valign="top">'. |
<td colspan="3" align="center" valign="top">'. |
§ions_selection(\@sections,'sectionpick').'</td>'); |
§ions_selection(\@sections,'sectionpick').'</td>'); |
Line 1276 sub sections_selection {
|
Line 1443 sub sections_selection {
|
} |
} |
foreach my $sec (@{$sections}) { |
foreach my $sec (@{$sections}) { |
if ($sec eq 'all') { |
if ($sec eq 'all') { |
$section_sel .= ' <option value="'.$sec.'" />all sections'."\n"; |
$section_sel .= ' <option value="'.$sec.'" selected="selected">'.&mt('all sections').'</option>'."\n"; |
} elsif ($sec eq 'none') { |
} elsif ($sec eq 'none') { |
$section_sel .= ' <option value="'.$sec.'" />no section'."\n"; |
$section_sel .= ' <option value="'.$sec.'">'.&mt('no section').'</option>'."\n"; |
} else { |
} else { |
$section_sel .= ' <option value="'.$sec.'" />'.$sec."\n"; |
$section_sel .= ' <option value="'.$sec.'">'.$sec."</option>\n"; |
} |
} |
} |
} |
my $output = ' |
my $output = ' |
Line 1291 sub sections_selection {
|
Line 1458 sub sections_selection {
|
} |
} |
|
|
sub access_date_settings { |
sub access_date_settings { |
my ($r,$tabcol,$action,$formname,$stored,$image) = @_; |
my ($r,$tabcol,$action,$formname,$stored,$image,$gpterm,$ucgpterm) = @_; |
my %lt = &Apache::lonlocal::texthash( |
my %lt = &Apache::lonlocal::texthash( |
'sten' => 'Default start and end dates for group access', |
'sten' => "Default start and end dates for $gpterm access", |
); |
); |
my $starttime = time; |
my $starttime = time; |
my $endtime = time+(6*30*24*60*60); # 6 months from now, approx |
my $endtime = time+(6*30*24*60*60); # 6 months from now, approx |
Line 1323 sub access_date_settings {
|
Line 1490 sub access_date_settings {
|
|
|
sub choose_members_form { |
sub choose_members_form { |
my ($r,$cdom,$cnum,$tabcol,$action,$formname,$page,$groupname,$description, |
my ($r,$cdom,$cnum,$tabcol,$action,$formname,$page,$groupname,$description, |
$granularity,$startdate,$enddate,$tools,$fixedprivs,$toolprivs, |
$granularity,$quota,$startdate,$enddate,$tools,$fixedprivs,$toolprivs, |
$functions,$users,$userdata,$idx,$stored,$states,$navbuttons, |
$functions,$users,$userdata,$idx,$stored,$states,$navbuttons, |
$rowColor1,$rowColor2) = @_; |
$rowColor1,$rowColor2,$gpterm,$ucgpterm,$crstype) = @_; |
my @regexps = ('user_','userpriv_','sec_'); |
my @regexps = ('user_','userpriv_','sec_'); |
my %origmembers; |
my %origmembers; |
$r->print(&Apache::lonhtmlcommon::echo_form_input( |
$r->print(&Apache::lonhtmlcommon::echo_form_input( |
['origin','action','state','page','member','specificity','branch', |
['origin','action','state','page','member','specificity','branch', |
'defpriv','autorole','autoadd','autodrop','sortby','togglefunc'], |
'defpriv','autorole','autoadd','autodrop','sortby','togglefunc'], |
\@regexps)); |
\@regexps)); |
my $earlyout = &validate_groupname($groupname,$action,$cdom,$cnum); |
my $earlyout = &validate_groupname($groupname,$action,$cdom,$cnum,$gpterm, |
|
$ucgpterm,$crstype); |
$r->print(' |
$r->print(' |
<table width="100%" cellpadding="0" cellspacing="0" border="0"> |
<table width="100%" cellpadding="0" cellspacing="0" border="0"> |
<tr> |
<tr> |
Line 1353 sub choose_members_form {
|
Line 1521 sub choose_members_form {
|
if ($action eq 'create') { |
if ($action eq 'create') { |
&print_current_settings($r,$action,$tabcol,$rowColor1,$rowColor2, |
&print_current_settings($r,$action,$tabcol,$rowColor1,$rowColor2, |
$functions,$startdate,$enddate,$groupname, |
$functions,$startdate,$enddate,$groupname, |
$description,$granularity,\@available, |
$description,$granularity,$quota,\@available, |
\@unavailable); |
\@unavailable,$gpterm,$ucgpterm); |
$specimg = 4; |
$specimg = 4; |
$memimg = 5; |
$memimg = 5; |
} else { |
} else { |
Line 1376 sub choose_members_form {
|
Line 1544 sub choose_members_form {
|
} |
} |
&privilege_specificity($r,$tabcol,$rowColor1,$rowColor2,$action, |
&privilege_specificity($r,$tabcol,$rowColor1,$rowColor2,$action, |
$specimg,$tools,$stored,$toolprivs, |
$specimg,$tools,$stored,$toolprivs, |
$fixedprivs,\@available,$formname); |
$fixedprivs,\@available,$formname,$gpterm,$ucgpterm); |
my $newusers = &pick_new_members($r,$action,$formname,$tabcol,$rowColor1, |
my $newusers = &pick_new_members($r,$action,$formname,$tabcol,$rowColor1, |
$rowColor2,\@available,$idx,$stored, |
$rowColor2,\@available,$idx,$stored, |
$memimg,$users,$userdata,$granularity, |
$memimg,$users,$userdata,$granularity, |
\%origmembers); |
\%origmembers,$gpterm,$ucgpterm); |
if ($newusers || $action eq 'create') { |
if ($newusers || $action eq 'create') { |
&display_navbuttons($r,$formname,$$states{$action}[$page-1], |
&display_navbuttons($r,$formname,$$states{$action}[$page-1], |
$$navbuttons{'gtps'},$$states{$action}[$page+1], |
$$navbuttons{'gtps'},$$states{$action}[$page+1], |
Line 1433 sub check_tools {
|
Line 1601 sub check_tools {
|
|
|
sub print_current_settings { |
sub print_current_settings { |
my ($r,$action,$tabcol,$rowColor1,$rowColor2,$functions,$startdate,$enddate, |
my ($r,$action,$tabcol,$rowColor1,$rowColor2,$functions,$startdate,$enddate, |
$groupname,$description,$granularity,$available,$unavailable) =@_; |
$groupname,$description,$granularity,$quota,$available,$unavailable, |
|
$gpterm,$ucgpterm) = @_; |
|
|
my %lt = &Apache::lonlocal::texthash( |
my %lt = &Apache::lonlocal::texthash( |
grna => 'Group Name', |
grna => "$ucgpterm Name", |
desc => 'Description', |
desc => 'Description', |
grfn => 'Group Functions', |
grfn => "$ucgpterm Functions", |
gran => 'Granularity', |
gran => 'Granularity', |
|
quot => 'File quota', |
dfac => 'Default access dates', |
dfac => 'Default access dates', |
ygrs => 'Your group selections', |
ygrs => "Your $gpterm selections", |
tfwa => 'The following settings will apply to the group:', |
tfwa => "The following settings will apply to the $gpterm:", |
difn => 'Different functionality<br />for different users:', |
difn => 'Different functionality<br />for different members:', |
stda => 'Start date', |
stda => 'Start date', |
enda => 'End date:', |
enda => 'End date:', |
); |
); |
Line 1474 sub print_current_settings {
|
Line 1644 sub print_current_settings {
|
<td><b>'.$lt{'desc'}.'</b></td> |
<td><b>'.$lt{'desc'}.'</b></td> |
<td><b>'.$lt{'grfn'}.'</b></td> |
<td><b>'.$lt{'grfn'}.'</b></td> |
<td><b>'.$lt{'gran'}.'</b></td> |
<td><b>'.$lt{'gran'}.'</b></td> |
|
<td><b>'.$lt{'quot'}.'</b></td> |
<td><b>'.$lt{'dfac'}.'</b></td> |
<td><b>'.$lt{'dfac'}.'</b></td> |
</tr> |
</tr> |
<tr bgcolor="'.$rowColor2.'"> |
<tr bgcolor="'.$rowColor2.'"> |
Line 1520 sub print_current_settings {
|
Line 1691 sub print_current_settings {
|
$r->print(<<"END"); |
$r->print(<<"END"); |
</td> |
</td> |
<td valign="top"><small><b>$lt{'difn'} |
<td valign="top"><small><b>$lt{'difn'} |
</b> $granularity</small> |
</b> $granularity</small></td> |
|
<td valign="top"><small>$quota Mb</small></td> |
<td valign="top"><small><b>$lt{'stda'}</b> $showstart<br /> |
<td valign="top"><small><b>$lt{'stda'}</b> $showstart<br /> |
<b>$lt{'enda'}</b> $showend</small> |
<b>$lt{'enda'}</b> $showend</small> |
</td> |
</td> |
Line 1536 END
|
Line 1708 END
|
|
|
sub pick_new_members { |
sub pick_new_members { |
my ($r,$action,$formname,$tabcol,$rowColor1,$rowColor2,$available,$idx, |
my ($r,$action,$formname,$tabcol,$rowColor1,$rowColor2,$available,$idx, |
$stored,$img,$users,$userdata,$granularity,$origmembers) = @_; |
$stored,$img,$users,$userdata,$granularity,$origmembers,$gpterm, |
|
$ucgpterm) = @_; |
my %lt = &Apache::lonlocal::texthash( |
my %lt = &Apache::lonlocal::texthash( |
'gpme' => 'Group membership', |
'gpme' => "$ucgpterm membership", |
'addm' => 'Add members', |
'addm' => 'Add members', |
'setf' => 'Set functionality', |
'setf' => 'Set functionality', |
'func' => 'Functionality', |
'func' => 'Functionality', |
'nome' => 'No members to add at this time.', |
'nome' => 'No members to add at this time.', |
'nnew' => 'There are no users to add as new members, as all users'. |
'nnew' => "There are no users to add as new members, as all users". |
' matching the specified type(s), role(s), and/or '. |
" matching the specified type(s), role(s), and/or ". |
'section(s) are already affiliated with this group.', |
"section(s) are already affiliated with this $gpterm.", |
'yoma' => 'You may need to use the '."'".'modify existing, past or '. |
'yoma' => 'You may need to use the '."'".'modify existing, past or '. |
'future members'."'".' page if you need to re-enable '. |
'future members'."'".' page if you need to re-enable '. |
'or activate access for previous or future members.', |
'or activate access for previous or future members.', |
Line 1611 sub pick_new_members {
|
Line 1784 sub pick_new_members {
|
</td> |
</td> |
<td><b><a href="javascript:changeSort('."'domain'".')">'.&mt('Domain').'</a></b></td> |
<td><b><a href="javascript:changeSort('."'domain'".')">'.&mt('Domain').'</a></b></td> |
<td><b><a href="javascript:changeSort('."'id'".')">ID</a></b></td> |
<td><b><a href="javascript:changeSort('."'id'".')">ID</a></b></td> |
|
<td><b><a href="javascript:changeSort('."'section'".')">Section</a></b></td> |
'); |
'); |
if (@{$available} > 0) { |
if (@{$available} > 0) { |
$r->print('<td><b>'.$lt{'func'}.'</b></td>'); |
$r->print('<td><b>'.$lt{'func'}.'</b></td>'); |
Line 1619 sub pick_new_members {
|
Line 1793 sub pick_new_members {
|
if (@{$available} > 0) { |
if (@{$available} > 0) { |
if ($granularity eq 'Yes') { |
if ($granularity eq 'Yes') { |
$r->print('<tr bgcolor="#cccccc"> |
$r->print('<tr bgcolor="#cccccc"> |
<td colspan="5"> </td> |
<td colspan="6"> </td> |
<td align="center"><small><nobr><b>'.&mt('All:').'</b> '); |
<td align="center"><small><nobr><b>'.&mt('All:').'</b> '); |
foreach my $tool (@{$available}) { |
foreach my $tool (@{$available}) { |
$r->print('<label><input type="checkbox" name="togglefunc" '. |
$r->print('<label><input type="checkbox" name="togglefunc" '. |
Line 1639 sub pick_new_members {
|
Line 1813 sub pick_new_members {
|
push(@{$Sortby{$members{$user}[$$idx{udom}]}},$user); |
push(@{$Sortby{$members{$user}[$$idx{udom}]}},$user); |
} elsif ($env{'form.sortby'} eq 'id') { |
} elsif ($env{'form.sortby'} eq 'id') { |
push(@{$Sortby{$members{$user}[$$idx{id}]}},$user); |
push(@{$Sortby{$members{$user}[$$idx{id}]}},$user); |
|
} elsif ($env{'form.sortby'} eq 'section') { |
|
push(@{$Sortby{$members{$user}[$$idx{section}]}},$user); |
} else { |
} else { |
push(@{$Sortby{$members{$user}[$$idx{fullname}]}},$user); |
push(@{$Sortby{$members{$user}[$$idx{fullname}]}},$user); |
} |
} |
Line 1656 sub pick_new_members {
|
Line 1832 sub pick_new_members {
|
my $fullname = $members{$user}[$$idx{fullname}]; |
my $fullname = $members{$user}[$$idx{fullname}]; |
my $udom = $members{$user}[$$idx{udom}]; |
my $udom = $members{$user}[$$idx{udom}]; |
my $uname = $members{$user}[$$idx{uname}]; |
my $uname = $members{$user}[$$idx{uname}]; |
|
my $section = $members{$user}[$$idx{section}]; |
$r->print('<tr bgcolor="'.$rowColor.'"><td align="right"> |
$r->print('<tr bgcolor="'.$rowColor.'"><td align="right"> |
<input type="checkbox" name="member" value="'.$user.'" /></td><td><small>'. |
<input type="checkbox" name="member" value="'.$user.'" /></td><td><small>'. |
$fullname.'</small></td><td><small>'.$uname.'</small></td><td><small>'. |
$fullname.'</small></td><td><small>'.$uname.'</small></td><td><small>'. |
$udom.'</small></td><td><small>'.$id.'</small></td>'); |
$udom.'</small></td><td><small>'.$id.'</small></td>'. |
|
'<td><small>'.$section.'</small></td>'); |
if (@{$available} > 0) { |
if (@{$available} > 0) { |
$r->print('<td align="center"><nobr><small>'. |
$r->print('<td align="center"><nobr><small>'. |
' '); |
' '); |
Line 1702 sub pick_new_members {
|
Line 1880 sub pick_new_members {
|
|
|
sub privilege_specificity { |
sub privilege_specificity { |
my ($r,$tabcol,$rowColor1,$rowColor2,$action,$img,$tools,$stored, |
my ($r,$tabcol,$rowColor1,$rowColor2,$action,$img,$tools,$stored, |
$toolprivs,$fixedprivs,$available,$formname) = @_; |
$toolprivs,$fixedprivs,$available,$formname,$gpterm,$ucgpterm) = @_; |
my %lt = &Apache::lonlocal::texthash ( |
my %lt = &Apache::lonlocal::texthash ( |
'uprv' => 'User privileges', |
'uprv' => 'User privileges', |
'frty' => 'For each type of functionality you have chosen to include, '. |
'frty' => 'For each type of functionality you have chosen to include, '. |
Line 1717 sub privilege_specificity {
|
Line 1895 sub privilege_specificity {
|
'privileges which apply to members with access to that '. |
'privileges which apply to members with access to that '. |
'functionality, and may also include additional privileges '. |
'functionality, and may also include additional privileges '. |
'which can be set for specific members.', |
'which can be set for specific members.', |
'cutg' => 'Currently the group is configured ', |
'cutg' => "Currently the $gpterm is configured ", |
'sdif' => 'so different group members can receive different privileges.', |
'sdif' => "so different $gpterm members can receive different privileges.", |
'sall' => 'so all group members will receive the same privileges.', |
'sall' => "so all $gpterm members will receive the same privileges.", |
'algm' => 'All group members will receive the same privileges.', |
'algm' => "All $gpterm members will receive the same privileges.", |
'smgp' => 'Some group members will receive different privileges from '. |
'smgp' => "Some $gpterm members will receive different privileges from ". |
'others.', |
"others.", |
'thwi' => 'These will be the privileges all group members receive, '. |
'thwi' => "These will be the privileges all $gpterm members receive, ". |
'if you selected the first option above.', |
"if you selected the first option above.", |
'thes' => 'These will be the privileges given to members assigned '. |
'thes' => "These will be the privileges given to members assigned ". |
'in the future, including via automatic group assignment '. |
"in the future, including via automatic $gpterm assignment ". |
'for specific sections/roles ', |
"for specific sections/roles ", |
'asyo' => 'As you have chosen not to include any functionality in the '. |
'asyo' => "As you have chosen not to include any functionality in the ". |
'group, no default user privileges settings need to be set.', |
"$gpterm, no default user privileges settings need to be set.", |
'plin' => 'Please indicate which <b>optional</b> privileges members '. |
'plin' => 'Please indicate which <b>optional</b> privileges members '. |
'will receive by default.', |
'will receive by default.', |
'oppr' => 'Optional privileges', |
'oppr' => 'Optional privileges', |
Line 1994 sub display_defprivs {
|
Line 2172 sub display_defprivs {
|
sub change_members_form { |
sub change_members_form { |
my ($r,$cdom,$cnum,$tabcol,$action,$formname,$page,$groupname,$description, |
my ($r,$cdom,$cnum,$tabcol,$action,$formname,$page,$groupname,$description, |
$startdate,$enddate,$tools,$fixedprivs,$functions,$users,$userdata, |
$startdate,$enddate,$tools,$fixedprivs,$functions,$users,$userdata, |
$granularity,$specificity,$idx,$states,$navbuttons,$rowColor1, |
$granularity,$quota,$specificity,$idx,$states,$navbuttons,$rowColor1, |
$rowColor2) = @_; |
$rowColor2,$gpterm,$ucgpterm) = @_; |
my %lt = &Apache::lonlocal::texthash( |
my %lt = &Apache::lonlocal::texthash( |
grse => 'Group settings', |
grse => "$ucgpterm settings", |
mogm => 'Modify group membership', |
mogm => "Modify $gpterm membership", |
); |
); |
my @regexps = ('user_','userpriv_'); |
my @regexps = ('user_','userpriv_'); |
$r->print(&Apache::lonhtmlcommon::echo_form_input( |
$r->print(&Apache::lonhtmlcommon::echo_form_input( |
Line 2023 sub change_members_form {
|
Line 2201 sub change_members_form {
|
'); |
'); |
&print_current_settings($r,$action,$tabcol,$rowColor1,$rowColor2, |
&print_current_settings($r,$action,$tabcol,$rowColor1,$rowColor2, |
$functions,$startdate,$enddate,$groupname, |
$functions,$startdate,$enddate,$groupname, |
$description,$granularity,\@available,\@unavailable); |
$description,$granularity,$quota,\@available, |
|
\@unavailable,$gpterm,$ucgpterm); |
$r->print(' |
$r->print(' |
</td></tr><tr><td colspan="4"> </td></tr>'); |
</td></tr><tr><td colspan="4"> </td></tr>'); |
&topic_bar($r,$tabcol,2,$lt{'mogm'}); |
&topic_bar($r,$tabcol,2,$lt{'mogm'}); |
Line 2061 sub current_membership {
|
Line 2240 sub current_membership {
|
'curf' => 'Current Functionality', |
'curf' => 'Current Functionality', |
'chpr' => 'Change Privileges' |
'chpr' => 'Change Privileges' |
); |
); |
if (keys(%membership) > 0) { |
my ($current,$hastools,$addtools,$num_reenable,$num_activate,$num_expire) = |
my %current = (); |
&Apache::longroup::group_memberlist($cdom,$cnum,$groupname,$fixedprivs, |
my %allnames = (); |
$available); |
my $hastools = 0; |
if (keys(%{$current}) > 0) { |
my $addtools = 0; |
$r->print(' |
my $num_reenable = 0; |
|
my $num_activate = 0; |
|
my $num_expire - 0; |
|
foreach my $key (sort(keys(%membership))) { |
|
if ($key =~ /^\Q$groupname\E:([^:]+):([^:]+)$/) { |
|
my $uname = $1; |
|
my $udom = $2; |
|
my $user = $uname.':'.$udom; |
|
my($end,$start,@userprivs) = split(/:/,$membership{$key}); |
|
unless ($start == -1) { |
|
$allnames{$udom}{$uname} = 1; |
|
%{$current{$user}} = (); |
|
$current{$user}{uname} = $uname; |
|
$current{$user}{udom} = $udom; |
|
$current{$user}{start} = |
|
&Apache::lonlocal::locallocaltime($start); |
|
if ($end == 0) { |
|
$current{$user}{end} = 'No end date'; |
|
} else { |
|
$current{$user}{end} = |
|
&Apache::lonlocal::locallocaltime($end); |
|
} |
|
my $now = time; |
|
if (($end > 0) && ($end < $now)) { |
|
$current{$user}{changestate} = 'reenable'; |
|
$num_reenable++; |
|
} elsif (($start > $now)) { |
|
$current{$user}{changestate} = 'activate'; |
|
$num_activate ++; |
|
} else { |
|
$current{$user}{changestate} = 'expire'; |
|
$num_expire ++; |
|
} |
|
@{$current{$user}{currtools}} = (); |
|
@{$current{$user}{newtools}} = (); |
|
if (@userprivs > 0) { |
|
foreach my $tool (sort(keys(%{$fixedprivs}))) { |
|
foreach my $priv (keys(%{$$fixedprivs{$tool}})) { |
|
if (grep/^$priv$/,@userprivs) { |
|
push(@{$current{$user}{currtools}},$tool); |
|
last; |
|
} |
|
} |
|
} |
|
$hastools = 1; |
|
} |
|
if (@{$available} > 0) { |
|
if (@{$current{$user}{currtools}} > 0) { |
|
if ("@{$available}" ne "@{$current{$user}{currtools}}") { |
|
foreach my $tool (@{$available}) { |
|
unless (grep/^$tool$/,@{$current{$user}{currtools}}) { |
|
push(@{$current{$user}{newtools}},$tool); |
|
} |
|
} |
|
} |
|
} else { |
|
@{$current{$user}{newtools}} = @{$available}; |
|
} |
|
if (@{$current{$user}{newtools}} > 0) { |
|
$addtools = 1; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
if (keys(%current) > 0) { |
|
my %idhash; |
|
foreach my $udom (keys(%allnames)) { |
|
%{$idhash{$udom}} = &Apache::lonnet::idrget($udom, |
|
keys(%{$allnames{$udom}})); |
|
foreach my $uname (keys(%{$idhash{$udom}})) { |
|
$current{$uname.':'.$udom}{'id'} = $idhash{$udom}{$uname}; |
|
} |
|
foreach my $uname (keys(%{$allnames{$udom}})) { |
|
$current{$uname.':'.$udom}{'fullname'} = |
|
&Apache::loncommon::plainname($uname,$udom, |
|
'lastname'); |
|
} |
|
} |
|
$r->print(' |
|
<tr> |
<tr> |
<td> </td> |
<td> </td> |
<td colspan="2"> |
<td colspan="2"> |
<table> |
<table> |
<tr>'); |
<tr>'); |
if ($num_expire) { |
if ($num_expire) { |
&check_uncheck_buttons($r,$formname,'expire',$lt{'expi'}); |
&check_uncheck_buttons($r,$formname,'expire',$lt{'expi'}); |
} |
} |
if ($num_reenable) { |
if ($num_reenable) { |
&check_uncheck_buttons($r,$formname,'reenable',$lt{'reen'}); |
&check_uncheck_buttons($r,$formname,'reenable',$lt{'reen'}); |
} |
} |
if ($num_activate) { |
if ($num_activate) { |
&check_uncheck_buttons($r,$formname,'activate',$lt{'acti'}); |
&check_uncheck_buttons($r,$formname,'activate',$lt{'acti'}); |
|
} |
|
&check_uncheck_buttons($r,$formname,'deletion',$lt{'dele'}); |
|
if (@{$available} > 0) { |
|
if ($specificity eq 'Yes') { |
|
&check_uncheck_buttons($r,$formname,'changepriv',$lt{'chpr'}); |
} |
} |
&check_uncheck_buttons($r,$formname,'deletion',$lt{'dele'}); |
if ($granularity eq 'Yes') { |
if (@{$available} > 0) { |
$r->print(&check_uncheck_tools($r,$available)); |
if ($specificity eq 'Yes') { |
$r->print(' |
&check_uncheck_buttons($r,$formname,'changepriv',$lt{'chpr'}); |
|
} |
|
if ($granularity eq 'Yes') { |
|
$r->print(&check_uncheck_tools($r,$available)); |
|
$r->print(' |
|
<td> |
<td> |
<nobr> |
<nobr> |
<fieldset><legend><b>'.$lt{'curf'}.'</b></legend> |
<fieldset><legend><b>'.$lt{'curf'}.'</b></legend> |
Line 2180 sub current_membership {
|
Line 2279 sub current_membership {
|
</nobr> |
</nobr> |
</td> |
</td> |
'); |
'); |
} |
|
} |
} |
$r->print(<<"END"); |
} |
|
$r->print(<<"END"); |
</tr> |
</tr> |
</table> |
</table> |
</td> |
</td> |
Line 2195 sub current_membership {
|
Line 2294 sub current_membership {
|
<td> </td> |
<td> </td> |
<td colspan="3"> |
<td colspan="3"> |
END |
END |
$r->print(&Apache::lonhtmlcommon::start_pick_box()); |
$r->print(&Apache::lonhtmlcommon::start_pick_box()); |
$r->print(<<"END"); |
$r->print(<<"END"); |
<table border="0" cellpadding="4" cellspacing="1"> |
<table border="0" cellpadding="4" cellspacing="1"> |
<tr bgcolor="$tabcol" align="center"> |
<tr bgcolor="$tabcol" align="center"> |
<td><b>$lt{'actn'}</b></td> |
<td><b>$lt{'actn'}</b></td> |
Line 2208 END
|
Line 2307 END
|
<td><b><a href="javascript:changeSort('start')">$lt{'stda'}</a></b></td> |
<td><b><a href="javascript:changeSort('start')">$lt{'stda'}</a></b></td> |
<td><b><a href="javascript:changeSort('end')">$lt{'enda'}</a></b></td> |
<td><b><a href="javascript:changeSort('end')">$lt{'enda'}</a></b></td> |
END |
END |
my $colspan = 0; |
my $colspan = 0; |
if ($hastools) { |
if ($hastools) { |
$r->print('<td><b>'.$lt{'curf'}.'</b></td>'); |
$r->print('<td><b>'.$lt{'curf'}.'</b></td>'); |
$colspan ++; |
$colspan ++; |
} |
} |
if ($addtools) { |
if ($addtools) { |
$r->print('<td><b>Additional Functionality</b></td>'); |
$r->print('<td><b>Additional Functionality</b></td>'); |
$colspan ++; |
$colspan ++; |
} |
} |
$r->print('</tr>'); |
$r->print('</tr>'); |
if ($colspan) { |
if ($colspan) { |
if ($granularity eq 'Yes') { |
if ($granularity eq 'Yes') { |
$r->print('<tr bgcolor="#cccccc"> |
$r->print('<tr bgcolor="#cccccc"> |
<td colspan="7"> </td> |
<td colspan="7"> </td> |
<td colspan="'.$colspan.'" align="center"><small><nobr><b>'.&mt('All:'). |
<td colspan="'.$colspan.'" align="center"><small><nobr><b>'.&mt('All:'). |
'</b> '); |
'</b> '); |
foreach my $tool (@{$available}) { |
foreach my $tool (@{$available}) { |
$r->print('<label><input type="checkbox" name="togglefunc"'. |
$r->print('<label><input type="checkbox" name="togglefunc"'. |
' onclick="javascript:toggleTools(document.'.$formname.'.user_'.$tool.',this);"'. |
' onclick="javascript:toggleTools(document.'.$formname.'.user_'.$tool.',this);"'. |
' value="'.$tool.'">'.'<b>'.$tool.'</b></label> '); |
' value="'.$tool.'">'.'<b>'.$tool.'</b></label> '); |
} |
|
$r->print('</nobr></small></td></tr>'); |
|
} |
} |
|
$r->print('</nobr></small></td></tr>'); |
} |
} |
my %Sortby = (); |
} |
foreach my $user (sort(keys(%current))) { |
my %Sortby = (); |
if ($env{'form.sortby'} eq 'fullname') { |
foreach my $user (sort(keys(%{$current}))) { |
push(@{$Sortby{$current{$user}{fullname}}},$user); |
if ($env{'form.sortby'} eq 'fullname') { |
} elsif ($env{'form.sortby'} eq 'username') { |
push(@{$Sortby{$$current{$user}{fullname}}},$user); |
push(@{$Sortby{$current{$user}{uname}}},$user); |
} elsif ($env{'form.sortby'} eq 'username') { |
} elsif ($env{'form.sortby'} eq 'domain') { |
push(@{$Sortby{$$current{$user}{uname}}},$user); |
push(@{$Sortby{$current{$user}{udom}}},$user); |
} elsif ($env{'form.sortby'} eq 'domain') { |
} elsif ($env{'form.sortby'} eq 'id') { |
push(@{$Sortby{$$current{$user}{udom}}},$user); |
push(@{$Sortby{$current{$user}{id}}},$user); |
} elsif ($env{'form.sortby'} eq 'id') { |
|
push(@{$Sortby{$$current{$user}{id}}},$user); |
|
} else { |
|
push(@{$Sortby{$$current{$user}{fullname}}},$user); |
|
} |
|
} |
|
my $rowNum = 0; |
|
my $rowColor; |
|
foreach my $key (sort(keys(%Sortby))) { |
|
foreach my $user (@{$Sortby{$key}}) { |
|
if ($rowNum %2 == 1) { |
|
$rowColor = $rowColor1; |
} else { |
} else { |
push(@{$Sortby{$current{$user}{fullname}}},$user); |
$rowColor = $rowColor2; |
} |
} |
} |
my $id = $$current{$user}{id}; |
my $rowNum = 0; |
my $fullname = $$current{$user}{fullname}; |
my $rowColor; |
my $udom = $$current{$user}{udom}; |
foreach my $key (sort(keys(%Sortby))) { |
my $uname = $$current{$user}{uname}; |
foreach my $user (@{$Sortby{$key}}) { |
my $start = $$current{$user}{start}; |
if ($rowNum %2 == 1) { |
my $end = $$current{$user}{end}; |
$rowColor = $rowColor1; |
$r->print('<tr bgcolor="'.$rowColor.'"> |
} else { |
<td><small>'); |
$rowColor = $rowColor2; |
if ($$current{$user}{changestate} eq 'reenable') { |
} |
$r->print('<nobr><label>'. |
my $id = $current{$user}{id}; |
|
my $fullname = $current{$user}{fullname}; |
|
my $udom = $current{$user}{udom}; |
|
my $uname = $current{$user}{uname}; |
|
my $start = $current{$user}{start}; |
|
my $end = $current{$user}{end}; |
|
$r->print('<tr bgcolor="'.$rowColor.'"> |
|
<td><small>'); |
|
if ($current{$user}{changestate} eq 'reenable') { |
|
$r->print('<nobr><label>'. |
|
'<input type="checkbox" name="reenable" value="'.$user.'" />'. |
'<input type="checkbox" name="reenable" value="'.$user.'" />'. |
$lt{'reen'}.'</label></nobr><br />'); |
$lt{'reen'}.'</label></nobr><br />'); |
} elsif ($current{$user}{changestate} eq 'expire') { |
} elsif ($$current{$user}{changestate} eq 'expire') { |
$r->print('<nobr><label>'. |
$r->print('<nobr><label>'. |
'<input type="checkbox" name="expire" value="'.$user.'" />'. |
'<input type="checkbox" name="expire" value="'.$user.'" />'. |
$lt{'expi'}.'</label></nobr><br />'); |
$lt{'expi'}.'</label></nobr><br />'); |
} elsif ($current{$user}{changestate} eq 'activate') { |
} elsif ($$current{$user}{changestate} eq 'activate') { |
$r->print('<nobr><label>'. |
$r->print('<nobr><label>'. |
'<input type="checkbox" name="activate" value="'.$user.'" />'. |
'<input type="checkbox" name="activate" value="'.$user.'" />'. |
$lt{'acti'}.'</label></nobr><br />'); |
$lt{'acti'}.'</label></nobr><br />'); |
} |
} |
$r->print('<nobr><label>'. |
$r->print('<nobr><label>'. |
'<input type="checkbox" name="deletion" value="'.$user.'" />'. |
'<input type="checkbox" name="deletion" value="'.$user.'" />'. |
$lt{'dele'}.'</label></nobr>'); |
$lt{'dele'}.'</label></nobr>'); |
if ($specificity eq 'Yes') { |
if ($specificity eq 'Yes') { |
$r->print('<br /><nobr><label>'. |
$r->print('<br /><nobr><label>'. |
'<input type="checkbox" name="changepriv" value="'.$user.'" />'.$lt{'chpr'}. |
'<input type="checkbox" name="changepriv" value="'.$user.'" />'.$lt{'chpr'}. |
'</label></nobr>'); |
'</label></nobr>'); |
} |
} |
$r->print(' |
$r->print(' |
</td> |
</td> |
<td><small>'. |
<td><small>'. |
$fullname.'</small></td><td><small>'.$uname.'</small></td><td><small>'. |
$fullname.'</small></td><td><small>'.$uname.'</small></td><td><small>'. |
$udom.'</small></td><td><small>'.$id.'</small></td><td><small>'.$start. |
$udom.'</small></td><td><small>'.$id.'</small></td><td><small>'.$start. |
'</small></td><td><small>'.$end.'</small></td>'); |
'</small></td><td><small>'.$end.'</small></td>'); |
if ($hastools) { |
if ($hastools) { |
$r->print('<td align="left"><small><nobr>'. |
$r->print('<td align="left"><small><nobr>'. |
' '); |
' '); |
foreach my $tool (@{$current{$user}{currtools}}) { |
foreach my $tool (@{$$current{$user}{currtools}}) { |
if ($granularity eq 'Yes') { |
if ($granularity eq 'Yes') { |
$r->print('<label><input type="checkbox" '. |
$r->print('<label><input type="checkbox" '. |
'checked="checked" '. |
'checked="checked" '. |
'name="user_'.$tool.'" value="'. |
'name="user_'.$tool.'" value="'. |
$user.'" />'.$tool.'</label>'); |
$user.'" />'.$tool.'</label>'); |
} else { |
} else { |
$r->print('<input type="hidden" '. |
$r->print('<input type="hidden" '. |
'checked="checked" '. |
'checked="checked" '. |
'name="user_'.$tool.'" value="'. |
'name="user_'.$tool.'" value="'. |
$user.'" />'.$tool); |
$user.'" />'.$tool); |
} |
} |
$r->print(' '); |
$r->print(' '); |
} |
|
$r->print('</nobr></small></td>'); |
|
} |
} |
if ($addtools) { |
$r->print('</nobr></small></td>'); |
$r->print('<td align="left"><small>'); |
} |
if ($granularity eq 'Yes') { |
if ($addtools) { |
foreach my $tool (@{$current{$user}{newtools}}) { |
$r->print('<td align="left"><small>'); |
$r->print('<nobr><label><input type="checkbox" |
if ($granularity eq 'Yes') { |
|
foreach my $tool (@{$$current{$user}{newtools}}) { |
|
$r->print('<nobr><label><input type="checkbox" |
name="user_'.$tool.'" value="'. |
name="user_'.$tool.'" value="'. |
$user.'" />'.$tool. |
$user.'" />'.$tool. |
'</label></nobr> '); |
'</label></nobr> '); |
} |
} |
} else { |
} else { |
foreach my $tool (@{$current{$user}{newtools}}) { |
foreach my $tool (@{$$current{$user}{newtools}}) { |
$r->print('<nobr><input type="hidden" |
$r->print('<nobr><input type="hidden" |
name="user_'. $tool.'" value="'. |
name="user_'. $tool.'" value="'. |
$user.'" />'.$tool. |
$user.'" />'.$tool. |
'</nobr> '); |
'</nobr> '); |
} |
|
} |
} |
$r->print('</small></td>'); |
|
} |
} |
$r->print('</tr>'."\n"); |
$r->print('</small></td>'); |
$rowNum ++; |
|
} |
} |
|
$r->print('</tr>'."\n"); |
|
$rowNum ++; |
} |
} |
$r->print(&Apache::lonhtmlcommon::end_pick_box()); |
} |
$r->print(' |
$r->print(&Apache::lonhtmlcommon::end_pick_box()); |
|
$r->print(' |
</td> |
</td> |
</tr>'); |
</tr>'); |
} |
|
} |
} |
return; |
return; |
} |
} |
Line 2364 sub change_privs_form {
|
Line 2462 sub change_privs_form {
|
my ($r,$cdom,$cnum,$tabcol,$action,$formname,$page,$startdate,$enddate, |
my ($r,$cdom,$cnum,$tabcol,$action,$formname,$page,$startdate,$enddate, |
$tools,$functions,$toolprivs,$fixedprivs,$userdata,$usertools, |
$tools,$functions,$toolprivs,$fixedprivs,$userdata,$usertools, |
$memchg,$idx,$states,$stored,$sectioncount,$navbuttons,$rowColor1, |
$memchg,$idx,$states,$stored,$sectioncount,$navbuttons,$rowColor1, |
$rowColor2) = @_; |
$rowColor2,$gpterm,$ucgpterm) = @_; |
my @regexps = ('userpriv_'); |
my @regexps = ('userpriv_'); |
my $nexttext; |
my $nexttext; |
my %lt = &Apache::lonlocal::texthash( |
my %lt = &Apache::lonlocal::texthash( |
'tode' => 'To be deleted', |
'tode' => 'To be deleted', |
'toex' => 'To be expired', |
'toex' => 'To be expired', |
'nome' => 'No members to be deleted or expired from the group.', |
'nome' => "No members to be deleted or expired from the $gpterm.", |
); |
); |
$r->print(&Apache::lonhtmlcommon::echo_form_input( |
$r->print(&Apache::lonhtmlcommon::echo_form_input( |
['origin','action','state','page','sortby'],\@regexps)); |
['origin','action','state','page','sortby'],\@regexps)); |
Line 2409 sub change_privs_form {
|
Line 2507 sub change_privs_form {
|
'</td></tr><tr><td colspan="4"> </td></tr>'); |
'</td></tr><tr><td colspan="4"> </td></tr>'); |
} |
} |
|
|
&topic_bar($r,$tabcol,4,&mt('Group member privileges')); |
&topic_bar($r,$tabcol,4,&mt('[_1] member privileges',$ucgpterm)); |
|
|
my $numchgs = &member_privileges_form($r,$tabcol,$action,$formname,$tools, |
my $numchgs = &member_privileges_form($r,$tabcol,$action,$formname,$tools, |
$toolprivs,$fixedprivs,$userdata, |
$toolprivs,$fixedprivs,$userdata, |
$usertools,$idx,$memchg,$states, |
$usertools,$idx,$memchg,$states, |
$stored,$rowColor1,$rowColor2); |
$stored,$rowColor1,$rowColor2, |
|
$gpterm); |
$r->print('</td></tr><tr><td colspan="4"> </td></tr>'); |
$r->print('</td></tr><tr><td colspan="4"> </td></tr>'); |
my $prevtext = $$navbuttons{'gtps'}; |
my $prevtext = $$navbuttons{'gtps'}; |
if ($numchgs || $exp_or_del) { |
if ($numchgs || $exp_or_del) { |
Line 2429 sub change_privs_form {
|
Line 2528 sub change_privs_form {
|
|
|
sub add_members_form { |
sub add_members_form { |
my ($r,$tabcol,$action,$formname,$page,$startdate,$enddate,$groupname, |
my ($r,$tabcol,$action,$formname,$page,$startdate,$enddate,$groupname, |
$description,$granularity,$sectioncount,$tools,$functions,$stored, |
$description,$granularity,$quota,$sectioncount,$tools,$functions, |
$states,$navbuttons,$rowColor1,$rowColor2) = @_; |
$stored,$states,$navbuttons,$rowColor1,$rowColor2,$gpterm,$ucgpterm)=@_; |
$r->print(' <br /> |
$r->print(' <br /> |
<table width="100%" cellpadding="0" cellspacing="0" border="0"> |
<table width="100%" cellpadding="0" cellspacing="0" border="0"> |
<tr> |
<tr> |
Line 2442 sub add_members_form {
|
Line 2541 sub add_members_form {
|
&check_tools($functions,$tools,\@available,\@unavailable); |
&check_tools($functions,$tools,\@available,\@unavailable); |
&print_current_settings($r,$action,$tabcol,$rowColor1,$rowColor2, |
&print_current_settings($r,$action,$tabcol,$rowColor1,$rowColor2, |
$functions,$startdate,$enddate,$groupname, |
$functions,$startdate,$enddate,$groupname, |
$description,$granularity,\@available,\@unavailable); |
$description,$granularity,$quota,\@available, |
|
\@unavailable,$gpterm,$ucgpterm); |
$r->print(' |
$r->print(' |
</td> |
</td> |
</tr> |
</tr> |
Line 2450 sub add_members_form {
|
Line 2550 sub add_members_form {
|
<td colspan="4"> </td> |
<td colspan="4"> </td> |
</tr>'); |
</tr>'); |
|
|
&membership_options($r,$action,$formname,$tabcol,$sectioncount,1); |
&membership_options($r,$action,$formname,$tabcol,$sectioncount,1,$gpterm, |
|
$ucgpterm); |
my $nexttext = $$navbuttons{'gtns'}; |
my $nexttext = $$navbuttons{'gtns'}; |
my $prevtext = $$navbuttons{'gtpp'}; |
my $prevtext = $$navbuttons{'gtpp'}; |
&display_navbuttons($r,$formname,$$states{$action}[$page-1],$prevtext, |
&display_navbuttons($r,$formname,$$states{$action}[$page-1],$prevtext, |
Line 2463 sub add_members_form {
|
Line 2564 sub add_members_form {
|
sub choose_privs_form { |
sub choose_privs_form { |
my ($r,$cdom,$cnum,$tabcol,$action,$formname,$page,$startdate,$enddate, |
my ($r,$cdom,$cnum,$tabcol,$action,$formname,$page,$startdate,$enddate, |
$tools,$functions,$toolprivs,$fixedprivs,$userdata,$usertools,$idx, |
$tools,$functions,$toolprivs,$fixedprivs,$userdata,$usertools,$idx, |
$states,$stored,$sectioncount,$navbuttons,$rowColor1,$rowColor2) = @_; |
$states,$stored,$sectioncount,$navbuttons,$rowColor1,$rowColor2, |
|
$gpterm,$ucgpterm,$crstype) = @_; |
|
|
my @regexps = ('userpriv_'); |
my @regexps = ('userpriv_'); |
my $nexttext; |
my $nexttext; |
Line 2481 sub choose_privs_form {
|
Line 2583 sub choose_privs_form {
|
} |
} |
|
|
$r->print('<br /><table width="100%" cellpadding="0" cellspacing="0" border="0">'); |
$r->print('<br /><table width="100%" cellpadding="0" cellspacing="0" border="0">'); |
&topic_bar($r,$tabcol,6,&mt('Group member privileges')); |
&topic_bar($r,$tabcol,6,&mt('[_1] member privileges',$ucgpterm)); |
|
|
&member_privileges_form($r,$tabcol,$action,$formname,$tools,$toolprivs, |
&member_privileges_form($r,$tabcol,$action,$formname,$tools,$toolprivs, |
$fixedprivs,$userdata,$usertools,$idx,undef, |
$fixedprivs,$userdata,$usertools,$idx,undef, |
$states,$stored,$rowColor1,$rowColor2); |
$states,$stored,$rowColor1,$rowColor2,$gpterm); |
|
|
$r->print('</td></tr><tr><td colspan="4"> </td></tr>'); |
$r->print('</td></tr><tr><td colspan="4"> </td></tr>'); |
if ($action eq 'create') { |
if ($action eq 'create') { |
Line 2494 sub choose_privs_form {
|
Line 2596 sub choose_privs_form {
|
my $img2 = 8; |
my $img2 = 8; |
&mapping_options($r,$action,$formname,$page,$tabcol,$sectioncount, |
&mapping_options($r,$action,$formname,$page,$tabcol,$sectioncount, |
$states,$stored,$navbuttons,$img1,$img2, |
$states,$stored,$navbuttons,$img1,$img2, |
$rowColor1,$rowColor2); |
$rowColor1,$rowColor2,$gpterm,$ucgpterm,$crstype); |
} |
} |
} |
} |
my $prevtext = $$navbuttons{'gtps'}; |
my $prevtext = $$navbuttons{'gtps'}; |
Line 2564 function uncheckAllTools(formname) {
|
Line 2666 function uncheckAllTools(formname) {
|
|
|
sub member_privileges_form { |
sub member_privileges_form { |
my ($r,$tabcol,$action,$formname,$tools,$toolprivs,$fixedprivs,$userdata, |
my ($r,$tabcol,$action,$formname,$tools,$toolprivs,$fixedprivs,$userdata, |
$usertools,$idx,$memchg,$states,$stored,$rowColor1,$rowColor2) = @_; |
$usertools,$idx,$memchg,$states,$stored,$rowColor1,$rowColor2, |
|
$gpterm) = @_; |
my %lt = &Apache::lonlocal::texthash( |
my %lt = &Apache::lonlocal::texthash( |
'addp' => 'Additional privileges', |
'addp' => 'Additional privileges', |
'fixp' => 'Fixed privileges', |
'fixp' => 'Fixed privileges', |
Line 2573 sub member_privileges_form {
|
Line 2676 sub member_privileges_form {
|
'forf' => 'For the functionality you have chosen to include '. |
'forf' => 'For the functionality you have chosen to include '. |
'there are no optional privileges to set besides '. |
'there are no optional privileges to set besides '. |
'the standard privileges.', |
'the standard privileges.', |
'algr' => 'All group members will receive the same privileges.', |
'algr' => "All $gpterm members will receive the same privileges.", |
'asno' => 'As no group members are being added, '. |
'asno' => "As no $gpterm members are being added, ". |
'there are no specific user privileges to set.', |
"there are no specific user privileges to set.", |
'asng' => 'As no group tools will be made available to users, '. |
'asng' => "As no $gpterm tools will be made available to users, ". |
'there are no specific user privileges to set.', |
"there are no specific user privileges to set.", |
'nogm' => 'No group member privileges to display or set, '. |
'nogm' => "No $gpterm member privileges to display or set, ". |
'as you have not indicated that you will be activating,'. |
"as you have not indicated that you will be activating,". |
' re-enabling, changing privileges, or adding/removing '. |
" re-enabling, changing privileges, or adding/removing ". |
'functionality for any current members ', |
"functionality for any current members ", |
'full' => 'Fullname', |
'full' => 'Fullname', |
'user' => 'Username', |
'user' => 'Username', |
'doma' => 'Domain', |
'doma' => 'Domain', |
Line 2740 sub process_request {
|
Line 2843 sub process_request {
|
my ($r,$cdom,$cnum,$tabcol,$action,$state,$page,$groupname,$description, |
my ($r,$cdom,$cnum,$tabcol,$action,$state,$page,$groupname,$description, |
$specificity,$userdata,$startdate,$enddate,$tools,$functions,$toolprivs, |
$specificity,$userdata,$startdate,$enddate,$tools,$functions,$toolprivs, |
$usertools,$idx,$types,$roles,$sections,$states,$navbuttons,$memchg, |
$usertools,$idx,$types,$roles,$sections,$states,$navbuttons,$memchg, |
$sectioncount,$stored,$rowColor1,$rowColor2) = @_; |
$sectioncount,$stored,$rowColor1,$rowColor2,$gpterm,$ucgpterm, |
|
$crstype) = @_; |
|
|
$r->print(&Apache::lonhtmlcommon::echo_form_input( |
$r->print(&Apache::lonhtmlcommon::echo_form_input( |
['origin','action','state','page','sortby'])); |
['origin','action','state','page','sortby'])); |
|
|
my $earlyout = &validate_groupname($groupname,$action,$cdom,$cnum); |
my $earlyout = &validate_groupname($groupname,$action,$cdom,$cnum,$gpterm, |
|
$ucgpterm,$crstype); |
if ($earlyout) { |
if ($earlyout) { |
$r->print(' |
$r->print(' |
<table width="100%" cellpadding="0" cellspacing="0" border="0"> |
<table width="100%" cellpadding="0" cellspacing="0" border="0"> |
Line 2791 sub process_request {
|
Line 2896 sub process_request {
|
$description,$startdate,$enddate, |
$description,$startdate,$enddate, |
$specificity,$functions,$tools, |
$specificity,$functions,$tools, |
$sectioncount,$roles,$types,$sections, |
$sectioncount,$roles,$types,$sections, |
\@defprivs,$stored); |
\@defprivs,$stored,$gpterm,$ucgpterm, |
|
$crstype); |
} |
} |
if (($action eq 'create' && $outcome eq 'ok') || (($action eq 'modify') && |
if (($action eq 'create' && $outcome eq 'ok') || (($action eq 'modify') && |
(($state eq 'memresult') || ($state eq 'addresult')))) { |
(($state eq 'memresult') || ($state eq 'addresult')))) { |
&process_membership($r,$cdom,$cnum,$action,$state,$groupname,$tools, |
&process_membership($r,$cdom,$cnum,$action,$state,$groupname,$tools, |
$enddate,$startdate,$userdata,$idx,$toolprivs, |
$enddate,$startdate,$userdata,$idx,$toolprivs, |
$usertools,$specificity,\@defprivs,$memchg); |
$usertools,$specificity,\@defprivs,$memchg,$gpterm, |
|
$ucgpterm); |
} |
} |
return; |
return; |
} |
} |
Line 2805 sub process_request {
|
Line 2912 sub process_request {
|
sub write_group_data { |
sub write_group_data { |
my ($r,$cdom,$cnum,$action,$state,$groupname,$description,$startdate, |
my ($r,$cdom,$cnum,$action,$state,$groupname,$description,$startdate, |
$enddate,$specificity,$functions,$tools,$sectioncount,$roles,$types, |
$enddate,$specificity,$functions,$tools,$sectioncount,$roles,$types, |
$sections,$defprivs,$stored) = @_; |
$sections,$defprivs,$stored,$gpterm,$ucgpterm,$crstype) = @_; |
my $now = time; |
my $now = time; |
my $creation = $now; |
my $creation = $now; |
my $creator = $env{'user.name'}.':'.$env{'user.domain'}; |
my $creator = $env{'user.name'}.':'.$env{'user.domain'}; |
Line 2813 sub write_group_data {
|
Line 2920 sub write_group_data {
|
$creation = $$stored{'creation'}; |
$creation = $$stored{'creation'}; |
$creator = $$stored{'creator'}; |
$creator = $$stored{'creator'}; |
} |
} |
my $esc_description = &Apache::lonnet::escape($description); |
my $esc_description = &escape($description); |
my @single_attributes = ('description','functions','startdate','enddate', |
my @single_attributes = ('description','functions','startdate','enddate', |
'creation','modified','creator','granularity', |
'creation','modified','creator','granularity', |
'specificity','autoadd','autodrop'); |
'specificity','autoadd','autodrop','quota'); |
my @mult_attributes = ('roles','types','sectionpick','defpriv'); |
my @mult_attributes = ('roles','types','sectionpick','defpriv'); |
|
|
|
my ($crsquota,$freespace,$maxposs) = &get_quota_constraints($action, |
|
$stored); |
|
my $quota = $env{'form.quota'}; |
|
|
|
$quota =~ s/^\s*([^\s]*)\s*$/$1/; |
|
if ($quota eq '') { |
|
$quota = 0; |
|
} |
|
if ($quota !~ /^\d*\.?\d*$/) { |
|
$quota = 0; |
|
$r->print(&mt('The value you entered for the quota for the file repository in this [_1] contained invalid characters, so it has been set to 0 Mb. You can change this by modifying the [_1] settings.<br />',$gpterm)); |
|
} |
|
if ($quota > $maxposs) { |
|
$quota = $maxposs; |
|
$r->print(&mt('The value you entered for the quota for the file repository in this [_1] exceeded the maximum possible value, so it has been set to [_2] Mb (the maximum possible value).<br />',$gpterm,$maxposs)); |
|
} |
my %groupinfo = ( |
my %groupinfo = ( |
description => $esc_description, |
description => $esc_description, |
startdate => $startdate, |
startdate => $startdate, |
Line 2830 sub write_group_data {
|
Line 2953 sub write_group_data {
|
specificity => $specificity, |
specificity => $specificity, |
autoadd => $env{'form.autoadd'}, |
autoadd => $env{'form.autoadd'}, |
autodrop => $env{'form.autodrop'}, |
autodrop => $env{'form.autodrop'}, |
|
quota => $quota, |
); |
); |
|
|
foreach my $func (keys(%{$functions})) { |
foreach my $func (keys(%{$functions})) { |
my $status; |
my $status; |
if (grep(/^$func$/,@{$tools})) { |
if (grep(/^$func$/,@{$tools})) { |
Line 2877 sub write_group_data {
|
Line 3002 sub write_group_data {
|
|
|
if ($result eq 'ok') { |
if ($result eq 'ok') { |
if ($action eq 'create') { |
if ($action eq 'create') { |
my $put_result = &create_homepage($cdom,$cnum,$groupname, |
my $result = &add_group_folder($cdom,$cnum,$now,$groupname,$action, |
\%groupinfo,$tools); |
$description,$tools,\%groupinfo, |
$r->print('Group '.$groupname.' was created.<br />'); |
$gpterm,$ucgpterm,$crstype); |
|
if ($result ne 'ok') { |
|
$r->print(&mt('A problem occurred when creating folders for the new [_1]. [_2].<br />',$gpterm,$result)); |
|
} |
|
$r->print(&mt('[_1] [_2] was created.<br />',$ucgpterm,$groupname)); |
} else { |
} else { |
$r->print('Group '.$groupname.' was updated.<br />'); |
$r->print(&mt('[_1] [_2] was updated.<br />',$ucgpterm,$groupname)); |
} |
} |
} else { |
} else { |
my %actiontype = ( |
my %actiontype = ( |
'create' => 'creating', |
'create' => 'creating', |
'modify' => 'modifying', |
'modify' => 'modifying', |
); |
); |
&Apache::lonnet::logthis('Failed to store group '.$groupname. |
&Apache::lonnet::logthis("Failed to store $gpterm $groupname ". |
'in course: '.$cnum.' in domain: '.$cdom); |
'in '.lc($crstype).': '.$cnum. |
$r->print(&mt('An error occurred when [_1] the new group. '. |
' in domain: '.$cdom); |
'Please try again.',$actiontype{$action})); |
$r->print(&mt('An error occurred when [_1] the [_2]. '. |
|
'Please try again.',$actiontype{$action},$gpterm)); |
} |
} |
return $result; |
return $result; |
} |
} |
|
|
sub process_membership { |
sub process_membership { |
my ($r,$cdom,$cnum,$action,$state,$groupname,$tools,$enddate,$startdate, |
my ($r,$cdom,$cnum,$action,$state,$groupname,$tools,$enddate,$startdate, |
$userdata,$idx,$toolprivs,$usertools,$specificity,$defprivs,$memchg)=@_; |
$userdata,$idx,$toolprivs,$usertools,$specificity,$defprivs,$memchg, |
|
$gpterm,$ucgpterm)=@_; |
my %usersettings = (); |
my %usersettings = (); |
my %added= (); |
my %added= (); |
my %failed = (); |
my %failed = (); |
my $num_ok = 0; |
my $num_ok = 0; |
my $num_fail = 0; |
my $num_fail = 0; |
my %group_privs = (); |
my %group_privs = (); |
|
my %curr_privs = (); |
|
my %curr_start = (); |
|
my %curr_end = (); |
my %tooltype = (); |
my %tooltype = (); |
|
|
foreach my $tool (@{$tools}) { |
foreach my $tool (@{$tools}) { |
Line 2923 sub process_membership {
|
Line 3057 sub process_membership {
|
} |
} |
} else { |
} else { |
if (@{$defprivs} > 0) { |
if (@{$defprivs} > 0) { |
foreach my $priv (@{$defprivs}) { |
if (grep/^\Q$priv\E$/,@{$defprivs}) { |
foreach my $user (sort(keys(%{$usertools}))) { |
foreach my $user (sort(keys(%{$usertools}))) { |
if ($$usertools{$user}{$tool}) { |
if ($$usertools{$user}{$tool}) { |
$group_privs{$user} .= $priv.':'; |
$group_privs{$user} .= $priv.':'; |
Line 2943 sub process_membership {
|
Line 3077 sub process_membership {
|
my @expire = (); |
my @expire = (); |
my @deletion = (); |
my @deletion = (); |
my @reenable = (); |
my @reenable = (); |
|
my @unchanged = (); |
if ($state eq 'memresult') { |
if ($state eq 'memresult') { |
if (ref($$memchg{'activate'}) eq 'ARRAY') { |
if (ref($$memchg{'activate'}) eq 'ARRAY') { |
@activate = @{$$memchg{'activate'}}; |
@activate = @{$$memchg{'activate'}}; |
Line 2956 sub process_membership {
|
Line 3091 sub process_membership {
|
if (ref($$memchg{'reenable'}) eq 'ARRAY') { |
if (ref($$memchg{'reenable'}) eq 'ARRAY') { |
@reenable = @{$$memchg{'reenable'}}; |
@reenable = @{$$memchg{'reenable'}}; |
} |
} |
|
my %membership = &Apache::lonnet::get_group_membership($cdom,$cnum, |
|
$groupname); |
|
foreach my $key (sort(keys(%membership))) { |
|
if ($key =~ /^\Q$groupname\E:([^:]+:[^:]+)$/) { |
|
($curr_end{$1},$curr_start{$1},$curr_privs{$1}) = |
|
split(/:/,$membership{$key},3); |
|
} |
|
} |
if (@expire + @deletion > 0) { |
if (@expire + @deletion > 0) { |
my %membership = &Apache::lonnet::get_group_membership($cdom,$cnum, |
|
$groupname); |
|
foreach my $user (@expire) { |
foreach my $user (@expire) { |
my ($currend,$currstart,@userprivs) = |
my $savestart = $curr_start{$user}; |
split(/:/,$membership{$groupname.':'.$user}); |
if ($savestart > $now) { |
$group_privs{$user} = join(':',@userprivs); |
$savestart = $now; |
if ($currstart > $now) { |
|
$currstart = $now; |
|
} |
} |
$usersettings{$groupname.':'.$user} = $now.':'.$currstart.':'. |
$usersettings{$groupname.':'.$user} = $now.':'.$savestart.':'. |
$group_privs{$user}; |
$curr_privs{$user}; |
if (&Apache::lonnet::modify_group_roles($cdom,$cnum,$groupname, |
if (&Apache::lonnet::modify_group_roles($cdom,$cnum,$groupname, |
$user,$now,$currstart, |
$user,$now,$savestart, |
$group_privs{$user}) eq 'ok') { |
$curr_privs{$user}) eq 'ok') { |
push(@{$added{'expired'}},$user); |
push(@{$added{'expired'}},$user); |
$num_ok ++; |
$num_ok ++; |
} else { |
} else { |
Line 2994 sub process_membership {
|
Line 3133 sub process_membership {
|
} |
} |
|
|
foreach my $user (sort(keys(%{$usertools}))) { |
foreach my $user (sort(keys(%{$usertools}))) { |
|
if ((grep(/^$user$/,@expire)) || (grep(/^$user$/,@deletion))) { |
|
next; |
|
} |
my $type; |
my $type; |
my $start = $startdate; |
my $start = $startdate; |
my $end = $enddate; |
my $end = $enddate; |
if ($state eq 'memresult') { |
if ($state eq 'memresult') { |
|
if ($curr_privs{$user} eq $group_privs{$user}) { |
|
push(@unchanged,$user); |
|
next; |
|
} |
|
if (exists($curr_start{$user})) { |
|
$start = $curr_start{$user}; |
|
} |
|
if (exists($curr_end{$user})) { |
|
$end = $curr_end{$user}; |
|
} |
$type = 'modified'; |
$type = 'modified'; |
if (@activate > 0) { |
if (@activate > 0) { |
if (grep/^$user$/,@activate) { |
if (grep/^$user$/,@activate) { |
$start = $now; |
$start = $now; |
|
$end = $enddate; |
$type = 'activated'; |
$type = 'activated'; |
} |
} |
} |
} |
if (@reenable > 0) { |
if (@reenable > 0) { |
if (grep/^$user$/,@reenable) { |
if (grep/^$user$/,@reenable) { |
|
$start = $startdate; |
|
$end = $enddate; |
$type = 'reenabled'; |
$type = 'reenabled'; |
} |
} |
} |
} |
Line 3030 sub process_membership {
|
Line 3185 sub process_membership {
|
if ($num_ok) { |
if ($num_ok) { |
foreach my $type (sort(keys(%added))) { |
foreach my $type (sort(keys(%added))) { |
$r->print(&mt('The following users were successfully [_1]',$type)); |
$r->print(&mt('The following users were successfully [_1]',$type)); |
if (!($type eq 'deleted' || $type eq 'expired')) { |
if (!($type eq 'deleted' || $type eq 'expired')) { |
$r->print(&mt(' with the following privileges')); |
$r->print(&mt(' with the following privileges')); |
} |
} |
$r->print(':<br />'); |
$r->print(':<br />'); |
Line 3051 sub process_membership {
|
Line 3206 sub process_membership {
|
} |
} |
$r->print($$userdata{$user}[$$idx{fullname}].' - '.$user.$privlist.'<br />'); |
$r->print($$userdata{$user}[$$idx{fullname}].' - '.$user.$privlist.'<br />'); |
} |
} |
|
$r->print('<br />'); |
} |
} |
} |
} |
if ($num_fail) { |
if ($num_fail) { |
Line 3060 sub process_membership {
|
Line 3216 sub process_membership {
|
$r->print($$userdata{$user}[$$idx{fullname}].' - '.$user.'<br />'); |
$r->print($$userdata{$user}[$$idx{fullname}].' - '.$user.'<br />'); |
} |
} |
} |
} |
|
$r->print('<br />'); |
|
} |
|
if (@unchanged > 0) { |
|
$r->print(&mt('No change occurred for the following users:<br />')); |
|
foreach my $user (sort(@unchanged)) { |
|
$r->print($$userdata{$user}[$$idx{fullname}].' - '.$user.'<br />'); |
|
} |
|
$r->print('<br />'); |
} |
} |
if ($roster_result eq 'ok') { |
if ($roster_result eq 'ok') { |
$r->print('<br />'.&mt('Group membership list updated.')); |
$r->print('<br />'.&mt('[_1] membership list updated.',$ucgpterm)); |
|
$r->print('<p>'.&mt("For full access to all of [_1]'s privileges, users will need to log out and log back in.",$groupname).'</p>'); |
} else { |
} else { |
$r->print('<br />'.&mt('An error occurred while updating the group membership list -').$roster_result.'<br />'); |
$r->print('<br />'.&mt('An error occurred while updating the [_1] membership list -',$gpterm).$roster_result.'<br />'); |
} |
} |
return; |
return; |
} |
} |
|
|
sub mapping_options { |
sub mapping_options { |
my ($r,$action,$formname,$page,$tabcol,$sectioncount,$states,$stored, |
my ($r,$action,$formname,$page,$tabcol,$sectioncount,$states,$stored, |
$navbuttons,$img1,$img2,$rowColor1,$rowColor2) = @_; |
$navbuttons,$img1,$img2,$rowColor1,$rowColor2,$gpterm,$ucgpterm, |
|
$crstype) = @_; |
my %lt = &Apache::lonlocal::texthash( |
my %lt = &Apache::lonlocal::texthash( |
'auto' => 'Settings for automatic group enrollment', |
'auto' => "Settings for automatic $gpterm enrollment", |
'gmma' => 'Group membership mapping to specific sections/roles', |
'gmma' => "$ucgpterm membership mapping to specific sections/roles", |
'endi' => 'Enable/disable automatic group enrollment for '. |
'endi' => "Enable/disable automatic $gpterm enrollment for ". |
'users in specified roles and sections', |
"users in specified roles and sections", |
'adds' => 'If automatic group enrollment is enabled, when a user is assigned a course-wide or section-specific role, he/she will automatically be added as a member of the group, with start and end access dates defined by the default dates set for the group, unless he/she is already a group member, with access dates that permit either current or future group access.', |
'adds' => "If automatic $gpterm enrollment is enabled, when a user is 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.", |
'drops' => "If automatic group disenrollment is enabled, when a user's role is expired, access to the group will be terminated unless the user continues to have other course-wide or section-specific active or future roles which receive automatic membership in the group.", |
'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.", |
'pirs' => 'Pick roles and sections for automatic group enrollment', |
'pirs' => "Pick roles and sections for automatic $gpterm enrollment", |
'curr' => 'Currently set to', |
'curr' => 'Currently set to', |
'on' => 'on', |
'on' => 'on', |
'off' => 'off', |
'off' => 'off', |
'auad' => 'Automatically enable group membership when roles are added?', |
'auad' => "Automatically enable $gpterm membership when roles are added?", |
'auex' => 'Automatically expire group membership when roles are removed?', |
'auex' => "Automatically expire $gpterm membership when roles are removed?", |
'mapr' => 'Mapping of roles and sections affected by automatic group enrollment/disenrollment follows scheme chosen below.', |
'mapr' => "Mapping of roles and sections affected by automatic $gpterm enrollment/disenrollment follows scheme chosen below.", |
); |
); |
&automapping($r,$action,$tabcol,$stored,\%lt,$img1); |
&automapping($r,$action,$tabcol,$stored,\%lt,$img1); |
$r->print(' |
$r->print(' |
Line 3093 sub mapping_options {
|
Line 3259 sub mapping_options {
|
<td colspan="4"> </td> |
<td colspan="4"> </td> |
</tr>'); |
</tr>'); |
&mapping_settings($r,$tabcol,$rowColor1,$rowColor2,$sectioncount,\%lt, |
&mapping_settings($r,$tabcol,$rowColor1,$rowColor2,$sectioncount,\%lt, |
$stored,$img2); |
$stored,$img2,$crstype); |
return; |
return; |
} |
} |
|
|
Line 3153 sub automapping {
|
Line 3319 sub automapping {
|
} |
} |
|
|
sub mapping_settings { |
sub mapping_settings { |
my ($r,$tabcol,$rowColor1,$rowColor2,$sectioncount,$lt,$stored,$image) = @_; |
my ($r,$tabcol,$rowColor1,$rowColor2,$sectioncount,$lt,$stored,$image, |
|
$crstype) = @_; |
my @sections = keys(%{$sectioncount}); |
my @sections = keys(%{$sectioncount}); |
if (@sections > 0) { |
if (@sections > 0) { |
@sections = sort {$a cmp $b} @sections; |
@sections = sort {$a cmp $b} @sections; |
Line 3179 sub mapping_settings {
|
Line 3346 sub mapping_settings {
|
my $rowNum = 0; |
my $rowNum = 0; |
my $rowColor; |
my $rowColor; |
foreach my $role (@roles) { |
foreach my $role (@roles) { |
my $plrole=&Apache::lonnet::plaintext($role); |
my $plrole=&Apache::lonnet::plaintext($role,$crstype); |
my $sections_sel; |
my $sections_sel; |
if (@sections > 0) { |
if (@sections > 0) { |
if ($role eq 'cc') { |
if ($role eq 'cc') { |
Line 3239 sub my_custom_roles {
|
Line 3406 sub my_custom_roles {
|
} |
} |
|
|
sub modify_menu { |
sub modify_menu { |
my ($r,$groupname,$page) = @_; |
my ($r,$groupname,$page,$gpterm) = @_; |
my @menu = |
my @menu = |
( |
( |
{ text => 'Modify default group settings', |
{ text => "Modify default $gpterm settings", |
help => 'Course_Modify_Group', |
help => 'Course_Modify_Group', |
state => 'change_settings', |
state => 'change_settings', |
branch => 'settings', |
branch => 'settings', |
Line 3253 sub modify_menu {
|
Line 3420 sub modify_menu {
|
state => 'change_members', |
state => 'change_members', |
branch => 'members', |
branch => 'members', |
}, |
}, |
{ text => 'Add member(s) to the group', |
{ text => "Add member(s) to the $gpterm", |
help => 'Course_Group_Add_Members', |
help => 'Course_Group_Add_Members', |
state => 'add_members', |
state => 'add_members', |
branch => 'adds', |
branch => 'adds', |
Line 3366 sub date_setting_table {
|
Line 3533 sub date_setting_table {
|
return ($start_table, $end_table); |
return ($start_table, $end_table); |
} |
} |
|
|
|
sub add_group_folder { |
|
my ($cdom,$cnum,$now,$groupname,$action,$description,$tools,$groupinfo, |
|
$gpterm,$ucgpterm,$crstype) = @_; |
|
if ($cdom eq '' || $cnum eq '') { |
|
return &mt('Error: invalid course domain or number - group folder creation failed'); |
|
} |
|
my ($outcome,$allgrpsmap,$grpmap,$boardsmap,$grppage); |
|
my $navmap = Apache::lonnavmaps::navmap->new(); |
|
my $crspath = '/uploaded/'.$cdom.'/'.$cnum.'/'; |
|
$allgrpsmap = $crspath.'default_0.sequence'; |
|
my $topmap = $navmap->getResourceByUrl($allgrpsmap); |
|
undef($navmap); |
|
if ($action eq 'create') { |
|
# check if default_0.sequence exists. |
|
if (!$topmap) { |
|
my $grpstitle = &mt('[_1] [_2]',$crstype,$ucgpterm); |
|
my $topmap_url = '/'.$env{'course.'.$env{'request.course.id'}.'.url'}; |
|
$topmap_url =~ s|/+|/|g; |
|
if ($topmap_url =~ m|^/uploaded|) { |
|
$outcome = &map_updater($cdom,$cnum,'default_0.sequence', |
|
'toplevelgroup',$grpstitle,$topmap_url); |
|
if ($outcome ne 'ok') { |
|
return $outcome; |
|
} |
|
} else { |
|
$outcome = &mt('Non-standard course - group folder not added.'); |
|
return $outcome; |
|
} |
|
} |
|
my $grpfolder = &mt('[_1] Folder -',$ucgpterm,).$description; |
|
$grppage='/adm/'.$cdom.'/'.$cnum.'/'.$groupname.'/grppg'; |
|
my $grptitle = &mt('Group homepage').' - '.$description; |
|
my ($seqid,$discussions,$disctitle); |
|
my $outcome = &map_updater($cdom,$cnum,'default_'.$now.'.sequence', |
|
'grpseq',$grpfolder,$allgrpsmap,$grppage, |
|
$grptitle); |
|
if ($outcome ne 'ok') { |
|
return $outcome; |
|
} |
|
my $pageout = &create_homepage($cdom,$cnum,$groupname,$groupinfo, |
|
$tools,$gpterm,$ucgpterm,$now); |
|
# Link to folder for bulletin boards |
|
$grpmap = $crspath.'default_'.$now.'.sequence'; |
|
if (grep/^discussion$/,@{$tools}) { |
|
$seqid = $now + 1; |
|
$disctitle = &mt('Discussion Boards'); |
|
my $outcome = &map_updater($cdom,$cnum,'default_'.$seqid. |
|
'.sequence','bbseq',$disctitle,$grpmap); |
|
if ($outcome ne 'ok') { |
|
return $outcome; |
|
} |
|
$boardsmap = $crspath.'default_'.$seqid.'.sequence'; |
|
} |
|
} else { |
|
#modify group folder if status of discussions tools is changed |
|
} |
|
my ($furl,$ferr)= &Apache::lonuserstate::readmap($cdom.'/'.$cnum); |
|
$navmap = Apache::lonnavmaps::navmap->new(); |
|
# modify parameters |
|
my $parm_result; |
|
if ($action eq 'create') { |
|
if ($allgrpsmap) { |
|
$parm_result .= &parm_setter($navmap,$cdom,$allgrpsmap,$groupname); |
|
} |
|
if ($grpmap) { |
|
$parm_result .= &parm_setter($navmap,$cdom,$grpmap,$groupname); |
|
} |
|
if ($grppage) { |
|
$parm_result .= &parm_setter($navmap,$cdom,$grppage,$groupname); |
|
} |
|
if ($boardsmap) { |
|
$parm_result .= &parm_setter($navmap,$cdom,$boardsmap,$groupname); |
|
} |
|
} |
|
if ($parm_result) { |
|
return $parm_result; |
|
} else { |
|
return 'ok'; |
|
} |
|
} |
|
|
|
sub map_updater { |
|
my ($cdom,$cnum,$newfile,$itemname,$itemtitle,$parentmap,$startsrc, |
|
$starttitle,$endsrc,$endtitle) = @_; |
|
my $outcome; |
|
$env{'form.'.$itemname} = &new_map($startsrc,$starttitle,$endsrc, |
|
$endtitle); |
|
my $newmapurl=&Apache::lonnet::finishuserfileupload($cnum,$cdom,$itemname, |
|
$newfile); |
|
if ($newmapurl !~ m|^/uploaded|) { |
|
$outcome = &mt('Error uploading new folder.')." ($newfile): $newmapurl".'<br />'; |
|
return $outcome; |
|
} |
|
my ($errtext,$fatal)=&Apache::lonratedt::mapread($parentmap); |
|
if ($fatal) { |
|
$outcome = &mt('Error reading contents of parent folder')." ($parentmap): $errtext".'<br />'; |
|
return $outcome; |
|
} else { |
|
my $newidx=&Apache::lonratedt::getresidx($newmapurl); |
|
$Apache::lonratedt::resources[$newidx] = $itemtitle.':'.$newmapurl. |
|
':false:normal:res'; |
|
$Apache::lonratedt::order[1+$#Apache::lonratedt::order]=$newidx; |
|
my ($outtext,$errtext) = &Apache::lonratedt::storemap($parentmap,1); |
|
if ($errtext) { |
|
$outcome = &mt('Error storing updated parent folder')." ($parentmap): $errtext".'<br />'; |
|
return $outcome; |
|
} |
|
} |
|
return 'ok'; |
|
} |
|
|
|
sub new_map { |
|
my ($startsrc,$starttitle,$endsrc,$endtitle) = @_; |
|
my $newmapstr = ' |
|
<map> |
|
<resource id="1" src="'.$startsrc.'" type="start" title="'.$starttitle.'"></resource> |
|
<link from="1" to="2" index="1"></link> |
|
<resource id="2" src="'.$endsrc.'" type="finish" title="'.$endtitle.'"></resource> |
|
</map> |
|
'; |
|
return $newmapstr; |
|
} |
|
|
|
sub parm_setter { |
|
my ($navmap,$cdom,$url,$groupname) = @_; |
|
my $allresults; |
|
my %hide_settings = ( |
|
'course' => { |
|
'num' => 13, |
|
'set' => 'yes', |
|
}, |
|
'group' => { |
|
'num' => 5, |
|
'set' => 'no', |
|
'extra' => $groupname, |
|
}, |
|
); |
|
my $res = $navmap->getResourceByUrl($url); |
|
my $symb = $res->symb(); |
|
foreach my $level (keys(%hide_settings)) { |
|
my $parmresult = &Apache::lonparmset::storeparm_by_symb($symb, |
|
'0_hiddenresource', |
|
$hide_settings{$level}{'num'}, |
|
$hide_settings{$level}{'set'}, |
|
'string_yesno',undef,$cdom, |
|
undef,undef, |
|
$hide_settings{$level}{'extra'}); |
|
if ($parmresult) { |
|
$allresults .= $level.': '.$parmresult; |
|
} |
|
} |
|
return $allresults; |
|
} |
|
|
sub create_homepage { |
sub create_homepage { |
my ($cdom,$cnum,$name,$groupinfo,$tools) = @_; |
my ($cdom,$cnum,$name,$groupinfo,$tools,$gpterm,$ucgpterm,$now) = @_; |
my $functionality = join(',',@{$tools}); |
my $functionality = join(',',@{$tools}); |
my $content = &Apache::lonnet::unescape($$groupinfo{description}); |
my $content = &unescape($$groupinfo{description}); |
$content=~s/\s+$//s; |
$content=~s/\s+$//s; |
$content=~s/^\s+//s; |
$content=~s/^\s+//s; |
$content=~s/\<br\s*\/*\>$//s; |
$content=~s/\<br\s*\/*\>$//s; |
$content=&Apache::lonfeedback::clear_out_html($content,1); |
$content=&Apache::lonfeedback::clear_out_html($content,1); |
|
|
my %pageinfo = ( |
my %pageinfo = ( |
'aaa_title' => 'Group: '.$name, |
'aaa_title' => "$ucgpterm: $name", |
'abb_links' => $functionality, |
'abb_links' => $functionality, |
'bbb_content' => $content, |
'bbb_content' => $content, |
'ccc_webreferences' => '', |
'ccc_webreferences' => '', |
'uploaded.lastmodified' => time, |
'uploaded.lastmodified' => $now, |
); |
); |
my $putresult = &Apache::lonnet::put('grppage_'.$name,\%pageinfo,$cdom,$cnum); |
my $putresult = &Apache::lonnet::put('grppage_'.$name,\%pageinfo,$cdom,$cnum); |
return $putresult; |
return $putresult; |
Line 3422 function toggleTools(field,caller) {
|
Line 3743 function toggleTools(field,caller) {
|
} |
} |
|
|
sub validate_groupname { |
sub validate_groupname { |
my ($groupname,$action,$cdom,$cnum) = @_; |
my ($groupname,$action,$cdom,$cnum,$gpterm,$ucgpterm,$crstype) = @_; |
my %sectioncount = &Apache::loncommon::get_sections($cdom,$cnum); |
my %sectioncount = &Apache::loncommon::get_sections($cdom,$cnum); |
my %curr_groups = &Apache::longroup::coursegroups($cdom,$cnum); |
my %curr_groups = &Apache::longroup::coursegroups($cdom,$cnum); |
|
|
my %lt = &Apache::lonlocal::texthash ( |
my %lt = &Apache::lonlocal::texthash ( |
igna => 'Invalid group name', |
igna => "Invalid $gpterm name", |
tgne => 'The group name entered ', |
tgne => "The $gpterm name entered ", |
grna => 'Group names and section names used in a course '. |
grna => "$ucgpterm names and section names used in a ". |
'must be unique.', |
"$crstype must be unique.", |
isno => 'is not a valid name.', |
isno => "is not a valid name.", |
gnmo => 'Group names may only contain letters, numbers '. |
gnmo => "$ucgpterm names may only contain letters, ". |
'or underscores.', |
"numbers or underscores.", |
cnnb => 'can not be used as it is the name of ', |
cnnb => "can not be used as it is the name of ", |
inth => ' in this course.', |
inth => " in this $crstype", |
thgr => '- does not correspond to the name of an existing'. |
thgr => "- does not correspond to the name of an ". |
' group ', |
"existing $gpterm", |
); |
); |
|
|
my $exitmsg = '<b>'.$lt{'igna'}.'</b><br /><br />'.$lt{'tgne'}.' "'. |
my $exitmsg = '<b>'.$lt{'igna'}.'</b><br /><br />'.$lt{'tgne'}.' "'. |
Line 3455 sub validate_groupname {
|
Line 3776 sub validate_groupname {
|
if ($action eq 'create' |
if ($action eq 'create' |
&& exists($curr_groups{$groupname})) { |
&& exists($curr_groups{$groupname})) { |
|
|
return $exitmsg.$lt{'cnnb'}.&mt('an existing group'). |
return $exitmsg.$lt{'cnnb'}.&mt('an existing [_1]',$gpterm). |
$lt{'inth'}.'<br />'.$lt{'grna'}; |
$lt{'inth'}.'<br />'.$lt{'grna'}; |
|
|
} elsif ($action eq 'modify') { |
} elsif ($action eq 'modify') { |
unless(exists($curr_groups{$groupname})) { |
unless(exists($curr_groups{$groupname})) { |
$earlyout = &mt('Group name:').' '.$groupname.$lt{'thgr'}.$lt{'inth'}; |
$earlyout = &mt('[_1] name:',$ucgpterm).' '.$groupname.$lt{'thgr'}. |
|
$lt{'inth'}; |
return $earlyout; |
return $earlyout; |
} |
} |
} |
} |