--- loncom/interface/loncoursegroups.pm 2006/07/07 21:25:02 1.49 +++ loncom/interface/loncoursegroups.pm 2008/10/21 14:29:39 1.79 @@ -1,6 +1,6 @@ # The LearningOnline Network with CAPA # -# $Id: loncoursegroups.pm,v 1.49 2006/07/07 21:25:02 raeburn Exp $ +# $Id: loncoursegroups.pm,v 1.79 2008/10/21 14:29:39 bisitz Exp $ # # Copyright Michigan State University Board of Trustees # @@ -29,13 +29,14 @@ package Apache::loncoursegroups; use strict; use Apache::lonnet; -use Apache::loncommon; -use Apache::lonhtmlcommon; +use Apache::loncommon(); +use Apache::lonhtmlcommon(); use Apache::lonlocal; -use Apache::lonnavmaps; -use Apache::longroup; -use Apache::portfolio; +use Apache::lonnavmaps(); +use Apache::longroup(); +use Apache::portfolio(); use Apache::Constants qw(:common :http); +use LONCAPA::map(); use lib '/home/httpd/lib/perl/'; use LONCAPA; @@ -63,9 +64,9 @@ sub handler { my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; my $view_permission = - &Apache::lonnet::allowed('vcg',$env{'request.course.id'}); + &Apache::lonnet::allowed('vcg',$env{'request.course.id'}.($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:'')); my $manage_permission = - &Apache::lonnet::allowed('mdg',$env{'request.course.id'}); + &Apache::lonnet::allowed('mdg',$env{'request.course.id'}.($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:'')); &Apache::lonhtmlcommon::clear_breadcrumbs(); my $gpterm = &Apache::loncommon::group_term(); @@ -91,20 +92,29 @@ sub handler { my $action = $env{'form.action'}; my $state = $env{'form.state'}; - if ((!defined($action)) || ($action eq 'view')) { + if ((!defined($action)) || ($action eq 'view') || ($action eq 'modify') || ($action eq 'delete') || ($action eq 'reenable')) { 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' || + $action eq 'delete' || $action eq 'reenable') { if ($view_permission || $manage_permission) { - &group_administration($r,$action,$state,$cdom,$cnum, - \%functions,\%idx,$view_permission, - $manage_permission,$gpterm,$ucgpterm, - $crstype); + if ($state eq 'view') { + &print_main_menu($r,$cdom,$cnum,\%functions,\%idx, + $view_permission,$manage_permission, + $action,$state,$gpterm,$ucgpterm,$crstype); + } else { + &group_administration($r,$action,$state,$cdom,$cnum, + \%functions,\%idx,$view_permission, + $manage_permission,$gpterm,$ucgpterm, + $crstype); + } } else { - $r->print(&mt('You do not have [_1] administration '. - 'privileges in this [_2]',$gpterm,lc($crstype))); + $r->print('
'.$lt{'gnam'}.': | '); if ($action eq 'create') { - $r->print(''); + $r->print(' ('. + $lt{'lett'}.')'); } else { $r->print(''.$env{'form.groupname'}); @@ -1281,23 +1677,25 @@ END | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
'.&mt('Disk quota: ').' | ');
if ($action eq 'create') {
- $r->print(&mt('If you enable the file repository for the [_1], allocate a disk quota.',$gpterm));
+ $r->print(&mt('If you enable the file repository for the '.$gpterm.', allocate a disk quota.'));
} else {
$r->print(&mt('Quota allocated to file repository:'));
}
- $r->print(' Mb');
+ $r->print(' '.&mt('[_1] Mb',''));
if ($action eq 'create') {
- $r->print(' '. - &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)); + $r->print(' ' + .&mt('A total of [_1] Mb can be divided amongst all '.$gpterm.'s in the ' + .lc($crstype).', and [_2] Mb are currently unallocated.' + ,$crsquota,sprintf("%.2f",$freespace)) + ); } else { $r->print(' ('.&mt('The quota is currently [_1] Mb', $$stored{'quota'}).').'); - $r->print(' '.&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(' ' + .&mt('The quota can be increased to [_1] Mb, ' + .'by adding all unallocated space for '.$gpterm.'s in the '.lc($crstype).'.' + ,sprintf("%.2f",$maxposs))); } $r->print(' |
@@ -1324,18 +1722,18 @@ sub get_quota_constraints {
}
sub membership_options {
- my ($r,$action,$state,$sectioncount,$image,$gpterm,$ucgpterm) = @_;
+ my ($r,$cdom,$cnum,$action,$state,$sectioncount,$image,$gpterm,$ucgpterm)=@_;
my $crstype = &Apache::loncommon::course_type();
my %lt = &Apache::lonlocal::texthash(
- 'pipa' => 'Pick parameters to generate membership list',
- 'gmem' => "$ucgpterm membership options",
+ 'pipa' => 'Build a list of users for selection of group members',
+ 'gmem' => "Group membership selection list criteria:",
'picr' => 'Pick the criteria to use to build a list of '.
lc($crstype).' users from which you will select ',
- 'meof' => "members of the new $gpterm.",
- 'admg' => "additional members of the $gpterm.",
+ 'meof' => "members of the new group.",
+ 'admg' => "additional members of the group.",
'ifno' => "If you do not wish to add members when you first ".
- "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.",
+ "create the group, there is no need to pick any criteria.",
+ 'asub' => "A subsequent step will also allow you to specify automatic adding/dropping of group members triggered by specified user role and section changes in the course.",
'acty' => 'Access types',
'coro' => $crstype.' roles',
'cose' => $crstype.' sections',
@@ -1346,13 +1744,11 @@ sub membership_options {
future => &mt('Will have future access'),
);
- #FIXME need to plumb around for the various cr roles defined by the user
- my @roles = ('st','cc','in','ta','ep');
+ my @roles = ('st','cc','in','ta','ep','cr');
my @sections = keys(%{$sectioncount});
- &topic_bar($r,$image,$lt{'pipa'});
- $r->print('
+ $r->print(&Apache::lonhtmlcommon::topic_bar($image,$lt{'pipa'}).'
'.$lt{'gmem'}.'
'.$lt{'acty'}.' | -'.$lt{'coro'}.' | '); - if (@sections >0) { - $r->print(' -'.$lt{'cose'}.' | '); - } - $r->print('|
---|---|---|---|
'); + | '.$lt{'coro'}.' | +'.$lt{'cose'}.' | +|
'); $r->print(&Apache::lonhtmlcommon::status_select_row(\%status_types)); $r->print(' | '); - $r->print(&Apache::lonhtmlcommon::role_select_row(\@roles)); + $r->print(&Apache::lonhtmlcommon::role_select_row(\@roles,undef,undef,1,$cdom,$cnum)); if (@sections > 0) { @sections = sort {$a cmp $b} @sections; unshift(@sections,'none'); # Put 'no sections' next unshift(@sections,'all'); # Put 'all' at the front of the list - $r->print(' | '. - §ions_selection(\@sections,'sectionpick').' | '); + } else { + @sections = ('all','none'); } - $r->print(' + $r->print(''. + §ions_selection(\@sections,'sectionpick').' |
'; } - $fixed .= ''.$$toolprivs{$tool}{$priv}.' '; + $fixed .= '' + .''.$$toolprivs{$tool}{$priv}.' '; if ($action eq 'modify') { if (grep(/^$tool$/,@{$available})) { $fixed .= ''.&mt('(on)').' '; @@ -1916,21 +2319,21 @@ sub default_privileges { $fixed .= ''.&mt('(off)').' '; } } + $fixed .= ''; } else { $privcount++; if ($privcount == 3) { $dynamic .= ' | ||||||||||||||||||||||||||||||||||
'."\n"; + $dynamic .= ' | '."\n"; } } if ($privcount == 0) { - $dynamic .= ' | None | '."\n"; + $dynamic .= ''.&mt('None').' | '."\n"; } if ($privcount < 3) { - $dynamic .= ' -'."\n"; + $dynamic .= ' | '."\n"; } elsif ($privcount%2) { $dynamic = ' | '."\n"; } @@ -1957,7 +2360,7 @@ sub display_defprivs { my $rowColor2 = "#eeeeee"; my %lt = &Apache::lonlocal::texthash( 'priv' => 'Privileges', - 'func' => 'Function', + 'func' => 'Collaborative Tool', ); $r->print(&Apache::lonhtmlcommon::start_pick_box()); $r->print(' | ||||||||||||||||||||||||||||
'.&mt('Additional Functionality').' | '); + $r->print(''.&mt('Additional Tools').' | '); $colspan++; } $r->print(&Apache::loncommon::end_data_table_header_row()); @@ -2249,8 +2658,10 @@ END } } $r->print(&Apache::loncommon::end_data_table()); + } else { + $r->print(&mt('There are no active, future or previous group members to modify.')); } - return; + return $numcurrent; } sub check_uncheck_buttons { @@ -2291,11 +2702,11 @@ sub change_privs_form { } else { $nexttext = $$navbuttons{'mose'}; } - &topic_bar($r,3,&mt('Members to delete or expire')); + $r->print(&Apache::lonhtmlcommon::topic_bar(3,&mt('Members to delete or expire'))); my $exp_or_del = 0; if (ref($$memchg{'deletion'}) eq 'ARRAY') { if (@{$$memchg{'deletion'}} > 0) { - $r->print('|||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
'.$lt{'tode'}.':
| '.$lt{'toex'}.': |
'); } - &topic_bar($r,4,&mt('[_1] member privileges',$ucgpterm)); + $r->print(&Apache::lonhtmlcommon::topic_bar(4,&mt('Setting optional privileges for specific group members'))); my $numchgs = &member_privileges_form($r,$action,$formname,$tools, $toolprivs,$fixedprivs,$userdata, @@ -2336,7 +2747,7 @@ sub change_privs_form { } sub add_members_form { - my ($r,$action,$formname,$page,$startdate,$enddate,$groupname, + my ($r,$cdom,$cnum,$action,$formname,$page,$startdate,$enddate,$groupname, $description,$granularity,$quota,$sectioncount,$tools,$functions, $stored,$states,$navbuttons,$gpterm,$ucgpterm)=@_; $r->print(' '); @@ -2346,7 +2757,8 @@ sub add_members_form { &print_current_settings($r,$action,$functions,$startdate,$enddate, $groupname,$description,$granularity,$quota, \@available,\@unavailable,$gpterm,$ucgpterm); - &membership_options($r,$action,$formname,$sectioncount,1,$gpterm,$ucgpterm); + &membership_options($r,$cdom,$cnum,$action,$formname,$sectioncount,1,$gpterm, + $ucgpterm); my $nexttext = $$navbuttons{'gtns'}; my $prevtext = $$navbuttons{'gtpp'}; &display_navbuttons($r,$formname,$$states{$action}[$page-1],$prevtext, @@ -2375,20 +2787,18 @@ sub choose_privs_form { $nexttext = $$navbuttons{'adme'}; } - &topic_bar($r,6,&mt('[_1] member privileges',$ucgpterm)); + $r->print(&Apache::lonhtmlcommon::topic_bar(6,&mt('Setting optional privileges for specific group members'))); &member_privileges_form($r,$action,$formname,$tools,$toolprivs, $fixedprivs,$userdata,$usertools,$idx,undef, $states,$stored,$gpterm); if ($action eq 'create') { - if (keys(%{$sectioncount}) > 0) { - my $img1 = 7; - my $img2 = 8; - &mapping_options($r,$action,$formname,$page,$sectioncount, - $states,$stored,$navbuttons,$img1,$img2, - $gpterm,$ucgpterm,$crstype); - } + my $img1 = 7; + my $img2 = 8; + &mapping_options($r,$action,$formname,$page,$sectioncount, + $states,$stored,$navbuttons,$img1,$img2, + $gpterm,$ucgpterm,$crstype,$cdom,$cnum); } my $prevtext = $$navbuttons{'gtps'}; &display_navbuttons($r,$formname,$$states{$action}[$page-1],$prevtext, @@ -2459,21 +2869,24 @@ sub member_privileges_form { $usertools,$idx,$memchg,$states,$stored,$gpterm) = @_; my %lt = &Apache::lonlocal::texthash( 'addp' => 'Additional privileges', - 'fixp' => 'Fixed privileges', + 'fixp' => 'Core privileges', 'oppr' => 'Optional privileges', - 'func' => 'Function', - 'forf' => 'For the functionality you have chosen to include '. - 'there are no optional privileges to set besides '. - 'the standard privileges.', - 'algr' => "All $gpterm members will receive the same privileges.", - 'asno' => "As no $gpterm members are being added, ". - "there are no specific user privileges to set.", - 'asng' => "As no $gpterm tools will be made available to users, ". - "there are no specific user privileges to set.", - 'nogm' => "No $gpterm member privileges to display or set, ". - "as you have not indicated that you will be activating,". - " re-enabling, changing privileges, or adding/removing ". - "functionality for any current members ", + 'func' => 'Tool', + 'forf' => 'For the collaborative tools included for group '. + 'members being added or modified, '. + 'there are no optional privileges to set '. + 'for specific members.', + 'algr' => 'All new group members will receive the same privileges.', 'ifex' => 'If previously expired members are being re-enabled, or '. + 'if access for future members is being activated now, '. + 'previously set privileges will be preserved.', + 'asno' => 'As no group members are being added, '. + 'there are no specific user privileges to set.', + 'asng' => 'As no group tools will be made available to users, '. + 'there are no specific user privileges to set.', + 'nogm' => 'No group member privileges to display or set, '. + 'as you have not indicated that you will be activating,'. + ' re-enabling, changing privileges, or adding/removing '. + 'tools for any current members.', 'full' => 'Fullname', 'user' => 'Username', 'doma' => 'Domain', @@ -2599,7 +3012,7 @@ END } } else { if (keys(%{$usertools}) > 0) { - $r->print($lt{'algr'}.' '); + $r->print($lt{'algr'}.' '.$lt{'ifex'}.' '); &display_defprivs($r,$tools,$toolprivs,\@defprivs); } else { $r->print($lt{'asno'}.' '); @@ -2707,11 +3120,19 @@ sub write_group_data { } 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. ',$gpterm)); + $r->print(' '
+ .&mt('The value you entered for the quota for the file repository in this '.$gpterm
+ .' contained invalid characters, so it has been set to 0 Mb. You can change this by'
+ .' modifying the '.$gpterm.' settings.')
+ .' ');
}
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).',$gpterm,$maxposs)); + $r->print(' '
+ .&mt('The value you entered for the quota for the file repository in this '.$gpterm
+ .' exceeded the maximum possible value, so it has been set to [_1] Mb '
+ .'(the maximum possible value).',sprintf("%.2f",$maxposs))
+ .' ');
}
my %groupinfo = (
description => $esc_description,
@@ -2776,12 +3197,65 @@ sub write_group_data {
my $result = &add_group_folder($cdom,$cnum,$now,$groupname,$action,
$description,$tools,\%groupinfo,
$gpterm,$ucgpterm,$crstype);
- if ($result ne 'ok') {
- $r->print(&mt('A problem occurred when creating folders for the new [_1]. [_2].',$gpterm,$result)); + if ($result eq 'ok') { + $r->print(' '
+ .&mt($ucgpterm.' [_1] was created.',''.$groupname.'')
+ .' ');
+ } else {
+ $r->print(''
+ .&mt('A problem occurred when creating folders for the new '.$gpterm.' [_1]:'
+ ,''.$groupname.'')
+ .' ');
+ }
+ } elsif ($action eq 'modify') {
+ my (@oldtools,@newtools);
+ if (ref($$stored{'tool'}) eq 'ARRAY') {
+ @oldtools = @{$$stored{'tool'}};
+ }
+ if (ref($tools) eq 'ARRAY') {
+ @newtools = @{$tools};
+ }
+ if (!grep(/^discussion$/,@oldtools) &&
+ grep(/^discussion$/,@newtools)) {
+ my $crspath = '/uploaded/'.$cdom.'/'.$cnum.'/';
+ my $boardsmap = $crspath.'group_boards_'.$groupname.'.sequence';
+ my $navmap = Apache::lonnavmaps::navmap->new();
+ my $bbmapres = $navmap->getResourceByUrl($boardsmap);
+ undef($navmap);
+ if (!$bbmapres) {
+ my $grpmap = $crspath.'group_folder_'.$groupname.'.sequence';
+ my $disctitle = &mt('Discussion Boards');
+ my $outcome = &map_updater($cdom,$cnum,'group_boards_'.
+ $groupname.'.sequence','bbseq',
+ $disctitle,$grpmap);
+ my ($furl,$ferr) =
+ &Apache::lonuserstate::readmap($cdom.'/'.$cnum);
+ $navmap = Apache::lonnavmaps::navmap->new();
+ # modify parameter
+ if ($outcome eq 'ok') {
+ my $parm_result = &parm_setter($navmap,$cdom,$boardsmap,
+ $groupname);
+ if ($parm_result) {
+ $r->print(''.$result + .' '
+ .&mt('An error occurred while setting parameters '
+ .'for Discussion Boards folder: '
+ .'[_1]',$parm_result)
+ .' ');
+ } else {
+ $r->print(''
+ .&mt('Discussion Boards Folder created.')
+ .' ');
+ }
+ } else {
+ $r->print($outcome);
+ }
+ undef($navmap);
+ }
}
- $r->print(&mt('[_1] [_2] was created.',$ucgpterm,$groupname)); - } else { - $r->print(&mt('[_1] [_2] was updated. ',$ucgpterm,$groupname)); + $r->print(' '
+ .&mt($ucgpterm.' [_1] was updated.',''.$groupname.'')
+ .' ');
}
} else {
my %actiontype = (
@@ -2791,8 +3265,10 @@ sub write_group_data {
&Apache::lonnet::logthis("Failed to store $gpterm $groupname ".
'in '.lc($crstype).': '.$cnum.
' in domain: '.$cdom);
- $r->print(&mt('An error occurred when [_1] the [_2]. '.
- 'Please try again.',$actiontype{$action},$gpterm));
+ $r->print(''
+ .&mt('An error occurred when [_1] the '.$gpterm.'. '
+ .'Please try again.',$actiontype{$action})
+ .' ');
}
return $result;
}
@@ -2811,6 +3287,7 @@ sub process_membership {
my %curr_start = ();
my %curr_end = ();
my %tooltype = ();
+ my $context = 'processgroupmembership';
foreach my $tool (@{$tools}) {
foreach my $priv (sort(keys(%{$$toolprivs{$tool}}))) {
@@ -2880,7 +3357,7 @@ sub process_membership {
$curr_privs{$user};
if (&Apache::lonnet::modify_group_roles($cdom,$cnum,$groupname,
$user,$now,$savestart,
- $curr_privs{$user}) eq 'ok') {
+ $curr_privs{$user},'',$context) eq 'ok') {
push(@{$added{'expired'}},$user);
$num_ok ++;
} else {
@@ -2891,7 +3368,7 @@ sub process_membership {
foreach my $user (@deletion) {
$usersettings{$groupname.':'.$user} = $now.':-1:';
if (&Apache::lonnet::modify_group_roles($cdom,$cnum,$groupname,
- $user,$now,'-1','')
+ $user,$now,'-1','','',$context)
eq 'ok') {
push(@{$added{'deleted'}},$user);
$num_ok ++;
@@ -2945,7 +3422,7 @@ sub process_membership {
$group_privs{$user};
if (&Apache::lonnet::modify_group_roles($cdom,$cnum,$groupname,
$user,$end,$start,
- $group_privs{$user}) eq 'ok') {
+ $group_privs{$user},'',$context) eq 'ok') {
push(@{$added{$type}},$user);
$num_ok ++;
} else {
@@ -2984,7 +3461,9 @@ sub process_membership {
}
if ($num_fail) {
foreach my $type (sort(keys(%failed))) {
- $r->print(&mt('The following users could not be [_1], because an error occurred:',$type)); + $r->print(' '
+ .&mt("The following users could not be $type, because an error occurred:")
+ .' ');
foreach my $user (@{$failed{$type}}) {
$r->print($$userdata{$user}[$$idx{fullname}].' - '.$user.''); } @@ -3000,7 +3479,7 @@ sub process_membership { } if ($roster_result eq 'ok') { $r->print(' '.&mt('[_1] membership list updated.',$ucgpterm)); - $r->print(' '.&mt("For full access to all of [_1]'s privileges, users will need to log out and log back in.",$groupname).' '); + $r->print(''.&mt("Any currently logged in course users affected by the changes you made to group membership or privileges for the [_1] group will need to log out and log back in for their LON-CAPA sessions to reflect these changes.",$groupname).' '); } else { $r->print(''.&mt('An error occurred while updating the [_1] membership list -',$gpterm).$roster_result.' '); } @@ -3009,13 +3488,13 @@ sub process_membership { sub mapping_options { my ($r,$action,$formname,$page,$sectioncount,$states,$stored, - $navbuttons,$img1,$img2,$gpterm,$ucgpterm,$crstype) = @_; + $navbuttons,$img1,$img2,$gpterm,$ucgpterm,$crstype,$cdom,$cnum) = @_; my %lt = &Apache::lonlocal::texthash( 'auto' => "Settings for automatic $gpterm enrollment", 'gmma' => "$ucgpterm membership mapping to specific sections/roles", 'endi' => "Enable/disable automatic $gpterm enrollment for ". "users in specified roles and sections", - '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.", + 'adds' => "If automatic $gpterm enrollment is enabled, when a user is newly assigned a ".lc($crstype)."-wide or section-specific role, he/she will automatically be added as a member of the $gpterm, with start and end access dates defined by the default dates set for the $gpterm, unless he/she is already a $gpterm member, with access dates that permit either current or future $gpterm access.", '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 $gpterm enrollment", 'curr' => 'Currently set to', @@ -3026,7 +3505,8 @@ sub mapping_options { 'mapr' => "Mapping of roles and sections affected by automatic $gpterm enrollment/disenrollment follows scheme chosen below.", ); &automapping($r,$action,$stored,\%lt,$img1); - &mapping_settings($r,$sectioncount,\%lt,$stored,$img2,$crstype); + &mapping_settings($r,$sectioncount,\%lt,$stored,$img2,$crstype,$cdom,$cnum, + $action); return; } @@ -3040,8 +3520,7 @@ sub automapping { if (exists($$stored{'autodrop'})) { $drop = $$stored{'autodrop'}; } - &topic_bar($r,$image,$$lt{'endi'}); - $r->print(' + $r->print(&Apache::lonhtmlcommon::topic_bar($image,$$lt{'endi'}).' '.$$lt{'gmma'}.': '.$$lt{'adds'}.' '.$$lt{'drops'}.' '.
- &mt('all sections').' | ';
- } else {
- $sections_sel=''.
- §ions_selection(\@sections,'sec_'.$role).
- ' | ';
- }
- }
- $r->print(&Apache::loncommon::start_data_table_row().
- ''.$plrole.
- ' | '.$sections_sel.
- &Apache::loncommon::end_data_table_row());
+ my $roletitle=&Apache::lonnet::plaintext($role,$crstype);
+ $r->print(&print_autorole_item($role,$roletitle,\@sections));
}
+ my @customs;
foreach my $role (sort(keys(%customroles))) {
- my $sections_sel;
- if (@sections > 0) {
- $sections_sel =
- ''.§ions_selection(\@sections,'sec_'.$role).' | ';
- }
- $r->print(&Apache::loncommon::start_data_table_row().
- ''.$role.' | '.
- $sections_sel.
- &Apache::loncommon::end_data_table_row());
+ my ($roletitle) = ($role =~ m|^cr/[^/]+/[^/]+/(.+)$|);
+ push (@customs,$role);
+ $r->print(&print_autorole_item($role,$roletitle,\@sections));
+ }
+ if ($action eq 'modify') {
+ foreach my $role (@{$$stored{'autorole'}}) {
+ if ((!grep(/^\Q$role\E$/,@customs)) &&
+ (!grep(/^\Q$role\E$/,@roles))) {
+ my $roletitle;
+ if ($role =~ /^cr/) {
+ ($roletitle) = ($role =~ m|_([^_]+)$|);
+ } else {
+ $roletitle = &Apache::lonnet::plaintext($role,$crstype);
+ }
+ $r->print(&print_autorole_item($role,$roletitle,\@sections));
+ }
+ }
}
$r->print(&Apache::loncommon::end_data_table());
return;
}
+sub print_autorole_item {
+ my ($role,$roletitle,$sections) = @_;
+ my $sections_sel;
+ if (@{$sections} > 0) {
+ if ($role eq 'cc') {
+ $sections_sel = ''.
+ &mt('all sections').' | ';
+ } else {
+ $sections_sel=''.
+ §ions_selection($sections,'sec_'.$role).
+ ' | ';
+ }
+ }
+ my $output = &Apache::loncommon::start_data_table_row().
+ ''.
+ ' | '.$roletitle.' | '.$sections_sel.
+ &Apache::loncommon::end_data_table_row();
+ return $output;
+}
+
sub standard_roles {
my @roles = ('cc','in','ta','ep','st');
return @roles;
}
-sub my_custom_roles {
- my %returnhash=();
- my %rolehash=&Apache::lonnet::dump('roles');
- foreach (keys %rolehash) {
- if ($_=~/^rolesdef\_(\w+)$/) {
- $returnhash{$1}=$1;
- }
- }
- return %returnhash;
-}
-
sub modify_menu {
my ($r,$groupname,$page,$gpterm) = @_;
my @menu =
@@ -3182,7 +3666,20 @@ sub member_privs_entries {
'.$$userdata{$user}[$$idx{fullname}].' |
'.$uname.' |
'.$udom.' |
- | ');
+
+ | ');
foreach my $tool (@{$showtools}) {
if (exists($$usertools{$user}{$tool})) {
$r->print('
|