--- loncom/interface/loncommon.pm 2016/11/29 03:01:04 1.1267 +++ loncom/interface/loncommon.pm 2025/03/25 01:02:59 1.1476 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common routines # -# $Id: loncommon.pm,v 1.1267 2016/11/29 03:01:04 raeburn Exp $ +# $Id: loncommon.pm,v 1.1476 2025/03/25 01:02:59 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -61,7 +61,7 @@ use POSIX qw(strftime mktime); use Apache::lonmenu(); use Apache::lonenc(); use Apache::lonlocal; -use Apache::lonnet(); +use Apache::lonnavmaps(); use HTML::Entities; use Apache::lonhtmlcommon(); use Apache::loncoursedata(); @@ -71,6 +71,10 @@ use Apache::lonuserutils(); use Apache::lonuserstate(); use Apache::courseclassifier(); use LONCAPA qw(:DEFAULT :match); +use LONCAPA::ltiutils; +use LONCAPA::LWPReq; +use LONCAPA::map(); +use HTTP::Request; use DateTime::TimeZone; use DateTime::Locale; use Encode(); @@ -78,11 +82,14 @@ use Text::Aspell; use Authen::Captcha; use Captcha::reCAPTCHA; use JSON::DWIW; -use LWP::UserAgent; use Crypt::DES; use DynaLoader; # for Crypt::DES version use MIME::Lite; use MIME::Types; +use File::Copy(); +use File::Path(); +use String::CRC32(); +use Short::URL(); # ---------------------------------------------- Designs use vars qw(%defaultdesign); @@ -198,7 +205,7 @@ BEGIN { { my $langtabfile = $Apache::lonnet::perlvar{'lonTabDir'}. '/language.tab'; - if ( open(my $fh,"<$langtabfile") ) { + if ( open(my $fh,'<',$langtabfile) ) { while (my $line = <$fh>) { next if ($line=~/^\#/); chomp($line); @@ -220,7 +227,7 @@ BEGIN { { my $copyrightfile = $Apache::lonnet::perlvar{'lonIncludes'}. '/copyright.tab'; - if ( open (my $fh,"<$copyrightfile") ) { + if ( open (my $fh,'<',$copyrightfile) ) { while (my $line = <$fh>) { next if ($line=~/^\#/); chomp($line); @@ -234,7 +241,7 @@ BEGIN { { my $sourcecopyrightfile = $Apache::lonnet::perlvar{'lonIncludes'}. '/source_copyright.tab'; - if ( open (my $fh,"<$sourcecopyrightfile") ) { + if ( open (my $fh,'<',$sourcecopyrightfile) ) { while (my $line = <$fh>) { next if ($line =~ /^\#/); chomp($line); @@ -248,7 +255,7 @@ BEGIN { # -------------------------------------------------------------- default domain designs my $designdir=$Apache::lonnet::perlvar{'lonTabDir'}.'/lonDomColors'; my $designfile = $designdir.'/default.tab'; - if ( open (my $fh,"<$designfile") ) { + if ( open (my $fh,'<',$designfile) ) { while (my $line = <$fh>) { next if ($line =~ /^\#/); chomp($line); @@ -262,7 +269,7 @@ BEGIN { { my $categoryfile = $Apache::lonnet::perlvar{'lonTabDir'}. '/filecategories.tab'; - if ( open (my $fh,"<$categoryfile") ) { + if ( open (my $fh,'<',$categoryfile) ) { while (my $line = <$fh>) { next if ($line =~ /^\#/); chomp($line); @@ -277,7 +284,7 @@ BEGIN { { my $typesfile = $Apache::lonnet::perlvar{'lonTabDir'}. '/filetypes.tab'; - if ( open (my $fh,"<$typesfile") ) { + if ( open (my $fh,'<',$typesfile) ) { while (my $line = <$fh>) { next if ($line =~ /^\#/); chomp($line); @@ -430,7 +437,7 @@ sub studentbrowser_javascript { + +ENDJS + +} + +=pod + +=item * &iframe_wrapper_resizejs() + +emits javascript used to handle resizing for a page containing +an iframe, to ensure that the iframe does not obscure any +standard LON-CAPA menu items. + +=back + +=cut + +# +# jQuery to use when iframe is in use and a page resize occurs. +# This script will ensure that the iframe does not obscure any +# standard LON-CAPA inline menus (primary, secondary, and/or +# breadcrumbs and Functions menus. Expects javascript from +# &iframe_wrapper_headjs() to be in head portion of the web page, +# e.g., by inclusion in second arg passed to &start_page(). +# + +sub iframe_wrapper_resizejs { + my $offset = 5; + &get_unprocessed_cgi($ENV{'QUERY_STRING'},['inhibitmenu']); + if (($env{'form.inhibitmenu'} eq 'yes') || ($env{'form.only_body'})) { + $offset = 0; + } + return &Apache::lonhtmlcommon::scripttag(< +ENDJS + } $endbodytag= - "". + "$endbodyjs". &mt('Continue').''. $endbodytag; } } + if ((ref($args) eq 'HASH') && ($args->{'dashjs'})) { + $endbodytag = &Apache::lonhtmlcommon::dash_to_minus_js().$endbodytag; + } return $endbodytag; } @@ -6072,7 +7278,6 @@ Inputs: (all optional) sub standard_css { my ($function,$domain,$bgcolor) = @_; $function = &get_users_function() if (!$function); - my $img = &designparm($function.'.img', $domain); my $tabbg = &designparm($function.'.tabbg', $domain); my $font = &designparm($function.'.font', $domain); my $fontmenu = &designparm($function.'.fontmenu', $domain); @@ -6125,6 +7330,7 @@ body { line-height:130%; font-size:0.83em; color:$font; + background-color: $pgbg_or_bgcolor; } a:focus, @@ -6136,14 +7342,63 @@ form, .inline { display: inline; } +.LC_landmark { + margin: 0; + padding: 0; + border: none; +} + +.LC_visually_hidden:not(:focus):not(:active) { + clip-path: inset(50%); + height: 1px; + overflow: hidden; + position: absolute; + white-space: nowrap; + width: 1px; + display: inline; +} + +.LC_heading_2 { + font-size: 1.17em; +} + +.LC_heading_3 { + font-size: 1.0em; +} + +h1.LC_search_results { + font-size: 1.0em; + font-weight: normal; +} + +.LC_menus_content.shown{ + display: block; +} + +.LC_menus_content.hidden { + display: none; +} + .LC_right { text-align:right; } +.LC_left { + text-align:left; +} + +.LC_center { + text-align:center; +} + .LC_middle { vertical-align:middle; } +.LC_bottom { + vertical-align:bottom; +} + .LC_floatleft { float: left; } @@ -6156,6 +7411,12 @@ form, .inline { width:400px; } +#LC_collapsible_separator { + border: 1px solid black; + width: 99.9%; + height: 0px; +} + .LC_iframecontainer { width: 98%; margin: 0; @@ -6223,6 +7484,14 @@ div.LC_confirm_box .LC_success img { height: auto; } +div.LC_minheight { + min-height: 24px; + border: 0; + margin: 4px 0 0 0; + padding: 0; + vertical-align: middle; +} + .LC_textsize_mobile { \@media only screen and (max-device-width: 480px) { -webkit-text-size-adjust:100%; -moz-text-size-adjust:100%; -ms-text-size-adjust:100%; @@ -6277,9 +7546,10 @@ div.LC_confirm_box .LC_success img { padding: 4px; } -table.LC_pastsubmission { +.LC_pastsubmission { border: 1px solid black; margin: 2px; + padding: 2px; } table#LC_menubuttons { @@ -6415,6 +7685,10 @@ li.LC_menubuttons_inline_text img { text-decoration: none; } +.LC_menubuttons_link img { + vertical-align: middle; +} + .LC_menubuttons_category { color: $font; background: $pgbg; @@ -6422,7 +7696,9 @@ li.LC_menubuttons_inline_text img { font-weight: bold; } -td.LC_menubuttons_text { +.LC_menu_text { + clear: left; + text-align: left; color: $font; } @@ -6430,6 +7706,11 @@ td.LC_menubuttons_text { background: $tabbg; } +td.LC_zero_height { + line-height: 0; + cellpadding: 0; +} + table.LC_data_table { border: 1px solid #000000; border-collapse: separate; @@ -6509,11 +7790,13 @@ table.LC_data_table tr td.LC_leftcol_hea } table.LC_data_table tr.LC_empty_row td, -table.LC_nested tr.LC_empty_row td { +table.LC_nested tr.LC_empty_row td, +table.LC_nested tr.LC_empty_row th { font-weight: bold; font-style: italic; text-align: center; padding: 8px; + border: 0; } table.LC_data_table tr.LC_empty_row td, @@ -6521,15 +7804,19 @@ table.LC_data_table tr.LC_footer_row td background-color: $sidebg; } +table.LC_nested tr.LC_empty_row th, table.LC_nested tr.LC_empty_row td { + padding: 4ex; background-color: #FFFFFF; } table.LC_caption { } -table.LC_nested tr.LC_empty_row td { - padding: 4ex +caption.LC_caption_prefs { + font-weight: normal; + text-align: left; + padding-bottom: 0.8em; } table.LC_nested_outer tr th { @@ -6548,14 +7835,17 @@ table.LC_nested_outer tr td.LC_subheader text-align: right; } -table.LC_nested tr.LC_info_row td { +table.LC_nested tr.LC_info_row td, +table.LC_nested tr.LC_info_row th { background-color: #CCCCCC; font-weight: bold; font-size: small; text-align: center; + border: 0; } table.LC_nested tr.LC_info_row td.LC_left_item, +table.LC_nested tr.LC_info_row th.LC_left_item, table.LC_nested_outer tr th.LC_left_item { text-align: left; } @@ -6698,6 +7988,10 @@ table.LC_data_table tr > td.LC_roles_sel border-right: 8px solid #11CC55; } +table.LC_data_table tr.LC_prefs_row { + line-height: 250%; +} + span.LC_current_location { font-size:larger; background: $pgbg; @@ -6751,6 +8045,12 @@ td.LC_parm_overview_restrictions { border-collapse: collapse; } +span.LC_parm_recursive, +td.LC_parm_recursive { + font-weight: bold; + font-size: smaller; +} + table.LC_parm_overview_restrictions td { border-width: 1px 4px 1px 4px; border-style: solid; @@ -6765,39 +8065,68 @@ table.LC_parm_overview_restrictions th { border-color: $pgbg; } -table#LC_helpmenu { - border: none; - height: 55px; - border-spacing: 0; +h1.LC_helpmenu { + display: inline; + font-size: 100%; + font-weight: normal; + line-height: 1em; + margin: 0; + padding: 0; + border: 0; } -table#LC_helpmenu fieldset legend { - font-size: larger; +.LC_helpdesk_headbox { + border: 2px groove threedface; + padding: 1em; } -table#LC_helpmenu_links { - width: 100%; - border: 1px solid black; +h1.LC_helpdesk_legend { + float: left; + margin: -1.7em 0 0; + padding: 0 .5em; background: $pgbg; + font-size: 1em; + font-weight: bold; +} + +h1.LC_helpdesk_title { + display: inline; + font-size: 1em; + line-height: 2.5em; + margin: 0; padding: 0; - border-spacing: 1px; + vertical-align: bottom; } -table#LC_helpmenu_links tr td { - padding: 1px; +.LC_helpdesk_links { + border: 1px solid black; + padding: 3px; background: $tabbg; text-align: center; font-weight: bold; + display: inline; + margin-right: -6px; +} + +.LC_helpdesk_img, +.LC_helpdesk_text { + padding: 0; + margin: 0; + border: 0; + display: inline; } -table#LC_helpmenu_links a:link, -table#LC_helpmenu_links a:visited, -table#LC_helpmenu_links a:active { +.LC_helpdesk_img a:link, +.LC_helpdesk_img a:visited, +.LC_helpdesk_img a:active, +.LC_helpdesk_text a:link, +.LC_helpdesk_text a:visited, +.LC_helpdesk_text a:active { text-decoration: none; color: $font; } -table#LC_helpmenu_links a:hover { +div.LC_helpdesk_text a:hover { text-decoration: underline; color: $vlink; } @@ -6824,7 +8153,7 @@ table.LC_pick_box { border-spacing: 1px; } -table.LC_pick_box td.LC_pick_box_title { +table.LC_pick_box th.LC_pick_box_title { background: $sidebg; font-weight: bold; text-align: left; @@ -6865,6 +8194,13 @@ table.LC_pick_box td.LC_oddrow_value { background-color: $data_table_light; } +td.LC_log_filter, +th.LC_log_filter { + vertical-align: top; + text-align: left; + padding: 0 4px; +} + span.LC_helpform_receipt_cat { font-weight: bold; } @@ -7020,12 +8356,51 @@ table.LC_prior_tries td { padding: 6px; } -.LC_answer_unknown { +.LC_answer_unknown, +.LC_answer_warning { background: orange; color: black; padding: 6px; } +span.LC_prob_status { + margin: 5px 0 0 0; + padding: 0 5px 0 0; + vertical-align: middle; +} + +div.LC_prob_status_outer { + display: inline-block; + margin: -5px 0 0 0; + padding: 0; +} + +div.LC_prob_status_inner { + display: inline-block; + margin: 0 5px 0 0; + padding: 5px; +} + +caption.LC_filesub_status { + text-align: left; + font-weight: bold; +} + +.LC_mail_actions { + float: left; + padding: 0; + margin: 6px; +} + +.LC_vertical_line { + width: 1px; + background-color: black; + height: 4em; + float: left; + margin: 0; + padding: 0; +} + span.LC_prior_numerical, span.LC_prior_string, span.LC_prior_custom, @@ -7102,6 +8477,12 @@ table.LC_data_table tr > td.LC_docs_entr color: #990000; } +.LC_docs_alias { + color: #440055; +} + +.LC_domprefs_email, +.LC_docs_alias_name, .LC_docs_reinit_warn, .LC_docs_ext_edit { font-size: x-small; @@ -7173,6 +8554,10 @@ div.LC_grade_show_user div.LC_Box { margin-right: 50px; } +div.LC_grade_show_user div.LC_Box table tr th { + font-weight: normal; +} + div.LC_grade_submissions, div.LC_grade_message_center, div.LC_grade_info_links { @@ -7203,6 +8588,12 @@ table.LC_scantron_action tr th { font-style:normal; } +div.LC_edit_problem_daxe_header { + padding: 3px; + background: $tabbg; + z-index: 100; +} + .LC_edit_problem_header, div.LC_edit_problem_footer { font-weight: normal; @@ -7268,8 +8659,9 @@ img.stift { vertical-align: middle; } -table td.LC_mainmenu_col_fieldset { - vertical-align: top; +div.LC_mainmenu { + margin: 3px 2px 2px 1px; + float: left; } div.LC_createcourse { @@ -7317,6 +8709,7 @@ h6 { border-bottom:solid 1px $lg_border_color; } +.LC_MainMenu_Box > .LC_hcell, .LC_Box > .LC_hcell { margin: 0 -10px 10px -10px; } @@ -7350,6 +8743,26 @@ fieldset { /* overflow: hidden; */ } +fieldset#LC_selectuser { + margin: -1px 0 0 0; + padding: 0; + border: 0; +} + +fieldset.LC_delete_slot { + display:inline; + margin: 0 4px 4px; + padding: 4px; +} + +fieldset.LC_delete_slot > legend { + font-weight: normal; +} + +p.LC_medium_line { + line-height: 0.85em; +} + article.geogebraweb div { margin: 0; } @@ -7749,6 +9162,11 @@ ol#LC_PathBreadcrumbs li a { padding: 0 0 10px 10px; } +.LC_MainMenu_Box { + border: solid 1px $lg_border_color; + padding: 0 10px 0 10px; +} + .LC_AboutMe_Image { float:left; margin-right:10px; @@ -7770,6 +9188,7 @@ dl.LC_ListStyleClean dd { .LC_ListStyleClean, .LC_ListStyleSimple, .LC_ListStyleNormal, +.LC_ListStyleMainMenu, .LC_ListStyleSpecial { /* display:block; */ list-style-position: inside; @@ -7807,6 +9226,12 @@ dl.LC_ListStyleClean dd { margin-bottom: 4px; } +.LC_ListStyleMainMenu li { + margin: 0; + padding: 2px 5px 2px 10px; + clear: both; +} + table.LC_SimpleTable { margin:5px; border:solid 1px $lg_border_color; @@ -7893,6 +9318,10 @@ a#LC_content_toolbar_edittoplevel { background-image:url(/res/adm/pages/edittoplevel.gif); } +a#LC_content_toolbar_printout { + background-image:url(/res/adm/pages/printout.gif); +} + ul#LC_toolbar li a:hover { background-position: bottom center; } @@ -7901,7 +9330,7 @@ ul#LC_toolbar { padding: 0; margin: 2px; list-style:none; - position:relative; + display:inline; background-color:white; overflow: auto; } @@ -7929,6 +9358,13 @@ a.LC_toolbarItem { background-color:transparent; } +.LC_navtools { + display: inline-block; + padding: 0; + margin: 2px; + vertical-align: middle; +} + ul.LC_funclist { margin: 0; padding: 0.5em 1em 0.5em 0; @@ -8010,16 +9446,62 @@ ul.LC_funclist li { cursor:pointer; } +.LCisDisabled { + cursor: not-allowed; + opacity: 0.5; +} + +a[aria-disabled="true"] { + color: currentColor; + display: inline-block; /* For IE11/ MS Edge bug */ + pointer-events: none; + text-decoration: none; +} + +pre.LC_wordwrap { + white-space: pre-wrap; + white-space: -moz-pre-wrap; + white-space: -pre-wrap; + white-space: -o-pre-wrap; + word-wrap: break-word; +} + /* styles used for response display */ -div.LC_radiofoil, div.LC_rankfoil { +div.LC_radiofoil, div.LC_rankfoil, div.LC_optionfoil, div.LC_matchfoil, div.LC_login_links { margin: .5em 0em .5em 0em; } table.LC_itemgroup { margin-top: 1em; } +table.LC_itemgroup tr th { + font-weight: normal; +} + +fieldset.LC_webbubbles { + margin: 2px 0 0 0; + padding: 0; + border: 0; +} + +ul.LC_webbubbles { + list-style: none; + padding: 0; + margin: 0; + text-align: left; + float: left; +} + +ul.LC_webbubbles li { + line-height: 1.8em; + border: 1px solid black; + padding: 0 2px 0 5px; + margin: 0 0 0 -1px; + float: left; +} + /* styles used by TTH when "Default set of options to pass to tth/m when converting TeX" in course settings has been set @@ -8122,6 +9604,39 @@ section.role-warning>h1:before { content:url('/adm/daxe/images/section_icons/warning.png'); } +#LC_minitab_header { + float:left; + width:100%; + background:#DAE0D2 url("/res/adm/pages/minitabmenu_bg.gif") repeat-x bottom; + font-size:93%; + line-height:normal; + margin: 0.5em 0 0.5em 0; +} +#LC_minitab_header ul { + margin:0; + padding:10px 10px 0; + list-style:none; +} +#LC_minitab_header li { + float:left; + background:url("/res/adm/pages/minitabmenu_left.gif") no-repeat left top; + margin:0; + padding:0 0 0 9px; +} +#LC_minitab_header a { + display:block; + background:url("/res/adm/pages/minitabmenu_right.gif") no-repeat right top; + padding:5px 15px 4px 6px; +} +#LC_minitab_header #LC_current_minitab { + background-image:url("/res/adm/pages/minitabmenu_left_on.gif"); +} +#LC_minitab_header #LC_current_minitab a { + background-image:url("/res/adm/pages/minitabmenu_right_on.gif"); + padding-bottom:5px; +} + + END } @@ -8142,7 +9657,13 @@ Inputs: $title - optional title for the 3- whether the side effect should occur (side effect of setting $env{'internal.head.redirect'} to the url - redirected too) + redirected to) + 4- whether the redirect target should be + the opener of the current (pop-up) + window (side effect of setting + $env{'internal.head.to_opener'} to + 1, if true. + 5- whether encrypt check should be skipped domain -> force to color decorate a page for a specific domain function -> force usage of a specific rolish color scheme @@ -8176,7 +9697,7 @@ sub headtag { $inhibitprint = &print_suppression(); } - if (!$args->{'frameset'}) { + if (!$args->{'frameset'} && !$args->{'switchserver'}) { $result .= &Apache::lonhtmlcommon::htmlareaheaders(); } if ($args->{'force_register'} && $env{'request.noversionuri'} !~ m{^/res/adm/pages/}) { @@ -8184,7 +9705,8 @@ sub headtag { } if (!$args->{'no_nav_bar'} && !$args->{'only_body'} - && !$args->{'frameset'}) { + && !$args->{'frameset'} + && !$args->{'switchserver'}) { $result .= &help_menu_js($httphost); $result.=&modal_window(); $result.=&togglebox_script(); @@ -8205,15 +9727,45 @@ sub headtag { } } if (ref($args->{'redirect'})) { - my ($time,$url,$inhibit_continue) = @{$args->{'redirect'}}; - $url = &Apache::lonenc::check_encrypt($url); + my ($time,$url,$inhibit_continue,$to_opener,$skip_enc_check) = @{$args->{'redirect'}}; + if (!$skip_enc_check) { + $url = &Apache::lonenc::check_encrypt($url); + } if (!$inhibit_continue) { $env{'internal.head.redirect'} = $url; } - $result.=< +ADDMETA + if ($to_opener) { + $env{'internal.head.to_opener'} = 1; + my $dest = &js_escape($url); + my $timeout = int($time * 1000); + $result .=<<"ENDJS"; + +ENDJS + } else { + $result.=<<"ADDMETA"; ADDMETA + } } else { unless (($args->{'frameset'}) || ($args->{'js_ready'}) || ($args->{'only_body'}) || ($args->{'no_nav_bar'})) { my $requrl = $env{'request.uri'}; @@ -8227,43 +9779,99 @@ ADDMETA my $dom_in_use = $Apache::lonnet::perlvar{'lonDefDomain'}; unless (&Apache::lonnet::allowed('mau',$dom_in_use)) { my %domdefs = &Apache::lonnet::get_domain_defaults($dom_in_use); + my $lonhost = $Apache::lonnet::perlvar{'lonHostID'}; + my ($offload,$offloadoth); if (ref($domdefs{'offloadnow'}) eq 'HASH') { - my $lonhost = $Apache::lonnet::perlvar{'lonHostID'}; if ($domdefs{'offloadnow'}{$lonhost}) { - my $newserver = &Apache::lonnet::spareserver(30000,undef,1,$dom_in_use); - if (($newserver) && ($newserver ne $lonhost)) { - my $numsec = 5; - my $timeout = $numsec * 1000; - my ($newurl,$locknum,%locks,$msg); - if ($env{'request.role.adv'}) { - ($locknum,%locks) = &Apache::lonnet::get_locks(); + $offload = 1; + if (($env{'user.domain'} ne '') && ($env{'user.domain'} ne $dom_in_use) && + (!(($env{'user.name'} eq 'public') && ($env{'user.domain'} eq 'public')))) { + unless (&Apache::lonnet::shared_institution($env{'user.domain'})) { + $offloadoth = 1; + $dom_in_use = $env{'user.domain'}; } - my $disable_submit = 0; - if ($requrl =~ /$LONCAPA::assess_re/) { - $disable_submit = 1; + } + } + } + unless ($offload) { + if (ref($domdefs{'offloadoth'}) eq 'HASH') { + if ($domdefs{'offloadoth'}{$lonhost}) { + if (($env{'user.domain'} ne '') && ($env{'user.domain'} ne $dom_in_use) && + (!(($env{'user.name'} eq 'public') && ($env{'user.domain'} eq 'public')))) { + unless (&Apache::lonnet::shared_institution($env{'user.domain'})) { + $offload = 1; + $offloadoth = 1; + $dom_in_use = $env{'user.domain'}; + } } - if ($locknum) { - my @lockinfo = sort(values(%locks)); - $msg = &mt('Once the following tasks are complete: ')."\\n". - join(", ",sort(values(%locks)))."\\n". - &mt('your session will be transferred to a different server, after you click "Roles".'); + } + } + } + if ($offload) { + my $newserver = &Apache::lonnet::spareserver(undef,30000,undef,1,$dom_in_use); + if (($newserver eq '') && ($offloadoth)) { + my @domains = &Apache::lonnet::current_machine_domains(); + if (($dom_in_use ne '') && (!grep(/^\Q$dom_in_use\E$/,@domains))) { + ($newserver) = &Apache::lonnet::choose_server($dom_in_use); + } + } + if (($newserver) && ($newserver ne $lonhost)) { + my $numsec = 5; + my $timeout = $numsec * 1000; + my ($newurl,$locknum,%locks,$msg); + if ($env{'request.role.adv'}) { + ($locknum,%locks) = &Apache::lonnet::get_locks(); + } + my $disable_submit = 0; + if ($requrl =~ /$LONCAPA::assess_re/) { + $disable_submit = 1; + } + if ($locknum) { + my @lockinfo = sort(values(%locks)); + $msg = &mt('Once the following tasks are complete:')." \n". + join(", ",sort(values(%locks)))."\n"; + if (&show_course()) { + $msg .= &mt('your session will be transferred to a different server, after you click "Courses".'); } else { - if (($requrl =~ m{^/res/}) && ($env{'form.submitted'} =~ /^part_/)) { - $msg = &mt('Your LON-CAPA submission has been recorded')."\\n"; - } - $msg .= &mt('Your current LON-CAPA session will be transferred to a different server in [quant,_1,second].',$numsec); - $newurl = '/adm/switchserver?otherserver='.$newserver; - if (($env{'request.role'}) && ($env{'request.role'} ne 'cm')) { - $newurl .= '&role='.$env{'request.role'}; + $msg .= &mt('your session will be transferred to a different server, after you click "Roles".'); + } + } else { + if (($requrl =~ m{^/res/}) && ($env{'form.submitted'} =~ /^part_/)) { + $msg = &mt('Your LON-CAPA submission has been recorded')."\n"; + } + $msg .= &mt('Your current LON-CAPA session will be transferred to a different server in [quant,_1,second].',$numsec); + $newurl = '/adm/switchserver?otherserver='.$newserver; + if (($env{'request.role'}) && ($env{'request.role'} ne 'cm')) { + $newurl .= '&role='.$env{'request.role'}; + } + if ($env{'request.symb'}) { + my $shownsymb = &Apache::lonenc::check_encrypt($env{'request.symb'}); + if ($shownsymb =~ m{^/enc/}) { + my $reqdmajor = 2; + my $reqdminor = 11; + my $reqdsubminor = 3; + my $newserverrev = &Apache::lonnet::get_server_loncaparev('',$newserver); + my $remoterev = &Apache::lonnet::get_server_loncaparev(undef,$newserver); + my ($major,$minor,$subminor) = ($remoterev =~ /^\'?(\d+)\.(\d+)\.(\d+|)[\w.\-]+\'?$/); + if (($major eq '' && $minor eq '') || + (($reqdmajor > $major) || (($reqdmajor == $major) && ($reqdminor > $minor)) || + (($reqdmajor == $major) && ($reqdminor == $minor) && (($subminor eq '') || + ($reqdsubminor > $subminor))))) { + undef($shownsymb); + } } - if ($env{'request.symb'}) { - $newurl .= '&symb='.$env{'request.symb'}; - } else { - $newurl .= '&origurl='.$requrl; + if ($shownsymb) { + &js_escape(\$shownsymb); + $newurl .= '&symb='.$shownsymb; } + } else { + my $shownurl = &Apache::lonenc::check_encrypt($requrl); + &js_escape(\$shownurl); + $newurl .= '&origurl='.$shownurl; } - &js_escape(\$msg); - $result.=< OFFLOAD - } } } } @@ -8295,8 +9902,12 @@ OFFLOAD $title = 'The LearningOnline Network with CAPA'; } if (!$args->{'no_auto_mt_title'}) { $title = &mt($title); } - $result .= '
'.$msg.'
'.&mt('Updated [quant,_1,reference] in [_2].', @@ -12483,6 +14452,18 @@ sub decompress_uploaded_file { sub process_decompression { my ($docudom,$docuname,$file,$destination,$dir_root,$hiddenelem) = @_; + unless (($dir_root eq '/userfiles') && ($destination =~ m{^(docs|supplemental)/(default|\d+)/\d+$})) { + return '
'.&mt('Not extracted.').''. + &mt('Unexpected file path.').'
'.&mt('Not extracted.').''. + &mt('Unexpected course context.').'
'.&mt('Not extracted.').''. + &mt('Filename contained unexpected characters.').'
'; + '
'; if ($switchwarning) { $output .= $switchwarning.''; if (&show_course()) { @@ -16768,7 +19199,7 @@ sub check_release_result { &mt('Switch Server'). ''; } - $output .= '