--- loncom/interface/loncreateuser.pm 2018/03/23 01:01:21 1.449 +++ loncom/interface/loncreateuser.pm 2023/11/05 20:06:04 1.473 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Create a user # -# $Id: loncreateuser.pm,v 1.449 2018/03/23 01:01:21 raeburn Exp $ +# $Id: loncreateuser.pm,v 1.473 2023/11/05 20:06:04 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -70,7 +70,9 @@ use Apache::lonlocal; use Apache::longroup; use Apache::lonuserutils; use Apache::loncoursequeueadmin; +use Apache::lonviewcoauthors; use LONCAPA qw(:DEFAULT :match); +use HTML::Entities; my $loginscript; # piece of javascript used in two separate instances my $authformnop; @@ -81,7 +83,7 @@ my $authformloc; my $authformlti; sub initialize_authen_forms { - my ($dom,$formname,$curr_authtype,$mode) = @_; + my ($dom,$formname,$curr_authtype,$mode,$readonly) = @_; my ($krbdef,$krbdefdom) = &Apache::loncommon::get_kerberos_defaults($dom); my %param = ( formname => $formname, kerb_def_dom => $krbdefdom, @@ -102,6 +104,9 @@ sub initialize_authen_forms { $param{'mode'} = $mode; } } + if ($readonly) { + $param{'readonly'} = 1; + } $loginscript = &Apache::loncommon::authform_header(%param); $authformkrb = &Apache::loncommon::authform_kerberos(%param); $authformnop = &Apache::loncommon::authform_nochange(%param); @@ -126,14 +131,82 @@ sub auth_abbrev { # ==================================================== sub user_quotas { - my ($ccuname,$ccdomain) = @_; + my ($ccuname,$ccdomain,$name) = @_; my %lt = &Apache::lonlocal::texthash( - 'usrt' => "User Tools", 'cust' => "Custom quota", 'chqu' => "Change quota", ); - - my $quota_javascript = <<"END_SCRIPT"; + my ($output,$longinsttype); + my ($usertypes,$order) = &Apache::lonnet::retrieve_inst_usertypes($ccdomain); + my %titles = &Apache::lonlocal::texthash ( + portfolio => "Disk space allocated to user's portfolio files", + author => "Disk space allocated to user's Authoring Space", + ); + 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,$colspan); + $custom_on = ' '; + $custom_off = ' checked="checked" '; + $colspan = ' colspan="2"'; + 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,[_2]as determined by the user's institutional". + " affiliation ([_3]).",$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,[_2]is determined by the user's institutional". + " affiliation ([_3]).",$defquota,'
'.$longinsttype); + } + } + + if (&Apache::lonnet::allowed('mpq',$ccdomain)) { + $output .= ''."\n". + ' '.$titles{$name}.''."\n". + ' '."\n". + &Apache::loncommon::start_data_table_row()."\n". + ' '. + &mt('Current quota: [_1] MB',$currquota).'  '. + $defaultinfo.''."\n". + &Apache::loncommon::end_data_table_row()."\n". + &Apache::loncommon::start_data_table_row()."\n". + ''.$lt{'chqu'}. + ':  '. + '  '. + ' '.&mt('MB').''."\n". + &Apache::loncommon::end_data_table_row()."\n"; + } + return $output; +} + +sub user_quota_js { + return <<"END_SCRIPT"; END_SCRIPT - my $longinsttype; - my ($usertypes,$order) = &Apache::lonnet::retrieve_inst_usertypes($ccdomain); - my $output = $quota_javascript."\n". - '

'.$lt{'usrt'}.'

'."\n". - &Apache::loncommon::start_data_table(); - - if ((&Apache::lonnet::allowed('mut',$ccdomain)) || - (&Apache::lonnet::allowed('udp',$ccdomain))) { - $output .= &build_tools_display($ccuname,$ccdomain,'tools'); - } - my %titles = &Apache::lonlocal::texthash ( - portfolio => "Disk space allocated to user's portfolio files", - author => "Disk space allocated to user's Authoring Space (if role assigned)", - ); - 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}; +} + +sub set_custom_js { + return <<"END_SCRIPT"; + + + +END_SCRIPT + } sub build_tools_display { my ($ccuname,$ccdomain,$context) = @_; my (@usertools,%userenv,$output,@options,%validations,%reqtitles,%reqdisplay, - $colspan,$isadv,%domconfig); + $colspan,$isadv,%domconfig,@defaulteditors,@customeditors,@custommanagers, + @possmanagers,$editorsty,$customsty); my %lt = &Apache::lonlocal::texthash ( 'blog' => "Personal User Blog", 'aboutme' => "Personal Information Page", - 'webdav' => "WebDAV access to Authoring Spaces (if SSL and author/co-author)", + 'webdav' => "WebDAV access to Authoring Spaces (https)", + 'editors' => "Available Editors", + 'managers' => "Co-authors who can add/revoke roles", 'portfolio' => "Personal User Portfolio", + 'portaccess' => "Portfolio Shareable", + 'timezone' => "Can set Time Zone", 'avai' => "Available", 'cusa' => "availability", 'chse' => "Change setting", @@ -258,7 +295,11 @@ sub build_tools_display { 'placement' => 'Can request creation of placement tests', 'lti' => 'Can request creation of LTI courses', 'requestauthor' => 'Can request author space', + 'edit' => 'Standard editor (Edit)', + 'xml' => 'Text editor (EditXML)', + 'daxe' => 'Daxe editor (Daxe)', ); + $isadv = &Apache::lonnet::is_advanced_user($ccdomain,$ccuname); if ($context eq 'requestcourses') { %userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname, 'requestcourses.official','requestcourses.unofficial', @@ -269,39 +310,57 @@ sub build_tools_display { %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($ccdomain,$ccuname); } elsif ($context eq 'requestauthor') { - %userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname, - '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); + } elsif ($context eq 'authordefaults') { + %domconfig = + &Apache::lonnet::get_dom('configuration',['quotas','authordefaults'],$ccdomain); + %userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname,'tools.webdav', + 'authoreditors','authormanagers', + 'domcoord.author'); + @usertools = ('webdav','editors','managers'); + $colspan = ' colspan="2"'; } else { %userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname, 'tools.aboutme','tools.portfolio','tools.blog', - 'tools.webdav'); - @usertools = ('aboutme','blog','webdav','portfolio'); + 'tools.timezone','tools.portaccess'); + @usertools = ('aboutme','blog','portfolio','portaccess','timezone'); + $colspan = ' colspan="2"'; } foreach my $item (@usertools) { my ($custom_access,$curr_access,$cust_on,$cust_off,$tool_on,$tool_off, - $currdisp,$custdisp,$custradio); + $currdisp,$custdisp,$custradio,$onclick); $cust_off = 'checked="checked" '; $tool_on = 'checked="checked" '; - $curr_access = + $curr_access = &Apache::lonnet::usertools_access($ccuname,$ccdomain,$item,undef, - $context); + $context,\%userenv,'', + {'is_adv' => $isadv}); if ($context eq 'requestauthor') { if ($userenv{$context} ne '') { $cust_on = ' checked="checked" '; $cust_off = ''; - } + } + } elsif ($context eq 'authordefaults') { + if ($item eq 'editors') { + if ($userenv{'author'.$item} ne '') { + $cust_on = ' checked="checked" '; + $cust_off = ''; + } + } elsif ($item eq 'webdav') { + if ($userenv{'tools.'.$item} ne '') { + $cust_on = ' checked="checked" '; + $cust_off = ''; + } + } } elsif ($userenv{$context.'.'.$item} ne '') { $cust_on = ' checked="checked" '; $cust_off = ''; @@ -309,46 +368,122 @@ sub build_tools_display { if ($context eq 'requestcourses') { if ($userenv{$context.'.'.$item} eq '') { $custom_access = &mt('Currently from default setting.'); + $customsty = ' style="display:none;"'; } else { $custom_access = &mt('Currently from custom setting.'); + $customsty = ' style="display:block;"'; } } elsif ($context eq 'requestauthor') { if ($userenv{$context} eq '') { $custom_access = &mt('Currently from default setting.'); + $customsty = ' style="display:none;"'; } else { $custom_access = &mt('Currently from custom setting.'); + $customsty = ' style="display:block;"'; + } + } elsif ($item eq 'editors') { + if ($userenv{'author'.$item} eq '') { + if (ref($domconfig{'authordefaults'}{'editors'}) eq 'ARRAY') { + @defaulteditors = @{$domconfig{'authordefaults'}{'editors'}}; + } else { + @defaulteditors = ('edit','xml'); + } + $custom_access = &mt('Can use: [_1]', + join(', ', map { $lt{$_} } @defaulteditors)); + $editorsty = ' style="display:none;"'; + } else { + $custom_access = &mt('Currently from custom setting.'); + foreach my $editor (split(/,/,$userenv{'author'.$item})) { + if ($editor =~ /^(edit|daxe|xml)$/) { + push(@customeditors,$editor); + } + } + if (@customeditors) { + if (@customeditors > 1) { + $custom_access .= '
'; + } else { + $custom_access .= ' '; + } + $custom_access .= &mt('Can use: [_1]', + join(', ', map { $lt{$_} } @customeditors)). + ''; + } else { + $custom_access .= ' '.&mt('No available editors'); + } + $editorsty = ' style="display:block;"'; + } + } elsif ($item eq 'managers') { + my %ca_roles = &Apache::lonnet::get_my_roles($ccuname,$ccdomain,undef, + ['active','future'],['ca']); + if (keys(%ca_roles)) { + foreach my $entry (sort(keys(%ca_roles))) { + if ($entry =~ /^($match_username\:$match_domain):ca$/) { + my $user = $1; + unless ($user eq "$ccuname:$ccdomain") { + push(@possmanagers,$user); + } + } + } + } + if ($userenv{'author'.$item} eq '') { + $custom_access = &mt('Currently author manages co-author roles'); + } else { + if (keys(%ca_roles)) { + foreach my $user (split(/,/,$userenv{'author'.$item})) { + if ($user =~ /^($match_username):($match_domain)$/) { + if (exists($ca_roles{$user.':ca'})) { + unless ($user eq "$ccuname:$ccdomain") { + push(@custommanagers,$user); + } + } + } + } + } + if (@custommanagers) { + $custom_access = &mt('Co-authors who manage co-author roles: [_1]', + join(', ',@custommanagers)); + } else { + $custom_access = &mt('Currently author manages co-author roles'); + } } } else { - if ($userenv{$context.'.'.$item} eq '') { + my $current = $userenv{$context.'.'.$item}; + if ($item eq 'webdav') { + $current = $userenv{'tools.webdav'}; + } + if ($current eq '') { $custom_access = &mt('Availability determined currently from default setting.'); if (!$curr_access) { $tool_off = 'checked="checked" '; $tool_on = ''; } + $customsty = ' style="display:none;"'; } else { $custom_access = &mt('Availability determined currently from custom setting.'); - if ($userenv{$context.'.'.$item} == 0) { + if ($current == 0) { $tool_off = 'checked="checked" '; $tool_on = ''; } + $customsty = ' style="display:inline;"'; } } $output .= ' '."\n". ' '.$lt{$item}.''."\n". ' '."\n". &Apache::loncommon::start_data_table_row()."\n"; - if (($context eq 'requestcourses') || ($context eq 'requestauthor')) { - my ($curroption,$currlimit); + my ($curroption,$currlimit,$customsty); my $envkey = $context.'.'.$item; if ($context eq 'requestauthor') { $envkey = $context; } if ($userenv{$envkey} ne '') { $curroption = $userenv{$envkey}; + $customsty = ' style="display:block"'; } else { + $customsty = ' style="display:none"'; my (@inststatuses); if ($context eq 'requestcourses') { $curroption = @@ -365,6 +500,11 @@ sub build_tools_display { if (!$curroption) { $curroption = 'norequest'; } + my $name = 'crsreq_'.$item; + if ($context eq 'requestauthor') { + $name = $item; + } + $onclick = ' onclick="javascript:toggleCustom(this.form,'."'customtext_$item','custom$item'".');"'; if ($curroption =~ /^autolimit=(\d*)$/) { $currlimit = $1; if ($currlimit eq '') { @@ -375,7 +515,7 @@ sub build_tools_display { } else { $currdisp = $reqdisplay{$curroption}; } - $custdisp = ''; + $custdisp = '
'; foreach my $option (@options) { my $val = $option; if ($option eq 'norequest') { @@ -398,53 +538,114 @@ sub build_tools_display { $checked = ' checked="checked"'; } } - my $name = 'crsreq_'.$item; - if ($context eq 'requestauthor') { - $name = $item; + if ($option eq 'autolimit') { + $custdisp .= '
'; } - $custdisp .= '
'; + $custdisp .= ' '; + } + $custdisp .= ''; + $custradio = '
'.$custdisp; + } elsif ($item eq 'editors') { + $output .= ''.$custom_access.''."\n". + &Apache::loncommon::end_data_table_row()."\n"; + unless (&Apache::lonnet::allowed('udp',$ccdomain)) { + $output .= &Apache::loncommon::start_data_table_row()."\n". + ''. + $lt{'chse'}.': '.(' ' x3). + '
'. + '
'; + foreach my $editor ('edit','xml','daxe') { + my $checked; + if ($userenv{'author'.$item} eq '') { + if (grep(/^\Q$editor\E$/,@defaulteditors)) { + $checked = ' checked="checked"'; + } + } elsif (grep(/^\Q$editor\E$/,@customeditors)) { + $checked = ' checked="checked"'; + } + $output .= ' '; + } + $output .= '
'. + &Apache::loncommon::end_data_table_row()."\n"; + } + } elsif ($item eq 'managers') { + $output .= ''.$custom_access.''."\n". + &Apache::loncommon::end_data_table_row()."\n"; + unless ((&Apache::lonnet::allowed('udp',$ccdomain)) || + (($userenv{'domcoord.author'} eq 'blocked') && + (($env{'user.name'} ne $ccuname) || ($env{'user.domain'} ne $ccdomain)))) { + $output .= + &Apache::loncommon::start_data_table_row()."\n". + ''; + if (@possmanagers) { + $output .= &mt('Select manager(s)').': '; + foreach my $user (@possmanagers) { + my $checked; + if (grep(/^\Q$user\E$/,@custommanagers)) { + $checked = ' checked="checked"'; + } + $output .= ' '; + } + } else { + $output .= &mt('No co-author roles assignable as manager'); + } + $output .= ''. + &Apache::loncommon::end_data_table_row()."\n"; } - $custdisp .= '
'; } else { $custdisp .= ''; } - $custdisp .= '
'; - $custradio = '
'.&mt('Custom setting').'
'.$custdisp; } else { $currdisp = ($curr_access?&mt('Yes'):&mt('No')); my $name = $context.'_'.$item; - if ($context eq 'requestauthor') { - $name = $context; - } + $onclick = 'onclick="javascript:toggleCustom(this.form,'."'customtext_$item','custom$item'".');" '; $custdisp = '  '; - $custradio = (' 'x2).'--'.$lt{'cusa'}.': '.$custdisp. - ''; - } - $output .= ' '.$custom_access.(' 'x4). - $lt{'avai'}.': '.$currdisp.''."\n". - &Apache::loncommon::end_data_table_row()."\n"; - unless (&Apache::lonnet::allowed('udp',$ccdomain)) { - $output .= + $tool_off.$onclick.'/>'.&mt('Off').''; + $custradio = ''. + '--'.$lt{'cusa'}.': '.$custdisp.''; + } + unless (($item eq 'editors') || ($item eq 'managers')) { + $output .= ' '.$custom_access.(' 'x4). + $lt{'avai'}.': '.$currdisp.''."\n". + &Apache::loncommon::end_data_table_row()."\n"; + unless (&Apache::lonnet::allowed('udp',$ccdomain)) { + $output .= &Apache::loncommon::start_data_table_row()."\n". - ' '. + ''. $lt{'chse'}.': '.(' ' x3). + $cust_off.$onclick.'/>'.$lt{'usde'}.''.(' ' x3). ''.$custradio.''. - &Apache::loncommon::end_data_table_row()."\n"; + $cust_on.$onclick.'/>'.$lt{'uscu'}.''; + if ($colspan) { + $output .= ''; + } + $output .= $custradio.''. + &Apache::loncommon::end_data_table_row()."\n"; + } } } return $output; @@ -532,7 +733,7 @@ sub coursereq_externaluser { sub domainrole_req { my ($ccuname,$ccdomain) = @_; return '

'. - &mt('User Can Request Assignment of Domain Roles?'). + &mt('Can Request Assignment of Domain Roles?'). '

'."\n". &Apache::loncommon::start_data_table(). &build_tools_display($ccuname,$ccdomain, @@ -540,6 +741,18 @@ sub domainrole_req { &Apache::loncommon::end_data_table(); } +sub authoring_defaults { + my ($ccuname,$ccdomain) = @_; + return '

'. + &mt('Authoring Space defaults (if role assigned)'). + '

'."\n". + &Apache::loncommon::start_data_table(). + &build_tools_display($ccuname,$ccdomain, + 'authordefaults'). + &user_quotas($ccuname,$ccdomain,'author'). + &Apache::loncommon::end_data_table(); +} + sub courserequest_titles { my %titles = &Apache::lonlocal::texthash ( official => 'Official', @@ -1260,8 +1473,9 @@ sub print_user_modification_page { my $groupslist = &Apache::lonuserutils::get_groupslist(); - my $js = &validation_javascript($context,$ccdomain,$pjump_def,$crstype, - $groupslist,$newuser,$formname,\%loaditem); + my $js = &validation_javascript($context,$ccdomain,$pjump_def, + $crstype,$groupslist,$newuser, + $formname,\%loaditem,$permission); my %breadcrumb_text = &singleuser_breadcrumb($crstype,$context,$ccdomain); my $helpitem = 'Course_Change_Privileges'; if ($env{'form.action'} eq 'singlestudent') { @@ -1270,6 +1484,7 @@ sub print_user_modification_page { $helpitem = 'Author_Change_Privileges'; } elsif ($context eq 'domain') { $helpitem = 'Domain_Change_Privileges'; + $js .= &set_custom_js(); } push (@{$brcrum}, {href => "javascript:backPage($form)", @@ -1295,6 +1510,32 @@ sub print_user_modification_page { if ($env{'form.popup'}) { $args->{'no_nav_bar'} = 1; } + if (($context eq 'domain') && ($env{'request.role.domain'} eq $ccdomain)) { + my @toggles; + if (&Apache::lonnet::allowed('cau',$ccdomain)) { + my ($isadv,$isauthor) = + &Apache::lonnet::is_advanced_user($ccdomain,$ccuname); + unless ($isauthor) { + push(@toggles,'requestauthor'); + } + push(@toggles,('webdav','editors')); + } + if (&Apache::lonnet::allowed('mut',$ccdomain)) { + push(@toggles,('aboutme','blog','portfolio','portaccess','timezone')); + } + if (&Apache::lonnet::allowed('ccc',$env{'request.role.domain'})) { + push(@toggles,('official','unofficial','community','textbook','placement','lti')); + } + if (@toggles) { + my $onload; + foreach my $item (@toggles) { + $onload .= "toggleCustom(document.cu,'customtext_$item','custom$item');"; + } + $args->{'add_entries'} = { + 'onload' => $onload, + }; + } + } my $start_page = &Apache::loncommon::start_page('User Management',$js,$args); @@ -1331,18 +1572,36 @@ ENDFORMINFO } } my $title = ''; + my $need_quota_js; if ($newuser) { my ($portfolioform,$domroleform); if ((&Apache::lonnet::allowed('mpq',$env{'request.role.domain'})) || (&Apache::lonnet::allowed('mut',$env{'request.role.domain'}))) { # Current user has quota or user tools modification privileges - $portfolioform = '
'.&user_quotas($ccuname,$ccdomain); + $portfolioform = '

'. + &mt('User Tools'). + '

'."\n". + &Apache::loncommon::start_data_table(); + if (&Apache::lonnet::allowed('mut',$ccdomain)) { + $portfolioform .= &build_tools_display($ccuname,$ccdomain,'tools'); + } + if (&Apache::lonnet::allowed('mpq',$ccdomain)) { + $portfolioform .= &user_quotas($ccuname,$ccdomain,'portfolio'); + $need_quota_js = 1; + } + $portfolioform .= &Apache::loncommon::end_data_table(); } if ((&Apache::lonnet::allowed('cau',$env{'request.role.domain'})) && ($ccdomain eq $env{'request.role.domain'})) { - $domroleform = '
'.&domainrole_req($ccuname,$ccdomain); + $domroleform = &domainrole_req($ccuname,$ccdomain). + &authoring_defaults($ccuname,$ccdomain); + $need_quota_js = 1; + } + my $readonly; + unless ($permission->{'cusr'}) { + $readonly = 1; } - &initialize_authen_forms($ccdomain,$formname); + &initialize_authen_forms($ccdomain,$formname,'','',$readonly); my %lt=&Apache::lonlocal::texthash( 'lg' => 'Login Data', 'hs' => "Home Server", @@ -1373,7 +1632,7 @@ ENDTITLE $r->print('

'.$title.'

'."\n"); $r->print('
'); $r->print(&personal_data_display($ccuname,$ccdomain,$newuser,$context, - $inst_results{$ccuname.':'.$ccdomain})); + $inst_results{$ccuname.':'.$ccdomain},$readonly)); # Option to disable student/employee ID conflict checking not offerred for new users. my ($home_server_pick,$numlib) = &Apache::loncommon::home_server_form_item($ccdomain,'hserver', @@ -1388,7 +1647,7 @@ $lt{'hs'}: $home_server_pick } if (&Apache::lonnet::allowed('ccc',$env{'request.role.domain'})) { $r->print('

'. - &mt('User Can Request Creation of Courses/Communities in this Domain?').'

'. + &mt('Can Request Creation of Courses/Communities in this Domain?').''. &Apache::loncommon::start_data_table(). &build_tools_display($ccuname,$ccdomain, 'requestcourses'). @@ -1484,41 +1743,61 @@ ENDAUTH $inst_results{$ccuname.':'.$ccdomain})); if ((&Apache::lonnet::allowed('ccc',$env{'request.role.domain'})) || (&Apache::lonnet::allowed('udp',$env{'request.role.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')); - } else { - if (&Apache::lonnet::will_trust('reqcrs',$ccdomain,$env{'request.role.domain'})) { + $r->print('

'.&mt('Can Request Creation of Courses/Communities in this Domain?').'

'."\n"); + if (($env{'request.role.domain'} eq $ccdomain) || + (&Apache::lonnet::will_trust('reqcrs',$ccdomain,$env{'request.role.domain'}))) { + $r->print(&Apache::loncommon::start_data_table()); + if ($env{'request.role.domain'} eq $ccdomain) { + $r->print(&build_tools_display($ccuname,$ccdomain,'requestcourses')); + } else { $r->print(&coursereq_externaluser($ccuname,$ccdomain, $env{'request.role.domain'})); } + $r->print(&Apache::loncommon::end_data_table()); + } else { + $r->print(&mt('Domain configuration for this domain prohibits course creation by users from domain: "[_1]"', + &Apache::lonnet::domain($ccdomain,'description'))); } - $r->print(&Apache::loncommon::end_data_table()); } $r->print('
'); - my @order = ('auth','quota','tools','requestauthor'); + my @order = ('auth','quota','tools','requestauthor','authordefaults'); my %user_text; my ($isadv,$isauthor) = &Apache::lonnet::is_advanced_user($ccdomain,$ccuname); - if ((!$isauthor) && - ((&Apache::lonnet::allowed('cau',$env{'request.role.domain'})) || + if (((&Apache::lonnet::allowed('cau',$env{'request.role.domain'})) || (&Apache::lonnet::allowed('udp',$env{'request.role.domain'}))) && - ($env{'request.role.domain'} eq $ccdomain)) { - $user_text{'requestauthor'} = &domainrole_req($ccuname,$ccdomain); + ($env{'request.role.domain'} eq $ccdomain)) { + if (!$isauthor) { + $user_text{'requestauthor'} = &domainrole_req($ccuname,$ccdomain); + } + $user_text{'authordefaults'} = &authoring_defaults($ccuname,$ccdomain); + if (&Apache::lonnet::allowed('cau',$env{'request.role.domain'})) { + $need_quota_js = 1; + } } - $user_text{'auth'} = &user_authentication($ccuname,$ccdomain,$formname); + $user_text{'auth'} = &user_authentication($ccuname,$ccdomain,$formname,$crstype,$permission); if ((&Apache::lonnet::allowed('mpq',$ccdomain)) || (&Apache::lonnet::allowed('mut',$ccdomain)) || (&Apache::lonnet::allowed('udp',$ccdomain))) { + $user_text{'quota'} = '

'.&mt('User Tools').'

'."\n". + &Apache::loncommon::start_data_table(); + if ((&Apache::lonnet::allowed('mut',$ccdomain)) || + (&Apache::lonnet::allowed('udp',$ccdomain))) { + $user_text{'quota'} .= &build_tools_display($ccuname,$ccdomain,'tools'); + } # Current user has quota modification privileges - $user_text{'quota'} = &user_quotas($ccuname,$ccdomain); + if ((&Apache::lonnet::allowed('mpq',$ccdomain)) || + (&Apache::lonnet::allowed('udp',$ccdomain))) { + $user_text{'quota'} .= &user_quotas($ccuname,$ccdomain,'portfolio'); + $need_quota_js = 1; + } + $user_text{'quota'} .= &Apache::loncommon::end_data_table(); } if (!&Apache::lonnet::allowed('mpq',$ccdomain)) { if (&Apache::lonnet::allowed('mpq',$env{'request.role.domain'})) { my %lt=&Apache::lonlocal::texthash( - 'dska' => "Disk quotas for user's portfolio and Authoring Space", - 'youd' => "You do not have privileges to modify the portfolio and/or Authoring Space quotas for this user.", + 'dska' => "Disk quotas for user's portfolio", + 'youd' => "You do not have privileges to modify the portfolio quota for this user.", 'ichr' => "If a change is required, contact a domain coordinator for the domain", ); $user_text{'quota'} = < "User Tools Availability", - 'yodo' => "You do not have privileges to modify Portfolio, Blog, WebDAV, or Personal Information Page settings for this user.", + 'yodo' => "You do not have privileges to modify Portfolio, Blog, Personal Information Page, or Time Zone settings for this user.", 'ifch' => "If a change is required, contact a domain coordinator for the domain", ); $user_text{'tools'} = <print(' onclick="auth_check()" \>'."\n"); } else { - $r->print('onclick="this.form.submit()" \>'."\n"); + $r->print(' onclick="this.form.submit()" \>'."\n"); } } else { $r->print(''. @@ -1629,6 +1908,9 @@ ENDNOTOOLSPRIV $r->print(&Apache::lonhtmlcommon::echo_form_input(['phase','userrole','ccdomain','prevphase','currstate','ccuname','ccdomain'])); $r->print(''); $r->print('

'); + if ($need_quota_js) { + $r->print(&user_quota_js()); + } return; } @@ -1687,14 +1969,16 @@ sub date_sections_select { sub validation_javascript { my ($context,$ccdomain,$pjump_def,$crstype,$groupslist,$newuser,$formname, - $loaditem) = @_; + $loaditem,$permission) = @_; my $dc_setcourse_code = ''; my $nondc_setsection_code = ''; if ($context eq 'domain') { - my $dcdom = $env{'request.role.domain'}; - $loaditem->{'onload'} = "document.cu.coursedesc.value='';"; - $dc_setcourse_code = - &Apache::lonuserutils::dc_setcourse_js('cu','singleuser',$context); + if ((ref($permission) eq 'HASH') && ($permission->{'cusr'})) { + my $dcdom = $env{'request.role.domain'}; + $loaditem->{'onload'} = "document.cu.coursedesc.value='';"; + $dc_setcourse_code = + &Apache::lonuserutils::dc_setcourse_js('cu','singleuser',$context); + } } else { my $checkauth; if (($newuser) || (&Apache::lonnet::allowed('mau',$ccdomain))) { @@ -1766,7 +2050,12 @@ sub display_existing_roles { 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'})); + if ($env{'request.role'} =~ m{^ca\./($match_domain)/($match_username)$}) { + my ($audom,$auname) = ($1,$2); + next unless (($rnum eq $auname) && ($rdom eq $audom)); + } else { + next unless (($rnum eq $env{'user.name'}) && ($rdom eq $env{'request.role.domain'})); + } } my ($newkey,$newvalue,$newrole); $newkey = '/'.$rdom.'/'.$rnum; @@ -1926,6 +2215,8 @@ sub display_existing_roles { $area=~m{/($match_domain)/($match_username)}; if (&Apache::lonuserutils::authorpriv($2,$1)) { $allowed=1; + } elsif (&Apache::lonuserutils::coauthorpriv($2,$1)) { + $allowed=1; } else { $allowed=0; } @@ -2028,6 +2319,9 @@ sub display_existing_roles { } } elsif ($env{'request.role'} =~ /^au\./) { $contextrole = &mt('Existing Co-Author Roles in your Authoring Space'); + } elsif ($env{'request.role'} =~ m{^ca\./($match_domain)/($match_username)/$}) { + $contextrole = &mt('Existing Co-Author Roles in [_1] Authoring Space', + ''.$1.'_'.$2.''); } else { if ($showall) { $contextrole = &mt('Existing Roles in this Domain'); @@ -2069,13 +2363,25 @@ sub new_coauthor_roles { # # Co-Author # - if (&Apache::lonuserutils::authorpriv($env{'user.name'}, - $env{'request.role.domain'}) && - ($env{'user.name'} ne $ccuname || $env{'user.domain'} ne $ccdomain)) { + my ($cuname,$cudom); + if (($env{'request.role'} eq "au./$env{'user.domain'}/") || + ($env{'request.role'} eq "dc./$env{'user.domain'}/")) { + $cuname=$env{'user.name'}; + $cudom=$env{'request.role.domain'}; # No sense in assigning co-author role to yourself - $addrolesdisplay = 1; - my $cuname=$env{'user.name'}; - my $cudom=$env{'request.role.domain'}; + if ((&Apache::lonuserutils::authorpriv($cuname,$cudom)) && + ($env{'user.name'} ne $ccuname || $env{'user.domain'} ne $ccdomain)) { + $addrolesdisplay = 1; + } + } elsif ($env{'request.role'} =~ m{^ca\./($match_domain)/($match_username)$}) { + ($cudom,$cuname) = ($1,$2); + if ((&Apache::lonuserutils::coauthorpriv($cuname,$cudom)) && + ($env{'user.name'} ne $ccuname || $env{'user.domain'} ne $ccdomain) && + ($cudom ne $ccdomain || $cuname ne $ccuname)) { + $addrolesdisplay = 1; + } + } + if ($addrolesdisplay) { my %lt=&Apache::lonlocal::texthash( 'cs' => "Authoring Space", 'act' => "Activate", @@ -2130,6 +2436,17 @@ sub new_coauthor_roles { ($env{'user.domain'} eq $ccdomain)) { $r->print(&mt('Assigning yourself a co-author or assistant co-author role in your own author area in Authoring Space is not permitted')); } + } elsif ($env{'request.role'} =~ m{^ca\./($match_domain)/($match_username)$}) { + if (!(&Apache::lonuserutils::coauthorpriv($2,$1))) { + $r->print(''. + &mt('You do not have privileges to assign co-author roles.'). + ''); + } elsif (($env{'user.name'} eq $ccuname) && + ($env{'user.domain'} eq $ccdomain)) { + $r->print(&mt('Assigning yourself a co-author or assistant co-author role in an author area in Authoring Space in which you already have a co-author role is not permitted')); + } elsif (($cudom eq $ccdomain) && ($cuname eq $ccuname)) { + $r->print(&mt("Assigning a co-author or assistant co-author role to an Authoring Space's author is not permitted")); + } } return $addrolesdisplay;; } @@ -2194,7 +2511,7 @@ sub new_domain_roles { } sub user_authentication { - my ($ccuname,$ccdomain,$formname) = @_; + my ($ccuname,$ccdomain,$formname,$crstype,$permission) = @_; my $currentauth=&Apache::lonnet::queryauthenticate($ccuname,$ccdomain); my $outcome; my %lt=&Apache::lonlocal::texthash( @@ -2267,6 +2584,43 @@ ENDBADAUTH } $outcome .= &Apache::loncommon::end_data_table(); } else { + if (($currentauth =~ /^internal:/) && + (&Apache::lonuserutils::can_change_internalpass($ccuname,$ccdomain,$crstype,$permission))) { + $outcome = <<"ENDJS"; + +ENDJS + + $outcome .= '

'.$lt{'ld'}.'

'. + &Apache::loncommon::start_data_table(). + &Apache::loncommon::start_data_table_row(). + ''.&mt('Internally authenticated').'
'.&mt("Change user's password?"). + ''.(' 'x2). + ''. + ''. + &Apache::loncommon::end_data_table_row(). + &Apache::loncommon::end_data_table(); + } if (&Apache::lonnet::allowed('udp',$ccdomain)) { # Current user has rights to view domain preferences for user's domain my $result; @@ -2285,7 +2639,7 @@ ENDBADAUTH } elsif ($currentauth =~ /^unix:/) { $result = &mt('Currently Filesystem Authenticated.'); } elsif ($currentauth =~ /^lti:/) { - $result = &mt('Currently LTi authenticated.'); + $result = &mt('Currently LTI authenticated.'); } $outcome = '

'.$lt{'ld'}.'

'. &Apache::loncommon::start_data_table(). @@ -2400,9 +2754,9 @@ sub modify_login_block { } sub personal_data_display { - my ($ccuname,$ccdomain,$newuser,$context,$inst_results,$rolesarray, - $now,$captchaform,$emailusername,$usertype,$usernameset,$condition,$excluded) = @_; - my ($output,%userenv,%canmodify,%canmodify_status); + my ($ccuname,$ccdomain,$newuser,$context,$inst_results,$readonly,$rolesarray,$now, + $captchaform,$emailusername,$usertype,$usernameset,$condition,$excluded,$showsubmit) = @_; + my ($output,%userenv,%canmodify,%canmodify_status,$disabled); my @userinfo = ('firstname','middlename','lastname','generation', 'permanentemail','id'); my $rowcount = 0; @@ -2471,6 +2825,8 @@ sub personal_data_display { %canmodify = &selfcreate_canmodify($context,$ccdomain,\@userinfo, $inst_results,$rolesarray); } + } elsif ($readonly) { + $disabled = ' disabled="disabled"'; } my $genhelp=&Apache::loncommon::help_open_topic('Generation'); @@ -2511,8 +2867,8 @@ sub personal_data_display { } $rowcount ++; $output .= &Apache::lonhtmlcommon::row_closure(1); - my $upassone = ''; - my $upasstwo = ''; + my $upassone = ''; + my $upasstwo = ''; $output .= &Apache::lonhtmlcommon::row_title(&mt('Password').'*', 'LC_pick_box_title', 'LC_oddrow_value')."\n". @@ -2526,10 +2882,11 @@ sub personal_data_display { if ($usernameset eq 'free') { my $onclick = "toggleUsernameDisp(this,'selfcreateusername');"; $output .= &Apache::lonhtmlcommon::row_title($lt{'username'},undef,'LC_oddrow_value')."\n". - &mt('Use e-mail address: '). - ''."\n". - (' 'x2). - ''."\n". + ''.&mt('Use e-mail address: '). + ''.(' 'x2). + ''."\n". '