--- loncom/interface/loncommon.pm 2007/07/06 09:02:03 1.546 +++ loncom/interface/loncommon.pm 2007/07/30 00:31:28 1.556 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common routines # -# $Id: loncommon.pm,v 1.546 2007/07/06 09:02:03 albertel Exp $ +# $Id: loncommon.pm,v 1.556 2007/07/30 00:31:28 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -709,8 +709,7 @@ sub help_open_topic { my ($topic, $text, $stayOnPage, $width, $height) = @_; $text = "" if (not defined $text); $stayOnPage = 0 if (not defined $stayOnPage); - if ($env{'browser.interface'} eq 'textual' || - $env{'environment.remote'} eq 'off' ) { + if ($env{'browser.interface'} eq 'textual') { $stayOnPage=1; } $width = 350 if (not defined $width); @@ -802,12 +801,17 @@ ENDOUTPUT # now just updates the help link and generates a blue icon sub help_open_menu { my ($topic,$component_help,$faq,$bug,$stayOnPage,$width,$height,$text) - = @_; - + = @_; $stayOnPage = 0 if (not defined $stayOnPage); - if ($env{'browser.interface'} eq 'textual' || - $env{'environment.remote'} eq 'off' ) { - $stayOnPage=1; + # formerly only used pop-up help (stayOnPage = 0) + # if environment.remote is on (using remote control UI) + # if ($env{'browser.interface'} eq 'textual' || + # $env{'environment.remote'} eq 'off' ) { + # $stayOnPage=1; + #} + # Now making pop-up help the default even with remote control + if ($env{'browser.interface'} eq 'textual') { + $stayOnPage=1; } my $output; if ($component_help) { @@ -1263,8 +1267,10 @@ sub domain_select { } &Apache::lonnet::all_domains(); if ($multiple) { $domains{''}=&mt('Any domain'); + $domains{'select_form_order'} = [sort {lc($a) cmp lc($b) } (keys(%domains))]; return &multiple_select_form($name,$value,4,\%domains); } else { + $domains{'select_form_order'} = [sort {lc($a) cmp lc($b) } (keys(%domains))]; return &select_form($name,$value,%domains); } } @@ -1430,7 +1436,7 @@ selected"); #------------------------------------------- sub select_dom_form { my ($defdom,$name,$includeempty) = @_; - my @domains = sort(&Apache::lonnet::all_domains()); + my @domains = sort {lc($a) cmp lc($b)} (&Apache::lonnet::all_domains()); if ($includeempty) { @domains=('',@domains); } my $selectdomain = " field of type hidden to + preserve the value + - a url - in which case the return value is the url with + the neccesary cgi args added to preserve the + inhibitmenu state + - a ref to a url - no return value, but the string is + updated to include the neccessary cgi + args to preserve the inhibitmenu state + +=cut + +sub inhibit_menu_check { + my ($arg) = @_; + &get_unprocessed_cgi($ENV{'QUERY_STRING'}, ['inhibitmenu']); + if ($arg eq 'input') { + if ($env{'form.inhibitmenu'}) { + return ''; + } else { + return + } + } + if ($env{'form.inhibitmenu'}) { + if (ref($arg)) { + $$arg .= '?inhibitmenu='.$env{'form.inhibitmenu'}; + } elsif ($arg eq '') { + $arg .= 'inhibitmenu='.$env{'form.inhibitmenu'}; + } else { + $arg .= '?inhibitmenu='.$env{'form.inhibitmenu'}; + } + } + if (!ref($arg)) { + return $arg; + } +} + ############################################### =pod +=back + +=head1 User Information Routines + +=over 4 + =item * &get_users_function() Used by &bodytag to determine the current users primary role. @@ -5498,8 +5532,229 @@ sub get_secgrprole_info { return (\@sections,\@groups,$allroles,$rolehash,$accesshash); } +sub user_picker { + my ($dom,$srch,$forcenewuser) = @_; + my $currdom = $dom; + my %curr_selected = ( + srchin => 'dom', + srchby => 'uname', + ); + my $srchterm; + if (ref($srch) eq 'HASH') { + if ($srch->{'srchby'} ne '') { + $curr_selected{'srchby'} = $srch->{'srchby'}; + } + if ($srch->{'srchin'} ne '') { + $curr_selected{'srchin'} = $srch->{'srchin'}; + } + if ($srch->{'srchtype'} ne '') { + $curr_selected{'srchtype'} = $srch->{'srchtype'}; + } + if ($srch->{'srchdomain'} ne '') { + $currdom = $srch->{'srchdomain'}; + } + $srchterm = $srch->{'srchterm'}; + } + + my %lt=&Apache::lonlocal::texthash( + 'usr' => 'Search for', + 'or' => 'or', + 'in' => 'in', + 'doma' => 'domain', + 'uname' => 'username', + 'lastname' => 'last name', + 'lastfirst' => 'last name, first name', + 'crs' => 'this course', + 'dom' => 'this domain', + 'alc' => 'all LON-CAPA', + 'instd' => 'institutional directory', + 'exact' => 'as exact match to', + 'contains' => 'contained in', + ); + my $domform = &select_dom_form($currdom,'srchdomain',1); + + my $srchinsel = ' \n"; + + my $srchbysel = ' \n"; + + my $srchtypesel = ' \n"; + + my ($newuserscript,$newuservalidate); + + if ($forcenewuser) { + $newuserscript = <<"ENDSCRIPT"; + +function setSearch() { + var createnew = 0; + for (var i=0; i +function validateEntry() { + $newuservalidate + var checkok = 1; + var srchin = document.crtuser.srchin.options[document.crtuser.srchin.selectedIndex].value; + var srchtype = document.crtuser.srchtype.options[document.crtuser.srchtype.selectedIndex].value; + var srchby = document.crtuser.srchby.options[document.crtuser.srchby.selectedIndex].value; + var srchdomain = document.crtuser.srchdomain.options[document.crtuser.srchdomain.selectedIndex].value; + var srchterm = document.crtuser.srchterm.value; + var msg = ""; + + if (srchterm == "") { + checkok = 0; + msg += "You must include some text to search for.\\n"; + } + + if (srchtype== 'contains') { + if (srchterm.length < 3) { + checkok = 0; + msg += "The text you are searching for must contain at least three characters when using a 'contained in' type search.\\n"; + } + } + if (srchin == 'instd') { + if (srchdomain == '') { + checkok = 0; + msg += "You must choose a domain when using an institutional directory search.\\n"; + } + } + if (srchin == 'dom') { + if (srchdomain == '') { + checkok = 0; + msg += "You must choose a domain when using a domain search.\\n"; + } + } + if (srchby == 'lastfirst') { + if (srchterm.indexOf(",") == -1) { + checkok = 0; + msg += "When using searching by last,first you must include a comma as separator between last name and first name.\\n"; + } + if (srchterm.indexOf(",") == srchterm.length -1) { + checkok = 0; + msg += "When searching by last,first you must include at least one character in the first name.\\n"; + } + } + if (checkok == 0) { + alert("The following need to be corrected before the search can be run:\\n"+msg); + return; + } + if (checkok == 1) { + document.crtuser.submit(); + } +} + +$newuserscript + + + + + + + + + + + + + + + +
$lt{'usr'}: +$srchtypesel + +$srchbysel +
$lt{'in'}: +$srchinsel +
$lt{'doma'}:$domform
+
+END_BLOCK + if ($forcenewuser) { + $output .= ''.&mt('Make new user if no match found: ').''.&mt('Yes').'  '.&mt('No').'
'; + } + return $output; +} + + + =pod +=back + +=head1 HTTP Helpers + +=over 4 + =item * get_unprocessed_cgi($query,$possible_names) Modify the %env hash to contain unprocessed CGI form parameters held in