--- loncom/interface/loncreateuser.pm 2013/12/17 06:41:44 1.383
+++ loncom/interface/loncreateuser.pm 2016/11/11 14:39:23 1.420
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Create a user
#
-# $Id: loncreateuser.pm,v 1.383 2013/12/17 06:41:44 raeburn Exp $
+# $Id: loncreateuser.pm,v 1.420 2016/11/11 14:39:23 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -126,9 +126,7 @@ sub user_quotas {
my ($ccuname,$ccdomain) = @_;
my %lt = &Apache::lonlocal::texthash(
'usrt' => "User Tools",
- 'cuqu' => "Current quota",
'cust' => "Custom quota",
- 'defa' => "Default",
'chqu' => "Change quota",
);
@@ -162,13 +160,14 @@ END_SCRIPT
'
'.$lt{'usrt'}.'
'."\n".
&Apache::loncommon::start_data_table();
- if (&Apache::lonnet::allowed('mut',$ccdomain)) {
+ if ((&Apache::lonnet::allowed('mut',$ccdomain)) ||
+ (&Apache::lonnet::allowed('udp',$ccdomain))) {
$output .= &build_tools_display($ccuname,$ccdomain,'tools');
}
my %titles = &Apache::lonlocal::texthash (
portfolio => "Disk space allocated to user's portfolio files",
- author => "Disk space allocated to user's authoring space (if role assigned)",
+ author => "Disk space allocated to user's Authoring Space (if role assigned)",
);
foreach my $name ('portfolio','author') {
my ($currquota,$quotatype,$inststatus,$defquota) =
@@ -211,8 +210,8 @@ END_SCRIPT
'
'.
+ &Apache::loncommon::end_data_table_header_row();
+ foreach my $key (sort(keys(%customroles))) {
+ next if ((!$canmodify) && (!grep(/^\Q$key\E$/,@current)));
+ $output .= &Apache::loncommon::start_data_table_row();
+ if ($canmodify) {
+ if (grep(/^\Q$key\E$/,@current)) {
+ $output .= '
'.
+ ''.
+ &mt('Delete').''.
+ '
';
+ } else {
+ $output .= '
'.
+ ''.
+ &mt('Add').''.
+ '
';
+ }
+ }
+ $output .= '
'.$key.'
';
+ 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',
norequest => 'Not allowed',
approval => 'Approval by Dom. Coord.',
validate => 'With validation',
@@ -664,6 +754,8 @@ sub print_username_entry_form {
$helpitem = 'Course_Editing_Custom_Roles';
} elsif ($env{'form.action'} eq 'singlestudent') {
$helpitem = 'Course_Add_Student';
+ } elsif ($env{'form.action'} eq 'accesslogs') {
+ $helpitem = 'Domain_User_Access_Logs';
}
my %breadcrumb_text = &singleuser_breadcrumb($crstype);
if ($env{'form.action'} eq 'custom') {
@@ -693,6 +785,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',
+ 'srva' => 'Search for a user and view access log information',
'usr' => "Username",
'dom' => "Domain",
'ecrp' => "Define or Edit Custom Role",
@@ -745,12 +838,17 @@ sub print_username_entry_form {
} else {
$actiontext = $lt{'srst'};
}
+ } elsif ($env{'form.action'} eq 'accesslogs') {
+ $actiontext = $lt{'srva'};
}
$r->print("
$actiontext
");
if ($env{'form.origform'} ne 'crtusername') {
- $r->print("\n".$response);
+ if ($response) {
+ $r->print("\n
$response
".
+ ' ');
+ }
}
- $r->print(&entry_form($defdom,$srch,$forcenewuser,$context,$response,$crstype));
+ $r->print(&entry_form($defdom,$srch,$forcenewuser,$context,$response,$crstype,1));
}
}
@@ -793,7 +891,7 @@ END
}
sub entry_form {
- my ($dom,$srch,$forcenewuser,$context,$responsemsg,$crstype) = @_;
+ my ($dom,$srch,$forcenewuser,$context,$responsemsg,$crstype,$fixeddom) = @_;
my ($usertype,$inexact);
if (ref($srch) eq 'HASH') {
if (($srch->{'srchin'} eq 'dom') &&
@@ -811,16 +909,20 @@ sub entry_form {
}
my $cancreate =
&Apache::lonuserutils::can_create_user($dom,$context,$usertype);
- my $userpicker =
+ my ($userpicker,$cansearch) =
&Apache::loncommon::user_picker($dom,$srch,$forcenewuser,
- 'document.crtuser',$cancreate,$usertype);
+ 'document.crtuser',$cancreate,$usertype,$context,$fixeddom);
my $srchbutton = &mt('Search');
if ($env{'form.action'} eq 'singlestudent') {
$srchbutton = &mt('Search and Enroll');
+ } elsif ($env{'form.action'} eq 'accesslogs') {
+ $srchbutton = &mt('Search');
} elsif ($cancreate && $responsemsg ne '' && $inexact) {
$srchbutton = &mt('Search or Add New User');
}
- my $output = <<"ENDBLOCK";
+ my $output;
+ if ($cansearch) {
+ $output = <<"ENDBLOCK";
ENDBLOCK
- if ($env{'form.phase'} eq '') {
+ } else {
+ $output = '
'.$userpicker.'
';
+ }
+ if (($env{'form.phase'} eq '') && ($env{'form.action'} ne 'accesslogs')) {
my $defdom=$env{'request.role.domain'};
my $domform = &Apache::loncommon::select_dom_form($defdom,'srchdomain');
my %lt=&Apache::lonlocal::texthash(
@@ -944,9 +1049,11 @@ ENDSCRIPT
'usrch' => "User Search to add/modify roles",
'stusrch' => "User Search to enroll student",
'memsrch' => "User Search to enroll member",
+ 'srcva' => "Search for a user and view access log information",
'usel' => "Select a user to add/modify 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",
'username' => "username",
'domain' => "domain",
'lastname' => "last name",
@@ -995,6 +1102,10 @@ ENDSCRIPT
$r->print($lt{'stusel'});
}
$r->print('');
+ } elsif ($env{'form.action'} eq 'accesslogs') {
+ $r->print("$lt{'srcva'} ");
+ $r->print(&entry_form($srch->{'srchdomain'},$srch,undef,'accesslogs',undef,undef,1));
+ $r->print('
'.$lt{'vacsel'}.'
');
}
}
$r->print('');
+ $r->print('
');
return;
}
@@ -1526,6 +1664,10 @@ sub singleuser_breadcrumb {
}
$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',
} else {
$breadcrumb_text{'search'} = 'Create/modify a user';
$breadcrumb_text{'userpicked'} = 'Select a user',
@@ -1599,8 +1741,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",
@@ -1664,6 +1820,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+)$});
@@ -1672,6 +1835,7 @@ sub display_existing_roles {
my $sortkey=$role_code;
my $class='Unknown';
my $credits='';
+ my $csec;
if ($area =~ m{^/($match_domain)/($match_courseid)} ) {
$class='Course';
my ($coursedom,$coursedir) = ($1,$2);
@@ -1734,12 +1898,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;
}
}
@@ -1781,29 +1946,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.='