--- loncom/interface/loncreateuser.pm 2012/08/17 22:43:31 1.363 +++ loncom/interface/loncreateuser.pm 2012/10/02 18:08:12 1.366 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Create a user # -# $Id: loncreateuser.pm,v 1.363 2012/08/17 22:43:31 raeburn Exp $ +# $Id: loncreateuser.pm,v 1.366 2012/10/02 18:08:12 bisitz Exp $ # # Copyright Michigan State University Board of Trustees # @@ -1651,7 +1651,7 @@ sub display_existing_roles { $allowed=1; } unless ($allowed) { - my $isowner = &is_courseowner($cid,$coursedata{'internal.courseowner'}); + my $isowner = &Apache::lonuserutils::is_courseowner($cid,$coursedata{'internal.courseowner'}); if ($isowner) { if (($role_code eq 'co') && ($class eq 'Community')) { $allowed = 1; @@ -4259,7 +4259,11 @@ sub handler { if ($env{'form.phase'} eq 'createnewuser') { my $response; if ($env{'form.srchterm'} !~ /^$match_username$/) { - my $response = &mt('You must specify a valid username. Only the following are allowed: letters numbers - . @'); + my $response = + '' + .&mt('You must specify a valid username. Only the following are allowed:' + .' letters numbers - . @') + .''; $env{'form.phase'} = ''; &print_username_entry_form($r,$context,$response,$srch,undef,$crstype,$brcrum); } else { @@ -4380,6 +4384,7 @@ sub handler { bread_crumbs_component => $bread_crumbs_component}; my ($cb_jscript,$jscript,$totcodes,$codetitles,$idlist,$idlist_titles); my $formname = 'studentform'; + my $hidecall = "hide_searching();"; if (($context eq 'domain') && (($env{'form.roletype'} eq 'course') || ($env{'form.roletype'} eq 'community'))) { if ($env{'form.roletype'} eq 'course') { @@ -4396,16 +4401,22 @@ sub handler { ); $jscript = &Apache::lonhtmlcommon::set_form_elements(\%elements); } - $jscript .= &verify_user_display(); + $jscript .= &verify_user_display($context)."\n". + &Apache::loncommon::check_uncheck_jscript(); my $js = &add_script($jscript).$cb_jscript; my $loadcode = &Apache::lonuserutils::course_selector_loadcode($formname); if ($loadcode ne '') { - $args->{add_entries} = {onload => $loadcode}; + $args->{add_entries} = {onload => "$loadcode;$hidecall"}; + } else { + $args->{add_entries} = {onload => $hidecall}; } $r->print(&header($js,$args)); } else { - $r->print(&header(&add_script(&verify_user_display()),$args)); + $args->{add_entries} = {onload => $hidecall}; + $jscript = &verify_user_display($context). + &Apache::loncommon::check_uncheck_jscript(); + $r->print(&header(&add_script($jscript),$args)); } &Apache::lonuserutils::print_userlist($r,undef,$permission,$context, $formname,$totcodes,$codetitles,$idlist,$idlist_titles); @@ -4541,14 +4552,68 @@ sub add_script { } sub verify_user_display { + my ($context) = @_; + my $photos; + if (($context eq 'course') && $env{'request.course.id'}) { + $photos = $env{'course.'.$env{'request.course.id'}.'.internal.showphoto'}; + } my $output = <<"END"; +function hide_searching() { + if (document.getElementById('searching')) { + document.getElementById('searching').style.display = 'none'; + } + return; +} + function display_update() { document.studentform.action.value = 'listusers'; document.studentform.phase.value = 'display'; document.studentform.submit(); } +function updateCols(caller) { + var context = '$context'; + var photos = '$photos'; + if (caller == 'Status') { + if (document.studentform.Status.options[document.studentform.Status.selectedIndex].value == 'Any') { + document.getElementById('showcolstatus').checked = true; + document.getElementById('showcolstatus').disabled = ''; + document.getElementById('showcolstart').checked = true; + document.getElementById('showcolend').checked = true; + } else { + document.getElementById('showcolstatus').checked = false; + document.getElementById('showcolstatus').disabled = 'disabled'; + document.getElementById('showcolstart').checked = false; + document.getElementById('showcolend').checked = false; + } + } + if (caller == 'output') { + if (photos == 1) { + if (document.getElementById('showcolphoto')) { + var photoitem = document.getElementById('showcolphoto'); + if (document.studentform.output.options[document.studentform.output.selectedIndex].value == 'html') { + photoitem.checked = true; + photoitem.disabled = ''; + } else { + photoitem.checked = false; + photoitem.disabled = 'disabled'; + } + } + } + } + if (caller == 'showrole') { + if (document.studentform.showrole.options[document.studentform.showrole.selectedIndex].value == 'Any') { + document.getElementById('showcolrole').checked = true; + document.getElementById('showcolrole').disabled = ''; + } else { + document.getElementById('showcolrole').checked = false; + document.getElementById('showcolrole').disabled = 'disabled'; + } + } + return; +} + END return $output; @@ -6378,7 +6443,7 @@ sub course_level_table { my $thiscourse=$protectedcourse; $thiscourse=~s:_:/:g; my %coursedata=&Apache::lonnet::coursedescription($thiscourse); - my $isowner = &is_courseowner($protectedcourse,$coursedata{'internal.courseowner'}); + my $isowner = &Apache::lonuserutils::is_courseowner($protectedcourse,$coursedata{'internal.courseowner'}); my $area=$coursedata{'description'}; my $crstype=$coursedata{'type'}; if (!defined($area)) { $area=&mt('Unavailable course').': '.$protectedcourse; } @@ -6872,7 +6937,7 @@ sub update_selfenroll_config { my ($visible,$cansetvis,$vismsgs,$visactions) = &visible_in_cat($cdom,$cnum); if (ref($visactions) eq 'HASH') { if (!$visible) { - $r->print('
'.$visactions->{'miss'}.'
'.$visactions->{'yous'}. + $r->print('
'.$visactions->{'miss'}.'
'.$visactions->{'yous'}. '
'); if (ref($vismsgs) eq 'ARRAY') { $r->print('
'.$visactions->{'take'}.'