--- loncom/interface/lonuserutils.pm 2008/12/12 16:53:37 1.73.2.1
+++ loncom/interface/lonuserutils.pm 2010/01/20 18:22:35 1.97.2.5
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Utility functions for managing LON-CAPA user accounts
#
-# $Id: lonuserutils.pm,v 1.73.2.1 2008/12/12 16:53:37 raeburn Exp $
+# $Id: lonuserutils.pm,v 1.97.2.5 2010/01/20 18:22:35 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -86,7 +86,7 @@ sub modifystudent {
sub modifyuserrole {
my ($context,$setting,$changeauth,$cid,$udom,$uname,$uid,$umode,$upass,
$first,$middle,$last,$gene,$sec,$forceid,$desiredhome,$email,$role,
- $end,$start,$checkid) = @_;
+ $end,$start,$checkid,$inststatus) = @_;
my ($scope,$userresult,$authresult,$roleresult,$idresult);
if ($setting eq 'course' || $context eq 'course') {
$scope = '/'.$cid;
@@ -124,7 +124,7 @@ sub modifyuserrole {
$userresult =
&Apache::lonnet::modifyuser($udom,$uname,$uid,$umode,$upass,$first,
$middle,$last,$gene,$forceid,$desiredhome,
- $email,$role,$start,$end);
+ $email,$inststatus);
if ($userresult eq 'ok') {
if ($role ne '') {
$role =~ s/_/\//g;
@@ -235,7 +235,7 @@ sub domain_roles_select {
# domain context
#
# Role types
- my @roletypes = ('domain','author','course');
+ my @roletypes = ('domain','author','course','community');
my %lt = &role_type_names();
#
# build up the menu information to be passed to
@@ -247,6 +247,10 @@ sub domain_roles_select {
foreach my $roletype (@roletypes) {
# set up the text for this domain
$select_menus{$roletype}->{'text'}= $lt{$roletype};
+ my $crstype;
+ if ($roletype eq 'community') {
+ $crstype = 'Community';
+ }
# we want a choice of 'default' as the default in the second menu
if ($env{'form.roletype'} ne '') {
$select_menus{$roletype}->{'default'} = $env{'form.showrole'};
@@ -261,7 +265,7 @@ sub domain_roles_select {
@roles = &construction_space_roles();
} else {
my $custom = 1;
- @roles = &course_roles('domain',undef,$custom);
+ @roles = &course_roles('domain',undef,$custom,$roletype);
}
my $order = ['Any',@roles];
$select_menus{$roletype}->{'order'} = $order;
@@ -271,14 +275,15 @@ sub domain_roles_select {
&mt('Custom role');
} else {
$select_menus{$roletype}->{'select2'}->{$role} =
- &Apache::lonnet::plaintext($role);
+ &Apache::lonnet::plaintext($role,$crstype);
}
}
$select_menus{$roletype}->{'select2'}->{'Any'} = &mt('Any');
}
my $result = &Apache::loncommon::linked_select_forms
('studentform',(' 'x3).&mt('Role: '),$env{'form.roletype'},
- 'roletype','showrole',\%select_menus,['domain','author','course']);
+ 'roletype','showrole',\%select_menus,
+ ['domain','author','course','community']);
return $result;
}
@@ -328,9 +333,11 @@ sub print_upload_manager_header {
&javascript_validations('upload',$krbdefdom,$password_choice,undef,
$env{'request.role.domain'},$context,
$groupslist);
- my $checked=(($env{'form.noFirstLine'})?' checked="checked" ':'');
- $r->print(&mt('Total number of records found in file: [_1]',''.$distotal.' ').
- " \n");
+ my $checked=(($env{'form.noFirstLine'})?' checked="checked"':'');
+ $r->print('
'
+ .&mt('Total number of records found in file: [_1]'
+ ,''.$distotal.' ')
+ ."
\n");
$r->print(''."\n".
' '.&mt('Please select').' '."\n";
if ($context eq 'course') {
- $options .= &default_course_roles($context,$checkpriv,%customroles);
+ $options .= &default_course_roles($context,$checkpriv,$crstype,%customroles);
} elsif ($context eq 'author') {
my @roles = &construction_space_roles($checkpriv);
foreach my $role (@roles) {
@@ -1098,9 +1211,9 @@ sub default_role_selector {
''.$lt{'grs'}.' '.
&Apache::loncommon::end_data_table_header_row().
&Apache::loncommon::start_data_table_row()."\n".
- ' '."\n".
+ ' '."\n".
''."\n".
- &default_course_roles($context,$checkpriv,%customroles)."\n".
+ &default_course_roles($context,$checkpriv,'Course',%customroles)."\n".
' '.
''.
''.
@@ -1125,13 +1238,13 @@ sub default_role_selector {
}
sub default_course_roles {
- my ($context,$checkpriv,%customroles) = @_;
+ my ($context,$checkpriv,$crstype,%customroles) = @_;
my $output;
my $custom = 1;
- my @roles = &course_roles($context,$checkpriv,$custom);
+ my @roles = &course_roles($context,$checkpriv,$custom,lc($crstype));
foreach my $role (@roles) {
if ($role ne 'cr') {
- my $plrole=&Apache::lonnet::plaintext($role);
+ my $plrole=&Apache::lonnet::plaintext($role,$crstype);
$output .= ' '.$plrole.' ';
}
}
@@ -1180,8 +1293,14 @@ sub domain_roles {
}
sub course_roles {
- my ($context,$checkpriv,$custom) = @_;
- my @allroles = &roles_by_context('course',$custom);
+ my ($context,$checkpriv,$custom,$roletype) = @_;
+ my $crstype;
+ if ($roletype eq 'community') {
+ $crstype = 'Community' ;
+ } else {
+ $crstype = 'Course';
+ }
+ my @allroles = &roles_by_context('course',$custom,$crstype);
my @roles;
if ($context eq 'domain') {
@roles = @allroles;
@@ -1192,7 +1311,7 @@ sub course_roles {
if (&Apache::lonnet::allowed('c'.$role,$env{'request.course.id'})) {
push(@roles,$role);
} else {
- if ($role ne 'cc' && $env{'request.course.sec'} ne '') {
+ if ((($role ne 'cc') && ($role ne 'co')) && ($env{'request.course.sec'} ne '')) {
if (&Apache::lonnet::allowed('c'.$role,
$env{'request.course.id'}.'/'.
$env{'request.course.sec'})) {
@@ -1210,19 +1329,19 @@ sub course_roles {
}
sub curr_role_permissions {
- my ($context,$setting,$checkpriv) = @_;
+ my ($context,$setting,$checkpriv,$type) = @_;
my $custom = 1;
my @roles;
if ($context eq 'author') {
@roles = &construction_space_roles($checkpriv);
} elsif ($context eq 'domain') {
if ($setting eq 'course') {
- @roles = &course_roles($context,$checkpriv,$custom);
+ @roles = &course_roles($context,$checkpriv,$custom,$type);
} else {
@roles = &domain_roles($checkpriv);
}
} elsif ($context eq 'course') {
- @roles = &course_roles($context,$checkpriv,$custom);
+ @roles = &course_roles($context,$checkpriv,$custom,$type);
}
return @roles;
}
@@ -1291,9 +1410,9 @@ sub print_userlist {
'html' => 'HTML');
my $output_selector = '';
foreach my $outputformat ('html','csv','excel') {
- my $option = '';
$output_selector .= "\n".$option;
@@ -1308,7 +1427,7 @@ sub print_userlist {
.''.(' 'x3)."\n");
my $roleselected = '';
if ($env{'form.showrole'} eq 'Any') {
- $roleselected = ' selected="selected" ';
+ $roleselected = ' selected="selected"';
}
my ($cnum,$cdom);
$r->print(&role_filter($context));
@@ -1316,26 +1435,52 @@ sub print_userlist {
($cnum,$cdom) = &get_course_identity();
$r->print(§ion_group_filter($cnum,$cdom));
}
- if (!(($context eq 'domain') && ($env{'form.roletype'} eq 'course'))) {
+ if ($env{'form.phase'} eq '') {
+ $r->print(' '.&list_submit_button(&mt('Display List of Users')).
+ "\n\n".
+ ' ');
+ return;
+ }
+ if (!(($context eq 'domain') &&
+ (($env{'form.roletype'} eq 'course') || ($env{'form.roletype'} eq 'community')))) {
$r->print(' '.&list_submit_button(&mt('Update Display')).
"\n\n");
}
my ($indexhash,$keylist) = &make_keylist_array();
- my (%userlist,%userinfo);
- if ($context eq 'domain' && $env{'form.roletype'} eq 'course') {
+ my (%userlist,%userinfo,$clearcoursepick);
+ if (($context eq 'domain') &&
+ ($env{'form.roletype'} eq 'course') ||
+ ($env{'form.roletype'} eq 'community')) {
+ my ($crstype,$numcodes,$title,$warning);
+ if ($env{'form.roletype'} eq 'course') {
+ $crstype = 'Course';
+ $numcodes = $totcodes;
+ $title = &mt('Select Courses');
+ $warning = &mt('Warning: data retrieval for multiple courses can take considerable time, as this operation is not currently optimized.');
+ } elsif ($env{'form.roletype'} eq 'community') {
+ $crstype = 'Community';
+ $numcodes = 0;
+ $title = &mt('Select Communities');
+ $warning = &mt('Warning: data retrieval for multiple communities can take considerable time, as this operation is not currently optimized.');
+ }
my $courseform =
- &Apache::lonhtmlcommon::course_selection($formname,$totcodes,
- $codetitles,$idlist,$idlist_titles);
+ &Apache::lonhtmlcommon::course_selection($formname,$numcodes,
+ $codetitles,$idlist,$idlist_titles,$crstype);
$r->print(''.&Apache::lonhtmlcommon::start_pick_box()."\n".
&Apache::lonhtmlcommon::start_pick_box()."\n".
- &Apache::lonhtmlcommon::row_title(&mt('Select Course(s)'),
- 'LC_oddrow_value')."\n".
+ &Apache::lonhtmlcommon::row_title($title,'LC_oddrow_value')."\n".
$courseform."\n".
&Apache::lonhtmlcommon::row_closure(1).
&Apache::lonhtmlcommon::end_pick_box().'
'.
- ''.&list_submit_button(&mt('Update Display')).
- "\n".'
'.&mt('Warning: data retrieval for multiple courses can take considerable time, as this operation is not currently optimized.').' '."\n");
- if ($env{'form.coursepick'}) {
+ ' '.
+ &list_submit_button(&mt('Update Display')).
+ "\n".'
'.$warning.' '."\n");
+ $clearcoursepick = 0;
+ if (($env{'form.origroletype'} ne '') &&
+ ($env{'form.origroletype'} ne $env{'form.roletype'})) {
+ $clearcoursepick = 1;
+ }
+ if (($env{'form.coursepick'}) && (!$clearcoursepick)) {
$r->print(' '.&mt('Searching').' ... ');
}
} else {
@@ -1409,7 +1554,7 @@ sub print_userlist {
}
}
} elsif ($env{'form.roletype'} eq 'course') {
- if ($env{'form.coursepick'}) {
+ if (($env{'form.coursepick'}) && (!$clearcoursepick)) {
my %courses = &process_coursepick();
my %allusers;
my $hidepriv = 1;
@@ -1420,7 +1565,8 @@ sub print_userlist {
my (@roles,@sections,%access,%users,%userdata,
%statushash);
if ($env{'form.showrole'} eq 'Any') {
- @roles = &course_roles($context,undef,$custom);
+ @roles = &course_roles($context,undef,$custom,
+ $env{'form.roletype'});
} else {
@roles = ($env{'form.showrole'});
}
@@ -1466,6 +1612,8 @@ sub print_userlist {
$r->print(&mt('There are no authors or co-authors to display.')."\n");
} elsif ($env{'form.roletype'} eq 'course') {
$r->print(&mt('There are no course users to display')."\n");
+ } elsif ($env{'form.roletype'} eq 'community') {
+ $r->print(&mt('There are no community users to display')."\n");
}
} elsif ($context eq 'course') {
$r->print(&mt('There are no course users to display.')."\n");
@@ -1496,7 +1644,7 @@ sub role_filter {
my $output;
my $roleselected = '';
if ($env{'form.showrole'} eq 'Any') {
- $roleselected = ' selected="selected" ';
+ $roleselected = ' selected="selected"';
}
my ($role_select);
if ($context eq 'domain') {
@@ -1508,17 +1656,26 @@ sub role_filter {
$role_select = ''."\n".
''.
&mt('Any role').' ';
- my @poss_roles = &curr_role_permissions($context);
+ my ($roletype,$crstype);
+ if ($context eq 'course') {
+ $crstype = &Apache::loncommon::course_type();
+ if ($crstype eq 'Community') {
+ $roletype = 'community';
+ } else {
+ $roletype = 'course';
+ }
+ }
+ my @poss_roles = &curr_role_permissions($context,'','',$roletype);
foreach my $role (@poss_roles) {
$roleselected = '';
if ($role eq $env{'form.showrole'}) {
- $roleselected = ' selected="selected" ';
+ $roleselected = ' selected="selected"';
}
my $plrole;
if ($role eq 'cr') {
$plrole = &mt('Custom role');
} else {
- $plrole=&Apache::lonnet::plaintext($role);
+ $plrole=&Apache::lonnet::plaintext($role,$crstype);
}
$role_select .= ''.$plrole.' ';
}
@@ -1569,7 +1726,7 @@ sub section_group_filter {
foreach my $option ('all','none',@options) {
$currsel = '';
if ($env{'form.'.$name{$item}} eq $option) {
- $currsel = ' selected="selected" ';
+ $currsel = ' selected="selected"';
}
$markup .= ' ';
if (($option eq 'all') || ($option eq 'none')) {
@@ -1633,7 +1790,8 @@ sub gather_userinfo {
$indexhash,$uniqid,$userlist);
}
}
- } elsif ($env{'form.roletype'} eq 'course') {
+ } elsif (($env{'form.roletype'} eq 'course') ||
+ ($env{'form.roletype'} eq 'community')) {
($userdata{'username'},$userdata{'domain'},$userdata{'role'}) =
split(/:/,$item);
if (ref($rolehash->{$item}) eq 'HASH') {
@@ -1683,7 +1841,8 @@ sub gather_userinfo {
sub build_user_record {
my ($context,$userdata,$userinfo,$indexhash,$record_key,$userlist) = @_;
next if ($userdata->{'start'} eq '-1' && $userdata->{'end'} eq '-1');
- if (!(($context eq 'domain') && ($env{'form.roletype'} eq 'course'))) {
+ if (!(($context eq 'domain') && (($env{'form.roletype'} eq 'course')
+ && ($env{'form.roletype'} eq 'community')))) {
&process_date_info($userdata);
}
my $username = $userdata->{'username'};
@@ -1908,15 +2067,15 @@ sub aggregate_user_info {
sub process_date_info {
my ($userdata) = @_;
my $now = time;
- $userdata->{'status'} = &mt('Active');
+ $userdata->{'status'} = 'Active';
if ($userdata->{'start'} > 0) {
if ($now < $userdata->{'start'}) {
- $userdata->{'status'} = &mt('Future');
+ $userdata->{'status'} = 'Future';
}
}
if ($userdata->{'end'} > 0) {
if ($now > $userdata->{'end'}) {
- $userdata->{'status'} = &mt('Expired');
+ $userdata->{'status'} = 'Expired';
}
}
return;
@@ -1948,9 +2107,10 @@ sub show_users_list {
$sortby = 'username';
}
my $setting = $env{'form.roletype'};
- my ($cid,$cdom,$cnum,$classgroups,$displayphotos,$displayclickers);
+ my ($cid,$cdom,$cnum,$classgroups,$displayphotos,$displayclickers,$crstype);
if ($context eq 'course') {
$cid = $env{'request.course.id'};
+ $crstype = &Apache::loncommon::course_type();
($cnum,$cdom) = &get_course_identity($cid);
($classgroups) = &Apache::loncoursedata::get_group_memberships(
$userlist,$keylist,$cdom,$cnum);
@@ -1968,6 +2128,7 @@ sub show_users_list {
if ($env{'course.'.$cid.'.internal.showphoto'}) {
$r->print('
');
}
@@ -1983,6 +2145,12 @@ function photowindow(photolink) {
END
}
+ } elsif ($context eq 'domain') {
+ if ($setting eq 'community') {
+ $crstype = 'Community';
+ } elsif ($crstype eq 'course') {
+ $crstype = 'Course';
+ }
}
if ($mode ne 'autoenroll' && $mode ne 'pickauthor') {
my $check_uncheck_js = &Apache::loncommon::check_uncheck_jscript();
@@ -1991,6 +2159,7 @@ END
$r->print(<
+//
$date_sec_selector
@@ -2050,7 +2231,7 @@ END
'status' => "status",
'role' => "role",
'type' => "enroll type/action",
- 'email' => "email address",
+ 'email' => "e-mail address",
'photo' => "photo",
'extent' => "extent",
'pr' => "Proceed",
@@ -2058,13 +2239,16 @@ END
'ua' => "uncheck all",
'ac' => "Action to take for selected users",
'link' => "Behavior of clickable username link for each user",
- 'aboutme' => "Display a user's personal page",
+ 'aboutme' => "Display a user's personal information page",
'owin' => "Open in a new window",
'modify' => "Modify a user's information",
+ 'track' => "View a user's recent activity",
'clicker' => "Clicker-ID",
);
if ($context eq 'domain' && $env{'form.roletype'} eq 'course') {
$lt{'extent'} = &mt('Course(s): description, section(s), status');
+ } elsif ($context eq 'domain' && $env{'form.roletype'} eq 'community') {
+ $lt{'extent'} = &mt('Communities: description, section(s), status');
} elsif ($context eq 'author') {
$lt{'extent'} = &mt('Author');
}
@@ -2076,18 +2260,21 @@ END
if ($context eq 'course') {
push(@cols,'section');
}
- if (!($context eq 'domain' && $env{'form.roletype'} eq 'course')) {
+ if (!($context eq 'domain' && ($env{'form.roletype'} eq 'course')
+ && ($env{'form.roletype'} eq 'community'))) {
push(@cols,('start','end'));
}
if ($env{'form.showrole'} eq 'Any' || $env{'form.showrole'} eq 'cr') {
push(@cols,'role');
}
if ($context eq 'domain' && ($env{'form.roletype'} eq 'author' ||
- $env{'form.roletype'} eq 'course')) {
+ $env{'form.roletype'} eq 'course' ||
+ $env{'form.roletype'} eq 'community')) {
push (@cols,'extent');
}
- if (($statusmode eq 'Any') &&
- (!($context eq 'domain' && $env{'form.roletype'} eq 'course'))) {
+ if (($statusmode eq 'Any') &&
+ (!($context eq 'domain' && (($env{'form.roletype'} eq 'course')
+ || ($env{'form.roletype'} eq 'community'))))) {
push(@cols,'status');
}
if ($context eq 'course') {
@@ -2105,7 +2292,8 @@ END
my $results_description;
if ($mode ne 'autoenroll') {
$results_description = &results_header_row($rolefilter,$statusmode,
- $context,$permission,$mode);
+ $context,$permission,$mode,$crstype);
+
$r->print(''.$results_description.' ');
}
my ($output,$actionselect,%canchange,%canchangesec);
@@ -2132,9 +2320,9 @@ END
if ($env{'form.showrole'} eq 'Any') {
my $custom = 1;
if ($context eq 'domain') {
- @allroles = &roles_by_context($setting,$custom);
+ @allroles = &roles_by_context($setting,$custom,$crstype);
} else {
- @allroles = &roles_by_context($context,$custom);
+ @allroles = &roles_by_context($context,$custom,$crstype);
}
} else {
@allroles = ($env{'form.showrole'});
@@ -2174,6 +2362,11 @@ END
if ($permission->{'cusr'}) {
unshift (@linkdests,'modify');
}
+ if (&Apache::lonnet::allowed('vsa', $env{'request.course.id'}) ||
+ &Apache::lonnet::allowed('vsa', $env{'request.course.id'}.'/'.
+ $env{'request.course.sec'})) {
+ push(@linkdests,'track');
+ }
$output .= '';
my $usernamelink = $env{'form.usernamelink'};
if ($usernamelink eq '') {
@@ -2182,15 +2375,15 @@ END
foreach my $item (@linkdests) {
my $checkedstr = '';
if ($item eq $usernamelink) {
- $checkedstr = ' checked="checked" ';
+ $checkedstr = ' checked="checked"';
}
- $output .= ' '.$lt{$item}.' ';
+ $output .= ' '.$lt{$item}.' ';
}
my $checkwin;
if ($env{'form.userwin'}) {
- $checkwin = 'checked = "checked"';
+ $checkwin = ' checked="checked"';
}
- $output .= ' '.$lt{'owin'}.'
';
+ $output .= ' '.$lt{'owin'}.' ';
}
$output .= "\n".''."\n".
&Apache::loncommon::start_data_table().
@@ -2303,6 +2496,11 @@ END
$grpfilter = 'all';
}
}
+ my %ltstatus = &Apache::lonlocal::texthash(
+ Active => 'Active',
+ Future => 'Future',
+ Expired => 'Expired',
+ );
# Get groups, role, permanent e-mail so we can sort on them if
# necessary.
foreach my $user (keys(%{$userlist})) {
@@ -2330,7 +2528,8 @@ END
}
} elsif ($env{'form.roletype'} eq 'author') {
($uname,$udom,$role) = split(/:/,$user,-1);
- } elsif ($env{'form.roletype'} eq 'course') {
+ } elsif (($env{'form.roletype'} eq 'course') ||
+ ($env{'form.roletype'} eq 'community')) {
($uname,$udom,$role) = split(/:/,$user);
}
} else {
@@ -2437,7 +2636,7 @@ END
if ($clickers!~/\w/) { $clickers='-'; }
$in{'clicker'} = $clickers;
my $role = $in{'role'};
- $in{'role'}=&Apache::lonnet::plaintext($sdata->[$index{'role'}]);
+ $in{'role'}=&Apache::lonnet::plaintext($sdata->[$index{'role'}],$crstype);
if (! defined($in{'start'}) || $in{'start'} == 0) {
$in{'start'} = &mt('none');
} else {
@@ -2457,7 +2656,7 @@ END
$cellentry = ''.&mt('auto').' Change ';
$autocount ++;
} else {
- $cellentry = '';
}
$r->print("$cellentry \n");
} else {
@@ -2502,7 +2701,7 @@ END
}
}
$r->print(' ');
+ 'actionlist" value="'.$checkval.'" />');
} else {
$r->print(' ');
}
@@ -2515,6 +2714,12 @@ END
$r->print(''.&print_username_link($mode,\%in).' ');
} elsif (($item eq 'start' || $item eq 'end') && ($actionselect)) {
$r->print(''.$in{$item}.' '."\n");
+ } elsif ($item eq 'status') {
+ my $showitem = $in{$item};
+ if (defined($ltstatus{$in{$item}})) {
+ $showitem = $ltstatus{$in{$item}};
+ }
+ $r->print(''.$showitem.' '."\n");
} else {
$r->print(''.$in{$item}.' '."\n");
}
@@ -2531,7 +2736,7 @@ END
}
if ($env{'course.'.$env{'request.course.id'}.'.internal.showphoto'}) {
if ($displayphotos eq 'on' && $role eq 'st' && $in{'photo'} ne '') {
- $r->print(' ');
+ $r->print(' ');
} else {
$r->print(' ');
}
@@ -2729,6 +2934,8 @@ sub role_type_names {
'domain' => 'Domain Roles',
'author' => 'Co-Author Roles',
'course' => 'Course Roles',
+ 'community' => 'Community Roles',
+
);
return %lt;
}
@@ -2818,8 +3025,8 @@ sub select_actions {
}
}
if ($choices{'sections'}) {
- $output .= ' '."\n".
- ' '."\n";
+ $output .= ' '."\n".
+ ' '."\n";
}
}
return $output;
@@ -2833,9 +3040,9 @@ sub date_section_javascript {
delete => "Check the boxes for any users for whom roles are to be deleted, and click 'Proceed'",
none => "Choose an action to take for selected users",
);
- my $output = '
-
ENDTWO
return $output;
}
sub date_section_selector {
- my ($context,$permission) = @_;
+ my ($context,$permission,$crstype) = @_;
my $callingform = $env{'form.callingform'};
my $formname = 'dateselect';
my $groupslist = &get_groupslist();
my $sec_js = &setsections_javascript($formname,$groupslist);
my $output = <<"END";
ENDJS
my %lt = &Apache::lonlocal::texthash (
@@ -2961,7 +3171,7 @@ ENDJS
}
$date_items = &date_setting_table($starttime,undef,$context,
$env{'form.bulkaction'},$formname,
- $permission);
+ $permission,$crstype);
}
$output .= ''.$headertext.' '.
'';
return $output;
}
sub section_picker {
- my ($cdom,$cnum,$role,$rowtitle,$permission,$context,$mode) = @_;
+ my ($cdom,$cnum,$role,$rowtitle,$permission,$context,$mode,$crstype) = @_;
my %sections_count = &Apache::loncommon::get_sections($cdom,$cnum);
my $sections_select .= &course_sections(\%sections_count,$role);
my $secbox = ''.&Apache::lonhtmlcommon::start_pick_box()."\n";
if ($mode eq 'upload') {
my ($options,$cb_script,$coursepick) =
- &default_role_selector($context,1);
+ &default_role_selector($context,1,$crstype);
$secbox .= &Apache::lonhtmlcommon::row_title(&mt('role'),'LC_oddrow_value').
$options. &Apache::lonhtmlcommon::row_closure(1)."\n";
}
@@ -3033,26 +3243,50 @@ sub section_picker {
}
sub results_header_row {
- my ($rolefilter,$statusmode,$context,$permission,$mode) = @_;
+ my ($rolefilter,$statusmode,$context,$permission,$mode,$crstype) = @_;
my ($description,$showfilter);
if ($rolefilter ne 'Any') {
$showfilter = $rolefilter;
}
if ($context eq 'course') {
if ($mode eq 'csv' || $mode eq 'excel') {
- $description = &mt('Course - [_1]:',$env{'course.'.$env{'request.course.id'}.'.description'}).' ';
+ if ($crstype eq 'Community') {
+ $description = &mt('Community - [_1]:',$env{'course.'.$env{'request.course.id'}.'.description'}).' ';
+ } else {
+ $description = &mt('Course - [_1]:',$env{'course.'.$env{'request.course.id'}.'.description'}).' ';
+ }
}
if ($statusmode eq 'Expired') {
- $description .= &mt('Users in course with expired [_1] roles',$showfilter);
+ if ($crstype eq 'Community') {
+ $description .= &mt('Users in community with expired [_1] roles',$showfilter);
+ } else {
+ $description .= &mt('Users in course with expired [_1] roles',$showfilter);
+ }
} elsif ($statusmode eq 'Future') {
- $description .= &mt('Users in course with future [_1] roles',$showfilter);
+ if ($crstype eq 'Community') {
+ $description .= &mt('Users in community with future [_1] roles',$showfilter);
+ } else {
+ $description .= &mt('Users in course with future [_1] roles',$showfilter);
+ }
} elsif ($statusmode eq 'Active') {
- $description .= &mt('Users in course with active [_1] roles',$showfilter);
+ if ($crstype eq 'Community') {
+ $description .= &mt('Users in community with active [_1] roles',$showfilter);
+ } else {
+ $description .= &mt('Users in course with active [_1] roles',$showfilter);
+ }
} else {
if ($rolefilter eq 'Any') {
- $description .= &mt('All users in course');
+ if ($crstype eq 'Community') {
+ $description .= &mt('All users in community');
+ } else {
+ $description .= &mt('All users in course');
+ }
} else {
- $description .= &mt('All users in course with [_1] roles',$rolefilter);
+ if ($crstype eq 'Community') {
+ $description .= &mt('All users in community with [_1] roles',$rolefilter);
+ } else {
+ $description .= &mt('All users in course with [_1] roles',$rolefilter);
+ }
}
}
my $constraint;
@@ -3148,19 +3382,29 @@ sub results_header_row {
$description .= &mt('All co-authors in domain with [_1] roles',$rolefilter);
}
}
- } elsif ($env{'form.roletype'} eq 'course') {
+ } elsif (($env{'form.roletype'} eq 'course') ||
+ ($env{'form.roletype'} eq 'community')) {
+
my $coursefilter = $env{'form.coursepick'};
- if ($coursefilter eq 'category') {
- my $instcode = &instcode_from_coursefilter();
- if ($instcode eq '.') {
+ if ($env{'form.roletype'} eq 'course') {
+ if ($coursefilter eq 'category') {
+ my $instcode = &instcode_from_coursefilter();
+ if ($instcode eq '.') {
+ $description .= &mt('All courses in domain').' - ';
+ } else {
+ $description .= &mt('Courses in domain with institutional code: [_1]',$instcode).' - ';
+ }
+ } elsif ($coursefilter eq 'selected') {
+ $description .= &mt('Selected courses in domain').' - ';
+ } elsif ($coursefilter eq 'all') {
$description .= &mt('All courses in domain').' - ';
- } else {
- $description .= &mt('Courses in domain with institutional code: [_1]',$instcode).' - ';
}
- } elsif ($coursefilter eq 'selected') {
- $description .= &mt('Selected courses in domain').' - ';
- } elsif ($coursefilter eq 'all') {
- $description .= &mt('All courses in domain').' - ';
+ } elsif ($env{'form.roletype'} eq 'community') {
+ if ($coursefilter eq 'selected') {
+ $description .= &mt('Selected communities in domain').' - ';
+ } elsif ($coursefilter eq 'all') {
+ $description .= &mt('All communities in domain').' - ';
+ }
}
if ($statusmode eq 'Expired') {
$description .= &mt('users with expired [_1] roles',$showfilter);
@@ -3197,7 +3441,7 @@ sub viewable_section {
#################################################
#################################################
sub show_drop_list {
- my ($r,$classlist,$nosort,$permission) = @_;
+ my ($r,$classlist,$nosort,$permission,$crstype) = @_;
my $cid = $env{'request.course.id'};
my ($cnum,$cdom) = &get_course_identity($cid);
if (! exists($env{'form.sortby'})) {
@@ -3215,10 +3459,12 @@ sub show_drop_list {
-
+
END
my ($indexhash,$keylist) = &make_keylist_array();
my $studentcount = 0;
@@ -3241,7 +3487,11 @@ END
}
}
if (!$studentcount) {
- $r->print(&mt('There are no students to drop.'));
+ if ($crstype eq 'Community') {
+ $r->print(&mt('There are no members to drop.'));
+ } else {
+ $r->print(&mt('There are no students to drop.'));
+ }
return;
}
my ($classgroups) = &Apache::loncoursedata::get_group_memberships(
@@ -3249,11 +3499,16 @@ END
my %lt=&Apache::lonlocal::texthash('usrn' => "username",
'dom' => "domain",
'sn' => "student name",
+ 'mn' => "member name",
'sec' => "section",
'start' => "start date",
'end' => "end date",
'groups' => "active groups",
);
+ my $nametitle = $lt{'sn'};
+ if ($crstype eq 'Community') {
+ $nametitle = $lt{'mn'};
+ }
if ($nosort) {
$r->print(&Apache::loncommon::start_data_table().
&Apache::loncommon::start_data_table_header_row());
@@ -3262,7 +3517,7 @@ END
$lt{'usrn'}
$lt{'dom'}
ID
- $lt{'sn'}
+ $nametitle
$lt{'sec'}
$lt{'start'}
$lt{'end'}
@@ -3281,7 +3536,7 @@ END
ID
- $lt{'sn'}
+ $nametitle
$lt{'sec'}
@@ -3336,7 +3591,7 @@ END
#
$r->print(&Apache::loncommon::start_data_table_row());
$r->print(<<"END");
-
+
$username
$domain
$id
@@ -3351,14 +3606,23 @@ END
$r->print(&Apache::loncommon::end_data_table().' ');
%lt=&Apache::lonlocal::texthash(
'dp' => "Drop Students",
+ 'dm' => "Drop Members",
'ca' => "check all",
'ua' => "uncheck all",
);
+ my $btn = $lt{'dp'};
+ if ($crstype eq 'Community') {
+ $btn = $lt{'dm'};
+ }
$r->print(<<"END");
-
-
-
-
+
+
+
+
+
+
+
+
END
return;
}
@@ -3369,24 +3633,43 @@ END
sub print_first_users_upload_form {
my ($r,$context) = @_;
my $str;
- $str = ' ';
+ $str = ' ';
$str .= ' ';
- $str .= ' ';
- $str .= "".&mt('Upload a file containing information about users')." \n";
- $str .= &Apache::loncommon::upfile_select_html();
- $str .= '';
- $str .= &Apache::loncommon::help_open_topic("Course_Create_Class_List",
- &mt("How do I create a users list from a spreadsheet")).
- " \n";
- $str .= &Apache::loncommon::help_open_topic("Course_Convert_To_CSV",
- &mt("How do I create a CSV file from a spreadsheet"));
- $str .= "
\n";
- $str .= "\n";
- $str .= ' '.
- &mt('Ignore First Line')."
\n";
- $str .= ' '." \n";
+ $str .= ' ';
+
+
+ $str .= ''.&mt('Upload a file containing information about users').' '."\n";
+
+ # Excel and CSV Help
+ $str .= ''
+ .&Apache::loncommon::help_open_topic("Course_Create_Class_List",
+ &mt("How do I create a users list from a spreadsheet"))
+ ." \n"
+ .&Apache::loncommon::help_open_topic("Course_Convert_To_CSV",
+ &mt("How do I create a CSV file from a spreadsheet"))
+ ."
\n";
+
+ $str .= &Apache::lonhtmlcommon::start_pick_box()
+ .&Apache::lonhtmlcommon::row_title(&mt('File'))
+ .''."\n"
+ .&mt('Please upload an UTF8 encoded file to ensure a correct character encoding in your classlist.')."\n"
+ .'
'."\n"
+ .&Apache::loncommon::upfile_select_html()
+ .&Apache::lonhtmlcommon::row_closure()
+ .&Apache::lonhtmlcommon::row_title(
+ ''
+ .&mt('Ignore First Line')
+ .' ')
+ .' '
+ .&Apache::lonhtmlcommon::row_closure(1)
+ .&Apache::lonhtmlcommon::end_pick_box();
+
+ $str .= ''
+ .' '
+ .'
';
+
$str .= &Apache::loncommon::end_page();
+
$r->print($str);
return;
}
@@ -3430,11 +3713,25 @@ sub upfile_drop_add {
'ipwd_choice' => 'scalar',
'email_choice' => 'scalar',
'role_choice' => 'scalar',
- 'domain_choice' => 'scalar'});
+ 'domain_choice' => 'scalar',
+ 'inststatus_choice' => 'scalar'});
#
+ my ($cid,$crstype,$setting);
+ if ($context eq 'domain') {
+ $setting = $env{'form.roleaction'};
+ }
+ if ($env{'request.course.id'} ne '') {
+ $cid = $env{'request.course.id'};
+ $crstype = &Apache::loncommon::course_type();
+ } elsif ($setting eq 'course') {
+ if (&Apache::lonnet::is_course($env{'form.dcdomain'},$env{'form.dccourse'})) {
+ $cid = $env{'form.dcdomain'}.'_'.$env{'form.dccourse'};
+ $crstype = &Apache::loncommon::course_type($cid);
+ }
+ }
my ($startdate,$enddate) = &get_dates_from_form();
if ($env{'form.makedatesdefault'}) {
- $r->print(&make_dates_default($startdate,$enddate,$context));
+ $r->print(&make_dates_default($startdate,$enddate,$context,$crstype);
}
# Determine domain and desired host (home server)
my $defdom=$env{'request.role.domain'};
@@ -3486,43 +3783,36 @@ sub upfile_drop_add {
$amode = ''; # This causes the loop below to be skipped
}
}
- my ($cid,$defaultsec,$defaultrole,$setting);
+ my ($defaultsec,$defaultrole);
if ($context eq 'domain') {
- $setting = $env{'form.roleaction'};
if ($setting eq 'domain') {
$defaultrole = $env{'form.defaultrole'};
} elsif ($setting eq 'course') {
$defaultrole = $env{'form.courserole'};
$defaultsec = $env{'form.sections'};
- }
+ }
} elsif ($context eq 'author') {
$defaultrole = $env{'form.defaultrole'};
} elsif ($context eq 'course') {
$defaultrole = $env{'form.defaultrole'};
$defaultsec = $env{'form.sections'};
}
- if ($env{'request.course.id'} ne '') {
- $cid = $env{'request.course.id'};
- } elsif ($setting eq 'course') {
- if (&Apache::lonnet::is_course($env{'form.dcdomain'},$env{'form.dccourse'})) {
- $cid = $env{'form.dcdomain'}.'_'.$env{'form.dccourse'};
- }
- }
# Check to see if user information can be changed
my @userinfo = ('firstname','middlename','lastname','generation',
'permanentemail','id');
my %canmodify;
if (&Apache::lonnet::allowed('mau',$domain)) {
+ push(@userinfo,'inststatus');
foreach my $field (@userinfo) {
$canmodify{$field} = 1;
}
}
my (%userlist,%modifiable_fields,@poss_roles);
my $secidx = &Apache::loncoursedata::CL_SECTION();
- my @courseroles = &roles_by_context('course',1);
+ my @courseroles = &roles_by_context('course',1,$crstype);
if (!&Apache::lonnet::allowed('mau',$domain)) {
if ($context eq 'course' || $context eq 'author') {
- @poss_roles = &curr_role_permissions($context);
+ @poss_roles = &curr_role_permissions($context,'','',$crstype);
my @statuses = ('active','future');
my ($indexhash,$keylist) = &make_keylist_array();
my %info;
@@ -3561,6 +3851,8 @@ sub upfile_drop_add {
} else {
$r->print(''.&mt('Adding/Modifying Users')." \n\n");
}
+ $r->rflush;
+
my %counts = (
user => 0,
auth => 0,
@@ -3607,7 +3899,8 @@ sub upfile_drop_add {
}
my (%curr_rules,%got_rules,%alerts);
my %customroles = &my_custom_roles();
- my @permitted_roles = &roles_on_upload($context,$setting,%customroles);
+ my @permitted_roles =
+ &roles_on_upload($context,$setting,$crstype,%customroles);
# Get new users list
foreach my $line (@userdata) {
my @secs;
@@ -3636,8 +3929,8 @@ sub upfile_drop_add {
if ($entries{$fields{'username'}}
ne &LONCAPA::clean_username($entries{$fields{'username'}})) {
$r->print(' '.
- &mt('[_1] : Unacceptable username for user [_2] [_3] [_4] [_5]',
- $entries{$fields{'username'}},$fname,$mname,$lname,$gen));
+ &mt('[_1]: Unacceptable username for user [_2] [_3] [_4] [_5]',
+ ''.$entries{$fields{'username'}}.' ',$fname,$mname,$lname,$gen));
next;
} else {
if ($entries{$fields{'domain'}}
@@ -3656,10 +3949,10 @@ sub upfile_drop_add {
$entries{$fields{'sec'}} =~ s/\W//g;
my $item = $entries{$fields{'sec'}};
if ($item eq "none" || $item eq 'all') {
- $r->print(' '.&mt('[_1] : Unable to enroll user [_2] [_3] [_4] [_5] in a section named "[_6]" - this is a reserved word.',$username,$fname,$mname,$lname,$gen,$item));
+ $r->print(' '.&mt('[_1]: Unable to enroll user [_2] [_3] [_4] [_5] in a section named "[_6]" - this is a reserved word.',''.$username.' ',$fname,$mname,$lname,$gen,$item));
next;
} elsif (exists($curr_groups{$item})) {
- $r->print(' '.&mt('[_1] : Unable to enroll user [_2] [_3] [_4] [_5] in a section named "[_6]" - this is a course group.',$username,$fname,$mname,$lname,$gen,$item).' '.&mt('Section names and group names must be distinct.'));
+ $r->print(' '.&mt('[_1]: Unable to enroll user [_2] [_3] [_4] [_5] in a section named "[_6]" - this is a course group.',''.$username.' ',$fname,$mname,$lname,$gen,$item).' '.&mt('Section names and group names must be distinct.'));
next;
} else {
push(@secs,$item);
@@ -3671,7 +3964,7 @@ sub upfile_drop_add {
if (ref($userlist{$username.':'.$userdomain}) eq 'ARRAY') {
my $currsec = $userlist{$username.':'.$userdomain}[$secidx];
if ($currsec ne $env{'request.course.sec'}) {
- $r->print(' '.&mt('[_1] : Unable to enroll user [_2] [_3] [_4] [_5] in a section named "[_6]".',$username,$fname,$mname,$lname,$gen,$secs[0]).' ');
+ $r->print(' '.&mt('[_1]: Unable to enroll user [_2] [_3] [_4] [_5] in a section named "[_6]".',''.$username.' ',$fname,$mname,$lname,$gen,$secs[0]).' ');
if ($currsec eq '') {
$r->print(&mt('This user already has an active/future student role in the course, unaffiliated to any section.'));
@@ -3700,7 +3993,15 @@ sub upfile_drop_add {
if (defined($fields{'email'})) {
if (defined($entries{$fields{'email'}})) {
$email=$entries{$fields{'email'}};
- unless ($email=~/^[^\@]+\@[^\@]+$/) { $email=''; } }
+ unless ($email=~/^[^\@]+\@[^\@]+$/) { $email=''; }
+ }
+ }
+ # determine affiliation
+ my $inststatus='';
+ if (defined($fields{'inststatus'})) {
+ if (defined($entries{$fields{'inststatus'}})) {
+ $inststatus=$entries{$fields{'inststatus'}};
+ }
}
# determine user password
my $password = $genpwd;
@@ -3721,8 +4022,13 @@ sub upfile_drop_add {
}
if ($role eq '') {
my $rolestr = join(', ',@permitted_roles);
- $r->print(' '.
- &mt('[_1] : You do not have permission to add the requested role [_2] for the user.',$entries{$fields{'username'}},$entries{$fields{'role'}}).' '.&mt('Allowable role(s) is/are: [_1].',$rolestr)."\n");
+ $r->print(' '
+ .&mt('[_1]: You do not have permission to add the requested role [_2] for the user.'
+ ,''.$entries{$fields{'username'}}.' '
+ ,$entries{$fields{'role'}})
+ .' '
+ .&mt('Allowable role(s) is/are: [_1].',$rolestr)."\n"
+ );
next;
}
}
@@ -3778,7 +4084,7 @@ sub upfile_drop_add {
}
}
my @newinfo = (\$fname,\$mname,\$lname,\$gen,\$email,\$id);
- for (my $i=0; $i<@userinfo; $i++) {
+ for (my $i=0; $i<@newinfo; $i++) {
if (${$newinfo[$i]} ne '') {
if (!$canmodify{$userinfo[$i]}) {
${$newinfo[$i]} = '';
@@ -3827,7 +4133,7 @@ sub upfile_drop_add {
$fname,$mname,$lname,$gen,$sec,$enddate,
$startdate,$env{'form.forceid'},
$desiredhost,$email,'manual','',$cid,
- '',$context);
+ '',$context,$inststatus);
$userresult = $roleresult;
} else {
if ($role ne '') {
@@ -3847,7 +4153,7 @@ sub upfile_drop_add {
$mname,$lname,$gen,$sec,
$env{'form.forceid'},$desiredhost,
$email,$role,$enddate,
- $startdate,$checkid);
+ $startdate,$checkid,$inststatus);
}
} elsif (@secs > 0) {
$singlesec = $secs[0];
@@ -3862,7 +4168,8 @@ sub upfile_drop_add {
$id,$amode,$password,$fname,
$mname,$lname,$gen,$singlesec,
$env{'form.forceid'},$desiredhost,
- $email,$role,$enddate,$startdate,$checkid);
+ $email,$role,$enddate,$startdate,
+ $checkid,$inststatus);
}
}
if ($multiple) {
@@ -3882,15 +4189,15 @@ sub upfile_drop_add {
} else {
if ($context eq 'course') {
$r->print(' '.
- &mt('[_1] : Unable to enroll. No password specified.',$username)
+ &mt('[_1]: Unable to enroll. No password specified.',''.$username.' ')
);
} elsif ($context eq 'author') {
$r->print(' '.
- &mt('[_1] : Unable to add co-author. No password specified.',$username)
+ &mt('[_1]: Unable to add co-author. No password specified.',''.$username.' ')
);
} else {
$r->print(' '.
- &mt('[_1] : Unable to add user. No password specified.',$username)
+ &mt('[_1]: Unable to add user. No password specified.',''.$username.' ')
);
}
}
@@ -3993,7 +4300,7 @@ sub user_change_result {
if ($userresult =~ /^error:(.+)$/) {
my $error = $1;
$r->print(' '.
- &mt('[_1] : Unable to add/modify: [_2]',$username.':'.$userdomain,$error));
+ &mt('[_1]: Unable to add/modify: [_2]',''.$username.':'.$userdomain.' ',$error));
}
} else {
$counts->{'user'} ++;
@@ -4003,7 +4310,7 @@ sub user_change_result {
if ($authresult =~ /^error:(.+)$/) {
my $error = $1;
$r->print(' '.
- &mt('[_1] : Unable to modify authentication: [_2]',$username.':'.$userdomain,$error));
+ &mt('[_1]: Unable to modify authentication: [_2]',''.$username.':'.$userdomain.' ',$error));
}
} else {
$counts->{'auth'} ++;
@@ -4013,7 +4320,7 @@ sub user_change_result {
if ($roleresult =~ /^error:(.+)$/) {
my $error = $1;
$r->print(' '.
- &mt('[_1] : Unable to add role: [_2]',$username.':'.$userdomain,$error));
+ &mt('[_1]: Unable to add role: [_2]',''.$username.':'.$userdomain.' ',$error));
}
} else {
$counts->{'role'} ++;
@@ -4036,14 +4343,24 @@ sub user_change_result {
# ========================================================= Menu Phase Two Drop
sub print_drop_menu {
- my ($r,$context,$permission) = @_;
- $r->print('
'.&mt("Drop Students").' '."\n".
+ my ($r,$context,$permission,$crstype) = @_;
+ my $heading;
+ if ($crstype eq 'Community') {
+ $heading = &mt("Drop Members");
+ } else {
+ $heading = &mt("Drop Students");
+ }
+ $r->print(''.$heading.' '."\n".
''. &Apache::loncommon::end_page());
return;
@@ -4055,6 +4372,10 @@ sub update_user_list {
my ($r,$context,$setting,$choice) = @_;
my $now = time;
my $count=0;
+ my $crstype;
+ if ($context eq 'course') {
+ $crstype = &Apache::loncommon::course_type();
+ }
my @changelist;
if ($choice eq 'drop') {
@changelist = &Apache::loncommon::get_env_multiple('form.droplist');
@@ -4125,7 +4446,7 @@ sub update_user_list {
}
}
}
- my $plrole = &Apache::lonnet::plaintext($role);
+ my $plrole = &Apache::lonnet::plaintext($role,$crstype);
my $start = $env{'form.'.$item.'_start'};
my $end = $env{'form.'.$item.'_end'};
if ($choice eq 'drop') {
@@ -4283,14 +4604,14 @@ sub update_user_list {
$r->print(''.&mt("$result_text{'ok'}{$choice} role(s) for [quant,_1,user,users,no users].",$count).'
');
if ($count > 0) {
if ($choice eq 'revoke' || $choice eq 'drop') {
- $r->print(''.&mt('Re-enabling will re-activate data for the role.
'));
+ $r->print(''.&mt('Re-enabling will re-activate data for the role.').'
');
}
# Flush the course logs so reverse user roles immediately updated
&Apache::lonnet::flushcourselogs();
}
if ($env{'form.makedatesdefault'}) {
if ($choice eq 'chgdates' || $choice eq 'reenable' || $choice eq 'activate') {
- $r->print(&make_dates_default($startdate,$enddate,$context));
+ $r->print(&make_dates_default($startdate,$enddate,$context,$crstype));
}
}
my $linktext = &mt('Display User Lists');
@@ -4377,7 +4698,7 @@ sub course_sections {
my $output = '';
my @sections = (sort {$a <=> $b} keys %{$sections_count});
my $numsec = scalar(@sections);
- my $is_selected = ' selected="selected" ';
+ my $is_selected = ' selected="selected"';
if ($numsec <= 1) {
$output = ''."\n".
' '.&mt('Select').' '."\n";
@@ -4576,7 +4897,7 @@ sub can_create_user {
}
if (ref($domconf{'usercreation'}) eq 'HASH') {
if (ref($domconf{'usercreation'}{'cancreate'}) eq 'HASH') {
- if ($context eq 'course' || $context eq 'author') {
+ if ($context eq 'course' || $context eq 'author' || $context eq 'requestcrs') {
my $creation = $domconf{'usercreation'}{'cancreate'}{$context};
if ($creation eq 'none') {
$cancreate = 0;
@@ -4674,27 +4995,36 @@ sub check_usertype {
}
sub roles_by_context {
- my ($context,$custom) = @_;
+ my ($context,$custom,$crstype) = @_;
my @allroles;
if ($context eq 'course') {
- @allroles = ('st','ad','ta','ep','in','cc');
+ @allroles = ('st');
+ if ($env{'request.role'} =~ m{^dc\./}) {
+ push(@allroles,'ad');
+ }
+ push(@allroles,('ta','ep','in'));
+ if ($crstype eq 'Community') {
+ push(@allroles,'co');
+ } else {
+ push(@allroles,'cc');
+ }
if ($custom) {
push(@allroles,'cr');
}
} elsif ($context eq 'author') {
@allroles = ('ca','aa');
} elsif ($context eq 'domain') {
- @allroles = ('li','dg','sc','au','dc');
+ @allroles = ('li','ad','dg','sc','au','dc');
}
return @allroles;
}
sub get_permission {
- my ($context,$roles) = @_;
+ my ($context,$crstype) = @_;
my %permission;
if ($context eq 'course') {
my $custom = 1;
- my @allroles = &roles_by_context($context,$custom);
+ my @allroles = &roles_by_context($context,$custom,$crstype);
foreach my $role (@allroles) {
if (&Apache::lonnet::allowed('c'.$role,$env{'request.course.id'})) {
$permission{'cusr'} = 1;
@@ -4763,9 +5093,9 @@ sub authorpriv {
}
sub roles_on_upload {
- my ($context,$setting,%customroles) = @_;
+ my ($context,$setting,$crstype,%customroles) = @_;
my (@possible_roles,@permitted_roles);
- @possible_roles = &curr_role_permissions($context,$setting,1);
+ @possible_roles = &curr_role_permissions($context,$setting,1,$crstype);
foreach my $role (@possible_roles) {
if ($role eq 'cr') {
push(@permitted_roles,keys(%customroles));