--- loncom/interface/loncreateuser.pm 2002/09/03 20:46:04 1.39.4.2
+++ loncom/interface/loncreateuser.pm 2003/12/10 20:38:09 1.72
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Create a user
#
-# $Id: loncreateuser.pm,v 1.39.4.2 2002/09/03 20:46:04 albertel Exp $
+# $Id: loncreateuser.pm,v 1.72 2003/12/10 20:38:09 sakharuk 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.39.4.2 2002/09/03 20:46:04 albertel 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;
@@ -71,15 +80,42 @@ BEGIN {
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)=@_;
+ if (($auname ne $ENV{'user.name'}) ||
+ (($audom ne $ENV{'user.domain'}) &&
+ ($audom ne $ENV{'request.role.domain'}))) { return ''; }
+ unless (&Apache::lonnet::allowed('cca',$audom)) { return ''; }
+ return 1;
+}
+
# =================================================================== Phase one
sub print_username_entry_form {
@@ -87,21 +123,45 @@ sub print_username_entry_form {
my $defdom=$ENV{'request.role.domain'};
my @domains = &Apache::loncommon::get_domains();
my $domform = &Apache::loncommon::select_dom_form($defdom,'ccdomain');
+ my $bodytag =&Apache::loncommon::bodytag(
+ 'Create Users, Change User Privileges');
+ my $selscript=&Apache::loncommon::studentbrowser_javascript();
+ 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"
+ );
$r->print(<<"ENDDOCUMENT");
The LearningOnline Network with CAPA
+$selscript
-
-Create User, Change User Privileges
-
+
-Home Server: $home_server_list
+$lt{'idsn'}
+${'hs'}: $home_server_list
-Login Data
+$lt{'lg'}
$generalrule
$authformkrb
$authformint
@@ -214,11 +291,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
+$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 +315,20 @@ ENDCHANGEUSER
END
@@ -250,33 +336,70 @@ END
my ($tmp) = keys(%rolesdump);
unless ($tmp =~ /^(con_lost|error)/i) {
my $now=time;
+ my %lt=&Apache::lonlocal::texthash(
+ 'rer' => "Revoke Existing Roles",
+ 'rev' => "Revoke",
+ 'del' => "Delete",
+ 'rol' => "Role",
+ 'ext' => "Extent",
+ 'sta' => "Start",
+ 'end' => "End"
+ );
$r->print(<
-Revoke Existing Roles
+$lt{'rer'}
-Revoke Role Extent Start End
+$lt{'rev'} $lt{'del'} $lt{'rol'} $lt{'ext'} $lt{'sta'} $lt{'end'}
END
- foreach my $area (keys(%rolesdump)) {
+ 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 $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;
if ($area =~ /^\/(\w+)\/(\d\w+)/ ) {
+ my ($coursedom,$coursedir) = ($1,$2);
+ # $1.'_'.$2 is the course id (eg. 103_12345abcef103l3).
my %coursedata=
&Apache::lonnet::coursedescription($1.'_'.$2);
- my $carea='Course: '.$coursedata{'description'};
+ my $carea;
+ if (defined($coursedata{'description'})) {
+ $carea=&mt('Course').': '.$coursedata{'description'}.
+ ' '.&mt('Domain').': '.$coursedom.(' 'x8).
+ &Apache::loncommon::syllabuswrapper('Syllabus',$coursedir,$coursedom);
+ } else {
+ $carea=&mt('Unavailable course').': '.$area;
+ }
$inccourses{$1.'_'.$2}=1;
- if (&Apache::lonnet::allowed('c'.$role_code,$1.'/'.$2)) {
+ 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/[^8-9b-e]//g;
- $bgcol=substr($bgcol.$bgcol.$bgcol.'ffffff',0,6);
+ $bgcol=~s/[^7-9a-e]//g;
+ $bgcol=substr($bgcol.$bgcol.$bgcol.'ffffff',2,6);
if ($area=~/^\/(\w+)\/(\d\w+)\/(\w+)/) {
$carea.=' Section/Group: '.$3;
}
@@ -284,39 +407,56 @@ END
} else {
# Determine if current user is able to revoke privileges
if ($area=~ /^\/(\w+)\//) {
- if (&Apache::lonnet::allowed('c'.$role_code,$1)) {
+ 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;
}
}
}
- # I have no idea what the hell the above code does
- # So the following is a check:
- if ($allowed) {
- # If we are looking at a co-author role, make sure it is
- # for the current users construction space before we let
- # them revoke it.
- if (($role_code eq 'ca') &&
- ($ENV{'request.role'} !~ /^dc/)) {
- if ($area !~
- /^\/$ENV{'request.role.domain'}\/$ENV{'user.name'}/) {
- $allowed = 0;
- }
+ if ($role_code eq 'ca') {
+ $area=~/\/(\w+)\/(\w+)/;
+ if (&authorpriv($2,$1)) {
+ $allowed=1;
+ } else {
+ $allowed=0;
}
}
my $row = '';
- $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 ($delallowed) {
+ $row.= ' ';
+ } else {
$row.=' ';
}
- $row.= ' '.&Apache::lonnet::plaintext($role_code).
+ 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)
: ' ' ).
@@ -328,16 +468,16 @@ END
$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=$1;
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:/
@@ -375,7 +515,7 @@ ENDBADAUTH
} else { # Authentication type is valid
my $authformcurrent='';
my $authform_other='';
- if ($currentauth=~/^krb4:/) {
+ if ($currentauth=~/^krb(4|5):/) {
$authformcurrent=$authformkrb;
$authform_other="$authformint
\n".
"$authformfsys
$authformloc
";
@@ -395,16 +535,7 @@ 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
+ $authformcurrent.=' (will override current values) ';
if (&Apache::lonnet::allowed('mau',$ENV{'request.role.domain'})) {
# Current user has login modification privileges
$r->print(<print('Add Roles ');
+ $r->print(''.&mt('Add Roles').' ');
#
# Co-Author
#
- if (&Apache::lonnet::allowed('cca',$ENV{'request.role.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",
+ 'ssd' => "Set Start Date",
+ 'sed' => "Set End Date"
+ );
$r->print(<Construction Space
-Activate Role Extent
-Start End
+$lt{'cs'}
+${'act'} ${'rol'} ${'ext'}
+$lt{'sta'} $lt{'end'}
-Co-Author
+$lt{'cau'}
$cudom\_$cuname
Set Start Date
+"javascript:pjump('date_start','Start Date Co-Author',document.cu.start_$cudom\_$cuname\_ca.value,'start_$cudom\_$cuname\_ca','cu.pres','dateset')">$lt{'ssd'}
Set End Date
+"javascript:pjump('date_end','End Date Co-Author',document.cu.end_$cudom\_$cuname\_ca.value,'end_$cudom\_$cuname\_ca','cu.pres','dateset')">$lt{'sed'}
ENDCOAUTH
@@ -450,14 +594,18 @@ ENDCOAUTH
#
# Domain level
#
- $r->print('Domain Level '.
+ $r->print(''.&mt('Domain Level').' '.
'Activate Role Extent '.
'Start 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($_);
+ my %lt=&Apache::lonlocal::texthash(
+ 'ssd' => "Set Start Date",
+ 'sed' => "Set End Date"
+ );
$r->print(<
@@ -465,10 +613,10 @@ ENDCOAUTH
$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
}
@@ -479,7 +627,7 @@ ENDDROW
# Course level
#
$r->print(&course_level_table(%inccourses));
- $r->print(" \n");
+ $r->print(" \n");
$r->print("");
}
@@ -497,9 +645,14 @@ sub update_user_data {
The LearningOnline Network with CAPA
-
-
ENDTHREEHEAD
+ my $title;
+ if (exists($ENV{'form.makeuser'})) {
+ $title='Set Privileges for New User';
+ } else {
+ $title='Modify User Privileges';
+ }
+ $r->print(&Apache::loncommon::bodytag($title));
# Check Inputs
if (! $ENV{'form.ccuname'} ) {
$r->print($error.'No login name specified.'.$end);
@@ -534,7 +687,8 @@ ENDTHREEHEAD
my $amode='';
my $genpwd='';
if ($ENV{'form.login'} eq 'krb') {
- $amode='krb4';
+ $amode='krb';
+ $amode.=$ENV{'form.krbver'};
$genpwd=$ENV{'form.krbarg'};
} elsif ($ENV{'form.login'} eq 'int') {
$amode='internal';
@@ -559,8 +713,7 @@ ENDTHREEHEAD
if ($ENV{'form.makeuser'}) {
# Create a new user
$r->print(<Create User
-Creating user "$ENV{'form.ccuname'}" in domain "$ENV{'form.ccdomain'}"
+Creating user "$ENV{'form.ccuname'}" in domain "$ENV{'form.ccdomain'}"
ENDNEWUSERHEAD
# Check for the authentication mode and password
if (! $amode || ! $genpwd) {
@@ -589,13 +742,12 @@ ENDNEWUSERHEAD
$r->print('Generating user: '.$result);
my $home = &Apache::lonnet::homeserver($ENV{'form.ccuname'},
$ENV{'form.ccdomain'});
- $r->print(' Home server: '.$home.' '.
+ $r->print(' Home server: '.$home.' '.
$Apache::lonnet::libserv{$home});
} elsif (($ENV{'form.login'} ne 'nochange') &&
($ENV{'form.login'} ne '' )) {
# Modify user privileges
$r->print(<Change User Privileges
User "$ENV{'form.ccuname'}" in domain "$ENV{'form.ccdomain'}"
ENDMODIFYUSERHEAD
if (! $amode || ! $genpwd) {
@@ -689,48 +841,100 @@ END
next if (! $ENV{$_});
# Revoke roles
if ($_=~/^form\.rev/) {
- if ($_=~/^form\.rev\:([^\_]+)\_([^\_]+)$/) {
- $r->print('Revoking '.$2.' in '.$1.': '.
+ if ($_=~/^form\.rev\:([^\_]+)\_([^\_\.]+)$/) {
+# Revoke standard role
+ $r->print('Revoking '.$2.' in '.$1.': '.
+ &Apache::lonnet::revokerole($ENV{'form.ccdomain'},
+ $ENV{'form.ccuname'},$1,$2).' ');
+ if ($2 eq 'st') {
+ $1=~/^\/(\w+)\/(\w+)/;
+ my $cid=$1.'_'.$2;
+ $r->print('Drop from classlist: '.
+ &Apache::lonnet::critical('put:'.
+ $ENV{'course.'.$cid.'.domain'}.':'.
+ $ENV{'course.'.$cid.'.num'}.':classlist:'.
+ &Apache::lonnet::escape($ENV{'form.ccuname'}.':'.
+ $ENV{'form.ccdomain'}).'='.
+ &Apache::lonnet::escape($now.':'),
+ $ENV{'course.'.$cid.'.home'}).' ');
+ }
+ }
+ if ($_=~/^form\.rev\:([^\_]+)\_cr\.cr\/(\w+)\/(\w+)\/(\w+)$/) {
+# Revoke custom role
+ $r->print(
+ 'Revoking custom role '.$4.' by '.$3.'@'.$2.' in '.$1.': '.
+&Apache::lonnet::revokecustomrole($ENV{'form.ccdomain'},
+ $ENV{'form.ccuname'},$1,$2,$3,$4).
+ ' ');
+ }
+ } elsif ($_=~/^form\.del/) {
+ if ($_=~/^form\.del\:([^\_]+)\_([^\_]+)$/) {
+ $r->print('Deleting '.$2.' in '.$1.': '.
&Apache::lonnet::assignrole($ENV{'form.ccdomain'},
- $ENV{'form.ccuname'},$1,$2,$now).' ');
+ $ENV{'form.ccuname'},$1,$2,$now,0,1).' ');
if ($2 eq 'st') {
$1=~/^\/(\w+)\/(\w+)/;
my $cid=$1.'_'.$2;
- $r->print('Drop from classlist: '.
+ $r->print('Drop from classlist: '.
&Apache::lonnet::critical('put:'.
$ENV{'course.'.$cid.'.domain'}.':'.
$ENV{'course.'.$cid.'.num'}.':classlist:'.
&Apache::lonnet::escape($ENV{'form.ccuname'}.':'.
$ENV{'form.ccdomain'}).'='.
&Apache::lonnet::escape($now.':'),
- $ENV{'course.'.$cid.'.home'}).' ');
+ $ENV{'course.'.$cid.'.home'}).' ');
}
}
} elsif ($_=~/^form\.act/) {
- if ($_=~/^form\.act\_([^\_]+)\_([^\_]+)\_([^\_]+)$/) {
+ if
+($_=~/^form\.act\_([^\_]+)\_([^\_]+)\_cr_cr_([^\_]+)_(\w+)_([^\_]+)$/) {
+ # Activate a custom role
+ my $url='/'.$1.'/'.$2;
+ my $full=$1.'_'.$2.'_cr_cr_'.$3.'_'.$4.'_'.$5;
+ if ($ENV{'form.sec_'.$full}) {
+ $url.='/'.$ENV{'form.sec_'.$full};
+ }
+
+ my $start = ( $ENV{'form.start_'.$full} ?
+ $ENV{'form.start_'.$full} :
+ $now );
+ my $end = ( $ENV{'form.end_'.$full} ?
+ $ENV{'form.end_'.$full} :
+ 0 );
+
+ $r->print('Assigning custom role "'.$5.'" by '.$4.'@'.$3.' in '.$url.
+ ($start?', starting '.localtime($start):'').
+ ($end?', ending '.localtime($end):'').': '.
+ &Apache::lonnet::assigncustomrole(
+ $ENV{'form.ccdomain'},$ENV{'form.ccuname'},$url,$3,$4,$5,$end,$start).
+ ' ');
+ } elsif ($_=~/^form\.act\_([^\_]+)\_([^\_]+)\_([^\_]+)$/) {
# Activate roles for sections with 3 id numbers
# set start, end times, and the url for the class
- my $start = ( $ENV{'form.start_'.$1.'_'.$2} ?
- $ENV{'form.start_'.$1.'_'.$2} :
+
+ my $start = ( $ENV{'form.start_'.$1.'_'.$2.'_'.$3} ?
+ $ENV{'form.start_'.$1.'_'.$2.'_'.$3} :
$now );
- my $end = ( $ENV{'form.end_'.$1.'_'.$2} ?
- $ENV{'form.end_'.$1.'_'.$2} :
+ my $end = ( $ENV{'form.end_'.$1.'_'.$2.'_'.$3} ?
+ $ENV{'form.end_'.$1.'_'.$2.'_'.$3} :
0 );
my $url='/'.$1.'/'.$2;
if ($ENV{'form.sec_'.$1.'_'.$2.'_'.$3}) {
$url.='/'.$ENV{'form.sec_'.$1.'_'.$2.'_'.$3};
}
# Assign the role and report it
- $r->print('Assigning: '.$3.' in '.$url.': '.
+ $r->print('Assigning '.$3.' in '.$url.
+ ($start?', starting '.localtime($start):'').
+ ($end?', ending '.localtime($end):'').': '.
&Apache::lonnet::assignrole(
$ENV{'form.ccdomain'},$ENV{'form.ccuname'},
$url,$3,$end,$start).
- ' ');
+ ' ');
# Handle students differently
if ($3 eq 'st') {
$url=~/^\/(\w+)\/(\w+)/;
my $cid=$1.'_'.$2;
- $r->print('Add to classlist: '.
+ $r->print('Add to classlist: '.
&Apache::lonnet::critical(
'put:'.$ENV{'course.'.$cid.'.domain'}.':'.
$ENV{'course.'.$cid.'.num'}.':classlist:'.
@@ -739,7 +943,7 @@ END
$ENV{'form.ccdomain'} ).'='.
&Apache::lonnet::escape($end.':'.$start),
$ENV{'course.'.$cid.'.home'})
- .' ');
+ .' ');
}
} elsif ($_=~/^form\.act\_([^\_]+)\_([^\_]+)$/) {
# Activate roles for sections with two id numbers
@@ -752,23 +956,190 @@ END
0 );
my $url='/'.$1.'/';
# Assign the role and report it.
- $r->print('Assigning: '.$2.' in '.$url.': '.
+ $r->print('Assigning '.$2.' in '.$url.': '.
+ ($start?', starting '.localtime($start):'').
+ ($end?', ending '.localtime($end):'').': '.
&Apache::lonnet::assignrole(
$ENV{'form.ccdomain'},$ENV{'form.ccuname'},
$url,$2,$end,$start)
- .' ');
- }
+ .' ');
+ } else {
+ $r->print('ERROR: Unknown command '.$_.'
');
+ }
}
} # End of foreach (keys(%ENV))
$r->print('