--- loncom/interface/loncreateuser.pm 2004/02/01 20:42:01 1.78
+++ loncom/interface/loncreateuser.pm 2005/06/17 21:04:40 1.104
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Create a user
#
-# $Id: loncreateuser.pm,v 1.78 2004/02/01 20:42:01 www Exp $
+# $Id: loncreateuser.pm,v 1.104 2005/06/17 21:04:40 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -73,10 +73,9 @@ 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
);
@@ -109,10 +108,7 @@ sub my_custom_roles {
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 ''; }
+ unless (&Apache::lonnet::allowed('cca',$audom.'/'.$auname)) { return ''; }
return 1;
}
@@ -120,13 +116,11 @@ sub authorpriv {
sub print_username_entry_form {
my $r=shift;
- my $defdom=$ENV{'request.role.domain'};
+ 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').
- &Apache::loncommon::help_open_faq(282).
- &Apache::loncommon::help_open_bug('Instructor Interface');
+ my $html=&Apache::lonxml::xmlbegin();
+ my $bodytag =&Apache::loncommon::bodytag('Create Users, Change User Privileges').&Apache::loncommon::help_open_menu('',undef,undef,'',282,'Instructor Interface');
my $selscript=&Apache::loncommon::studentbrowser_javascript();
my $sellink=&Apache::loncommon::selectstudent_link
('crtuser','ccuname','ccdomain');
@@ -145,7 +139,7 @@ sub print_username_entry_form {
my $helpsiur=&Apache::loncommon::help_open_topic('Course_Change_Privileges');
my $helpecpr=&Apache::loncommon::help_open_topic('Course_Editing_Custom_Roles');
$r->print(<<"ENDDOCUMENT");
-
+$html
The LearningOnline Network with CAPA
$selscript
@@ -174,18 +168,18 @@ ENDDOCUMENT
# =================================================================== Phase two
sub print_user_modification_page {
my $r=shift;
- my $ccuname=$ENV{'form.ccuname'};
- my $ccdomain=$ENV{'form.ccdomain'};
+ my $ccuname=$env{'form.ccuname'};
+ my $ccdomain=$env{'form.ccdomain'};
- $ccuname=~s/\W//gs;
- $ccdomain=~s/\W//gs;
+ $ccuname=~s/\W//g;
+ $ccdomain=~s/\W//g;
unless (($ccuname) && ($ccdomain)) {
&print_username_entry_form($r);
return;
}
- my $defdom=$ENV{'request.role.domain'};
+ my $defdom=$env{'request.role.domain'};
my ($krbdef,$krbdefdom) =
&Apache::loncommon::get_kerberos_defaults($defdom);
@@ -200,8 +194,84 @@ sub print_user_modification_page {
$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
+$html
The LearningOnline Network with CAPA
ENDDOCHEAD
$r->print(&Apache::loncommon::bodytag(
- 'Create Users, Change User Privileges'));
+ 'Create Users, Change User Privileges',undef,$loaditem));
my $forminfo =<<"ENDFORMINFO";