--- loncom/interface/loncreateuser.pm 2012/08/17 22:43:31 1.363 +++ loncom/interface/loncreateuser.pm 2012/08/21 15:43:27 1.365 @@ -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.365 2012/08/21 15:43:27 raeburn 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; @@ -4380,6 +4380,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 +4397,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 +4548,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 +6439,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; } @@ -6902,21 +6963,6 @@ sub get_selfenroll_titles { return (\@row,\%lt); } -sub is_courseowner { - my ($thiscourse,$courseowner) = @_; - if ($courseowner eq '') { - if ($env{'request.course.id'} eq $thiscourse) { - $courseowner = $env{'course.'.$env{'request.course.id'}.'.internal.courseowner'}; - } - } - if ($courseowner ne '') { - if ($courseowner eq $env{'user.name'}.':'.$env{'user.domain'}) { - return 1; - } - } - return; -} - #---------------------------------------------- end functions for &phase_two #--------------------------------- functions for &phase_two and &phase_three