--- loncom/interface/loncreateuser.pm 2001/11/16 06:23:11 1.20
+++ loncom/interface/loncreateuser.pm 2025/01/13 01:00:58 1.483
@@ -1,698 +1,11043 @@
# The LearningOnline Network with CAPA
# Create a user
#
-# (Create a course
-# (My Desk
+# $Id: loncreateuser.pm,v 1.483 2025/01/13 01:00:58 raeburn Exp $
#
-# (Internal Server Error Handler
+# Copyright Michigan State University Board of Trustees
#
-# (Login Screen
-# 5/21/99,5/22,5/25,5/26,5/31,6/2,6/10,7/12,7/14,
-# 1/14/00,5/29,5/30,6/1,6/29,7/1,11/9 Gerd Kortemeyer)
+# This file is part of the LearningOnline Network with CAPA (LON-CAPA).
#
-# YEAR=2001
-# 3/1/1 Gerd Kortemeyer)
+# LON-CAPA is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
#
-# 3/1 Gerd Kortemeyer)
+# LON-CAPA is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
#
-# 2/14 Gerd Kortemeyer)
+# You should have received a copy of the GNU General Public License
+# along with LON-CAPA; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
-# 2/14,2/17,2/19,2/20,2/21,2/22,2/23,3/2,3/17,3/24,04/12 Gerd Kortemeyer
-# April Guy Albertelli
-# 05/10,10/16 Gerd Kortemeyer
-# 11/12,11/13,11/15 Scott Harrison
+# /home/httpd/html/adm/gpl.txt
+#
+# http://www.lon-capa.org/
#
-# $Id: loncreateuser.pm,v 1.20 2001/11/16 06:23:11 harris41 Exp $
###
package Apache::loncreateuser;
+=pod
+
+=head1 NAME
+
+Apache::loncreateuser.pm
+
+=head1 SYNOPSIS
+
+ Handler to create users and custom roles
+
+ Provides an Apache handler for creating users,
+ editing their login parameters, roles, and removing roles, and
+ also creating and assigning custom roles.
+
+=head1 OVERVIEW
+
+=head2 Custom Roles
+
+In LON-CAPA, roles are actually collections of privileges. "Teaching
+Assistant", "Course Coordinator", and other such roles are really just
+collection of privileges that are useful in many circumstances.
+
+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 file of the creator
+of the role.
+
+=cut
+
use strict;
use Apache::Constants qw(:common :http);
use Apache::lonnet;
+use Apache::loncommon;
+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 $generalrule;
my $authformnop;
my $authformkrb;
my $authformint;
my $authformfsys;
my $authformloc;
+my $authformlti;
+
+sub initialize_authen_forms {
+ my ($dom,$formname,$curr_authtype,$mode,$readonly) = @_;
+ my ($krbdef,$krbdefdom) = &Apache::loncommon::get_kerberos_defaults($dom);
+ my %param = ( formname => $formname,
+ kerb_def_dom => $krbdefdom,
+ kerb_def_auth => $krbdef,
+ domain => $dom,
+ );
+ my %abv_auth = &auth_abbrev();
+ if ($curr_authtype =~ /^(krb4|krb5|internal|localauth|unix|lti):(.*)$/) {
+ my $long_auth = $1;
+ my $curr_autharg = $2;
+ my %abv_auth = &auth_abbrev();
+ $param{'curr_authtype'} = $abv_auth{$long_auth};
+ if ($long_auth =~ /^krb(4|5)$/) {
+ $param{'curr_kerb_ver'} = $1;
+ $param{'curr_autharg'} = $curr_autharg;
+ }
+ if ($mode eq 'modifyuser') {
+ $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);
+ $authformint = &Apache::loncommon::authform_internal(%param);
+ $authformfsys = &Apache::loncommon::authform_filesystem(%param);
+ $authformloc = &Apache::loncommon::authform_local(%param);
+ $authformlti = &Apache::loncommon::authform_lti(%param);
+}
+
+sub auth_abbrev {
+ my %abv_auth = (
+ krb5 => 'krb',
+ krb4 => 'krb',
+ internal => 'int',
+ localauth => 'loc',
+ unix => 'fsys',
+ lti => 'lti',
+ );
+ return %abv_auth;
+}
+
+# ====================================================
+
+sub user_quotas {
+ my ($ccuname,$ccdomain,$name) = @_;
+ my %lt = &Apache::lonlocal::texthash(
+ 'cust' => "Custom quota",
+ 'chqu' => "Change quota",
+ );
+ 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('Default ([_1] MB)',$defquota).' '.
+ ' '.$lt{'cust'}.': '.
+ ' '.&mt('MB').' '."\n".
+ &Apache::loncommon::end_data_table_row()."\n";
+ }
+ return $output;
+}
+
+sub user_quota_js {
+ return <<"END_SCRIPT";
+
+END_SCRIPT
-sub BEGIN {
- $ENV{'SERVER_NAME'}=~/(\w+\.\w+)$/;
- my $krbdefdom=$1;
- $krbdefdom=~tr/a-z/A-Z/;
- $authformnop=(<
-
-Do not change login data
-
-END
- $authformkrb=(<
-
-Kerberos authenticated with domain
-
-
-END
- $authformint=(<
-
-Internally authenticated (with initial password
- )
-
-END
- $authformfsys=(<
-
-Filesystem authenticated (with initial password
- )
-
-END
- $authformloc=(<
-
-Local Authentication with argument
-
-
-END
- $loginscript=(<
-function setkrb(vf) {
- if (vf.krbdom.value!='') {
- vf.login[0].checked=true;
- vf.krbdom.value=vf.krbdom.value.toUpperCase();
- vf.intpwd.value='';
- vf.fsyspwd.value='';
- vf.locarg.value='';
- }
-}
-
-function setint(vf) {
- if (vf.intpwd.value!='') {
- vf.login[1].checked=true;
- vf.krbdom.value='';
- vf.fsyspwd.value='';
- vf.locarg.value='';
- }
-}
-
-function setfsys(vf) {
- if (vf.fsyspwd.value!='') {
- vf.login[2].checked=true;
- vf.krbdom.value='';
- vf.intpwd.value='';
- vf.locarg.value='';
- }
-}
-
-function setloc(vf) {
- if (vf.locarg.value!='') {
- vf.login[3].checked=true;
- vf.krbdom.value='';
- vf.intpwd.value='';
- vf.fsyspwd.value='';
- }
-}
-
-function clicknop(vf) {
- vf.krbdom.value='';
- vf.intpwd.value='';
- vf.fsyspwd.value='';
- vf.locarg.value='';
-}
-
-function clickkrb(vf) {
- vf.krbdom.value='$krbdefdom';
- vf.intpwd.value='';
- vf.fsyspwd.value='';
- vf.locarg.value='';
-}
-
-function clickint(vf) {
- vf.krbdom.value='';
- vf.fsyspwd.value='';
- vf.locarg.value='';
-}
-
-function clickfsys(vf) {
- vf.krbdom.value='';
- vf.intpwd.value='';
- vf.locarg.value='';
-}
-
-function clickloc(vf) {
- vf.krbdom.value='';
- vf.intpwd.value='';
- vf.fsyspwd.value='';
-}
-
-ENDLOGINSCRIPT
- $generalrule=<
-As a general rule, only authors or co-authors should be filesystem
-authenticated (which allows access to the server filesystem).
-
-END
+}
+
+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,@defaulteditors,@customeditors,@custommanagers,
+ @possmanagers);
+ my %lt = &Apache::lonlocal::texthash (
+ 'blog' => "Personal User Blog",
+ 'aboutme' => "Personal Information Page",
+ 'webdav' => "WebDAV access to Authoring Spaces (https)",
+ 'editors' => "Available Editors",
+ 'managers' => "Co-authors who can add/revoke roles",
+ 'archive' => "Managers can download tar.gz file of Authoring Space",
+ 'portfolio' => "Personal User Portfolio",
+ 'portaccess' => "Portfolio Shareable",
+ 'timezone' => "Can set Time Zone",
+ 'avai' => "Available",
+ 'cusa' => "availability",
+ 'chse' => "Change setting",
+ 'usde' => "Use default",
+ 'uscu' => "Use custom",
+ 'official' => 'Can request creation of official courses',
+ 'unofficial' => 'Can request creation of unofficial courses',
+ 'community' => 'Can request creation of communities',
+ 'textbook' => 'Can request creation of textbook courses',
+ 'placement' => 'Can request creation of placement tests',
+ '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',
+ 'requestcourses.community','requestcourses.textbook',
+ 'requestcourses.placement','requestcourses.lti');
+ @usertools = ('official','unofficial','community','textbook','placement','lti');
+ @options =('norequest','approval','autolimit','validate');
+ %validations = &Apache::lonnet::auto_courserequest_checks($ccdomain);
+ %reqtitles = &courserequest_titles();
+ %reqdisplay = &courserequest_display();
+ %domconfig =
+ &Apache::lonnet::get_dom('configuration',['requestcourses'],$ccdomain);
+ } elsif ($context eq 'requestauthor') {
+ %userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname,'requestauthor');
+ @usertools = ('requestauthor');
+ @options =('norequest','approval','automatic');
+ %reqtitles = &requestauthor_titles();
+ %reqdisplay = &requestauthor_display();
+ %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',
+ 'authorarchive','domcoord.author');
+ @usertools = ('webdav','editors','managers','archive');
+ $colspan = ' colspan="2"';
+ } else {
+ %userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname,
+ 'tools.aboutme','tools.portfolio','tools.blog',
+ '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,$onclick,$customsty,$editorsty);
+ $cust_off = 'checked="checked" ';
+ $tool_on = 'checked="checked" ';
+ unless (($context eq 'authordefaults') || ($item eq 'webdav')) {
+ $curr_access =
+ &Apache::lonnet::usertools_access($ccuname,$ccdomain,$item,undef,
+ $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') || ($item eq 'archive')) {
+ if ($userenv{'author'.$item} ne '') {
+ $cust_on = ' checked="checked" ';
+ $cust_off = '';
+ if ($item eq 'archive') {
+ $curr_access = $userenv{'author'.$item};
+ }
+ } elsif ($item eq 'archive') {
+ $curr_access = 0;
+ if (ref($domconfig{'authordefaults'}) eq 'HASH') {
+ $curr_access = $domconfig{'authordefaults'}{'archive'};
+ }
+ }
+ } elsif ($item eq 'webdav') {
+ if ($userenv{'tools.'.$item} ne '') {
+ $cust_on = ' checked="checked" ';
+ $cust_off = '';
+ $curr_access = $userenv{'tools.'.$item};
+ } else {
+ $curr_access =
+ &Apache::lonnet::usertools_access($ccuname,$ccdomain,$item,'reload',
+ undef,\%userenv,'',
+ {'is_adv' => $isadv});
+ }
+ }
+ } elsif ($userenv{$context.'.'.$item} ne '') {
+ $cust_on = ' checked="checked" ';
+ $cust_off = '';
+ }
+ 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 {
+ my $current = $userenv{$context.'.'.$item};
+ if ($item eq 'webdav') {
+ $current = $userenv{'tools.webdav'};
+ } elsif ($item eq 'archive') {
+ $current = $userenv{'author'.$item};
+ }
+ 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 ($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 $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';
+ }
+ 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 '') {
+ $currdisp = &mt('Yes, automatic creation');
+ } else {
+ $currdisp = &mt('Yes, up to [quant,_1,request]/user',$currlimit);
+ }
+ } else {
+ $currdisp = $reqdisplay{$curroption};
+ }
+ $custdisp = '';
+ foreach my $option (@options) {
+ my $val = $option;
+ if ($option eq 'norequest') {
+ $val = 0;
+ }
+ if ($option eq 'validate') {
+ my $canvalidate = 0;
+ if (ref($validations{$item}) eq 'HASH') {
+ if ($validations{$item}{'_custom_'}) {
+ $canvalidate = 1;
+ }
+ }
+ next if (!$canvalidate);
+ }
+ my $checked = '';
+ if ($option eq $curroption) {
+ $checked = ' checked="checked"';
+ } elsif ($option eq 'autolimit') {
+ if ($curroption =~ /^autolimit/) {
+ $checked = ' checked="checked"';
+ }
+ }
+ if ($option eq 'autolimit') {
+ $custdisp .= ' ';
+ }
+ $custdisp .= ''.
+ ' '.
+ $reqtitles{$option}.' ';
+ if ($option eq 'autolimit') {
+ $custdisp .= ' '.
+ $reqtitles{'unlimited'}.' ';
+ } else {
+ $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'}.': '.
+ ' '.
+ $lt{'usde'}.' '.(' ' x3).
+ ' '.
+ $lt{'uscu'}.' '.
+ '';
+ 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 .= ''.
+ ' '.
+ $lt{$editor}.' ';
+ }
+ $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 .= ''.
+ ' "&').'"'.$checked.' />'.
+ $user.' ';
+ }
+ } else {
+ $output .= &mt('No co-author roles assignable as manager');
+ }
+ $output .= ' '.
+ &Apache::loncommon::end_data_table_row()."\n";
+ }
+ } else {
+ $currdisp = ($curr_access?&mt('Yes'):&mt('No'));
+ my $name = $context.'_'.$item;
+ $onclick = 'onclick="javascript:toggleCustom(this.form,'."'customtext_$item','custom$item'".');" ';
+ $custdisp = ''.
+ ' '.&mt('On').' '.
+ ' '.&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'}.': '.
+ ' '.$lt{'usde'}.' '.(' ' x3).
+ ' '.$lt{'uscu'}.' ';
+ if ($colspan) {
+ $output .= '';
+ }
+ $output .= $custradio.' '.
+ &Apache::loncommon::end_data_table_row()."\n";
+ }
+ }
+ }
+ return $output;
+}
+
+sub coursereq_externaluser {
+ my ($ccuname,$ccdomain,$cdom) = @_;
+ my (@usertools,@options,%validations,%userenv,$output);
+ my %lt = &Apache::lonlocal::texthash (
+ 'official' => 'Can request creation of official courses',
+ 'unofficial' => 'Can request creation of unofficial courses',
+ 'community' => 'Can request creation of communities',
+ 'textbook' => 'Can request creation of textbook courses',
+ 'placement' => 'Can request creation of placement tests',
+ );
+
+ %userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname,
+ 'reqcrsotherdom.official','reqcrsotherdom.unofficial',
+ 'reqcrsotherdom.community','reqcrsotherdom.textbook',
+ 'reqcrsotherdom.placement');
+ @usertools = ('official','unofficial','community','textbook','placement');
+ @options = ('approval','validate','autolimit');
+ %validations = &Apache::lonnet::auto_courserequest_checks($cdom);
+ my $optregex = join('|',@options);
+ my %reqtitles = &courserequest_titles();
+ foreach my $item (@usertools) {
+ my ($curroption,$currlimit,$tooloff);
+ if ($userenv{'reqcrsotherdom.'.$item} ne '') {
+ my @curr = split(',',$userenv{'reqcrsotherdom.'.$item});
+ foreach my $req (@curr) {
+ if ($req =~ /^\Q$cdom\E\:($optregex)=?(\d*)$/) {
+ $curroption = $1;
+ $currlimit = $2;
+ last;
+ }
+ }
+ if (!$curroption) {
+ $curroption = 'norequest';
+ $tooloff = ' checked="checked"';
+ }
+ } else {
+ $curroption = 'norequest';
+ $tooloff = ' checked="checked"';
+ }
+ $output.= &Apache::loncommon::start_data_table_row()."\n".
+ ' '.$lt{$item}.': '.
+ ' '."\n".
+ &Apache::loncommon::end_data_table_row()."\n";
+ }
+ return $output;
+}
+
+sub domainrole_req {
+ my ($ccuname,$ccdomain) = @_;
+ return ''.
+ &mt('Can Request Assignment of Domain Roles?').
+ ' '."\n".
+ &Apache::loncommon::start_data_table().
+ &build_tools_display($ccuname,$ccdomain,
+ 'requestauthor').
+ &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',
+ unofficial => 'Unofficial',
+ community => 'Communities',
+ textbook => 'Textbook',
+ placement => 'Placement Tests',
+ lti => 'LTI Provider',
+ norequest => 'Not allowed',
+ approval => 'Approval by Dom. Coord.',
+ validate => 'With validation',
+ autolimit => 'Numerical limit',
+ unlimited => '(blank for unlimited)',
+ );
+ return %titles;
+}
+
+sub courserequest_display {
+ my %titles = &Apache::lonlocal::texthash (
+ approval => 'Yes, need approval',
+ validate => 'Yes, with validation',
+ norequest => 'No',
+ );
+ 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 phase_one {
- my $r=shift;
- my $defdom=$ENV{'user.domain'};
- $r->print(<
-
-The LearningOnline Network with CAPA
-
-
-Create User, Change User Privileges
-
-
-