--- loncom/interface/loncommon.pm 2010/12/25 16:01:54 1.948.2.17 +++ loncom/interface/loncommon.pm 2011/09/28 15:44:16 1.948.2.30 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common routines # -# $Id: loncommon.pm,v 1.948.2.17 2010/12/25 16:01:54 raeburn Exp $ +# $Id: loncommon.pm,v 1.948.2.30 2011/09/28 15:44:16 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -3570,8 +3570,8 @@ sub format_previous_attempt_value { my @anskeys = sort(keys(%answers)); if (@anskeys == 1) { my $answer = $answers{$anskeys[0]}; - if ($answer =~ m{\Q\0\E}) { - $answer =~ s{\Q\0\E}{, }g; + if ($answer =~ m{\0}) { + $answer =~ s{\0}{,}g; } my $tag_internal_answer_name = 'INTERNAL'; if ($anskeys[0] eq $tag_internal_answer_name) { @@ -3582,8 +3582,8 @@ sub format_previous_attempt_value { } else { foreach my $ans (@anskeys) { my $answer = $answers{$ans}; - if ($answer =~ m{\Q\0\E}) { - $answer =~ s{\Q\0\E}{, }g; + if ($answer =~ m{\0}) { + $answer =~ s{\0}{,}g; } $value .= $ans.'='.$answer.'
';; } @@ -4282,8 +4282,7 @@ sub get_domainconf { if (ref($domconfig{'login'}{$key}) eq 'HASH') { if ($key eq 'loginvia') { if (ref($domconfig{'login'}{'loginvia'}) eq 'HASH') { - my @ids = &Apache::lonnet::current_machine_ids(); - foreach my $hostname (@ids) { + foreach my $hostname (keys(%{$domconfig{'login'}{'loginvia'}})) { if (ref($domconfig{'login'}{'loginvia'}{$hostname}) eq 'HASH') { if ($domconfig{'login'}{'loginvia'}{$hostname}{'server'}) { my $server = $domconfig{'login'}{'loginvia'}{$hostname}{'server'}; @@ -4292,7 +4291,7 @@ sub get_domainconf { $designhash{$udom.'.login.loginvia_'.$hostname} = $server.':'.$domconfig{'login'}{'loginvia'}{$hostname}{'custompath'}; } else { - $designhash{$udom.'.login.loginvia_'.$hostname} = $server.':'.$domconfig{'login'}{'loginvia'}{$hostname}{'serverpath'}; + $designhash{$udom.'.login.loginvia_'.$hostname} = $server.':'.$domconfig{'login'}{'loginvia'}{$hostname}{'serverpath'}; } if ($domconfig{'login'}{'loginvia'}{$hostname}{'exempt'}) { $designhash{$udom.'.login.loginvia_exempt_'.$hostname} = $domconfig{'login'}{'loginvia'}{$hostname}{'exempt'}; @@ -4496,7 +4495,7 @@ Returns: HTML div with $content sub head_subbox { my ($content)=@_; my $output = - '
' + '
' .$content .'
' } @@ -4689,11 +4688,11 @@ sub bodytag { $role = '('.$role.')' if $role; &get_unprocessed_cgi($ENV{'QUERY_STRING'}, ['inhibitmenu']); - if ($env{'environment.remote'} eq 'off') { + if ($env{'environment.remote'} ne 'on') { # No Remote if ($no_nav_bar || $env{'form.inhibitmenu'} eq 'yes') { - return $bodytag; - } + return $bodytag; + } if ($env{'request.state'} eq 'construct') { $forcereg=1; } @@ -4711,6 +4710,10 @@ sub bodytag { $realm $dc_info
|; return $bodytag; } + if (($env{'request.noversionuri'} =~ m{^/adm/navmaps}) && + ($env{'environment.remotenavmap'} eq 'on')) { + return $bodytag; + } unless ($env{'request.symb'} =~ m/\.page___\d+___/) { $bodytag .= qq|
$name $role
|; @@ -4765,10 +4768,13 @@ sub bodytag { $dc_info = qq|($dc_info)|; } - $bodytag .= qq|
$name $role
-
    -
  1. $menu
  2. -
$realm $dc_info
| unless $env{'form.inhibitmenu'}; + unless ($env{'form.inhibitmenu'}) { + $bodytag .= qq|
$name $role
+
    +
  1. $menu
  2. +
$realm $dc_info
|; + } + return(< @@ -5153,6 +5159,7 @@ td.LC_table_cell_checkbox { overflow: hidden; margin: 0; padding: 0; + text-align: left; } /* Preliminary fix to hide breadcrumbs inside remote control window */ @@ -5160,12 +5167,13 @@ td.LC_table_cell_checkbox { display:none; } -#LC_head_subbox { +.LC_head_subbox { clear:both; background: #F8F8F8; /* $sidebg; */ border: 1px solid $sidebg; margin: 0 0 10px 0; padding: 3px; + text-align: left; } .LC_fontsize_medium { @@ -5188,6 +5196,7 @@ td.LC_table_cell_checkbox { li.LC_menubuttons_inline_text img,a { cursor:pointer; + text-decoration: none; } .LC_menubuttons_link { @@ -6143,6 +6152,7 @@ fieldset > legend { #LC_nav_bar { float: left; + background-color: $pgbg_or_bgcolor; margin: 0 0 2px 0; } @@ -6151,6 +6161,7 @@ fieldset > legend { padding: 0; font-weight: bold; text-align: center; + background-color: $pgbg_or_bgcolor; } #LC_nav_bar em { @@ -6166,9 +6177,10 @@ fieldset > legend { ol.LC_primary_menu { float: right; margin: 0; + background-color: $pgbg_or_bgcolor; } -span.LC_new_message{ +ol.LC_primary_menu a.LC_new_message { font-weight:bold; color: darkred; } @@ -6225,6 +6237,7 @@ ul#LC_secondary_menu { padding: 0; margin: 0; width: 100%; + text-align: left; } ul#LC_secondary_menu li { @@ -7816,7 +7829,7 @@ sub get_secgrprole_info { } sub user_picker { - my ($dom,$srch,$forcenewuser,$caller,$cancreate,$usertype) = @_; + my ($dom,$srch,$forcenewuser,$caller,$cancreate,$usertype,$context) = @_; my $currdom = $dom; my %curr_selected = ( srchin => 'dom', @@ -7907,10 +7920,15 @@ sub user_picker { $srchtypesel .= "\n \n"; my ($newuserscript,$new_user_create); - + my $context_dom = $env{'request.role.domain'}; + if ($context eq 'requestcrs') { + if ($env{'form.coursedom'} ne '') { + $context_dom = $env{'form.coursedom'}; + } + } if ($forcenewuser) { if (ref($srch) eq 'HASH') { - if ($srch->{'srchby'} eq 'uname' && $srch->{'srchtype'} eq 'exact' && $srch->{'srchin'} eq 'dom' && $srch->{'srchdomain'} eq $env{'request.role.domain'}) { + if ($srch->{'srchby'} eq 'uname' && $srch->{'srchtype'} eq 'exact' && $srch->{'srchin'} eq 'dom' && $srch->{'srchdomain'} eq $context_dom) { if ($cancreate) { $new_user_create = '

&"').'" onclick="javascript:setSearch(\'1\','.$caller.');" />

'; } else { @@ -7949,7 +7967,7 @@ function setSearch(createnew,callingForm } } for (var i=0; i'; } @@ -9008,7 +9027,7 @@ sub modify_html_refs { if ($allfiles{$ref}) { my $newname = $orig; my ($attrib_regexp,$codebase); - my $attrib_regexp = &unescape($env{'form.embedded_attrib_'.$i}); + $attrib_regexp = &unescape($env{'form.embedded_attrib_'.$i}); if ($attrib_regexp =~ /:/) { $attrib_regexp =~ s/\:/|/g; } @@ -9017,7 +9036,7 @@ sub modify_html_refs { $count += $numchg; } if ($env{'form.embedded_codebase_'.$i} ne '') { - my $codebase = &unescape($env{'form.embedded_codebase_'.$i}); + $codebase = &unescape($env{'form.embedded_codebase_'.$i}); my $numchg = ($content =~ s/(codebase\s*=\s*["']?)\Q$codebase\E(["']?)/$1.$2/i); #' stupid emacs $codebasecount ++; } @@ -9086,7 +9105,7 @@ sub check_for_upload { &mt('Unable to upload [_1]. (size = [_2] bytes)', ''.$fname.'', $filesize).'
'. - &mt('Either the file you uploaded was empty, or your web browser was unable to read its contents.').'
'; + &mt('Either the file you attempted to upload was empty, or your web browser was unable to read its contents.').'
'. ''; return ('zero_bytes',$msg); } @@ -9096,6 +9115,11 @@ sub check_for_upload { $getpropath); my $found_file = 0; my $locked_file = 0; + my @lockers; + my $navmap; + if ($env{'request.course.id'}) { + $navmap = Apache::lonnavmaps::navmap->new(); + } foreach my $line (@dir_list) { my ($file_name,$rest)=split(/\&/,$line,2); if ($file_name eq $fname){ @@ -9104,8 +9128,28 @@ sub check_for_upload { $file_name = $group.$file_name; } $found_file = 1; - if (&Apache::lonnet::is_locked($file_name,$udom,$uname) eq 'true') { - $locked_file = 1; + if (&Apache::lonnet::is_locked($file_name,$udom,$uname,\@lockers) eq 'true') { + foreach my $lock (@lockers) { + if (ref($lock) eq 'ARRAY') { + my ($symb,$crsid) = @{$lock}; + if ($crsid eq $env{'request.course.id'}) { + if (ref($navmap)) { + my $res = $navmap->getBySymb($symb); + foreach my $part (@{$res->parts()}) { + my ($slot_status,$slot_time,$slot_name)=$res->check_for_slot($part); + unless (($slot_status == $res->RESERVED) || + ($slot_status == $res->RESERVED_LOCATION)) { + $locked_file = 1; + } + } + } else { + $locked_file = 1; + } + } else { + $locked_file = 1; + } + } + } } else { my @info = split(/\&/,$rest); my $currsize = $info[6]/1000;