--- loncom/interface/loncreateuser.pm 2002/04/23 21:05:45 1.33
+++ loncom/interface/loncreateuser.pm 2006/03/19 22:15:46 1.110
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Create a user
#
-# $Id: loncreateuser.pm,v 1.33 2002/04/23 21:05:45 matthew Exp $
+# $Id: loncreateuser.pm,v 1.110 2006/03/19 22:15:46 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -25,36 +25,45 @@
#
# http://www.lon-capa.org/
#
-# (Create a course
-# (My Desk
-#
-# (Internal Server Error Handler
-#
-# (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)
-#
-# YEAR=2001
-# 3/1/1 Gerd Kortemeyer)
-#
-# 3/1 Gerd Kortemeyer)
-#
-# 2/14 Gerd Kortemeyer)
-#
-# 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
-# 02/11/02 Matthew Hall
-#
-# $Id: loncreateuser.pm,v 1.33 2002/04/23 21:05:45 matthew Exp $
###
package Apache::loncreateuser;
+=pod
+
+=head1 NAME
+
+Apache::loncreateuser - handler to create users and custom roles
+
+=head1 SYNOPSIS
+
+Apache::loncreateuser 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.
+
+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 role definitions are stored in the C file of the role
+author.
+
+=cut
+
use strict;
use Apache::Constants qw(:common :http);
use Apache::lonnet;
+use Apache::loncommon;
+use Apache::lonlocal;
my $loginscript; # piece of javascript used in two separate instances
my $generalrule;
@@ -64,71 +73,104 @@ my $authformint;
my $authformfsys;
my $authformloc;
-BEGIN {
- $ENV{'SERVER_NAME'}=~/(\w+\.\w+)$/;
- my $krbdefdom=$1;
- $krbdefdom=~tr/a-z/A-Z/;
+sub initialize_authen_forms {
+ my ($krbdefdom)=( $ENV{'SERVER_NAME'}=~/(\w+\.\w+)$/);
+ $krbdefdom= uc($krbdefdom);
my %param = ( formname => 'document.cu',
kerb_def_dom => $krbdefdom
);
- $loginscript = &Apache::loncommon::authform_header(%param);
+# no longer static due to configurable kerberos defaults
+# $loginscript = &Apache::loncommon::authform_header(%param);
$generalrule = &Apache::loncommon::authform_authorwarning(%param);
$authformnop = &Apache::loncommon::authform_nochange(%param);
- $authformkrb = &Apache::loncommon::authform_kerberos(%param);
+# no longer static due to configurable kerberos defaults
+# $authformkrb = &Apache::loncommon::authform_kerberos(%param);
$authformint = &Apache::loncommon::authform_internal(%param);
$authformfsys = &Apache::loncommon::authform_filesystem(%param);
$authformloc = &Apache::loncommon::authform_local(%param);
}
+
+# ======================================================= Existing Custom Roles
+
+sub my_custom_roles {
+ my %returnhash=();
+ my %rolehash=&Apache::lonnet::dump('roles');
+ foreach (keys %rolehash) {
+ if ($_=~/^rolesdef\_(\w+)$/) {
+ $returnhash{$1}=$1;
+ }
+ }
+ return %returnhash;
+}
+
+# ==================================================== Figure out author access
+
+sub authorpriv {
+ my ($auname,$audom)=@_;
+ unless ((&Apache::lonnet::allowed('cca',$audom.'/'.$auname))
+ || (&Apache::lonnet::allowed('caa',$audom.'/'.$auname))) { return ''; }
+ return 1;
+}
+
# =================================================================== Phase one
-sub phase_one {
- my $r=shift;
- my $defdom=$ENV{'user.domain'};
+sub print_username_entry_form {
+ my ($r) = @_;
+ my $defdom=$env{'request.role.domain'};
my @domains = &Apache::loncommon::get_domains();
my $domform = &Apache::loncommon::select_dom_form($defdom,'ccdomain');
+ my $selscript=&Apache::loncommon::studentbrowser_javascript();
+ my $start_page =
+ &Apache::loncommon::start_page('Create Users, Change User Privileges',
+ $selscript);
+
+ my $sellink=&Apache::loncommon::selectstudent_link
+ ('crtuser','ccuname','ccdomain');
+ my %existingroles=&my_custom_roles();
+ my $choice=&Apache::loncommon::select_form('make new role','rolename',
+ ('make new role' => 'Generate new role ...',%existingroles));
+ my %lt=&Apache::lonlocal::texthash(
+ 'siur' => "Set Individual User Roles",
+ 'usr' => "Username",
+ 'dom' => "Domain",
+ 'usrr' => "User Roles",
+ 'ecrp' => "Edit Custom Role Privileges",
+ 'nr' => "Name of Role",
+ 'cre' => "Custom Role Editor"
+ );
+ my $help = &Apache::loncommon::help_open_menu('',undef,undef,'',282,'Instructor Interface');
+ my $helpsiur=&Apache::loncommon::help_open_topic('Course_Change_Privileges');
+ my $helpecpr=&Apache::loncommon::help_open_topic('Course_Editing_Custom_Roles');
$r->print(<<"ENDDOCUMENT");
-
-
-The LearningOnline Network with CAPA
-
-
-Create User, Change User Privileges
-
-
-
ENDDOCUMENT
+ if (&Apache::lonnet::allowed('mcr','/')) {
+ $r->print(<
+
+$lt{'ecrp'}$helpecpr
+$lt{'nr'}: $choice
+
+
+ENDCUSTOM
+ }
+ $r->print(&Apache::loncommon::end_page());
}
-# =================================================================== Phase two
-sub phase_two {
- my $r=shift;
- my $ccuname=$ENV{'form.ccuname'};
- my $ccdomain=$ENV{'form.ccdomain'};
-
- $ENV{'SERVER_NAME'}=~/(\w+\.\w+)$/;
- my $krbdefdom=$1;
- $krbdefdom=~tr/a-z/A-Z/;
- my %param = ( formname => 'document.cu',
- kerb_def_dom => $krbdefdom
- );
- $loginscript = &Apache::loncommon::authform_header(%param);
-
- my $defdom=$ENV{'user.domain'};
- $ccuname=~s/\W//g;
- $ccdomain=~s/\W//g;
- my $dochead =<<"ENDDOCHEAD";
-
-
-The LearningOnline Network with CAPA
+sub user_modification_js {
+ my ($pjump_def, $dc_setcourse_code)=@_;
+ return <
function pclose() {
@@ -137,14 +179,8 @@ sub phase_two {
parmwin.close();
}
- function pjump(type,dis,value,marker,ret,call) {
- parmwin=window.open("/adm/rat/parameter.html?type="+escape(type)
- +"&value="+escape(value)+"&marker="+escape(marker)
- +"&return="+escape(ret)
- +"&call="+escape(call)+"&name="+escape(dis),"LONCAPAparms",
- "height=350,width=350,scrollbars=no,menubar=no");
-
- }
+ $pjump_def
+ $dc_setcourse_code
function dateset() {
eval("document.cu."+document.cu.pres_marker.value+
@@ -152,14 +188,183 @@ sub phase_two {
pclose();
}
+ function setSections() {
+ var re1 = /^currsec_/;
+ for (var i=0;i 0) {
+ if (document.cu.elements[i+1].value != "" && document.cu.elements[i+1].value != null) {
+ sections = sections + "," + document.cu.elements[i+1].value;
+ }
+ }
+ else {
+ sections = document.cu.elements[i+1].value;
+ }
+ var newsecs = document.cu.elements[i+1].value;
+ if (newsecs != null && newsecs != "") {
+ var numsplit = newsecs.split(/,/g);
+ numsec = numsec + numsplit.length;
+ }
+ if ((role == 'st') && (numsec > 1)) {
+ alert("In each course, each user may only have one student role at a time. You had selected "+numsec+" sections.\\nPlease modify your selections so they include no more than one section.")
+ return;
+ }
+ else {
+ document.cu.elements[i+2].value = sections;
+ }
+ }
+ }
+ }
+ }
+ document.cu.submit();
+ }
-
-
-
-ENDDOCHEAD
+END
+}
+
+# =================================================================== Phase two
+sub print_user_modification_page {
+ my $r=shift;
+ my $ccuname=$env{'form.ccuname'};
+ my $ccdomain=$env{'form.ccdomain'};
+
+ $ccuname=~s/\W//g;
+ $ccdomain=~s/\W//g;
+
+ unless (($ccuname) && ($ccdomain)) {
+ &print_username_entry_form($r);
+ return;
+ }
+
+ my $defdom=$env{'request.role.domain'};
+
+ my ($krbdef,$krbdefdom) =
+ &Apache::loncommon::get_kerberos_defaults($defdom);
+
+ my %param = ( formname => 'document.cu',
+ kerb_def_dom => $krbdefdom,
+ kerb_def_auth => $krbdef
+ );
+ $loginscript = &Apache::loncommon::authform_header(%param);
+ $authformkrb = &Apache::loncommon::authform_kerberos(%param);
+
+ $ccuname=~s/\W//g;
+ $ccdomain=~s/\W//g;
+ my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition();
+ my $dc_setcourse_code = '';
+ my $loaditem;
+ if ($env{'request.role'} =~ m-^dc\./(\w+)/$-) {
+ my $dcdom = $1;
+ $loaditem = qq|OnLoad="document.cu.coursedesc.value=''"|;
+ $dc_setcourse_code = <<"ENDSCRIPT";
+ function setCourse() {
+ var course = document.cu.dccourse.value;
+ if (course != "") {
+ if (document.cu.dcdomain.value != document.cu.origdom.value) {
+ alert("You must select a course in the current domain");
+ return;
+ }
+ var userrole = document.cu.role.options[document.cu.role.selectedIndex].value
+ var section="";
+ var numsections = 0;
+ for (var i=0; i 1)) {
+ alert("In each course, each user may only have one student role at a time. You had selected "+numsections+" sections.\\nPlease modify your selections so they include no more than one section.")
+ return;
+ }
+ if ((userrole == 'cc') && (numsections > 0)) {
+ alert("Section designations do not apply to Course Coordinator roles.\\nA course coordinator role will be added with access to all sections.");
+ section = "";
+ }
+ var numcourse = getIndex(document.cu.dccourse);
+ if (numcourse == "-1") {
+ alert("There was a problem with your course selection");
+ return
+ }
+ else {
+ var coursename = "_$dcdom"+"_"+course+"_"+userrole
+ document.cu.elements[numcourse].name = "act"+coursename
+ document.cu.elements[numcourse+4].name = "sec"+coursename
+ document.cu.elements[numcourse+4].value = section
+ document.cu.elements[numcourse+5].name = "start"+coursename
+ document.cu.elements[numcourse+6].name = "end"+coursename
+ }
+ }
+ document.cu.submit();
+ }
+
+ function getIndex(caller) {
+ for (var i=0;i $loaditem,});
+
my $forminfo =<<"ENDFORMINFO";
-Home Server: $home_server_list
+$lt{'idsn'}
+$lt{'hs'}: $home_server_list
-Login Data
+$lt{'lg'}
$generalrule
$authformkrb
$authformint
@@ -214,11 +434,20 @@ Home Server: $authformloc
ENDNEWUSER
} else { # user already exists
+ my %lt=&Apache::lonlocal::texthash(
+ 'cup' => "Change User Privileges",
+ 'usr' => "User",
+ 'id' => "in domain",
+ 'fn' => "first name",
+ 'mn' => "middle name",
+ 'ln' => "last name",
+ 'gen' => "generation"
+ );
$r->print(<Change User Privileges
+$start_page
+$lt{'cup'}
$forminfo
-User "$ccuname" in domain $ccdomain
+$lt{'usr'} "$ccuname" $lt{'id'} "$ccdomain"
ENDCHANGEUSER
# Get the users information
my %userenv = &Apache::lonnet::get('environment',
@@ -229,20 +458,20 @@ ENDCHANGEUSER
END
@@ -250,93 +479,221 @@ END
my ($tmp) = keys(%rolesdump);
unless ($tmp =~ /^(con_lost|error)/i) {
my $now=time;
- $r->print('Revoke Existing Roles '.
- 'Revoke Role Extent '.
- 'Start End ');
- foreach my $area (keys(%rolesdump)) {
- if ($area!~/^rolesdef/) {
- my $role = $rolesdump{$area};
- my $thisrole=$area;
- $area=~s/\_\w\w$//;
- my ($role_code,$role_end_time,$role_start_time) =
- split(/_/,$role);
- my $bgcol='ffffff';
- my $allows=0;
- if ($area=~/^\/(\w+)\/(\d\w+)/) {
- my %coursedata=
- &Apache::lonnet::coursedescription($1.'_'.$2);
- my $carea='Course: '.$coursedata{'description'};
- $inccourses{$1.'_'.$2}=1;
- if (&Apache::lonnet::allowed('c'.$role_code,$1.'/'.$2)) {
- $allows=1;
- }
- # Compute the background color based on $area
- $bgcol=$1.'_'.$2;
- $bgcol=~s/[^8-9b-e]//g;
- $bgcol=substr($bgcol.$bgcol.$bgcol.'ffffff',0,6);
- if ($area=~/^\/(\w+)\/(\d\w+)\/(\w+)/) {
- $carea.=' Section/Group: '.$3;
- }
- $area=$carea;
- } else {
- # Determine if current user is able to revoke privileges
- if ($area=~/^\/(\w+)\//) {
- if (&Apache::lonnet::allowed('c'.$role_code,$1)) {
- $allows=1;
- }
- } else {
- if (&Apache::lonnet::allowed('c'.$role_code,'/')) {
- $allows=1;
- }
- }
- }
- $r->print('');
- my $active=1;
- $active=0 if (($role_end_time) && ($now>$role_end_time));
- if (($active) && ($allows)) {
- $r->print(' ');
- } else {
- $r->print(' ');
- }
- $r->print(' '.
- &Apache::lonnet::plaintext($role_code).
- ' '.$area.' '.
- ($role_start_time ? localtime($role_start_time)
- : ' ' )
- .' '.
- ($role_end_time ? localtime($role_end_time)
- : ' ' )
- ." \n");
- }
+ my %lt=&Apache::lonlocal::texthash(
+ 'rer' => "Revoke Existing Roles",
+ 'rev' => "Revoke",
+ 'del' => "Delete",
+ 'ren' => "Re-Enable",
+ 'rol' => "Role",
+ 'ext' => "Extent",
+ '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);
+# Is this a custom role? Get role owner and title.
+ my ($croleudom,$croleuname,$croletitle)=
+ ($role_code=~/^cr\/(\w+)\/(\w+)\/(\w+)$/);
+ my $bgcol='ffffff';
+ my $allowed=0;
+ my $delallowed=0;
+ my $sortkey=$role_code;
+ my $class='Unknown';
+ if ($area =~ /^\/(\w+)\/(\d\w+)/ ) {
+ $class='Course';
+ my ($coursedom,$coursedir) = ($1,$2);
+ $sortkey.="\0$1";
+ # $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('Syllabus',$coursedir,$coursedom);
+ $sortkey.="\0".$coursedata{'description'};
+ } else {
+ $carea=&mt('Unavailable course').': '.$area;
+ $sortkey.="\0".&mt('Unavailable course').': '.$area;
+ }
+ $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;
+ }
+# - custom role. Needs more info, too
+ if ($croletitle) {
+ if (&Apache::lonnet::allowed('ccr',$1.'/'.$2)) {
+ $allowed=1;
+ $thisrole.='.'.$role_code;
+ }
+ }
+ # Compute the background color based on $area
+ $bgcol=$1.'_'.$2;
+ $bgcol=~s/[^7-9a-e]//g;
+ $bgcol=substr($bgcol.$bgcol.$bgcol.'ffffff',2,6);
+ if ($area=~/^\/(\w+)\/(\d\w+)\/(\w+)/) {
+ $carea.=' Section/Group: '.$3;
+ $sortkey.="\0$3";
+ }
+ $area=$carea;
+ } else {
+ $sortkey.="\0".$area;
+ # Determine if current user is able to revoke privileges
+ if ($area=~ /^\/(\w+)\//) {
+ 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;
+ }
+ }
+ if ($role_code eq 'ca' || $role_code eq 'au') {
+ $class='Construction Space';
+ } elsif ($role_code eq 'su') {
+ $class='System';
+ } else {
+ $class='Domain';
+ }
+ }
+ if (($role_code eq 'ca') || ($role_code eq 'aa')) {
+ $area=~/\/(\w+)\/(\w+)/;
+ if (&authorpriv($2,$1)) {
+ $allowed=1;
+ } else {
+ $allowed=0;
+ }
+ }
+ $bgcol='77FF77';
+ 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='';
+ unless ($croletitle) {
+ $plaintext=&Apache::lonnet::plaintext($role_code);
+ } else {
+ $plaintext=
+ "Customrole '$croletitle' defined by $croleuname\@$croleudom";
+ }
+ $row.= ' '.$plaintext.
+ ' '.$area.
+ ' '.($role_start_time?localtime($role_start_time)
+ : ' ' ).
+ ' '.($role_end_time ?localtime($role_end_time)
+ : ' ' )
+ ." \n";
+ $sortrole{$sortkey}=$envkey;
+ $roletext{$envkey}=$row;
+ $roleclass{$envkey}=$class;
+ $rolepriv{$envkey}=$allowed;
+ #$r->print($row);
} # end of foreach (table building loop)
- $r->print('
');
+ my $rolesdisplay = 0;
+ my %output = ();
+ foreach my $type ('Construction Space','Course','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}.=$roletext{$sortrole{$which}};
+ }
+ }
+ unless($output{$type} eq '') {
+ $output{$type} = "".
+ "".&mt($type)." ".
+ $output{$type};
+ $rolesdisplay = 1;
+ }
+ }
+ if ($rolesdisplay == 1) {
+ $r->print(<
+$lt{'rer'}
+
+$lt{'rev'} $lt{'ren'} $lt{'del'} $lt{'rol'} $lt{'e
+xt'} $lt{'sta'} $lt{'end'}
+END
+ foreach my $type ('Construction Space','Course','Domain','System','Unknown') {
+ if ($output{$type}) {
+ $r->print($output{$type}."\n");
+ }
+ }
+ $r->print('
');
+ }
} # End of unless
my $currentauth=&Apache::lonnet::queryauthenticate($ccuname,$ccdomain);
- if ($currentauth=~/^krb4:/) {
- $currentauth=~/^krb4:(.*)/;
- my $krbdefdom2=$1;
+ if ($currentauth=~/^krb(4|5):/) {
+ $currentauth=~/^krb(4|5):(.*)/;
+ my $krbdefdom=$2;
my %param = ( formname => 'document.cu',
kerb_def_dom => $krbdefdom
);
$loginscript = &Apache::loncommon::authform_header(%param);
}
# Check for a bad authentication type
- unless ($currentauth=~/^krb4:/ or
+ unless ($currentauth=~/^krb(4|5):/ or
$currentauth=~/^unix:/ or
$currentauth=~/^internal:/ or
$currentauth=~/^localauth:/
) { # bad authentication scheme
- if (&Apache::lonnet::allowed('mau',$ENV{'user.domain'})) {
+ if (&Apache::lonnet::allowed('mau',$env{'request.role.domain'})) {
+ &initialize_authen_forms();
+ my %lt=&Apache::lonlocal::texthash(
+ 'err' => "ERROR",
+ 'uuas' => "This user has an unrecognized authentication scheme",
+ 'sldb' => "Please specify login data below",
+ 'ld' => "Login Data"
+ );
$r->print(<
-ERROR:
-This user has an unrecognized authentication scheme ($currentauth).
-Please specify login data below.
-Login Data
+$lt{'err'}:
+$lt{'uuas'} ($currentauth). $lt{'sldb'}.
+$lt{'ld'}
$generalrule
$authformkrb
$authformint
@@ -346,21 +703,26 @@ ENDBADAUTH
} else {
# This user is not allowed to modify the users
# authentication scheme, so just notify them of the problem
+ my %lt=&Apache::lonlocal::texthash(
+ 'err' => "ERROR",
+ 'uuas' => "This user has an unrecognized authentication scheme",
+ 'adcs' => "Please alert a domain coordinator of this situation"
+ );
$r->print(<
- ERROR:
-This user has an unrecognized authentication scheme ($currentauth).
-Please alert a domain coordinator of this situation.
+ $lt{'err'}:
+$lt{'uuas'} ($currentauth). $lt{'adcs'}.
ENDBADAUTH
}
} else { # Authentication type is valid
my $authformcurrent='';
my $authform_other='';
- if ($currentauth=~/^krb4:/) {
+ &initialize_authen_forms();
+ if ($currentauth=~/^krb(4|5):/) {
$authformcurrent=$authformkrb;
$authform_other="$authformint
\n".
"$authformfsys
$authformloc
";
@@ -380,55 +742,74 @@ ENDBADAUTH
$authform_other="$authformkrb
".
"$authformint
$authformfsys
";
}
- $authformcurrent=<
-
-* * * WARNING * * *
-* * * WARNING * * *
-
-$authformcurrent
-Changing this value will overwrite existing authentication for the user; you should notify the user of this change.
-
-ENDCURRENTAUTH
- if (&Apache::lonnet::allowed('mau',$ENV{'user.domain'})) {
+ $authformcurrent.=' (will override current values) ';
+ if (&Apache::lonnet::allowed('mau',$env{'request.role.domain'})) {
# Current user has login modification privileges
+ my %lt=&Apache::lonlocal::texthash(
+ 'ccld' => "Change Current Login Data",
+ 'enld' => "Enter New Login Data"
+ );
$r->print(<
-Change Current Login Data
+$lt{'ccld'}
$generalrule
$authformnop
$authformcurrent
-Enter New Login Data
+$lt{'enld'}
$authform_other
ENDOTHERAUTHS
}
} ## End of "check for bad authentication type" logic
} ## End of new user/old user logic
- $r->print('Add Roles ');
+ $r->print(''.&mt('Add Roles').' ');
#
# Co-Author
#
-
- if (&Apache::lonnet::allowed('cca',$ENV{'user.domain'})) {
- my $cuname=$ENV{'user.name'};
- my $cudom=$ENV{'user.domain'};
+ if (&authorpriv($env{'user.name'},$env{'request.role.domain'}) &&
+ ($env{'user.name'} ne $ccuname || $env{'user.domain'} ne $ccdomain)) {
+ # No sense in assigning co-author role to yourself
+ my $cuname=$env{'user.name'};
+ my $cudom=$env{'request.role.domain'};
+ my %lt=&Apache::lonlocal::texthash(
+ 'cs' => "Construction Space",
+ 'act' => "Activate",
+ 'rol' => "Role",
+ 'ext' => "Extent",
+ 'sta' => "Start",
+ 'end' => "End",
+ 'cau' => "Co-Author",
+ 'caa' => "Assistant Co-Author",
+ 'ssd' => "Set Start Date",
+ 'sed' => "Set End Date"
+ );
$r->print(<Construction Space
-Activate Role Extent
-Start End
+$lt{'cs'}
+$lt{'act'} $lt{'rol'} $lt{'ext'}
+$lt{'sta'} $lt{'end'}
+
+
+$lt{'cau'}
+$cudom\_$cuname
+
+$lt{'ssd'}
+
+$lt{'sed'}
+
-
-Co-Author
+
+$lt{'caa'}
$cudom\_$cuname
-
+
Set Start Date
-
+"javascript:pjump('date_start','Start Date Assistant Co-Author',document.cu.start_$cudom\_$cuname\_aa.value,'start_$cudom\_$cuname\_aa','cu.pres','dateset')">$lt{'ssd'}
+
Set End Date
+"javascript:pjump('date_end','End Date Assistant Co-Author',document.cu.end_$cudom\_$cuname\_aa.value,'end_$cudom\_$cuname\_aa','cu.pres','dateset')">$lt{'sed'}
ENDCOAUTH
@@ -436,171 +817,200 @@ ENDCOAUTH
#
# Domain level
#
- $r->print('Domain Level '.
- 'Activate Role Extent '.
- 'Start End ');
+ my $num_domain_level = 0;
+ my $domaintext =
+ ''.&mt('Domain Level').' '.
+ ''.&mt('Activate').' '.&mt('Role').' '.&mt('Extent').' '.
+ ''.&mt('Start').' '.&mt('End').' ';
foreach ( sort( keys(%incdomains))) {
my $thisdomain=$_;
- foreach ('dc','li','dg','au') {
+ foreach ('dc','li','dg','au','sc') {
if (&Apache::lonnet::allowed('c'.$_,$thisdomain)) {
my $plrole=&Apache::lonnet::plaintext($_);
- $r->print(< "Set Start Date",
+ 'sed' => "Set End Date"
+ );
+ $num_domain_level ++;
+ $domaintext .= <<"ENDDROW";
$plrole
$thisdomain
Set Start Date
+"javascript:pjump('date_start','Start Date $plrole',document.cu.start_$thisdomain\_$_.value,'start_$thisdomain\_$_','cu.pres','dateset')">$lt{'ssd'}
Set End Date
+"javascript:pjump('date_end','End Date $plrole',document.cu.end_$thisdomain\_$_.value,'end_$thisdomain\_$_','cu.pres','dateset')">$lt{'sed'}
ENDDROW
}
}
}
- $r->print('
');
+ $domaintext.='
';
+ if ($num_domain_level > 0) {
+ $r->print($domaintext);
+ }
#
# Course level
#
- $r->print(&course_level_table(%inccourses));
- $r->print(" \n");
- $r->print("");
+ my $num_sections;
+
+ if ($env{'request.role'} =~ m-^dc\./(\w+)/$-) {
+ $r->print(&course_level_dc($1));
+ $r->print(' '."\n");
+ } else {
+ $r->print(&course_level_table(%inccourses));
+ $r->print(' '."\n");
+ }
+ $r->print("".&Apache::loncommon::end_page());
}
# ================================================================= Phase Three
-sub phase_three {
+sub update_user_data {
my $r=shift;
- my $uhome=&Apache::lonnet::homeserver($ENV{'form.ccuname'},
- $ENV{'form.ccdomain'});
+ my $uhome=&Apache::lonnet::homeserver($env{'form.ccuname'},
+ $env{'form.ccdomain'});
# Error messages
- my $error = 'Error: ';
- my $end = '