'.
+ &mt('Authoring Space defaults (if role assigned)').
+ '
'."\n".
+ &Apache::loncommon::start_data_table().
+ &build_tools_display($ccuname,$ccdomain,
+ 'authordefaults').
+ &user_quotas($ccuname,$ccdomain,'author').
+ &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',
@@ -476,10 +801,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'})) {
@@ -503,42 +912,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 $crumbs = &Apache::lonhtmlcommon::breadcrumbs('User Management',
- $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 %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:');
@@ -578,20 +1010,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 {
@@ -633,8 +1075,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') &&
@@ -642,25 +1083,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',
@@ -738,19 +1202,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('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','authordefaults');
+ my %user_text;
+ my ($isadv,$isauthor) =
+ &Apache::lonnet::is_advanced_user($ccdomain,$ccuname);
+ if (((&Apache::lonnet::allowed('cau',$env{'request.role.domain'})) ||
+ (&Apache::lonnet::allowed('udp',$env{'request.role.domain'}))) &&
+ ($env{'request.role.domain'} eq $ccdomain)) {
+ if (!$isauthor) {
+ $user_text{'requestauthor'} = &domainrole_req($ccuname,$ccdomain);
+ }
+ $user_text{'authordefaults'} = &authoring_defaults($ccuname,$ccdomain);
+ if (&Apache::lonnet::allowed('cau',$env{'request.role.domain'})) {
+ $need_quota_js = 1;
+ }
+ }
+ $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))) {
+ $user_text{'quota'} = '
'.&mt('User Tools').'
'."\n".
+ &Apache::loncommon::start_data_table();
+ if ((&Apache::lonnet::allowed('mut',$ccdomain)) ||
+ (&Apache::lonnet::allowed('udp',$ccdomain))) {
+ $user_text{'quota'} .= &build_tools_display($ccuname,$ccdomain,'tools');
+ }
# Current user has quota modification privileges
- $user_quota_text = &portfolio_quota($ccuname,$ccdomain);
+ if ((&Apache::lonnet::allowed('mpq',$ccdomain)) ||
+ (&Apache::lonnet::allowed('udp',$ccdomain))) {
+ $user_text{'quota'} .= &user_quotas($ccuname,$ccdomain,'portfolio');
+ $need_quota_js = 1;
+ }
+ $user_text{'quota'} .= &Apache::loncommon::end_data_table();
}
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",
+ 'dska' => "Disk quotas for user's portfolio",
'youd' => "You do not have privileges to modify the portfolio quota 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
@@ -1251,49 +1833,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, Personal Information Page, or Time Zone 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}}) ) {
@@ -1656,25 +2341,41 @@ 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');
- } else {
- $contextrole = &mt('Existing Roles in this Domain');
+ $contextrole = &mt('Existing Co-Author Roles in your Authoring Space');
+ } elsif ($env{'request.role'} =~ m{^ca\./($match_domain)/($match_username)/$}) {
+ $contextrole = &mt('Existing Co-Author Roles in [_1] Authoring Space',
+ ''.$1.'_'.$2.'');
+ } else {
+ 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('
'.
+'
');
}
return;
}
@@ -1685,15 +2386,27 @@ sub new_coauthor_roles {
#
# Co-Author
#
- if (&Apache::lonuserutils::authorpriv($env{'user.name'},
- $env{'request.role.domain'}) &&
- ($env{'user.name'} ne $ccuname || $env{'user.domain'} ne $ccdomain)) {
+ my ($cuname,$cudom);
+ if (($env{'request.role'} eq "au./$env{'user.domain'}/") ||
+ ($env{'request.role'} eq "dc./$env{'user.domain'}/")) {
+ $cuname=$env{'user.name'};
+ $cudom=$env{'request.role.domain'};
# No sense in assigning co-author role to yourself
- $addrolesdisplay = 1;
- my $cuname=$env{'user.name'};
- my $cudom=$env{'request.role.domain'};
+ if ((&Apache::lonuserutils::authorpriv($cuname,$cudom)) &&
+ ($env{'user.name'} ne $ccuname || $env{'user.domain'} ne $ccdomain)) {
+ $addrolesdisplay = 1;
+ }
+ } elsif ($env{'request.role'} =~ m{^ca\./($match_domain)/($match_username)$}) {
+ ($cudom,$cuname) = ($1,$2);
+ if ((&Apache::lonuserutils::coauthorpriv($cuname,$cudom)) &&
+ ($env{'user.name'} ne $ccuname || $env{'user.domain'} ne $ccdomain) &&
+ ($cudom ne $ccdomain || $cuname ne $ccuname)) {
+ $addrolesdisplay = 1;
+ }
+ }
+ if ($addrolesdisplay) {
my %lt=&Apache::lonlocal::texthash(
- 'cs' => "Construction Space",
+ 'cs' => "Authoring Space",
'act' => "Activate",
'rol' => "Role",
'ext' => "Extent",
@@ -1744,14 +2457,25 @@ 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'));
+ }
+ } elsif ($env{'request.role'} =~ m{^ca\./($match_domain)/($match_username)$}) {
+ if (!(&Apache::lonuserutils::coauthorpriv($2,$1))) {
+ $r->print(''.
+ &mt('You do not have privileges to assign co-author 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 an author area in Authoring Space in which you already have a co-author role is not permitted'));
+ } elsif (($cudom eq $ccdomain) && ($cuname eq $ccuname)) {
+ $r->print(&mt("Assigning a co-author or assistant co-author role to an Authoring Space's author is not permitted"));
}
}
return $addrolesdisplay;;
}
sub new_domain_roles {
- my ($r) = @_;
+ my ($r,$ccdomain) = @_;
my $addrolesdisplay = 0;
#
# Domain level
@@ -1766,10 +2490,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",
@@ -1800,19 +2534,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);
@@ -1838,16 +2572,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;
@@ -2176,7 +3137,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
@@ -2200,37 +3161,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'} ) {
@@ -2261,9 +3229,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;
}
}
@@ -2284,6 +3255,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
@@ -2291,16 +3265,21 @@ 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 @userinfo = ('firstname','middlename','lastname','generation','permanentemail','id');
- my @usertools = ('aboutme','blog','portfolio');
- my @requestcourses = ('official','unofficial','community');
+ my @usertools = ('aboutme','blog','portfolio','portaccess','timezone');
+ my @requestcourses = ('official','unofficial','community','textbook','placement','lti');
+ my @requestauthor = ('requestauthor');
+ my @authordefaults = ('webdav','editors','archive');
my ($othertitle,$usertypes,$types) =
&Apache::loncommon::sorted_inst_types($env{'form.ccdomain'});
my %canmodify_status =
@@ -2355,6 +3334,7 @@ sub update_user_data {
}
}
}
+ &Apache::lonhtmlcommon::Increment_PrgWin($r, \%prog_state);
# Call modifyuser
my $result = &Apache::lonnet::modifyuser
($env{'form.ccdomain'},$env{'form.ccuname'},$env{'form.cid'},
@@ -2368,14 +3348,18 @@ sub update_user_data {
my (%changeHash,%newcustom,%changed,%changedinfo);
if ($uhome ne 'no_host') {
if ($context eq 'domain') {
- if ($env{'form.customquota'} == 1) {
- if ($env{'form.portfolioquota'} eq '') {
- $newcustom{'quota'} = 0;
- } else {
- $newcustom{'quota'} = $env{'form.portfolioquota'};
- $newcustom{'quota'} =~ s/[^\d\.]//g;
+ foreach my $name ('portfolio','author') {
+ if ($env{'form.custom_'.$name.'quota'} == 1) {
+ if ($env{'form.'.$name.'quota'} eq '') {
+ $newcustom{$name.'quota'} = 0;
+ } else {
+ $newcustom{$name.'quota'} = $env{'form.'.$name.'quota'};
+ $newcustom{$name.'quota'} =~ s/[^\d\.]//g;
+ }
+ if ("a_admin($newcustom{$name.'quota'},\%changeHash,$name)) {
+ $changed{$name.'quota'} = 1;
+ }
}
- $changed{'quota'} = "a_admin($newcustom{'quota'},\%changeHash);
}
foreach my $item (@usertools) {
if ($env{'form.custom'.$item} == 1) {
@@ -2385,15 +3369,53 @@ sub update_user_data {
}
}
foreach my $item (@requestcourses) {
- $newcustom{$item} = $env{'form.crsreq_'.$item};
- if ($env{'form.crsreq_'.$item} eq 'autolimit') {
- $newcustom{$item} .= '=';
- unless ($env{'form.crsreq_'.$item.'_limit'} =~ /\D/) {
- $newcustom{$item} .= $env{'form.crsreq_'.$item.'_limit'};
+ if ($env{'form.custom'.$item} == 1) {
+ $newcustom{$item} = $env{'form.crsreq_'.$item};
+ if ($env{'form.crsreq_'.$item} eq 'autolimit') {
+ $newcustom{$item} .= '=';
+ $env{'form.crsreq_'.$item.'_limit'} =~ s/\D+//g;
+ if ($env{'form.crsreq_'.$item.'_limit'}) {
+ $newcustom{$item} .= $env{'form.crsreq_'.$item.'_limit'};
+ }
}
+ $changed{$item} = &tool_admin($item,$newcustom{$item},
+ \%changeHash,'requestcourses');
+ }
+ }
+ if ($env{'form.customrequestauthor'} == 1) {
+ $newcustom{'requestauthor'} = $env{'form.requestauthor'};
+ $changed{'requestauthor'} = &tool_admin('requestauthor',
+ $newcustom{'requestauthor'},
+ \%changeHash,'requestauthor');
+ }
+ if ($env{'form.customeditors'} == 1) {
+ my @editors;
+ my @posseditors = &Apache::loncommon::get_env_multiple('form.custom_editor');
+ if (@posseditors) {
+ foreach my $editor (@posseditors) {
+ if (grep(/^\Q$editor\E$/,@posseditors)) {
+ unless (grep(/^\Q$editor\E$/,@editors)) {
+ push(@editors,$editor);
+ }
+ }
+ }
+ }
+ if (@editors) {
+ @editors = sort(@editors);
+ $changed{'editors'} = &tool_admin('editors',join(',',@editors),
+ \%changeHash,'authordefaults');
}
- $changed{$item} = &tool_admin($item,$newcustom{$item},
- \%changeHash,'requestcourses');
+ }
+ if ($env{'form.customwebdav'} == 1) {
+ $newcustom{'webdav'} = $env{'form.authordefaults_webdav'};
+ $changed{'webdav'} = &tool_admin('webdav',$newcustom{'webdav'},
+ \%changeHash,'authordefaults');
+ }
+ if ($env{'form.customarchive'} == 1) {
+ $newcustom{'archive'} = $env{'form.authordefaults_archive'};
+ $changed{'archive'} = &tool_admin('archive',$newcustom{'archive'},
+ \%changeHash,'authordefaults');
+
}
}
if ($canmodify_status{'inststatus'}) {
@@ -2412,9 +3434,9 @@ sub update_user_data {
my $chgresult =
&Apache::lonnet::put('environment',\%changeHash,
$env{'form.ccdomain'},$env{'form.ccuname'});
- }
+ }
}
- $r->print(' '.&mt('Home server').': '.$uhome.' '.
+ $r->print(' '.&mt('Home Server').': '.$uhome.' '.
&Apache::lonnet::hostname($uhome));
} elsif (($env{'form.login'} ne 'nochange') &&
($env{'form.login'} ne '' )) {
@@ -2423,39 +3445,62 @@ sub update_user_data {
$r->print($error.'Invalid login mode or password'.$end.$rtnlink);
return;
}
- # Only allow authentification modification if the person has authority
+ # Only allow authentication modification if the person has authority
if (&Apache::lonnet::allowed('mau',$env{'form.ccdomain'})) {
$r->print('Modifying authentication: '.
&Apache::lonnet::modifyuserauth(
$env{'form.ccdomain'},$env{'form.ccuname'},
$amode,$genpwd));
- $r->print(' '.&mt('Home server').': '.&Apache::lonnet::homeserver
+ $r->print(' '.&mt('Home Server').': '.&Apache::lonnet::homeserver
($env{'form.ccuname'},$env{'form.ccdomain'}));
} else {
# Okay, this is a non-fatal error.
- $r->print($error.&mt('You do not have the authority to modify this users authentification information').'.'.$end);
+ $r->print($error.&mt('You do not have privileges to modify the authentication configuration for this user.').$end);
}
+ } elsif (($env{'form.intarg'} ne '') &&
+ (&Apache::lonnet::queryauthenticate($env{'form.ccuname'},$env{'form.ccdomain'}) =~ /^internal:/) &&
+ (&Apache::lonuserutils::can_change_internalpass($env{'form.ccuname'},$env{'form.ccdomain'},$crstype,$permission))) {
+ $r->print('Modifying authentication: '.
+ &Apache::lonnet::modifyuserauth(
+ $env{'form.ccdomain'},$env{'form.ccuname'},
+ 'internal',$env{'form.intarg'}));
}
+ $r->rflush(); # Finish display of header before time consuming actions start
+ &Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state);
##
- my (@userroles,%userupdate,$cnum,$cdom,$crstype,%namechanged);
+ my (@userroles,%userupdate,$cnum,$cdom,$defaultcredits,%namechanged);
if ($context eq 'course') {
- ($cnum,$cdom) = &Apache::lonuserutils::get_course_identity();
+ ($cnum,$cdom) =
+ &Apache::lonuserutils::get_course_identity();
$crstype = &Apache::loncommon::course_type($cdom.'_'.$cnum);
+ if ($showcredits) {
+ $defaultcredits = &Apache::lonuserutils::get_defaultcredits($cdom,$cnum);
+ }
}
if (! $env{'form.makeuser'} ) {
# Check for need to change
my %userenv = &Apache::lonnet::get
('environment',['firstname','middlename','lastname','generation',
- 'id','permanentemail','portfolioquota','inststatus','tools.aboutme',
- 'tools.blog','tools.portfolio','requestcourses.official',
- 'requestcourses.unofficial','requestcourses.community',
+ 'id','permanentemail','portfolioquota','authorquota','inststatus',
+ 'tools.aboutme','tools.blog','tools.webdav',
+ 'tools.portfolio','tools.timezone','tools.portaccess',
+ 'authormanagers','authoreditors','authorarchive','requestauthor',
+ 'requestcourses.official','requestcourses.unofficial',
+ 'requestcourses.community','requestcourses.textbook',
+ 'requestcourses.placement','requestcourses.lti',
'reqcrsotherdom.official','reqcrsotherdom.unofficial',
- 'reqcrsotherdom.community'],
+ 'reqcrsotherdom.community','reqcrsotherdom.textbook',
+ 'reqcrsotherdom.placement','domcoord.author'],
$env{'form.ccdomain'},$env{'form.ccuname'});
my ($tmp) = keys(%userenv);
if ($tmp =~ /^(con_lost|error)/i) {
%userenv = ();
}
+ unless (($userenv{'domcoord.author'} eq 'blocked') &&
+ (($env{'user.name'} ne $env{'form.ccuname'}) ||
+ ($env{'user.domain'} ne $env{'form.ccdomain'}))) {
+ push(@authordefaults,'managers');
+ }
my $no_forceid_alert;
# Check to see if user information can be changed
my %domconfig =
@@ -2480,7 +3525,7 @@ sub update_user_data {
}
} elsif ($context eq 'author') {
if ($rolenum eq $auname && $roledom eq $audom) {
- if (!grep(/^\Q$role\E$/,@userroles)) {
+ if (!grep(/^\Q$role\E$/,@userroles)) {
push(@userroles,$role);
}
}
@@ -2572,18 +3617,23 @@ sub update_user_data {
}
}
}
- my ($quotachanged,$oldportfolioquota,$newportfolioquota,$oldinststatus,
- $newinststatus,$oldisdefault,$newisdefault,%oldsettings,
- %oldsettingstext,%newsettings,%newsettingstext,@disporder);
+ my (%quotachanged,%oldquota,%newquota,%olddefquota,%newdefquota,
+ $oldinststatus,$newinststatus,%oldisdefault,%newisdefault,%oldsettings,
+ %oldsettingstext,%newsettings,%newsettingstext,@disporder,
+ %oldsettingstatus,%newsettingstatus);
@disporder = ('inststatus');
if ($env{'request.role.domain'} eq $env{'form.ccdomain'}) {
- push(@disporder,'requestcourses');
+ push(@disporder,('requestcourses','requestauthor','authordefaults'));
} else {
push(@disporder,'reqcrsotherdom');
}
push(@disporder,('quota','tools'));
- my ($defquota,my $settingstatus) =
- &Apache::loncommon::default_quota($env{'form.ccdomain'},$oldinststatus);
+ $oldinststatus = $userenv{'inststatus'};
+ foreach my $name ('portfolio','author') {
+ ($olddefquota{$name},$oldsettingstatus{$name}) =
+ &Apache::loncommon::default_quota($env{'form.ccdomain'},$oldinststatus,$name);
+ ($newdefquota{$name},$newsettingstatus{$name}) = ($olddefquota{$name},$oldsettingstatus{$name});
+ }
my %canshow;
if (&Apache::lonnet::allowed('mpq',$env{'form.ccdomain'})) {
$canshow{'quota'} = 1;
@@ -2599,8 +3649,11 @@ sub update_user_data {
if (&Apache::lonnet::allowed('mau',$env{'form.ccdomain'})) {
$canshow{'inststatus'} = 1;
}
+ if (&Apache::lonnet::allowed('cau',$env{'form.ccdomain'})) {
+ $canshow{'requestauthor'} = 1;
+ $canshow{'authordefaults'} = 1;
+ }
my (%changeHash,%changed);
- $oldinststatus = $userenv{'inststatus'};
if ($oldinststatus eq '') {
$oldsettings{'inststatus'} = $othertitle;
} else {
@@ -2620,11 +3673,15 @@ sub update_user_data {
$changeHash{'inststatus'} = $newinststatus;
if ($newinststatus ne $oldinststatus) {
$changed{'inststatus'} = $newinststatus;
+ foreach my $name ('portfolio','author') {
+ ($newdefquota{$name},$newsettingstatus{$name}) =
+ &Apache::loncommon::default_quota($env{'form.ccdomain'},$newinststatus,$name);
+ }
}
if (ref($usertypes) eq 'HASH') {
$newsettings{'inststatus'} = join(', ',map{ $usertypes->{$_}; } (@inststatuses));
} else {
- $newsettings{'inststatus'} = join(', ',map{ $usertypes->{$_}; } (@inststatuses));
+ $newsettings{'inststatus'} = join(', ',@inststatuses);
}
}
} else {
@@ -2633,57 +3690,84 @@ sub update_user_data {
$newsettings{'inststatus'} = $othertitle;
if ($newinststatus ne $oldinststatus) {
$changed{'inststatus'} = $changeHash{'inststatus'};
+ foreach my $name ('portfolio','author') {
+ ($newdefquota{$name},$newsettingstatus{$name}) =
+ &Apache::loncommon::default_quota($env{'form.ccdomain'},$newinststatus,$name);
+ }
}
}
} elsif ($context ne 'selfcreate') {
$canshow{'inststatus'} = 1;
+ $newsettings{'inststatus'} = $oldsettings{'inststatus'};
+ }
+ foreach my $name ('portfolio','author') {
+ $changeHash{$name.'quota'} = $userenv{$name.'quota'};
}
- $changeHash{'portfolioquota'} = $userenv{'portfolioquota'};
if ($context eq 'domain') {
- if ($userenv{'portfolioquota'} ne '') {
- $oldportfolioquota = $userenv{'portfolioquota'};
- if ($env{'form.customquota'} == 1) {
- if ($env{'form.portfolioquota'} eq '') {
- $newportfolioquota = 0;
+ foreach my $name ('portfolio','author') {
+ if ($userenv{$name.'quota'} ne '') {
+ $oldquota{$name} = $userenv{$name.'quota'};
+ if ($env{'form.custom_'.$name.'quota'} == 1) {
+ if ($env{'form.'.$name.'quota'} eq '') {
+ $newquota{$name} = 0;
+ } else {
+ $newquota{$name} = $env{'form.'.$name.'quota'};
+ $newquota{$name} =~ s/[^\d\.]//g;
+ }
+ if ($newquota{$name} != $oldquota{$name}) {
+ if ("a_admin($newquota{$name},\%changeHash,$name)) {
+ $changed{$name.'quota'} = 1;
+ }
+ }
} else {
- $newportfolioquota = $env{'form.portfolioquota'};
- $newportfolioquota =~ s/[^\d\.]//g;
- }
- if ($newportfolioquota != $oldportfolioquota) {
- $changed{'quota'} = "a_admin($newportfolioquota,\%changeHash);
+ if ("a_admin('',\%changeHash,$name)) {
+ $changed{$name.'quota'} = 1;
+ $newquota{$name} = $newdefquota{$name};
+ $newisdefault{$name} = 1;
+ }
}
} else {
- $changed{'quota'} = "a_admin('',\%changeHash);
- $newportfolioquota = $defquota;
- $newisdefault = 1;
- }
- } else {
- $oldisdefault = 1;
- $oldportfolioquota = $defquota;
- if ($env{'form.customquota'} == 1) {
- if ($env{'form.portfolioquota'} eq '') {
- $newportfolioquota = 0;
+ $oldisdefault{$name} = 1;
+ $oldquota{$name} = $olddefquota{$name};
+ if ($env{'form.custom_'.$name.'quota'} == 1) {
+ if ($env{'form.'.$name.'quota'} eq '') {
+ $newquota{$name} = 0;
+ } else {
+ $newquota{$name} = $env{'form.'.$name.'quota'};
+ $newquota{$name} =~ s/[^\d\.]//g;
+ }
+ if ("a_admin($newquota{$name},\%changeHash,$name)) {
+ $changed{$name.'quota'} = 1;
+ }
} else {
- $newportfolioquota = $env{'form.portfolioquota'};
- $newportfolioquota =~ s/[^\d\.]//g;
+ $newquota{$name} = $newdefquota{$name};
+ $newisdefault{$name} = 1;
}
- $changed{'quota'} = "a_admin($newportfolioquota,\%changeHash);
+ }
+ if ($oldisdefault{$name}) {
+ $oldsettingstext{'quota'}{$name} = &get_defaultquota_text($oldsettingstatus{$name});
+ } else {
+ $oldsettingstext{'quota'}{$name} = &mt('custom quota: [_1] MB',$oldquota{$name});
+ }
+ if ($newisdefault{$name}) {
+ $newsettingstext{'quota'}{$name} = &get_defaultquota_text($newsettingstatus{$name});
} else {
- $newportfolioquota = $defquota;
- $newisdefault = 1;
+ $newsettingstext{'quota'}{$name} = &mt('custom quota: [_1] MB',$newquota{$name});
}
}
- if ($oldisdefault) {
- $oldsettingstext{'quota'} = &get_defaultquota_text($settingstatus);
- }
- if ($newisdefault) {
- $newsettingstext{'quota'} = &get_defaultquota_text($settingstatus);
- }
&tool_changes('tools',\@usertools,\%oldsettings,\%oldsettingstext,\%userenv,
\%changeHash,\%changed,\%newsettings,\%newsettingstext);
if ($env{'form.ccdomain'} eq $env{'request.role.domain'}) {
&tool_changes('requestcourses',\@requestcourses,\%oldsettings,\%oldsettingstext,
\%userenv,\%changeHash,\%changed,\%newsettings,\%newsettingstext);
+ my ($isadv,$isauthor) =
+ &Apache::lonnet::is_advanced_user($env{'form.ccdomain'},$env{'form.ccuname'});
+ unless ($isauthor) {
+ &tool_changes('requestauthor',\@requestauthor,\%oldsettings,\%oldsettingstext,
+ \%userenv,\%changeHash,\%changed,\%newsettings,\%newsettingstext);
+ }
+ &tool_changes('authordefaults',\@authordefaults,\%oldsettings,\%oldsettingstext,
+ \%userenv,\%changeHash,\%changed,\%newsettings,\%newsettingstext);
} else {
&tool_changes('reqcrsotherdom',\@requestcourses,\%oldsettings,\%oldsettingstext,
\%userenv,\%changeHash,\%changed,\%newsettings,\%newsettingstext);
@@ -2694,35 +3778,142 @@ sub update_user_data {
$namechanged{$item} = 1;
}
}
- $oldsettings{'quota'} = $oldportfolioquota.' Mb';
- $newsettings{'quota'} = $newportfolioquota.' Mb';
+ foreach my $name ('portfolio','author') {
+ $oldsettings{'quota'}{$name} = &mt('[_1] MB',$oldquota{$name});
+ $newsettings{'quota'}{$name} = &mt('[_1] MB',$newquota{$name});
+ }
if ((keys(%namechanged) > 0) || (keys(%changed) > 0)) {
- $changeHash{'firstname'} = $env{'form.cfirstname'};
- $changeHash{'middlename'} = $env{'form.cmiddlename'};
- $changeHash{'lastname'} = $env{'form.clastname'};
- $changeHash{'generation'} = $env{'form.cgeneration'};
- $changeHash{'id'} = $env{'form.cid'};
- $changeHash{'permanentemail'} = $env{'form.cpermanentemail'};
my ($chgresult,$namechgresult);
if (keys(%changed) > 0) {
- $chgresult =
+ $chgresult =
&Apache::lonnet::put('environment',\%changeHash,
$env{'form.ccdomain'},$env{'form.ccuname'});
if ($chgresult eq 'ok') {
+ my ($ca_mgr_del,%ca_mgr_add);
+ if ($changed{'managers'}) {
+ my (@adds,@dels);
+ if ($changeHash{'authormanagers'} eq '') {
+ @dels = split(/,/,$userenv{'authormanagers'});
+ } elsif ($userenv{'authormanagers'} eq '') {
+ @adds = split(/,/,$changeHash{'authormanagers'});
+ } else {
+ my @old = split(/,/,$userenv{'authormanagers'});
+ my @new = split(/,/,$changeHash{'authormanagers'});
+ my @diffs = &Apache::loncommon::compare_arrays(\@old,\@new);
+ if (@diffs) {
+ foreach my $user (@diffs) {
+ if (grep(/^\Q$user\E$/,@old)) {
+ push(@dels,$user);
+ } elsif (grep(/^\Q$user\E$/,@new)) {
+ push(@adds,$user);
+ }
+ }
+ }
+ }
+ my $key = "internal.manager./$env{'form.ccdomain'}/$env{'form.ccuname'}";
+ if (@dels) {
+ foreach my $user (@dels) {
+ if ($user =~ /^($match_username):($match_domain)$/) {
+ &Apache::lonnet::del('environment',[$key],$2,$1);
+ }
+ }
+ my $curruser = $env{'user.name'}.':'.$env{'user.domain'};
+ if (grep(/^\Q$curruser\E$/,@dels)) {
+ $ca_mgr_del = $key;
+ }
+ }
+ if (@adds) {
+ foreach my $user (@adds) {
+ if ($user =~ /^($match_username):($match_domain)$/) {
+ &Apache::lonnet::put('environment',{$key => 1},$2,$1);
+ }
+ }
+ my $curruser = $env{'user.name'}.':'.$env{'user.domain'};
+ if (grep(/^\Q$curruser\E$/,@adds)) {
+ $ca_mgr_add{$key} = 1;
+ }
+ }
+ }
if (($env{'user.name'} eq $env{'form.ccuname'}) &&
($env{'user.domain'} eq $env{'form.ccdomain'})) {
- my %newenvhash;
+ my (%newenvhash,$got_domdefs,%domdefaults,$got_userenv,
+ %userenv);
+ my @fromenv = keys(%changed);
+ push(@fromenv,'inststatus');
foreach my $key (keys(%changed)) {
- if (($key eq 'official') || ($key eq 'unofficial')
- || ($key eq 'community')) {
+ if (($key eq 'official') || ($key eq 'unofficial') ||
+ ($key eq 'community') || ($key eq 'textbook') ||
+ ($key eq 'placement') || ($key eq 'lti')) {
$newenvhash{'environment.requestcourses.'.$key} =
$changeHash{'requestcourses.'.$key};
- if ($changeHash{'requestcourses.'.$key} ne '') {
+ if ($changeHash{'requestcourses.'.$key}) {
$newenvhash{'environment.canrequest.'.$key} = 1;
} else {
+ unless ($got_domdefs) {
+ %domdefaults =
+ &Apache::lonnet::get_domain_defaults($env{'user.domain'});
+ $got_domdefs = 1;
+ }
+ unless ($got_userenv) {
+ %userenv =
+ &Apache::lonnet::userenvironment($env{'user.domain'},
+ $env{'user.name'},@fromenv);
+ $got_userenv = 1;
+ }
$newenvhash{'environment.canrequest.'.$key} =
&Apache::lonnet::usertools_access($env{'user.name'},$env{'user.domain'},
- $key,'reload','requestcourses');
+ $key,'reload','requestcourses',\%userenv,\%domdefaults);
+ }
+ } elsif ($key eq 'requestauthor') {
+ $newenvhash{'environment.'.$key} = $changeHash{$key};
+ if ($changeHash{$key}) {
+ $newenvhash{'environment.canrequest.author'} = 1;
+ } else {
+ unless ($got_domdefs) {
+ %domdefaults =
+ &Apache::lonnet::get_domain_defaults($env{'user.domain'});
+ $got_domdefs = 1;
+ }
+ unless ($got_userenv) {
+ %userenv =
+ &Apache::lonnet::userenvironment($env{'user.domain'},
+ $env{'user.name'},@fromenv);
+ $got_userenv = 1;
+ }
+ $newenvhash{'environment.canrequest.author'} =
+ &Apache::lonnet::usertools_access($env{'user.name'},$env{'user.domain'},
+ $key,'reload','requestauthor',\%userenv,\%domdefaults);
+ }
+ } elsif ($key eq 'editors') {
+ $newenvhash{'environment.author'.$key} = $changeHash{'author'.$key};
+ if ($env{'form.customeditors'}) {
+ $newenvhash{'environment.editors'} = $changeHash{'author'.$key};
+ } else {
+ unless ($got_domdefs) {
+ %domdefaults =
+ &Apache::lonnet::get_domain_defaults($env{'user.domain'});
+ $got_domdefs = 1;
+ }
+ if ($domdefaults{'editors'} ne '') {
+ $newenvhash{'environment.editors'} = $domdefaults{'editors'};
+ } else {
+ $newenvhash{'environment.editors'} = 'edit,xml';
+ }
+ }
+ } elsif ($key eq 'archive') {
+ $newenvhash{'environment.author.'.$key} =
+ $changeHash{'author.'.$key};
+ if ($changeHash{'author.'.$key} ne '') {
+ $newenvhash{'environment.canarchive'} =
+ $changeHash{'author.'.$key};
+ } else {
+ unless ($got_domdefs) {
+ %domdefaults =
+ &Apache::lonnet::get_domain_defaults($env{'user.domain'});
+ $got_domdefs = 1;
+ }
+ $newenvhash{'environment.canarchive'} =
+ $domdefaults{'archive'};
}
} elsif ($key ne 'quota') {
$newenvhash{'environment.tools.'.$key} =
@@ -2731,25 +3922,51 @@ sub update_user_data {
$newenvhash{'environment.availabletools.'.$key} =
$changeHash{'tools.'.$key};
} else {
+ unless ($got_domdefs) {
+ %domdefaults =
+ &Apache::lonnet::get_domain_defaults($env{'user.domain'});
+ $got_domdefs = 1;
+ }
+ unless ($got_userenv) {
+ %userenv =
+ &Apache::lonnet::userenvironment($env{'user.domain'},
+ $env{'user.name'},@fromenv);
+ $got_userenv = 1;
+ }
$newenvhash{'environment.availabletools.'.$key} =
- &Apache::lonnet::usertools_access($env{'user.name'},$env{'user.domain'}, $key,'reload','tools');
+ &Apache::lonnet::usertools_access($env{'user.name'},$env{'user.domain'},
+ $key,'reload','tools',\%userenv,\%domdefaults);
}
}
}
if (keys(%newenvhash)) {
&Apache::lonnet::appenv(\%newenvhash);
}
+ } else {
+ if ($ca_mgr_del) {
+ &Apache::lonnet::delenv($ca_mgr_del);
+ }
+ if (keys(%ca_mgr_add)) {
+ &Apache::lonnet::appenv(\%ca_mgr_add);
+ }
+ }
+ if ($changed{'aboutme'}) {
+ &Apache::loncommon::devalidate_aboutme_cache($env{'form.ccuname'},
+ $env{'form.ccdomain'});
}
}
}
if (keys(%namechanged) > 0) {
- # Make the change
+ foreach my $field (@userinfo) {
+ $changeHash{$field} = $env{'form.c'.$field};
+ }
+# Make the change
$namechgresult =
&Apache::lonnet::modifyuser($env{'form.ccdomain'},
$env{'form.ccuname'},$changeHash{'id'},undef,undef,
$changeHash{'firstname'},$changeHash{'middlename'},
$changeHash{'lastname'},$changeHash{'generation'},
- $changeHash{'id'},undef,$changeHash{'permanentemail'});
+ $changeHash{'id'},undef,$changeHash{'permanentemail'},undef,\@userinfo);
%userupdate = (
lastname => $env{'form.clastname'},
middlename => $env{'form.cmiddlename'},
@@ -2762,12 +3979,12 @@ sub update_user_data {
((keys(%changed) > 0) && $chgresult eq 'ok')) {
# Tell the user we changed the name
&display_userinfo($r,1,\@disporder,\%canshow,\@requestcourses,
- \@usertools,\%userenv,\%changed,\%namechanged,
+ \@usertools,\@requestauthor,\%userenv,\%changed,\%namechanged,
\%oldsettings, \%oldsettingstext,\%newsettings,
\%newsettingstext);
if ($env{'form.cid'} ne $userenv{'id'}) {
&Apache::lonnet::idput($env{'form.ccdomain'},
- ($env{'form.ccuname'} => $env{'form.cid'}));
+ {$env{'form.ccuname'} => $env{'form.cid'}},$uhome,'ids');
if (($recurseid) &&
(&Apache::lonnet::allowed('mau',$env{'form.ccdomain'}))) {
my $idresult =
@@ -2786,16 +4003,19 @@ sub update_user_data {
&Apache::lonnet::appenv(\%newenvhash);
}
} else { # error occurred
- $r->print(''.&mt('Unable to successfully change environment for').' '.
- $env{'form.ccuname'}.' '.&mt('in domain').' '.
- $env{'form.ccdomain'}.' ');
+ $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
# 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
&display_userinfo($r,undef,\@disporder,\%canshow,\@requestcourses,
- \@usertools,\%userenv,\%changed,\%namechanged,\%oldsettings,
+ \@usertools,\@requestauthor,\%userenv,\%changed,\%namechanged,\%oldsettings,
\%oldsettingstext,\%newsettings,\%newsettingstext);
}
if (@mod_disallowed) {
@@ -2806,9 +4026,9 @@ sub update_user_data {
$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();
@@ -2817,9 +4037,9 @@ sub update_user_data {
}
$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.' '
@@ -2832,17 +4052,20 @@ sub update_user_data {
.&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('
');
}
- $r->print(&Apache::loncommon::end_data_table().' ');
return;
}
@@ -3011,20 +4258,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;
}
@@ -3034,7 +4281,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};
}
@@ -3045,8 +4300,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) {
@@ -3080,15 +4344,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'");
}
}
}
@@ -3096,41 +4360,201 @@ sub tool_changes {
}
return;
}
+ my %tooldesc = &Apache::lonlocal::texthash(
+ 'edit' => 'Standard editor (Edit)',
+ 'xml' => 'Text editor (EditXML)',
+ 'daxe' => 'Daxe editor (Daxe)',
+ );
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;
+ } elsif ($context eq 'authordefaults') {
+ if ($tool eq 'editors') {
+ $envkey = 'authoreditors';
+ if ($env{'form.customeditors'} == 1) {
+ my @editors;
+ my @posseditors = &Apache::loncommon::get_env_multiple('form.custom_editor');
+ if (@posseditors) {
+ foreach my $editor (@posseditors) {
+ if (grep(/^\Q$editor\E$/,@posseditors)) {
+ unless (grep(/^\Q$editor\E$/,@editors)) {
+ push(@editors,$editor);
+ }
+ }
+ }
+ }
+ if (@editors) {
+ $newval = join(',',(sort(@editors)));
+ }
+ }
+ } elsif ($tool eq 'managers') {
+ $envkey = 'authormanagers';
+ my @possibles = &Apache::loncommon::get_env_multiple('form.custommanagers');
+ if (@possibles) {
+ my %ca_roles = &Apache::lonnet::get_my_roles($env{'form.ccuname'},$env{'form.ccdomain'},
+ undef,['active','future'],['ca']);
+ if (keys(%ca_roles)) {
+ my @custommanagers;
+ foreach my $user (@possibles) {
+ if ($user =~ /^($match_username):($match_domain)$/) {
+ if (exists($ca_roles{$user.':ca'})) {
+ unless ($user eq $env{'form.ccuname'}.':'.$env{'form.ccdomain'}) {
+ push(@custommanagers,$user);
+ }
+ }
+ }
+ }
+ if (@custommanagers) {
+ $newval = join(',',sort(@custommanagers));
+ }
+ }
+ }
+ } elsif ($tool eq 'webdav') {
+ $envkey = 'tools.webdav';
+ $newval = $env{'form.'.$context.'_'.$tool};
+ } elsif ($tool eq 'archive') {
+ $envkey = 'authorarchive';
+ $newval = $env{'form.'.$context.'_'.$tool};
}
} 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'");
+ }
+ } elsif ($context eq 'authordefaults') {
+ if ($tool eq 'managers') {
+ if ($userenv->{$envkey} eq '') {
+ $oldaccesstext->{$tool} = &mt('Only author may manage co-author roles');
+ } else {
+ my $managers = $userenv->{$envkey};
+ $managers =~ s/,/, /g;
+ $oldaccesstext->{$tool} = $managers;
+ }
+ } elsif ($tool eq 'editors') {
+ $oldaccesstext->{$tool} = &mt('can use: [_1]',
+ join(', ', map { $tooldesc{$_} } split(/,/,$userenv->{$envkey})));
+ } elsif (($tool eq 'webdav') || ($tool eq 'archive')) {
+ if ($userenv->{$envkey}) {
+ $oldaccesstext->{$tool} = &mt("availability set to 'on'");
+ } 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};
- if ($env{'form.custom'.$tool} == 1) {
- if ($newval ne $userenv->{$context.'.'.$tool}) {
+ $changeHash->{$envkey} = $userenv->{$envkey};
+ if (($env{'form.custom'.$tool} == 1) ||
+ (($context eq 'authordefaults') && ($tool eq 'managers') && ($newval ne ''))) {
+ 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'");
+ }
+ } elsif ($context eq 'authordefaults') {
+ if ($tool eq 'editors') {
+ $newaccesstext->{$tool} = &mt('can use: [_1]',
+ join(', ', map { $tooldesc{$_} } split(/,/,$changeHash->{$envkey})));
+ } elsif ($tool eq 'managers') {
+ if ($changeHash->{$envkey} eq '') {
+ $newaccesstext->{$tool} = &mt('Only author may manage co-author roles');
+ } else {
+ my $managers = $changeHash->{$envkey};
+ $managers =~ s/,/, /g;
+ $newaccesstext->{$tool} = $managers;
+ }
+ } elsif (($tool eq 'webdav') || ($tool eq 'archive')) {
+ if ($newval) {
+ $newaccesstext->{$tool} = &mt("availability set to 'on'");
+ } 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 ($userenv->{$envkey} =~ /^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 ($userenv->{$envkey}) {
+ $newaccesstext->{$tool} = $reqdisplay{$userenv->{$envkey}};
+ } else {
+ $newaccesstext->{$tool} = &mt("availability set to 'off'");
+ }
+ } elsif ($context eq 'authordefaults') {
+ if ($tool eq 'editors') {
+ $newaccesstext->{$tool} = &mt('can use: [_1]',
+ join(', ', map { $tooldesc{$_} } split(/,/,$userenv->{$envkey})));
+ } elsif ($tool eq 'managers') {
+ if ($userenv->{$envkey} eq '') {
+ $newaccesstext->{$tool} = &mt('Only author may manage co-author roles');
+ } else {
+ my $managers = $userenv->{$envkey};
+ $managers =~ s/,/, /g;
+ $newaccesstext->{$tool} = $managers;
+ }
+ } elsif (($tool eq 'webdav') || ($tool eq 'archive')) {
+ if ($userenv->{$envkey}) {
+ $newaccesstext->{$tool} = &mt("availability set to 'on'");
+ } 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 {
@@ -3143,24 +4567,91 @@ 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'");
+ }
+ } elsif ($context eq 'authordefaults') {
+ if ($tool eq 'editors') {
+ $newaccesstext->{$tool} = &mt('can use: [_1]',
+ join(', ', map { $tooldesc{$_} } split(/,/,$newval)));
+ } elsif ($tool eq 'managers') {
+ if ($newval eq '') {
+ $newaccesstext->{$tool} = &mt('Only author may manage co-author roles');
+ } else {
+ my $managers = $newval;
+ $managers =~ s/,/, /g;
+ $newaccesstext->{$tool} = $managers;
+ }
+ } elsif (($tool eq 'webdav') || ($tool eq 'archive')) {
+ if ($userenv->{$envkey}) {
+ $newaccesstext->{$tool} = &mt("availability set to 'on'");
+ } 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 {
$oldaccess->{$tool} = &mt('default');
- if ($env{'form.custom'.$tool} == 1) {
+ if (($env{'form.custom'.$tool} == 1) ||
+ (($context eq 'authordefaults') && ($tool eq 'managers') && ($newval ne ''))) {
$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'");
+ }
+ } elsif ($context eq 'authordefaults') {
+ if ($tool eq 'managers') {
+ if ($newval eq '') {
+ $newaccesstext->{$tool} = &mt('Only author may manage co-author roles');
+ } else {
+ my $managers = $newval;
+ $managers =~ s/,/, /g;
+ $newaccesstext->{$tool} = $managers;
+ }
+ } elsif ($tool eq 'editors') {
+ $newaccesstext->{$tool} = &mt('can use: [_1]',
+ join(', ', map { $tooldesc{$_} } split(/,/,$newval)));
+ } elsif (($tool eq 'webdav') || ($tool eq 'archive')) {
+ if ($newval) {
+ $newaccesstext->{$tool} = &mt("availability set to 'on'");
+ } 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};
@@ -3174,12 +4665,18 @@ sub tool_changes {
}
sub update_roles {
- my ($r,$context) = @_;
+ my ($r,$context,$showcredits) = @_;
my $now=time;
my @rolechanges;
- my %disallowed;
+ my (%disallowed,%got_role_approvals,%got_instdoms,%process_by,%instdoms,
+ %pending,%reject,%notifydc,%status,%unauthorized,%currqueued);
+ $got_role_approvals{$context} = '';
+ $process_by{$context} = {};
+ my @domroles = &Apache::lonuserutils::domain_roles();
+ my @cstrroles = &Apache::lonuserutils::construction_space_roles();
+ my @courseroles = &Apache::lonuserutils::roles_by_context('course',1);
$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
@@ -3191,14 +4688,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);
@@ -3206,11 +4709,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');
}
@@ -3224,14 +4731,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);
@@ -3240,11 +4754,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');
}
@@ -3256,31 +4776,66 @@ sub update_roles {
if ($key=~/^form\.ren\:([^\_]+)\_([^\_\.]+)$/) {
my $url = $1;
my $role = $2;
+ my $id = $url.'_'.$role;
my $logmsg;
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);
+ }
+ unless ($udom eq $cdom) {
+ next if (&Apache::lonuserutils::restricted_dom($context,$id,$udom,
+ $uname,$role,$now,0,$cdom,$cnum,$csec,$credits,
+ \%process_by,\%instdoms,\%got_role_approvals,
+ \%got_instdoms,\%reject,\%pending,\%notifydc,
+ \%status,\%unauthorized,\%currqueued));
+ }
+ 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 ($cdom,$cnum,$csec);
+ if (grep(/^\Q$role\E$/,@cstrroles)) {
+ ($cdom,$cnum) = ($url =~ m{^/($match_domain)/($match_username)$});
+ } elsif (grep(/^\Q$role\E$/,@domroles)) {
+ ($cdom) = ($url =~ m{^/($match_domain)/$});
+ } elsif ($url =~ m-^/($match_domain)/($match_courseid)/?(\w*)$-) {
+ ($cdom,$cnum,$csec) = ($1,$2,$3);
+ }
+ if ($cdom ne '') {
+ unless ($udom eq $cdom) {
+ next if (&Apache::lonuserutils::restricted_dom($context,$id,$udom,
+ $uname,$role,$now,0,$cdom,$cnum,$csec,'',\%process_by,
+ \%instdoms,\%got_role_approvals,\%got_instdoms,\%reject,
+ \%pending,\%notifydc,\%status,\%unauthorized,\%currqueued));
+ }
+ }
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);
@@ -3289,11 +4844,27 @@ sub update_roles {
# Re-enable custom role
if ($key=~m{^form\.ren\:([^_]+)_cr\.cr/($match_domain)/($match_username)/(\w+)$}) {
my ($url,$rdom,$rnam,$rolename) = ($1,$2,$3,$4);
+ my $id = $url.'_cr'."/$rdom/$rnam/$rolename";
+ my $role = "cr/$rdom/$rnam/$rolename";
+ if ($url =~ m-^/($match_domain)/($match_courseid)/?(\w*)$-) {
+ my ($cdom,$cnum,$csec) = ($1,$2,$3);
+ unless ($udom eq $cdom) {
+ next if (&Apache::lonuserutils::restricted_dom($context,$id,$udom,
+ $uname,$role,$now,0,$cdom,$cnum,$csec,'',\%process_by,
+ \%instdoms,\%got_role_approvals,\%got_instdoms,\%reject,
+ \%pending,\%notifydc,\%status,\%unauthorized,\%currqueued));
+ }
+ }
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');
}
@@ -3305,6 +4876,8 @@ sub update_roles {
# Activate a custom role
my ($one,$two,$three,$four,$five)=($1,$2,$3,$4,$5);
my $url='/'.$one.'/'.$two;
+ my $id = $url.'_cr/'."$three/$four/$five";
+ my $role = "cr/$three/$four/$five";
my $full=$one.'_'.$two.'_cr_cr_'.$three.'_'.$four.'_'.$five;
my $start = ( $env{'form.start_'.$full} ?
@@ -3313,24 +4886,41 @@ sub update_roles {
my $end = ( $env{'form.end_'.$full} ?
$env{'form.end_'.$full} :
0 );
-
+
# split multiple sections
my %sections = ();
- my $num_sections = &build_roles($env{'form.sec_'.$full},\%sections,$5);
+ my $num_sections = &build_roles($env{'form.sec_'.$full},\%sections,$five);
if ($num_sections == 0) {
+ unless ($udom eq $one) {
+ next if (&Apache::lonuserutils::restricted_dom($context,$id,$udom,
+ $uname,$role,$start,$end,$one,$two,'','',\%process_by,
+ \%instdoms,\%got_role_approvals,\%got_instdoms,\%reject,
+ \%pending,\%notifydc,\%status,\%unauthorized,\%currqueued));
+ }
$r->print(&Apache::loncommon::commit_customrole($udom,$uname,$url,$three,$four,$five,$start,$end,$context));
} else {
my %curr_groups =
&Apache::longroup::coursegroups($one,$two);
- foreach my $sec (sort {$a cmp $b} keys %sections) {
+ my ($restricted,$numchanges);
+ foreach my $sec (sort {$a cmp $b} keys(%sections)) {
if (($sec eq 'none') || ($sec eq 'all') ||
exists($curr_groups{$sec})) {
$disallowed{$sec} = $url;
next;
}
my $securl = $url.'/'.$sec;
+ my $secid = $securl.'_cr'."/$three/$four/$five";
+ undef($restricted);
+ unless ($udom eq $one) {
+ next if (&Apache::lonuserutils::restricted_dom($context,$secid,$udom,
+ $uname,$role,$start,$end,$one,$two,$sec,'',\%process_by,
+ \%instdoms,\%got_role_approvals,\%got_instdoms,\%reject,
+ \%pending,\%notifydc,\%status,\%unauthorized,\%currqueued));
+ }
+ $numchanges ++;
$r->print(&Apache::loncommon::commit_customrole($udom,$uname,$securl,$three,$four,$five,$start,$end,$context));
}
+ next unless ($numchanges);
}
if (!grep(/^cr$/,@rolechanges)) {
push(@rolechanges,'cr');
@@ -3339,24 +4929,44 @@ sub update_roles {
# Activate roles for sections with 3 id numbers
# set start, end times, and the url for the class
my ($one,$two,$three)=($1,$2,$3);
- my $start = ( $env{'form.start_'.$one.'_'.$two.'_'.$three} ?
- $env{'form.start_'.$one.'_'.$two.'_'.$three} :
+ my $start = ( $env{'form.start_'.$one.'_'.$two.'_'.$three} ?
+ $env{'form.start_'.$one.'_'.$two.'_'.$three} :
$now );
- my $end = ( $env{'form.end_'.$one.'_'.$two.'_'.$three} ?
+ my $end = ( $env{'form.end_'.$one.'_'.$two.'_'.$three} ?
$env{'form.end_'.$one.'_'.$two.'_'.$three} :
0 );
my $url='/'.$one.'/'.$two;
- my $type = 'three';
+ my $id = $url.'_'.$three;
# split multiple sections
my %sections = ();
my $num_sections = &build_roles($env{'form.sec_'.$one.'_'.$two.'_'.$three},\%sections,$three);
+ my ($credits,$numchanges);
+ 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));
+ unless ($udom eq $one) {
+ next if (&Apache::lonuserutils::restricted_dom($context,$id,$udom,
+ $uname,$three,$start,$end,$one,$two,'',$credits,\%process_by,
+ \%instdoms,\%got_role_approvals,\%got_instdoms,\%reject,
+ \%pending,\%notifydc,\%status,\%unauthorized,\%currqueued));
+ }
+ $numchanges ++;
+ $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) {
+ my $restricted;
+ foreach my $sec (sort {$a cmp $b} keys(%sections)) {
$sec =~ s/\W//g;
if ($sec ne '') {
if (($sec eq 'none') || ($sec eq 'all') ||
@@ -3365,14 +4975,34 @@ sub update_roles {
next;
}
my $securl = $url.'/'.$sec;
- $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$securl,$three,$start,$end,$one,$two,$sec,$context));
+ my $secid = $securl.'_'.$three;
+ unless ($udom eq $one) {
+ undef($restricted);
+ $restricted = &Apache::lonuserutils::restricted_dom($context,$secid,$udom,
+ $uname,$three,$start,$end,$one,$two,$sec,$credits,\%process_by,
+ \%instdoms,\%got_role_approvals,\%got_instdoms,\%reject,
+ \%pending,\%notifydc,\%status,\%unauthorized,\%currqueued);
+ next if ($restricted);
+ }
+ $numchanges ++;
+ $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));
+ unless ($udom eq $one) {
+ undef($restricted);
+ $restricted = &Apache::lonuserutils::restricted_dom($context,$id,$udom,
+ $uname,$three,$start,$end,$one,$two,'',$credits,\%process_by,
+ \%instdoms,\%got_role_approvals,\%got_instdoms,\%reject,
+ \%pending,\%notifydc,\%status,\%unauthorized,\%currqueued);
+ next if ($restricted);
+ }
+ $numchanges ++;
+ $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$url,$three,$start,$end,$one,$two,'',$context,$credits));
}
+ next unless ($numchanges);
}
if (!grep(/^\Q$three\E$/,@rolechanges)) {
push(@rolechanges,$three);
@@ -3380,33 +5010,64 @@ sub update_roles {
} elsif ($key=~/^form\.act\_([^\_]+)\_([^\_]+)$/) {
# Activate roles for sections with two id numbers
# set start, end times, and the url for the class
- my $start = ( $env{'form.start_'.$1.'_'.$2} ?
- $env{'form.start_'.$1.'_'.$2} :
+ my $start = ( $env{'form.start_'.$1.'_'.$2} ?
+ $env{'form.start_'.$1.'_'.$2} :
$now );
- my $end = ( $env{'form.end_'.$1.'_'.$2} ?
+ my $end = ( $env{'form.end_'.$1.'_'.$2} ?
$env{'form.end_'.$1.'_'.$2} :
0 );
my $one = $1;
my $two = $2;
my $url='/'.$one.'/';
+ my $id = $url.'_'.$two;
+ my ($cdom,$cnum) = split(/\//,$one);
# split multiple sections
my %sections = ();
+ my ($restricted,$numchanges);
my $num_sections = &build_roles($env{'form.sec_'.$one.'_'.$two},\%sections,$two);
if ($num_sections == 0) {
+ unless ($udom eq $one) {
+ $restricted = &Apache::lonuserutils::restricted_dom($context,$id,$udom,
+ $uname,$two,$start,$end,$cdom,$cnum,'','',\%process_by,
+ \%instdoms,\%got_role_approvals,\%got_instdoms,\%reject,
+ \%pending,\%notifydc,\%status,\%unauthorized,\%currqueued);
+ next if ($restricted);
+ }
+ $numchanges ++;
$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;
+ my $secid = $securl.'_'.$two;
+ unless ($udom eq $one) {
+ undef($restricted);
+ $restricted = &Apache::lonuserutils::restricted_dom($context,$secid,$udom,
+ $uname,$two,$start,$end,$cdom,$cnum,$sec,'',\%process_by,
+ \%instdoms,\%got_role_approvals,\%got_instdoms,\%reject,
+ \%pending,\%notifydc,\%status,\%unauthorized,\%currqueued);
+ next if ($restricted);
+ }
+ $numchanges ++;
$r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$securl,$two,$start,$end,$one,undef,$sec,$context));
} else {
$emptysec = 1;
}
}
if ($emptysec) {
+ unless ($udom eq $one) {
+ undef($restricted);
+ $restricted = &Apache::lonuserutils::restricted_dom($context,$id,$udom,
+ $uname,$two,$start,$end,$cdom,$cnum,'','',\%process_by,
+ \%instdoms,\%got_role_approvals,\%got_instdoms,\%reject,
+ \%pending,\%notifydc,\%status,\%unauthorized,\%currqueued);
+ next if ($restricted);
+ }
+ $numchanges ++;
$r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$url,$two,$start,$end,$one,undef,'',$context));
}
+ next unless ($numchanges);
}
if (!grep(/^\Q$two\E$/,@rolechanges)) {
push(@rolechanges,$two);
@@ -3430,16 +5091,45 @@ sub update_roles {
}
}
} # End of foreach (keys(%env))
+ if ((keys(%reject)) || (keys(%unauthorized))) {
+ $r->print(&Apache::lonuserutils::print_roles_rejected($context,\%reject,\%unauthorized));
+ }
+ if ((keys(%pending)) || (keys(%currqueued))) {
+ $r->print(&Apache::lonuserutils::print_roles_queued($context,\%pending,\%notifydc,\%currqueued));
+ }
# 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'));
@@ -3451,18 +5141,54 @@ 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);
+ }
+ }
+ }
+ my ($startdate,$enddate) = &Apache::lonuserutils::get_dates_from_form();
+ my (%got_role_approvals,%got_instdoms,%process_by,%instdoms,%pending,%reject,%notifydc,
+ %status,%unauthorized,%currqueued);
+ unless ($env{'form.ccdomain'} eq $env{'course.'.$env{'request.course.id'}.'.domain'}) {
+ my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+ my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
+ my $csec = $env{'form.sections'};
+ my $id = "/$cdom/$cnum";
+ if ($csec ne '') {
+ $id .= "/$csec";
+ }
+ $id .= '_st';
+ if (&Apache::lonuserutils::restricted_dom($context,$id,$env{'form.ccdomain'},$env{'form.ccuname'},
+ 'st',$startdate,$enddate,$cdom,$cnum,$csec,$credits,
+ \%process_by,\%instdoms,\%got_role_approvals,\%got_instdoms,
+ \%reject,\%pending,\%notifydc,\%status,\%unauthorized,\%currqueued)) {
+ if ((keys(%reject)) || (keys(%unauthorized))) {
+ $r->print(&Apache::lonuserutils::print_roles_rejected($context,\%reject,\%unauthorized));
+ }
+ if ((keys(%pending)) || (keys(%currqueued))) {
+ $r->print(&Apache::lonuserutils::print_roles_queued($context,\%pending,\%notifydc,\%currqueued));
+ }
+ return;
+ }
+ }
+
# 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);
- my ($startdate,$enddate) = &Apache::lonuserutils::get_dates_from_form();
my $enroll_result =
&Apache::lonnet::modify_student_enrollment($env{'form.ccdomain'},
$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'}));
}
@@ -3479,11 +5205,11 @@ 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(&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('
');
}
@@ -3497,14 +5223,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;
@@ -3513,7 +5239,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;
@@ -3559,6 +5285,14 @@ 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 ($context eq 'authordefaults') {
+ 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;
@@ -3567,7 +5301,15 @@ sub tool_admin {
if ($canchange) {
if (ref($changeHash) eq 'HASH') {
$toolchanged = 1;
- $changeHash->{$context.'.'.$tool} = $settool;
+ if ($tool eq 'requestauthor') {
+ $changeHash->{$context} = $settool;
+ } elsif (($tool eq 'managers') || ($tool eq 'editors') || ($tool eq 'archive')) {
+ $changeHash->{'author'.$tool} = $settool;
+ } elsif ($tool eq 'webdav') {
+ $changeHash->{'tools.'.$tool} = $settool;
+ } else {
+ $changeHash->{$context.'.'.$tool} = $settool;
+ }
}
}
return $toolchanged;
@@ -3609,288 +5351,116 @@ 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 .= '
';
}
$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.');
@@ -5046,10 +7814,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');
@@ -5073,8 +7841,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');
@@ -5120,7 +7888,45 @@ sub visible_in_cat {
unshift(@vismsgs,'dc_unhide')
}
}
- return ($visible,$cansetvis,\@vismsgs,\%visactions);
+ return ($visible,$cansetvis,\@vismsgs);
+}
+
+sub cat_visibility {
+ my ($cdom) = @_;
+ 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 catalog display 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.',
+ );
+ if ($env{'request.role'} eq "dc./$cdom/") {
+ $visactions{'dc_chgconf'} = &mt('Use: "Main menu" [_1] "Set domain configuration" [_1] "Cataloging of courses/communities" to change the Catalog type for this domain.','»');
+ $visactions{'dc_setcode'} = &mt('Use: "Main menu" [_1] "Set domain configuration" [_1] "Cataloging of courses/communities" to assign a six character code to the course.','»');
+ $visactions{'dc_unhide'} = &mt('Use: "Main menu" [_1] "Set domain configuration" [_1] "Cataloging of courses/communities" to change the "Exclude from course catalog" setting.','»');
+ $visactions{'dc_addinst'} = &mt('Use: "Main menu" [_1] "Set domain configuration" [_1] "Cataloging of courses/communities" to enable catalog display of "Official courses (with institutional codes)".','»');
+ $visactions{'dc_instcode'} = &mt('Use: "Main menu" [_1] "View or modify a course or community" [_1] "View/Modify course owner, institutional code ... " to assign an institutional code (if this is an official course).','»');
+ $visactions{'dc_catalog'} = &mt('Use: "Main menu" [_1] "Set domain configuration" [_1] "Cataloging of courses/communities" to enable or create at least one course category in the domain.','»');
+ $visactions{'dc_categories'} = &mt('Use: "Main menu" [_1] "Set domain configuration" [_1] "Cataloging of courses/communities" to create a hierarchy of categories and sub categories for courses in the domain.','»');
+ $visactions{'dc_chgcat'} = &mt('Use: "Main menu" [_1] "View or modify a course or community" [_1] "View/Modify catalog settings for course" to change the category assigned to the course, as the one currently assigned is no longer used in the domain.','»');
+ $visactions{'dc_addcat'} = &mt('Use: "Main menu" [_1] "View or modify a course or community" [_1] "View/Modify catalog settings for course" 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 {
@@ -5146,12 +7952,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';
@@ -5176,7 +7986,7 @@ sub selfenroll_inst_types {
$output .= 'checked="checked"';
}
}
- $output .= ' name="selfenroll_types_'.$num.'" />'.$usertypes->{$type}.'';
+ $output .= ' name="selfenroll_types_'.$num.'"'.$disabled.' />'.$usertypes->{$type}.'';
}
$count ++;
}
@@ -5199,7 +8009,7 @@ sub selfenroll_inst_types {
} else {
$output .= ' checked="checked"';
}
- $output .= ' name="selfenroll_types_'.$num.'" />'.$othertitle.'';
+ $output .= ' name="selfenroll_types_'.$num.'"'.$disabled.' />'.$othertitle.'';
}
return $output;
}
@@ -5220,19 +8030,69 @@ 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'};
+ } elsif ($env{'request.role'} =~ m{^ca\./($match_domain)/($match_username)$}) {
+ ($domain,$username) = ($1,$2);
+ } else {
+ undef($domain);
+ }
+ }
+ if ($domain ne '' && $username ne '') {
+ %roleslog=&Apache::lonnet::dump('nohist_rolelog',$domain,$username);
+ }
+ }
if ((keys(%roleslog))[0]=~/^error\:/) { undef(%roleslog); }
- my %saveable_parameters = ('show' => 'scalar',);
- &Apache::loncommon::store_course_settings('roles_log',
- \%saveable_parameters);
- &Apache::loncommon::restore_course_settings('roles_log',
- \%saveable_parameters);
+ my $helpitem;
+ if ($context eq 'course') {
+ $helpitem = 'Course_User_Logs';
+ } elsif ($context eq 'domain') {
+ $helpitem = 'Domain_Role_Logs';
+ } elsif ($context eq 'author') {
+ $helpitem = 'Author_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
@@ -5243,12 +8103,13 @@ sub print_userchangelogs_display {
chgcontext => 'any',
rolelog_start_date => $defstart,
rolelog_end_date => $now,
+ approvals => 'any',
);
my $more_records = 0;
# set current
my %curr;
- foreach my $item ('show','page','role','chgcontext') {
+ foreach my $item ('show','page','role','chgcontext','approvals') {
$curr{$item} = $env{'form.'.$item};
}
my ($startdate,$enddate) =
@@ -5265,7 +8126,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'};
@@ -5274,10 +8137,9 @@ sub print_userchangelogs_display {
# Form Header
$r->print('
');
+
+ if (keys(%customroles)) {
+ my %lt = &Apache::lonlocal::texthash(
+ 'aco' => 'As course owner you may override the defaults set in the domain for role usage and/or privileges.',
+ 'rou' => 'Role usage',
+ 'whi' => 'Which helpdesk personnel may use this role?',
+ 'udd' => 'Use domain default',
+ 'all' => 'All with domain helpdesk or helpdesk assistant role',
+ 'dh' => 'All with domain helpdesk role',
+ 'da' => 'All with domain helpdesk assistant role',
+ 'none' => 'None',
+ 'status' => 'Determined based on institutional status',
+ 'inc' => 'Include all, but exclude specific personnel',
+ 'exc' => 'Exclude all, but include specific personnel',
+ 'hel' => 'Helpdesk',
+ 'rpr' => 'Role privileges',
+ );
+ $lt{'tfh'} = &mt("Custom [_1]ad hoc[_2] course roles available for use by the domain's helpdesk are as follows",'','');
+ my %domconfig = &Apache::lonnet::get_dom('configuration',['helpsettings'],$cdom);
+ my (%domcurrent,%ordered,%description,%domusage,$disabled);
+ if (ref($domconfig{'helpsettings'}) eq 'HASH') {
+ if (ref($domconfig{'helpsettings'}{'adhoc'}) eq 'HASH') {
+ %domcurrent = %{$domconfig{'helpsettings'}{'adhoc'}};
+ }
+ }
+ my $count = 0;
+ foreach my $role (sort(keys(%customroles))) {
+ my ($order,$desc,$access_in_dom);
+ if (ref($domcurrent{$role}) eq 'HASH') {
+ $order = $domcurrent{$role}{'order'};
+ $desc = $domcurrent{$role}{'desc'};
+ $access_in_dom = $domcurrent{$role}{'access'};
+ }
+ if ($order eq '') {
+ $order = $count;
+ }
+ $ordered{$order} = $role;
+ if ($desc ne '') {
+ $description{$role} = $desc;
+ } else {
+ $description{$role}= $role;
+ }
+ $count++;
+ }
+ %domusage = &domain_adhoc_access(\%customroles,\%domcurrent,\@accesstypes,$usertypes,$othertitle);
+ my @roles_by_num = ();
+ foreach my $item (sort {$a <=> $b } (keys(%ordered))) {
+ push(@roles_by_num,$ordered{$item});
+ }
+ $r->print('
'.
+ '');
+ my %full=();
+ my %levels= (
+ course => {},
+ domain => {},
+ system => {},
+ );
+ my %levelscurrent=(
+ course => {},
+ domain => {},
+ system => {},
+ );
+ &Apache::lonuserutils::custom_role_privs($customroles{$role},\%full,\%levels,\%levelscurrent);
+ $r->print('
');
+ }
+ if ($permission->{'owner'}) {
+ $r->print('');
+ }
+ } else {
+ $r->print(&mt('Helpdesk roles have not yet been created in this domain.'));
+ }
+ # Form Footer
+ $r->print(''
+ .'
');
+ return;
+}
+
+sub print_queued_roles {
+ my ($r,$context,$permission,$brcrum) = @_;
+ push (@{$brcrum},
+ {href => '/adm/createuser?action=rolerequests',
+ text => 'Role Requests (other domains)',
+ help => ''});
+ my $bread_crumbs_component = 'Role Requests';
+ my $args = { bread_crumbs => $brcrum,
+ bread_crumbs_component => $bread_crumbs_component};
+ # print page header
+ $r->print(&header('',$args));
+ my ($dom,$cnum);
+ $dom = $env{'request.role.domain'};
+ if ($context eq 'course') {
+ if ($env{'request.course.id'}) {
+ if (&Apache::loncommon::course_type() eq 'Community') {
+ $context = 'community';
+ }
+ $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
+ }
+ } elsif ($context eq 'author') {
+ $cnum = $env{'user.name'};
+ }
+ $r->print(&Apache::loncoursequeueadmin::display_queued_requests('othdomqueue',$dom,$cnum,$context));
+ return;
+}
+
+sub print_pendingroles {
+ my ($r,$context,$permission,$brcrum) = @_;
+ push (@{$brcrum},
+ {href => '/adm/createuser?action=queuedroles',
+ text => 'Queued Role Assignments (users in this domain)',
+ help => ''});
+ my $bread_crumbs_component = 'Queued Role Assignments';
+ my $args = { bread_crumbs => $brcrum,
+ bread_crumbs_component => $bread_crumbs_component};
+ # print page header
+ $r->print(&header('',$args));
+ $r->print(&Apache::loncoursequeueadmin::display_queued_requests('othdomaction',$env{'request.role.domain'},'','domain'));
+ return;
+}
+
+sub process_pendingroles {
+ my ($r,$context,$permission,$brcrum) = @_;
+ push (@{$brcrum},
+ {href => '/adm/createuser?action=queuedroles',
+ text => 'Queued Role Assignments (users in this domain)',
+ help => ''},
+ {href => '/adm/createuser?action=processrolereq',
+ text => 'Process Queue',
+ help => ''});
+ my $bread_crumbs_component = 'Queued Role Assignments';
+ my $args = { bread_crumbs => $brcrum,
+ bread_crumbs_component => $bread_crumbs_component};
+ # print page header
+ $r->print(&header('',$args));
+ $r->print(&Apache::loncoursequeueadmin::update_request_queue('othdombydc',
+ $env{'request.role.domain'}));
+ return;
+}
+
+sub domain_adhoc_access {
+ my ($roles,$domcurrent,$accesstypes,$usertypes,$othertitle) = @_;
+ my %domusage;
+ return unless ((ref($roles) eq 'HASH') && (ref($domcurrent) eq 'HASH') && (ref($accesstypes) eq 'ARRAY'));
+ foreach my $role (keys(%{$roles})) {
+ if (ref($domcurrent->{$role}) eq 'HASH') {
+ my $access = $domcurrent->{$role}{'access'};
+ if (($access eq '') || (!grep(/^\Q$access\E$/,@{$accesstypes}))) {
+ $access = 'all';
+ $domusage{$role} = &mt('Any user in domain with active [_1] or [_2] role',&Apache::lonnet::plaintext('dh'),
+ &Apache::lonnet::plaintext('da'));
+ } elsif ($access eq 'status') {
+ if (ref($domcurrent->{$role}{$access}) eq 'ARRAY') {
+ my @shown;
+ foreach my $type (@{$domcurrent->{$role}{$access}}) {
+ unless ($type eq 'default') {
+ if ($usertypes->{$type}) {
+ push(@shown,$usertypes->{$type});
+ }
+ }
+ }
+ if (grep(/^default$/,@{$domcurrent->{$role}{$access}})) {
+ push(@shown,$othertitle);
+ }
+ if (@shown) {
+ my $shownstatus = join(' '.&mt('or').' ',@shown);
+ $domusage{$role} = &mt('Any user in domain with active [_1] or [_2] role, and institutional status: [_3]',
+ &Apache::lonnet::plaintext('dh'),&Apache::lonnet::plaintext('da'),$shownstatus);
+ } else {
+ $domusage{$role} = &mt('No one in the domain');
+ }
+ }
+ } elsif ($access eq 'inc') {
+ my @dominc = ();
+ if (ref($domcurrent->{$role}{'inc'}) eq 'ARRAY') {
+ foreach my $user (@{$domcurrent->{$role}{'inc'}}) {
+ my ($uname,$udom) = split(/:/,$user);
+ push(@dominc,&Apache::loncommon::aboutmewrapper(&Apache::loncommon::plainname($uname,$udom),$uname,$udom));
+ }
+ my $showninc = join(', ',@dominc);
+ if ($showninc ne '') {
+ $domusage{$role} = &mt('Include any user in domain with active [_1] or [_2] role, except: [_3]',
+ &Apache::lonnet::plaintext('dh'),&Apache::lonnet::plaintext('da'),$showninc);
+ } else {
+ $domusage{$role} = &mt('Any user in domain with active [_1] or [_2] role',
+ &Apache::lonnet::plaintext('dh'),&Apache::lonnet::plaintext('da'));
+ }
+ }
+ } elsif ($access eq 'exc') {
+ my @domexc = ();
+ if (ref($domcurrent->{$role}{'exc'}) eq 'ARRAY') {
+ foreach my $user (@{$domcurrent->{$role}{'exc'}}) {
+ my ($uname,$udom) = split(/:/,$user);
+ push(@domexc,&Apache::loncommon::aboutmewrapper(&Apache::loncommon::plainname($uname,$udom),$uname,$udom));
+ }
+ }
+ my $shownexc = join(', ',@domexc);
+ if ($shownexc ne '') {
+ $domusage{$role} = &mt('Only the following in the domain with active [_1] or [_2] role: [_3]',
+ &Apache::lonnet::plaintext('dh'),&Apache::lonnet::plaintext('da'),$shownexc);
+ } else {
+ $domusage{$role} = &mt('No one in the domain');
+ }
+ } elsif ($access eq 'none') {
+ $domusage{$role} = &mt('No one in the domain');
+ } elsif ($access eq 'dh') {
+ $domusage{$role} = &mt('Any user in domain with active [_1] role',&Apache::lonnet::plaintext('dh'));
+ } elsif ($access eq 'da') {
+ $domusage{$role} = &mt('Any user in domain with active [_1] role',&Apache::lonnet::plaintext('da'));
+ } elsif ($access eq 'all') {
+ $domusage{$role} = &mt('Any user in domain with active [_1] or [_2] role',
+ &Apache::lonnet::plaintext('dh'),&Apache::lonnet::plaintext('da'));
+ }
+ } else {
+ $domusage{$role} = &mt('Any user in domain with active [_1] or [_2] role',
+ &Apache::lonnet::plaintext('dh'),&Apache::lonnet::plaintext('da'));
+ }
+ }
+ return %domusage;
+}
+
+sub get_domain_customroles {
+ my ($cdom,$confname) = @_;
+ my %existing=&Apache::lonnet::dump('roles',$cdom,$confname,'rolesdef_');
+ 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;
+ }
+ }
+ return %customroles;
+}
+
+sub role_priv_table {
+ my ($role,$permission,$crstype,$full,$levels,$levelscurrent,$overridden) = @_;
+ return unless ((ref($full) eq 'HASH') && (ref($levels) eq 'HASH') &&
+ (ref($levelscurrent) eq 'HASH'));
+ my %lt=&Apache::lonlocal::texthash (
+ 'crl' => 'Course Level Privilege',
+ 'def' => 'Domain Defaults',
+ 'ove' => 'Override in Course',
+ 'ine' => 'In effect',
+ 'dis' => 'Disabled',
+ 'ena' => 'Enabled',
+ );
if ($crstype eq 'Community') {
- $lt{'createcourse'} = &mt('Community Creation');
- $lt{'course'} = &mt('User Management in community');
- $lt{'requestcourses'} = &mt('Community Request');
+ $lt{'ove'} = 'Override in Community',
}
- return %lt;
+ my @status = ('Disabled','Enabled');
+ my (%on,%off);
+ if (ref($overridden) eq 'HASH') {
+ if (ref($overridden->{'on'}) eq 'ARRAY') {
+ map { $on{$_} = 1; } (@{$overridden->{'on'}});
+ }
+ if (ref($overridden->{'off'}) eq 'ARRAY') {
+ map { $off{$_} = 1; } (@{$overridden->{'off'}});
+ }
+ }
+ my $output=&Apache::loncommon::start_data_table().
+ &Apache::loncommon::start_data_table_header_row().
+ '
'.$lt{'crl'}.'
'.$lt{'def'}.'
'.$lt{'ove'}.
+ '
'.$lt{'ine'}.'
'.
+ &Apache::loncommon::end_data_table_header_row();
+ foreach my $priv (sort(keys(%{$full}))) {
+ next unless ($levels->{'course'}{$priv});
+ my $privtext = &Apache::lonnet::plaintext($priv,$crstype);
+ my ($default,$ineffect);
+ if ($levelscurrent->{'course'}{$priv}) {
+ $default = '';
+ $ineffect = $default;
+ }
+ my ($customstatus,$checked);
+ $output .= &Apache::loncommon::start_data_table_row().
+ '
');
+ if ($env{'form.'.$role.'_incrs'}) {
+ if ($newsettings{$role}{'access'} eq 'all') {
+ $r->print(&mt('All helpdesk staff can access '.lc($crstype).' with this role.'));
+ } elsif ($newsettings{$role}{'access'} eq 'dh') {
+ $r->print(&mt('Helpdesk staff can use this role if they have an active [_1] role',
+ &Apache::lonnet::plaintext('dh')));
+ } elsif ($newsettings{$role}{'access'} eq 'da') {
+ $r->print(&mt('Helpdesk staff can use this role if they have an active [_1] role',
+ &Apache::lonnet::plaintext('da')));
+ } elsif ($newsettings{$role}{'access'} eq 'none') {
+ $r->print(&mt('No helpdesk staff can access '.lc($crstype).' with this role.'));
+ } elsif ($newsettings{$role}{'access'} eq 'status') {
+ if ($newsettings{$role}{'status'}) {
+ my ($access,$rest) = split(/=/,$storehash{'internal.adhoc.'.$role});
+ if (split(/,/,$rest) > 1) {
+ $r->print(&mt('Helpdesk staff can use this role if their institutional type is one of: [_1].',
+ $newsettings{$role}{'status'}));
+ } else {
+ $r->print(&mt('Helpdesk staff can use this role if their institutional type is: [_1].',
+ $newsettings{$role}{'status'}));
+ }
+ } else {
+ $r->print(&mt('No helpdesk staff can access '.lc($crstype).' with this role.'));
+ }
+ } elsif ($newsettings{$role}{'access'} eq 'exc') {
+ if ($newsettings{$role}{'exc'}) {
+ $r->print(&mt('Helpdesk staff who can use this role are as follows:').' '.$newsettings{$role}{'exc'}.'.');
+ } else {
+ $r->print(&mt('No helpdesk staff can access '.lc($crstype).' with this role.'));
+ }
+ } elsif ($newsettings{$role}{'access'} eq 'inc') {
+ if ($newsettings{$role}{'inc'}) {
+ $r->print(&mt('All helpdesk staff may use this role except the following:').' '.$newsettings{$role}{'inc'}.'.');
+ } else {
+ $r->print(&mt('All helpdesk staff may use this role.'));
+ }
+ }
+ } else {
+ $r->print(&mt('Default access set in the domain now applies.').' '.
+ ''.$domusage{$role}.'');
+ }
+ $r->print('
');
+ }
+ unless ($newsettings{$role}{'access'} eq 'none') {
+ if ($changed{$role}{'off'}) {
+ if ($newsettings{$role}{'off'}) {
+ $r->print('
'.&mt('Privileges which are available by default for this ad hoc role, but are disabled for this specific '.lc($crstype).':').
+ '
'.$newsettings{$role}{'off'}.'
');
+ } else {
+ $r->print('
'.&mt('All privileges available by default for this ad hoc role are enabled.').'
');
+ }
+ }
+ if ($changed{$role}{'on'}) {
+ if ($newsettings{$role}{'on'}) {
+ $r->print('
'.&mt('Privileges which are not available by default for this ad hoc role, but are enabled for this specific '.lc($crstype).':').
+ '
'.$newsettings{$role}{'on'}.'
');
+ } else {
+ $r->print('
'.&mt('None of the privileges unavailable by default for this ad hoc role are enabled.').'
');
+ }
+ }
+ }
+ $r->print('
');
+ }
+ $r->print('
');
+ }
+ } else {
+ $r->print(&mt('No changes made to helpdesk access settings.'));
+ }
+ }
+ return;
}
#-------------------------------------------------- functions for &phase_two
@@ -5580,13 +9936,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 in the institutional directory.');
+ }
+ $response .= ' ';
+ }
+ } else {
+ unless (($context eq 'requestcrs') && ($srch->{'srchtype'} eq 'exact')) {
+ my $domd_chk = &domdirectorysrch_check($srch);
+ if (($domd_chk ne 'ok') && ($env{'form.action'} ne 'accesslogs')) {
+ 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 in the LON-CAPA domain.');
+ }
+ $response .= ' ';
+ }
}
}
if ($response ne '') {
@@ -5616,6 +9988,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} =
@@ -5681,8 +10056,8 @@ sub user_search_result {
$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.').
- '
';
+ &mt('You may want to search in the LON-CAPA domain instead of in the institutional directory.').
+ ' ';
}
}
} else {
@@ -5750,18 +10125,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.').
- '
';
+ &mt('You may want to search in the LON-CAPA domain instead of in 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;
@@ -5883,7 +10278,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'});
@@ -5903,7 +10302,7 @@ sub build_search_response {
if ($srch->{'srchin'} ne 'alc') {
$forcenewuser = 1;
my $cansrchinst = 0;
- if ($srch->{'srchdomain'}) {
+ if (($srch->{'srchdomain'}) && ($env{'form.action'} ne 'accesslogs')) {
my %domconfig = &Apache::lonnet::get_dom('configuration',['directorysrch'],$srch->{'srchdomain'});
if (ref($domconfig{'directorysrch'}) eq 'HASH') {
if ($domconfig{'directorysrch'}{'available'}) {
@@ -5928,7 +10327,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.'';
@@ -5952,18 +10352,20 @@ sub build_search_response {
.&mt("Click 'Search'")
.'
';
- if ($context eq 'requestcrs') {
- $response .= &mt("You are not authorized to define new users in the new course's domain - [_1].",$targetdom);
- } else {
- $response .= &mt("You are not authorized to create new users in your current role's domain - [_1].",$targetdom);
+ unless (($context eq 'domain') && ($env{'form.action'} eq 'singleuser')) {
+ my $helplink = ' href="javascript:helpMenu('."'display'".')"';
+ $response .= '
';
+ if ($context eq 'requestcrs') {
+ $response .= &mt("You are not authorized to define new users in the new course's domain - [_1].",$targetdom);
+ } else {
+ $response .= &mt("You are not authorized to create new users in your current role's domain - [_1].",$targetdom);
+ }
+ $response .= ' '
+ .&mt('Please contact the [_1]helpdesk[_2] if you need to create a new user.'
+ ,' '
+ ,'')
+ .' ';
}
- $response .= ' '
- .&mt('Please contact the [_1]helpdesk[_2] if you need to create a new user.'
- ,' '
- ,'')
- .'
';
}
}
}
@@ -6030,7 +10432,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?
@@ -6045,15 +10448,16 @@ 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);
- my $isowner = &is_courseowner($protectedcourse,$coursedata{'internal.courseowner'});
+ my $isowner = &Apache::lonuserutils::is_courseowner($protectedcourse,$coursedata{'internal.courseowner'});
my $area=$coursedata{'description'};
my $crstype=$coursedata{'type'};
if (!defined($area)) { $area=&mt('Unavailable course').': '.$protectedcourse; }
@@ -6071,12 +10475,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);
}
}
}
@@ -6085,7 +10491,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);
}
}
}
@@ -6098,8 +10505,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();
@@ -6107,12 +10520,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().
'