--- loncom/interface/loncreateuser.pm 2004/01/19 23:09:07 1.70.2.1
+++ loncom/interface/loncreateuser.pm 2005/06/23 21:56:12 1.106
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Create a user
#
-# $Id: loncreateuser.pm,v 1.70.2.1 2004/01/19 23:09:07 albertel Exp $
+# $Id: loncreateuser.pm,v 1.106 2005/06/23 21:56:12 www 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,8 @@ 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))
+ || (&Apache::lonnet::allowed('caa',$audom.'/'.$auname))) { return ''; }
return 1;
}
@@ -120,19 +117,30 @@ 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');
+ 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');
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 $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
@@ -140,39 +148,43 @@ $selscript
$bodytag
+ENDDOCUMENT
+ if (&Apache::lonnet::allowed('mcr','/')) {
+ $r->print(<
-
Edit Custom Role Privileges
-Name of Role: $choice
-
+
$lt{'ecrp'}$helpecpr
+$lt{'nr'}: $choice
+
-ENDDOCUMENT
+ENDCUSTOM
+ }
}
# =================================================================== 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);
@@ -187,8 +199,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";