'.
+ &mt('User Can Request Assignment of Domain Roles?').
+ '
'."\n".
+ &Apache::loncommon::start_data_table().
+ &build_tools_display($ccuname,$ccdomain,
+ 'requestauthor').
+ &Apache::loncommon::end_data_table();
+}
+
sub courserequest_titles {
my %titles = &Apache::lonlocal::texthash (
official => 'Official',
unofficial => 'Unofficial',
community => 'Communities',
+ textbook => 'Textbook',
+ placement => 'Placement Tests',
+ lti => 'LTI Provider',
norequest => 'Not allowed',
approval => 'Approval by Dom. Coord.',
validate => 'With validation',
@@ -464,10 +568,94 @@ sub courserequest_display {
return %titles;
}
+sub requestauthor_titles {
+ my %titles = &Apache::lonlocal::texthash (
+ norequest => 'Not allowed',
+ approval => 'Approval by Dom. Coord.',
+ automatic => 'Automatic approval',
+ );
+ return %titles;
+
+}
+
+sub requestauthor_display {
+ my %titles = &Apache::lonlocal::texthash (
+ approval => 'Yes, need approval',
+ automatic => 'Yes, automatic approval',
+ norequest => 'No',
+ );
+ 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'));
+ if ($uname eq '' || $udom eq '') {
+ $uname = $env{'user.name'};
+ $udom = $env{'user.domain'};
+ $isadv = $env{'user.adv'};
+ }
+ my (%userenv,%settings,$val);
+ my @options = ('automatic','approval');
+ %userenv =
+ &Apache::lonnet::userenvironment($udom,$uname,'requestauthor','inststatus');
+ if ($userenv{'requestauthor'}) {
+ $val = $userenv{'requestauthor'};
+ @{$inststatuses} = ('_custom_');
+ } else {
+ my %alltasks;
+ if (ref($domconfig->{'requestauthor'}) eq 'HASH') {
+ %settings = %{$domconfig->{'requestauthor'}};
+ if (($isadv) && ($settings{'_LC_adv'} ne '')) {
+ $val = $settings{'_LC_adv'};
+ @{$inststatuses} = ('_LC_adv_');
+ } else {
+ if ($userenv{'inststatus'} ne '') {
+ @{$inststatuses} = split(',',$userenv{'inststatus'});
+ } else {
+ @{$inststatuses} = ('default');
+ }
+ foreach my $status (@{$inststatuses}) {
+ if (exists($settings{$status})) {
+ my $value = $settings{$status};
+ next unless ($value);
+ unless (exists($alltasks{$value})) {
+ if (ref($alltasks{$value}) eq 'ARRAY') {
+ unless(grep(/^\Q$status\E$/,@{$alltasks{$value}})) {
+ push(@{$alltasks{$value}},$status);
+ }
+ } else {
+ @{$alltasks{$value}} = ($status);
+ }
+ }
+ }
+ }
+ foreach my $option (@options) {
+ if ($alltasks{$option}) {
+ $val = $option;
+ last;
+ }
+ }
+ }
+ }
+ }
+ return $val;
+}
+
# =================================================================== Phase one
sub print_username_entry_form {
- my ($r,$context,$response,$srch,$forcenewuser,$crstype) = @_;
+ my ($r,$context,$response,$srch,$forcenewuser,$crstype,$brcrum,
+ $permission) = @_;
my $defdom=$env{'request.role.domain'};
my $formtoset = 'crtuser';
if (exists($env{'form.startrolename'})) {
@@ -491,43 +679,65 @@ sub print_username_entry_form {
&& (&Apache::lonnet::allowed('mcr','/'))) {
$jscript .= &customrole_javascript();
}
- my %loaditems = (
- 'onload' => "javascript:setFormElements(document.$formtoset)",
- );
- my %breadcrumb_text = &singleuser_breadcrumb($crstype);
- my $start_page =
- &Apache::loncommon::start_page('User Management',
- $jscript,{'add_entries' => \%loaditems,});
- if ($env{'form.action'} eq 'custom') {
- &Apache::lonhtmlcommon::add_breadcrumb
- ({href=>"javascript:backPage(document.crtuser)",
- text=>"Pick custom role",});
- } else {
- &Apache::lonhtmlcommon::add_breadcrumb
- ({href=>"javascript:backPage(document.crtuser)",
- text=>$breadcrumb_text{'search'},
- faq=>282,bug=>'Instructor Interface',});
- }
my $helpitem = 'Course_Change_Privileges';
if ($env{'form.action'} eq 'custom') {
- $helpitem = 'Course_Editing_Custom_Roles';
+ if ($context eq 'course') {
+ $helpitem = 'Course_Editing_Custom_Roles';
+ } elsif ($context eq 'domain') {
+ $helpitem = 'Domain_Editing_Custom_Roles';
+ }
} elsif ($env{'form.action'} eq 'singlestudent') {
$helpitem = 'Course_Add_Student';
+ } elsif ($env{'form.action'} eq 'accesslogs') {
+ $helpitem = 'Domain_User_Access_Logs';
+ } elsif ($context eq 'author') {
+ $helpitem = 'Author_Change_Privileges';
+ } elsif ($context eq 'domain') {
+ if ($permission->{'cusr'}) {
+ $helpitem = 'Domain_Change_Privileges';
+ } elsif ($permission->{'view'}) {
+ $helpitem = 'Domain_View_Privileges';
+ } else {
+ undef($helpitem);
+ }
+ }
+ my %breadcrumb_text = &singleuser_breadcrumb($crstype,$context,$defdom);
+ if ($env{'form.action'} eq 'custom') {
+ push(@{$brcrum},
+ {href=>"javascript:backPage(document.crtuser)",
+ text=>"Pick custom role",
+ help => $helpitem,}
+ );
+ } else {
+ push (@{$brcrum},
+ {href => "javascript:backPage(document.crtuser)",
+ text => $breadcrumb_text{'search'},
+ help => $helpitem,
+ faq => 282,
+ bug => 'Instructor Interface',}
+ );
}
- my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('User Management',
- $helpitem);
+ my %loaditems = (
+ 'onload' => "javascript:setFormElements(document.$formtoset)",
+ );
+ my $args = {bread_crumbs => $brcrum,
+ bread_crumbs_component => 'User Management',
+ add_entries => \%loaditems,};
+ $r->print(&Apache::loncommon::start_page('User Management',$jscript,$args));
+
my %lt=&Apache::lonlocal::texthash(
'srst' => 'Search for a user and enroll as a student',
'srme' => 'Search for a user and enroll as a member',
-
'srad' => 'Search for a user and modify/add user information or roles',
+ 'srvu' => 'Search for a user and view user information and roles',
+ 'srva' => 'Search for a user and view access log information',
'usr' => "Username",
'dom' => "Domain",
'ecrp' => "Define or Edit Custom Role",
'nr' => "role name",
'cre' => "Next",
);
- $r->print($start_page."\n".$crumbs);
+
if ($env{'form.action'} eq 'custom') {
if (&Apache::lonnet::allowed('mcr','/')) {
my $newroletext = &mt('Define new custom role:');
@@ -567,20 +777,30 @@ sub print_username_entry_form {
}
} else {
my $actiontext = $lt{'srad'};
+ my $fixeddom;
if ($env{'form.action'} eq 'singlestudent') {
if ($crstype eq 'Community') {
$actiontext = $lt{'srme'};
} else {
$actiontext = $lt{'srst'};
}
+ } elsif ($env{'form.action'} eq 'accesslogs') {
+ $actiontext = $lt{'srva'};
+ $fixeddom = 1;
+ } elsif (($env{'form.action'} eq 'singleuser') &&
+ ($context eq 'domain') && (!&Apache::lonnet::allowed('mau',$defdom))) {
+ $actiontext = $lt{'srvu'};
+ $fixeddom = 1;
}
$r->print("
$actiontext
");
if ($env{'form.origform'} ne 'crtusername') {
- $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,$fixeddom));
}
- $r->print(&Apache::loncommon::end_page());
}
sub customrole_javascript {
@@ -622,8 +842,7 @@ END
}
sub entry_form {
- my ($dom,$srch,$forcenewuser,$context,$responsemsg,$crstype) = @_;
- my %domconf = &Apache::lonnet::get_dom('configuration',['usercreation'],$dom);
+ my ($dom,$srch,$forcenewuser,$context,$responsemsg,$crstype,$fixeddom) = @_;
my ($usertype,$inexact);
if (ref($srch) eq 'HASH') {
if (($srch->{'srchin'} eq 'dom') &&
@@ -631,25 +850,35 @@ sub entry_form {
($srch->{'srchtype'} eq 'exact') &&
($srch->{'srchdomain'} ne '') &&
($srch->{'srchterm'} ne '')) {
+ my (%curr_rules,%got_rules);
my ($rules,$ruleorder) =
&Apache::lonnet::inst_userrules($srch->{'srchdomain'},'username');
- $usertype = &Apache::lonuserutils::check_usertype($srch->{'srchdomain'},$srch->{'srchterm'},$rules);
+ $usertype = &Apache::lonuserutils::check_usertype($srch->{'srchdomain'},$srch->{'srchterm'},$rules,\%curr_rules,\%got_rules);
} else {
$inexact = 1;
}
}
- my $cancreate =
- &Apache::lonuserutils::can_create_user($dom,$context,$usertype);
- my $userpicker =
+ my ($cancreate,$noinstd);
+ if ($env{'form.action'} eq 'accesslogs') {
+ $noinstd = 1;
+ } else {
+ $cancreate =
+ &Apache::lonuserutils::can_create_user($dom,$context,$usertype);
+ }
+ my ($userpicker,$cansearch) =
&Apache::loncommon::user_picker($dom,$srch,$forcenewuser,
- 'document.crtuser',$cancreate,$usertype);
+ 'document.crtuser',$cancreate,$usertype,$context,$fixeddom,$noinstd);
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') &&
+ (!(($env{'form.action'} eq 'singleuser') && ($context eq 'domain') &&
+ (!&Apache::lonnet::allowed('mau',$env{'request.role.domain'}))))) {
my $defdom=$env{'request.role.domain'};
- my $domform = &Apache::loncommon::select_dom_form($defdom,'srchdomain');
+ my ($trusted,$untrusted);
+ if ($context eq 'course') {
+ ($trusted,$untrusted) = &Apache::lonnet::trusted_domains('enroll',$defdom);
+ } elsif ($context eq 'author') {
+ ($trusted,$untrusted) = &Apache::lonnet::trusted_domains('othcoau',$defdom);
+ } elsif ($context eq 'domain') {
+ ($trusted,$untrusted) = &Apache::lonnet::trusted_domains('domroles',$defdom);
+ }
+ my $domform = &Apache::loncommon::select_dom_form($defdom,'srchdomain',undef,undef,undef,$trusted,$untrusted);
my %lt=&Apache::lonlocal::texthash(
'enro' => 'Enroll one student',
'enrm' => 'Enroll one member',
@@ -674,7 +916,7 @@ ENDBLOCK
);
my $sellink=&Apache::loncommon::selectstudent_link('crtusername','srchterm','srchdomain');
my ($title,$buttontext,$showresponse);
- if ($env{'form.action'} eq 'singlestudent') {
+ if ($env{'form.action'} eq 'singlestudent') {
if ($crstype eq 'Community') {
$title = $lt{'enrm'};
} else {
@@ -727,19 +969,13 @@ sub user_modification_js {
-
$lt{'cnu'} "$ccuname" $lt{'ind'} $ccdomain
ENDTITLE
if ($env{'form.action'} eq 'singlestudent') {
if ($crstype eq 'Community') {
- $r->print(' ('.$lt{'ame'}.')');
+ $title = &mt('Create New User [_1] in domain [_2] as a member',
+ '"'.$ccuname.'"','"'.$ccdomain.'"');
} else {
- $r->print(' ('.$lt{'ast'}.')');
+ $title = &mt('Create New User [_1] in domain [_2] as a student',
+ '"'.$ccuname.'"','"'.$ccdomain.'"');
}
+ } else {
+ $title = &mt('Create New User [_1] in domain [_2]',
+ '"'.$ccuname.'"','"'.$ccdomain.'"');
}
- $r->print('
'.&mt('User Can Request Creation of Courses/Communities in this Domain?').'
'."\n");
+ if (($env{'request.role.domain'} eq $ccdomain) ||
+ (&Apache::lonnet::will_trust('reqcrs',$ccdomain,$env{'request.role.domain'}))) {
+ $r->print(&Apache::loncommon::start_data_table());
+ if ($env{'request.role.domain'} eq $ccdomain) {
+ $r->print(&build_tools_display($ccuname,$ccdomain,'requestcourses'));
+ } else {
+ $r->print(&coursereq_externaluser($ccuname,$ccdomain,
+ $env{'request.role.domain'}));
+ }
+ $r->print(&Apache::loncommon::end_data_table());
} else {
- $r->print(&coursereq_externaluser($ccuname,$ccdomain,
- $env{'request.role.domain'}));
+ $r->print(&mt('Domain configuration for this domain prohibits course creation by users from domain: "[_1]"',
+ &Apache::lonnet::domain($ccdomain,'description')));
}
- $r->print(&Apache::loncommon::end_data_table());
}
$r->print('
');
- my $user_auth_text = &user_authentication($ccuname,$ccdomain,$formname);
- my ($user_quota_text,$user_tools_text,$user_reqcrs_text);
+ my @order = ('auth','quota','tools','requestauthor');
+ my %user_text;
+ my ($isadv,$isauthor) =
+ &Apache::lonnet::is_advanced_user($ccdomain,$ccuname);
+ if ((!$isauthor) &&
+ ((&Apache::lonnet::allowed('cau',$env{'request.role.domain'})) ||
+ (&Apache::lonnet::allowed('udp',$env{'request.role.domain'}))) &&
+ ($env{'request.role.domain'} eq $ccdomain)) {
+ $user_text{'requestauthor'} = &domainrole_req($ccuname,$ccdomain);
+ }
+ $user_text{'auth'} = &user_authentication($ccuname,$ccdomain,$formname,$crstype,$permission);
if ((&Apache::lonnet::allowed('mpq',$ccdomain)) ||
- (&Apache::lonnet::allowed('mut',$ccdomain))) {
+ (&Apache::lonnet::allowed('mut',$ccdomain)) ||
+ (&Apache::lonnet::allowed('udp',$ccdomain))) {
# Current user has quota modification privileges
- $user_quota_text = &portfolio_quota($ccuname,$ccdomain);
+ $user_text{'quota'} = &user_quotas($ccuname,$ccdomain);
}
if (!&Apache::lonnet::allowed('mpq',$ccdomain)) {
if (&Apache::lonnet::allowed('mpq',$env{'request.role.domain'})) {
- # Get the user's portfolio information
- my %portq = &Apache::lonnet::get('environment',['portfolioquota'],
- $ccdomain,$ccuname);
my %lt=&Apache::lonlocal::texthash(
- 'dska' => "Disk space allocated to user's portfolio files",
- 'youd' => "You do not have privileges to modify the portfolio quota for this user.",
+ 'dska' => "Disk quotas for user's portfolio and Authoring Space",
+ 'youd' => "You do not have privileges to modify the portfolio and/or Authoring Space quotas for this user.",
'ichr' => "If a change is required, contact a domain coordinator for the domain",
);
- $user_quota_text = <$lt{'dska'}
$lt{'youd'} $lt{'ichr'}: $ccdomain
ENDNOPORTPRIV
@@ -1240,49 +1537,55 @@ ENDNOPORTPRIV
if (&Apache::lonnet::allowed('mut',$env{'request.role.domain'})) {
my %lt=&Apache::lonlocal::texthash(
'utav' => "User Tools Availability",
- 'yodo' => "You do not have privileges to modify Portfolio, Blog or Personal Information Page settings for this user.",
+ 'yodo' => "You do not have privileges to modify Portfolio, Blog, WebDAV, or Personal Information Page settings for this user.",
'ifch' => "If a change is required, contact a domain coordinator for the domain",
);
- $user_tools_text = <$lt{'utav'}
$lt{'yodo'} $lt{'ifch'}: $ccdomain
ENDNOTOOLSPRIV
}
}
- if ($user_auth_text ne '') {
- $r->print('
'.$user_auth_text);
- if ($user_quota_text ne '') {
- $r->print($user_quota_text);
- }
- if ($user_tools_text ne '') {
- $r->print($user_tools_text);
- }
- if ($env{'form.action'} eq 'singlestudent') {
- $r->print(&date_sections_select($context,$newuser,$formname));
- }
- } elsif ($user_quota_text ne '') {
- $r->print('
'.$user_quota_text);
- if ($user_tools_text ne '') {
- $r->print($user_tools_text);
- }
- if ($env{'form.action'} eq 'singlestudent') {
- $r->print(&date_sections_select($context,$newuser,$formname));
- }
- } elsif ($user_tools_text ne '') {
- $r->print('
';
$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)) &&
+ ($envkey=~m{^/$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}}) ) {
- $output{$type}.=
+ $output{$type}.=
&Apache::loncommon::start_data_table_row().
$roletext{$sortrole{$which}}.
&Apache::loncommon::end_data_table_row();
@@ -1643,25 +2033,38 @@ sub display_existing_roles {
$contextrole = &mt('Existing Roles in this Course');
}
} elsif ($env{'request.role'} =~ /^au\./) {
- $contextrole = 'Existing Co-Author Roles in your Construction Space';
+ $contextrole = &mt('Existing Co-Author Roles in your Authoring Space');
} else {
- $contextrole = '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'}.'
'.
-'
'.&mt($contextrole).'
'.
+ $r->print('
'.
+'
');
}
return;
}
@@ -1680,7 +2083,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",
@@ -1731,14 +2134,14 @@ 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;;
}
sub new_domain_roles {
- my ($r) = @_;
+ my ($r,$ccdomain) = @_;
my $addrolesdisplay = 0;
#
# Domain level
@@ -1753,10 +2156,20 @@ sub new_domain_roles {
'
'.&mt('Start').'
'.&mt('End').'
'.
&Apache::loncommon::end_data_table_header_row();
my @allroles = &Apache::lonuserutils::roles_by_context('domain');
+ my $uprimary = &Apache::lonnet::domain($env{'request.role.domain'},'primary');
+ my $uintdom = &Apache::lonnet::internet_dom($uprimary);
foreach my $thisdomain (sort(&Apache::lonnet::all_domains())) {
foreach my $role (@allroles) {
next if ($role eq 'ad');
+ next if (($role eq 'au') && ($ccdomain ne $thisdomain));
if (&Apache::lonnet::allowed('c'.$role,$thisdomain)) {
+ if ($role eq 'dc') {
+ unless ($thisdomain eq $env{'request.role.domain'}) {
+ my $domprim = &Apache::lonnet::domain($thisdomain,'primary');
+ my $intdom = &Apache::lonnet::internet_dom($domprim);
+ next unless ($uintdom eq $intdom);
+ }
+ }
my $plrole=&Apache::lonnet::plaintext($role);
my %lt=&Apache::lonlocal::texthash(
'ssd' => "Set Start Date",
@@ -1787,19 +2200,19 @@ sub new_domain_roles {
}
sub user_authentication {
- my ($ccuname,$ccdomain,$formname) = @_;
+ my ($ccuname,$ccdomain,$formname,$crstype,$permission) = @_;
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):/) {
+ if ($currentauth !~ /^(krb4|krb5|unix|internal|localauth|lti):/) {
# 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);
@@ -1825,16 +2238,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 =
'
+ENDJS
+
+ $outcome .= '
'.
+ &Apache::lonhtmlcommon::row_closure(1);
+ $rowcount ++;
+ }
+ if ($showsubmit) {
+ my $submit_text = &mt('Create account');
+ $output .= &Apache::lonhtmlcommon::row_title()."\n".
+ ' ';
+ if ($usertype ne '') {
+ $output .= '';
+ }
+ $output .= &Apache::lonhtmlcommon::row_closure(1);
+ }
+ }
$output .= &Apache::lonhtmlcommon::end_pick_box();
if (wantarray) {
if ($context eq 'selfcreate') {
return($output,$rowcount,$editable);
} else {
- return ($output,$showforceid);
+ return $output;
}
} else {
return $output;
@@ -2150,7 +2775,7 @@ sub get_inststatuses {
# ================================================================= Phase Three
sub update_user_data {
- my ($r,$context,$crstype) = @_;
+ my ($r,$context,$crstype,$brcrum,$showcredits,$permission) = @_;
my $uhome=&Apache::lonnet::homeserver($env{'form.ccuname'},
$env{'form.ccdomain'});
# Error messages
@@ -2174,37 +2799,44 @@ sub update_user_data {
$jsback."\n".
'// ]]>'."\n".
''."\n";
- my %breadcrumb_text = &singleuser_breadcrumb($crstype);
- my $args;
- if ($env{'form.popup'}) {
- $args->{'no_nav_bar'} = 1;
- } else {
- $args = undef;
- }
- $r->print(&Apache::loncommon::start_page($title,$jscript,$args));
- &Apache::lonhtmlcommon::add_breadcrumb
- ({href=>"javascript:backPage(document.userupdate)",
- text=>$breadcrumb_text{'search'},
- faq=>282,bug=>'Instructor Interface',});
+ my %breadcrumb_text = &singleuser_breadcrumb($crstype,$context,$env{'form.ccdomain'});
+ push (@{$brcrum},
+ {href => "javascript:backPage(document.userupdate)",
+ text => $breadcrumb_text{'search'},
+ faq => 282,
+ bug => 'Instructor Interface',}
+ );
if ($env{'form.prevphase'} eq 'userpicked') {
- &Apache::lonhtmlcommon::add_breadcrumb
- ({href=>"javascript:backPage(document.userupdate,'get_user_info','select')",
- text=>$breadcrumb_text{'userpicked'},
- faq=>282,bug=>'Instructor Interface',});
- }
- &Apache::lonhtmlcommon::add_breadcrumb
- ({href=>"javascript:backPage(document.userupdate,'$env{'form.prevphase'}','modify')",
- text=>$breadcrumb_text{'modify'},
- faq=>282,bug=>'Instructor Interface',},
- {href=>"/adm/createuser",
- text=>"Result",
- faq=>282,bug=>'Instructor Interface',});
+ push(@{$brcrum},
+ {href => "javascript:backPage(document.userupdate,'get_user_info','select')",
+ text => $breadcrumb_text{'userpicked'},
+ faq => 282,
+ bug => 'Instructor Interface',});
+ }
my $helpitem = 'Course_Change_Privileges';
if ($env{'form.action'} eq 'singlestudent') {
$helpitem = 'Course_Add_Student';
+ } elsif ($context eq 'author') {
+ $helpitem = 'Author_Change_Privileges';
+ } elsif ($context eq 'domain') {
+ $helpitem = 'Domain_Change_Privileges';
+ }
+ push(@{$brcrum},
+ {href => "javascript:backPage(document.userupdate,'$env{'form.prevphase'}','modify')",
+ text => $breadcrumb_text{'modify'},
+ faq => 282,
+ bug => 'Instructor Interface',},
+ {href => "/adm/createuser",
+ text => "Result",
+ faq => 282,
+ bug => 'Instructor Interface',
+ help => $helpitem});
+ my $args = {bread_crumbs => $brcrum,
+ bread_crumbs_component => 'User Management'};
+ if ($env{'form.popup'}) {
+ $args->{'no_nav_bar'} = 1;
}
- $r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management',
- $helpitem));
+ $r->print(&Apache::loncommon::start_page($title,$jscript,$args));
$r->print(&update_result_form($uhome));
# Check Inputs
if (! $env{'form.ccuname'} ) {
@@ -2235,9 +2867,12 @@ sub update_user_data {
if (! exists($env{'form.makeuser'})) {
# Modifying an existing user, so check the validity of the name
if ($uhome eq 'no_host') {
- $r->print($error.&mt('Unable to determine home server for ').
- $env{'form.ccuname'}.&mt(' in domain ').
- $env{'form.ccdomain'}.'.');
+ $r->print(
+ $error
+ .'
'
+ .&mt('Unable to determine home server for [_1] in domain [_2].',
+ '"'.$env{'form.ccuname'}.'"','"'.$env{'form.ccdomain'}.'"')
+ .'
');
return;
}
}
@@ -2258,6 +2893,9 @@ sub update_user_data {
$amode='localauth';
$genpwd=$env{'form.locarg'};
$genpwd=" " if (!$genpwd);
+ } elsif ($env{'form.login'} eq 'lti') {
+ $amode='lti';
+ $genpwd=" ";
} elsif (($env{'form.login'} eq 'nochange') ||
($env{'form.login'} eq '' )) {
# There is no need to tell the user we did not change what they
@@ -2265,17 +2903,25 @@ sub update_user_data {
# If they are creating a new user but have not specified login
# information this will be caught below.
} else {
- $r->print($error.&mt('Invalid login mode or password').$end.$rtnlink);
- return;
+ $r->print($error.&mt('Invalid login mode or password').$end.$rtnlink);
+ return;
}
$r->print('
'.&mt('User [_1] in domain [_2]',
- $env{'form.ccuname'}, $env{'form.ccdomain'}).'
');
+ $env{'form.ccuname'}.' ('.&Apache::loncommon::plainname($env{'form.ccuname'},
+ $env{'form.ccdomain'}).')', $env{'form.ccdomain'}).'');
+ my %prog_state = &Apache::lonhtmlcommon::Create_PrgWin($r,2);
+
my (%alerts,%rulematch,%inst_results,%curr_rules);
- my @usertools = ('aboutme','blog','portfolio');
- my @requestcourses = ('official','unofficial');
+ my @userinfo = ('firstname','middlename','lastname','generation','permanentemail','id');
+ my @usertools = ('aboutme','blog','webdav','portfolio','timezone');
+ my @requestcourses = ('official','unofficial','community','textbook','placement','lti');
+ my @requestauthor = ('requestauthor');
my ($othertitle,$usertypes,$types) =
&Apache::loncommon::sorted_inst_types($env{'form.ccdomain'});
+ my %canmodify_status =
+ &Apache::lonuserutils::can_modify_userinfo($context,$env{'form.ccdomain'},
+ ['inststatus']);
if ($env{'form.makeuser'}) {
$r->print('
'
+ .&mt('Unable to successfully change environment for [_1] in domain [_2].',
+ '"'.$env{'form.ccuname'}.'"',
+ '"'.$env{'form.ccdomain'}.'"')
+ .'
');
}
- } else { # End of if ($env ... ) logic
+ } else { # End of if ($env ... ) logic
# They did not want to change the users name, quota, tool availability,
# or ability to request creation of courses,
# but we can still tell them what the name and quota and availabilities are
- my %lt=&Apache::lonlocal::texthash(
- 'id' => "Student/Employee ID",
- 'mail' => "Permanent e-mail address",
- 'disk' => "Disk space allocated to user's portfolio files",
- 'blog' => "Blog Availability",
- 'aboutme' => "Personal Information Page Availability",
- 'portfolio' => "Portfolio Availability",
- 'official' => "Can Request Official Courses",
- 'unofficial' => "Can Request Unofficial Courses",
- 'inststatus' => "Affiliation",
- );
- $r->print(<<"END");
-
');
+ &display_userinfo($r,undef,\@disporder,\%canshow,\@requestcourses,
+ \@usertools,\@requestauthor,\%userenv,\%changed,\%namechanged,\%oldsettings,
+ \%oldsettingstext,\%newsettings,\%newsettingstext);
}
if (@mod_disallowed) {
my ($rolestr,$contextname);
@@ -2931,9 +3498,9 @@ END
$rolestr = &mt('No roles');
}
if ($context eq 'course') {
- $contextname = &mt('course');
+ $contextname = 'course';
} elsif ($context eq 'author') {
- $contextname = &mt('co-author');
+ $contextname = 'co-author';
}
$r->print(&mt('The following fields were not updated: ').'
');
my %fieldtitles = &Apache::loncommon::personal_data_fieldtitles();
@@ -2942,9 +3509,9 @@ END
}
$r->print('
');
if (@mod_disallowed == 1) {
- $r->print(&mt("You do not have the authority to change this field given the user's current set of active/future [_1] roles:",$contextname));
+ $r->print(&mt("You do not have the authority to change this field given the user's current set of active/future $contextname roles:"));
} else {
- $r->print(&mt("You do not have the authority to change these fields given the user's current set of active/future [_1] roles:",$contextname));
+ $r->print(&mt("You do not have the authority to change these fields given the user's current set of active/future $contextname roles:"));
}
my $helplink = 'javascript:helpMenu('."'display'".')';
$r->print(''.$rolestr.' '
@@ -2957,18 +3524,21 @@ END
.&Apache::lonuserutils::print_namespacing_alerts($env{'form.ccdomain'},\%alerts,\%curr_rules)
.'');
}
+ &Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state);
if ($env{'form.action'} eq 'singlestudent') {
- &enroll_single_student($r,$uhome,$amode,$genpwd,$now,$newuser,$context,$crstype);
- $r->print('
');
+ }
+ return;
}
sub tool_changes {
@@ -3006,20 +3712,20 @@ sub tool_changes {
(ref($newaccess) eq 'HASH') && (ref($newaccesstext) eq 'HASH'))) {
return;
}
+ my %reqdisplay = &requestchange_display();
if ($context eq 'reqcrsotherdom') {
my @options = ('approval','validate','autolimit');
my $optregex = join('|',@options);
- my %reqdisplay = &courserequest_display();
my $cdom = $env{'request.role.domain'};
foreach my $tool (@{$usertools}) {
- $oldaccesstext->{$tool} = &mt('No');
+ $oldaccesstext->{$tool} = &mt("availability set to 'off'");
$newaccesstext->{$tool} = $oldaccesstext->{$tool};
$changeHash->{$context.'.'.$tool} = $userenv->{$context.'.'.$tool};
- my $newop;
+ my ($newop,$limit);
if ($env{'form.'.$context.'_'.$tool}) {
$newop = $env{'form.'.$context.'_'.$tool};
if ($newop eq 'autolimit') {
- my $limit = $env{'form.'.$context.'_'.$tool.'_limit'};
+ $limit = $env{'form.'.$context.'_'.$tool.'_limit'};
$limit =~ s/\D+//g;
$newop .= '='.$limit;
}
@@ -3029,7 +3735,15 @@ sub tool_changes {
$changed->{$tool}=&tool_admin($tool,$cdom.':'.$newop,
$changeHash,$context);
if ($changed->{$tool}) {
- $newaccesstext->{$tool} = &mt('Yes');
+ if ($newop =~ /^autolimit/) {
+ if ($limit) {
+ $newaccesstext->{$tool} = &mt('available with automatic approval, up to limit of [quant,_1,request] per user',$limit);
+ } else {
+ $newaccesstext->{$tool} = &mt('available with automatic approval (unlimited)');
+ }
+ } else {
+ $newaccesstext->{$tool} = $reqdisplay{$newop};
+ }
} else {
$newaccesstext->{$tool} = $oldaccesstext->{$tool};
}
@@ -3040,8 +3754,17 @@ sub tool_changes {
my $changedoms;
foreach my $req (@curr) {
if ($req =~ /^\Q$cdom\E\:($optregex\=?\d*)$/) {
- $oldaccesstext->{$tool} = &mt('Yes');
my $oldop = $1;
+ if ($oldop =~ /^autolimit=(\d*)/) {
+ my $limit = $1;
+ if ($limit) {
+ $oldaccesstext->{$tool} = &mt('available with automatic approval, up to limit of [quant,_1,request] per user',$limit);
+ } else {
+ $oldaccesstext->{$tool} = &mt('available with automatic approval (unlimited)');
+ }
+ } else {
+ $oldaccesstext->{$tool} = $reqdisplay{$oldop};
+ }
if ($oldop ne $newop) {
$changedoms = 1;
foreach my $item (@curr) {
@@ -3075,15 +3798,15 @@ sub tool_changes {
my $limit = $env{'form.'.$context.'_'.$tool.'_limit'};
$limit =~ s/\D+//g;
if ($limit) {
- $newaccesstext->{$tool} = &mt('Yes, up to limit of [quant,_1,request] per user.',$limit);
+ $newaccesstext->{$tool} = &mt('available with automatic approval, up to limit of [quant,_1,request] per user',$limit);
} else {
- $newaccesstext->{$tool} = &mt('Yes, processed automatically');
+ $newaccesstext->{$tool} = &mt('available with automatic approval (unlimited)');
}
} else {
$newaccesstext->{$tool} = $reqdisplay{$env{'form.'.$context.'_'.$tool}};
}
} else {
- $newaccesstext->{$tool} = &mt('No');
+ $newaccesstext->{$tool} = &mt("availability set to 'off'");
}
}
}
@@ -3092,40 +3815,89 @@ sub tool_changes {
return;
}
foreach my $tool (@{$usertools}) {
- my $newval;
+ my ($newval,$limit,$envkey);
+ $envkey = $context.'.'.$tool;
if ($context eq 'requestcourses') {
$newval = $env{'form.crsreq_'.$tool};
if ($newval eq 'autolimit') {
- $newval .= '='.$env{'form.crsreq_'.$tool.'_limit'};
- }
+ $limit = $env{'form.crsreq_'.$tool.'_limit'};
+ $limit =~ s/\D+//g;
+ $newval .= '='.$limit;
+ }
+ } elsif ($context eq 'requestauthor') {
+ $newval = $env{'form.'.$context};
+ $envkey = $context;
} else {
$newval = $env{'form.'.$context.'_'.$tool};
}
- if ($userenv->{$context.'.'.$tool} ne '') {
+ if ($userenv->{$envkey} ne '') {
$oldaccess->{$tool} = &mt('custom');
- if ($userenv->{$context.'.'.$tool}) {
- $oldaccesstext->{$tool} = &mt("availability set to 'on'");
+ if (($context eq 'requestcourses') || ($context eq 'requestauthor')) {
+ if ($userenv->{$envkey} =~ /^autolimit=(\d*)$/) {
+ my $currlimit = $1;
+ if ($currlimit eq '') {
+ $oldaccesstext->{$tool} = &mt('available with automatic approval (unlimited)');
+ } else {
+ $oldaccesstext->{$tool} = &mt('available with automatic approval, up to limit of [quant,_1,request] per user',$currlimit);
+ }
+ } elsif ($userenv->{$envkey}) {
+ $oldaccesstext->{$tool} = $reqdisplay{$userenv->{$envkey}};
+ } else {
+ $oldaccesstext->{$tool} = &mt("availability set to 'off'");
+ }
} else {
- $oldaccesstext->{$tool} = &mt("availability set to 'off'");
+ if ($userenv->{$envkey}) {
+ $oldaccesstext->{$tool} = &mt("availability set to 'on'");
+ } else {
+ $oldaccesstext->{$tool} = &mt("availability set to 'off'");
+ }
}
- $changeHash->{$context.'.'.$tool} = $userenv->{$context.'.'.$tool};
+ $changeHash->{$envkey} = $userenv->{$envkey};
if ($env{'form.custom'.$tool} == 1) {
- if ($newval ne $userenv->{$context.'.'.$tool}) {
+ if ($newval ne $userenv->{$envkey}) {
$changed->{$tool} = &tool_admin($tool,$newval,$changeHash,
$context);
if ($changed->{$tool}) {
$newaccess->{$tool} = &mt('custom');
- if ($newval) {
- $newaccesstext->{$tool} = &mt("availability set to 'on'");
+ if (($context eq 'requestcourses') || ($context eq 'requestauthor')) {
+ if ($newval =~ /^autolimit/) {
+ if ($limit) {
+ $newaccesstext->{$tool} = &mt('available with automatic approval, up to limit of [quant,_1,request] per user',$limit);
+ } else {
+ $newaccesstext->{$tool} = &mt('available with automatic approval (unlimited)');
+ }
+ } elsif ($newval) {
+ $newaccesstext->{$tool} = $reqdisplay{$newval};
+ } else {
+ $newaccesstext->{$tool} = &mt("availability set to 'off'");
+ }
} else {
- $newaccesstext->{$tool} = &mt("availability set to 'off'");
+ if ($newval) {
+ $newaccesstext->{$tool} = &mt("availability set to 'on'");
+ } else {
+ $newaccesstext->{$tool} = &mt("availability set to 'off'");
+ }
}
} else {
$newaccess->{$tool} = $oldaccess->{$tool};
- if ($userenv->{$context.'.'.$tool}) {
- $newaccesstext->{$tool} = &mt("availability set to 'on'");
+ if (($context eq 'requestcourses') || ($context eq 'requestauthor')) {
+ if ($newval =~ /^autolimit/) {
+ if ($limit) {
+ $newaccesstext->{$tool} = &mt('available with automatic approval, up to limit of [quant,_1,request] per user',$limit);
+ } else {
+ $newaccesstext->{$tool} = &mt('available with automatic approval (unlimited)');
+ }
+ } elsif ($newval) {
+ $newaccesstext->{$tool} = $reqdisplay{$newval};
+ } else {
+ $newaccesstext->{$tool} = &mt("availability set to 'off'");
+ }
} else {
- $newaccesstext->{$tool} = &mt("availability set to 'off'");
+ if ($userenv->{$context.'.'.$tool}) {
+ $newaccesstext->{$tool} = &mt("availability set to 'on'");
+ } else {
+ $newaccesstext->{$tool} = &mt("availability set to 'off'");
+ }
}
}
} else {
@@ -3138,10 +3910,24 @@ sub tool_changes {
$newaccess->{$tool} = &mt('default');
} else {
$newaccess->{$tool} = $oldaccess->{$tool};
- if ($userenv->{$context.'.'.$tool}) {
- $newaccesstext->{$tool} = &mt("availability set to 'on'");
+ if (($context eq 'requestcourses') || ($context eq 'requestauthor')) {
+ if ($newval =~ /^autolimit/) {
+ if ($limit) {
+ $newaccesstext->{$tool} = &mt('available with automatic approval, up to limit of [quant,_1,request] per user',$limit);
+ } else {
+ $newaccesstext->{$tool} = &mt('available with automatic approval (unlimited)');
+ }
+ } elsif ($newval) {
+ $newaccesstext->{$tool} = $reqdisplay{$newval};
+ } else {
+ $newaccesstext->{$tool} = &mt("availability set to 'off'");
+ }
} else {
- $newaccesstext->{$tool} = &mt("availability set to 'off'");
+ if ($userenv->{$context.'.'.$tool}) {
+ $newaccesstext->{$tool} = &mt("availability set to 'on'");
+ } else {
+ $newaccesstext->{$tool} = &mt("availability set to 'off'");
+ }
}
}
}
@@ -3152,10 +3938,24 @@ sub tool_changes {
$context);
if ($changed->{$tool}) {
$newaccess->{$tool} = &mt('custom');
- if ($newval) {
- $newaccesstext->{$tool} = &mt("availability set to 'on'");
+ if (($context eq 'requestcourses') || ($context eq 'requestauthor')) {
+ if ($newval =~ /^autolimit/) {
+ if ($limit) {
+ $newaccesstext->{$tool} = &mt('available with automatic approval, up to limit of [quant,_1,request] per user',$limit);
+ } else {
+ $newaccesstext->{$tool} = &mt('available with automatic approval (unlimited)');
+ }
+ } elsif ($newval) {
+ $newaccesstext->{$tool} = $reqdisplay{$newval};
+ } else {
+ $newaccesstext->{$tool} = &mt("availability set to 'off'");
+ }
} else {
- $newaccesstext->{$tool} = &mt("availability set to 'off'");
+ if ($newval) {
+ $newaccesstext->{$tool} = &mt("availability set to 'on'");
+ } else {
+ $newaccesstext->{$tool} = &mt("availability set to 'off'");
+ }
}
} else {
$newaccess->{$tool} = $oldaccess->{$tool};
@@ -3169,12 +3969,12 @@ sub tool_changes {
}
sub update_roles {
- my ($r,$context) = @_;
+ my ($r,$context,$showcredits) = @_;
my $now=time;
my @rolechanges;
my %disallowed;
$r->print('
'.&mt('Modifying Roles').'
');
- foreach my $key (keys (%env)) {
+ foreach my $key (keys(%env)) {
next if (! $env{$key});
next if ($key eq 'form.action');
# Revoke roles
@@ -3186,14 +3986,20 @@ sub update_roles {
&Apache::lonnet::revokerole($env{'form.ccdomain'},
$env{'form.ccuname'},
$scope,$role,'','',$context);
- $r->print(&mt('Revoking [_1] in [_2]: [_3]',
- $role,$scope,''.$result.'').' ');
+ $r->print(&Apache::lonhtmlcommon::confirm_success(
+ &mt('Revoking [_1] in [_2]',
+ &Apache::lonnet::plaintext($role),
+ &Apache::loncommon::show_role_extent($scope,$context,$role)),
+ $result ne "ok").' ');
+ if ($result ne "ok") {
+ $r->print(&mt('Error: [_1]',$result).' ');
+ }
if ($role eq 'st') {
my $result =
&Apache::lonuserutils::classlist_drop($scope,
$env{'form.ccuname'},$env{'form.ccdomain'},
$now);
- $r->print($result);
+ $r->print(&Apache::lonhtmlcommon::confirm_success($result));
}
if (!grep(/^\Q$role\E$/,@rolechanges)) {
push(@rolechanges,$role);
@@ -3201,11 +4007,15 @@ sub update_roles {
}
if ($key=~m{^form\.rev\:([^_]+)_cr\.cr/($match_domain)/($match_username)/(\w+)$}s) {
# Revoke custom role
- $r->print(&mt('Revoking custom role:').
- ' '.$4.' by '.$3.':'.$2.' in '.$1.': '.
- &Apache::lonnet::revokecustomrole($env{'form.ccdomain'},
- $env{'form.ccuname'},$1,$2,$3,$4,'','',$context).
- ' ');
+ my $result = &Apache::lonnet::revokecustomrole(
+ $env{'form.ccdomain'},$env{'form.ccuname'},$1,$2,$3,$4,'','',$context);
+ $r->print(&Apache::lonhtmlcommon::confirm_success(
+ &mt('Revoking custom role [_1] by [_2] in [_3]',
+ $4,$3.':'.$2,&Apache::loncommon::show_role_extent($1,$context,'cr')),
+ $result ne 'ok').' ');
+ if ($result ne "ok") {
+ $r->print(&mt('Error: [_1]',$result).' ');
+ }
if (!grep(/^cr$/,@rolechanges)) {
push(@rolechanges,'cr');
}
@@ -3219,14 +4029,21 @@ sub update_roles {
$env{'form.ccuname'},
$scope,$role,$now,0,1,'',
$context);
- $r->print(&mt('Deleting [_1] in [_2]: [_3]',$role,$scope,
- ''.$result.'').' ');
+ $r->print(&Apache::lonhtmlcommon::confirm_success(
+ &mt('Deleting [_1] in [_2]',
+ &Apache::lonnet::plaintext($role),
+ &Apache::loncommon::show_role_extent($scope,$context,$role)),
+ $result ne 'ok').' ');
+ if ($result ne "ok") {
+ $r->print(&mt('Error: [_1]',$result).' ');
+ }
+
if ($role eq 'st') {
my $result =
&Apache::lonuserutils::classlist_drop($scope,
$env{'form.ccuname'},$env{'form.ccdomain'},
$now);
- $r->print($result);
+ $r->print(&Apache::lonhtmlcommon::confirm_success($result));
}
if (!grep(/^\Q$role\E$/,@rolechanges)) {
push(@rolechanges,$role);
@@ -3235,11 +4052,17 @@ sub update_roles {
if ($key=~m{^form\.del\:([^_]+)_cr\.cr/($match_domain)/($match_username)/(\w+)$}) {
my ($url,$rdom,$rnam,$rolename) = ($1,$2,$3,$4);
# Delete custom role
- $r->print(&mt('Deleting custom role [_1] by [_2] in [_3]',
- $rolename,$rnam.':'.$rdom,$url).': '.
- &Apache::lonnet::assigncustomrole($env{'form.ccdomain'},
- $env{'form.ccuname'},$url,$rdom,$rnam,$rolename,$now,
- 0,1,$context).' ');
+ my $result =
+ &Apache::lonnet::assigncustomrole($env{'form.ccdomain'},
+ $env{'form.ccuname'},$url,$rdom,$rnam,$rolename,$now,
+ 0,1,$context);
+ $r->print(&Apache::lonhtmlcommon::confirm_success(&mt('Deleting custom role [_1] by [_2] in [_3]',
+ $rolename,$rnam.':'.$rdom,&Apache::loncommon::show_role_extent($1,$context,'cr')),
+ $result ne "ok").' ');
+ if ($result ne "ok") {
+ $r->print(&mt('Error: [_1]',$result).' ');
+ }
+
if (!grep(/^cr$/,@rolechanges)) {
push(@rolechanges,'cr');
}
@@ -3255,27 +4078,38 @@ sub update_roles {
my $output;
if ($role eq 'st') {
if ($url =~ m-^/($match_domain)/($match_courseid)/?(\w*)$-) {
- my $result = &Apache::loncommon::commit_studentrole(\$logmsg,$udom,$uname,$url,$role,$now,0,$1,$2,$3);
+ my ($cdom,$cnum,$csec) = ($1,$2,$3);
+ my $credits;
+ if ($showcredits) {
+ my $defaultcredits =
+ &Apache::lonuserutils::get_defaultcredits($cdom,$cnum);
+ $credits = &get_user_credits($defaultcredits,$cdom,$cnum);
+ }
+ my $result = &Apache::loncommon::commit_studentrole(\$logmsg,$udom,$uname,$url,$role,$now,0,$cdom,$cnum,$csec,$context,$credits);
if (($result =~ /^error/) || ($result eq 'not_in_class') || ($result eq 'unknown_course') || ($result eq 'refused')) {
if ($result eq 'refused' && $logmsg) {
$output = $logmsg;
} else {
- $output = "Error: $result\n";
+ $output = &mt('Error: [_1]',$result)."\n";
}
} else {
- $output = &mt('Assigning').' '.$role.' in '.$url.
- &mt('starting').' '.localtime($now).
- ': '.$logmsg.' '.
- &mt('Add to classlist').': ok ';
+ $output = &Apache::lonhtmlcommon::confirm_success(&mt('Assigning [_1] in [_2] starting [_3]',
+ &Apache::lonnet::plaintext($role),
+ &Apache::loncommon::show_role_extent($url,$context,'st'),
+ &Apache::lonlocal::locallocaltime($now))).' '.$logmsg.' ';
}
}
} else {
my $result=&Apache::lonnet::assignrole($env{'form.ccdomain'},
$env{'form.ccuname'},$url,$role,0,$now,'','',
$context);
- $output = &mt('Re-enabling [_1] in [_2]: [_3]',
- $role,$url,''.$result.'').' ';
- }
+ $output = &Apache::lonhtmlcommon::confirm_success(&mt('Re-enabling [_1] in [_2]',
+ &Apache::lonnet::plaintext($role),
+ &Apache::loncommon::show_role_extent($url,$context,$role)),$result ne "ok").' ';
+ if ($result ne "ok") {
+ $output .= &mt('Error: [_1]',$result).' ';
+ }
+ }
$r->print($output);
if (!grep(/^\Q$role\E$/,@rolechanges)) {
push(@rolechanges,$role);
@@ -3287,8 +4121,13 @@ sub update_roles {
my $result = &Apache::lonnet::assigncustomrole(
$env{'form.ccdomain'}, $env{'form.ccuname'},
$url,$rdom,$rnam,$rolename,0,$now,undef,$context);
- $r->print(&mt('Re-enabling custom role [_1] by [_2] in [_3]: [_4]',
- $rolename,$rnam.':'.$rdom,$url,''.$result.'').' ');
+ $r->print(&Apache::lonhtmlcommon::confirm_success(
+ &mt('Re-enabling custom role [_1] by [_2] in [_3]',
+ $rolename,$rnam.':'.$rdom,&Apache::loncommon::show_role_extent($1,$context,'cr')),
+ $result ne "ok").' ');
+ if ($result ne "ok") {
+ $r->print(&mt('Error: [_1]',$result).' ');
+ }
if (!grep(/^cr$/,@rolechanges)) {
push(@rolechanges,'cr');
}
@@ -3317,7 +4156,7 @@ sub update_roles {
} else {
my %curr_groups =
&Apache::longroup::coursegroups($one,$two);
- foreach my $sec (sort {$a cmp $b} keys %sections) {
+ foreach my $sec (sort {$a cmp $b} keys(%sections)) {
if (($sec eq 'none') || ($sec eq 'all') ||
exists($curr_groups{$sec})) {
$disallowed{$sec} = $url;
@@ -3345,13 +4184,25 @@ sub update_roles {
# split multiple sections
my %sections = ();
my $num_sections = &build_roles($env{'form.sec_'.$one.'_'.$two.'_'.$three},\%sections,$three);
+ my $credits;
+ if ($three eq 'st') {
+ if ($showcredits) {
+ my $defaultcredits =
+ &Apache::lonuserutils::get_defaultcredits($one,$two);
+ $credits = $env{'form.credits_'.$one.'_'.$two.'_'.$three};
+ $credits =~ s/[^\d\.]//g;
+ if ($credits eq $defaultcredits) {
+ undef($credits);
+ }
+ }
+ }
if ($num_sections == 0) {
- $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$url,$three,$start,$end,$one,$two,'',$context));
+ $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$url,$three,$start,$end,$one,$two,'',$context,$credits));
} else {
my %curr_groups =
&Apache::longroup::coursegroups($one,$two);
my $emptysec = 0;
- foreach my $sec (sort {$a cmp $b} keys %sections) {
+ foreach my $sec (sort {$a cmp $b} keys(%sections)) {
$sec =~ s/\W//g;
if ($sec ne '') {
if (($sec eq 'none') || ($sec eq 'all') ||
@@ -3360,13 +4211,13 @@ sub update_roles {
next;
}
my $securl = $url.'/'.$sec;
- $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$securl,$three,$start,$end,$one,$two,$sec,$context));
+ $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$securl,$three,$start,$end,$one,$two,$sec,$context,$credits));
} else {
$emptysec = 1;
}
}
if ($emptysec) {
- $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$url,$three,$start,$end,$one,$two,'',$context));
+ $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$url,$three,$start,$end,$one,$two,'',$context,$credits));
}
}
if (!grep(/^\Q$three\E$/,@rolechanges)) {
@@ -3391,7 +4242,7 @@ sub update_roles {
$r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$url,$two,$start,$end,$one,undef,'',$context));
} else {
my $emptysec = 0;
- foreach my $sec (sort {$a cmp $b} keys %sections) {
+ foreach my $sec (sort {$a cmp $b} keys(%sections)) {
if ($sec ne '') {
my $securl = $url.'/'.$sec;
$r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$securl,$two,$start,$end,$one,undef,$sec,$context));
@@ -3426,15 +4277,38 @@ sub update_roles {
}
} # End of foreach (keys(%env))
# Flush the course logs so reverse user roles immediately updated
- &Apache::lonnet::flushcourselogs();
+ $r->register_cleanup(\&Apache::lonnet::flushcourselogs);
if (@rolechanges == 0) {
- $r->print(&mt('No roles to modify'));
+ $r->print('
'.&mt('No roles to modify').'
');
}
return @rolechanges;
}
+sub get_user_credits {
+ my ($uname,$udom,$defaultcredits,$cdom,$cnum) = @_;
+ if ($cdom eq '' || $cnum eq '') {
+ return unless ($env{'request.course.id'});
+ $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+ $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
+ }
+ my $credits;
+ my %currhash =
+ &Apache::lonnet::get('classlist',[$uname.':'.$udom],$cdom,$cnum);
+ if (keys(%currhash) > 0) {
+ my @items = split(/:/,$currhash{$uname.':'.$udom});
+ my $crdidx = &Apache::loncoursedata::CL_CREDITS() - 3;
+ $credits = $items[$crdidx];
+ $credits =~ s/[^\d\.]//g;
+ }
+ if ($credits eq $defaultcredits) {
+ undef($credits);
+ }
+ return $credits;
+}
+
sub enroll_single_student {
- my ($r,$uhome,$amode,$genpwd,$now,$newuser,$context,$crstype) = @_;
+ my ($r,$uhome,$amode,$genpwd,$now,$newuser,$context,$crstype,
+ $showcredits,$defaultcredits) = @_;
$r->print('
');
if ($crstype eq 'Community') {
$r->print(&mt('Enrolling Member'));
@@ -3446,6 +4320,17 @@ sub enroll_single_student {
# Remove non alphanumeric values from section
$env{'form.sections'}=~s/\W//g;
+ my $credits;
+ if (($showcredits) && ($env{'form.credits'} ne '')) {
+ $credits = $env{'form.credits'};
+ $credits =~ s/[^\d\.]//g;
+ if ($credits ne '') {
+ if ($credits eq $defaultcredits) {
+ undef($credits);
+ }
+ }
+ }
+
# Clean out any old student roles the user has in this class.
&Apache::lonuserutils::modifystudent($env{'form.ccdomain'},
$env{'form.ccuname'},$env{'request.course.id'},undef,$uhome);
@@ -3455,9 +4340,10 @@ sub enroll_single_student {
$env{'form.ccuname'},$env{'form.cid'},$env{'form.cfirstname'},
$env{'form.cmiddlename'},$env{'form.clastname'},
$env{'form.generation'},$env{'form.sections'},$enddate,
- $startdate,'manual',undef,$env{'request.course.id'},'',$context);
+ $startdate,'manual',undef,$env{'request.course.id'},'',$context,
+ $credits);
if ($enroll_result =~ /^ok/) {
- $r->print(&mt('[_1] enrolled',$env{'form.ccuname'}.':'.$env{'form.ccdomain'}));
+ $r->print(&mt('[_1] enrolled',''.$env{'form.ccuname'}.':'.$env{'form.ccdomain'}.''));
if ($env{'form.sections'} ne '') {
$r->print(' '.&mt('in section [_1]',$env{'form.sections'}));
}
@@ -3474,13 +4360,13 @@ sub enroll_single_student {
}
$r->print('. '.$showstart.'; '.$showend);
if ($startdate <= $now && !$newuser) {
- $r->print('
');
+ $r->print('
');
if ($crstype eq 'Community') {
- $r->print(&mt('If the member is currently logged-in to LON-CAPA, the new role will be available when the member next logs in.'));
+ $r->print(&mt('If the member is currently logged-in to LON-CAPA, the new role can be displayed by using the "Check for changes" link on the Roles/Courses page.'));
} else {
- $r->print(&mt('If the student is currently logged-in to LON-CAPA, the new role will be available when the student next logs in.'));
- }
- $r->print('
');
+ $r->print(&mt('If the student is currently logged-in to LON-CAPA, the new role can be displayed by using the "Check for changes" link on the Roles/Courses page.'));
+ }
+ $r->print('');
}
} else {
$r->print(&mt('unable to enroll').": ".$enroll_result);
@@ -3492,14 +4378,14 @@ sub get_defaultquota_text {
my ($settingstatus) = @_;
my $defquotatext;
if ($settingstatus eq '') {
- $defquotatext = &mt('(default)');
+ $defquotatext = &mt('default');
} else {
my ($usertypes,$order) =
&Apache::lonnet::retrieve_inst_usertypes($env{'form.ccdomain'});
if ($usertypes->{$settingstatus} eq '') {
- $defquotatext = &mt('(default)');
+ $defquotatext = &mt('default');
} else {
- $defquotatext = &mt('(default for [_1])',$usertypes->{$settingstatus});
+ $defquotatext = &mt('default for [_1]',$usertypes->{$settingstatus});
}
}
return $defquotatext;
@@ -3508,7 +4394,7 @@ sub get_defaultquota_text {
sub update_result_form {
my ($uhome) = @_;
my $outcome =
- ''."\n";
+ '';
return $outcome;
}
sub quota_admin {
- my ($setquota,$changeHash) = @_;
+ my ($setquota,$changeHash,$name) = @_;
my $quotachanged;
if (&Apache::lonnet::allowed('mpq',$env{'form.ccdomain'})) {
# Current user has quota modification privileges
if (ref($changeHash) eq 'HASH') {
$quotachanged = 1;
- $changeHash->{'portfolioquota'} = $setquota;
+ $changeHash->{$name.'quota'} = $setquota;
}
}
return $quotachanged;
@@ -3554,6 +4440,10 @@ sub tool_admin {
if (&Apache::lonnet::allowed('ccc',$env{'request.role.domain'})) {
$canchange = 1;
}
+ } elsif ($context eq 'requestauthor') {
+ if (&Apache::lonnet::allowed('cau',$env{'request.role.domain'})) {
+ $canchange = 1;
+ }
} elsif (&Apache::lonnet::allowed('mut',$env{'form.ccdomain'})) {
# Current user has quota modification privileges
$canchange = 1;
@@ -3562,7 +4452,11 @@ sub tool_admin {
if ($canchange) {
if (ref($changeHash) eq 'HASH') {
$toolchanged = 1;
- $changeHash->{$context.'.'.$tool} = $settool;
+ if ($tool eq 'requestauthor') {
+ $changeHash->{$context} = $settool;
+ } else {
+ $changeHash->{$context.'.'.$tool} = $settool;
+ }
}
}
return $toolchanged;
@@ -3604,309 +4498,148 @@ sub build_roles {
# ========================================================== Custom Role Editor
sub custom_role_editor {
- my ($r) = @_;
+ my ($r,$context,$brcrum,$prefix,$permission) = @_;
my $action = $env{'form.customroleaction'};
- my $rolename;
+ my ($rolename,$helpitem);
if ($action eq 'new') {
$rolename=$env{'form.newrolename'};
} else {
$rolename=$env{'form.rolename'};
}
- $rolename=~s/[^A-Za-z0-9]//gs;
- if (!$rolename || $env{'form.phase'} eq 'pickrole') {
- &print_username_entry_form($r);
- return;
- }
my ($crstype,$context);
if ($env{'request.course.id'}) {
$crstype = &Apache::loncommon::course_type();
$context = 'course';
+ $helpitem = 'Course_Editing_Custom_Roles';
} else {
$context = 'domain';
- $crstype = $env{'form.templatecrstype'};
+ $crstype = 'course';
+ $helpitem = 'Domain_Editing_Custom_Roles';
}
-# ------------------------------------------------------- What can be assigned?
- my %full=();
- my %courselevel=();
- my %courselevelcurrent=();
- my $syspriv='';
- my $dompriv='';
- my $coursepriv='';
- my $body_top;
+
+ $rolename=~s/[^A-Za-z0-9]//gs;
+ if (!$rolename || $env{'form.phase'} eq 'pickrole') {
+ &print_username_entry_form($r,$context,undef,undef,undef,$crstype,$brcrum,
+ $permission);
+ return;
+ }
+
+ my $formname = 'form1';
+ my %privs=();
+ my $body_top = '
';
+# ------------------------------------------------------- Does this role exist?
my ($rdummy,$roledef)=
&Apache::lonnet::get('roles',["rolesdef_$rolename"]);
-# ------------------------------------------------------- Does this role exist?
- $body_top .= '
';
- }
- return $menu_html;
}
sub restore_prev_selections {
@@ -4456,11 +5890,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);
@@ -4469,6 +5903,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');
@@ -4579,7 +6018,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)
}
}
@@ -4600,12 +6039,13 @@ function validate_types(form) {
}
function check_types(num,countfail,needaction) {
- var typeidx = getIndexByName('selfenroll_types_'+num);
+ var boxname = 'selfenroll_types_'+num;
+ var typeidx = getIndexByName(boxname);
var count = 0;
if (typeidx != -1) {
- if (document.$formname.elements[typeidx].length) {
- for (var k=0; k'."\n".
'// '."\n".
''."\n".
'
'.$lt->{'selfenroll'}.'
'."\n";
- my ($visible,$cansetvis,$vismsgs,$visactions) = &visible_in_cat($cdom,$cnum);
- if (ref($visactions) eq 'HASH') {
- if ($visible) {
- $output .= '
';
}
$output .= &Apache::lonhtmlcommon::row_closure(1);
}
}
- $output .= &Apache::lonhtmlcommon::end_pick_box().
- ' '
- .'';
+ $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]Set course environment[_2] to change the "Exclude from course catalog" setting.','"','"');
- $visactions{'chgcat'} = &mt('Use [_1]Set course environment[_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]Set course environment[_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.');
@@ -4953,10 +6571,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');
@@ -4980,8 +6598,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');
@@ -5027,7 +6645,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 {
@@ -5053,12 +6697,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';
@@ -5083,7 +6731,7 @@ sub selfenroll_inst_types {
$output .= 'checked="checked"';
}
}
- $output .= ' name="selfenroll_types_'.$num.'" />'.$usertypes->{$type}.'';
+ $output .= ' name="selfenroll_types_'.$num.'"'.$disabled.' />'.$usertypes->{$type}.'';
}
$count ++;
}
@@ -5106,7 +6754,7 @@ sub selfenroll_inst_types {
} else {
$output .= ' checked="checked"';
}
- $output .= ' name="selfenroll_types_'.$num.'" />'.$othertitle.'';
+ $output .= ' name="selfenroll_types_'.$num.'"'.$disabled.' />'.$othertitle.'';
}
return $output;
}
@@ -5127,20 +6775,67 @@ sub selfenroll_date_forms {
}
sub print_userchangelogs_display {
- my ($r,$context,$permission) = @_;
- my $formname = 'roleslog';
- my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
- my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
- my $crstype = &Apache::loncommon::course_type();
- my %roleslog=&Apache::lonnet::dump('nohist_rolelog',$cdom,$cnum);
+ my ($r,$context,$permission,$brcrum) = @_;
+ my $formname = 'rolelog';
+ my ($username,$domain,$crstype,$viewablesec,%roleslog);
+ if ($context eq 'domain') {
+ $domain = $env{'request.role.domain'};
+ %roleslog=&Apache::lonnet::dump_dom('nohist_rolelog',$domain);
+ } else {
+ if ($context eq 'course') {
+ $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);
+ &Apache::loncommon::restore_course_settings('roles_log',
+ \%saveable_parameters);
+ } elsif ($context eq 'author') {
+ $domain = $env{'user.domain'};
+ if ($env{'request.role'} =~ m{^au\./\Q$domain\E/$}) {
+ $username = $env{'user.name'};
+ } else {
+ undef($domain);
+ }
+ }
+ if ($domain ne '' && $username ne '') {
+ %roleslog=&Apache::lonnet::dump('nohist_rolelog',$domain,$username);
+ }
+ }
if ((keys(%roleslog))[0]=~/^error\:/) { undef(%roleslog); }
- $r->print('