';
- foreach my $level ('course','domain','system') {
- if ($customroles{$key}{$level}) {
- my $suffix;
- if (($level eq 'domain') || ($level eq 'system')) {
- $suffix = ' ('.&mt($level).')';
- }
- my @privs = split(/:/,$customroles{$key}{$level});
- foreach my $item (@privs) {
- next if ($item eq '');
- my ($priv,$cond) = split(/\&/,$item);
- $output .= &Apache::lonnet::plaintext($priv,'Course').$suffix.' ';
- }
- }
- }
- $output .= '
'.
- &Apache::loncommon::end_data_table_row();
- }
- $output .= &Apache::loncommon::end_data_table();
- }
- return $output;
-}
-
sub courserequest_titles {
my %titles = &Apache::lonlocal::texthash (
official => 'Official',
unofficial => 'Unofficial',
community => 'Communities',
textbook => 'Textbook',
+ placement => 'Placement Tests',
+ lti => 'LTI Provider',
norequest => 'Not allowed',
approval => 'Approval by Dom. Coord.',
validate => 'With validation',
@@ -703,7 +655,8 @@ sub curr_requestauthor {
# =================================================================== Phase one
sub print_username_entry_form {
- my ($r,$context,$response,$srch,$forcenewuser,$crstype,$brcrum) = @_;
+ my ($r,$context,$response,$srch,$forcenewuser,$crstype,$brcrum,
+ $permission) = @_;
my $defdom=$env{'request.role.domain'};
my $formtoset = 'crtuser';
if (exists($env{'form.startrolename'})) {
@@ -729,13 +682,27 @@ sub print_username_entry_form {
}
my $helpitem = 'Course_Change_Privileges';
if ($env{'form.action'} eq 'custom') {
- $helpitem = 'Course_Editing_Custom_Roles';
+ if ($context eq 'course') {
+ $helpitem = 'Course_Editing_Custom_Roles';
+ } elsif ($context eq 'domain') {
+ $helpitem = 'Domain_Editing_Custom_Roles';
+ }
} elsif ($env{'form.action'} eq 'singlestudent') {
$helpitem = 'Course_Add_Student';
} elsif ($env{'form.action'} eq 'accesslogs') {
$helpitem = 'Domain_User_Access_Logs';
+ } elsif ($context eq 'author') {
+ $helpitem = 'Author_Change_Privileges';
+ } elsif ($context eq 'domain') {
+ if ($permission->{'cusr'}) {
+ $helpitem = 'Domain_Change_Privileges';
+ } elsif ($permission->{'view'}) {
+ $helpitem = 'Domain_View_Privileges';
+ } else {
+ undef($helpitem);
+ }
}
- my %breadcrumb_text = &singleuser_breadcrumb($crstype);
+ my %breadcrumb_text = &singleuser_breadcrumb($crstype,$context,$defdom);
if ($env{'form.action'} eq 'custom') {
push(@{$brcrum},
{href=>"javascript:backPage(document.crtuser)",
@@ -763,6 +730,7 @@ sub print_username_entry_form {
'srst' => 'Search for a user and enroll as a student',
'srme' => 'Search for a user and enroll as a member',
'srad' => 'Search for a user and modify/add user information or roles',
+ 'srvu' => 'Search for a user and view user information and roles',
'srva' => 'Search for a user and view access log information',
'usr' => "Username",
'dom' => "Domain",
@@ -810,6 +778,7 @@ sub print_username_entry_form {
}
} else {
my $actiontext = $lt{'srad'};
+ my $fixeddom;
if ($env{'form.action'} eq 'singlestudent') {
if ($crstype eq 'Community') {
$actiontext = $lt{'srme'};
@@ -818,6 +787,11 @@ sub print_username_entry_form {
}
} elsif ($env{'form.action'} eq 'accesslogs') {
$actiontext = $lt{'srva'};
+ $fixeddom = 1;
+ } elsif (($env{'form.action'} eq 'singleuser') &&
+ ($context eq 'domain') && (!&Apache::lonnet::allowed('mau',$defdom))) {
+ $actiontext = $lt{'srvu'};
+ $fixeddom = 1;
}
$r->print("
$actiontext
");
if ($env{'form.origform'} ne 'crtusername') {
@@ -826,7 +800,7 @@ sub print_username_entry_form {
' ');
}
}
- $r->print(&entry_form($defdom,$srch,$forcenewuser,$context,$response,$crstype,1));
+ $r->print(&entry_form($defdom,$srch,$forcenewuser,$context,$response,$crstype,$fixeddom));
}
}
@@ -885,11 +859,16 @@ sub entry_form {
$inexact = 1;
}
}
- my $cancreate =
- &Apache::lonuserutils::can_create_user($dom,$context,$usertype);
+ my ($cancreate,$noinstd);
+ if ($env{'form.action'} eq 'accesslogs') {
+ $noinstd = 1;
+ } else {
+ $cancreate =
+ &Apache::lonuserutils::can_create_user($dom,$context,$usertype);
+ }
my ($userpicker,$cansearch) =
&Apache::loncommon::user_picker($dom,$srch,$forcenewuser,
- 'document.crtuser',$cancreate,$usertype,$context,$fixeddom);
+ 'document.crtuser',$cancreate,$usertype,$context,$fixeddom,$noinstd);
my $srchbutton = &mt('Search');
if ($env{'form.action'} eq 'singlestudent') {
$srchbutton = &mt('Search and Enroll');
@@ -911,9 +890,19 @@ ENDBLOCK
} else {
$output = '
'.$userpicker.'
';
}
- if (($env{'form.phase'} eq '') && ($env{'form.action'} ne 'accesslogs')) {
+ if (($env{'form.phase'} eq '') && ($env{'form.action'} ne 'accesslogs') &&
+ (!(($env{'form.action'} eq 'singleuser') && ($context eq 'domain') &&
+ (!&Apache::lonnet::allowed('mau',$env{'request.role.domain'}))))) {
my $defdom=$env{'request.role.domain'};
- my $domform = &Apache::loncommon::select_dom_form($defdom,'srchdomain');
+ my ($trusted,$untrusted);
+ if ($context eq 'course') {
+ ($trusted,$untrusted) = &Apache::lonnet::trusted_domains('enroll',$defdom);
+ } elsif ($context eq 'author') {
+ ($trusted,$untrusted) = &Apache::lonnet::trusted_domains('othcoau',$defdom);
+ } elsif ($context eq 'domain') {
+ ($trusted,$untrusted) = &Apache::lonnet::trusted_domains('domroles',$defdom);
+ }
+ my $domform = &Apache::loncommon::select_dom_form($defdom,'srchdomain',undef,undef,undef,$trusted,$untrusted);
my %lt=&Apache::lonlocal::texthash(
'enro' => 'Enroll one student',
'enrm' => 'Enroll one member',
@@ -1028,7 +1017,9 @@ ENDSCRIPT
'stusrch' => "User Search to enroll student",
'memsrch' => "User Search to enroll member",
'srcva' => "Search for a user and view access log information",
+ 'usrvu' => "User Search to view user roles",
'usel' => "Select a user to add/modify roles",
+ 'suvr' => "Select a user to view roles",
'stusel' => "Select a user to enroll as a student",
'memsel' => "Select a user to enroll as a member",
'vacsel' => "Select a user to view access log",
@@ -1041,12 +1032,16 @@ ENDSCRIPT
if ($context eq 'requestcrs') {
$r->print('
'
.&mt("You are not authorized to create new $usertypetext{$usertype} users in this domain.")
- .' '
- .&mt('Please contact the [_1]helpdesk[_2] for assistance.'
- ,'','')
- .'
';
+ .' ';
+ if ($context eq 'domain') {
+ $response .= &mt('Please contact a [_1] for assistance.',
+ &Apache::lonnet::plaintext('dc'));
+ } else {
+ $response .= &mt('Please contact the [_1]helpdesk[_2] for assistance.'
+ ,'','');
+ }
+ $response .= ' ';
$env{'form.phase'} = '';
- &print_username_entry_form($r,$context,$response,undef,undef,$crstype,$brcrum);
+ &print_username_entry_form($r,$context,$response,undef,undef,$crstype,$brcrum,
+ $permission);
return;
}
$newuser = 1;
@@ -1231,7 +1243,8 @@ sub print_user_modification_page {
'username');
}
$env{'form.phase'} = '';
- &print_username_entry_form($r,$context,$userchkmsg,undef,undef,$crstype,$brcrum);
+ &print_username_entry_form($r,$context,$userchkmsg,undef,undef,$crstype,$brcrum,
+ $permission);
return;
}
}
@@ -1252,10 +1265,14 @@ sub print_user_modification_page {
my $js = &validation_javascript($context,$ccdomain,$pjump_def,$crstype,
$groupslist,$newuser,$formname,\%loaditem);
- my %breadcrumb_text = &singleuser_breadcrumb($crstype);
+ my %breadcrumb_text = &singleuser_breadcrumb($crstype,$context,$ccdomain);
my $helpitem = 'Course_Change_Privileges';
if ($env{'form.action'} eq 'singlestudent') {
$helpitem = 'Course_Add_Student';
+ } elsif ($context eq 'author') {
+ $helpitem = 'Author_Change_Privileges';
+ } elsif ($context eq 'domain') {
+ $helpitem = 'Domain_Change_Privileges';
}
push (@{$brcrum},
{href => "javascript:backPage($form)",
@@ -1318,7 +1335,7 @@ ENDFORMINFO
}
my $title = '';
if ($newuser) {
- my ($portfolioform,$domroleform,$adhocroleform);
+ my ($portfolioform,$domroleform);
if ((&Apache::lonnet::allowed('mpq',$env{'request.role.domain'})) ||
(&Apache::lonnet::allowed('mut',$env{'request.role.domain'}))) {
# Current user has quota or user tools modification privileges
@@ -1328,12 +1345,6 @@ ENDFORMINFO
($ccdomain eq $env{'request.role.domain'})) {
$domroleform = ' '.&domainrole_req($ccuname,$ccdomain);
}
- if (&Apache::lonnet::allowed('cdh',$env{'request.role.domain'})) {
- $adhocroleform = &domadhocroles($ccuname,$ccdomain);
- if ($adhocroleform) {
- $adhocroleform = ' '.$adhocroleform;
- }
- }
&initialize_authen_forms($ccdomain,$formname);
my %lt=&Apache::lonlocal::texthash(
'lg' => 'Login Data',
@@ -1444,7 +1455,7 @@ ENDAUTH
} else {
$r->print(&Apache::lonuserutils::set_login($ccdomain,$authformkrb,$authformint,$authformloc));
}
- $r->print($portfolioform.$domroleform.$adhocroleform);
+ $r->print($portfolioform.$domroleform);
if ($env{'form.action'} eq 'singlestudent') {
$r->print(&date_sections_select($context,$newuser,$formname,
$permission,$crstype,$ccuname,
@@ -1462,40 +1473,51 @@ ENDAUTH
'"'.$ccuname.'"','"'.$ccdomain.'"');
}
} else {
- $title = &mt('Modify existing user: [_1] in domain [_2]',
+ if ($permission->{'cusr'}) {
+ $title = &mt('Modify existing user: [_1] in domain [_2]',
'"'.$ccuname.'"','"'.$ccdomain.'"');
+ } else {
+ $title = &mt('Existing user: [_1] in domain [_2]',
+ '"'.$ccuname.'"','"'.$ccdomain.'"');
+ }
}
$r->print('
'.$title.'
'."\n");
$r->print('
');
$r->print(&personal_data_display($ccuname,$ccdomain,$newuser,$context,
$inst_results{$ccuname.':'.$ccdomain}));
- if (&Apache::lonnet::allowed('ccc',$env{'request.role.domain'})) {
- $r->print('
'.&mt('User Can Request Creation of Courses/Communities in this Domain?').'
'.
- &Apache::loncommon::start_data_table());
- if ($env{'request.role.domain'} eq $ccdomain) {
- $r->print(&build_tools_display($ccuname,$ccdomain,'requestcourses'));
+ if ((&Apache::lonnet::allowed('ccc',$env{'request.role.domain'})) ||
+ (&Apache::lonnet::allowed('udp',$env{'request.role.domain'}))) {
+ $r->print('
'.&mt('User Can Request Creation of Courses/Communities in this Domain?').'
'."\n");
+ if (($env{'request.role.domain'} eq $ccdomain) ||
+ (&Apache::lonnet::will_trust('reqcrs',$ccdomain,$env{'request.role.domain'}))) {
+ $r->print(&Apache::loncommon::start_data_table());
+ if ($env{'request.role.domain'} eq $ccdomain) {
+ $r->print(&build_tools_display($ccuname,$ccdomain,'requestcourses'));
+ } else {
+ $r->print(&coursereq_externaluser($ccuname,$ccdomain,
+ $env{'request.role.domain'}));
+ }
+ $r->print(&Apache::loncommon::end_data_table());
} else {
- $r->print(&coursereq_externaluser($ccuname,$ccdomain,
- $env{'request.role.domain'}));
+ $r->print(&mt('Domain configuration for this domain prohibits course creation by users from domain: "[_1]"',
+ &Apache::lonnet::domain($ccdomain,'description')));
}
- $r->print(&Apache::loncommon::end_data_table());
}
$r->print('
');
- my @order = ('auth','quota','tools','requestauthor','adhocroles');
+ my @order = ('auth','quota','tools','requestauthor');
my %user_text;
my ($isadv,$isauthor) =
- &Apache::lonnet::is_advanced_user($ccuname,$ccdomain);
+ &Apache::lonnet::is_advanced_user($ccdomain,$ccuname);
if ((!$isauthor) &&
- (&Apache::lonnet::allowed('cau',$env{'request.role.domain'}))
- && ($env{'request.role.domain'} eq $ccdomain)) {
+ ((&Apache::lonnet::allowed('cau',$env{'request.role.domain'})) ||
+ (&Apache::lonnet::allowed('udp',$env{'request.role.domain'}))) &&
+ ($env{'request.role.domain'} eq $ccdomain)) {
$user_text{'requestauthor'} = &domainrole_req($ccuname,$ccdomain);
}
- if (&Apache::lonnet::allowed('cdh',$env{'request.role.domain'})) {
- $user_text{'adhocroles'} = &domadhocroles($ccuname,$ccdomain);
- }
- $user_text{'auth'} = &user_authentication($ccuname,$ccdomain,$formname);
+ $user_text{'auth'} = &user_authentication($ccuname,$ccdomain,$formname,$crstype,$permission);
if ((&Apache::lonnet::allowed('mpq',$ccdomain)) ||
- (&Apache::lonnet::allowed('mut',$ccdomain))) {
+ (&Apache::lonnet::allowed('mut',$ccdomain)) ||
+ (&Apache::lonnet::allowed('udp',$ccdomain))) {
# Current user has quota modification privileges
$user_text{'quota'} = &user_quotas($ccuname,$ccdomain);
}
@@ -1553,9 +1575,18 @@ ENDNOTOOLSPRIV
if ($gotdiv) {
$r->print('
');
}
+ my $statuses;
+ if (($context eq 'domain') && (&Apache::lonnet::allowed('udp',$ccdomain)) &&
+ (!&Apache::lonnet::allowed('mau',$ccdomain))) {
+ $statuses = ['active'];
+ } elsif (($context eq 'course') && ((&Apache::lonnet::allowed('vcl',$env{'request.course.id'})) ||
+ ($env{'request.course.sec'} &&
+ &Apache::lonnet::allowed('vcl',$env{'request.course.id'}.'/'.$env{'request.course.sec'})))) {
+ $statuses = ['active'];
+ }
if ($env{'form.action'} ne 'singlestudent') {
&display_existing_roles($r,$ccuname,$ccdomain,\%inccourses,$context,
- $roledom,$crstype);
+ $roledom,$crstype,$showcredits,$statuses);
}
} ## End of new user/old user logic
if ($env{'form.action'} eq 'singlestudent') {
@@ -1566,7 +1597,7 @@ ENDNOTOOLSPRIV
$btntxt = &mt('Enroll Student');
}
$r->print(' '."\n");
- } else {
+ } elsif ($permission->{'cusr'}) {
$r->print('
'.
'
'.
@@ -1609,7 +1640,7 @@ ENDNOTOOLSPRIV
}
sub singleuser_breadcrumb {
- my ($crstype) = @_;
+ my ($crstype,$context,$domain) = @_;
my %breadcrumb_text;
if ($env{'form.action'} eq 'singlestudent') {
if ($crstype eq 'Community') {
@@ -1617,16 +1648,21 @@ sub singleuser_breadcrumb {
} else {
$breadcrumb_text{'search'} = 'Enroll a student';
}
- $breadcrumb_text{'userpicked'} = 'Select a user',
- $breadcrumb_text{'modify'} = 'Set section/dates',
+ $breadcrumb_text{'userpicked'} = 'Select a user';
+ $breadcrumb_text{'modify'} = 'Set section/dates';
} elsif ($env{'form.action'} eq 'accesslogs') {
$breadcrumb_text{'search'} = 'View access logs for a user';
- $breadcrumb_text{'userpicked'} = 'Select a user',
- $breadcrumb_text{'activity'} = 'Activity',
+ $breadcrumb_text{'userpicked'} = 'Select a user';
+ $breadcrumb_text{'activity'} = 'Activity';
+ } elsif (($env{'form.action'} eq 'singleuser') && ($context eq 'domain') &&
+ (!&Apache::lonnet::allowed('mau',$domain))) {
+ $breadcrumb_text{'search'} = "View user's roles";
+ $breadcrumb_text{'userpicked'} = 'Select a user';
+ $breadcrumb_text{'modify'} = 'User roles';
} else {
$breadcrumb_text{'search'} = 'Create/modify a user';
- $breadcrumb_text{'userpicked'} = 'Select a user',
- $breadcrumb_text{'modify'} = 'Set user role',
+ $breadcrumb_text{'userpicked'} = 'Select a user';
+ $breadcrumb_text{'modify'} = 'Set user role';
}
return %breadcrumb_text;
}
@@ -1696,8 +1732,22 @@ sub validation_javascript {
sub display_existing_roles {
my ($r,$ccuname,$ccdomain,$inccourses,$context,$roledom,$crstype,
- $showcredits) = @_;
+ $showcredits,$statuses) = @_;
my $now=time;
+ my $showall = 1;
+ my ($showexpired,$showactive);
+ if ((ref($statuses) eq 'ARRAY') && (@{$statuses} > 0)) {
+ $showall = 0;
+ if (grep(/^expired$/,@{$statuses})) {
+ $showexpired = 1;
+ }
+ if (grep(/^active$/,@{$statuses})) {
+ $showactive = 1;
+ }
+ if ($showexpired && $showactive) {
+ $showall = 1;
+ }
+ }
my %lt=&Apache::lonlocal::texthash(
'rer' => "Existing Roles",
'rev' => "Revoke",
@@ -1761,6 +1811,13 @@ sub display_existing_roles {
$area =~ s/\_\w\w$//;
my ($role_code,$role_end_time,$role_start_time) =
split(/_/,$role);
+ my $active=1;
+ $active=0 if (($role_end_time) && ($now>$role_end_time));
+ if ($active) {
+ next unless($showall || $showactive);
+ } else {
+ next unless($showall || $showexpired);
+ }
# Is this a custom role? Get role owner and title.
my ($croleudom,$croleuname,$croletitle)=
($role_code=~m{^cr/($match_domain)/($match_username)/(\w+)$});
@@ -1769,11 +1826,13 @@ sub display_existing_roles {
my $sortkey=$role_code;
my $class='Unknown';
my $credits='';
- if ($area =~ m{^/($match_domain)/($match_courseid)} ) {
+ my $csec;
+ if ($area =~ m{^/($match_domain)/($match_courseid)}) {
$class='Course';
my ($coursedom,$coursedir) = ($1,$2);
my $cid = $1.'_'.$2;
# $1.'_'.$2 is the course id (eg. 103_12345abcef103l3).
+ next if ($envkey =~ m{^/$match_domain/$match_courseid/[A-Za-z0-9]+_gr$});
my %coursedata=
&Apache::lonnet::coursedescription($cid);
if ($coursedir =~ /^$match_community$/) {
@@ -1831,12 +1890,13 @@ sub display_existing_roles {
$thisrole.='.'.$role_code;
}
}
- if ($area=~m{^/($match_domain)/($match_courseid)/(\w+)}) {
- $carea.=' '.&mt('Section: [_1]',$3);
- $sortkey.="\0$3";
+ if ($area=~m{^/($match_domain/$match_courseid/(\w+))}) {
+ $csec = $2;
+ $carea.=' '.&mt('Section: [_1]',$csec);
+ $sortkey.="\0$csec";
if (!$allowed) {
- if ($env{'request.course.sec'} eq $3) {
- if (&Apache::lonnet::allowed('c'.$role_code,$1.'/'.$2.'/'.$3)) {
+ if ($env{'request.course.sec'} eq $csec) {
+ if (&Apache::lonnet::allowed('c'.$role_code,$1)) {
$allowed = 1;
}
}
@@ -1878,29 +1938,30 @@ sub display_existing_roles {
}
}
my $row = '';
- $row.= '
';
- my $active=1;
- $active=0 if (($role_end_time) && ($now>$role_end_time));
- if (($active) && ($allowed)) {
- $row.= '';
- } else {
- if ($active) {
- $row.=' ';
+ if ($showall) {
+ $row.= '
';
+ if (($active) && ($allowed)) {
+ $row.= '';
} else {
- $row.=&mt('expired or revoked');
+ if ($active) {
+ $row.=' ';
+ } else {
+ $row.=&mt('expired or revoked');
+ }
}
- }
- $row.='