--- loncom/interface/loncreateuser.pm 2009/10/31 14:27:48 1.321
+++ loncom/interface/loncreateuser.pm 2014/02/10 18:39:29 1.389
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Create a user
#
-# $Id: loncreateuser.pm,v 1.321 2009/10/31 14:27:48 raeburn Exp $
+# $Id: loncreateuser.pm,v 1.389 2014/02/10 18:39:29 bisitz Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -51,13 +51,14 @@ In LON-CAPA, roles are actually collecti
Assistant", "Course Coordinator", and other such roles are really just
collection of privileges that are useful in many circumstances.
-Creating custom roles can be done by the Domain Coordinator through
-the Create User functionality. That screen will show all privileges
-that can be assigned to users. For a complete list of privileges,
-please see C.
+Custom roles can be defined by a Domain Coordinator, Course Coordinator
+or Community Coordinator via the Manage User functionality.
+The custom role editor screen will show all privileges which can be
+assigned to users. For a complete list of privileges, please see
+C.
-Custom role definitions are stored in the C '
+ .&mt('Unable to determine home server for [_1] in domain [_2].',
+ '"'.$env{'form.ccuname'}.'"','"'.$env{'form.ccdomain'}.'"')
+ .' '
+ .&mt('Unable to successfully change environment for [_1] in domain [_2].',
+ '"'.$env{'form.ccuname'}.'"',
+ '"'.$env{'form.ccdomain'}.'"')
+ .' '
- .&mt('Modify this user: [_1]',''.$env{'form.ccuname'}.':'.$env{'form.ccdomain'}.' ('.$userinfo.')').''
- .(' 'x5).''
- .&mt('Create/Modify Another User').' '.&mt('No changes made to user information').' '.&mt('No roles to modify').' ');
+ $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.'));
} else {
@@ -3365,14 +3962,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;
@@ -3381,7 +3978,7 @@ sub get_defaultquota_text {
sub update_result_form {
my ($uhome) = @_;
my $outcome =
- ' '.&mt('Create or edit another custom role').' '.&mt('Display User Lists').'');
- $r->print(&Apache::loncommon::end_page());
}
} else {
- &Apache::lonhtmlcommon::add_breadcrumb
- ({href=>'/adm/createuser?action=listusers',
- text=>"List Users"});
+ push(@{$brcrum},
+ {href => '/adm/createuser?action=listusers',
+ text => "List Users",
+ help => 'Course_View_Class_List'});
+ $bread_crumbs_component = 'List Users';
+ $args = {bread_crumbs => $brcrum,
+ bread_crumbs_component => $bread_crumbs_component};
my ($cb_jscript,$jscript,$totcodes,$codetitles,$idlist,$idlist_titles);
my $formname = 'studentform';
+ my $hidecall = "hide_searching();";
if (($context eq 'domain') && (($env{'form.roletype'} eq 'course') ||
($env{'form.roletype'} eq 'community'))) {
if ($env{'form.roletype'} eq 'course') {
@@ -3973,132 +4724,144 @@ sub handler {
);
$jscript = &Apache::lonhtmlcommon::set_form_elements(\%elements);
}
- $jscript .= &verify_user_display();
+ $jscript .= &verify_user_display($context)."\n".
+ &Apache::loncommon::check_uncheck_jscript();
my $js = &add_script($jscript).$cb_jscript;
my $loadcode =
&Apache::lonuserutils::course_selector_loadcode($formname);
if ($loadcode ne '') {
- $r->print(&header($js,{'onload' => $loadcode,}));
+ $args->{add_entries} = {onload => "$loadcode;$hidecall"};
} else {
- $r->print(&header($js));
+ $args->{add_entries} = {onload => $hidecall};
}
+ $r->print(&header($js,$args));
} else {
- $r->print(&header(&add_script(&verify_user_display())));
+ $args->{add_entries} = {onload => $hidecall};
+ $jscript = &verify_user_display($context).
+ &Apache::loncommon::check_uncheck_jscript();
+ $r->print(&header(&add_script($jscript),$args));
}
- $r->print(&Apache::lonhtmlcommon::breadcrumbs("List Users",
- 'Course_View_Class_List'));
&Apache::lonuserutils::print_userlist($r,undef,$permission,$context,
- $formname,$totcodes,$codetitles,$idlist,$idlist_titles);
- $r->print(&Apache::loncommon::end_page());
+ $formname,$totcodes,$codetitles,$idlist,$idlist_titles,
+ $showcredits);
}
} elsif ($env{'form.action'} eq 'drop' && $permission->{'cusr'}) {
- $r->print(&header());
my $brtext;
if ($crstype eq 'Community') {
$brtext = 'Drop Members';
} else {
$brtext = 'Drop Students';
}
- &Apache::lonhtmlcommon::add_breadcrumb
- ({href=>'/adm/createuser?action=drop',
- text=>$brtext});
+ push(@{$brcrum},
+ {href => '/adm/createuser?action=drop',
+ text => $brtext,
+ help => 'Course_Drop_Student'});
+ if ($env{'form.state'} eq 'done') {
+ push(@{$brcrum},
+ {href=>'/adm/createuser?action=drop',
+ text=>"Result"});
+ }
+ $bread_crumbs_component = $brtext;
+ $args = {bread_crumbs => $brcrum,
+ bread_crumbs_component => $bread_crumbs_component};
+ $r->print(&header(undef,$args));
if (!exists($env{'form.state'})) {
- $r->print(&Apache::lonhtmlcommon::breadcrumbs($brtext,
- 'Course_Drop_Student'));
-
&Apache::lonuserutils::print_drop_menu($r,$context,$permission,$crstype);
} elsif ($env{'form.state'} eq 'done') {
- &Apache::lonhtmlcommon::add_breadcrumb
- ({href=>'/adm/createuser?action=drop',
- text=>"Result"});
- $r->print(&Apache::lonhtmlcommon::breadcrumbs($brtext,
- 'Course_Drop_Student'));
&Apache::lonuserutils::update_user_list($r,$context,undef,
$env{'form.action'});
}
- $r->print(&Apache::loncommon::end_page());
} elsif ($env{'form.action'} eq 'dateselect') {
if ($permission->{'cusr'}) {
- $r->print(&header(undef,undef,{'no_nav_bar' => 1}).
- &Apache::lonuserutils::date_section_selector($context,
- $permission,$crstype).
- &Apache::loncommon::end_page());
- } else {
- $r->print(&header().
- ''.&mt('You do not have permission to modify dates or sections for users').''.
- &Apache::loncommon::end_page());
+ $r->print(&header(undef,{'no_nav_bar' => 1}).
+ &Apache::lonuserutils::date_section_selector($context,$permission,
+ $crstype,$showcredits));
+ } else {
+ $r->print(&header(undef,{'no_nav_bar' => 1}).
+ ''.&mt('You do not have permission to modify dates or sections for users').'');
}
} elsif ($env{'form.action'} eq 'selfenroll') {
- $r->print(&header());
- &Apache::lonhtmlcommon::add_breadcrumb
- ({href=>'/adm/createuser?action=selfenroll',
- text=>"Configure Self-enrollment"});
+ push(@{$brcrum},
+ {href => '/adm/createuser?action=selfenroll',
+ text => "Configure Self-enrollment",
+ help => 'Course_Self_Enrollment'});
if (!exists($env{'form.state'})) {
- $r->print(&Apache::lonhtmlcommon::breadcrumbs('Configure Self-enrollment',
- 'Course_Self_Enrollment'));
+ $args = { bread_crumbs => $brcrum,
+ bread_crumbs_component => 'Configure Self-enrollment'};
+ $r->print(&header(undef,$args));
$r->print(' '
.&mt('There are no records to display.')
.' ';
- if (($curr{'page'} > 1) || ($more_records)) {
- if ($curr{'page'} > 1) {
- $nav_links .= ' ';
- }
- if ($more_records) {
- $nav_links .= '';
+ # Navigation Buttons
+ $nav_links = ' ';
+ if (($curr->{'page'} > 1) || ($more_records)) {
+ if ($curr->{'page'} > 1) {
+ $nav_links .= ' ';
+ }
+ if ($more_records) {
+ $nav_links .= '';
+ }
}
+ $nav_links .= ''.$lt{'usrt'}.'
'."\n".
&Apache::loncommon::start_data_table();
@@ -188,29 +165,71 @@ END_SCRIPT
if (&Apache::lonnet::allowed('mut',$ccdomain)) {
$output .= &build_tools_display($ccuname,$ccdomain,'tools');
}
- if (&Apache::lonnet::allowed('mpq',$ccdomain)) {
- $output .= ''."\n".
- ' '."\n".
- &Apache::loncommon::start_data_table_row()."\n".
- ' '.$lt{'disk'}.' '."\n".
- ' '.$lt{'cuqu'}.': '.
- $currquota.' Mb. '.
- $defaultinfo.' '."\n".
- &Apache::loncommon::end_data_table_row()."\n".
- &Apache::loncommon::start_data_table_row()."\n".
- ' '.$lt{'chqu'}.
- ': '.
- ' '.
- ' Mb '."\n".
- &Apache::loncommon::end_data_table_row()."\n";
- }
+
+ my %titles = &Apache::lonlocal::texthash (
+ portfolio => "Disk space allocated to user's portfolio files",
+ author => "Disk space allocated to user's Authoring Space (if role assigned)",
+ );
+ foreach my $name ('portfolio','author') {
+ my ($currquota,$quotatype,$inststatus,$defquota) =
+ &Apache::loncommon::get_user_quota($ccuname,$ccdomain,$name);
+ if ($longinsttype eq '') {
+ if ($inststatus ne '') {
+ if ($usertypes->{$inststatus} ne '') {
+ $longinsttype = $usertypes->{$inststatus};
+ }
+ }
+ }
+ my ($showquota,$custom_on,$custom_off,$defaultinfo);
+ $custom_on = ' ';
+ $custom_off = ' checked="checked" ';
+ if ($quotatype eq 'custom') {
+ $custom_on = $custom_off;
+ $custom_off = ' ';
+ $showquota = $currquota;
+ if ($longinsttype eq '') {
+ $defaultinfo = &mt('For this user, the default quota would be [_1]'
+ .' MB.',$defquota);
+ } else {
+ $defaultinfo = &mt("For this user, the default quota would be [_1]".
+ " MB, as determined by the user's institutional".
+ " affiliation ([_2]).",$defquota,$longinsttype);
+ }
+ } else {
+ if ($longinsttype eq '') {
+ $defaultinfo = &mt('For this user, the default quota is [_1]'
+ .' MB.',$defquota);
+ } else {
+ $defaultinfo = &mt("For this user, the default quota of [_1]".
+ " MB, is determined by the user's institutional".
+ " affiliation ([_2]).",$defquota,$longinsttype);
+ }
+ }
+
+ if (&Apache::lonnet::allowed('mpq',$ccdomain)) {
+ $output .= ''."\n".
+ ' '."\n".
+ &Apache::loncommon::start_data_table_row()."\n".
+ ' '.$titles{$name}.' '."\n".
+ ' '.$lt{'cuqu'}.': '.
+ $currquota.' MB. '.
+ $defaultinfo.' '."\n".
+ &Apache::loncommon::end_data_table_row()."\n".
+ &Apache::loncommon::start_data_table_row()."\n".
+ ' '.$lt{'chqu'}.
+ ': '.
+ ' '.
+ ' MB '."\n".
+ &Apache::loncommon::end_data_table_row()."\n";
+ }
+ }
$output .= &Apache::loncommon::end_data_table();
return $output;
}
@@ -218,10 +237,11 @@ END_SCRIPT
sub build_tools_display {
my ($ccuname,$ccdomain,$context) = @_;
my (@usertools,%userenv,$output,@options,%validations,%reqtitles,%reqdisplay,
- $colspan);
+ $colspan,$isadv,%domconfig);
my %lt = &Apache::lonlocal::texthash (
'blog' => "Personal User Blog",
'aboutme' => "Personal Information Page",
+ 'webdav' => "WebDAV access to Authoring Spaces (if SSL and author/co-author)",
'portfolio' => "Personal User Portfolio",
'avai' => "Available",
'cusa' => "availability",
@@ -231,21 +251,37 @@ sub build_tools_display {
'official' => 'Can request creation of official courses',
'unofficial' => 'Can request creation of unofficial courses',
'community' => 'Can request creation of communities',
+ 'textbook' => 'Can request creation of textbook courses',
+ 'requestauthor' => 'Can request author space',
);
if ($context eq 'requestcourses') {
%userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname,
'requestcourses.official','requestcourses.unofficial',
- 'requestcourses.community');
- @usertools = ('official','unofficial','community');
+ 'requestcourses.community','requestcourses.textbook');
+ @usertools = ('official','unofficial','community','textbook');
@options =('norequest','approval','autolimit','validate');
%validations = &Apache::lonnet::auto_courserequest_checks($ccdomain);
%reqtitles = &courserequest_titles();
%reqdisplay = &courserequest_display();
$colspan = ' colspan="2"';
+ %domconfig =
+ &Apache::lonnet::get_dom('configuration',['requestcourses'],$ccdomain);
+ $isadv = &Apache::lonnet::is_advanced_user($ccuname,$ccdomain);
+ } elsif ($context eq 'requestauthor') {
+ %userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname,
+ 'requestauthor');
+ @usertools = ('requestauthor');
+ @options =('norequest','approval','automatic');
+ %reqtitles = &requestauthor_titles();
+ %reqdisplay = &requestauthor_display();
+ $colspan = ' colspan="2"';
+ %domconfig =
+ &Apache::lonnet::get_dom('configuration',['requestauthor'],$ccdomain);
} else {
%userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname,
- 'tools.aboutme','tools.portfolio','tools.blog');
- @usertools = ('aboutme','blog','portfolio');
+ 'tools.aboutme','tools.portfolio','tools.blog',
+ 'tools.webdav');
+ @usertools = ('aboutme','blog','webdav','portfolio');
}
foreach my $item (@usertools) {
my ($custom_access,$curr_access,$cust_on,$cust_off,$tool_on,$tool_off,
@@ -255,7 +291,12 @@ sub build_tools_display {
$curr_access =
&Apache::lonnet::usertools_access($ccuname,$ccdomain,$item,undef,
$context);
- if ($userenv{$context.'.'.$item} ne '') {
+ if ($context eq 'requestauthor') {
+ if ($userenv{$context} ne '') {
+ $cust_on = ' checked="checked" ';
+ $cust_off = '';
+ }
+ } elsif ($userenv{$context.'.'.$item} ne '') {
$cust_on = ' checked="checked" ';
$cust_off = '';
}
@@ -265,6 +306,12 @@ sub build_tools_display {
} else {
$custom_access = &mt('Currently from custom setting.');
}
+ } elsif ($context eq 'requestauthor') {
+ if ($userenv{$context} eq '') {
+ $custom_access = &mt('Currently from default setting.');
+ } else {
+ $custom_access = &mt('Currently from custom setting.');
+ }
} else {
if ($userenv{$context.'.'.$item} eq '') {
$custom_access =
@@ -286,9 +333,28 @@ sub build_tools_display {
' '.$lt{$item}.' '."\n".
' '."\n".
&Apache::loncommon::start_data_table_row()."\n";
- if ($context eq 'requestcourses') {
+ if (($context eq 'requestcourses') || ($context eq 'requestauthor')) {
my ($curroption,$currlimit);
- $curroption = $userenv{$context.'.'.$item};
+ my $envkey = $context.'.'.$item;
+ if ($context eq 'requestauthor') {
+ $envkey = $context;
+ }
+ if ($userenv{$envkey} ne '') {
+ $curroption = $userenv{$envkey};
+ } else {
+ my (@inststatuses);
+ if ($context eq 'requestcourses') {
+ $curroption =
+ &Apache::loncoursequeueadmin::get_processtype('course',$ccuname,$ccdomain,
+ $isadv,$ccdomain,$item,
+ \@inststatuses,\%domconfig);
+ } else {
+ $curroption =
+ &Apache::loncoursequeueadmin::get_processtype('requestauthor',$ccuname,$ccdomain,
+ $isadv,$ccdomain,undef,
+ \@inststatuses,\%domconfig);
+ }
+ }
if (!$curroption) {
$curroption = 'norequest';
}
@@ -325,28 +391,36 @@ sub build_tools_display {
$checked = ' checked="checked"';
}
}
+ my $name = 'crsreq_'.$item;
+ if ($context eq 'requestauthor') {
+ $name = $item;
+ }
$custdisp .= ' ';
+ } else {
+ $custdisp .= '';
+ }
+ $custdisp .= '';
}
$custdisp .= '';
$custradio = ' ';
if ($option eq 'autolimit') {
- $custdisp .= '
'.
$reqtitles{'unlimited'};
- } else {
- $custdisp .= '';
- }
- $custdisp .= ''.&mt('Custom setting').'
'.$custdisp;
} else {
$currdisp = ($curr_access?&mt('Yes'):&mt('No'));
+ my $name = $context.'_'.$item;
+ if ($context eq 'requestauthor') {
+ $name = $context;
+ }
$custdisp = ' ';
$custradio = (' 'x2).'--'.$lt{'cusa'}.': '.$custdisp.
'';
@@ -373,12 +447,13 @@ sub coursereq_externaluser {
'official' => 'Can request creation of official courses',
'unofficial' => 'Can request creation of unofficial courses',
'community' => 'Can request creation of communities',
+ 'textbook' => 'Can request creation of textbook courses',
);
%userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname,
'reqcrsotherdom.official','reqcrsotherdom.unofficial',
- 'reqcrsotherdom.community');
- @usertools = ('official','unofficial','community');
+ 'reqcrsotherdom.community','reqcrsotherdom.textbook');
+ @usertools = ('official','unofficial','community','textbook');
@options = ('approval','validate','autolimit');
%validations = &Apache::lonnet::auto_courserequest_checks($cdom);
my $optregex = join('|',@options);
@@ -442,11 +517,23 @@ sub coursereq_externaluser {
return $output;
}
+sub domainrole_req {
+ my ($ccuname,$ccdomain) = @_;
+ return ''.
+ &mt('User Can Request Assignment of Domain Roles?').
+ '
'."\n".
+ &Apache::loncommon::start_data_table().
+ &build_tools_display($ccuname,$ccdomain,
+ 'requestauthor').
+ &Apache::loncommon::end_data_table();
+}
+
sub courserequest_titles {
my %titles = &Apache::lonlocal::texthash (
official => 'Official',
unofficial => 'Unofficial',
community => 'Communities',
+ textbook => 'Textbook',
norequest => 'Not allowed',
approval => 'Approval by Dom. Coord.',
validate => 'With validation',
@@ -465,10 +552,93 @@ 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) = @_;
my $defdom=$env{'request.role.domain'};
my $formtoset = 'crtuser';
if (exists($env{'form.startrolename'})) {
@@ -487,22 +657,10 @@ sub print_username_entry_form {
'// ]]>'."\n".
''."\n";
- 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 %existingroles=&Apache::lonuserutils::my_custom_roles($crstype);
+ if (($env{'form.action'} eq 'custom') && (keys(%existingroles) > 0)
+ && (&Apache::lonnet::allowed('mcr','/'))) {
+ $jscript .= &customrole_javascript();
}
my $helpitem = 'Course_Change_Privileges';
if ($env{'form.action'} eq 'custom') {
@@ -510,33 +668,77 @@ sub print_username_entry_form {
} elsif ($env{'form.action'} eq 'singlestudent') {
$helpitem = 'Course_Add_Student';
}
- my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('User Management',
- $helpitem);
- my %existingroles=&Apache::lonuserutils::my_custom_roles();
- my $choice=&Apache::loncommon::select_form('make new role','rolename',
- ('make new role' => 'Generate new role ...',%existingroles));
+ my %breadcrumb_text = &singleuser_breadcrumb($crstype);
+ 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',
'usr' => "Username",
'dom' => "Domain",
- 'ecrp' => "Edit Custom Role Privileges",
- 'nr' => "Name of Role",
+ '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','/')) {
- $r->print(<$lt{'ecrp'}
-$choice $lt{'nr'}:
-
-
-ENDCUSTOM
+ my $newroletext = &mt('Define new custom role:');
+ $r->print('');
}
} else {
my $actiontext = $lt{'srad'};
@@ -547,19 +749,54 @@ ENDCUSTOM
$actiontext = $lt{'srst'};
}
}
- $r->print("
-$actiontext
");
+ $r->print("$actiontext
");
if ($env{'form.origform'} ne 'crtusername') {
$r->print("\n".$response);
}
$r->print(&entry_form($defdom,$srch,$forcenewuser,$context,$response,$crstype));
}
- $r->print(&Apache::loncommon::end_page());
+}
+
+sub customrole_javascript {
+ my $js = <<"END";
+
+END
+ return $js;
}
sub entry_form {
my ($dom,$srch,$forcenewuser,$context,$responsemsg,$crstype) = @_;
- my %domconf = &Apache::lonnet::get_dom('configuration',['usercreation'],$dom);
my ($usertype,$inexact);
if (ref($srch) eq 'HASH') {
if (($srch->{'srchin'} eq 'dom') &&
@@ -567,9 +804,10 @@ 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;
}
@@ -663,19 +901,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('
'."\n".''.$title.'
'."\n");
+ $r->print(''.&mt('User Can Request Creation of Courses/Communities in this Domain?').'
'.
+ $r->print(''.
+ &mt('User Can Request Creation of Courses/Communities in this Domain?').'
'.
&Apache::loncommon::start_data_table().
&build_tools_display($ccuname,$ccdomain,
'requestcourses').
@@ -1086,45 +1354,35 @@ ENDAUTH
} else {
$r->print(&Apache::lonuserutils::set_login($ccdomain,$authformkrb,$authformint,$authformloc));
}
- $r->print($portfolioform);
+ $r->print($portfolioform.$domroleform);
if ($env{'form.action'} eq 'singlestudent') {
$r->print(&date_sections_select($context,$newuser,$formname,
- $permission));
+ $permission,$crstype,$ccuname,
+ $ccdomain,$showcredits));
}
$r->print(''.$title.'
'."\n");
+ $r->print(''.&mt('User Can Request Creation of Courses/Communities in this Domain?').'
'.
+ $r->print(''.&mt('User Can Request Creation of Courses/Communities in this Domain?').'
'.
&Apache::loncommon::start_data_table());
if ($env{'request.role.domain'} eq $ccdomain) {
$r->print(&build_tools_display($ccuname,$ccdomain,'requestcourses'));
@@ -1135,24 +1393,29 @@ ENDCHANGEUSER
$r->print(&Apache::loncommon::end_data_table());
}
$r->print('
'.$user_text{$item});
}
}
- $r->print('
'."\n");
} else {
- $r->print(''.&mt('Add Roles').'
');
+ $r->print('
'."\n");
} elsif ($context eq 'author') {
if ($addrolesdisplay) {
- $r->print('
print('
print(' onclick="auth_check()" \>'."\n");
} else {
$r->print('onclick="this.form.submit()" \>'."\n");
}
} else {
- $r->print('
'.
+ $r->print('
'.
&mt('Back to previous page').'');
}
} else {
- $r->print(&course_level_table(%inccourses));
- $r->print('
'."\n");
+ $r->print(&course_level_table(\%inccourses,$showcredits,$defaultcredits));
+ $r->print('
'."\n");
}
}
$r->print(&Apache::lonhtmlcommon::echo_form_input(['phase','userrole','ccdomain','prevphase','currstate','ccuname','ccdomain']));
$r->print('');
- $r->print('');
- $r->print("".&Apache::loncommon::end_page());
+ $r->print('');
return;
}
@@ -1272,22 +1531,32 @@ sub singleuser_breadcrumb {
}
sub date_sections_select {
- my ($context,$newuser,$formname,$permission) = @_;
+ my ($context,$newuser,$formname,$permission,$crstype,$ccuname,$ccdomain,
+ $showcredits) = @_;
+ my $credits;
+ if ($showcredits) {
+ my $defaultcredits = &Apache::lonuserutils::get_defaultcredits();
+ $credits = &get_user_credits($ccuname,$ccdomain,$defaultcredits);
+ if ($credits eq '') {
+ $credits = $defaultcredits;
+ }
+ }
my $cid = $env{'request.course.id'};
my ($cnum,$cdom) = &Apache::lonuserutils::get_course_identity($cid);
my $date_table = ''.&mt('Starting and Ending Dates').'
'."\n".
&Apache::lonuserutils::date_setting_table(undef,undef,$context,
undef,$formname,$permission);
my $rowtitle = 'Section';
- my $secbox = ''.&mt('Section').'
'."\n".
+ my $secbox = ''.&mt('Section and Credits').'
'."\n".
&Apache::lonuserutils::section_picker($cdom,$cnum,'st',$rowtitle,
- $permission);
+ $permission,$context,'',$crstype,
+ $showcredits,$credits);
my $output = $date_table.$secbox;
return $output;
}
sub validation_javascript {
- my ($context,$ccdomain,$pjump_def,$groupslist,$newuser,$formname,
+ my ($context,$ccdomain,$pjump_def,$crstype,$groupslist,$newuser,$formname,
$loaditem) = @_;
my $dc_setcourse_code = '';
my $nondc_setsection_code = '';
@@ -1304,7 +1573,8 @@ sub validation_javascript {
if ($context eq 'course') {
$nondc_setsection_code =
&Apache::lonuserutils::setsections_javascript($formname,$groupslist,
- undef,$checkauth);
+ undef,$checkauth,
+ $crstype);
}
if ($checkauth) {
$nondc_setsection_code .=
@@ -1324,214 +1594,290 @@ sub validation_javascript {
}
sub display_existing_roles {
- my ($r,$ccuname,$ccdomain,$inccourses) = @_;
- my %rolesdump=&Apache::lonnet::dump('roles',$ccdomain,$ccuname);
- # Build up table of user roles to allow revocation and re-enabling of roles.
- my ($tmp) = keys(%rolesdump);
- if ($tmp !~ /^(con_lost|error)/i) {
- my $now=time;
- my %lt=&Apache::lonlocal::texthash(
+ my ($r,$ccuname,$ccdomain,$inccourses,$context,$roledom,$crstype,
+ $showcredits) = @_;
+ my $now=time;
+ my %lt=&Apache::lonlocal::texthash(
'rer' => "Existing Roles",
'rev' => "Revoke",
'del' => "Delete",
'ren' => "Re-Enable",
'rol' => "Role",
'ext' => "Extent",
+ 'crd' => "Credits",
'sta' => "Start",
'end' => "End",
);
- my (%roletext,%sortrole,%roleclass,%rolepriv);
- foreach my $area (sort { my $a1=join('_',(split('_',$a))[1,0]);
- my $b1=join('_',(split('_',$b))[1,0]);
- return $a1 cmp $b1;
- } keys(%rolesdump)) {
- next if ($area =~ /^rolesdef/);
- my $envkey=$area;
- my $role = $rolesdump{$area};
- my $thisrole=$area;
- $area =~ s/\_\w\w$//;
- my ($role_code,$role_end_time,$role_start_time) =
- split(/_/,$role);
+ my (%rolesdump,%roletext,%sortrole,%roleclass,%rolepriv);
+ if ($context eq 'course' || $context eq 'author') {
+ my @roles = &Apache::lonuserutils::roles_by_context($context,1,$crstype);
+ my %roleshash =
+ &Apache::lonnet::get_my_roles($ccuname,$ccdomain,'userroles',
+ ['active','previous','future'],\@roles,$roledom,1);
+ foreach my $key (keys(%roleshash)) {
+ my ($start,$end) = split(':',$roleshash{$key});
+ next if ($start eq '-1' || $end eq '-1');
+ my ($rnum,$rdom,$role,$sec) = split(':',$key);
+ if ($context eq 'course') {
+ next unless (($rnum eq $env{'course.'.$env{'request.course.id'}.'.num'})
+ && ($rdom eq $env{'course.'.$env{'request.course.id'}.'.domain'}));
+ } elsif ($context eq 'author') {
+ next unless (($rnum eq $env{'user.name'}) && ($rdom eq $env{'request.role.domain'}));
+ }
+ my ($newkey,$newvalue,$newrole);
+ $newkey = '/'.$rdom.'/'.$rnum;
+ if ($sec ne '') {
+ $newkey .= '/'.$sec;
+ }
+ $newvalue = $role;
+ if ($role =~ /^cr/) {
+ $newrole = 'cr';
+ } else {
+ $newrole = $role;
+ }
+ $newkey .= '_'.$newrole;
+ if ($start ne '' && $end ne '') {
+ $newvalue .= '_'.$end.'_'.$start;
+ } elsif ($end ne '') {
+ $newvalue .= '_'.$end;
+ }
+ $rolesdump{$newkey} = $newvalue;
+ }
+ } else {
+ %rolesdump=&Apache::lonnet::dump('roles',$ccdomain,$ccuname);
+ }
+ # Build up table of user roles to allow revocation and re-enabling of roles.
+ my ($tmp) = keys(%rolesdump);
+ return if ($tmp =~ /^(con_lost|error)/i);
+ foreach my $area (sort { my $a1=join('_',(split('_',$a))[1,0]);
+ my $b1=join('_',(split('_',$b))[1,0]);
+ return $a1 cmp $b1;
+ } keys(%rolesdump)) {
+ next if ($area =~ /^rolesdef/);
+ my $envkey=$area;
+ my $role = $rolesdump{$area};
+ my $thisrole=$area;
+ $area =~ s/\_\w\w$//;
+ my ($role_code,$role_end_time,$role_start_time) =
+ split(/_/,$role);
# Is this a custom role? Get role owner and title.
- my ($croleudom,$croleuname,$croletitle)=
- ($role_code=~m{^cr/($match_domain)/($match_username)/(\w+)$});
- my $allowed=0;
- my $delallowed=0;
- my $sortkey=$role_code;
- my $class='Unknown';
- if ($area =~ m{^/($match_domain)/($match_courseid)} ) {
- $class='Course';
- my ($coursedom,$coursedir) = ($1,$2);
- $sortkey.="\0$coursedom";
- # $1.'_'.$2 is the course id (eg. 103_12345abcef103l3).
- my %coursedata=
- &Apache::lonnet::coursedescription($1.'_'.$2);
- my $carea;
- if (defined($coursedata{'description'})) {
- $carea=$coursedata{'description'}.
- '
'.&mt('Domain').': '.$coursedom.(' 'x8).
- &Apache::loncommon::syllabuswrapper(&mt('Syllabus'),$coursedir,$coursedom);
- $sortkey.="\0".$coursedata{'description'};
- $class=$coursedata{'type'};
+ my ($croleudom,$croleuname,$croletitle)=
+ ($role_code=~m{^cr/($match_domain)/($match_username)/(\w+)$});
+ my $allowed=0;
+ my $delallowed=0;
+ my $sortkey=$role_code;
+ my $class='Unknown';
+ my $credits='';
+ if ($area =~ m{^/($match_domain)/($match_courseid)} ) {
+ $class='Course';
+ my ($coursedom,$coursedir) = ($1,$2);
+ my $cid = $1.'_'.$2;
+ # $1.'_'.$2 is the course id (eg. 103_12345abcef103l3).
+ my %coursedata=
+ &Apache::lonnet::coursedescription($cid);
+ if ($coursedir =~ /^$match_community$/) {
+ $class='Community';
+ }
+ $sortkey.="\0$coursedom";
+ my $carea;
+ if (defined($coursedata{'description'})) {
+ $carea=$coursedata{'description'}.
+ '
'.&mt('Domain').': '.$coursedom.(' 'x8).
+ &Apache::loncommon::syllabuswrapper(&mt('Syllabus'),$coursedir,$coursedom);
+ $sortkey.="\0".$coursedata{'description'};
+ } else {
+ if ($class eq 'Community') {
+ $carea=&mt('Unavailable community').': '.$area;
+ $sortkey.="\0".&mt('Unavailable community').': '.$area;
} else {
$carea=&mt('Unavailable course').': '.$area;
$sortkey.="\0".&mt('Unavailable course').': '.$area;
}
- $sortkey.="\0$coursedir";
- $inccourses->{$1.'_'.$2}=1;
- if ((&Apache::lonnet::allowed('c'.$role_code,$1.'/'.$2)) ||
- (&Apache::lonnet::allowed('c'.$role_code,$ccdomain))) {
- $allowed=1;
- }
- if ((&Apache::lonnet::allowed('dro',$1)) ||
- (&Apache::lonnet::allowed('dro',$ccdomain))) {
- $delallowed=1;
+ }
+ $sortkey.="\0$coursedir";
+ $inccourses->{$cid}=1;
+ if (($showcredits) && ($class eq 'Course') && ($role_code eq 'st')) {
+ my $defaultcredits = $coursedata{'internal.defaultcredits'};
+ $credits =
+ &get_user_credits($ccuname,$ccdomain,$defaultcredits,
+ $coursedom,$coursedir);
+ if ($credits eq '') {
+ $credits = $defaultcredits;
+ }
+ }
+ if ((&Apache::lonnet::allowed('c'.$role_code,$coursedom.'/'.$coursedir)) ||
+ (&Apache::lonnet::allowed('c'.$role_code,$ccdomain))) {
+ $allowed=1;
+ }
+ unless ($allowed) {
+ my $isowner = &Apache::lonuserutils::is_courseowner($cid,$coursedata{'internal.courseowner'});
+ if ($isowner) {
+ if (($role_code eq 'co') && ($class eq 'Community')) {
+ $allowed = 1;
+ } elsif (($role_code eq 'cc') && ($class eq 'Course')) {
+ $allowed = 1;
+ }
}
+ }
+ if ((&Apache::lonnet::allowed('dro',$coursedom)) ||
+ (&Apache::lonnet::allowed('dro',$ccdomain))) {
+ $delallowed=1;
+ }
# - custom role. Needs more info, too
- if ($croletitle) {
- if (&Apache::lonnet::allowed('ccr',$1.'/'.$2)) {
- $allowed=1;
- $thisrole.='.'.$role_code;
- }
+ if ($croletitle) {
+ if (&Apache::lonnet::allowed('ccr',$coursedom.'/'.$coursedir)) {
+ $allowed=1;
+ $thisrole.='.'.$role_code;
}
- # Compute the background color based on $area
- if ($area=~m{^/($match_domain)/($match_courseid)/(\w+)}) {
- $carea.='
Section: '.$3;
- $sortkey.="\0$3";
- if (!$allowed) {
- if ($env{'request.course.sec'} eq $3) {
- if (&Apache::lonnet::allowed('c'.$role_code,$1.'/'.$2.'/'.$3)) {
- $allowed = 1;
- }
+ }
+ if ($area=~m{^/($match_domain)/($match_courseid)/(\w+)}) {
+ $carea.='
'.&mt('Section: [_1]',$3);
+ $sortkey.="\0$3";
+ if (!$allowed) {
+ if ($env{'request.course.sec'} eq $3) {
+ if (&Apache::lonnet::allowed('c'.$role_code,$1.'/'.$2.'/'.$3)) {
+ $allowed = 1;
}
}
}
- $area=$carea;
- } else {
- $sortkey.="\0".$area;
- # Determine if current user is able to revoke privileges
- if ($area=~m{^/($match_domain)/}) {
- if ((&Apache::lonnet::allowed('c'.$role_code,$1)) ||
- (&Apache::lonnet::allowed('c'.$role_code,$ccdomain))) {
- $allowed=1;
- }
- if (((&Apache::lonnet::allowed('dro',$1)) ||
- (&Apache::lonnet::allowed('dro',$ccdomain))) &&
- ($role_code ne 'dc')) {
- $delallowed=1;
- }
- } else {
- if (&Apache::lonnet::allowed('c'.$role_code,'/')) {
- $allowed=1;
- }
+ }
+ $area=$carea;
+ } else {
+ $sortkey.="\0".$area;
+ # Determine if current user is able to revoke privileges
+ if ($area=~m{^/($match_domain)/}) {
+ if ((&Apache::lonnet::allowed('c'.$role_code,$1)) ||
+ (&Apache::lonnet::allowed('c'.$role_code,$ccdomain))) {
+ $allowed=1;
}
- if ($role_code eq 'ca' || $role_code eq 'au') {
- $class='Construction Space';
- } elsif ($role_code eq 'su') {
- $class='System';
- } else {
- $class='Domain';
+ if (((&Apache::lonnet::allowed('dro',$1)) ||
+ (&Apache::lonnet::allowed('dro',$ccdomain))) &&
+ ($role_code ne 'dc')) {
+ $delallowed=1;
}
- }
- if (($role_code eq 'ca') || ($role_code eq 'aa')) {
- $area=~m{/($match_domain)/($match_username)};
- if (&Apache::lonuserutils::authorpriv($2,$1)) {
+ } else {
+ if (&Apache::lonnet::allowed('c'.$role_code,'/')) {
$allowed=1;
- } else {
- $allowed=0;
}
}
- my $row = '';
- $row.= '';
- my $active=1;
- $active=0 if (($role_end_time) && ($now>$role_end_time));
- if (($active) && ($allowed)) {
- $row.= '';
- } else {
- if ($active) {
- $row.=' ';
- } else {
- $row.=&mt('expired or revoked');
- }
- }
- $row.=' ';
- if ($allowed && !$active) {
- $row.= '';
- } else {
- $row.=' ';
- }
- $row.=' ';
- if ($delallowed) {
- $row.= '';
- } else {
- $row.=' ';
- }
- my $plaintext='';
- if (!$croletitle) {
- $plaintext=&Apache::lonnet::plaintext($role_code,$class)
- } else {
- $plaintext=
- "Customrole '$croletitle'
defined by $croleuname\@$croleudom";
- }
- $row.= ''.$plaintext.
- ' '.$area.
- ' '.($role_start_time?&Apache::lonlocal::locallocaltime($role_start_time)
- : ' ' ).
- ' '.($role_end_time ?&Apache::lonlocal::locallocaltime($role_end_time)
- : ' ' )
- ." ";
- $sortrole{$sortkey}=$envkey;
- $roletext{$envkey}=$row;
- $roleclass{$envkey}=$class;
- $rolepriv{$envkey}=$allowed;
- #$r->print($row);
- } # end of foreach (table building loop)
- my $rolesdisplay = 0;
- my %output = ();
- foreach my $type ('Construction Space','Course','Community','Domain','System','Unknown') {
- $output{$type} = '';
- foreach my $which (sort {uc($a) cmp uc($b)} (keys(%sortrole))) {
- if ( ($roleclass{$sortrole{$which}} =~ /^\Q$type\E/ ) && ($rolepriv{$sortrole{$which}}) ) {
- $output{$type}.=
- &Apache::loncommon::start_data_table_row().
- $roletext{$sortrole{$which}}.
- &Apache::loncommon::end_data_table_row();
- }
- }
- unless($output{$type} eq '') {
- $output{$type} = ''.
- " ".
- $output{$type};
- $rolesdisplay = 1;
- }
- }
- if ($rolesdisplay == 1) {
- my $contextrole='';
- if ($env{'request.course.id'}) {
- my $crstype = &Apache::loncommon::course_type();
- $contextrole = "Existing Roles in this $crstype";
- } elsif ($env{'request.role'} =~ /^au\./) {
- $contextrole = 'Existing Co-Author Roles in your Construction Space';
- } else {
- $contextrole = 'Existing Roles in this Domain';
- }
- $r->print('
-".&mt($type)." '.$lt{'rer'}.'
'.
-'';
+ my $active=1;
+ $active=0 if (($role_end_time) && ($now>$role_end_time));
+ if (($active) && ($allowed)) {
+ $row.= '';
+ } else {
+ if ($active) {
+ $row.=' ';
+ } else {
+ $row.=&mt('expired or revoked');
+ }
+ }
+ $row.=' ';
+ if ($allowed && !$active) {
+ $row.= '';
+ } else {
+ $row.=' ';
+ }
+ $row.=' ';
+ if ($delallowed) {
+ $row.= '';
+ } else {
+ $row.=' ';
+ }
+ my $plaintext='';
+ if (!$croletitle) {
+ $plaintext=&Apache::lonnet::plaintext($role_code,$class);
+ if (($showcredits) && ($credits ne '')) {
+ $plaintext .= '
'.
+ ''.
+ &mt('Credits: [_1]',$credits).
+ '';
+ }
+ } else {
+ $plaintext=
+ &mt('Customrole [_1][_2]defined by [_3]',
+ '"'.$croletitle.'"',
+ '
',
+ $croleuname.':'.$croleudom);
+ }
+ $row.= ''.$plaintext.
+ ' '.$area.
+ ' '.($role_start_time?&Apache::lonlocal::locallocaltime($role_start_time)
+ : ' ' ).
+ ' '.($role_end_time ?&Apache::lonlocal::locallocaltime($role_end_time)
+ : ' ' )
+ ." ";
+ $sortrole{$sortkey}=$envkey;
+ $roletext{$envkey}=$row;
+ $roleclass{$envkey}=$class;
+ $rolepriv{$envkey}=$allowed;
+ } # end of foreach (table building loop)
+
+ my $rolesdisplay = 0;
+ my %output = ();
+ foreach my $type ('Authoring Space','Course','Community','Domain','System','Unknown') {
+ $output{$type} = '';
+ foreach my $which (sort {uc($a) cmp uc($b)} (keys(%sortrole))) {
+ if ( ($roleclass{$sortrole{$which}} =~ /^\Q$type\E/ ) && ($rolepriv{$sortrole{$which}}) ) {
+ $output{$type}.=
+ &Apache::loncommon::start_data_table_row().
+ $roletext{$sortrole{$which}}.
+ &Apache::loncommon::end_data_table_row();
+ }
+ }
+ unless($output{$type} eq '') {
+ $output{$type} = ''.
+ " ".
+ $output{$type};
+ $rolesdisplay = 1;
+ }
+ }
+ if ($rolesdisplay == 1) {
+ my $contextrole='';
+ if ($env{'request.course.id'}) {
+ if (&Apache::loncommon::course_type() eq 'Community') {
+ $contextrole = &mt('Existing Roles in this Community');
+ } else {
+ $contextrole = &mt('Existing Roles in this Course');
+ }
+ } elsif ($env{'request.role'} =~ /^au\./) {
+ $contextrole = &mt('Existing Co-Author Roles in your Authoring Space');
+ } else {
+ $contextrole = &mt('Existing Roles in this Domain');
+ }
+ $r->print('".&mt($type)."
'.&Apache::lonuserutils::forceid_change($context);
}
}
$row .= &Apache::lonhtmlcommon::row_closure(1);
@@ -1921,13 +2268,26 @@ sub personal_data_display {
if ($canmodify_status{'inststatus'}) {
$shown = &pick_inst_statuses($userenv{'inststatus'},$usertypes,$types);
} else {
- $shown .= $userenv{'inststatus'};
if ($userenv{'inststatus'} eq '') {
$hiderow = 1;
+ } else {
+ my @showitems;
+ foreach my $item ( map { &unescape($_); } split(':',$userenv{'inststatus'})) {
+ if (exists($usertypes->{$item})) {
+ push(@showitems,$usertypes->{$item});
+ } else {
+ push(@showitems,$item);
+ }
+ }
+ if (@showitems) {
+ $shown = join(', ',@showitems);
+ } else {
+ $hiderow = 1;
+ }
}
}
if (!$hiderow) {
- my $row = &Apache::lonhtmlcommon::row_title(&mt('Affliations'),undef,'LC_oddrow_value')."\n".
+ my $row = &Apache::lonhtmlcommon::row_title(&mt('Affiliations'),undef,'LC_oddrow_value')."\n".
$shown.&Apache::lonhtmlcommon::row_closure(1);
if ($context eq 'selfcreate') {
$rowcount ++;
@@ -1942,7 +2302,7 @@ sub personal_data_display {
if ($context eq 'selfcreate') {
return($output,$rowcount,$editable);
} else {
- return ($output,$showforceid);
+ return $output;
}
} else {
return $output;
@@ -2019,7 +2379,7 @@ sub get_inststatuses {
# ================================================================= Phase Three
sub update_user_data {
- my ($r,$context,$crstype) = @_;
+ my ($r,$context,$crstype,$brcrum,$showcredits) = @_;
my $uhome=&Apache::lonnet::homeserver($env{'form.ccuname'},
$env{'form.ccdomain'});
# Error messages
@@ -2044,36 +2404,39 @@ sub update_user_data {
'// ]]>'."\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',});
+ 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';
}
- $r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management',
- $helpitem));
+ 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::loncommon::start_page($title,$jscript,$args));
$r->print(&update_result_form($uhome));
# Check Inputs
if (! $env{'form.ccuname'} ) {
@@ -2104,9 +2467,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('User [_1] in domain [_2]',
- $env{'form.ccuname'}, $env{'form.ccdomain'}).'
');
+ $env{'form.ccuname'}.' ('.&Apache::loncommon::plainname($env{'form.ccuname'},
+ $env{'form.ccdomain'}).')', $env{'form.ccdomain'}).'');
+ my %prog_state = &Apache::lonhtmlcommon::Create_PrgWin($r,2);
+
my (%alerts,%rulematch,%inst_results,%curr_rules);
- my @usertools = ('aboutme','blog','portfolio');
- my @requestcourses = ('official','unofficial','community');
+ my @userinfo = ('firstname','middlename','lastname','generation','permanentemail','id');
+ my @usertools = ('aboutme','blog','webdav','portfolio');
+ my @requestcourses = ('official','unofficial','community','textbook');
+ my @requestauthor = ('requestauthor');
my ($othertitle,$usertypes,$types) =
&Apache::loncommon::sorted_inst_types($env{'form.ccdomain'});
+ my %canmodify_status =
+ &Apache::lonuserutils::can_modify_userinfo($context,$env{'form.ccdomain'},
+ ['inststatus']);
if ($env{'form.makeuser'}) {
$r->print(''.&mt('Creating new account.').'
');
# Check for the authentication mode and password
@@ -2194,6 +2568,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'},
@@ -2204,49 +2579,63 @@ sub update_user_data {
$r->print(&mt('Generating user').': '.$result);
$uhome = &Apache::lonnet::homeserver($env{'form.ccuname'},
$env{'form.ccdomain'});
- my (%changeHash,%newcustom,%changed);
+ my (%changeHash,%newcustom,%changed,%changedinfo);
if ($uhome ne 'no_host') {
- if ($env{'form.customquota'} == 1) {
- if ($env{'form.portfolioquota'} eq '') {
- $newcustom{'quota'} = 0;
- } else {
- $newcustom{'quota'} = $env{'form.portfolioquota'};
- $newcustom{'quota'} =~ s/[^\d\.]//g;
+ if ($context eq 'domain') {
+ 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) {
- $newcustom{$item} = $env{'form.tools_'.$item};
- $changed{$item} = &tool_admin($item,$newcustom{$item},
- \%changeHash,'tools');
+ foreach my $item (@usertools) {
+ if ($env{'form.custom'.$item} == 1) {
+ $newcustom{$item} = $env{'form.tools_'.$item};
+ $changed{$item} = &tool_admin($item,$newcustom{$item},
+ \%changeHash,'tools');
+ }
}
- }
- 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'};
+ foreach my $item (@requestcourses) {
+ 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');
}
}
- $changed{$item} = &tool_admin($item,$newcustom{$item},
- \%changeHash,'requestcourses');
- }
- if (exists($env{'form.inststatus'})) {
- my @inststatuses = &Apache::loncommon::get_env_multiple('form.inststatus');
- if (@inststatuses > 0) {
- $changeHash{'inststatus'} = join(',',@inststatuses);
- $changed{'inststatus'} = $changeHash{'inststatus'};
+ if ($env{'form.customrequestauthor'} == 1) {
+ $newcustom{'requestauthor'} = $env{'form.requestauthor'};
+ $changed{'requestauthor'} = &tool_admin('requestauthor',
+ $newcustom{'requestauthor'},
+ \%changeHash,'requestauthor');
+ }
+ }
+ if ($canmodify_status{'inststatus'}) {
+ if (exists($env{'form.inststatus'})) {
+ my @inststatuses = &Apache::loncommon::get_env_multiple('form.inststatus');
+ if (@inststatuses > 0) {
+ $changeHash{'inststatus'} = join(',',@inststatuses);
+ $changed{'inststatus'} = $changeHash{'inststatus'};
+ }
}
}
if (keys(%changed)) {
- $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'};
+ foreach my $item (@userinfo) {
+ $changeHash{$item} = $env{'form.c'.$item};
+ }
my $chgresult =
&Apache::lonnet::put('environment',\%changeHash,
$env{'form.ccdomain'},$env{'form.ccuname'});
@@ -2274,21 +2663,29 @@ sub update_user_data {
$r->print($error.&mt('You do not have the authority to modify this users authentification information').'.'.$end);
}
}
+ $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',
+ 'requestcourses.official','requestcourses.unofficial',
+ 'requestcourses.community','requestcourses.textbook',
'reqcrsotherdom.official','reqcrsotherdom.unofficial',
- 'reqcrsotherdom.community'],
+ 'reqcrsotherdom.community','reqcrsotherdom.textbook',
+ 'requestauthor'],
$env{'form.ccdomain'},$env{'form.ccuname'});
my ($tmp) = keys(%userenv);
if ($tmp =~ /^(con_lost|error)/i) {
@@ -2365,7 +2762,6 @@ sub update_user_data {
push(@longroles,&Apache::lonnet::plaintext($role,$crstype));
}
}
- my @userinfo = ('firstname','middlename','lastname','generation','permanentemail','id');
my %canmodify = &Apache::lonuserutils::can_modify_userinfo($context,$env{'form.ccdomain'},\@userinfo,\@userroles);
foreach my $item (@userinfo) {
# Strip leading and trailing whitespace
@@ -2411,41 +2807,54 @@ sub update_user_data {
}
}
}
- my ($quotachanged,$oldportfolioquota,$newportfolioquota,$oldinststatus,
- $inststatus,$newinststatus,$oldisdefault,$newisdefault,$olddefquotatext,
- $newdefquotatext,%oldaccess,%oldaccesstext,%newaccess,%newaccesstext,
- $oldinststatuses,$newinststatuses);
- my ($defquota,$settingstatus) =
- &Apache::loncommon::default_quota($env{'form.ccdomain'},$inststatus);
- my ($showquota,$showtools,$showrequestcourses,$showinststatus,$showreqotherdom);
+ 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','requestauthor');
+ } else {
+ push(@disporder,'reqcrsotherdom');
+ }
+ push(@disporder,('quota','tools'));
+ $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'})) {
- $showquota = 1;
+ $canshow{'quota'} = 1;
}
if (&Apache::lonnet::allowed('mut',$env{'form.ccdomain'})) {
- $showtools = 1;
+ $canshow{'tools'} = 1;
}
if (&Apache::lonnet::allowed('ccc',$env{'form.ccdomain'})) {
- $showrequestcourses = 1;
+ $canshow{'requestcourses'} = 1;
} elsif (&Apache::lonnet::allowed('ccc',$env{'request.role.domain'})) {
- $showreqotherdom = 1;
+ $canshow{'reqcrsotherdom'} = 1;
}
if (&Apache::lonnet::allowed('mau',$env{'form.ccdomain'})) {
- $showinststatus = 1;
+ $canshow{'inststatus'} = 1;
+ }
+ if (&Apache::lonnet::allowed('cau',$env{'form.ccdomain'})) {
+ $canshow{'requestauthor'} = 1;
}
my (%changeHash,%changed);
- $oldinststatus = $userenv{'inststatus'};
if ($oldinststatus eq '') {
- $oldinststatuses = $othertitle;
+ $oldsettings{'inststatus'} = $othertitle;
} else {
if (ref($usertypes) eq 'HASH') {
- $oldinststatuses = join(', ',map{ $usertypes->{ &unescape($_) }; } (split(/:/,$userenv{'inststatus'})));
+ $oldsettings{'inststatus'} = join(', ',map{ $usertypes->{ &unescape($_) }; } (split(/:/,$userenv{'inststatus'})));
} else {
- $oldinststatuses = join(', ',map{ &unescape($_); } (split(/:/,$userenv{'inststatus'})));
+ $oldsettings{'inststatus'} = join(', ',map{ &unescape($_); } (split(/:/,$userenv{'inststatus'})));
}
}
$changeHash{'inststatus'} = $userenv{'inststatus'};
- my %canmodify_inststatus = &Apache::lonuserutils::can_modify_userinfo($context,$env{'form.ccdomain'},['inststatus'],\@userroles);
- if ($canmodify_inststatus{'inststatus'}) {
+ if ($canmodify_status{'inststatus'}) {
+ $canshow{'inststatus'} = 1;
if (exists($env{'form.inststatus'})) {
my @inststatuses = &Apache::loncommon::get_env_multiple('form.inststatus');
if (@inststatuses > 0) {
@@ -2453,86 +2862,110 @@ 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') {
- $newinststatuses = join(', ',map{ $usertypes->{$_}; } (@inststatuses));
+ $newsettings{'inststatus'} = join(', ',map{ $usertypes->{$_}; } (@inststatuses));
} else {
- $newinststatuses = join(', ',map{ $usertypes->{$_}; } (@inststatuses));
+ $newsettings{'inststatus'} = join(', ',@inststatuses);
+ }
+ }
+ } else {
+ $newinststatus = '';
+ $changeHash{'inststatus'} = $newinststatus;
+ $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'};
+ }
+ if ($context eq 'domain') {
+ 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 {
+ if ("a_admin('',\%changeHash,$name)) {
+ $changed{$name.'quota'} = 1;
+ $newquota{$name} = $newdefquota{$name};
+ $newisdefault{$name} = 1;
+ }
}
} else {
- $newinststatus = '';
- $changeHash{'inststatus'} = $newinststatus;
- $newinststatuses = $othertitle;
- if ($newinststatus ne $oldinststatus) {
- $changed{'inststatus'} = $changeHash{'inststatus'};
+ $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 {
+ $newquota{$name} = $newdefquota{$name};
+ $newisdefault{$name} = 1;
}
}
+ 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 {
+ $newsettingstext{'quota'}{$name} = &mt('custom quota: [_1] MB',$newquota{$name});
+ }
+ }
+ &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);
+ &tool_changes('requestauthor',\@requestauthor,\%oldsettings,\%oldsettingstext,
+ \%userenv,\%changeHash,\%changed,\%newsettings,\%newsettingstext);
+ } else {
+ &tool_changes('reqcrsotherdom',\@requestcourses,\%oldsettings,\%oldsettingstext,
+ \%userenv,\%changeHash,\%changed,\%newsettings,\%newsettingstext);
}
}
- $changeHash{'portfolioquota'} = $userenv{'portfolioquota'};
- if ($userenv{'portfolioquota'} ne '') {
- $oldportfolioquota = $userenv{'portfolioquota'};
- if ($env{'form.customquota'} == 1) {
- if ($env{'form.portfolioquota'} eq '') {
- $newportfolioquota = 0;
- } else {
- $newportfolioquota = $env{'form.portfolioquota'};
- $newportfolioquota =~ s/[^\d\.]//g;
- }
- if ($newportfolioquota != $oldportfolioquota) {
- $changed{'quota'} = "a_admin($newportfolioquota,\%changeHash);
- }
- } 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;
- } else {
- $newportfolioquota = $env{'form.portfolioquota'};
- $newportfolioquota =~ s/[^\d\.]//g;
- }
- $changed{'quota'} = "a_admin($newportfolioquota,\%changeHash);
- } else {
- $newportfolioquota = $defquota;
- $newisdefault = 1;
- }
- }
- if ($oldisdefault) {
- $olddefquotatext = &get_defaultquota_text($settingstatus);
- }
- if ($newisdefault) {
- $newdefquotatext = &get_defaultquota_text($settingstatus);
- }
- &tool_changes('tools',\@usertools,\%oldaccess,\%oldaccesstext,\%userenv,
- \%changeHash,\%changed,\%newaccess,\%newaccesstext);
- if ($env{'form.ccdomain'} eq $env{'request.role.domain'}) {
- &tool_changes('requestcourses',\@requestcourses,\%oldaccess,\%oldaccesstext,
- \%userenv,\%changeHash,\%changed,\%newaccess,\%newaccesstext);
- } else {
- &tool_changes('reqcrsotherdom',\@requestcourses,\%oldaccess,\%oldaccesstext,
- \%userenv,\%changeHash,\%changed,\%newaccess,\%newaccesstext);
- }
- if ($env{'form.cfirstname'} ne $userenv{'firstname'} ||
- $env{'form.cmiddlename'} ne $userenv{'middlename'} ||
- $env{'form.clastname'} ne $userenv{'lastname'} ||
- $env{'form.cgeneration'} ne $userenv{'generation'} ||
- $env{'form.cid'} ne $userenv{'id'} ||
- $env{'form.cpermanentemail'} ne $userenv{'permanentemail'} ) {
- $namechanged = 1;
- }
- if (($namechanged) || (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'};
+ foreach my $item (@userinfo) {
+ if ($env{'form.c'.$item} ne $userenv{$item}) {
+ $namechanged{$item} = 1;
+ }
+ }
+ foreach my $name ('portfolio','author') {
+ $oldsettings{'quota'}{$name} = $oldquota{$name}.' MB';
+ $newsettings{'quota'}{$name} = $newquota{$name}.' MB';
+ }
+ if ((keys(%namechanged) > 0) || (keys(%changed) > 0)) {
my ($chgresult,$namechgresult);
if (keys(%changed) > 0) {
$chgresult =
@@ -2547,14 +2980,22 @@ sub update_user_data {
|| ($key eq 'community')) {
$newenvhash{'environment.requestcourses.'.$key} =
$changeHash{'requestcourses.'.$key};
- if ($changeHash{'requestcourses.'.$key} ne '') {
- $newenvhash{'environment.canrequest.'.$key} =
- $changeHash{'requestcourses.'.$key};
+ if ($changeHash{'requestcourses.'.$key}) {
+ $newenvhash{'environment.canrequest.'.$key} = 1;
} else {
$newenvhash{'environment.canrequest.'.$key} =
&Apache::lonnet::usertools_access($env{'user.name'},$env{'user.domain'},
$key,'reload','requestcourses');
}
+ } elsif ($key eq 'requestauthor') {
+ $newenvhash{'environment.'.$key} = $changeHash{$key};
+ if ($changeHash{$key}) {
+ $newenvhash{'environment.canrequest.author'} = 1;
+ } else {
+ $newenvhash{'environment.canrequest.author'} =
+ &Apache::lonnet::usertools_access($env{'user.name'},$env{'user.domain'},
+ $key,'reload','requestauthor');
+ }
} elsif ($key ne 'quota') {
$newenvhash{'environment.tools.'.$key} =
$changeHash{'tools.'.$key};
@@ -2563,7 +3004,8 @@ sub update_user_data {
$changeHash{'tools.'.$key};
} else {
$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');
}
}
}
@@ -2573,14 +3015,17 @@ sub update_user_data {
}
}
}
- if ($namechanged) {
- # Make the change
+ if (keys(%namechanged) > 0) {
+ 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'},
@@ -2589,139 +3034,13 @@ sub update_user_data {
id => $env{'form.cid'},
);
}
- if (($namechanged && $namechgresult eq 'ok') ||
+ if (((keys(%namechanged) > 0) && $namechgresult eq 'ok') ||
((keys(%changed) > 0) && $chgresult eq 'ok')) {
# Tell the user we changed the name
- my %lt=&Apache::lonlocal::texthash(
- 'uic' => 'User Information Changed',
- 'frst' => 'First Name',
- 'mddl' => 'Middle Name',
- 'lst' => 'Last Name',
- 'gen' => 'Generation',
- 'id' => 'Student/Employee ID',
- 'mail' => 'Permanent e-mail address',
- 'disk' => 'Disk space allocated to portfolio files',
- 'blog' => 'Blog Availability',
- 'aboutme' => 'Personal Information Page Availability',
- 'portfolio' => 'Portfolio Availability',
- 'official' => 'Can Request Official Courses',
- 'unofficial' => 'Can Request Unofficial Courses',
- 'community' => 'Can Request Communities',
- 'inststatus' => "Affiliation",
- 'prvs' => 'Previous Value:',
- 'chto' => 'Changed To:'
- );
- $r->print(''.$lt{'uic'}.'
'.
- &Apache::loncommon::start_data_table().
- &Apache::loncommon::start_data_table_header_row());
- $r->print(<<"END");
-
- $lt{'frst'}
- $lt{'mddl'}
- $lt{'lst'}
- $lt{'gen'}
- $lt{'id'}
- $lt{'mail'}
-END
- if ($showinststatus) {
- $r->print("
- $lt{'inststatus'} \n");
- }
- if ($showrequestcourses) {
- foreach my $item (@requestcourses) {
- $r->print("
- $lt{$item} \n");
- }
- } elsif ($showreqotherdom) {
- foreach my $item (@requestcourses) {
- $r->print("
- $lt{$item} \n");
- }
- }
- if ($showquota) {
- $r->print("
- $lt{'disk'} \n");
- }
- if ($showtools) {
- foreach my $item (@usertools) {
- $r->print("
- $lt{$item} \n");
- }
- }
- $r->print(&Apache::loncommon::end_data_table_header_row().
- &Apache::loncommon::start_data_table_row());
- $r->print(<<"END");
- $lt{'prvs'}
- $userenv{'firstname'}
- $userenv{'middlename'}
- $userenv{'lastname'}
- $userenv{'generation'}
- $userenv{'id'}
- $userenv{'permanentemail'}
-END
- if ($showinststatus) {
- $r->print("
- $oldinststatuses \n");
- }
- if ($showrequestcourses) {
- foreach my $item (@requestcourses) {
- $r->print("
- $oldaccess{$item} $oldaccesstext{$item} \n");
- }
- } elsif ($showreqotherdom) {
- foreach my $item (@requestcourses) {
- $r->print("
- $oldaccess{$item} $oldaccesstext{$item} \n");
- }
- }
- if ($showquota) {
- $r->print("
- $oldportfolioquota Mb $olddefquotatext \n");
- }
- if ($showtools) {
- foreach my $item (@usertools) {
- $r->print("
- $oldaccess{$item} $oldaccesstext{$item} \n");
- }
- }
- $r->print(&Apache::loncommon::end_data_table_row().
- &Apache::loncommon::start_data_table_row());
- $r->print(<<"END");
- $lt{'chto'}
- $env{'form.cfirstname'}
- $env{'form.cmiddlename'}
- $env{'form.clastname'}
- $env{'form.cgeneration'}
- $env{'form.cid'}
- $env{'form.cpermanentemail'}
-END
- if ($showinststatus) {
- $r->print("
- $newinststatuses \n");
- }
- if ($showrequestcourses) {
- foreach my $item (@requestcourses) {
- $r->print("
- $newaccess{$item} $newaccesstext{$item} \n");
- }
- } elsif ($showreqotherdom) {
- foreach my $item (@requestcourses) {
- $r->print("
- $newaccess{$item} $newaccesstext{$item} \n");
- }
- }
- if ($showquota) {
- $r->print("
- $newportfolioquota Mb $newdefquotatext \n");
- }
- if ($showtools) {
- foreach my $item (@usertools) {
- $r->print("
- $newaccess{$item} $newaccesstext{$item} \n");
- }
- }
- $r->print(&Apache::loncommon::end_data_table_row().
- &Apache::loncommon::end_data_table().'
');
+ &display_userinfo($r,1,\@disporder,\%canshow,\@requestcourses,
+ \@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'}));
@@ -2743,58 +3062,20 @@ END
&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(
+ '$userenv{'firstname'} $userenv{'middlename'} $userenv{'lastname'} $userenv{'generation'}
-END
- if ($userenv{'permanentemail'} ne '') {
- $r->print('
');
+ &display_userinfo($r,undef,\@disporder,\%canshow,\@requestcourses,
+ \@usertools,\@requestauthor,\%userenv,\%changed,\%namechanged,\%oldsettings,
+ \%oldsettingstext,\%newsettings,\%newsettingstext);
}
if (@mod_disallowed) {
my ($rolestr,$contextname);
@@ -2830,18 +3111,21 @@ END
.&Apache::lonuserutils::print_namespacing_alerts($env{'form.ccdomain'},\%alerts,\%curr_rules)
.'');
}
+ &Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state);
if ($env{'form.action'} eq 'singlestudent') {
- &enroll_single_student($r,$uhome,$amode,$genpwd,$now,$newuser,$context,$crstype);
- $r->print('');
+ &enroll_single_student($r,$uhome,$amode,$genpwd,$now,$newuser,$context,
+ $crstype,$showcredits,$defaultcredits);
+ my $linktext = ($crstype eq 'Community' ?
+ &mt('Enroll Another Member') : &mt('Enroll Another Student'));
+ $r->print(
+ &Apache::lonhtmlcommon::actionbox([
+ ''
+ .($crstype eq 'Community' ?
+ &mt('Enroll Another Member') : &mt('Enroll Another Student'))
+ .'']));
} else {
- my @rolechanges = &update_roles($r,$context);
- if ($namechanged) {
+ my @rolechanges = &update_roles($r,$context,$showcredits);
+ if (keys(%namechanged) > 0) {
if ($context eq 'course') {
if (@userroles > 0) {
if ((@rolechanges == 0) ||
@@ -2861,13 +3145,146 @@ END
if ($env{'form.popup'}) {
$r->print('');
} else {
- $r->print('
['.$lt{'mail'}.': '.
- $userenv{'permanentemail'}.']');
- }
- if ($showinststatus) {
- $r->print('
['.$lt{'inststatus'}.': '.$oldinststatuses.']');
- }
- if ($showrequestcourses) {
- foreach my $item (@requestcourses) {
- $r->print('
['.$lt{$item}.': '.$newaccess{$item}.' '.
- $newaccesstext{$item}.']'."\n");
- }
- } elsif ($showreqotherdom) {
- foreach my $item (@requestcourses) {
- $r->print('
['.$lt{$item}.': '.$newaccess{$item}.' '.
- $newaccesstext{$item}.']'."\n");
- }
- }
- if ($showtools) {
- foreach my $item (@usertools) {
- $r->print('
['.$lt{$item}.': '.$newaccess{$item}.' '.
- $newaccesstext{$item}.']'."\n");
- }
- }
- if ($showquota) {
- $r->print('
['.$lt{'disk'}.': '.$oldportfolioquota.' Mb '.
- $olddefquotatext.']');
- }
- $r->print('
'.&Apache::lonhtmlcommon::actionbox([''
+ .&mt('Modify this user: [_1]',''.$env{'form.ccuname'}.':'.$env{'form.ccdomain'}.' ('.$userinfo.')').'',
+ ''.&mt('Create/Modify Another User').'']));
}
}
- $r->print(&Apache::loncommon::end_page());
+}
+
+sub display_userinfo {
+ my ($r,$changed,$order,$canshow,$requestcourses,$usertools,$requestauthor,
+ $userenv,$changedhash,$namechangedhash,$oldsetting,$oldsettingtext,
+ $newsetting,$newsettingtext) = @_;
+ return unless (ref($order) eq 'ARRAY' &&
+ ref($canshow) eq 'HASH' &&
+ ref($requestcourses) eq 'ARRAY' &&
+ ref($requestauthor) eq 'ARRAY' &&
+ ref($usertools) eq 'ARRAY' &&
+ ref($userenv) eq 'HASH' &&
+ ref($changedhash) eq 'HASH' &&
+ ref($oldsetting) eq 'HASH' &&
+ ref($oldsettingtext) eq 'HASH' &&
+ ref($newsetting) eq 'HASH' &&
+ ref($newsettingtext) eq 'HASH');
+ my %lt=&Apache::lonlocal::texthash(
+ 'ui' => 'User Information',
+ 'uic' => 'User Information Changed',
+ 'firstname' => 'First Name',
+ 'middlename' => 'Middle Name',
+ 'lastname' => 'Last Name',
+ 'generation' => 'Generation',
+ 'id' => 'Student/Employee ID',
+ 'permanentemail' => 'Permanent e-mail address',
+ 'portfolioquota' => 'Disk space allocated to portfolio files',
+ 'authorquota' => 'Disk space allocated to Authoring Space',
+ 'blog' => 'Blog Availability',
+ 'webdav' => 'WebDAV Availability',
+ 'aboutme' => 'Personal Information Page Availability',
+ 'portfolio' => 'Portfolio Availability',
+ 'official' => 'Can Request Official Courses',
+ 'unofficial' => 'Can Request Unofficial Courses',
+ 'community' => 'Can Request Communities',
+ 'textbook' => 'Can Request Textbook Courses',
+ 'requestauthor' => 'Can Request Author Role',
+ 'inststatus' => "Affiliation",
+ 'prvs' => 'Previous Value:',
+ 'chto' => 'Changed To:'
+ );
+ if ($changed) {
+ $r->print(''.$lt{'uic'}.'
'.
+ &Apache::loncommon::start_data_table().
+ &Apache::loncommon::start_data_table_header_row());
+ $r->print(" \n");
+ $r->print(''.$lt{'prvs'}.' ');
+ $r->print(''.$lt{'chto'}.' ');
+ $r->print(&Apache::loncommon::end_data_table_header_row());
+ my @userinfo = ('firstname','middlename','lastname','generation','permanentemail','id');
+
+ foreach my $item (@userinfo) {
+ my $value = $env{'form.c'.$item};
+ #show changes only:
+ unless ($value eq $userenv->{$item}){
+ $r->print(&Apache::loncommon::start_data_table_row());
+ $r->print("$lt{$item} \n");
+ $r->print("".$userenv->{$item}." \n");
+ $r->print("$value \n");
+ $r->print(&Apache::loncommon::end_data_table_row());
+ }
+ }
+ foreach my $entry (@{$order}) {
+ if ($canshow->{$entry}) {
+ if (($entry eq 'requestcourses') || ($entry eq 'reqcrsotherdom') || ($entry eq 'requestauthor')) {
+ my @items;
+ if ($entry eq 'requestauthor') {
+ @items = ($entry);
+ } else {
+ @items = @{$requestcourses};
+ }
+ foreach my $item (@items) {
+ if (($newsetting->{$item} ne $oldsetting->{$item}) ||
+ ($newsettingtext->{$item} ne $oldsettingtext->{$item})) {
+ $r->print(&Apache::loncommon::start_data_table_row()."\n");
+ $r->print("$lt{$item} \n");
+ $r->print("".$oldsetting->{$item});
+ if ($oldsettingtext->{$item}) {
+ if ($oldsetting->{$item}) {
+ $r->print(' -- ');
+ }
+ $r->print($oldsettingtext->{$item});
+ }
+ $r->print(" \n");
+ $r->print("".$newsetting->{$item});
+ if ($newsettingtext->{$item}) {
+ if ($newsetting->{$item}) {
+ $r->print(' -- ');
+ }
+ $r->print($newsettingtext->{$item});
+ }
+ $r->print(" \n");
+ $r->print(&Apache::loncommon::end_data_table_row()."\n");
+ }
+ }
+ } elsif ($entry eq 'tools') {
+ foreach my $item (@{$usertools}) {
+ if ($newsetting->{$item} ne $oldsetting->{$item}) {
+ $r->print(&Apache::loncommon::start_data_table_row()."\n");
+ $r->print("$lt{$item} \n");
+ $r->print("".$oldsetting->{$item}.' '.$oldsettingtext->{$item}." \n");
+ $r->print("".$newsetting->{$item}.' '.$newsettingtext->{$item}." \n");
+ $r->print(&Apache::loncommon::end_data_table_row()."\n");
+ }
+ }
+ } elsif ($entry eq 'quota') {
+ if ((ref($oldsetting->{$entry}) eq 'HASH') && (ref($oldsettingtext->{$entry}) eq 'HASH') &&
+ (ref($newsetting->{$entry}) eq 'HASH') && (ref($newsettingtext->{$entry}) eq 'HASH')) {
+ foreach my $name ('portfolio','author') {
+ if ($newsetting->{$entry}->{$name} ne $oldsetting->{$entry}->{$name}) {
+ $r->print(&Apache::loncommon::start_data_table_row()."\n");
+ $r->print("$lt{$name.$entry} \n");
+ $r->print("".$oldsettingtext->{$entry}->{$name}." \n");
+ $r->print("".$newsettingtext->{$entry}->{$name}." \n");
+ $r->print(&Apache::loncommon::end_data_table_row()."\n");
+ }
+ }
+ }
+ } else {
+ if ($newsetting->{$entry} ne $oldsetting->{$entry}) {
+ $r->print(&Apache::loncommon::start_data_table_row()."\n");
+ $r->print("$lt{$entry} \n");
+ $r->print("".$oldsetting->{$entry}.' '.$oldsettingtext->{$entry}." \n");
+ $r->print("".$newsetting->{$entry}.' '.$newsettingtext->{$entry}." \n");
+ $r->print(&Apache::loncommon::end_data_table_row()."\n");
+ }
+ }
+ }
+ }
+ $r->print(&Apache::loncommon::end_data_table().'
');
+ } else {
+ $r->print(''.$lt{'ui'}.'
'.
+ '
');
+ $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);
@@ -3074,11 +3591,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');
}
@@ -3092,14 +3613,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);
@@ -3108,11 +3636,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');
}
@@ -3128,27 +3662,38 @@ sub update_roles {
my $output;
if ($role eq 'st') {
if ($url =~ m-^/($match_domain)/($match_courseid)/?(\w*)$-) {
- my $result = &Apache::loncommon::commit_studentrole(\$logmsg,$udom,$uname,$url,$role,$now,0,$1,$2,$3);
+ my ($cdom,$cnum,$csec) = ($1,$2,$3);
+ my $credits;
+ if ($showcredits) {
+ my $defaultcredits =
+ &Apache::lonuserutils::get_defaultcredits($cdom,$cnum);
+ $credits = &get_user_credits($defaultcredits,$cdom,$cnum);
+ }
+ my $result = &Apache::loncommon::commit_studentrole(\$logmsg,$udom,$uname,$url,$role,$now,0,$cdom,$cnum,$csec,$context,$credits);
if (($result =~ /^error/) || ($result eq 'not_in_class') || ($result eq 'unknown_course') || ($result eq 'refused')) {
if ($result eq 'refused' && $logmsg) {
$output = $logmsg;
} else {
- $output = "Error: $result\n";
+ $output = &mt('Error: [_1]',$result)."\n";
}
} else {
- $output = &mt('Assigning').' '.$role.' in '.$url.
- &mt('starting').' '.localtime($now).
- ':
'.$logmsg.'
'.
- &mt('Add to classlist').': ok
';
+ $output = &Apache::lonhtmlcommon::confirm_success(&mt('Assigning [_1] in [_2] starting [_3]',
+ &Apache::lonnet::plaintext($role),
+ &Apache::loncommon::show_role_extent($url,$context,'st'),
+ &Apache::lonlocal::locallocaltime($now))).'
'.$logmsg.'
';
}
}
} else {
my $result=&Apache::lonnet::assignrole($env{'form.ccdomain'},
$env{'form.ccuname'},$url,$role,0,$now,'','',
$context);
- $output = &mt('Re-enabling [_1] in [_2]: [_3]',
- $role,$url,''.$result.'').'
';
- }
+ $output = &Apache::lonhtmlcommon::confirm_success(&mt('Re-enabling [_1] in [_2]',
+ &Apache::lonnet::plaintext($role),
+ &Apache::loncommon::show_role_extent($url,$context,$role)),$result ne "ok").'
';
+ if ($result ne "ok") {
+ $output .= &mt('Error: [_1]',$result).'
';
+ }
+ }
$r->print($output);
if (!grep(/^\Q$role\E$/,@rolechanges)) {
push(@rolechanges,$role);
@@ -3160,8 +3705,13 @@ sub update_roles {
my $result = &Apache::lonnet::assigncustomrole(
$env{'form.ccdomain'}, $env{'form.ccuname'},
$url,$rdom,$rnam,$rolename,0,$now,undef,$context);
- $r->print(&mt('Re-enabling custom role [_1] by [_2] in [_3]: [_4]',
- $rolename,$rnam.':'.$rdom,$url,''.$result.'').'
');
+ $r->print(&Apache::lonhtmlcommon::confirm_success(
+ &mt('Re-enabling custom role [_1] by [_2] in [_3]',
+ $rolename,$rnam.':'.$rdom,&Apache::loncommon::show_role_extent($1,$context,'cr')),
+ $result ne "ok").'
');
+ if ($result ne "ok") {
+ $r->print(&mt('Error: [_1]',$result).'
');
+ }
if (!grep(/^cr$/,@rolechanges)) {
push(@rolechanges,'cr');
}
@@ -3218,8 +3768,20 @@ sub update_roles {
# split multiple sections
my %sections = ();
my $num_sections = &build_roles($env{'form.sec_'.$one.'_'.$two.'_'.$three},\%sections,$three);
+ my $credits;
+ if ($three eq 'st') {
+ if ($showcredits) {
+ my $defaultcredits =
+ &Apache::lonuserutils::get_defaultcredits($one,$two);
+ $credits = $env{'form.credits_'.$one.'_'.$two.'_'.$three};
+ $credits =~ s/[^\d\.]//g;
+ if ($credits eq $defaultcredits) {
+ undef($credits);
+ }
+ }
+ }
if ($num_sections == 0) {
- $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$url,$three,$start,$end,$one,$two,'',$context));
+ $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$url,$three,$start,$end,$one,$two,'',$context,$credits));
} else {
my %curr_groups =
&Apache::longroup::coursegroups($one,$two);
@@ -3233,13 +3795,13 @@ sub update_roles {
next;
}
my $securl = $url.'/'.$sec;
- $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$securl,$three,$start,$end,$one,$two,$sec,$context));
+ $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$securl,$three,$start,$end,$one,$two,$sec,$context,$credits));
} else {
$emptysec = 1;
}
}
if ($emptysec) {
- $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$url,$three,$start,$end,$one,$two,'',$context));
+ $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$url,$three,$start,$end,$one,$two,'',$context,$credits));
}
}
if (!grep(/^\Q$three\E$/,@rolechanges)) {
@@ -3299,15 +3861,38 @@ sub update_roles {
}
} # End of foreach (keys(%env))
# Flush the course logs so reverse user roles immediately updated
- &Apache::lonnet::flushcourselogs();
+ $r->register_cleanup(\&Apache::lonnet::flushcourselogs);
if (@rolechanges == 0) {
- $r->print(&mt('No roles to modify'));
+ $r->print('');
if ($crstype eq 'Community') {
$r->print(&mt('Enrolling Member'));
@@ -3319,6 +3904,17 @@ sub enroll_single_student {
# Remove non alphanumeric values from section
$env{'form.sections'}=~s/\W//g;
+ my $credits;
+ if (($showcredits) && ($env{'form.credits'} ne '')) {
+ $credits = $env{'form.credits'};
+ $credits =~ s/[^\d\.]//g;
+ if ($credits ne '') {
+ if ($credits eq $defaultcredits) {
+ undef($credits);
+ }
+ }
+ }
+
# Clean out any old student roles the user has in this class.
&Apache::lonuserutils::modifystudent($env{'form.ccdomain'},
$env{'form.ccuname'},$env{'request.course.id'},undef,$uhome);
@@ -3328,9 +3924,10 @@ sub enroll_single_student {
$env{'form.ccuname'},$env{'form.cid'},$env{'form.cfirstname'},
$env{'form.cmiddlename'},$env{'form.clastname'},
$env{'form.generation'},$env{'form.sections'},$enddate,
- $startdate,'manual',undef,$env{'request.course.id'},'',$context);
+ $startdate,'manual',undef,$env{'request.course.id'},'',$context,
+ $credits);
if ($enroll_result =~ /^ok/) {
- $r->print(&mt('[_1] enrolled',$env{'form.ccuname'}.':'.$env{'form.ccdomain'}));
+ $r->print(&mt('[_1] enrolled',''.$env{'form.ccuname'}.':'.$env{'form.ccdomain'}.''));
if ($env{'form.sections'} ne '') {
$r->print(' '.&mt('in section [_1]',$env{'form.sections'}));
}
@@ -3347,7 +3944,7 @@ sub enroll_single_student {
}
$r->print('.
'.$showstart.'; '.$showend);
if ($startdate <= $now && !$newuser) {
- $r->print('
');
$r->print(<');
+ if ($priv eq 'bre' && $crstype eq 'Community') {
+ $r->print(' ');
+ } else {
+ $r->print($systemlevel{$priv}?'':' ');
+ }
+ $r->print(' '.
+ &Apache::loncommon::end_data_table_row());
}
$r->print(&Apache::loncommon::end_data_table().
''.
''."\n".''."\n".
''."\n".
- ''.
- &Apache::loncommon::end_page());
+ '');
}
# --------------------------------------------------------
sub make_script_template {
- my ($role) = @_;
+ my ($role,$crstype) = @_;
my %full_c=();
my %full_d=();
my %full_s=();
@@ -3640,6 +4303,7 @@ sub make_script_template {
$full_d{$priv}=1;
}
foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:s'})) {
+ next if (($crstype eq 'Community') && ($item eq 'bre&S'));
my ($priv,$restrict)=split(/\&/,$item);
$full_s{$priv}=1;
}
@@ -3699,11 +4363,11 @@ sub make_button_code {
}
# ---------------------------------------------------------- Call to definerole
sub set_custom_role {
- my ($r,$context) = @_;
+ my ($r,$context,$brcrum) = @_;
my $rolename=$env{'form.rolename'};
$rolename=~s/[^A-Za-z0-9]//gs;
if (!$rolename) {
- &custom_role_editor($r);
+ &custom_role_editor($r,$brcrum);
return;
}
my ($jsback,$elements) = &crumb_utilities();
@@ -3712,20 +4376,24 @@ sub set_custom_role {
.$jsback."\n"
.'// ]]>'."\n"
.''."\n";
-
- $r->print(&Apache::loncommon::start_page('Save Custom Role'),$jscript);
- &Apache::lonhtmlcommon::add_breadcrumb
- ({href=>"javascript:backPage(document.customresult,'pickrole','')",
- text=>"Pick custom role",
- faq=>282,bug=>'Instructor Interface',},
- {href=>"javascript:backPage(document.customresult,'selected_custom_edit','')",
- text=>"Edit custom role",
- faq=>282,bug=>'Instructor Interface',},
- {href=>"javascript:backPage(document.customresult,'set_custom_roles','')",
- text=>"Result",
- faq=>282,bug=>'Instructor Interface',});
- $r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management',
- 'Course_Editing_Custom_Roles'));
+ push(@{$brcrum},
+ {href => "javascript:backPage(document.customresult,'pickrole','')",
+ text => "Pick custom role",
+ faq => 282,
+ bug => 'Instructor Interface',},
+ {href => "javascript:backPage(document.customresult,'selected_custom_edit','')",
+ text => "Edit custom role",
+ faq => 282,
+ bug => 'Instructor Interface',},
+ {href => "javascript:backPage(document.customresult,'set_custom_roles','')",
+ text => "Result",
+ faq => 282,
+ bug => 'Instructor Interface',
+ help => 'Course_Editing_Custom_Roles'},
+ );
+ my $args = { bread_crumbs => $brcrum,
+ bread_crumbs_component => 'User Management'};
+ $r->print(&Apache::loncommon::start_page('Save Custom Role',$jscript,$args));
my ($rdummy,$roledef)=
&Apache::lonnet::get('roles',["rolesdef_$rolename"]);
@@ -3767,22 +4435,44 @@ sub set_custom_role {
$sysrole.=':'.$item;
}
}
- $r->print('
Defining Role: '.
- &Apache::lonnet::definerole($rolename,$sysrole,$domrole,$courole));
+ # Assign role; Compile and show result
+ my $errmsg;
+ my $result =
+ &Apache::lonnet::definerole($rolename,$sysrole,$domrole,$courole);
+ if ($result ne 'ok') {
+ $errmsg = ': '.$result;
+ }
+ my $message =
+ &Apache::lonhtmlcommon::confirm_success(
+ &mt('Defining Role').$errmsg, ($result eq 'ok' ? 0 : 1));
if ($env{'request.course.id'}) {
my $url='/'.$env{'request.course.id'};
$url=~s/\_/\//g;
- $r->print('
'.&mt('Assigning Role to Self').': '.
- &Apache::lonnet::assigncustomrole($env{'user.domain'},
- $env{'user.name'},
- $url,
- $env{'user.domain'},
- $env{'user.name'},
- $rolename,undef,undef,undef,$context));
+ $result =
+ &Apache::lonnet::assigncustomrole(
+ $env{'user.domain'},$env{'user.name'},
+ $url,
+ $env{'user.domain'},$env{'user.name'},
+ $rolename,undef,undef,undef,$context);
+ if ($result ne 'ok') {
+ $errmsg = ': '.$result;
+ }
+ $message .=
+ '
'
+ .&Apache::lonhtmlcommon::confirm_success(
+ &mt('Assigning Role to Self').$errmsg, ($result eq 'ok' ? 0 : 1));
}
- $r->print('
'
+ .&Apache::lonhtmlcommon::actionbox([
+ ''
+ .&mt('Create or edit another custom role')
+ .''])
+ .''
+ );
}
# ================================================================ Main Handler
@@ -3802,21 +4492,29 @@ sub handler {
} else {
$context = 'domain';
}
+
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
['action','state','callingform','roletype','showrole','bulkaction','popup','phase',
'username','domain','srchterm','srchdomain','srchin','srchby','srchtype']);
&Apache::lonhtmlcommon::clear_breadcrumbs();
+ my $args;
+ my $brcrum = [];
+ my $bread_crumbs_component = 'User Management';
if ($env{'form.action'} ne 'dateselect') {
- &Apache::lonhtmlcommon::add_breadcrumb
- ({href=>"/adm/createuser",
- text=>"User Management",
- help=>'Course_Create_Class_List,Course_Change_Privileges,Course_View_Class_List,Course_Editing_Custom_Roles,Course_Add_Student,Course_Drop_Student,Course_Automated_Enrollment,Course_Self_Enrollment,Course_Manage_Group'});
+ $brcrum = [{href=>"/adm/createuser",
+ text=>"User Management",
+ help=>'Course_Create_Class_List,Course_Change_Privileges,Course_View_Class_List,Course_Editing_Custom_Roles,Course_Add_Student,Course_Drop_Student,Course_Automated_Enrollment,Course_Self_Enrollment,Course_Manage_Group'}
+ ];
}
#SD Following files not added to help, because the corresponding .tex-files seem to
#be missing: Course_Approve_Selfenroll,Course_User_Logs,
my ($permission,$allowed) =
&Apache::lonuserutils::get_permission($context,$crstype);
if (!$allowed) {
+ if ($context eq 'course') {
+ $r->internal_redirect('/adm/viewclasslist');
+ return OK;
+ }
$env{'user.error.msg'}=
"/adm/createuser:cst:0:0:Cannot create/modify user data ".
"or view user status.";
@@ -3826,35 +4524,48 @@ sub handler {
&Apache::loncommon::content_type($r,'text/html');
$r->send_http_header;
+ my $showcredits;
+ if ((($context eq 'course') && ($crstype eq 'Course')) ||
+ ($context eq 'domain')) {
+ my %domdefaults =
+ &Apache::lonnet::get_domain_defaults($env{'request.role.domain'});
+ if ($domdefaults{'officialcredits'} || $domdefaults{'unofficialcredits'}) {
+ $showcredits = 1;
+ }
+ }
+
# Main switch on form.action and form.state, as appropriate
if (! exists($env{'form.action'})) {
- $r->print(&header());
- $r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management'));
+ $args = {bread_crumbs => $brcrum,
+ bread_crumbs_component => $bread_crumbs_component};
+ $r->print(&header(undef,$args));
$r->print(&print_main_menu($permission,$context,$crstype));
- $r->print(&Apache::loncommon::end_page());
} elsif ($env{'form.action'} eq 'upload' && $permission->{'cusr'}) {
- $r->print(&header());
- &Apache::lonhtmlcommon::add_breadcrumb
- ({href=>'/adm/createuser?action=upload&state=',
- text=>"Upload Users List"});
- $r->print(&Apache::lonhtmlcommon::breadcrumbs('Upload Users List',
- 'Course_Create_Class_List'));
+ push(@{$brcrum},
+ { href => '/adm/createuser?action=upload&state=',
+ text => 'Upload Users List',
+ help => 'Course_Create_Class_List',
+ });
+ $bread_crumbs_component = 'Upload Users List';
+ $args = {bread_crumbs => $brcrum,
+ bread_crumbs_component => $bread_crumbs_component};
+ $r->print(&header(undef,$args));
$r->print(''.&Apache::loncommon::end_page());
} elsif ((($env{'form.action'} eq 'singleuser') || ($env{'form.action'}
eq 'singlestudent')) && ($permission->{'cusr'})) {
my $phase = $env{'form.phase'};
@@ -3869,15 +4580,21 @@ sub handler {
if ($env{'form.phase'} eq 'createnewuser') {
my $response;
if ($env{'form.srchterm'} !~ /^$match_username$/) {
- my $response = &mt('You must specify a valid username. Only the following are allowed: letters numbers - . @');
+ my $response =
+ ''
+ .&mt('You must specify a valid username. Only the following are allowed:'
+ .' letters numbers - . @')
+ .'';
$env{'form.phase'} = '';
- &print_username_entry_form($r,$context,$response,$srch,undef,$crstype);
+ &print_username_entry_form($r,$context,$response,$srch,undef,
+ $crstype,$brcrum,$showcredits);
} else {
my $ccuname =&LONCAPA::clean_username($srch->{'srchterm'});
my $ccdomain=&LONCAPA::clean_domain($srch->{'srchdomain'});
&print_user_modification_page($r,$ccuname,$ccdomain,
$srch,$response,$context,
- $permission,$crstype);
+ $permission,$crstype,$brcrum,
+ $showcredits);
}
} elsif ($env{'form.phase'} eq 'get_user_info') {
my ($currstate,$response,$forcenewuser,$results) =
@@ -3887,7 +4604,8 @@ sub handler {
}
if ($currstate eq 'select') {
&print_user_selection_page($r,$response,$srch,$results,
- \@search,$context,undef,$crstype);
+ \@search,$context,undef,$crstype,
+ $brcrum);
} elsif ($currstate eq 'modify') {
my ($ccuname,$ccdomain);
if (($srch->{'srchby'} eq 'uname') &&
@@ -3905,58 +4623,91 @@ sub handler {
}
&print_user_modification_page($r,$ccuname,$ccdomain,
$srch,$response,$context,
- $permission,$crstype);
+ $permission,$crstype,$brcrum);
} elsif ($currstate eq 'query') {
- &print_user_query_page($r,'createuser');
+ &print_user_query_page($r,'createuser',$brcrum);
} else {
$env{'form.phase'} = '';
&print_username_entry_form($r,$context,$response,$srch,
- $forcenewuser,$crstype);
+ $forcenewuser,$crstype,$brcrum);
}
} elsif ($env{'form.phase'} eq 'userpicked') {
my $ccuname = &LONCAPA::clean_username($env{'form.seluname'});
my $ccdomain = &LONCAPA::clean_domain($env{'form.seludom'});
&print_user_modification_page($r,$ccuname,$ccdomain,$srch,'',
- $context,$permission,$crstype);
+ $context,$permission,$crstype,
+ $brcrum);
}
} elsif ($env{'form.phase'} eq 'update_user_data') {
- &update_user_data($r,$context,$crstype);
+ &update_user_data($r,$context,$crstype,$brcrum,$showcredits);
} else {
- &print_username_entry_form($r,$context,undef,$srch,undef,$crstype);
+ &print_username_entry_form($r,$context,undef,$srch,undef,$crstype,
+ $brcrum);
}
} elsif ($env{'form.action'} eq 'custom' && $permission->{'custom'}) {
if ($env{'form.phase'} eq 'set_custom_roles') {
- &set_custom_role($r,$context);
+ &set_custom_role($r,$context,$brcrum);
} else {
- &custom_role_editor($r);
+ &custom_role_editor($r,$brcrum);
+ }
+ } elsif (($env{'form.action'} eq 'processauthorreq') &&
+ ($permission->{'cusr'}) &&
+ (&Apache::lonnet::allowed('cau',$env{'request.role.domain'}))) {
+ push(@{$brcrum},
+ {href => '/adm/createuser?action=processauthorreq',
+ text => 'Authoring Space requests',
+ help => 'Domain_Role_Approvals'});
+ $bread_crumbs_component = 'Authoring requests';
+ if ($env{'form.state'} eq 'done') {
+ push(@{$brcrum},
+ {href => '/adm/createuser?action=authorreqqueue',
+ text => 'Result',
+ help => 'Domain_Role_Approvals'});
+ $bread_crumbs_component = 'Authoring request result';
+ }
+ $args = { bread_crumbs => $brcrum,
+ bread_crumbs_component => $bread_crumbs_component};
+ $r->print(&header(undef,$args));
+ if (!exists($env{'form.state'})) {
+ $r->print(&Apache::loncoursequeueadmin::display_queued_requests('requestauthor',
+ $env{'request.role.domain'}));
+ } elsif ($env{'form.state'} eq 'done') {
+ $r->print(''.&mt('Authoring request processing').'
'."\n");
+ $r->print(&Apache::loncoursequeueadmin::update_request_queue('requestauthor',
+ $env{'request.role.domain'}));
}
} elsif (($env{'form.action'} eq 'listusers') &&
($permission->{'view'} || $permission->{'cusr'})) {
if ($env{'form.phase'} eq 'bulkchange') {
- &Apache::lonhtmlcommon::add_breadcrumb
- ({href=>'/adm/createuser?action=listusers',
- text=>"List Users"},
- {href=>"/adm/createuser",
- text=>"Result"});
+ push(@{$brcrum},
+ {href => '/adm/createuser?action=listusers',
+ text => "List Users"},
+ {href => "/adm/createuser",
+ text => "Result",
+ help => 'Course_View_Class_List'});
+ $bread_crumbs_component = 'Update Users';
+ $args = {bread_crumbs => $brcrum,
+ bread_crumbs_component => $bread_crumbs_component};
+ $r->print(&header(undef,$args));
my $setting = $env{'form.roletype'};
my $choice = $env{'form.bulkaction'};
- $r->print(&header());
- $r->print(&Apache::lonhtmlcommon::breadcrumbs("Update Users",
- 'Course_View_Class_List'));
if ($permission->{'cusr'}) {
- &Apache::lonuserutils::update_user_list($r,$context,$setting,$choice);
- $r->print(&Apache::loncommon::end_page());
+ &Apache::lonuserutils::update_user_list($r,$context,$setting,$choice,$crstype);
} else {
$r->print(&mt('You are not authorized to make bulk changes to user roles'));
$r->print(''.&mt('Self-enrollment with a student role').'
'."\n");
&print_selfenroll_menu($r,$context,$permission);
} elsif ($env{'form.state'} eq 'done') {
- &Apache::lonhtmlcommon::add_breadcrumb
- ({href=>'/adm/createuser?action=selfenroll',
- text=>"Result"});
- $r->print(&Apache::lonhtmlcommon::breadcrumbs('Self-enrollment result',
- 'Course_Self_Enrollment'));
+ push (@{$brcrum},
+ {href=>'/adm/createuser?action=selfenroll',
+ text=>"Result"});
+ $args = { bread_crumbs => $brcrum,
+ bread_crumbs_component => 'Self-enrollment result'};
+ $r->print(&header(undef,$args));
$r->print(''.&mt('Self-enrollment with a student role').'
'."\n");
&update_selfenroll_config($r,$context,$permission);
}
- $r->print(&Apache::loncommon::end_page());
} elsif ($env{'form.action'} eq 'selfenrollqueue') {
- $r->print(&header());
- &Apache::lonhtmlcommon::add_breadcrumb
- ({href=>'/adm/createuser?action=selfenrollqueue',
- text=>"Enrollment requests"});
+ push(@{$brcrum},
+ {href => '/adm/createuser?action=selfenrollqueue',
+ text => 'Enrollment requests',
+ help => 'Course_Self_Enrollment'});
+ $bread_crumbs_component = 'Enrollment requests';
+ if ($env{'form.state'} eq 'done') {
+ push(@{$brcrum},
+ {href => '/adm/createuser?action=selfenrollqueue',
+ text => 'Result',
+ help => 'Course_Self_Enrollment'});
+ $bread_crumbs_component = 'Enrollment result';
+ }
+ $args = { bread_crumbs => $brcrum,
+ bread_crumbs_component => $bread_crumbs_component};
+ $r->print(&header(undef,$args));
my $cid = $env{'request.course.id'};
my $cdom = $env{'course.'.$cid.'.domain'};
my $cnum = $env{'course.'.$cid.'.num'};
my $coursedesc = $env{'course.'.$cid.'.description'};
if (!exists($env{'form.state'})) {
- $r->print(&Apache::lonhtmlcommon::breadcrumbs('Enrollment requests',
- 'Course_SelfEnrollment_Approval'));
$r->print(''.&mt('Pending enrollment requests').'
'."\n");
$r->print(&Apache::loncoursequeueadmin::display_queued_requests($context,
$cdom,$cnum));
} elsif ($env{'form.state'} eq 'done') {
- &Apache::lonhtmlcommon::add_breadcrumb
- ({href=>'/adm/createuser?action=selfenrollqueue',
- text=>"Result"});
- $r->print(&Apache::lonhtmlcommon::breadcrumbs('Enrollment result',
- 'Course_Self_Enrollment'));
$r->print(''.&mt('Enrollment request processing').'
'."\n");
$r->print(&Apache::loncoursequeueadmin::update_request_queue($context,
$cdom,$cnum,$coursedesc));
}
- $r->print(&Apache::loncommon::end_page());
} elsif ($env{'form.action'} eq 'changelogs') {
- $r->print(&header());
- &Apache::lonhtmlcommon::add_breadcrumb
- ({href=>'/adm/createuser?action=changelogs',
- text=>"User Management Logs"});
- $r->print(&Apache::lonhtmlcommon::breadcrumbs('User Changes',
- 'Course_User_Logs'));
- &print_userchangelogs_display($r,$context,$permission);
- $r->print(&Apache::loncommon::end_page());
+ my $helpitem;
+ if ($context eq 'course') {
+ $helpitem = 'Course_User_Logs';
+ }
+ push (@{$brcrum},
+ {href => '/adm/createuser?action=changelogs',
+ text => 'User Management Logs',
+ help => $helpitem});
+ $bread_crumbs_component = 'User Changes';
+ $args = { bread_crumbs => $brcrum,
+ bread_crumbs_component => $bread_crumbs_component};
+ $r->print(&header(undef,$args));
+ &print_userchangelogs_display($r,$context,$permission);
} else {
- $r->print(&header());
- $r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management'));
+ $bread_crumbs_component = 'User Management';
+ $args = { bread_crumbs => $brcrum,
+ bread_crumbs_component => $bread_crumbs_component};
+ $r->print(&header(undef,$args));
$r->print(&print_main_menu($permission,$context,$crstype));
- $r->print(&Apache::loncommon::end_page());
}
+ $r->print(&Apache::loncommon::end_page());
return OK;
}
sub header {
- my ($jscript,$loaditems,$args) = @_;
+ my ($jscript,$args) = @_;
my $start_page;
- if (ref($loaditems) eq 'HASH') {
- $start_page=&Apache::loncommon::start_page('User Management',$jscript,{'add_entries' => $loaditems});
- } else {
+ if (ref($args) eq 'HASH') {
$start_page=&Apache::loncommon::start_page('User Management',$jscript,$args);
+ } else {
+ $start_page=&Apache::loncommon::start_page('User Management',$jscript);
}
return $start_page;
}
@@ -4113,14 +4876,143 @@ sub add_script {
}
sub verify_user_display {
+ my ($context) = @_;
+ my %lt = &Apache::lonlocal::texthash (
+ course => 'course(s): description, section(s), status',
+ community => 'community(s): description, section(s), status',
+ author => 'author',
+ );
+ my $photos;
+ if (($context eq 'course') && $env{'request.course.id'}) {
+ $photos = $env{'course.'.$env{'request.course.id'}.'.internal.showphoto'};
+ }
my $output = <<"END";
+function hide_searching() {
+ if (document.getElementById('searching')) {
+ document.getElementById('searching').style.display = 'none';
+ }
+ return;
+}
+
function display_update() {
document.studentform.action.value = 'listusers';
document.studentform.phase.value = 'display';
document.studentform.submit();
}
+function updateCols(caller) {
+ var context = '$context';
+ var photos = '$photos';
+ if (caller == 'Status') {
+ if ((context == 'domain') &&
+ ((document.studentform.roletype.options[document.studentform.roletype.selectedIndex].value == 'course') ||
+ (document.studentform.roletype.options[document.studentform.roletype.selectedIndex].value == 'community'))) {
+ document.getElementById('showcolstatus').checked = false;
+ document.getElementById('showcolstatus').disabled = 'disabled';
+ document.getElementById('showcolstart').checked = false;
+ document.getElementById('showcolend').checked = false;
+ } else {
+ if (document.studentform.Status.options[document.studentform.Status.selectedIndex].value == 'Any') {
+ document.getElementById('showcolstatus').checked = true;
+ document.getElementById('showcolstatus').disabled = '';
+ document.getElementById('showcolstart').checked = true;
+ document.getElementById('showcolend').checked = true;
+ } else {
+ document.getElementById('showcolstatus').checked = false;
+ document.getElementById('showcolstatus').disabled = 'disabled';
+ document.getElementById('showcolstart').checked = false;
+ document.getElementById('showcolend').checked = false;
+ }
+ }
+ }
+ if (caller == 'output') {
+ if (photos == 1) {
+ if (document.getElementById('showcolphoto')) {
+ var photoitem = document.getElementById('showcolphoto');
+ if (document.studentform.output.options[document.studentform.output.selectedIndex].value == 'html') {
+ photoitem.checked = true;
+ photoitem.disabled = '';
+ } else {
+ photoitem.checked = false;
+ photoitem.disabled = 'disabled';
+ }
+ }
+ }
+ }
+ if (caller == 'showrole') {
+ if ((document.studentform.showrole.options[document.studentform.showrole.selectedIndex].value == 'Any') ||
+ (document.studentform.showrole.options[document.studentform.showrole.selectedIndex].value == 'cr')) {
+ document.getElementById('showcolrole').checked = true;
+ document.getElementById('showcolrole').disabled = '';
+ } else {
+ document.getElementById('showcolrole').checked = false;
+ document.getElementById('showcolrole').disabled = 'disabled';
+ }
+ if (context == 'domain') {
+ var quotausageshow = 0;
+ if ((document.studentform.roletype.options[document.studentform.roletype.selectedIndex].value == 'course') ||
+ (document.studentform.roletype.options[document.studentform.roletype.selectedIndex].value == 'community')) {
+ document.getElementById('showcolstatus').checked = false;
+ document.getElementById('showcolstatus').disabled = 'disabled';
+ document.getElementById('showcolstart').checked = false;
+ document.getElementById('showcolend').checked = false;
+ } else {
+ if (document.studentform.Status.options[document.studentform.Status.selectedIndex].value == 'Any') {
+ document.getElementById('showcolstatus').checked = true;
+ document.getElementById('showcolstatus').disabled = '';
+ document.getElementById('showcolstart').checked = true;
+ document.getElementById('showcolend').checked = true;
+ }
+ }
+ if (document.studentform.roletype.options[document.studentform.roletype.selectedIndex].value == 'domain') {
+ document.getElementById('showcolextent').disabled = 'disabled';
+ document.getElementById('showcolextent').checked = 'false';
+ document.getElementById('showextent').style.display='none';
+ document.getElementById('showcoltextextent').innerHTML = '';
+ if ((document.studentform.showrole.options[document.studentform.showrole.selectedIndex].value == 'au') ||
+ (document.studentform.showrole.options[document.studentform.showrole.selectedIndex].value == 'Any')) {
+ if (document.getElementById('showcolauthorusage')) {
+ document.getElementById('showcolauthorusage').disabled = '';
+ }
+ if (document.getElementById('showcolauthorquota')) {
+ document.getElementById('showcolauthorquota').disabled = '';
+ }
+ quotausageshow = 1;
+ }
+ } else {
+ document.getElementById('showextent').style.display='block';
+ document.getElementById('showextent').style.textAlign='left';
+ document.getElementById('showextent').style.textFace='normal';
+ if (document.studentform.roletype.options[document.studentform.roletype.selectedIndex].value == 'author') {
+ document.getElementById('showcolextent').disabled = '';
+ document.getElementById('showcolextent').checked = 'true';
+ document.getElementById('showcoltextextent').innerHTML="$lt{'author'}";
+ } else {
+ document.getElementById('showcolextent').disabled = '';
+ document.getElementById('showcolextent').checked = 'true';
+ if (document.studentform.roletype.options[document.studentform.roletype.selectedIndex].value == 'community') {
+ document.getElementById('showcoltextextent').innerHTML="$lt{'community'}";
+ } else {
+ document.getElementById('showcoltextextent').innerHTML="$lt{'course'}";
+ }
+ }
+ }
+ if (quotausageshow == 0) {
+ if (document.getElementById('showcolauthorusage')) {
+ document.getElementById('showcolauthorusage').checked = false;
+ document.getElementById('showcolauthorusage').disabled = 'disabled';
+ }
+ if (document.getElementById('showcolauthorquota')) {
+ document.getElementById('showcolauthorquota').checked = false;
+ document.getElementById('showcolauthorquota').disabled = 'disabled';
+ }
+ }
+ }
+ }
+ return;
+}
+
END
return $output;
@@ -4151,12 +5043,12 @@ sub print_main_menu {
course => {
upload => 'Upload a File of Course Users',
singleuser => 'Add/Modify a Course User',
- listusers => 'Manage Course Users',
+ listusers => 'List and Modify Multiple Course Users',
},
community => {
upload => 'Upload a File of Community Users',
singleuser => 'Add/Modify a Community User',
- listusers => 'Manage Community Users',
+ listusers => 'List and Modify Multiple Community Users',
},
);
my %linktitles = (
@@ -4195,7 +5087,7 @@ sub print_main_menu {
[
{
linktext => $links{$linkcontext}{'upload'},
- icon => 'sctr.png',
+ icon => 'uplusr.png',
#help => 'Course_Create_Class_List',
url => '/adm/createuser?action=upload',
permission => $permission->{'cusr'},
@@ -4203,7 +5095,7 @@ sub print_main_menu {
},
{
linktext => $links{$linkcontext}{'listusers'},
- icon => 'edit-find.png',
+ icon => 'mngcu.png',
#help => 'Course_View_Class_List',
url => '/adm/createuser?action=listusers',
permission => ($permission->{'view'} || $permission->{'cusr'}),
@@ -4227,6 +5119,22 @@ sub print_main_menu {
permission => $permission->{'custom'},
linktitle => 'Configure a custom role.',
},
+ {
+ linktext => 'Authoring Space Requests',
+ icon => 'selfenrl-queue.png',
+ #help => 'Domain_Role_Approvals',
+ url => '/adm/createuser?action=processauthorreq',
+ permission => $permission->{'cusr'},
+ linktitle => 'Approve or reject author role requests',
+ },
+ {
+ linktext => 'Change Log',
+ icon => 'document-properties.png',
+ #help => 'Course_User_Logs',
+ url => '/adm/createuser?action=changelogs',
+ permission => $permission->{'cusr'},
+ linktitle => 'View change log.',
+ },
);
}elsif ($context eq 'course'){
@@ -4290,14 +5198,14 @@ sub print_main_menu {
},
{
linktext => $linktext{$crstype}{'groups'},
- icon => 'conf.png',
+ icon => 'grps.png',
#help => 'Course_Manage_Group',
url => '/adm/coursegroups?refpage=cusr',
permission => $permission->{'grp_manage'},
linktitle => $linktitle{$crstype}{'groups'},
},
{
- linktext => 'Change Logs',
+ linktext => 'Change Log',
icon => 'document-properties.png',
#help => 'Course_User_Logs',
url => '/adm/createuser?action=changelogs',
@@ -4335,7 +5243,7 @@ sub print_main_menu {
push(@{ $menu[2]->{items} },
{
linktext => 'User Self-Enrollment',
- icon => 'cstr.png',
+ icon => 'self_enroll.png',
#help => 'Course_Self_Enrollment',
url => '/adm/createuser?action=selfenroll',
permission => $permission->{'cusr'},
@@ -4343,8 +5251,19 @@ sub print_main_menu {
},
);
}
- };
-return Apache::lonhtmlcommon::generate_menu(@menu);
+ } elsif ($context eq 'author') {
+ push(@{ $menu[2]->{items} }, #Category: Administration
+ {
+ linktext => 'Change Log',
+ icon => 'document-properties.png',
+ #help => 'Course_User_Logs',
+ url => '/adm/createuser?action=changelogs',
+ permission => $permission->{'cusr'},
+ linktitle => 'View change log.',
+ },
+ );
+ }
+ return Apache::lonhtmlcommon::generate_menu(@menu);
# { text => 'View Log-in History',
# help => 'Course_User_Logins',
# action => 'logins',
@@ -4365,6 +5284,7 @@ sub restore_prev_selections {
sub print_selfenroll_menu {
my ($r,$context,$permission) = @_;
+ my $crstype = &Apache::loncommon::course_type();
my $formname = 'enrollstudent';
my $nolink = 1;
my ($row,$lt) = &get_selfenroll_titles();
@@ -4726,8 +5646,12 @@ ENDSCRIPT
&mt('No').'';
my %advhash = &Apache::lonnet::get_course_adv_roles($cid,1);
my (@ccs,%notified);
- if ($advhash{'cc'}) {
- @ccs = split(/,/,$advhash{'cc'});
+ my $ccrole = 'cc';
+ if ($crstype eq 'Community') {
+ $ccrole = 'co';
+ }
+ if ($advhash{$ccrole}) {
+ @ccs = split(/,/,$advhash{$ccrole});
}
if ($currnotified) {
foreach my $current (split(/,/,$currnotified)) {
@@ -4756,7 +5680,7 @@ ENDSCRIPT
''.
&Apache::loncommon::plainname($ccuname,$ccudom).
'';
- $count;
+ $count ++;
}
my $rem = $count%$numcols;
if ($rem) {
@@ -4773,7 +5697,7 @@ ENDSCRIPT
my $cid = $env{'request.course.id'};
my $currlim = $env{'course.'.$cid.'.internal.selfenroll_limit'};
my $currcap = $env{'course.'.$cid.'.internal.selfenroll_cap'};
- my $nolimit = ' checked="checked" ';
+ $nolimit = ' checked="checked" ';
if ($currlim eq 'allstudents') {
$crslimit = ' checked="checked" ';
$selflimit = ' ';
@@ -4829,9 +5753,9 @@ sub visible_in_cat {
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.','"','"');
+ $visactions{'unhide'} = &mt('Use [_1]Categorize course[_2] to change the "Exclude from course catalog" setting.','','"');
+ $visactions{'chgcat'} = &mt('Use [_1]Categorize course[_2] to change the category assigned to the course, as the one currently assigned is no longer used in the domain.','"','"');
+ $visactions{'addcat'} = &mt('Use [_1]Categorize course[_2] to assign a category to the course.','"','"');
if (ref($domconf{'coursecategories'}) eq 'HASH') {
if ($domconf{'coursecategories'}{'togglecats'} eq 'crs') {
$settable{'togglecats'} = 1;
@@ -5029,19 +5953,35 @@ 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 $formname = 'rolelog';
+ my ($username,$domain,$crstype,%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();
+ my %saveable_parameters = ('show' => 'scalar',);
+ &Apache::loncommon::store_course_settings('roles_log',
+ \%saveable_parameters);
+ &Apache::loncommon::restore_course_settings('roles_log',
+ \%saveable_parameters);
+ } elsif ($context eq 'author') {
+ $domain = $env{'user.domain'};
+ if ($env{'request.role'} =~ m{^au\./\Q$domain\E/$}) {
+ $username = $env{'user.name'};
+ } else {
+ undef($domain);
+ }
+ }
+ if ($domain ne '' && $username ne '') {
+ %roleslog=&Apache::lonnet::dump('nohist_rolelog',$domain,$username);
+ }
+ }
if ((keys(%roleslog))[0]=~/^error\:/) { undef(%roleslog); }
- $r->print('';
-
- # Only display table, if content is available (has been collected above)
- if (!$content) {
+ if ($showntableheader) { # Table footer, if content displayed above
+ $r->print(&Apache::loncommon::end_data_table()
+ .$nav_links);
+ } else { # No content displayed above
$r->print('
'.
''.&mt('Changes/page:').' '. @@ -5259,7 +6214,7 @@ sub role_display_filter { &Apache::lonhtmlcommon::date_setter($formname,'rolelog_end_date', $curr->{'rolelog_end_date'},undef, undef,undef,undef,undef,undef,undef,$nolink); - my %lt = &rolechg_contexts($crstype); + my %lt = &rolechg_contexts($context,$crstype); $output .= ' | '.&mt('Window during which changes occurred:').' '. '
| '."\n";
+ if ($showcredits) {
+ $otheritems .= ''."\n". + ''."\n"; + } $otheritems .= < |
-$lt{'ssd'}
+ | |
ENDTIMEENTRY
@@ -6065,7 +7090,8 @@ sub update_selfenroll_config {
$newnum ++;
}
}
- for (my $j=0; $j<$env{'form.selfenroll_types_total'}; $j++) { if ((!grep(/^$j$/,@deletedoms)) && (!grep(/^$j$/,@activations))) {
+ for (my $j=0; $j<$env{'form.selfenroll_types_total'}; $j++) {
+ if ((!grep(/^$j$/,@deletedoms)) && (!grep(/^$j$/,@activations))) {
my @types = &Apache::loncommon::get_env_multiple('form.selfenroll_types_'.$j);
if (@types > 0) {
@types = sort(@types);
@@ -6338,7 +7364,7 @@ sub update_selfenroll_config {
my ($visible,$cansetvis,$vismsgs,$visactions) = &visible_in_cat($cdom,$cnum);
if (ref($visactions) eq 'HASH') {
if (!$visible) {
- $r->print('$lt{'sed'} '.$visactions->{'miss'}.' '.$visactions->{'yous'}. + $r->print(' '.$visactions->{'miss'}.' '.$visactions->{'yous'}. ' '); if (ref($vismsgs) eq 'ARRAY') { $r->print(' '.$visactions->{'take'}.'
|