--- loncom/interface/loncreateuser.pm 2012/12/28 04:12:32 1.370
+++ loncom/interface/loncreateuser.pm 2016/11/11 02:09:55 1.419
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Create a user
#
-# $Id: loncreateuser.pm,v 1.370 2012/12/28 04:12:32 raeburn Exp $
+# $Id: loncreateuser.pm,v 1.419 2016/11/11 02:09:55 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -122,96 +122,114 @@ sub auth_abbrev {
# ====================================================
-sub portfolio_quota {
+sub user_quotas {
my ($ccuname,$ccdomain) = @_;
my %lt = &Apache::lonlocal::texthash(
'usrt' => "User Tools",
- 'disk' => "Disk space allocated to user's portfolio files",
- 'cuqu' => "Current quota",
'cust' => "Custom quota",
- 'defa' => "Default",
'chqu' => "Change quota",
);
- my ($currquota,$quotatype,$inststatus,$defquota) =
- &Apache::loncommon::get_user_quota($ccuname,$ccdomain);
- my ($usertypes,$order) = &Apache::lonnet::retrieve_inst_usertypes($ccdomain);
- my ($longinsttype,$showquota,$custom_on,$custom_off,$defaultinfo);
- if ($inststatus ne '') {
- if ($usertypes->{$inststatus} ne '') {
- $longinsttype = $usertypes->{$inststatus};
- }
- }
- $custom_on = ' ';
- $custom_off = ' checked="checked" ';
+
my $quota_javascript = <<"END_SCRIPT";
END_SCRIPT
- if ($quotatype eq 'custom') {
- $custom_on = $custom_off;
- $custom_off = ' ';
- $showquota = $currquota;
- if ($longinsttype eq '') {
- $defaultinfo = &mt('For this user, the default quota would be [_1]'
- .' Mb.',$defquota);
- } else {
- $defaultinfo = &mt("For this user, the default quota would be [_1]".
- " Mb, as determined by the user's institutional".
- " affiliation ([_2]).",$defquota,$longinsttype);
- }
- } else {
- if ($longinsttype eq '') {
- $defaultinfo = &mt('For this user, the default quota is [_1]'
- .' Mb.',$defquota);
- } else {
- $defaultinfo = &mt("For this user, the default quota of [_1]".
- " Mb, is determined by the user's institutional".
- " affiliation ([_2]).",$defquota,$longinsttype);
- }
- }
-
+ my $longinsttype;
+ my ($usertypes,$order) = &Apache::lonnet::retrieve_inst_usertypes($ccdomain);
my $output = $quota_javascript."\n".
'
'.$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');
}
- if (&Apache::lonnet::allowed('mpq',$ccdomain)) {
- $output .= ''."\n".
- ' '.$lt{'disk'}.' '."\n".
- ' '."\n".
- &Apache::loncommon::start_data_table_row()."\n".
- ' '.$lt{'cuqu'}.': '.
- $currquota.' Mb. '.
- $defaultinfo.' '."\n".
- &Apache::loncommon::end_data_table_row()."\n".
- &Apache::loncommon::start_data_table_row()."\n".
- ' '.$lt{'chqu'}.
- ': '.
- ' '.$lt{'defa'}.' ('.$defquota.' Mb). '.
- ' '.
- $lt{'cust'}.': '.
- ' Mb '."\n".
- &Apache::loncommon::end_data_table_row()."\n";
- }
+
+ 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)",
+ );
+ foreach my $name ('portfolio','author') {
+ my ($currquota,$quotatype,$inststatus,$defquota) =
+ &Apache::loncommon::get_user_quota($ccuname,$ccdomain,$name);
+ if ($longinsttype eq '') {
+ if ($inststatus ne '') {
+ if ($usertypes->{$inststatus} ne '') {
+ $longinsttype = $usertypes->{$inststatus};
+ }
+ }
+ }
+ my ($showquota,$custom_on,$custom_off,$defaultinfo);
+ $custom_on = ' ';
+ $custom_off = ' checked="checked" ';
+ if ($quotatype eq 'custom') {
+ $custom_on = $custom_off;
+ $custom_off = ' ';
+ $showquota = $currquota;
+ if ($longinsttype eq '') {
+ $defaultinfo = &mt('For this user, the default quota would be [_1]'
+ .' MB.',$defquota);
+ } else {
+ $defaultinfo = &mt("For this user, the default quota would be [_1]".
+ " MB, as determined by the user's institutional".
+ " affiliation ([_2]).",$defquota,$longinsttype);
+ }
+ } else {
+ if ($longinsttype eq '') {
+ $defaultinfo = &mt('For this user, the default quota is [_1]'
+ .' MB.',$defquota);
+ } else {
+ $defaultinfo = &mt("For this user, the default quota of [_1]".
+ " MB, is determined by the user's institutional".
+ " affiliation ([_2]).",$defquota,$longinsttype);
+ }
+ }
+
+ if (&Apache::lonnet::allowed('mpq',$ccdomain)) {
+ $output .= ''."\n".
+ ' '.$titles{$name}.' '."\n".
+ ' '."\n".
+ &Apache::loncommon::start_data_table_row()."\n".
+ ' '.
+ &mt('Current quota: [_1] MB',$currquota).' '.
+ $defaultinfo.' '."\n".
+ &Apache::loncommon::end_data_table_row()."\n".
+ &Apache::loncommon::start_data_table_row()."\n".
+ ' '.$lt{'chqu'}.
+ ': '.
+ ''.
+ &mt('Default ([_1] MB)',$defquota).' '.
+ ' '.$lt{'cust'}.': '.
+ ' '.&mt('MB').' '."\n".
+ &Apache::loncommon::end_data_table_row()."\n";
+ }
+ }
$output .= &Apache::loncommon::end_data_table();
return $output;
}
@@ -223,7 +241,7 @@ sub build_tools_display {
my %lt = &Apache::lonlocal::texthash (
'blog' => "Personal User Blog",
'aboutme' => "Personal Information Page",
- 'webdav' => "WebDAV access to authoring spaces (if SSL and author/co-author)",
+ 'webdav' => "WebDAV access to Authoring Spaces (if SSL and author/co-author)",
'portfolio' => "Personal User Portfolio",
'avai' => "Available",
'cusa' => "availability",
@@ -233,13 +251,16 @@ sub build_tools_display {
'official' => 'Can request creation of official courses',
'unofficial' => 'Can request creation of unofficial courses',
'community' => 'Can request creation of communities',
+ 'textbook' => 'Can request creation of textbook courses',
+ 'placement' => 'Can request creation of placement tests',
'requestauthor' => 'Can request author space',
);
if ($context eq 'requestcourses') {
%userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname,
'requestcourses.official','requestcourses.unofficial',
- 'requestcourses.community');
- @usertools = ('official','unofficial','community');
+ 'requestcourses.community','requestcourses.textbook',
+ 'requestcourses.placement');
+ @usertools = ('official','unofficial','community','textbook','placement');
@options =('norequest','approval','autolimit','validate');
%validations = &Apache::lonnet::auto_courserequest_checks($ccdomain);
%reqtitles = &courserequest_titles();
@@ -247,7 +268,7 @@ sub build_tools_display {
$colspan = ' colspan="2"';
%domconfig =
&Apache::lonnet::get_dom('configuration',['requestcourses'],$ccdomain);
- $isadv = &Apache::lonnet::is_advanced_user($ccuname,$ccdomain);
+ $isadv = &Apache::lonnet::is_advanced_user($ccdomain,$ccuname);
} elsif ($context eq 'requestauthor') {
%userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname,
'requestauthor');
@@ -314,6 +335,7 @@ sub build_tools_display {
' '.$lt{$item}.' '."\n".
' '."\n".
&Apache::loncommon::start_data_table_row()."\n";
+
if (($context eq 'requestcourses') || ($context eq 'requestauthor')) {
my ($curroption,$currlimit);
my $envkey = $context.'.'.$item;
@@ -408,7 +430,9 @@ sub build_tools_display {
}
$output .= ' '.$custom_access.(' 'x4).
$lt{'avai'}.': '.$currdisp.' '."\n".
- &Apache::loncommon::end_data_table_row()."\n".
+ &Apache::loncommon::end_data_table_row()."\n";
+ unless (&Apache::lonnet::allowed('udp',$ccdomain)) {
+ $output .=
&Apache::loncommon::start_data_table_row()."\n".
' '.
$lt{'chse'}.': '.
@@ -417,6 +441,7 @@ sub build_tools_display {
' '.$lt{'uscu'}.' '.$custradio.' '.
&Apache::loncommon::end_data_table_row()."\n";
+ }
}
return $output;
}
@@ -428,12 +453,15 @@ sub coursereq_externaluser {
'official' => 'Can request creation of official courses',
'unofficial' => 'Can request creation of unofficial courses',
'community' => 'Can request creation of communities',
+ 'textbook' => 'Can request creation of textbook courses',
+ 'placement' => 'Can request creation of placement tests',
);
%userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname,
'reqcrsotherdom.official','reqcrsotherdom.unofficial',
- 'reqcrsotherdom.community');
- @usertools = ('official','unofficial','community');
+ 'reqcrsotherdom.community','reqcrsotherdom.textbook',
+ 'reqcrsotherdom.placement');
+ @usertools = ('official','unofficial','community','textbook','placement');
@options = ('approval','validate','autolimit');
%validations = &Apache::lonnet::auto_courserequest_checks($cdom);
my $optregex = join('|',@options);
@@ -508,11 +536,91 @@ sub domainrole_req {
&Apache::loncommon::end_data_table();
}
+sub domadhocroles {
+ my ($ccuname,$ccdomain) = @_;
+ my $confname = &Apache::lonnet::get_domainconfiguser($env{'request.role.domain'});
+ my %existing=&Apache::lonnet::dump('roles',$env{'request.role.domain'},
+ $confname,'rolesdef_');
+ my ($output,$canmodify);
+ if (&Apache::lonnet::allowed('cdh',$env{'request.role.domain'})) {
+ $canmodify = 1;
+ }
+ if (keys(%existing) > 0) {
+ my @current;
+ my $curradhoc = 'adhocroles.'.$env{'request.role.domain'};
+ my %userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname,$curradhoc);
+ if ($userenv{$curradhoc}) {
+ @current = split(/,/,$userenv{$curradhoc});
+ }
+ if (!$canmodify && !@current) {
+ return;
+ }
+ my %customroles;
+ foreach my $key (keys(%existing)) {
+ if ($key=~/^rolesdef\_(\w+)$/) {
+ my $rolename = $1;
+ my %privs;
+ ($privs{'system'},$privs{'domain'},$privs{'course'}) = split(/\_/,$existing{$key});
+ $customroles{$rolename} = \%privs;
+ }
+ }
+ $output = ''.
+ &mt('Ad Hoc Course Roles Selectable via Helpdesk Role').
+ ' '."\n".
+ &Apache::loncommon::start_data_table().
+ &Apache::loncommon::start_data_table_header_row();
+ if ($canmodify) {
+ $output .= ''.&mt('Action').' ';
+ }
+ $output .= ''.&mt('Role').' '.
+ ''.&mt('Privileges in Course').' '.
+ &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',
@@ -550,6 +658,15 @@ sub requestauthor_display {
return %titles;
}
+sub requestchange_display {
+ my %titles = &Apache::lonlocal::texthash (
+ approval => "availability set to 'on' (approval required)",
+ automatic => "availability set to 'on' (automatic approval)",
+ norequest => "availability set to 'off'",
+ );
+ return %titles;
+}
+
sub curr_requestauthor {
my ($uname,$udom,$isadv,$inststatuses,$domconfig) = @_;
return unless ((ref($inststatuses) eq 'ARRAY') && (ref($domconfig) eq 'HASH'));
@@ -637,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') {
@@ -666,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",
@@ -718,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));
}
}
@@ -766,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') &&
@@ -784,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(
@@ -917,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",
@@ -968,9 +1102,13 @@ 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;
}
@@ -1486,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',
@@ -1495,22 +1677,32 @@ sub singleuser_breadcrumb {
}
sub date_sections_select {
- my ($context,$newuser,$formname,$permission) = @_;
+ my ($context,$newuser,$formname,$permission,$crstype,$ccuname,$ccdomain,
+ $showcredits) = @_;
+ my $credits;
+ if ($showcredits) {
+ my $defaultcredits = &Apache::lonuserutils::get_defaultcredits();
+ $credits = &get_user_credits($ccuname,$ccdomain,$defaultcredits);
+ if ($credits eq '') {
+ $credits = $defaultcredits;
+ }
+ }
my $cid = $env{'request.course.id'};
my ($cnum,$cdom) = &Apache::lonuserutils::get_course_identity($cid);
my $date_table = ''.&mt('Starting and Ending Dates').' '."\n".
&Apache::lonuserutils::date_setting_table(undef,undef,$context,
undef,$formname,$permission);
my $rowtitle = 'Section';
- my $secbox = ''.&mt('Section').' '."\n".
+ my $secbox = ''.&mt('Section and Credits').' '."\n".
&Apache::lonuserutils::section_picker($cdom,$cnum,'st',$rowtitle,
- $permission);
+ $permission,$context,'',$crstype,
+ $showcredits,$credits);
my $output = $date_table.$secbox;
return $output;
}
sub validation_javascript {
- my ($context,$ccdomain,$pjump_def,$groupslist,$newuser,$formname,
+ my ($context,$ccdomain,$pjump_def,$crstype,$groupslist,$newuser,$formname,
$loaditem) = @_;
my $dc_setcourse_code = '';
my $nondc_setsection_code = '';
@@ -1527,7 +1719,8 @@ sub validation_javascript {
if ($context eq 'course') {
$nondc_setsection_code =
&Apache::lonuserutils::setsections_javascript($formname,$groupslist,
- undef,$checkauth);
+ undef,$checkauth,
+ $crstype);
}
if ($checkauth) {
$nondc_setsection_code .=
@@ -1547,8 +1740,23 @@ sub validation_javascript {
}
sub display_existing_roles {
- my ($r,$ccuname,$ccdomain,$inccourses,$context,$roledom,$crstype) = @_;
+ my ($r,$ccuname,$ccdomain,$inccourses,$context,$roledom,$crstype,
+ $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",
@@ -1556,6 +1764,7 @@ sub display_existing_roles {
'ren' => "Re-Enable",
'rol' => "Role",
'ext' => "Extent",
+ 'crd' => "Credits",
'sta' => "Start",
'end' => "End",
);
@@ -1611,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+)$});
@@ -1618,6 +1834,8 @@ sub display_existing_roles {
my $delallowed=0;
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);
@@ -1646,6 +1864,15 @@ sub display_existing_roles {
}
$sortkey.="\0$coursedir";
$inccourses->{$cid}=1;
+ if (($showcredits) && ($class eq 'Course') && ($role_code eq 'st')) {
+ my $defaultcredits = $coursedata{'internal.defaultcredits'};
+ $credits =
+ &get_user_credits($ccuname,$ccdomain,$defaultcredits,
+ $coursedom,$coursedir);
+ if ($credits eq '') {
+ $credits = $defaultcredits;
+ }
+ }
if ((&Apache::lonnet::allowed('c'.$role_code,$coursedom.'/'.$coursedir)) ||
(&Apache::lonnet::allowed('c'.$role_code,$ccdomain))) {
$allowed=1;
@@ -1671,12 +1898,13 @@ sub display_existing_roles {
$thisrole.='.'.$role_code;
}
}
- if ($area=~m{^/($match_domain)/($match_courseid)/(\w+)}) {
- $carea.=' Section: '.$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;
}
}
@@ -1702,7 +1930,7 @@ sub display_existing_roles {
}
}
if ($role_code eq 'ca' || $role_code eq 'au' || $role_code eq 'aa') {
- $class='Construction Space';
+ $class='Authoring Space';
} elsif ($role_code eq 'su') {
$class='System';
} else {
@@ -1718,56 +1946,76 @@ 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.=' ';
- if ($allowed && !$active) {
- $row.= ' ';
- } else {
- $row.=' ';
- }
- $row.=' ';
- if ($delallowed) {
- $row.= ' ';
- } else {
- $row.=' ';
+ $row.=' ';
+ if ($allowed && !$active) {
+ $row.= ' ';
+ } else {
+ $row.=' ';
+ }
+ $row.=' ';
+ if ($delallowed) {
+ $row.= ' ';
+ } else {
+ $row.=' ';
+ }
+ $row.= ' ';
}
my $plaintext='';
if (!$croletitle) {
- $plaintext=&Apache::lonnet::plaintext($role_code,$class)
+ $plaintext=&Apache::lonnet::plaintext($role_code,$class);
+ if (($showcredits) && ($credits ne '')) {
+ $plaintext .= ''.
+ ''.
+ &mt('Credits: [_1]',$credits).
+ ' ';
+ }
} else {
$plaintext=
- &mt('Customrole [_1][_2]defined by [_3]',
+ &mt('Custom role [_1][_2]defined by [_3]',
'"'.$croletitle.'"',
' ',
$croleuname.':'.$croleudom);
}
- $row.= ''.$plaintext.
- ' '.$area.
- ' '.($role_start_time?&Apache::lonlocal::locallocaltime($role_start_time)
- : ' ' ).
- ' '.($role_end_time ?&Apache::lonlocal::locallocaltime($role_end_time)
- : ' ' )
- ." ";
+ $row.= ''.$plaintext.' '.
+ ''.$area.' '.
+ ''.($role_start_time?&Apache::lonlocal::locallocaltime($role_start_time)
+ : ' ' ).' '.
+ ''.($role_end_time ?&Apache::lonlocal::locallocaltime($role_end_time)
+ : ' ' ).' ';
$sortrole{$sortkey}=$envkey;
$roletext{$envkey}=$row;
$roleclass{$envkey}=$class;
- $rolepriv{$envkey}=$allowed;
+ if ($allowed) {
+ $rolepriv{$envkey}='edit';
+ } else {
+ if ($context eq 'domain') {
+ if (&Apache::lonnet::allowed('vur',$ccdomain)) {
+ $rolepriv{$envkey}='view';
+ }
+ } elsif ($context eq 'course') {
+ if ((&Apache::lonnet::allowed('vcl',$env{'request.course.id'})) ||
+ ($env{'request.course.sec'} && ($env{'request.course.sec'} eq $csec) &&
+ &Apache::lonnet::allowed('vcl',$env{'request.course.id'}.'/'.$env{'request.course.sec'}))) {
+ $rolepriv{$envkey}='view';
+ }
+ }
+ }
} # end of foreach (table building loop)
my $rolesdisplay = 0;
my %output = ();
- foreach my $type ('Construction Space','Course','Community','Domain','System','Unknown') {
+ foreach my $type ('Authoring Space','Course','Community','Domain','System','Unknown') {
$output{$type} = '';
foreach my $which (sort {uc($a) cmp uc($b)} (keys(%sortrole))) {
if ( ($roleclass{$sortrole{$which}} =~ /^\Q$type\E/ ) && ($rolepriv{$sortrole{$which}}) ) {
@@ -1793,25 +2041,38 @@ sub display_existing_roles {
$contextrole = &mt('Existing Roles in this Course');
}
} elsif ($env{'request.role'} =~ /^au\./) {
- $contextrole = &mt('Existing Co-Author Roles in your Construction Space');
+ $contextrole = &mt('Existing Co-Author Roles in your Authoring Space');
} else {
- $contextrole = &mt('Existing Roles in this Domain');
+ if ($showall) {
+ $contextrole = &mt('Existing Roles in this Domain');
+ } elsif ($showactive) {
+ $contextrole = &mt('Unexpired Roles in this Domain');
+ } elsif ($showexpired) {
+ $contextrole = &mt('Expired or Revoked Roles in this Domain');
+ }
}
- $r->print('
-'.$lt{'rer'}.' '.
-''.$contextrole.'
'.
+ $r->print(''.
+'
'.$contextrole.' '.
&Apache::loncommon::start_data_table("LC_createuser").
-&Apache::loncommon::start_data_table_header_row().
-''.$lt{'rev'}.' '.$lt{'ren'}.' '.$lt{'del'}.
-' '.$lt{'rol'}.' '.$lt{'ext'}.
-' '.$lt{'sta'}.' '.$lt{'end'}.' '.
+&Apache::loncommon::start_data_table_header_row());
+ if ($showall) {
+ $r->print(
+''.$lt{'rev'}.' '.$lt{'ren'}.' '.$lt{'del'}.' '
+ );
+ } elsif ($showexpired) {
+ $r->print(''.$lt{'rev'}.' ');
+ }
+ $r->print(
+''.$lt{'rol'}.' '.$lt{'ext'}.' '.
+''.$lt{'sta'}.' '.$lt{'end'}.' '.
&Apache::loncommon::end_data_table_header_row());
- foreach my $type ('Construction Space','Course','Community','Domain','System','Unknown') {
+ foreach my $type ('Authoring Space','Course','Community','Domain','System','Unknown') {
if ($output{$type}) {
$r->print($output{$type}."\n");
}
}
- $r->print(&Apache::loncommon::end_data_table());
+ $r->print(&Apache::loncommon::end_data_table().
+ ' ');
}
return;
}
@@ -1830,7 +2091,7 @@ sub new_coauthor_roles {
my $cuname=$env{'user.name'};
my $cudom=$env{'request.role.domain'};
my %lt=&Apache::lonlocal::texthash(
- 'cs' => "Construction Space",
+ 'cs' => "Authoring Space",
'act' => "Activate",
'rol' => "Role",
'ext' => "Extent",
@@ -1881,7 +2142,7 @@ sub new_coauthor_roles {
'');
} elsif (($env{'user.name'} eq $ccuname) &&
($env{'user.domain'} eq $ccdomain)) {
- $r->print(&mt('Assigning yourself a co-author or assistant co-author role in your own author area in Construction Space is not permitted'));
+ $r->print(&mt('Assigning yourself a co-author or assistant co-author role in your own author area in Authoring Space is not permitted'));
}
}
return $addrolesdisplay;;
@@ -1941,16 +2202,16 @@ sub user_authentication {
my ($ccuname,$ccdomain,$formname) = @_;
my $currentauth=&Apache::lonnet::queryauthenticate($ccuname,$ccdomain);
my $outcome;
+ my %lt=&Apache::lonlocal::texthash(
+ 'err' => "ERROR",
+ 'uuas' => "This user has an unrecognized authentication scheme",
+ 'adcs' => "Please alert a domain coordinator of this situation",
+ 'sldb' => "Please specify login data below",
+ 'ld' => "Login Data"
+ );
# Check for a bad authentication type
if ($currentauth !~ /^(krb4|krb5|unix|internal|localauth):/) {
# bad authentication scheme
- my %lt=&Apache::lonlocal::texthash(
- 'err' => "ERROR",
- 'uuas' => "This user has an unrecognized authentication scheme",
- 'adcs' => "Please alert a domain coordinator of this situation",
- 'sldb' => "Please specify login data below",
- 'ld' => "Login Data"
- );
if (&Apache::lonnet::allowed('mau',$ccdomain)) {
&initialize_authen_forms($ccdomain,$formname);
@@ -1976,16 +2237,12 @@ $lt{'uuas'} ($currentauth). $lt{'adcs'}.
ENDBADAUTH
}
} else { # Authentication type is valid
+
&initialize_authen_forms($ccdomain,$formname,$currentauth,'modifyuser');
my ($authformcurrent,$can_modify,@authform_others) =
&modify_login_block($ccdomain,$currentauth);
if (&Apache::lonnet::allowed('mau',$ccdomain)) {
# Current user has login modification privileges
- my %lt=&Apache::lonlocal::texthash (
- 'ld' => "Login Data",
- 'ccld' => "Change Current Login Data",
- 'enld' => "Enter New Login Data"
- );
$outcome =
''."\n";
+ my @templateroles = &Apache::lonuserutils::custom_template_roles($context,$crstype);
+ my $head_script =
+ &Apache::lonuserutils::custom_roledefs_js($context,$crstype,$formname,
+ \%full,\@templateroles,$jsback);
push (@{$brcrum},
- {href => "javascript:backPage(document.form1,'pickrole','')",
+ {href => "javascript:backPage(document.$formname,'pickrole','')",
text => "Pick custom role",
faq => 282,bug=>'Instructor Interface',},
- {href => "javascript:backPage(document.form1,'','')",
+ {href => "javascript:backPage(document.$formname,'','')",
text => "Edit custom role",
faq => 282,
bug => 'Instructor Interface',
@@ -3944,145 +4538,31 @@ sub custom_role_editor {
$r->print(&Apache::loncommon::start_page('Custom Role Editor',
$head_script,$args).
$body_top);
- my %lt=&Apache::lonlocal::texthash(
- 'prv' => "Privilege",
- 'crl' => "Course Level",
- 'dml' => "Domain Level",
- 'ssl' => "System Level");
-
- $r->print(''
- .'
');
- if ($context_code) {
- $r->print(''
- .''
- .'
'
- );
- }
- $r->print(' ');
+ $r->print('');
}
-# --------------------------------------------------------
-sub make_script_template {
- my ($role,$crstype) = @_;
- my %full_c=();
- my %full_d=();
- my %full_s=();
- my $return_script;
- foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:c'})) {
- my ($priv,$restrict)=split(/\&/,$item);
- $full_c{$priv}=1;
- }
- foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:d'})) {
- my ($priv,$restrict)=split(/\&/,$item);
- $full_d{$priv}=1;
- }
- foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:s'})) {
- next if (($crstype eq 'Community') && ($item eq 'bre&S'));
- my ($priv,$restrict)=split(/\&/,$item);
- $full_s{$priv}=1;
- }
- $return_script .= 'function set_'.$role.'() {'."\n";
- my @temp = split(/:/,$Apache::lonnet::pr{$role.':c'});
- my %role_c;
- foreach my $priv (@temp) {
- my ($priv_item, $dummy) = split(/\&/,$priv);
- $role_c{$priv_item} = 1;
- }
- my %role_d;
- @temp = split(/:/,$Apache::lonnet::pr{$role.':d'});
- foreach my $priv(@temp) {
- my ($priv_item, $dummy) = split(/\&/,$priv);
- $role_d{$priv_item} = 1;
- }
- my %role_s;
- @temp = split(/:/,$Apache::lonnet::pr{$role.':s'});
- foreach my $priv(@temp) {
- my ($priv_item, $dummy) = split(/\&/,$priv);
- $role_s{$priv_item} = 1;
- }
- foreach my $priv_item (keys(%full_c)) {
- my ($priv, $dummy) = split(/\&/,$priv_item);
- if ((exists($role_c{$priv})) || (exists($role_d{$priv})) ||
- (exists($role_s{$priv}))) {
- $return_script .= "document.form1.$priv"."_c.checked = true;\n";
- } else {
- $return_script .= "document.form1.$priv"."_c.checked = false;\n";
- }
- }
- foreach my $priv_item (keys(%full_d)) {
- my ($priv, $dummy) = split(/\&/,$priv_item);
- if ((exists($role_d{$priv})) || (exists($role_s{$priv}))) {
- $return_script .= "document.form1.$priv"."_d.checked = true;\n";
- } else {
- $return_script .= "document.form1.$priv"."_d.checked = false;\n";
- }
- }
- foreach my $priv_item (keys(%full_s)) {
- my ($priv, $dummy) = split(/\&/,$priv_item);
- if (exists($role_s{$priv})) {
- $return_script .= "document.form1.$priv"."_s.checked = true;\n";
- } else {
- $return_script .= "document.form1.$priv"."_s.checked = false;\n";
- }
- }
- $return_script .= '}'."\n";
- return ($return_script);
-}
-# ----------------------------------------------------------
-sub make_button_code {
- my ($role,$crstype) = @_;
- my $label = &Apache::lonnet::plaintext($role,$crstype);
- my $button_code = ' ';
- return ($button_code);
-}
+
# ---------------------------------------------------------- Call to definerole
sub set_custom_role {
- my ($r,$context,$brcrum) = @_;
+ my ($r,$context,$brcrum,$prefix) = @_;
my $rolename=$env{'form.rolename'};
$rolename=~s/[^A-Za-z0-9]//gs;
if (!$rolename) {
- &custom_role_editor($r,$brcrum);
+ &custom_role_editor($r,$brcrum,$prefix);
return;
}
my ($jsback,$elements) = &crumb_utilities();
@@ -4107,9 +4587,10 @@ sub set_custom_role {
help => 'Course_Editing_Custom_Roles'},
);
my $args = { bread_crumbs => $brcrum,
- bread_crumbs_component => 'User Management'};
+ bread_crumbs_component => 'User Management'};
$r->print(&Apache::loncommon::start_page('Save Custom Role',$jscript,$args));
+ my $newrole;
my ($rdummy,$roledef)=
&Apache::lonnet::get('roles',["rolesdef_$rolename"]);
@@ -4120,51 +4601,50 @@ sub set_custom_role {
} else {
$r->print(&mt('New Role').' "');
$roledef='';
+ $newrole = 1;
}
$r->print($rolename.'"');
-# ------------------------------------------------------- What can be assigned?
- my $sysrole='';
- my $domrole='';
- my $courole='';
-
- foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:c'})) {
- my ($priv,$restrict)=split(/\&/,$item);
- if (!$restrict) { $restrict=''; }
- if ($env{'form.'.$priv.'_c'}) {
- $courole.=':'.$item;
- }
- }
-
- foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:d'})) {
- my ($priv,$restrict)=split(/\&/,$item);
- if (!$restrict) { $restrict=''; }
- if ($env{'form.'.$priv.'_d'}) {
- $domrole.=':'.$item;
- }
- }
+# ------------------------------------------------- Assign role and show result
- foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:s'})) {
- my ($priv,$restrict)=split(/\&/,$item);
- if (!$restrict) { $restrict=''; }
- if ($env{'form.'.$priv.'_s'}) {
- $sysrole.=':'.$item;
- }
- }
- $r->print(' Defining Role: '.
- &Apache::lonnet::definerole($rolename,$sysrole,$domrole,$courole));
+ my $errmsg;
+ my %newprivs = &Apache::lonuserutils::custom_role_update($rolename,$prefix);
+ # Assign role and return result
+ my $result = &Apache::lonnet::definerole($rolename,$newprivs{'s'},$newprivs{'d'},
+ $newprivs{'c'});
+ if ($result ne 'ok') {
+ $errmsg = ': '.$result;
+ }
+ my $message =
+ &Apache::lonhtmlcommon::confirm_success(
+ &mt('Defining Role').$errmsg, ($result eq 'ok' ? 0 : 1));
if ($env{'request.course.id'}) {
my $url='/'.$env{'request.course.id'};
$url=~s/\_/\//g;
- $r->print(' '.&mt('Assigning Role to Self').': '.
- &Apache::lonnet::assigncustomrole($env{'user.domain'},
- $env{'user.name'},
- $url,
- $env{'user.domain'},
- $env{'user.name'},
- $rolename,undef,undef,undef,$context));
- }
- $r->print(''.&mt('Create or edit another custom role').'
');
+ $result =
+ &Apache::lonnet::assigncustomrole(
+ $env{'user.domain'},$env{'user.name'},
+ $url,
+ $env{'user.domain'},$env{'user.name'},
+ $rolename,undef,undef,undef,$context);
+ if ($result ne 'ok') {
+ $errmsg = ': '.$result;
+ }
+ $message .=
+ ' '
+ .&Apache::lonhtmlcommon::confirm_success(
+ &mt('Assigning Role to Self').$errmsg, ($result eq 'ok' ? 0 : 1));
+ }
+ $r->print(
+ &Apache::loncommon::confirmwrapper($message)
+ .' '
+ .&Apache::lonhtmlcommon::actionbox([
+ ''
+ .&mt('Create or edit another custom role')
+ .' '])
+ .''
+ );
}
# ================================================================ Main Handler
@@ -4184,14 +4664,15 @@ sub handler {
} else {
$context = 'domain';
}
+
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
['action','state','callingform','roletype','showrole','bulkaction','popup','phase',
- 'username','domain','srchterm','srchdomain','srchin','srchby','srchtype']);
+ 'username','domain','srchterm','srchdomain','srchin','srchby','srchtype','queue']);
&Apache::lonhtmlcommon::clear_breadcrumbs();
my $args;
my $brcrum = [];
my $bread_crumbs_component = 'User Management';
- if ($env{'form.action'} ne 'dateselect') {
+ if (($env{'form.action'} ne 'dateselect') && ($env{'form.action'} ne 'displayuserreq')) {
$brcrum = [{href=>"/adm/createuser",
text=>"User Management",
help=>'Course_Create_Class_List,Course_Change_Privileges,Course_View_Class_List,Course_Editing_Custom_Roles,Course_Add_Student,Course_Drop_Student,Course_Automated_Enrollment,Course_Self_Enrollment,Course_Manage_Group'}
@@ -4215,6 +4696,16 @@ sub handler {
&Apache::loncommon::content_type($r,'text/html');
$r->send_http_header;
+ my $showcredits;
+ if ((($context eq 'course') && ($crstype eq 'Course')) ||
+ ($context eq 'domain')) {
+ my %domdefaults =
+ &Apache::lonnet::get_domain_defaults($env{'request.role.domain'});
+ if ($domdefaults{'officialcredits'} || $domdefaults{'unofficialcredits'}) {
+ $showcredits = 1;
+ }
+ }
+
# Main switch on form.action and form.state, as appropriate
if (! exists($env{'form.action'})) {
$args = {bread_crumbs => $brcrum,
@@ -4237,17 +4728,20 @@ sub handler {
if (! exists($env{'form.state'})) {
&Apache::lonuserutils::print_first_users_upload_form($r,$context);
} elsif ($env{'form.state'} eq 'got_file') {
- &Apache::lonuserutils::print_upload_manager_form($r,$context,
- $permission,$crstype);
+ &Apache::lonuserutils::print_upload_manager_form($r,$context,$permission,
+ $crstype,$showcredits);
} elsif ($env{'form.state'} eq 'enrolling') {
if ($env{'form.datatoken'}) {
- &Apache::lonuserutils::upfile_drop_add($r,$context,$permission);
+ &Apache::lonuserutils::upfile_drop_add($r,$context,$permission,
+ $showcredits);
}
} else {
&Apache::lonuserutils::print_first_users_upload_form($r,$context);
}
- } elsif ((($env{'form.action'} eq 'singleuser') || ($env{'form.action'}
- eq 'singlestudent')) && ($permission->{'cusr'})) {
+ } elsif (((($env{'form.action'} eq 'singleuser') || ($env{'form.action'}
+ eq 'singlestudent')) && ($permission->{'cusr'})) ||
+ (($env{'form.action'} eq 'singleuser') && ($permission->{'view'})) ||
+ (($env{'form.action'} eq 'accesslogs') && ($permission->{'activity'}))) {
my $phase = $env{'form.phase'};
my @search = ('srchterm','srchby','srchin','srchtype','srchdomain');
&Apache::loncreateuser::restore_prev_selections();
@@ -4256,7 +4750,7 @@ sub handler {
$srch->{$item} = $env{'form.'.$item};
}
if (($phase eq 'get_user_info') || ($phase eq 'userpicked') ||
- ($phase eq 'createnewuser')) {
+ ($phase eq 'createnewuser') || ($phase eq 'activity')) {
if ($env{'form.phase'} eq 'createnewuser') {
my $response;
if ($env{'form.srchterm'} !~ /^$match_username$/) {
@@ -4266,13 +4760,15 @@ sub handler {
.' letters numbers - . @')
.'';
$env{'form.phase'} = '';
- &print_username_entry_form($r,$context,$response,$srch,undef,$crstype,$brcrum);
+ &print_username_entry_form($r,$context,$response,$srch,undef,
+ $crstype,$brcrum,$showcredits);
} else {
my $ccuname =&LONCAPA::clean_username($srch->{'srchterm'});
my $ccdomain=&LONCAPA::clean_domain($srch->{'srchdomain'});
&print_user_modification_page($r,$ccuname,$ccdomain,
$srch,$response,$context,
- $permission,$crstype,$brcrum);
+ $permission,$crstype,$brcrum,
+ $showcredits);
}
} elsif ($env{'form.phase'} eq 'get_user_info') {
my ($currstate,$response,$forcenewuser,$results) =
@@ -4284,8 +4780,8 @@ sub handler {
&print_user_selection_page($r,$response,$srch,$results,
\@search,$context,undef,$crstype,
$brcrum);
- } elsif ($currstate eq 'modify') {
- my ($ccuname,$ccdomain);
+ } elsif (($currstate eq 'modify') || ($env{'form.action'} eq 'accesslogs')) {
+ my ($ccuname,$ccdomain,$uhome);
if (($srch->{'srchby'} eq 'uname') &&
($srch->{'srchtype'} eq 'exact')) {
$ccuname = $srch->{'srchterm'};
@@ -4296,12 +4792,32 @@ sub handler {
}
$ccuname =&LONCAPA::clean_username($ccuname);
$ccdomain=&LONCAPA::clean_domain($ccdomain);
- if ($env{'form.forcenewuser'}) {
- $response = '';
+ if ($env{'form.action'} eq 'accesslogs') {
+ my $uhome;
+ if (($ccuname ne '') && ($ccdomain ne '')) {
+ $uhome = &Apache::lonnet::homeserver($ccuname,$ccdomain);
+ }
+ if (($uhome eq '') || ($uhome eq 'no_host')) {
+ $env{'form.phase'} = '';
+ undef($forcenewuser);
+ #if ($response) {
+ # unless ($response =~ m{\Q \E$}) {
+ # $response .= ' ';
+ # }
+ #}
+ &print_username_entry_form($r,$context,$response,$srch,
+ $forcenewuser,$crstype,$brcrum);
+ } else {
+ &print_useraccesslogs_display($r,$ccuname,$ccdomain,$permission,$brcrum);
+ }
+ } else {
+ if ($env{'form.forcenewuser'}) {
+ $response = '';
+ }
+ &print_user_modification_page($r,$ccuname,$ccdomain,
+ $srch,$response,$context,
+ $permission,$crstype,$brcrum);
}
- &print_user_modification_page($r,$ccuname,$ccdomain,
- $srch,$response,$context,
- $permission,$crstype,$brcrum);
} elsif ($currstate eq 'query') {
&print_user_query_page($r,'createuser',$brcrum);
} else {
@@ -4312,28 +4828,37 @@ sub handler {
} elsif ($env{'form.phase'} eq 'userpicked') {
my $ccuname = &LONCAPA::clean_username($env{'form.seluname'});
my $ccdomain = &LONCAPA::clean_domain($env{'form.seludom'});
- &print_user_modification_page($r,$ccuname,$ccdomain,$srch,'',
- $context,$permission,$crstype,
- $brcrum);
+ if ($env{'form.action'} eq 'accesslogs') {
+ &print_useraccesslogs_display($r,$ccuname,$ccdomain,$permission,$brcrum);
+ } else {
+ &print_user_modification_page($r,$ccuname,$ccdomain,$srch,'',
+ $context,$permission,$crstype,
+ $brcrum);
+ }
+ } elsif ($env{'form.action'} eq 'accesslogs') {
+ my $ccuname = &LONCAPA::clean_username($env{'form.accessuname'});
+ my $ccdomain = &LONCAPA::clean_domain($env{'form.accessudom'});
+ &print_useraccesslogs_display($r,$ccuname,$ccdomain,$permission,$brcrum);
}
} elsif ($env{'form.phase'} eq 'update_user_data') {
- &update_user_data($r,$context,$crstype,$brcrum);
+ &update_user_data($r,$context,$crstype,$brcrum,$showcredits);
} else {
&print_username_entry_form($r,$context,undef,$srch,undef,$crstype,
$brcrum);
}
} elsif ($env{'form.action'} eq 'custom' && $permission->{'custom'}) {
+ my $prefix;
if ($env{'form.phase'} eq 'set_custom_roles') {
- &set_custom_role($r,$context,$brcrum);
+ &set_custom_role($r,$context,$brcrum,$prefix);
} else {
- &custom_role_editor($r,$brcrum);
+ &custom_role_editor($r,$brcrum,$prefix);
}
} elsif (($env{'form.action'} eq 'processauthorreq') &&
($permission->{'cusr'}) &&
(&Apache::lonnet::allowed('cau',$env{'request.role.domain'}))) {
push(@{$brcrum},
{href => '/adm/createuser?action=processauthorreq',
- text => 'Authoring space requests',
+ text => 'Authoring Space requests',
help => 'Domain_Role_Approvals'});
$bread_crumbs_component = 'Authoring requests';
if ($env{'form.state'} eq 'done') {
@@ -4345,7 +4870,8 @@ sub handler {
}
$args = { bread_crumbs => $brcrum,
bread_crumbs_component => $bread_crumbs_component};
- $r->print(&header(undef,$args));
+ my $js = &usernamerequest_javascript();
+ $r->print(&header(&add_script($js),$args));
if (!exists($env{'form.state'})) {
$r->print(&Apache::loncoursequeueadmin::display_queued_requests('requestauthor',
$env{'request.role.domain'}));
@@ -4354,6 +4880,124 @@ sub handler {
$r->print(&Apache::loncoursequeueadmin::update_request_queue('requestauthor',
$env{'request.role.domain'}));
}
+ } elsif (($env{'form.action'} eq 'processusernamereq') &&
+ ($permission->{'cusr'}) &&
+ (&Apache::lonnet::allowed('cau',$env{'request.role.domain'}))) {
+ push(@{$brcrum},
+ {href => '/adm/createuser?action=processusernamereq',
+ text => 'LON-CAPA account requests',
+ help => 'Domain_Username_Approvals'});
+ $bread_crumbs_component = 'Account requests';
+ if ($env{'form.state'} eq 'done') {
+ push(@{$brcrum},
+ {href => '/adm/createuser?action=usernamereqqueue',
+ text => 'Result',
+ help => 'Domain_Username_Approvals'});
+ $bread_crumbs_component = 'LON-CAPA account request result';
+ }
+ $args = { bread_crumbs => $brcrum,
+ bread_crumbs_component => $bread_crumbs_component};
+ my $js = &usernamerequest_javascript();
+ $r->print(&header(&add_script($js),$args));
+ if (!exists($env{'form.state'})) {
+ $r->print(&Apache::loncoursequeueadmin::display_queued_requests('requestusername',
+ $env{'request.role.domain'}));
+ } elsif ($env{'form.state'} eq 'done') {
+ $r->print(''.&mt('LON-CAPA account request processing').' '."\n");
+ $r->print(&Apache::loncoursequeueadmin::update_request_queue('requestusername',
+ $env{'request.role.domain'}));
+ }
+ } elsif (($env{'form.action'} eq 'displayuserreq') &&
+ ($permission->{'cusr'})) {
+ my $dom = $env{'form.domain'};
+ my $uname = $env{'form.username'};
+ my $warning;
+ if (($dom =~ /^$match_domain$/) && (&Apache::lonnet::domain($dom) ne '')) {
+ if (($dom eq $env{'request.role.domain'}) && (&Apache::lonnet::allowed('ccc',$dom))) {
+ if (($uname =~ /^$match_username$/) && ($env{'form.queue'} eq 'approval')) {
+ my $uhome = &Apache::lonnet::homeserver($uname,$dom);
+ if ($uhome eq 'no_host') {
+ my $queue = $env{'form.queue'};
+ my $reqkey = &escape($uname).'_'.$queue;
+ my $namespace = 'usernamequeue';
+ my $domconfig = &Apache::lonnet::get_domainconfiguser($dom);
+ my %queued =
+ &Apache::lonnet::get($namespace,[$reqkey],$dom,$domconfig);
+ unless ($queued{$reqkey}) {
+ $warning = &mt('No information was found for this LON-CAPA account request.');
+ }
+ } else {
+ $warning = &mt('A LON-CAPA account already exists for the requested username and domain.');
+ }
+ } else {
+ $warning = &mt('LON-CAPA account request status check is for an invalid username.');
+ }
+ } else {
+ $warning = &mt('You do not have rights to view LON-CAPA account requests in the domain specified.');
+ }
+ } else {
+ $warning = &mt('LON-CAPA account request status check is for an invalid domain.');
+ }
+ my $args = { only_body => 1 };
+ $r->print(&header(undef,$args).
+ ''.&mt('LON-CAPA Account Request Details').' ');
+ if ($warning ne '') {
+ $r->print(''.$warning.'
');
+ } else {
+ my ($infofields,$infotitles) = &Apache::loncommon::emailusername_info();
+ my $domconfiguser = &Apache::lonnet::get_domainconfiguser($dom);
+ my %domconfig = &Apache::lonnet::get_dom('configuration',['usercreation'],$dom);
+ if (ref($domconfig{'usercreation'}) eq 'HASH') {
+ if (ref($domconfig{'usercreation'}{'cancreate'}) eq 'HASH') {
+ if (ref($domconfig{'usercreation'}{'cancreate'}{'emailusername'}) eq 'HASH') {
+ my %info =
+ &Apache::lonnet::get('nohist_requestedusernames',[$uname],$dom,$domconfiguser);
+ if (ref($info{$uname}) eq 'HASH') {
+ my $usertype = $info{$uname}{'inststatus'};
+ unless ($usertype) {
+ $usertype = 'default';
+ }
+ if (ref($domconfig{'usercreation'}{'cancreate'}{'emailusername'}{$usertype}) eq 'HASH') {
+ if ((ref($infofields) eq 'ARRAY') && (ref($infotitles) eq 'HASH')) {
+ $r->print(''.&Apache::lonhtmlcommon::start_pick_box());
+ my ($num,$count,$showstatus);
+ $count = scalar(keys(%{$domconfig{'usercreation'}{'cancreate'}{'emailusername'}{$usertype}}));
+ unless ($usertype eq 'default') {
+ my ($othertitle,$usertypes,$types) =
+ &Apache::loncommon::sorted_inst_types($dom);
+ if (ref($usertypes) eq 'HASH') {
+ if ($usertypes->{$usertype}) {
+ $showstatus = $usertypes->{$usertype};
+ $count ++;
+ }
+ }
+ }
+ foreach my $field (@{$infofields}) {
+ next unless ($domconfig{'usercreation'}{'cancreate'}{'emailusername'}{$usertype}{$field});
+ next unless ($infotitles->{$field});
+ $r->print(&Apache::lonhtmlcommon::row_title($infotitles->{$field}).
+ $info{$uname}{$field});
+ $num ++;
+ if ($count == $num) {
+ $r->print(&Apache::lonhtmlcommon::row_closure(1));
+ } else {
+ $r->print(&Apache::lonhtmlcommon::row_closure());
+ }
+ }
+ if ($showstatus) {
+ $r->print(&Apache::lonhtmlcommon::row_title(&mt('Status type (self-reported)')).
+ $showstatus.
+ &Apache::lonhtmlcommon::row_closure(1));
+ }
+ $r->print(&Apache::lonhtmlcommon::end_pick_box().'
');
+ }
+ }
+ }
+ }
+ }
+ }
+ $r->print(&close_popup_form());
+ }
} elsif (($env{'form.action'} eq 'listusers') &&
($permission->{'view'} || $permission->{'cusr'})) {
if ($env{'form.phase'} eq 'bulkchange') {
@@ -4420,7 +5064,8 @@ sub handler {
$r->print(&header(&add_script($jscript),$args));
}
&Apache::lonuserutils::print_userlist($r,undef,$permission,$context,
- $formname,$totcodes,$codetitles,$idlist,$idlist_titles);
+ $formname,$totcodes,$codetitles,$idlist,$idlist_titles,
+ $showcredits);
}
} elsif ($env{'form.action'} eq 'drop' && $permission->{'cusr'}) {
my $brtext;
@@ -4451,76 +5096,98 @@ sub handler {
} elsif ($env{'form.action'} eq 'dateselect') {
if ($permission->{'cusr'}) {
$r->print(&header(undef,{'no_nav_bar' => 1}).
- &Apache::lonuserutils::date_section_selector($context,
- $permission,$crstype));
+ &Apache::lonuserutils::date_section_selector($context,$permission,
+ $crstype,$showcredits));
} else {
$r->print(&header(undef,{'no_nav_bar' => 1}).
''.&mt('You do not have permission to modify dates or sections for users').' ');
}
} elsif ($env{'form.action'} eq 'selfenroll') {
- push(@{$brcrum},
- {href => '/adm/createuser?action=selfenroll',
- text => "Configure Self-enrollment",
- help => 'Course_Self_Enrollment'});
- if (!exists($env{'form.state'})) {
- $args = { bread_crumbs => $brcrum,
- bread_crumbs_component => 'Configure Self-enrollment'};
- $r->print(&header(undef,$args));
- $r->print(''.&mt('Self-enrollment with a student role').' '."\n");
- &print_selfenroll_menu($r,$context,$permission);
- } elsif ($env{'form.state'} eq 'done') {
- push (@{$brcrum},
- {href=>'/adm/createuser?action=selfenroll',
- text=>"Result"});
- $args = { bread_crumbs => $brcrum,
- bread_crumbs_component => 'Self-enrollment result'};
- $r->print(&header(undef,$args));
- $r->print(''.&mt('Self-enrollment with a student role').' '."\n");
- &update_selfenroll_config($r,$context,$permission);
+ if ($permission->{selfenrolladmin}) {
+ my $cid = $env{'request.course.id'};
+ my $cdom = $env{'course.'.$cid.'.domain'};
+ my $cnum = $env{'course.'.$cid.'.num'};
+ my %currsettings = (
+ selfenroll_types => $env{'course.'.$cid.'.internal.selfenroll_types'},
+ selfenroll_registered => $env{'course.'.$cid.'.internal.selfenroll_registered'},
+ selfenroll_section => $env{'course.'.$cid.'.internal.selfenroll_section'},
+ selfenroll_notifylist => $env{'course.'.$cid.'.internal.selfenroll_notifylist'},
+ selfenroll_approval => $env{'course.'.$cid.'.internal.selfenroll_approval'},
+ selfenroll_limit => $env{'course.'.$cid.'.internal.selfenroll_limit'},
+ selfenroll_cap => $env{'course.'.$cid.'.internal.selfenroll_cap'},
+ selfenroll_start_date => $env{'course.'.$cid.'.internal.selfenroll_start_date'},
+ selfenroll_end_date => $env{'course.'.$cid.'.internal.selfenroll_end_date'},
+ selfenroll_start_access => $env{'course.'.$cid.'.internal.selfenroll_start_access'},
+ selfenroll_end_access => $env{'course.'.$cid.'.internal.selfenroll_end_access'},
+ default_enrollment_start_date => $env{'course.'.$cid.'.default_enrollment_start_date'},
+ default_enrollment_end_date => $env{'course.'.$cid.'.default_enrollment_end_date'},
+ uniquecode => $env{'course.'.$cid.'.internal.uniquecode'},
+ );
+ push(@{$brcrum},
+ {href => '/adm/createuser?action=selfenroll',
+ text => "Configure Self-enrollment",
+ help => 'Course_Self_Enrollment'});
+ if (!exists($env{'form.state'})) {
+ $args = { bread_crumbs => $brcrum,
+ bread_crumbs_component => 'Configure Self-enrollment'};
+ $r->print(&header(undef,$args));
+ $r->print(''.&mt('Self-enrollment with a student role').' '."\n");
+ &print_selfenroll_menu($r,'course',$cid,$cdom,$cnum,\%currsettings);
+ } elsif ($env{'form.state'} eq 'done') {
+ push (@{$brcrum},
+ {href=>'/adm/createuser?action=selfenroll',
+ text=>"Result"});
+ $args = { bread_crumbs => $brcrum,
+ bread_crumbs_component => 'Self-enrollment result'};
+ $r->print(&header(undef,$args));
+ $r->print(''.&mt('Self-enrollment with a student role').' '."\n");
+ &update_selfenroll_config($r,$cid,$cdom,$cnum,$context,$crstype,\%currsettings);
+ }
+ } else {
+ $r->print(&header(undef,{'no_nav_bar' => 1}).
+ ''.&mt('You do not have permission to configure self-enrollment').' ');
}
} elsif ($env{'form.action'} eq 'selfenrollqueue') {
- push(@{$brcrum},
- {href => '/adm/createuser?action=selfenrollqueue',
- text => 'Enrollment requests',
- help => 'Course_Self_Enrollment'});
- $bread_crumbs_component = 'Enrollment requests';
- if ($env{'form.state'} eq 'done') {
+ if ($permission->{selfenrolladmin}) {
push(@{$brcrum},
{href => '/adm/createuser?action=selfenrollqueue',
- text => 'Result',
+ text => 'Enrollment requests',
help => 'Course_Self_Enrollment'});
- $bread_crumbs_component = 'Enrollment result';
- }
- $args = { bread_crumbs => $brcrum,
- bread_crumbs_component => $bread_crumbs_component};
- $r->print(&header(undef,$args));
- my $cid = $env{'request.course.id'};
- my $cdom = $env{'course.'.$cid.'.domain'};
- my $cnum = $env{'course.'.$cid.'.num'};
- my $coursedesc = $env{'course.'.$cid.'.description'};
- if (!exists($env{'form.state'})) {
- $r->print(''.&mt('Pending enrollment requests').' '."\n");
- $r->print(&Apache::loncoursequeueadmin::display_queued_requests($context,
- $cdom,$cnum));
- } elsif ($env{'form.state'} eq 'done') {
- $r->print(''.&mt('Enrollment request processing').' '."\n");
- $r->print(&Apache::loncoursequeueadmin::update_request_queue($context,
- $cdom,$cnum,$coursedesc));
+ $bread_crumbs_component = 'Enrollment requests';
+ if ($env{'form.state'} eq 'done') {
+ push(@{$brcrum},
+ {href => '/adm/createuser?action=selfenrollqueue',
+ text => 'Result',
+ help => 'Course_Self_Enrollment'});
+ $bread_crumbs_component = 'Enrollment result';
+ }
+ $args = { bread_crumbs => $brcrum,
+ bread_crumbs_component => $bread_crumbs_component};
+ $r->print(&header(undef,$args));
+ my $cid = $env{'request.course.id'};
+ my $cdom = $env{'course.'.$cid.'.domain'};
+ my $cnum = $env{'course.'.$cid.'.num'};
+ my $coursedesc = $env{'course.'.$cid.'.description'};
+ if (!exists($env{'form.state'})) {
+ $r->print(''.&mt('Pending enrollment requests').' '."\n");
+ $r->print(&Apache::loncoursequeueadmin::display_queued_requests($context,
+ $cdom,$cnum));
+ } elsif ($env{'form.state'} eq 'done') {
+ $r->print(''.&mt('Enrollment request processing').' '."\n");
+ $r->print(&Apache::loncoursequeueadmin::update_request_queue($context,
+ $cdom,$cnum,$coursedesc));
+ }
+ } else {
+ $r->print(&header(undef,{'no_nav_bar' => 1}).
+ ''.&mt('You do not have permission to manage self-enrollment').' ');
}
} elsif ($env{'form.action'} eq 'changelogs') {
- my $helpitem;
- if ($context eq 'course') {
- $helpitem = 'Course_User_Logs';
+ if ($permission->{cusr} || $permission->{view}) {
+ &print_userchangelogs_display($r,$context,$permission,$brcrum);
+ } else {
+ $r->print(&header(undef,{'no_nav_bar' => 1}).
+ ''.&mt('You do not have permission to view change logs').' ');
}
- push (@{$brcrum},
- {href => '/adm/createuser?action=changelogs',
- text => 'User Management Logs',
- help => $helpitem});
- $bread_crumbs_component = 'User Changes';
- $args = { bread_crumbs => $brcrum,
- bread_crumbs_component => $bread_crumbs_component};
- $r->print(&header(undef,$args));
- &print_userchangelogs_display($r,$context,$permission);
} else {
$bread_crumbs_component = 'User Management';
$args = { bread_crumbs => $brcrum,
@@ -4552,8 +5219,39 @@ sub add_script {
.''."\n";
}
+sub usernamerequest_javascript {
+ my $js = <
+END
+}
+
sub verify_user_display {
my ($context) = @_;
+ my %lt = &Apache::lonlocal::texthash (
+ course => 'course(s): description, section(s), status',
+ community => 'community(s): description, section(s), status',
+ author => 'author',
+ );
my $photos;
if (($context eq 'course') && $env{'request.course.id'}) {
$photos = $env{'course.'.$env{'request.course.id'}.'.internal.showphoto'};
@@ -4577,16 +5275,25 @@ function updateCols(caller) {
var context = '$context';
var photos = '$photos';
if (caller == 'Status') {
- if (document.studentform.Status.options[document.studentform.Status.selectedIndex].value == 'Any') {
- document.getElementById('showcolstatus').checked = true;
- document.getElementById('showcolstatus').disabled = '';
- document.getElementById('showcolstart').checked = true;
- document.getElementById('showcolend').checked = true;
- } else {
+ if ((context == 'domain') &&
+ ((document.studentform.roletype.options[document.studentform.roletype.selectedIndex].value == 'course') ||
+ (document.studentform.roletype.options[document.studentform.roletype.selectedIndex].value == 'community'))) {
document.getElementById('showcolstatus').checked = false;
document.getElementById('showcolstatus').disabled = 'disabled';
document.getElementById('showcolstart').checked = false;
document.getElementById('showcolend').checked = false;
+ } else {
+ if (document.studentform.Status.options[document.studentform.Status.selectedIndex].value == 'Any') {
+ document.getElementById('showcolstatus').checked = true;
+ document.getElementById('showcolstatus').disabled = '';
+ document.getElementById('showcolstart').checked = true;
+ document.getElementById('showcolend').checked = true;
+ } else {
+ document.getElementById('showcolstatus').checked = false;
+ document.getElementById('showcolstatus').disabled = 'disabled';
+ document.getElementById('showcolstart').checked = false;
+ document.getElementById('showcolend').checked = false;
+ }
}
}
if (caller == 'output') {
@@ -4604,13 +5311,74 @@ function updateCols(caller) {
}
}
if (caller == 'showrole') {
- if (document.studentform.showrole.options[document.studentform.showrole.selectedIndex].value == 'Any') {
+ if ((document.studentform.showrole.options[document.studentform.showrole.selectedIndex].value == 'Any') ||
+ (document.studentform.showrole.options[document.studentform.showrole.selectedIndex].value == 'cr')) {
document.getElementById('showcolrole').checked = true;
document.getElementById('showcolrole').disabled = '';
} else {
document.getElementById('showcolrole').checked = false;
document.getElementById('showcolrole').disabled = 'disabled';
}
+ if (context == 'domain') {
+ var quotausageshow = 0;
+ if ((document.studentform.roletype.options[document.studentform.roletype.selectedIndex].value == 'course') ||
+ (document.studentform.roletype.options[document.studentform.roletype.selectedIndex].value == 'community')) {
+ document.getElementById('showcolstatus').checked = false;
+ document.getElementById('showcolstatus').disabled = 'disabled';
+ document.getElementById('showcolstart').checked = false;
+ document.getElementById('showcolend').checked = false;
+ } else {
+ if (document.studentform.Status.options[document.studentform.Status.selectedIndex].value == 'Any') {
+ document.getElementById('showcolstatus').checked = true;
+ document.getElementById('showcolstatus').disabled = '';
+ document.getElementById('showcolstart').checked = true;
+ document.getElementById('showcolend').checked = true;
+ }
+ }
+ if (document.studentform.roletype.options[document.studentform.roletype.selectedIndex].value == 'domain') {
+ document.getElementById('showcolextent').disabled = 'disabled';
+ document.getElementById('showcolextent').checked = 'false';
+ document.getElementById('showextent').style.display='none';
+ document.getElementById('showcoltextextent').innerHTML = '';
+ if ((document.studentform.showrole.options[document.studentform.showrole.selectedIndex].value == 'au') ||
+ (document.studentform.showrole.options[document.studentform.showrole.selectedIndex].value == 'Any')) {
+ if (document.getElementById('showcolauthorusage')) {
+ document.getElementById('showcolauthorusage').disabled = '';
+ }
+ if (document.getElementById('showcolauthorquota')) {
+ document.getElementById('showcolauthorquota').disabled = '';
+ }
+ quotausageshow = 1;
+ }
+ } else {
+ document.getElementById('showextent').style.display='block';
+ document.getElementById('showextent').style.textAlign='left';
+ document.getElementById('showextent').style.textFace='normal';
+ if (document.studentform.roletype.options[document.studentform.roletype.selectedIndex].value == 'author') {
+ document.getElementById('showcolextent').disabled = '';
+ document.getElementById('showcolextent').checked = 'true';
+ document.getElementById('showcoltextextent').innerHTML="$lt{'author'}";
+ } else {
+ document.getElementById('showcolextent').disabled = '';
+ document.getElementById('showcolextent').checked = 'true';
+ if (document.studentform.roletype.options[document.studentform.roletype.selectedIndex].value == 'community') {
+ document.getElementById('showcoltextextent').innerHTML="$lt{'community'}";
+ } else {
+ document.getElementById('showcoltextextent').innerHTML="$lt{'course'}";
+ }
+ }
+ }
+ if (quotausageshow == 0) {
+ if (document.getElementById('showcolauthorusage')) {
+ document.getElementById('showcolauthorusage').checked = false;
+ document.getElementById('showcolauthorusage').disabled = 'disabled';
+ }
+ if (document.getElementById('showcolauthorquota')) {
+ document.getElementById('showcolauthorquota').checked = false;
+ document.getElementById('showcolauthorquota').disabled = 'disabled';
+ }
+ }
+ }
}
return;
}
@@ -4671,6 +5439,27 @@ sub print_main_menu {
listusers => 'Show and manage users in this community.',
},
);
+ if ($linkcontext eq 'domain') {
+ unless ($permission->{'cusr'}) {
+ $links{'domain'}{'singleuser'} = 'View a User';
+ $linktitles{'domain'}{'singleuser'} = 'View information about a user in the domain';
+
+ }
+ } elsif ($linkcontext eq 'course') {
+ unless ($permission->{'cusr'}) {
+ $links{'course'}{'singleuser'} = 'View a Course User';
+ $linktitles{'course'}{'singleuser'} = 'View information about a user in this course';
+ $links{'course'}{'listusers'} = 'List Course Users';
+ $linktitles{'course'}{'listusers'} = 'Show information about users in this course';
+ }
+ } elsif ($linkcontext eq 'community') {
+ unless ($permission->{'cusr'}) {
+ $links{'community'}{'singleuser'} = 'View a Community User';
+ $linktitles{'community'}{'singleuser'} = 'View information about a user in this community';
+ $links{'community'}{'listusers'} = 'List Community Users';
+ $linktitles{'community'}{'listusers'} = 'Show information about users in this community';
+ }
+ }
my @menu = ( {categorytitle => 'Single Users',
items =>
[
@@ -4679,7 +5468,7 @@ sub print_main_menu {
icon => 'edit-redo.png',
#help => 'Course_Change_Privileges',
url => '/adm/createuser?action=singleuser',
- permission => $permission->{'cusr'},
+ permission => ($permission->{'view'} || $permission->{'cusr'}),
linktitle => $linktitles{$linkcontext}{'singleuser'},
},
]},
@@ -4709,8 +5498,18 @@ sub print_main_menu {
{categorytitle => 'Administration',
items => [ ]},
);
-
+
if ($context eq 'domain'){
+ push(@{ $menu[0]->{items} }, # Single Users
+ {
+ linktext => 'User Access Log',
+ icon => 'document-properties.png',
+ #help => 'User_Access_Logs',
+ url => '/adm/createuser?action=accesslogs',
+ permission => $permission->{'activity'},
+ linktitle => 'View user access log.',
+ }
+ );
push(@{ $menu[2]->{items} }, #Category: Administration
{
@@ -4730,11 +5529,19 @@ sub print_main_menu {
linktitle => 'Approve or reject author role requests',
},
{
+ linktext => 'LON-CAPA Account Requests',
+ icon => 'list-add.png',
+ #help => 'Domain_Username_Approvals',
+ url => '/adm/createuser?action=processusernamereq',
+ permission => $permission->{'cusr'},
+ linktitle => 'Approve or reject LON-CAPA account requests',
+ },
+ {
linktext => 'Change Log',
icon => 'document-properties.png',
#help => 'Course_User_Logs',
url => '/adm/createuser?action=changelogs',
- permission => $permission->{'cusr'},
+ permission => ($permission->{'cusr'} || $permission->{'view'}),
linktitle => 'View change log.',
},
);
@@ -4754,6 +5561,7 @@ sub print_main_menu {
groups => 'Community Groups',
},
);
+ $linktext{'Placement'} = $linktext{'Course'};
my %linktitle = (
'Course' => {
@@ -4768,6 +5576,8 @@ sub print_main_menu {
},
);
+ $linktitle{'Placement'} = $linktitle{'Course'};
+
push(@{ $menu[0]->{items} }, #Category: Single Users
{
linktext => $linktext{$crstype}{'single'},
@@ -4811,18 +5621,18 @@ sub print_main_menu {
icon => 'document-properties.png',
#help => 'Course_User_Logs',
url => '/adm/createuser?action=changelogs',
- permission => $permission->{'cusr'},
+ permission => ($permission->{'view'} || $permission->{'cusr'}),
linktitle => 'View change log.',
},
);
if ($env{'course.'.$env{'request.course.id'}.'.internal.selfenroll_approval'}) {
push(@{ $menu[2]->{items} },
- {
+ {
linktext => 'Enrollment Requests',
icon => 'selfenrl-queue.png',
#help => 'Course_Approve_Selfenroll',
url => '/adm/createuser?action=selfenrollqueue',
- permission => $permission->{'cusr'},
+ permission => $permission->{'selfenrolladmin'},
linktitle =>'Approve or reject enrollment requests.',
},
);
@@ -4836,7 +5646,8 @@ sub print_main_menu {
icon => 'roles.png',
#help => 'Course_Automated_Enrollment',
permission => (&Apache::lonnet::auto_run($cnum,$cdom)
- && $permission->{'cusr'}),
+ && (($permission->{'cusr'}) ||
+ ($permission->{'view'}))),
url => '/adm/populate',
linktitle => 'Automated enrollment manager.',
}
@@ -4848,7 +5659,7 @@ sub print_main_menu {
icon => 'self_enroll.png',
#help => 'Course_Self_Enrollment',
url => '/adm/createuser?action=selfenroll',
- permission => $permission->{'cusr'},
+ permission => $permission->{'selfenrolladmin'},
linktitle => 'Configure user self-enrollment.',
},
);
@@ -4885,11 +5696,11 @@ sub restore_prev_selections {
}
sub print_selfenroll_menu {
- my ($r,$context,$permission) = @_;
+ my ($r,$context,$cid,$cdom,$cnum,$currsettings,$additional,$readonly) = @_;
my $crstype = &Apache::loncommon::course_type();
- my $formname = 'enrollstudent';
+ my $formname = 'selfenroll';
my $nolink = 1;
- my ($row,$lt) = &get_selfenroll_titles();
+ my ($row,$lt) = &Apache::lonuserutils::get_selfenroll_titles();
my $groupslist = &Apache::lonuserutils::get_groupslist();
my $setsec_js =
&Apache::lonuserutils::setsections_javascript($formname,$groupslist);
@@ -4898,6 +5709,11 @@ sub print_selfenroll_menu {
butn => 'but no user types have been checked.',
wilf => "Please uncheck 'activate' or check at least one type.",
);
+ my $disabled;
+ if ($readonly) {
+ $disabled = ' disabled="disabled"';
+ }
+ &js_escape(\%alerts);
my $selfenroll_js = <<"ENDSCRIPT";
function update_types(caller,num) {
var delidx = getIndexByName('selfenroll_delete');
@@ -5008,7 +5824,7 @@ function validate_types(form) {
}
} else {
if (document.$formname.selfenroll_activate.checked) {
- var num = document.enrollstudent.selfenroll_activate.value;
+ var num = document.$formname.selfenroll_activate.value;
countfail = check_types(num,countfail,needaction)
}
}
@@ -5055,6 +5871,26 @@ function check_types(num,countfail,needa
return countfail;
}
+function toggleNotify() {
+ var selfenrollApproval = 0;
+ if (document.$formname.selfenroll_approval.length) {
+ for (var i=0; i'."\n".
'// '."\n".
''."\n".
''.$lt->{'selfenroll'}.' '."\n";
- my ($visible,$cansetvis,$vismsgs,$visactions) = &visible_in_cat($cdom,$cnum);
- if (ref($visactions) eq 'HASH') {
- if ($visible) {
- $output .= ''.$visactions->{'vis'}.'
';
+
+ my $visactions = &cat_visibility();
+ my ($cathash,%cattype);
+ my %domconfig = &Apache::lonnet::get_dom('configuration',['coursecategories'],$cdom);
+ if (ref($domconfig{'coursecategories'}) eq 'HASH') {
+ $cathash = $domconfig{'coursecategories'}{'cats'};
+ $cattype{'auth'} = $domconfig{'coursecategories'}{'auth'};
+ $cattype{'unauth'} = $domconfig{'coursecategories'}{'unauth'};
+ if ($cattype{'auth'} eq '') {
+ $cattype{'auth'} = 'std';
+ }
+ if ($cattype{'unauth'} eq '') {
+ $cattype{'unauth'} = 'std';
+ }
+ } else {
+ $cathash = {};
+ $cattype{'auth'} = 'std';
+ $cattype{'unauth'} = 'std';
+ }
+ if (($cattype{'auth'} eq 'none') && ($cattype{'unauth'} eq 'none')) {
+ $r->print(''.$visactions->{'miss'}.' '.$visactions->{'yous'}.
+ ' '.
+ ' '.$visactions->{'take'}.''.
+ ''.$visactions->{'dc_chgconf'}.' '.
+ ' ');
+ } elsif (($cattype{'auth'} !~ /^(std|domonly)$/) && ($cattype{'unauth'} !~ /^(std|domonly)$/)) {
+ if ($currsettings->{'uniquecode'}) {
+ $r->print(''.$visactions->{'vis'}.' ');
} else {
- $output .= ''.$visactions->{'miss'}.'
'
- .$visactions->{'yous'}.
- ''.$visactions->{'gen'}.' '.$visactions->{'coca'};
- if (ref($vismsgs) eq 'ARRAY') {
- $output .= ' '.$visactions->{'make'}.'
';
- foreach my $item (@{$vismsgs}) {
- $output .= ''.$visactions->{$item}.' ';
+ $r->print(''.$visactions->{'miss'}.' '.$visactions->{'yous'}.
+ ' '.
+ ' '.$visactions->{'take'}.''.
+ ''.$visactions->{'dc_setcode'}.' '.
+ ' ');
+ }
+ } else {
+ my ($visible,$cansetvis,$vismsgs) = &visible_in_stdcat($cdom,$cnum,\%domconfig);
+ if (ref($visactions) eq 'HASH') {
+ if ($visible) {
+ $output .= ''.$visactions->{'vis'}.'
';
+ } else {
+ $output .= ''.$visactions->{'miss'}.'
'
+ .$visactions->{'yous'}.
+ ''.$visactions->{'gen'}.' '.$visactions->{'coca'};
+ if (ref($vismsgs) eq 'ARRAY') {
+ $output .= ' '.$visactions->{'make'}.'
';
+ foreach my $item (@{$vismsgs}) {
+ $output .= ''.$visactions->{$item}.' ';
+ }
+ $output .= ' ';
}
- $output .= ' ';
+ $output .= '';
}
- $output .= '';
}
}
- $output .= '';
+ $output .= &Apache::lonhtmlcommon::end_pick_box().' ';
+ unless ($readonly) {
+ $output .= ' ';
+ }
+ $output .= ' '
+ .' '."\n"
+ .$additional.'';
$r->print($output);
return;
}
-sub visible_in_cat {
- my ($cdom,$cnum) = @_;
- my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$cdom);
- my ($cathash,%settable,@vismsgs,$cansetvis);
- my %visactions = &Apache::lonlocal::texthash(
- vis => 'Your course/community currently appears in the Course/Community Catalog for this domain.',
- gen => 'Courses can be both self-cataloging, based on an institutional code (e.g., fs08phy231), or can be assigned categories from a hierarchy defined for the domain.',
- miss => 'Your course/community does not currently appear in the Course/Community Catalog for this domain.',
- yous => 'You should remedy this if you plan to allow self-enrollment, otherwise students will have difficulty finding your course.',
- coca => 'Courses can be absent from the Catalog, because they do not have an institutional code, have no assigned category, or have been specifically excluded.',
- make => 'Make any changes to self-enrollment settings below, click "Save", then take action to include the course in the Catalog:',
- take => 'Take the following action to ensure the course appears in the Catalog:',
- dc_unhide => 'Ask a domain coordinator to change the "Exclude from course catalog" setting.',
- dc_addinst => 'Ask a domain coordinator to enable display the catalog of "Official courses (with institutional codes)".',
- dc_instcode => 'Ask a domain coordinator to assign an institutional code (if this is an official course).',
- dc_catalog => 'Ask a domain coordinator to enable or create at least one course category in the domain.',
- dc_categories => 'Ask a domain coordinator to create a hierarchy of categories and sub categories for courses in the domain.',
- dc_chgcat => 'Ask a domain coordinator to change the category assigned to the course, as the one currently assigned is no longer used in the domain',
- dc_addcat => 'Ask a domain coordinator to assign a category to the course.',
- );
- $visactions{'unhide'} = &mt('Use [_1]Categorize course[_2] to change the "Exclude from course catalog" setting.','',' "');
- $visactions{'chgcat'} = &mt('Use [_1]Categorize course[_2] to change the category assigned to the course, as the one currently assigned is no longer used in the domain.','"',' "');
- $visactions{'addcat'} = &mt('Use [_1]Categorize course[_2] to assign a category to the course.','"',' "');
- if (ref($domconf{'coursecategories'}) eq 'HASH') {
- if ($domconf{'coursecategories'}{'togglecats'} eq 'crs') {
+sub get_noedit_fields {
+ my ($cdom,$cnum,$crstype,$row) = @_;
+ my %noedit;
+ if (ref($row) eq 'ARRAY') {
+ my %settings = &Apache::lonnet::get('environment',['internal.coursecode','internal.textbook',
+ 'internal.selfenrollmgrdc',
+ 'internal.selfenrollmgrcc'],$cdom,$cnum);
+ my $type = &Apache::lonuserutils::get_extended_type($cdom,$cnum,$crstype,\%settings);
+ my (%specific_managebydc,%specific_managebycc,%default_managebydc);
+ map { $specific_managebydc{$_} = 1; } (split(/,/,$settings{'internal.selfenrollmgrdc'}));
+ map { $specific_managebycc{$_} = 1; } (split(/,/,$settings{'internal.selfenrollmgrcc'}));
+ my %domdefaults = &Apache::lonnet::get_domain_defaults($cdom);
+ map { $default_managebydc{$_} = 1; } (split(/,/,$domdefaults{$type.'selfenrolladmdc'}));
+
+ foreach my $item (@{$row}) {
+ next if ($specific_managebycc{$item});
+ if (($specific_managebydc{$item}) || ($default_managebydc{$item})) {
+ $noedit{$item} = 1;
+ }
+ }
+ }
+ return %noedit;
+}
+
+sub visible_in_stdcat {
+ my ($cdom,$cnum,$domconf) = @_;
+ my ($cathash,%settable,@vismsgs,$cansetvis,$visible);
+ unless (ref($domconf) eq 'HASH') {
+ return ($visible,$cansetvis,\@vismsgs);
+ }
+ if (ref($domconf->{'coursecategories'}) eq 'HASH') {
+ if ($domconf->{'coursecategories'}{'togglecats'} eq 'crs') {
$settable{'togglecats'} = 1;
}
- if ($domconf{'coursecategories'}{'categorize'} eq 'crs') {
+ if ($domconf->{'coursecategories'}{'categorize'} eq 'crs') {
$settable{'categorize'} = 1;
}
- $cathash = $domconf{'coursecategories'}{'cats'};
+ $cathash = $domconf->{'coursecategories'}{'cats'};
}
if ($settable{'togglecats'} && $settable{'categorize'}) {
$cansetvis = &mt('You are able to both assign a course category and choose to exclude this course from the catalog.');
@@ -5380,10 +6375,10 @@ sub visible_in_cat {
my %currsettings =
&Apache::lonnet::get('environment',['hidefromcat','categories','internal.coursecode'],
$cdom,$cnum);
- my $visible = 0;
+ $visible = 0;
if ($currsettings{'internal.coursecode'} ne '') {
- if (ref($domconf{'coursecategories'}) eq 'HASH') {
- $cathash = $domconf{'coursecategories'}{'cats'};
+ if (ref($domconf->{'coursecategories'}) eq 'HASH') {
+ $cathash = $domconf->{'coursecategories'}{'cats'};
if (ref($cathash) eq 'HASH') {
if ($cathash->{'instcode::0'} eq '') {
push(@vismsgs,'dc_addinst');
@@ -5407,8 +6402,8 @@ sub visible_in_cat {
}
if ($currsettings{'categories'} ne '') {
my $cathash;
- if (ref($domconf{'coursecategories'}) eq 'HASH') {
- $cathash = $domconf{'coursecategories'}{'cats'};
+ if (ref($domconf->{'coursecategories'}) eq 'HASH') {
+ $cathash = $domconf->{'coursecategories'}{'cats'};
if (ref($cathash) eq 'HASH') {
if (keys(%{$cathash}) == 0) {
push(@vismsgs,'dc_catalog');
@@ -5454,7 +6449,33 @@ sub visible_in_cat {
unshift(@vismsgs,'dc_unhide')
}
}
- return ($visible,$cansetvis,\@vismsgs,\%visactions);
+ return ($visible,$cansetvis,\@vismsgs);
+}
+
+sub cat_visibility {
+ my %visactions = &Apache::lonlocal::texthash(
+ vis => 'This course/community currently appears in the Course/Community Catalog for this domain.',
+ gen => 'Courses can be both self-cataloging, based on an institutional code (e.g., fs08phy231), or can be assigned categories from a hierarchy defined for the domain.',
+ miss => 'This course/community does not currently appear in the Course/Community Catalog for this domain.',
+ none => 'Display of a course catalog is disabled for this domain.',
+ yous => 'You should remedy this if you plan to allow self-enrollment, otherwise students will have difficulty finding this course.',
+ coca => 'Courses can be absent from the Catalog, because they do not have an institutional code, have no assigned category, or have been specifically excluded.',
+ make => 'Make any changes to self-enrollment settings below, click "Save", then take action to include the course in the Catalog:',
+ take => 'Take the following action to ensure the course appears in the Catalog:',
+ dc_chgconf => 'Ask a domain coordinator to change the Catalog type for this domain.',
+ dc_setcode => 'Ask a domain coordinator to assign a six character code to the course',
+ dc_unhide => 'Ask a domain coordinator to change the "Exclude from course catalog" setting.',
+ dc_addinst => 'Ask a domain coordinator to enable display the catalog of "Official courses (with institutional codes)".',
+ dc_instcode => 'Ask a domain coordinator to assign an institutional code (if this is an official course).',
+ dc_catalog => 'Ask a domain coordinator to enable or create at least one course category in the domain.',
+ dc_categories => 'Ask a domain coordinator to create a hierarchy of categories and sub categories for courses in the domain.',
+ dc_chgcat => 'Ask a domain coordinator to change the category assigned to the course, as the one currently assigned is no longer used in the domain',
+ dc_addcat => 'Ask a domain coordinator to assign a category to the course.',
+ );
+ $visactions{'unhide'} = &mt('Use [_1]Categorize course[_2] to change the "Exclude from course catalog" setting.','',' "');
+ $visactions{'chgcat'} = &mt('Use [_1]Categorize course[_2] to change the category assigned to the course, as the one currently assigned is no longer used in the domain.','"',' "');
+ $visactions{'addcat'} = &mt('Use [_1]Categorize course[_2] to assign a category to the course.','"',' "');
+ return \%visactions;
}
sub new_selfenroll_dom_row {
@@ -5480,12 +6501,16 @@ sub new_selfenroll_dom_row {
}
sub selfenroll_inst_types {
- my ($num,$currdom,$currinsttypes) = @_;
+ my ($num,$currdom,$currinsttypes,$readonly) = @_;
my $output;
my $numinrow = 4;
my $count = 0;
my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($currdom);
my $othervalue = 'any';
+ my $disabled;
+ if ($readonly) {
+ $disabled = ' disabled="disabled"';
+ }
if ((ref($types) eq 'ARRAY') && (ref($usertypes) eq 'HASH')) {
if (keys(%{$usertypes}) > 0) {
$othervalue = 'other';
@@ -5510,7 +6535,7 @@ sub selfenroll_inst_types {
$output .= 'checked="checked"';
}
}
- $output .= ' name="selfenroll_types_'.$num.'" />'.$usertypes->{$type}.'';
+ $output .= ' name="selfenroll_types_'.$num.'"'.$disabled.' />'.$usertypes->{$type}.'';
}
$count ++;
}
@@ -5533,7 +6558,7 @@ sub selfenroll_inst_types {
} else {
$output .= ' checked="checked"';
}
- $output .= ' name="selfenroll_types_'.$num.'" />'.$othertitle.'';
+ $output .= ' name="selfenroll_types_'.$num.'"'.$disabled.' />'.$othertitle.'';
}
return $output;
}
@@ -5554,9 +6579,9 @@ sub selfenroll_date_forms {
}
sub print_userchangelogs_display {
- my ($r,$context,$permission) = @_;
+ my ($r,$context,$permission,$brcrum) = @_;
my $formname = 'rolelog';
- my ($username,$domain,$crstype,%roleslog);
+ my ($username,$domain,$crstype,$viewablesec,%roleslog);
if ($context eq 'domain') {
$domain = $env{'request.role.domain'};
%roleslog=&Apache::lonnet::dump_dom('nohist_rolelog',$domain);
@@ -5565,6 +6590,7 @@ sub print_userchangelogs_display {
$domain = $env{'course.'.$env{'request.course.id'}.'.domain'};
$username = $env{'course.'.$env{'request.course.id'}.'.num'};
$crstype = &Apache::loncommon::course_type();
+ $viewablesec = &Apache::lonuserutils::viewable_section($permission);
my %saveable_parameters = ('show' => 'scalar',);
&Apache::loncommon::store_course_settings('roles_log',
\%saveable_parameters);
@@ -5584,6 +6610,32 @@ sub print_userchangelogs_display {
}
if ((keys(%roleslog))[0]=~/^error\:/) { undef(%roleslog); }
+ my $helpitem;
+ if ($context eq 'course') {
+ $helpitem = 'Course_User_Logs';
+ }
+ push (@{$brcrum},
+ {href => '/adm/createuser?action=changelogs',
+ text => 'User Management Logs',
+ help => $helpitem});
+ my $bread_crumbs_component = 'User Changes';
+ my $args = { bread_crumbs => $brcrum,
+ bread_crumbs_component => $bread_crumbs_component};
+
+ # Create navigation javascript
+ my $jsnav = &userlogdisplay_js($formname);
+
+ my $jscript = (<
+//
+
+ENDSCRIPT
+
+ # print page header
+ $r->print(&header($jscript,$args));
+
# set defaults
my $now = time();
my $defstart = $now - (7*24*3600); #7 days ago
@@ -5616,7 +6668,9 @@ sub print_userchangelogs_display {
my ($minshown,$maxshown);
$minshown = 1;
my $count = 0;
- if ($curr{'show'} ne &mt('all')) {
+ if ($curr{'show'} =~ /\D/) {
+ $curr{'page'} = 1;
+ } else {
$maxshown = $curr{'page'} * $curr{'show'};
if ($curr{'page'} > 1) {
$minshown = 1 + ($curr{'page'} - 1) * $curr{'show'};
@@ -5628,8 +6682,6 @@ sub print_userchangelogs_display {
&role_display_filter($context,$formname,$domain,$username,\%curr,
$version,$crstype));
- # Create navigation
- my ($nav_script,$nav_links) = &userlogdisplay_nav($formname,\%curr,$more_records);
my $showntableheader = 0;
# Table Header
@@ -5654,7 +6706,7 @@ sub print_userchangelogs_display {
foreach my $id (sort { $roleslog{$b}{'exe_time'}<=>$roleslog{$a}{'exe_time'} } (keys(%roleslog))) {
next if (($roleslog{$id}{'exe_time'} < $curr{'rolelog_start_date'}) ||
($roleslog{$id}{'exe_time'} > $curr{'rolelog_end_date'}));
- if ($curr{'show'} ne &mt('all')) {
+ if ($curr{'show'} !~ /\D/) {
if ($count >= $curr{'page'} * $curr{'show'}) {
$more_records = 1;
last;
@@ -5670,12 +6722,13 @@ sub print_userchangelogs_display {
next if ($roleslog{$id}{'logentry'}{'context'} ne $curr{'chgcontext'});
}
}
+ if (($context eq 'course') && ($viewablesec ne '')) {
+ next if ($roleslog{$id}{'logentry'}{'section'} ne $viewablesec);
+ }
$count ++;
next if ($count < $minshown);
unless ($showntableheader) {
- $r->print($nav_script
- .$nav_links
- .&Apache::loncommon::start_data_table()
+ $r->print(&Apache::loncommon::start_data_table()
.$tableheader);
$r->rflush();
$showntableheader = 1;
@@ -5736,8 +6789,8 @@ sub print_userchangelogs_display {
}
if ($showntableheader) { # Table footer, if content displayed above
- $r->print(&Apache::loncommon::end_data_table()
- .$nav_links);
+ $r->print(&Apache::loncommon::end_data_table().
+ &userlogdisplay_navlinks(\%curr,$more_records));
} else { # No content displayed above
$r->print(''
.&mt('There are no records to display.')
@@ -5753,15 +6806,331 @@ sub print_userchangelogs_display {
return;
}
-sub userlogdisplay_nav {
- my ($formname,$curr,$more_records) = @_;
- my ($nav_script,$nav_links);
- if (ref($curr) eq 'HASH') {
- # Create Navigation:
- # Navigation Script
- $nav_script = <<"ENDSCRIPT";
+sub print_useraccesslogs_display {
+ my ($r,$uname,$udom,$permission,$brcrum) = @_;
+ my $formname = 'accesslog';
+ my $form = 'document.accesslog';
+
+# set breadcrumbs
+ my %breadcrumb_text = &singleuser_breadcrumb();
+ push (@{$brcrum},
+ {href => "javascript:backPage($form)",
+ text => $breadcrumb_text{'search'}});
+ my (@prevphases,$prevphasestr);
+ if ($env{'form.prevphases'}) {
+ @prevphases = split(/,/,$env{'form.prevphases'});
+ $prevphasestr = $env{'form.prevphases'};
+ }
+ if (($env{'form.phase'} eq 'userpicked') || (grep(/^userpicked$/,@prevphases))) {
+ push(@{$brcrum},
+ {href => "javascript:backPage($form,'get_user_info','select')",
+ text => $breadcrumb_text{'userpicked'}});
+ if ($env{'form.phase'} eq 'userpicked') {
+ $prevphasestr = 'userpicked';
+ }
+ }
+ push(@{$brcrum},
+ {href => '/adm/createuser?action=accesslogs',
+ text => 'User access logs',
+ help => 'User_Access_Logs'});
+ my $bread_crumbs_component = 'User Access Logs';
+ my $args = { bread_crumbs => $brcrum,
+ bread_crumbs_component => 'User Management'};
+
+# set javascript
+ my ($jsback,$elements) = &crumb_utilities();
+ my $jsnav = &userlogdisplay_js($formname);
+
+ my $jscript = (<
//
+
+
+ENDSCRIPT
+
+# print page header
+ $r->print(&header($jscript,$args));
+
+# early out unless log data can be displayed.
+ unless ($permission->{'activity'}) {
+ $r->print(''
+ .&mt('You do not have rights to display user access logs.')
+ .'
'
+ .&earlyout_accesslog_form($formname,$prevphasestr,$udom));
+ return;
+ }
+
+ unless ($udom eq $env{'request.role.domain'}) {
+ $r->print(''
+ .&mt("User's domain must match role's domain")
+ .'
'
+ .&earlyout_accesslog_form($formname,$prevphasestr,$udom));
+ return;
+ }
+
+ if (($uname eq '') || ($udom eq '')) {
+ $r->print(''
+ .&mt('Invalid username or domain')
+ .'
'
+ .&earlyout_accesslog_form($formname,$prevphasestr,$udom));
+ return;
+ }
+
+# set defaults
+ my $now = time();
+ my $defstart = $now - (7*24*3600);
+ my %defaults = (
+ page => '1',
+ show => '10',
+ activity => 'any',
+ accesslog_start_date => $defstart,
+ accesslog_end_date => $now,
+ );
+ my $more_records = 0;
+
+# set current
+ my %curr;
+ foreach my $item ('show','page','activity') {
+ $curr{$item} = $env{'form.'.$item};
+ }
+ my ($startdate,$enddate) =
+ &Apache::lonuserutils::get_dates_from_form('accesslog_start_date','accesslog_end_date');
+ $curr{'accesslog_start_date'} = $startdate;
+ $curr{'accesslog_end_date'} = $enddate;
+ foreach my $key (keys(%defaults)) {
+ if ($curr{$key} eq '') {
+ $curr{$key} = $defaults{$key};
+ }
+ }
+ my ($minshown,$maxshown);
+ $minshown = 1;
+ my $count = 0;
+ if ($curr{'show'} =~ /\D/) {
+ $curr{'page'} = 1;
+ } else {
+ $maxshown = $curr{'page'} * $curr{'show'};
+ if ($curr{'page'} > 1) {
+ $minshown = 1 + ($curr{'page'} - 1) * $curr{'show'};
+ }
+ }
+
+# form header
+ $r->print('');
+ return;
+}
+
+sub earlyout_accesslog_form {
+ my ($formname,$prevphasestr,$udom) = @_;
+ my $srchterm = &HTML::Entities::encode($env{'form.srchterm'},'<>"&');
+ return <<"END";
+
+END
+}
+
+sub activity_display_filter {
+ my ($formname,$curr) = @_;
+ my $nolink = 1;
+ my $output = ''.
+ ''.&mt('Actions/page:').' '.
+ &Apache::lonmeta::selectbox('show',$curr->{'show'},undef,
+ (&mt('all'),5,10,20,50,100,1000,10000)).
+ ' ';
+ my $startform =
+ &Apache::lonhtmlcommon::date_setter($formname,'accesslog_start_date',
+ $curr->{'accesslog_start_date'},undef,
+ undef,undef,undef,undef,undef,undef,$nolink);
+ my $endform =
+ &Apache::lonhtmlcommon::date_setter($formname,'accesslog_end_date',
+ $curr->{'accesslog_end_date'},undef,
+ undef,undef,undef,undef,undef,undef,$nolink);
+ my %lt = &Apache::lonlocal::texthash (
+ activity => 'Activity',
+ Role => 'Role selection',
+ log => 'Log-in or Logout',
+ );
+ $output .= ''.&mt('Window during which actions occurred:').' '.
+ ''.&mt('After:').
+ ' '.$startform.' '.
+ ''.&mt('Before:').' '.
+ ''.$endform.'
'.
+ ' '.
+ ' '.
+ ''.&mt('Activities').' '.
+ '{'activity'} eq 'any') {
+ $output .= ' selected="selected"';
+ }
+ $output .= '>'.&mt('Any').' '."\n";
+ foreach my $activity ('Role','log') {
+ my $selstr = '';
+ if ($activity eq $curr->{'activity'}) {
+ $selstr = ' selected="selected"';
+ }
+ $output .= ''.$lt{$activity}.' ';
+ }
+ $output .= ' '.
+ '
';
+ # Update Display button
+ $output .= ''
+ .' '
+ .'
';
+ return $output;
+}
+
+sub userlogdisplay_js {
+ my ($formname) = @_;
+ return <<"ENDSCRIPT";
+
function chgPage(caller) {
if (caller == 'previous') {
document.$formname.page.value --;
@@ -5772,28 +7141,30 @@ function chgPage(caller) {
document.$formname.submit();
return;
}
-// ]]>
-
ENDSCRIPT
- # Navigation Buttons
- $nav_links = '';
- if (($curr->{'page'} > 1) || ($more_records)) {
- if ($curr->{'page'} > 1) {
- $nav_links .= ' ';
- }
- if ($more_records) {
- $nav_links .= ' ';
- }
+}
+
+sub userlogdisplay_navlinks {
+ my ($curr,$more_records) = @_;
+ return unless(ref($curr) eq 'HASH');
+ # Navigation Buttons
+ my $nav_links = '
';
+ if (($curr->{'page'} > 1) || ($more_records)) {
+ if (($curr->{'page'} > 1) && ($curr->{'show'} !~ /\D/)) {
+ $nav_links .= ' ';
+ }
+ if ($more_records) {
+ $nav_links .= ' ';
}
- $nav_links .= '
';
}
- return ($nav_script,$nav_links);
+ $nav_links .= '
';
+ return $nav_links;
}
sub role_display_filter {
@@ -5850,7 +7221,7 @@ sub role_display_filter {
&mt('Context:').'';
my @posscontexts;
if ($context eq 'course') {
- @posscontexts = ('any','auto','updatenow','createcourse','course','domain','selfenroll','requestcourses');
+ @posscontexts = ('any','automated','updatenow','createcourse','course','domain','selfenroll','requestcourses');
} elsif ($context eq 'domain') {
@posscontexts = ('any','domain','requestauthor','domconfig','server');
} else {
@@ -5862,7 +7233,7 @@ sub role_display_filter {
$selstr = ' selected="selected"';
}
if ($context eq 'course') {
- if (($chgtype eq 'auto') || ($chgtype eq 'updatenow')) {
+ if (($chgtype eq 'automated') || ($chgtype eq 'updatenow')) {
next if (!&Apache::lonnet::auto_run($cnum,$cdom));
}
}
@@ -5898,7 +7269,7 @@ sub rolechg_contexts {
if ($context eq 'course') {
%lt = &Apache::lonlocal::texthash (
any => 'Any',
- auto => 'Automated enrollment',
+ automated => 'Automated Enrollment',
updatenow => 'Roster Update',
createcourse => 'Course Creation',
course => 'User Management in course',
@@ -5973,13 +7344,29 @@ sub user_search_result {
}
}
if ($response ne '') {
- $response = ''.$response.' ';
+ $response = ''.$response.' ';
}
if ($srch->{'srchin'} eq 'instd') {
- my $instd_chk = &directorysrch_check($srch);
+ my $instd_chk = &instdirectorysrch_check($srch);
if ($instd_chk ne 'ok') {
- $response = ''.$instd_chk.' '.
- ' '.&mt('You may want to search in the LON-CAPA domain instead of the institutional directory.').' ';
+ my $domd_chk = &domdirectorysrch_check($srch);
+ $response .= ''.$instd_chk.' ';
+ if ($domd_chk eq 'ok') {
+ $response .= &mt('You may want to search in the LON-CAPA domain instead of the institutional directory.');
+ }
+ $response .= ' ';
+ }
+ } else {
+ unless (($context eq 'requestcrs') && ($srch->{'srchtype'} eq 'exact')) {
+ my $domd_chk = &domdirectorysrch_check($srch);
+ if ($domd_chk ne 'ok') {
+ my $instd_chk = &instdirectorysrch_check($srch);
+ $response .= ''.$domd_chk.' ';
+ if ($instd_chk eq 'ok') {
+ $response .= &mt('You may want to search in the institutional directory instead of the LON-CAPA domain.');
+ }
+ $response .= ' ';
+ }
}
}
if ($response ne '') {
@@ -6009,6 +7396,9 @@ sub user_search_result {
&build_search_response($context,$srch,%srch_results);
} else {
$currstate = 'modify';
+ if ($env{'form.action'} eq 'accesslogs') {
+ $currstate = 'activity';
+ }
my $uname = $srch->{'srchterm'};
my $udom = $srch->{'srchdomain'};
$srch_results{$uname.':'.$udom} =
@@ -6075,7 +7465,7 @@ sub user_search_result {
&mt('Institutional directory search is not available in domain: [_1]',$showdom).
' '.
&mt('You may want to search in the LON-CAPA domain instead of the institutional directory.').
- ' ';
+ ' ';
}
}
} else {
@@ -6143,18 +7533,38 @@ sub user_search_result {
($currstate,$response,$forcenewuser) =
&build_search_response($context,$srch,%srch_results);
} else {
- my $showdom = &display_domain_info($srch->{'srchdomain'}); $response = ''.
+ my $showdom = &display_domain_info($srch->{'srchdomain'});
+ $response = ''.
&mt('Institutional directory search is not available in domain: [_1]',$showdom).
' '.
&mt('You may want to search in the LON-CAPA domain instead of the institutional directory.').
- ' ';
+ ' ';
}
}
}
return ($currstate,$response,$forcenewuser,\%srch_results);
}
-sub directorysrch_check {
+sub domdirectorysrch_check {
+ my ($srch) = @_;
+ my $response;
+ my %dom_inst_srch = &Apache::lonnet::get_dom('configuration',
+ ['directorysrch'],$srch->{'srchdomain'});
+ my $showdom = &display_domain_info($srch->{'srchdomain'});
+ if (ref($dom_inst_srch{'directorysrch'}) eq 'HASH') {
+ if ($dom_inst_srch{'directorysrch'}{'lcavailable'} eq '0') {
+ return &mt('LON-CAPA directory search is not available in domain: [_1]',$showdom);
+ }
+ if ($dom_inst_srch{'directorysrch'}{'lclocalonly'}) {
+ if ($env{'request.role.domain'} ne $srch->{'srchdomain'}) {
+ return &mt('LON-CAPA directory search in domain: [_1] is only allowed for users with a current role in the domain.',$showdom);
+ }
+ }
+ }
+ return 'ok';
+}
+
+sub instdirectorysrch_check {
my ($srch) = @_;
my $can_search = 0;
my $response;
@@ -6276,7 +7686,11 @@ sub build_search_response {
$currstate = 'select';
} else {
if (keys(%srch_results) == 1) {
- $currstate = 'modify';
+ if ($env{'form.action'} eq 'accesslogs') {
+ $currstate = 'activity';
+ } else {
+ $currstate = 'modify';
+ }
$response = &mt("$single{$srch->{'srchtype'}} was found for the $names{$srch->{'srchby'}} ([_1]) in $names{$srch->{'srchin'}}.",$srch->{'srchterm'});
if ($srch->{'srchin'} eq 'dom' || $srch->{'srchin'} eq 'instd') {
$response .= ': '.&display_domain_info($srch->{'srchdomain'});
@@ -6321,7 +7735,8 @@ sub build_search_response {
$createdom = $env{'form.coursedom'};
}
}
- if (!($srch->{'srchby'} eq 'uname' && $srch->{'srchin'} eq 'dom' && $srch->{'srchtype'} eq 'exact' && $srch->{'srchdomain'} eq $createdom)) {
+ unless (($env{'form.action'} eq 'accesslogs') || (($srch->{'srchby'} eq 'uname') && ($srch->{'srchin'} eq 'dom') &&
+ ($srch->{'srchtype'} eq 'exact') && ($srch->{'srchdomain'} eq $createdom))) {
my $cancreate =
&Apache::lonuserutils::can_create_user($createdom,$context);
my $targetdom = ''.$createdom.' ';
@@ -6356,7 +7771,7 @@ sub build_search_response {
.&mt('Please contact the [_1]helpdesk[_2] if you need to create a new user.'
,' '
,' ')
- .' ';
+ .' ';
}
}
}
@@ -6423,7 +7838,8 @@ function backPage(formname,prevphase,pre
}
sub course_level_table {
- my (%inccourses) = @_;
+ my ($inccourses,$showcredits,$defaultcredits) = @_;
+ return unless (ref($inccourses) eq 'HASH');
my $table = '';
# Custom Roles?
@@ -6438,11 +7854,12 @@ sub course_level_table {
'rol' => "Role",
'ext' => "Extent",
'grs' => "Section",
+ 'crd' => "Credits",
'sta' => "Start",
'end' => "End"
);
- foreach my $protectedcourse (sort(keys(%inccourses))) {
+ foreach my $protectedcourse (sort(keys(%{$inccourses}))) {
my $thiscourse=$protectedcourse;
$thiscourse=~s:_:/:g;
my %coursedata=&Apache::lonnet::coursedescription($thiscourse);
@@ -6464,12 +7881,14 @@ sub course_level_table {
if ((&Apache::lonnet::allowed('c'.$role,$thiscourse)) ||
((($role eq 'cc') || ($role eq 'co')) && ($isowner))) {
$table .= &course_level_row($protectedcourse,$role,$area,$domain,
- $plrole,\%sections_count,\%lt);
+ $plrole,\%sections_count,\%lt,
+ $showcredits,$defaultcredits,$crstype);
} elsif ($env{'request.course.sec'} ne '') {
if (&Apache::lonnet::allowed('c'.$role,$thiscourse.'/'.
$env{'request.course.sec'})) {
$table .= &course_level_row($protectedcourse,$role,$area,$domain,
- $plrole,\%sections_count,\%lt);
+ $plrole,\%sections_count,\%lt,
+ $showcredits,$defaultcredits,$crstype);
}
}
}
@@ -6478,7 +7897,8 @@ sub course_level_table {
next if ($crstype eq 'Community' && $customroles{$cust} =~ /bre\&S/);
my $role = 'cr_cr_'.$env{'user.domain'}.'_'.$env{'user.name'}.'_'.$cust;
$table .= &course_level_row($protectedcourse,$role,$area,$domain,
- $cust,\%sections_count,\%lt);
+ $cust,\%sections_count,\%lt,
+ $showcredits,$defaultcredits,$crstype);
}
}
}
@@ -6491,8 +7911,14 @@ sub course_level_table {
$result .=
&Apache::loncommon::start_data_table().
&Apache::loncommon::start_data_table_header_row().
-' '.$lt{'act'}.' '.$lt{'rol'}.' '.$lt{'ext'}.'
-'.$lt{'grs'}.' '.$lt{'sta'}.' '.$lt{'end'}.' '.
+''.$lt{'act'}.' '.$lt{'rol'}.' '."\n".
+''.$lt{'ext'}.' '."\n";
+ if ($showcredits) {
+ $result .= $lt{'crd'}.' ';
+ }
+ $result .=
+''.$lt{'grs'}.' '.$lt{'sta'}.' '."\n".
+''.$lt{'end'}.' '.
&Apache::loncommon::end_data_table_header_row().
$table.
&Apache::loncommon::end_data_table();
@@ -6500,12 +7926,21 @@ $table.
}
sub course_level_row {
- my ($protectedcourse,$role,$area,$domain,$plrole,$sections_count,$lt) = @_;
+ my ($protectedcourse,$role,$area,$domain,$plrole,$sections_count,
+ $lt,$showcredits,$defaultcredits,$crstype) = @_;
+ my $creditem;
my $row = &Apache::loncommon::start_data_table_row().
' '."\n".
' '.$plrole.' '."\n".
' '.$area.' Domain: '.$domain.' '."\n";
+ if (($showcredits) && ($role eq 'st') && ($crstype eq 'Course')) {
+ $row .=
+ ' ';
+ } else {
+ $row .= ' ';
+ }
if (($role eq 'cc') || ($role eq 'co')) {
$row .= ' ';
} elsif ($env{'request.course.sec'} ne '') {
@@ -6531,7 +7966,7 @@ sub course_level_row {
''."\n";
} else {
$row .= ' '."\n";
+ 'name="sec_'.$protectedcourse.'_'.$role.'" />'."\n";
}
}
$row .= < '.
@@ -6555,7 +7990,11 @@ sub course_level_dc {
' ';
my $courseform=&Apache::loncommon::selectcourse_link
('cu','dccourse','dcdomain','coursedesc',undef,undef,'Select','crstype');
- my $cb_jscript = &Apache::loncommon::coursebrowser_javascript($dcdom,'currsec','cu','role','Course/Community Browser');
+ my $credit_elem;
+ if ($showcredits) {
+ $credit_elem = 'credits';
+ }
+ my $cb_jscript = &Apache::loncommon::coursebrowser_javascript($dcdom,'currsec','cu','role','Course/Community Browser',$credit_elem);
my %lt=&Apache::lonlocal::texthash(
'rol' => "Role",
'grs' => "Section",
@@ -6565,39 +8004,47 @@ sub course_level_dc {
'end' => "End",
'ssd' => "Set Start Date",
'sed' => "Set End Date",
- 'scc' => "Course/Community"
+ 'scc' => "Course/Community",
+ 'crd' => "Credits",
);
my $header = ''.&mt('Course/Community Level').' '.
&Apache::loncommon::start_data_table().
&Apache::loncommon::start_data_table_header_row().
- ''.$lt{'scc'}.' '.$lt{'rol'}.' '.$lt{'grs'}.' '.$lt{'sta'}.' '.$lt{'end'}.' '.
+ ''.$lt{'scc'}.' '.$lt{'rol'}.' '."\n".
+ ''.$lt{'grs'}.' '."\n";
+ $header .= ''.$lt{'crd'}.' '."\n" if ($showcredits);
+ $header .= ''.$lt{'sta'}.' '.$lt{'end'}.' '."\n".
&Apache::loncommon::end_data_table_header_row();
my $otheritems = &Apache::loncommon::start_data_table_row()."\n".
' '.
$courseform.(' ' x4).' '."\n".
- ''."\n";
+ ''."\n";
foreach my $role (@roles) {
my $plrole=&Apache::lonnet::plaintext($role);
- $otheritems .= ' '.$plrole;
+ $otheritems .= ' '.$plrole.' ';
}
- if ( keys %customroles > 0) {
- foreach my $cust (sort keys %customroles) {
+ if ( keys(%customroles) > 0) {
+ foreach my $cust (sort(keys(%customroles))) {
my $custrole='cr_cr_'.$env{'user.domain'}.
'_'.$env{'user.name'}.'_'.$cust;
- $otheritems .= ' '.$cust;
+ $otheritems .= ' '.$cust.' ';
}
}
$otheritems .= ' '.
' ';
+ ' '."\n";
+ if ($showcredits) {
+ $otheritems .= ' '."\n".
+ ' '."\n";
+ }
$otheritems .= <
{'selfenroll_'.$type.'_date'};
$newenrolldate{$type} = &Apache::lonhtmlcommon::get_date_from_form('selfenroll_'.$type.'_date');
if ($newenrolldate{$type} ne $currenrolldate{$type}) {
$changes{'internal.selfenroll_'.$type.'_date'} = $newenrolldate{$type};
@@ -6633,15 +8084,14 @@ sub update_selfenroll_config {
} elsif ($item eq 'access_dates') {
my (%currdate,%newdate);
foreach my $type ('start','end') {
- $currdate{$type} = $env{'course.'.$env{'request.course.id'}.'.internal.selfenroll_'.$type.'_access'};
+ $currdate{$type} = $currsettings->{'selfenroll_'.$type.'_access'};
$newdate{$type} = &Apache::lonhtmlcommon::get_date_from_form('selfenroll_'.$type.'_access');
if ($newdate{$type} ne $currdate{$type}) {
$changes{'internal.selfenroll_'.$type.'_access'} = $newdate{$type};
}
}
} elsif ($item eq 'types') {
- $curr_types =
- $env{'course.'.$env{'request.course.id'}.'.internal.selfenroll_'.$item};
+ $curr_types = $currsettings->{'selfenroll_'.$item};
if ($env{'form.selfenroll_all'}) {
if ($curr_types ne '*') {
$changes{'internal.selfenroll_types'} = '*';
@@ -6710,9 +8160,9 @@ sub update_selfenroll_config {
my $newlimit = $env{'form.selfenroll_limit'};
my $newcap = $env{'form.selfenroll_cap'};
$newcap =~s/\s+//g;
- my $currlimit = $env{'course.'.$env{'request.course.id'}.'.internal.selfenroll_limit'};
+ my $currlimit = $currsettings->{'selfenroll_limit'};
$currlimit = 'none' if ($currlimit eq '');
- my $currcap = $env{'course.'.$env{'request.course.id'}.'.internal.selfenroll_cap'};
+ my $currcap = $currsettings->{'selfenroll_cap'};
if ($newlimit ne $currlimit) {
if ($newlimit ne 'none') {
if ($newcap =~ /^\d+$/) {
@@ -6721,7 +8171,8 @@ sub update_selfenroll_config {
}
$changes{'internal.selfenroll_limit'} = $newlimit;
} else {
- $warning{$item} = &mt('Maximum enrollment setting unchanged.').' '.&mt('The value provided was invalid - it must be a positive integer if enrollment is being limited.');
+ $warning{$item} = &mt('Maximum enrollment setting unchanged.').' '.
+ &mt('The value provided was invalid - it must be a positive integer if enrollment is being limited.');
}
} elsif ($currcap ne '') {
$changes{'internal.selfenroll_cap'} = '';
@@ -6733,13 +8184,14 @@ sub update_selfenroll_config {
$changes{'internal.selfenroll_cap'} = $newcap;
}
} else {
- $warning{$item} = &mt('Maximum enrollment setting unchanged.').' '.&mt('The value provided was invalid - it must be a positive integer if enrollment is being limited.');
+ $warning{$item} = &mt('Maximum enrollment setting unchanged.').' '.
+ &mt('The value provided was invalid - it must be a positive integer if enrollment is being limited.');
}
}
} elsif ($item eq 'approval') {
my (@currnotified,@newnotified);
- my $currapproval = $env{'course.'.$env{'request.course.id'}.'.internal.selfenroll_approval'};
- my $currnotifylist = $env{'course.'.$env{'request.course.id'}.'.internal.selfenroll_notifylist'};
+ my $currapproval = $currsettings->{'selfenroll_approval'};
+ my $currnotifylist = $currsettings->{'selfenroll_notifylist'};
if ($currnotifylist ne '') {
@currnotified = split(/,/,$currnotifylist);
@currnotified = sort(@currnotified);
@@ -6775,14 +8227,14 @@ sub update_selfenroll_config {
}
}
} else {
- my $curr_val =
- $env{'course.'.$env{'request.course.id'}.'.internal.selfenroll_'.$item};
+ my $curr_val = $currsettings->{'selfenroll_'.$item};
my $newval = $env{'form.selfenroll_'.$item};
if ($item eq 'section') {
$newval = $env{'form.sections'};
if (defined($curr_groups{$newval})) {
$newval = $curr_val;
- $warning{$item} = &mt('Section for self-enrolled users unchanged as the proposed section is a group').' '.&mt('Group names and section names must be distinct');
+ $warning{$item} = &mt('Section for self-enrolled users unchanged as the proposed section is a group').' '.
+ &mt('Group names and section names must be distinct');
} elsif ($newval eq 'all') {
$newval = $curr_val;
$warning{$item} = &mt('Section for self-enrolled users unchanged, as "all" is a reserved section name.');
@@ -6812,11 +8264,10 @@ sub update_selfenroll_config {
my %crsinfo = &Apache::lonnet::courseiddump($cdom,'.',1,'.','.',
$cnum,undef,undef,'Course');
my $chome = &Apache::lonnet::homeserver($cnum,$cdom);
- if (ref($crsinfo{$env{'request.course.id'}}) eq 'HASH') {
+ if (ref($crsinfo{$cid}) eq 'HASH') {
foreach my $item ('selfenroll_types','selfenroll_start_date','selfenroll_end_date') {
if (exists($changes{'internal.'.$item})) {
- $crsinfo{$env{'request.course.id'}}{$item} =
- $changes{'internal.'.$item};
+ $crsinfo{$cid}{$item} = $changes{'internal.'.$item};
}
}
my $crsputresult =
@@ -6853,7 +8304,7 @@ sub update_selfenroll_config {
if ($changes{'internal.selfenroll_cap'} ne '') {
$newcap = $changes{'internal.selfenroll_cap'}
} else {
- $newcap = $env{'course.'.$env{'request.course.id'}.'.internal.selfenroll_cap'};
+ $newcap = $currsettings->{'selfenroll_cap'};
}
if ($changes{'internal.selfenroll_limit'} eq 'none') {
$newval = &mt('No limit');
@@ -6863,7 +8314,7 @@ sub update_selfenroll_config {
} elsif ($changes{'internal.selfenroll_limit'} eq 'selfenrolled') {
$newval = &mt('New self-enrollment no longer allowed when total number of self-enrolled students reaches [_1].',$newcap);
} else {
- my $currlimit = $env{'course.'.$env{'request.course.id'}.'.internal.selfenroll_limit'};
+ my $currlimit = $currsettings->{'selfenroll_limit'};
if ($currlimit eq 'allstudents') {
$newval = &mt('New self-enrollment no longer allowed when total (all students) reaches [_1].',$newcap);
} elsif ($changes{'internal.selfenroll_limit'} eq 'selfenrolled') {
@@ -6875,24 +8326,24 @@ sub update_selfenroll_config {
} elsif ($item eq 'approval') {
if ((exists($changes{'internal.selfenroll_approval'})) ||
(exists($changes{'internal.selfenroll_notifylist'}))) {
+ my %selfdescs = &Apache::lonuserutils::selfenroll_default_descs();
my ($newval,$newnotify);
if (exists($changes{'internal.selfenroll_notifylist'})) {
$newnotify = $changes{'internal.selfenroll_notifylist'};
} else {
- $newnotify = $env{'course.'.$env{'request.course.id'}.'.internal.selfenroll_notifylist'};
+ $newnotify = $currsettings->{'selfenroll_notifylist'};
}
- if ($changes{'internal.selfenroll_approval'}) {
- $newval = &mt('Yes');
- } elsif ($changes{'internal.selfenroll_approval'} eq '0') {
- $newval = &mt('No');
+ if (exists($changes{'internal.selfenroll_approval'})) {
+ if ($changes{'internal.selfenroll_approval'} !~ /^[012]$/) {
+ $changes{'internal.selfenroll_approval'} = '0';
+ }
+ $newval = $selfdescs{'approval'}{$changes{'internal.selfenroll_approval'}};
} else {
- my $currapproval =
- $env{'course.'.$env{'request.course.id'}.'.internal.selfenroll_approval'};
- if ($currapproval) {
- $newval = &mt('Yes');
- } else {
- $newval = &mt('No');
+ my $currapproval = $currsettings->{'selfenroll_approval'};
+ if ($currapproval !~ /^[012]$/) {
+ $currapproval = 0;
}
+ $newval = $selfdescs{'approval'}{$currapproval};
}
$r->print(''.&mt('"[_1]" set to "[_2]".',$title,$newval));
if ($newnotify) {
@@ -6923,13 +8374,16 @@ sub update_selfenroll_config {
}
}
$r->print('');
- my %newenvhash;
- foreach my $key (keys(%changes)) {
- $newenvhash{'course.'.$env{'request.course.id'}.'.'.$key} = $changes{$key};
+ if ($env{'course.'.$cid.'.description'} ne '') {
+ my %newenvhash;
+ foreach my $key (keys(%changes)) {
+ $newenvhash{'course.'.$cid.'.'.$key} = $changes{$key};
+ }
+ &Apache::lonnet::appenv(\%newenvhash);
}
- &Apache::lonnet::appenv(\%newenvhash);
} else {
- $r->print(&mt('An error occurred when saving changes to self-enrollment settings in this course.').' '.&mt('The error was: [_1].',$putresult));
+ $r->print(&mt('An error occurred when saving changes to self-enrollment settings in this course.').' '.
+ &mt('The error was: [_1].',$putresult));
}
} else {
$r->print(&mt('No changes were made to the existing self-enrollment settings in this course.'));
@@ -6937,50 +8391,60 @@ sub update_selfenroll_config {
} else {
$r->print(&mt('No changes were made to the existing self-enrollment settings in this course.'));
}
- my ($visible,$cansetvis,$vismsgs,$visactions) = &visible_in_cat($cdom,$cnum);
- if (ref($visactions) eq 'HASH') {
- if (!$visible) {
+ my $visactions = &cat_visibility();
+ my ($cathash,%cattype);
+ my %domconfig = &Apache::lonnet::get_dom('configuration',['coursecategories'],$cdom);
+ if (ref($domconfig{'coursecategories'}) eq 'HASH') {
+ $cathash = $domconfig{'coursecategories'}{'cats'};
+ $cattype{'auth'} = $domconfig{'coursecategories'}{'auth'};
+ $cattype{'unauth'} = $domconfig{'coursecategories'}{'unauth'};
+ } else {
+ $cathash = {};
+ $cattype{'auth'} = 'std';
+ $cattype{'unauth'} = 'std';
+ }
+ if (($cattype{'auth'} eq 'none') && ($cattype{'unauth'} eq 'none')) {
+ $r->print(''.$visactions->{'miss'}.' '.$visactions->{'yous'}.
+ ' '.
+ ' '.$visactions->{'take'}.''.
+ ''.$visactions->{'dc_chgconf'}.' '.
+ ' ');
+ } elsif (($cattype{'auth'} !~ /^(std|domonly)$/) && ($cattype{'unauth'} !~ /^(std|domonly)$/)) {
+ if ($currsettings->{'uniquecode'}) {
+ $r->print(''.$visactions->{'vis'}.' ');
+ } else {
$r->print(''.$visactions->{'miss'}.' '.$visactions->{'yous'}.
- ' ');
- if (ref($vismsgs) eq 'ARRAY') {
- $r->print(' '.$visactions->{'take'}.'');
- foreach my $item (@{$vismsgs}) {
- $r->print(''.$visactions->{$item}.' ');
+ ' '.
+ ' '.$visactions->{'take'}.''.
+ ''.$visactions->{'dc_setcode'}.' '.
+ ' ');
+ }
+ } else {
+ my ($visible,$cansetvis,$vismsgs) = &visible_in_stdcat($cdom,$cnum,\%domconfig);
+ if (ref($visactions) eq 'HASH') {
+ if (!$visible) {
+ $r->print(''.$visactions->{'miss'}.' '.$visactions->{'yous'}.
+ ' ');
+ if (ref($vismsgs) eq 'ARRAY') {
+ $r->print(' '.$visactions->{'take'}.'');
+ foreach my $item (@{$vismsgs}) {
+ $r->print(''.$visactions->{$item}.' ');
+ }
+ $r->print(' ');
}
- $r->print(' ');
+ $r->print($cansetvis);
}
- $r->print($cansetvis);
}
}
return;
}
-sub get_selfenroll_titles {
- my @row = ('types','registered','enroll_dates','access_dates','section',
- 'approval','limit');
- my %lt = &Apache::lonlocal::texthash (
- types => 'Users allowed to self-enroll in this course',
- registered => 'Restrict self-enrollment to students officially registered for the course',
- enroll_dates => 'Dates self-enrollment available',
- access_dates => 'Course access dates assigned to self-enrolling users',
- section => 'Section assigned to self-enrolling users',
- approval => 'Self-enrollment requests need approval?',
- limit => 'Enrollment limit',
- );
- return (\@row,\%lt);
-}
-
#---------------------------------------------- end functions for &phase_two
#--------------------------------- functions for &phase_two and &phase_three
#--------------------------end of functions for &phase_two and &phase_three
-sub cid_to_cname(){
- my $courseid = shift;
- $courseid =~ s/^\///;
- $courseid =~ s/\//_/;
- return $env{'course.'.$courseid.'.description'};
-}
+
1;
__END__