--- loncom/interface/loncreateuser.pm 2006/06/02 13:58:31 1.120 +++ loncom/interface/loncreateuser.pm 2006/11/21 21:03:06 1.133 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Create a user # -# $Id: loncreateuser.pm,v 1.120 2006/06/02 13:58:31 raeburn Exp $ +# $Id: loncreateuser.pm,v 1.133 2006/11/21 21:03:06 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -142,7 +142,7 @@ sub print_username_entry_form { 'nr' => "Name of Role", 'cre' => "Custom Role Editor" ); - my $help = &Apache::loncommon::help_open_menu('',undef,undef,'',282,'Instructor Interface'); + 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"); @@ -313,18 +313,27 @@ sub print_user_modification_page { alert("Section designations do not apply to Course Coordinator roles.\\nA course coordinator role will be added with access to all sections."); section = ""; } + var coursename = "_$dcdom"+"_"+course+"_"+userrole 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+5].name = "sec"+coursename - document.cu.elements[numcourse+5].value = section - document.cu.elements[numcourse+7].name = "start"+coursename - document.cu.elements[numcourse+8].name = "end"+coursename + else { + document.cu.elements[numcourse].name = "act"+coursename; + var numnewsec = getIndex(document.cu.newsec); + if (numnewsec != "-1") { + document.cu.elements[numnewsec].name = "sec"+coursename; + document.cu.elements[numnewsec].value = section; + } + var numstart = getIndex(document.cu.start); + if (numstart != "-1") { + document.cu.elements[numstart].name = "start"+coursename; + } + var numend = getIndex(document.cu.end); + if (numend != "-1") { + document.cu.elements[numend].name = "end"+coursename + } } } document.cu.submit(); @@ -378,7 +387,6 @@ ENDSCRIPT var str = document.cu.elements[i].name; var checkcurr = str.match(re1); if (checkcurr != null) { - var re2 = /^currsec_[a-zA-Z0-9]+_[a-zA-Z0-9]+_(\\w+)\$/; if (document.cu.elements[i-1].checked == true) { var re2 = /^currsec_[a-zA-Z0-9]+_[a-zA-Z0-9]+_(\\w+)\$/; match = re2.exec(str); @@ -415,15 +423,17 @@ ENDSCRIPT sections = document.cu.elements[i+1].value; } var newsecs = document.cu.elements[i+1].value; + var numsplit; if (newsecs != null && newsecs != "") { - var numsplit = newsecs.split(/,/g); + 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 { + else if (numsplit != null) { for (var j=0; j "ERROR", @@ -793,7 +804,7 @@ $lt{'uuas'} ($currentauth). $lt{'sldb'}.

$authformloc

ENDBADAUTH } else { - # This user is not allowed to modify the users + # This user is not allowed to modify the user's # authentication scheme, so just notify them of the problem my %lt=&Apache::lonlocal::texthash( 'err' => "ERROR", @@ -802,9 +813,6 @@ ENDBADAUTH ); $r->print(< - $lt{'err'}: $lt{'uuas'} ($currentauth). $lt{'adcs'}.
@@ -835,7 +843,7 @@ ENDBADAUTH "

$authformint

$authformfsys

"; } $authformcurrent.=' (will override current values)
'; - if (&Apache::lonnet::allowed('mau',$env{'request.role.domain'})) { + if (&Apache::lonnet::allowed('mau',$ccdomain)) { # Current user has login modification privileges my %lt=&Apache::lonlocal::texthash( 'ccld' => "Change Current Login Data", @@ -853,6 +861,19 @@ $loginscript

$lt{'enld'}

$authform_other ENDOTHERAUTHS + } else { + if (&Apache::lonnet::allowed('mau',$env{'request.role.domain'})) { + my %lt=&Apache::lonlocal::texthash( + 'ccld' => "Change Current Login Data", + 'yodo' => "You do not have privileges to modify the authentication configuration for this user.", + 'ifch' => "If a change is required, contact a domain coordinator for the domain", + ); + $r->print(< +

$lt{'ccld'}

+$lt{'yodo'} $lt{'ifch'}: $ccdomain +ENDNOPRIV + } } } ## End of "check for bad authentication type" logic } ## End of new user/old user logic @@ -1249,7 +1270,7 @@ END my $output; if ($role eq 'st') { if ($url =~ m-^/(\w+)/(\w+)/?(\w*)$-) { - my $result = &commit_studentrole(\$logmsg,$udom,$uname,$url,$role,$now,0,$1,$2,$3); + my $result = &Apache::loncommon::commit_studentrole(\$logmsg,$udom,$uname,$url,$role,$now,0,$1,$2,$3); if (($result =~ /^error/) || ($result eq 'not_in_class') || ($result eq 'unknown_course')) { $output = "Error: $result\n"; } else { @@ -1296,7 +1317,7 @@ END my %sections = (); my $num_sections = &build_roles($env{'form.sec_'.$full},\%sections,$5); if ($num_sections == 0) { - $r->print(&commit_customrole($udom,$uname,$url,$three,$four,$five,$start,$end)); + $r->print(&Apache::loncommon::commit_customrole($udom,$uname,$url,$three,$four,$five,$start,$end)); } else { my %curr_groups = &Apache::longroup::coursegroups($one,$two); @@ -1307,7 +1328,7 @@ END next; } my $securl = $url.'/'.$sec; - $r->print(&commit_customrole($udom,$uname,$securl,$three,$four,$five,$start,$end)); + $r->print(&Apache::loncommon::commit_customrole($udom,$uname,$securl,$three,$four,$five,$start,$end)); } } } elsif ($_=~/^form\.act\_([^\_]+)\_(\w+)\_([^\_]+)$/) { @@ -1326,7 +1347,7 @@ END my %sections = (); my $num_sections = &build_roles($env{'form.sec_'.$one.'_'.$two.'_'.$three},\%sections,$three); if ($num_sections == 0) { - $r->print(&commit_standardrole($udom,$uname,$url,$three,$start,$end,$one,$two,'')); + $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$url,$three,$start,$end,$one,$two,'')); } else { my %curr_groups = &Apache::longroup::coursegroups($one,$two); @@ -1340,13 +1361,13 @@ END next; } my $securl = $url.'/'.$sec; - $r->print(&commit_standardrole($udom,$uname,$securl,$three,$start,$end,$one,$two,$sec)); + $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$securl,$three,$start,$end,$one,$two,$sec)); } else { $emptysec = 1; } } if ($emptysec) { - $r->print(&commit_standardrole($udom,$uname,$url,$three,$start,$end,$one,$two,'')); + $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$url,$three,$start,$end,$one,$two,'')); } } } elsif ($_=~/^form\.act\_([^\_]+)\_([^\_]+)$/) { @@ -1363,19 +1384,19 @@ END my %sections = (); my $num_sections = &build_roles($env{'form.sec_'.$1.'_'.$2},\%sections,$2); if ($num_sections == 0) { - $r->print(&commit_standardrole($udom,$uname,$url,$2,$start,$end,$1,undef,'')); + $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$url,$2,$start,$end,$1,undef,'')); } else { my $emptysec = 0; foreach my $sec (sort {$a cmp $b} keys %sections) { if ($sec ne '') { my $securl = $url.'/'.$sec; - $r->print(&commit_standardrole($udom,$uname,$securl,$2,$start,$end,$1,undef,$sec)); + $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$securl,$2,$start,$end,$1,undef,$sec)); } else { $emptysec = 1; } } if ($emptysec) { - $r->print(&commit_standardrole($udom,$uname,$url,$2,$start,$end,$1,undef,'')); + $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$url,$2,$start,$end,$1,undef,'')); } } } else { @@ -1397,89 +1418,6 @@ END $r->print(&Apache::loncommon::end_page()); } -sub commit_customrole { - my ($udom,$uname,$url,$three,$four,$five,$start,$end) = @_; - my $output = &mt('Assigning custom role').' "'.$five.'" by '.$four.'@'.$three.' in '.$url. - ($start?', '.&mt('starting').' '.localtime($start):''). - ($end?', ending '.localtime($end):'').': '. - &Apache::lonnet::assigncustomrole( - $udom,$uname,$url,$three,$four,$five,$end,$start). - '
'; - return $output; -} - -sub commit_standardrole { - my ($udom,$uname,$url,$three,$start,$end,$one,$two,$sec) = @_; - my $output; - my $logmsg; - if ($three eq 'st') { - my $result = &commit_studentrole(\$logmsg,$udom,$uname,$url,$three,$start,$end,$one,$two,$sec); - if (($result =~ /^error/) || ($result eq 'not_in_class') || ($result eq 'unknown_course')) { - $output = "Error: $result\n"; - } else { - $output = &mt('Assigning').' '.$three.' in '.$url. - ($start?', '.&mt('starting').' '.localtime($start):''). - ($end?', '.&mt('ending').' '.localtime($end):''). - ': '.$result.'
'. - &mt('Add to classlist').': ok
'; - } - } else { - $output = &mt('Assigning').' '.$three.' in '.$url. - ($start?', '.&mt('starting').' '.localtime($start):''). - ($end?', '.&mt('ending').' '.localtime($end):'').': '. - &Apache::lonnet::assignrole( - $udom,$uname,$url,$three,$end,$start). - '
'; - } - return $output; -} - -sub commit_studentrole { - my ($logmsg,$udom,$uname,$url,$three,$start,$end,$one,$two,$sec) = @_; - my $linefeed = '
'."\n"; - my $result; - if (defined($one) && defined($two)) { - my $cid=$one.'_'.$two; - my $oldsec=&Apache::lonnet::getsection($udom,$uname,$cid); - my $secchange = 0; - my $expire_role_result; - my $modify_section_result; - unless ($oldsec eq '-1') { - unless ($sec eq $oldsec) { - $secchange = 1; - my $uurl='/'.$cid; - $uurl=~s/\_/\//g; - if ($oldsec) { - $uurl.='/'.$oldsec; - } - $expire_role_result = &Apache::lonnet::assignrole($udom,$uname,$uurl,'st',time); - $result = $expire_role_result; - } - } - if (($expire_role_result eq 'ok') || ($secchange == 0)) { - $modify_section_result = &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,$sec,$end,$start,'','',$cid); - if ($modify_section_result =~ /^ok/) { - if ($secchange == 1) { - $$logmsg .= "Section for $uname switched from old section: $oldsec to new section: $sec".$linefeed; - } elsif ($oldsec eq '-1') { - $$logmsg .= "New student role for $uname in section $sec in course $cid".$linefeed; - } else { - $$logmsg .= "Student $uname assigned to unchanged section $sec in course $cid".$linefeed; - } - } else { - $$logmsg .= "Error when attempting section change for $uname from old section $oldsec to new section: $sec in course $cid -error: $modify_section_result".$linefeed; - } - $result = $modify_section_result; - } elsif ($secchange == 1) { - $$logmsg .= "Error when attempting to expire role for $uname in old section $oldsec in course $cid -error: $expire_role_result".$linefeed; - } - } else { - $$logmsg .= "Incomplete course id defined. Addition of user $uname from domain $udom to course $one\_$two, section $sec not completed.$linefeed"; - $result = "error: incomplete course id\n"; - } - return $result; -} - sub build_roles { my ($sectionstr,$sections,$role) = @_; my $num_sections = 0; @@ -1509,7 +1447,7 @@ sub build_roles { $num_sections ++; } } - + return $num_sections; } @@ -1584,7 +1522,7 @@ sub custom_role_editor { } my %lt=&Apache::lonlocal::texthash( 'prv' => "Privilege", - 'crl' => "Course/Group Level", + 'crl' => "Course Level", 'dml' => "Domain Level", 'ssl' => "System Level" ); @@ -1598,11 +1536,6 @@ sub custom_role_editor { ENDCCF foreach my $priv (sort keys %full) { my $privtext = &Apache::lonnet::plaintext($priv); - if ($env{'course.'.$env{'request.course.id'}.'.type'}) { - $privtext =~ s/Student/Member/; - $privtext =~ s/student/member/; - $privtext =~ s/course/group/; - } $r->print(''.$privtext.''. ($courselevel{$priv}?'':' '). @@ -1739,7 +1672,7 @@ sub course_level_table { 'new' => "Define new section", 'ssd' => "Set Start Date", 'sed' => "Set End Date", - 'crl' => "Course/Group Level", + 'crl' => "Course Level", 'act' => "Activate", 'rol' => "Role", 'ext' => "Extent", @@ -1770,9 +1703,6 @@ sub course_level_table { foreach ('st','ta','ep','in','cc') { if (&Apache::lonnet::allowed('c'.$_,$thiscourse)) { my $plrole=&Apache::lonnet::plaintext($_); - if ($type eq 'Group') { - $plrole = &Apache::loncommon::convert_role($plrole,$type); - } $table .= < @@ -1889,8 +1819,8 @@ sub course_level_dc { ''. ''; my $courseform=''.&Apache::loncommon::selectcourse_link - ('cu','dccourse','dcdomain','coursedesc',undef,undef,'Course/Group').''; - my $cb_jscript = &Apache::loncommon::coursebrowser_javascript($dcdom); + ('cu','dccourse','dcdomain','coursedesc',undef,undef,'Course').''; + my $cb_jscript = &Apache::loncommon::coursebrowser_javascript($dcdom,'currsec','cu'); my %lt=&Apache::lonlocal::texthash( 'typ' => "Type", 'rol' => "Role", @@ -1902,14 +1832,14 @@ sub course_level_dc { 'ssd' => "Set Start Date", 'sed' => "Set End Date" ); - my $header = '

'.&mt('Course/Group Level').'

'. + my $header = '

'.&mt('Course Level').'

'. ''; my $otheritems = ''."\n". + ''."\n". '
'.$lt{'typ'}.''.$courseform.''.$lt{'rol'}.''.$lt{'grs'}.''.$lt{'sta'}.''.$lt{'end'}.'
'."\n". - '