--- loncom/interface/loncommon.pm 2024/09/07 18:47:20 1.1075.2.161.2.28 +++ loncom/interface/loncommon.pm 2024/07/31 22:14:33 1.1075.2.168 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common routines # -# $Id: loncommon.pm,v 1.1075.2.161.2.28 2024/09/07 18:47:20 raeburn Exp $ +# $Id: loncommon.pm,v 1.1075.2.168 2024/07/31 22:14:33 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -61,7 +61,6 @@ use POSIX qw(strftime mktime); use Apache::lonmenu(); use Apache::lonenc(); use Apache::lonlocal; -use Apache::lonnavmaps(); use HTML::Entities; use Apache::lonhtmlcommon(); use Apache::loncoursedata(); @@ -71,7 +70,6 @@ use Apache::lonuserutils(); use Apache::lonuserstate(); use Apache::courseclassifier(); use LONCAPA qw(:DEFAULT :match); -use LONCAPA::map(); use HTTP::Request; use DateTime::TimeZone; use DateTime::Locale; @@ -84,8 +82,6 @@ use Crypt::DES; use DynaLoader; # for Crypt::DES version use File::Copy(); use File::Path(); -use String::CRC32(); -use Short::URL(); # ---------------------------------------------- Designs use vars qw(%defaultdesign); @@ -431,7 +427,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(< 'document.cu', - kerb_def_dom => 'MSU.EDU', - @_, - ); - my ($lticheck,$result,$authtype,$autharg,$jscall,$disabled); - my ($authnum,%can_assign) = &get_assignable_auth($in{'domain'}); - if ($in{'readonly'}) { - $disabled = ' disabled="disabled"'; - } - if (defined($in{'curr_authtype'})) { - if ($in{'curr_authtype'} eq 'lti') { - if ($can_assign{'lti'}) { - $lticheck = 'checked="checked" '; - if (defined($in{'mode'})) { - if ($in{'mode'} eq 'modifyuser') { - $lticheck = ''; - } - } - } else { - $result = &mt('Currently LTI Authenticated.'); - return $result; - } - } - } else { - if ($authnum == 1) { - $authtype = ''; - } - } - if (!$can_assign{'lti'}) { - return; - } elsif ($authtype eq '') { - if (defined($in{'mode'})) { - if ($in{'mode'} eq 'modifycourse') { - if ($authnum == 1) { - $authtype = ''; - } - } - } - } - $jscall = "javascript:changed_radio('lti',$in{'formname'});"; - if (($authtype eq '') && (($in{'mode'} eq 'modifycourse') || ($in{'curr_authtype'} ne 'lti'))) { - $authtype = ''; - } - $autharg = ''; - if ($authtype) { - $result = &mt('[_1] LTI Authenticated', - ''.$autharg); - } else { - $result = ''.&mt('LTI Authenticated').''. - $autharg; - } - return $result; -} - sub get_assignable_auth { my ($dom) = @_; if ($dom eq '') { @@ -3434,170 +3249,6 @@ sub check_passwd_rules { return $warning; } -sub passwd_validation_js { - my ($currpasswdval,$domain,$context,$id) = @_; - my (%passwdconf,$alertmsg); - if ($context eq 'linkprot') { - my %domconfig = &Apache::lonnet::get_dom('configuration',['ltisec'],$domain); - if (ref($domconfig{'ltisec'}) eq 'HASH') { - if (ref($domconfig{'ltisec'}{'rules'}) eq 'HASH') { - %passwdconf = %{$domconfig{'ltisec'}{'rules'}}; - } - } - if ($id eq 'add') { - $alertmsg = &mt('Secret for added launcher did not satisfy requirement(s):').'\n\n'; - } elsif ($id =~ /^\d+$/) { - my $pos = $id+1; - $alertmsg = &mt('Secret for launcher [_1] did not satisfy requirement(s):','#'.$pos).'\n\n'; - } else { - $alertmsg = &mt('A secret did not satisfy requirement(s):').'\n\n'; - } - } elsif ($context eq 'ltitools') { - my %domconfig = &Apache::lonnet::get_dom('configuration',['toolsec'],$domain); - if (ref($domconfig{'toolsec'}) eq 'HASH') { - if (ref($domconfig{'toolsec'}{'rules'}) eq 'HASH') { - %passwdconf = %{$domconfig{'toolsec'}{'rules'}}; - } - } - if ($id eq 'add') { - $alertmsg = &mt('Secret for added external tool did not satisfy requirement(s):').'\n\n'; - } elsif ($id =~ /^\d+$/) { - my $pos = $id+1; - $alertmsg = &mt('Secret for external tool [_1] did not satisfy requirement(s):','#'.$pos).'\n\n'; - } else { - $alertmsg = &mt('A secret did not satisfy requirement(s):').'\n\n'; - } - } else { - %passwdconf = &Apache::lonnet::get_passwdconf($domain); - $alertmsg = &mt('Initial password did not satisfy requirement(s):').'\n\n'; - } - my ($min,$max,@chars,$numrules,$intargjs,%alert); - $numrules = 0; - $min = $Apache::lonnet::passwdmin; - if (ref($passwdconf{'chars'}) eq 'ARRAY') { - if ($passwdconf{'min'} =~ /^\d+$/) { - if ($passwdconf{'min'} > $min) { - $min = $passwdconf{'min'}; - } - } - if ($passwdconf{'max'} =~ /^\d+$/) { - $max = $passwdconf{'max'}; - $numrules ++; - } - @chars = @{$passwdconf{'chars'}}; - if (@chars) { - $numrules ++; - } - } - if ($min > 0) { - $numrules ++; - } - if (($min > 0) || ($max ne '') || (@chars > 0)) { - if ($min) { - $alert{'min'} = &mt('minimum [quant,_1,character]',$min).'\n'; - } - if ($max) { - $alert{'max'} = &mt('maximum [quant,_1,character]',$max).'\n'; - } - my (@charalerts,@charrules); - if (@chars) { - if (grep(/^uc$/,@chars)) { - push(@charalerts,&mt('contain at least one upper case letter')); - push(@charrules,'uc'); - } - if (grep(/^lc$/,@chars)) { - push(@charalerts,&mt('contain at least one lower case letter')); - push(@charrules,'lc'); - } - if (grep(/^num$/,@chars)) { - push(@charalerts,&mt('contain at least one number')); - push(@charrules,'num'); - } - if (grep(/^spec$/,@chars)) { - push(@charalerts,&mt('contain at least one non-alphanumeric')); - push(@charrules,'spec'); - } - } - $intargjs = qq| var rulesmsg = '';\n|. - qq| var currpwval = $currpasswdval;\n|; - if ($min) { - $intargjs .= qq| - if (currpwval.length < $min) { - rulesmsg += ' - $alert{min}'; - } -|; - } - if ($max) { - $intargjs .= qq| - if (currpwval.length > $max) { - rulesmsg += ' - $alert{max}'; - } -|; - } - if (@chars > 0) { - my $charrulestr = '"'.join('","',@charrules).'"'; - my $charalertstr = '"'.join('","',@charalerts).'"'; - $intargjs .= qq| var brokerules = new Array();\n|. - qq| var charrules = new Array($charrulestr);\n|. - qq| var charalerts = new Array($charalertstr);\n|; - my %rules; - map { $rules{$_} = 1; } @chars; - if ($rules{'uc'}) { - $intargjs .= qq| - var ucRegExp = /[A-Z]/; - if (!ucRegExp.test(currpwval)) { - brokerules.push('uc'); - } -|; - } - if ($rules{'lc'}) { - $intargjs .= qq| - var lcRegExp = /[a-z]/; - if (!lcRegExp.test(currpwval)) { - brokerules.push('lc'); - } -|; - } - if ($rules{'num'}) { - $intargjs .= qq| - var numRegExp = /[0-9]/; - if (!numRegExp.test(currpwval)) { - brokerules.push('num'); - } -|; - } - if ($rules{'spec'}) { - $intargjs .= q| - var specRegExp = /[!"#$%&'()*+,\-.\/:;<=>?@[\\^\]_`{\|}~]/; - if (!specRegExp.test(currpwval)) { - brokerules.push('spec'); - } -|; - } - $intargjs .= qq| - if (brokerules.length > 0) { - for (var i=0; i$linktext}; } +# ----------------------------------------------------------------------------- + sub aboutme_on { my ($uname,$udom)=@_; unless ($uname) { $uname=$env{'user.name'}; } @@ -4040,8 +3693,6 @@ sub devalidate_aboutme_cache { &Apache::lonnet::devalidate_cache_new('aboutme',$id); } -# ----------------------------------------------------------------------------- - sub track_student_link { my ($linktext,$sname,$sdom,$target,$start,$only_body) = @_; my $link ="/adm/trackstudent?"; @@ -4643,15 +4294,9 @@ sub get_previous_attempt { } $prevattempts.= &end_data_table_row().&end_data_table(); } else { - my $msg; - if ($symb =~ /ext\.tool$/) { - $msg = &mt('No grade passed back.'); - } else { - $msg = &mt('Nothing submitted - no attempts.'); - } $prevattempts= &start_data_table().&start_data_table_row(). - ''.$msg.''. + ''.&mt('Nothing submitted - no attempts.').''. &end_data_table_row().&end_data_table(); } } else { @@ -5108,7 +4753,7 @@ sub findallcourses { sub blockcheck { my ($setters,$activity,$clientip,$uname,$udom,$url,$is_course,$symb,$caller) = @_; - unless (($activity eq 'docs') || ($activity eq 'reinit') || ($activity eq 'alert')) { + unless ($activity eq 'docs') { my ($has_evb,$check_ipaccess); my $dom = $env{'user.domain'}; if ($env{'request.course.id'}) { @@ -5215,9 +4860,8 @@ sub blockcheck { # boards, chat or groups, check for blocking in current course only. if (($activity eq 'boards' || $activity eq 'chat' || - $activity eq 'groups' || $activity eq 'printout' || - $activity eq 'search' || $activity eq 'reinit' || - $activity eq 'alert') && ($env{'request.course.id'})) { + $activity eq 'groups' || $activity eq 'printout') && + ($env{'request.course.id'})) { foreach my $key (keys(%live_courses)) { if ($key ne $env{'request.course.id'}) { delete($live_courses{$key}); @@ -5551,10 +5195,6 @@ END_MYBLOCK $text = &mt('Gradebook Blocked'); } elsif ($activity eq 'search') { $text = &mt('Search Blocked'); - } elsif ($activity eq 'alert') { - $text = &mt('Checking Critical Messages Blocked'); - } elsif ($activity eq 'reinit') { - $text = &mt('Checking Course Update Blocked'); } elsif ($activity eq 'about') { $text = &mt('Access to User Information Pages Blocked'); } elsif ($activity eq 'wishlist') { @@ -5595,34 +5235,13 @@ sub check_ip_acc { } my $name; - my %access = ( - allowfrom => 1, - denyfrom => 0, - ); - my @allows; - my @denies; - foreach my $item (split(',',$acc)) { - $item =~ s/^\s*//; - $item =~ s/\s*$//; - if ($item =~ /^\!(.+)$/) { - push(@denies,$1); - } else { - push(@allows,$item); - } - } - my $numdenies = scalar(@denies); - my $numallows = scalar(@allows); - my $count = 0; - foreach my $pattern (@denies,@allows) { - $count ++; - my $acctype = 'allowfrom'; - if ($count <= $numdenies) { - $acctype = 'denyfrom'; - } + foreach my $pattern (split(',',$acc)) { + $pattern =~ s/^\s*//; + $pattern =~ s/\s*$//; if ($pattern =~ /\*$/) { #35.8.* $pattern=~s/\*//; - if ($ip =~ /^\Q$pattern\E/) { $allowed=$access{$acctype}; } + if ($ip =~ /^\Q$pattern\E/) { $allowed=1; } } elsif ($pattern =~ /(\d+\.\d+\.\d+)\.\[(\d+)-(\d+)\]$/) { #35.8.3.[34-56] my $low=$2; @@ -5630,7 +5249,7 @@ sub check_ip_acc { $pattern=$1; if ($ip =~ /^\Q$pattern\E/) { my $last=(split(/\./,$ip))[3]; - if ($last <=$high && $last >=$low) { $allowed=$access{$acctype}; } + if ($last <=$high && $last >=$low) { $allowed=1; } } } elsif ($pattern =~ /^\*/) { #*.msu.edu @@ -5640,10 +5259,10 @@ sub check_ip_acc { my $netaddr=inet_aton($ip); ($name)=gethostbyaddr($netaddr,AF_INET); } - if ($name =~ /\Q$pattern\E$/i) { $allowed=$access{$acctype}; } + if ($name =~ /\Q$pattern\E$/i) { $allowed=1; } } elsif ($pattern =~ /\d+\.\d+\.\d+\.\d+/) { #127.0.0.1 - if ($ip =~ /^\Q$pattern\E/) { $allowed=$access{$acctype}; } + if ($ip =~ /^\Q$pattern\E/) { $allowed=1; } } else { #some.name.com if (!defined($name)) { @@ -5651,16 +5270,9 @@ sub check_ip_acc { my $netaddr=inet_aton($ip); ($name)=gethostbyaddr($netaddr,AF_INET); } - if ($name =~ /\Q$pattern\E$/i) { $allowed=$access{$acctype}; } - } - if ($allowed =~ /^(0|1)$/) { last; } - } - if ($allowed eq '') { - if ($numdenies && !$numallows) { - $allowed = 1; - } else { - $allowed = 0; + if ($name =~ /\Q$pattern\E$/i) { $allowed=1; } } + if ($allowed) { last; } } return $allowed; } @@ -5746,7 +5358,7 @@ sub get_domainconf { foreach my $host (keys(%{$domconfig{'login'}{$key}})) { if (ref($domconfig{'login'}{$key}{$host}) eq 'HASH') { $designhash{$udom.'.login.'.$key.'_'.$host} = 1; - foreach my $item ('text','img','alt','url','title','window','notsso') { + foreach my $item ('text','img','alt','url','title','notsso') { $designhash{$udom.'.login.'.$key.'_'.$item.'_'.$host} = $domconfig{'login'}{$key}{$host}{$item}; } } @@ -5979,12 +5591,6 @@ sub head_subbox { Input: (optional) filename from which breadcrumb trail is built. In most cases no input as needed, as $env{'request.filename'} is appropriate for use in building the breadcrumb trail. - frameset flag - If page header is being requested for use in a frameset, then - the second (option) argument -- frameset will be true, and - the target attribute set for links should be target="_parent". - If $title is supplied as the third arg, that will be used to - the left of the breadcrumbs tail for the current path. Returns: HTML div with CSTR path and recent box To be included on Authoring Space pages @@ -5992,7 +5598,7 @@ Returns: HTML div with CSTR path and rec =cut sub CSTR_pageheader { - my ($trailfile,$frameset,$title) = @_; + my ($trailfile) = @_; if ($trailfile eq '') { $trailfile = $env{'request.filename'}; } @@ -6015,28 +5621,13 @@ sub CSTR_pageheader { $lastitem = $thisdisfn; } - if ($title eq '') { - $title = &mt('Authoring Space'); - } - - my ($target,$crumbtarget) = (' target="_top"','_top'); - if ($frameset) { - $target = ' target="_parent"'; - $crumbtarget = '_parent'; - } elsif (($env{'request.lti.login'}) && ($env{'request.lti.target'} eq 'iframe')) { - $target = ''; - $crumbtarget = ''; - } elsif (($env{'request.deeplink.login'}) && ($env{'request.deeplink.target'})) { - $target = ' target="'.$env{'request.deeplink.target'}.'"'; - $crumbtarget = $env{'request.deeplink.target'}; - } - my $output = '
' .&Apache::loncommon::help_open_menu('','',3,'Authoring') #FIXME: Broken? Where is it? - .''.$title.' ' - .'
' - .&Apache::lonhtmlcommon::crumbs($uname.'/'.$parentpath,$crumbtarget,'/priv/'.$udom,undef,undef); + .''.&mt('Authoring Space:').' ' + .'' #FIXME lonpubdir: target="_parent" + .&Apache::lonhtmlcommon::crumbs($uname.'/'.$parentpath,'_top','/priv/'.$udom,undef,undef); if ($lastitem) { $output .= @@ -6046,156 +5637,15 @@ sub CSTR_pageheader { } $output .= '
' - #FIXME lonpubdir: &Apache::lonhtmlcommon::crumbs($uname.$thisdisfn.'/',$crumbtarget,'/priv','','+1',1)."
" + #FIXME lonpubdir: &Apache::lonhtmlcommon::crumbs($uname.$thisdisfn.'/','_top','/priv','','+1',1)."
" .&Apache::lonhtmlcommon::select_recent('construct','recent','this.form.action=this.form.recent.value;this.form.submit()') .'
' - .&Apache::lonmenu::constspaceform($frameset) + .&Apache::lonmenu::constspaceform() .'
'; return $output; } -############################################## -=pod - -=item * &nocodemirror() - -Input: None - -Returns: 1 if CodeMirror is deactivated based on - user's preference, or domain default, - if user indicated use of default. - -=cut - -sub nocodemirror { - my $nocodem = $env{'environment.nocodemirror'}; - unless ($nocodem) { - my %domdefs = &Apache::lonnet::get_domain_defaults($env{'user.domain'}); - if ($domdefs{'nocodemirror'}) { - $nocodem = 'yes'; - } - } - if ($nocodem eq 'yes') { - return 1; - } - return; -} - -############################################## -=pod - -=item * &permitted_editors() - -Input: $uri (optional) - -Returns: %editors hash in which keys are editors - permitted in current Authoring Space, - or in current course for web pages - created in a course. - - Value for each key is 1. Possible keys - are: edit, xml, and daxe. - - For a regular Authoring Space, if no specific - set of editors has been set for the Author - who owns the Authoring Space, then the - domain default will be used. If no domain - default has been set, then the keys will be - edit and xml. - - For a course author, or for web pages created - in a course, if no specific set of editors has - been set for the course, then the domain - course default will be used. If no domain - course default has been set, then the keys - will be edit and xml. - -=cut - -sub permitted_editors { - my ($uri) = @_; - my ($is_author,$is_coauthor,$is_course,$auname,$audom,%editors); - if ($env{'request.role'} =~ m{^au\./}) { - $is_author = 1; - } elsif ($env{'request.role'} =~ m{^(?:ca|aa)\./($match_domain)/($match_username)}) { - ($audom,$auname) = ($1,$2); - if (($audom ne '') && ($auname ne '')) { - if (($env{'user.domain'} eq $audom) && - ($env{'user.name'} eq $auname)) { - $is_author = 1; - } else { - $is_coauthor = 1; - } - } - } elsif ($env{'request.course.id'}) { - my ($cdom,$cnum); - $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; - $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; - if (($env{'request.editurl'} =~ m{^/priv/\Q$cdom/$cnum\E/}) || - ($env{'request.editurl'} =~ m{^/uploaded/\Q$cdom/$cnum\E/(docs|supplemental)/}) || - ($uri =~ m{^/uploaded/\Q$cdom/$cnum\E/(docs|supplemental)/})) { - $is_course = 1; - } elsif ($env{'request.editurl'} =~ m{^/priv/($match_domain)/($match_username)/}) { - ($audom,$auname) = ($1,$2); - } elsif ($env{'request.uri'} =~ m{^/priv/($match_domain)/($match_username)/}) { - ($audom,$auname) = ($1,$2); - } elsif (($uri eq '/daxesave') && - (($env{'form.path'} =~ m{^/daxeopen/priv/\Q$cdom/$cnum\E/}) || - ($env{'form.path'} =~ m{^/daxeopen/uploaded/\Q$cdom/$cnum\E/(docs|supplemental)/}))) { - $is_course = 1; - } elsif (($uri eq '/daxesave') && - ($env{'form.path'} =~ m{^/daxeopen/priv/($match_domain)/($match_username)/})) { - ($audom,$auname) = ($1,$2); - } - unless ($is_course) { - if (($audom ne '') && ($auname ne '')) { - if (($env{'user.domain'} eq $audom) && - ($env{'user.name'} eq $auname)) { - $is_author = 1; - } else { - $is_coauthor = 1; - } - } - } - } - if ($is_author) { - if (exists($env{'environment.editors'})) { - map { $editors{$_} = 1; } split(/,/,$env{'environment.editors'}); - } else { - %editors = ( edit => 1, - xml => 1, - ); - } - } elsif ($is_coauthor) { - if (exists($env{"environment.internal.editors./$audom/$auname"})) { - map { $editors{$_} = 1; } split(/,/,$env{"environment.internal.editors./$audom/$auname"}); - } else { - %editors = ( edit => 1, - xml => 1, - ); - } - } elsif ($is_course) { - if (exists($env{'course.'.$env{'request.course.id'}.'.internal.crseditors'})) { - map { $editors{$_} = 1; } split(/,/,$env{'course.'.$env{'request.course.id'}.'.internal.crseditors'}); - } else { - my %domdefaults = &Apache::lonnet::get_domain_defaults($env{'course.'.$env{'request.course.id'}.'.domain'}); - if (exists($domdefaults{'crseditors'})) { - map { $editors{$_} = 1; } split(/,/,$domdefaults{'crseditors'}); - } else { - %editors = ( edit => 1, - xml => 1, - ); - } - } - } else { - %editors = ( edit => 1, - xml => 1, - ); - } - return %editors; -} - ############################################### ############################################### @@ -6247,34 +5697,6 @@ Inputs: inlineremote items to be added in "Functions" menu below breadcrumbs. -=item * $ltiscope, optional argument, will be one of: resource, map or - course, if LON-CAPA is in LTI Provider context. Value is - the scope of use, i.e., launch was for access to a single, a map - or the entire course. - -=item * $ltiuri, optional argument, if LON-CAPA is in LTI Provider - context, this will contain the URL for the landing item in - the course, after launch from an LTI Consumer - -=item * $ltimenu, optional argument, if LON-CAPA is in LTI Provider - context, this will contain a reference to hash of items - to be included in the page header and/or inline menu. - -=item * $menucoll, optional argument, if specific menu collection is in - effect, either set as the default for the course, or set for - the deeplink paramater for $env{'request.deeplink.login'} - then $menucoll will be the number of that collection. - -=item * $menuref, optional argument, reference to a hash, containing the - menu options included for the menu in effect, based on the - configuration for the numbered menu collection in use. - -=item * $showncrumbsref, reference to a scalar. Calls to lonmenu::innerregister - within &bodytag() can result in calls to lonhtmlcommon::breadcrumbs(), - if so, $showncrumbsref is set there to 1, and will propagate back - via &bodytag() to &start_page(), to prevent lonhtmlcommon::breadcrumbs() - being called a second time. - =back Returns: A uniform header for LON-CAPA web pages. @@ -6286,8 +5708,7 @@ other decorations will be returned. sub bodytag { my ($title,$function,$addentries,$bodyonly,$domain,$forcereg, - $no_nav_bar,$bgcolor,$no_inline_link,$args,$advtoolsref, - $ltiscope,$ltiuri,$ltimenu,$menucoll,$menuref,$showncrumbsref)=@_; + $no_nav_bar,$bgcolor,$no_inline_link,$args,$advtoolsref)=@_; my $public; if ((($env{'user.name'} eq 'public') && ($env{'user.domain'} eq 'public')) @@ -6371,46 +5792,16 @@ sub bodytag { undef($role); } - my $showcrstitle = 1; - if (($cid) && ($env{'request.lti.login'})) { - if (ref($ltimenu) eq 'HASH') { - unless ($ltimenu->{'role'}) { - undef($role); - } - unless ($ltimenu->{'coursetitle'}) { - $realm=' '; - $showcrstitle = 0; - } - } - } elsif (($cid) && ($menucoll)) { - if (ref($menuref) eq 'HASH') { - unless ($menuref->{'role'}) { - undef($role); - } - unless ($menuref->{'crs'}) { - $realm=' '; - $showcrstitle = 0; - } - } - } - my $titleinfo = '

'.$title.'

'; # # Extra info if you are the DC my $dc_info = ''; - if (($env{'user.adv'}) && ($env{'request.course.id'}) && $showcrstitle && + if (($env{'user.adv'}) && ($env{'request.course.id'}) && (exists($env{'user.role.dc./'.$env{'course.'.$cid.'.domain'}.'/'}))) { $dc_info = $cid.' '.$env{'course.'.$cid.'.internal.coursecode'}; $dc_info =~ s/\s+$//; } - my $crstype; - if ($cid) { - $crstype = $env{'course.'.$cid.'.type'}; - } elsif ($args->{'crstype'}) { - $crstype = $args->{'crstype'}; - } - $role = '('.$role.')' if ($role && !$env{'browser.mobile'}); if ($env{'request.state'} eq 'construct') { $forcereg=1; } @@ -6438,53 +5829,27 @@ sub bodytag { $bodytag .= Apache::lonhtmlcommon::scripttag( Apache::lonmenu::utilityfunctions($httphost), 'start'); - my $collapsible; - if ($args->{'collapsible_header'} ne '') { - $collapsible = 1; - my ($menustate,$tiptext,$divclass); - if ($args->{'start_collapsed'}) { - $menustate = 'collapsed'; - $tiptext = 'display'; - $divclass = 'hidden'; - } else { - $menustate = 'expanded'; - $tiptext = 'hide'; - $divclass = 'shown'; - } - my $alttext = &mt('menu state: '.$menustate); - my $tooltip = &mt($tiptext.' standard menus'); - $bodytag .= <<"END"; -
-
-$alttext
-
-END - } - unless ($args->{'no_primary_menu'}) { - my ($left,$right) = Apache::lonmenu::primary_menu($crstype,$ltimenu,$menucoll,$menuref, - $args->{'links_disabled'}, - $args->{'links_target'}, - $collapsible); - if ($env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { - if ($dc_info) { - $dc_info = qq|$dc_info|; - } - $bodytag .= qq|
$left $role
- $realm $dc_info
|; - return $bodytag; - } + my ($left,$right) = Apache::lonmenu::primary_menu($args->{'links_disabled'}); - unless ($env{'request.symb'} =~ m/\.page___\d+___/) { - $bodytag .= qq|
$left $role
|; + if ($env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { + if ($dc_info) { + $dc_info = qq|$dc_info|; } + $bodytag .= qq|
$left $role
+ $realm $dc_info
|; + return $bodytag; + } - $bodytag .= $right; + unless ($env{'request.symb'} =~ m/\.page___\d+___/) { + $bodytag .= qq|
$left $role
|; + } - if ($dc_info) { - $dc_info = &dc_courseid_toggle($dc_info); - } - $bodytag .= qq|
$realm $dc_info
|; + $bodytag .= $right; + + if ($dc_info) { + $dc_info = &dc_courseid_toggle($dc_info); } + $bodytag .= qq|
$realm $dc_info
|; #if directed to not display the secondary menu, don't. if ($args->{'no_secondary_menu'}) { @@ -6492,23 +5857,17 @@ END } #don't show menus for public users if (!$public){ - unless ($args->{'no_inline_menu'}) { - $bodytag .= Apache::lonmenu::secondary_menu($httphost,$ltiscope,$ltimenu, - $args->{'no_primary_menu'}, - $menucoll,$menuref, - $args->{'links_disabled'}, - $args->{'links_target'}); - } + $bodytag .= Apache::lonmenu::secondary_menu($httphost,$args->{'links_disabled'}); $bodytag .= Apache::lonmenu::serverform(); $bodytag .= Apache::lonhtmlcommon::scripttag('', 'end'); if ($env{'request.state'} eq 'construct') { $bodytag .= &Apache::lonmenu::innerregister($forcereg, - $args->{'bread_crumbs'},'','',$hostname, - $ltiscope,$ltiuri,$showncrumbsref); + $args->{'bread_crumbs'},'','',$hostname); } elsif ($forcereg) { $bodytag .= &Apache::lonmenu::innerregister($forcereg,undef, - $args->{'group'},$args->{'hide_buttons'}, - $hostname,$ltiscope,$ltiuri,$showncrumbsref); + $args->{'group'}, + $args->{'hide_buttons'}, + $hostname); } else { my $forbodytag; &Apache::lonmenu::prepare_functions($env{'request.noversionuri'}, @@ -6526,11 +5885,7 @@ END $bodytag .= '
'; $bodytag .= Apache::lonhtmlcommon::scripttag('', 'end'); } - if ($args->{'collapsible_header'} ne '') { - $bodytag .= $args->{'collapsible_header'}. - '
'. - '
'; - } + return $bodytag; } @@ -6655,38 +6010,8 @@ sub endbodytag { } if ( exists( $env{'internal.head.redirect'} ) ) { if (!(ref($args) eq 'HASH' && $args->{'noredirectlink'})) { - my ($endbodyjs,$idattr); - if ($env{'internal.head.to_opener'}) { - my $linkid = 'LC_continue_link'; - $idattr = ' id="'.$linkid.'"'; - my $redirect_for_js = &js_escape($env{'internal.head.redirect'}); - $endbodyjs=< -// - -ENDJS - } $endbodytag= - "$endbodyjs
". + "
". &mt('Continue').''. $endbodytag; } @@ -6778,14 +6103,6 @@ form, .inline { display: inline; } -.LC_menus_content.shown{ - display: block; -} - -.LC_menus_content.hidden { - display: none; -} - .LC_right { text-align:right; } @@ -6806,12 +6123,6 @@ form, .inline { width:400px; } -#LC_collapsible_separator { - border: 1px solid black; - width: 99.9%; - height: 0px; -} - .LC_iframecontainer { width: 98%; margin: 0; @@ -8007,11 +7318,6 @@ fieldset { /* overflow: hidden; */ } -fieldset#LC_selectuser { - margin: 0; - padding: 0; -} - article.geogebraweb div { margin: 0; } @@ -8555,10 +7861,6 @@ 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; } @@ -8697,16 +7999,6 @@ pre.LC_wordwrap { } /* - styles used for response display -*/ -div.LC_radiofoil, div.LC_rankfoil { - margin: .5em 0em .5em 0em; -} -table.LC_itemgroup { - margin-top: 1em; -} - -/* styles used by TTH when "Default set of options to pass to tth/m when converting TeX" in course settings has been set @@ -8727,87 +8019,6 @@ span.roman {font-family: serif; font-sty span.overacc2 {position: relative; left: .8em; top: -1.2ex;} span.overacc1 {position: relative; left: .6em; top: -1.2ex;} -/* - sections with roles, for content only -*/ -section[class^="role-"] { - padding-left: 10px; - padding-right: 5px; - margin-top: 8px; - margin-bottom: 8px; - border: 1px solid #2A4; - border-radius: 5px; - box-shadow: 0px 1px 1px #BBB; -} -section[class^="role-"]>h1 { - position: relative; - margin: 0px; - padding-top: 10px; - padding-left: 40px; -} -section[class^="role-"]>h1:before { - position: absolute; - left: -5px; - top: 5px; -} -section.role-activity>h1:before { - content:url('/adm/daxe/images/section_icons/activity.png'); -} -section.role-advice>h1:before { - content:url('/adm/daxe/images/section_icons/advice.png'); -} -section.role-bibliography>h1:before { - content:url('/adm/daxe/images/section_icons/bibliography.png'); -} -section.role-citation>h1:before { - content:url('/adm/daxe/images/section_icons/citation.png'); -} -section.role-conclusion>h1:before { - content:url('/adm/daxe/images/section_icons/conclusion.png'); -} -section.role-definition>h1:before { - content:url('/adm/daxe/images/section_icons/definition.png'); -} -section.role-demonstration>h1:before { - content:url('/adm/daxe/images/section_icons/demonstration.png'); -} -section.role-example>h1:before { - content:url('/adm/daxe/images/section_icons/example.png'); -} -section.role-explanation>h1:before { - content:url('/adm/daxe/images/section_icons/explanation.png'); -} -section.role-introduction>h1:before { - content:url('/adm/daxe/images/section_icons/introduction.png'); -} -section.role-method>h1:before { - content:url('/adm/daxe/images/section_icons/method.png'); -} -section.role-more_information>h1:before { - content:url('/adm/daxe/images/section_icons/more_information.png'); -} -section.role-objectives>h1:before { - content:url('/adm/daxe/images/section_icons/objectives.png'); -} -section.role-prerequisites>h1:before { - content:url('/adm/daxe/images/section_icons/prerequisites.png'); -} -section.role-remark>h1:before { - content:url('/adm/daxe/images/section_icons/remark.png'); -} -section.role-reminder>h1:before { - content:url('/adm/daxe/images/section_icons/reminder.png'); -} -section.role-summary>h1:before { - content:url('/adm/daxe/images/section_icons/summary.png'); -} -section.role-syntax>h1:before { - content:url('/adm/daxe/images/section_icons/syntax.png'); -} -section.role-warning>h1:before { - content:url('/adm/daxe/images/section_icons/warning.png'); -} - #LC_minitab_header { float:left; width:100%; @@ -8861,13 +8072,8 @@ 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 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 + redirected too) + 4- 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 @@ -8930,45 +8136,17 @@ sub headtag { } } if (ref($args->{'redirect'})) { - my ($time,$url,$inhibit_continue,$to_opener,$skip_enc_check) = @{$args->{'redirect'}}; + my ($time,$url,$inhibit_continue,$skip_enc_check) = @{$args->{'redirect'}}; if (!$skip_enc_check) { - $url = &Apache::lonenc::check_encrypt($url); + $url = &Apache::lonenc::check_encrypt($url); } if (!$inhibit_continue) { $env{'internal.head.redirect'} = $url; } - $result.=<<"ADDMETA"; + $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'}; @@ -9014,7 +8192,7 @@ ADDMETA 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))) { + if (($dom_in_use ne '') && (!grep(/^\Q$dom_in_use\E$/,@domains))) { ($newserver) = &Apache::lonnet::choose_server($dom_in_use); } } @@ -9108,7 +8286,7 @@ OFFLOAD if ($title =~ /^LON-CAPA\s+/) { $result .= ' '.$title.''; } else { - $result .= ' LON-CAPA '.$title.''; + $result .= ' LON-CAPA '.$title.''; } $result .= "\n".'{'frameset'}) { @@ -9322,7 +8500,6 @@ $args - additional optional args support links_disabled -> Links in primary and secondary menus are disabled (Can enable them once page has loaded - see lonroles.pm for an example). - links_target -> Target for links, e.g., _parent (optional). =back @@ -9335,83 +8512,12 @@ sub start_page { #&Apache::lonnet::logthis("start_page ".join(':',caller(0))); $env{'internal.start_page'}++; - my ($result,@advtools,$ltiscope,$ltiuri,%ltimenu,$menucoll,%menu); + my ($result,@advtools); if (! exists($args->{'skip_phases'}{'head'}) ) { $result .= &xml_begin($args->{'frameset'}) . &headtag($title, $head_extra, $args); } - - if (($env{'request.course.id'}) && ($env{'request.lti.login'})) { - if ($env{'course.'.$env{'request.course.id'}.'.lti.override'}) { - unless ($env{'course.'.$env{'request.course.id'}.'.lti.topmenu'}) { - $args->{'no_primary_menu'} = 1; - } - unless ($env{'course.'.$env{'request.course.id'}.'.lti.inlinemenu'}) { - $args->{'no_inline_menu'} = 1; - } - if ($env{'course.'.$env{'request.course.id'}.'.lti.lcmenu'}) { - map { $ltimenu{$_} = 1; } split(/,/,$env{'course.'.$env{'request.course.id'}.'.lti.lcmenu'}); - } - } else { - my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; - my %lti = &Apache::lonnet::get_domain_lti($cdom,'provider'); - if (ref($lti{$env{'request.lti.login'}}) eq 'HASH') { - unless ($lti{$env{'request.lti.login'}}{'topmenu'}) { - $args->{'no_primary_menu'} = 1; - } - unless ($lti{$env{'request.lti.login'}}{'inlinemenu'}) { - $args->{'no_inline_menu'} = 1; - } - if (ref($lti{$env{'request.lti.login'}}{'lcmenu'}) eq 'ARRAY') { - map { $ltimenu{$_} = 1; } @{$lti{$env{'request.lti.login'}}{'lcmenu'}}; - } - } - } - ($ltiscope,$ltiuri) = &LONCAPA::ltiutils::lti_provider_scope($env{'request.lti.uri'}, - $env{'course.'.$env{'request.course.id'}.'.domain'}, - $env{'course.'.$env{'request.course.id'}.'.num'}); - } elsif ($env{'request.course.id'}) { - my $expiretime=600; - if ((time-$env{'course.'.$env{'request.course.id'}.'.last_cache'}) > $expiretime) { - &Apache::lonnet::coursedescription($env{'request.course.id'},{'freshen_cache' => 1}); - } - my ($deeplinkmenu,$menuref); - ($menucoll,$deeplinkmenu,$menuref) = &menucoll_in_effect(); - if ($menucoll) { - if (ref($menuref) eq 'HASH') { - %menu = %{$menuref}; - } - if ($menu{'top'} eq 'n') { - $args->{'no_primary_menu'} = 1; - } - if ($menu{'inline'} eq 'n') { - unless (&Apache::lonnet::allowed('opa')) { - my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; - my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; - my $crstype = &course_type(); - my $now = time; - my $ccrole; - if ($crstype eq 'Community') { - $ccrole = 'co'; - } else { - $ccrole = 'cc'; - } - if ($env{'user.role.'.$ccrole.'./'.$cdom.'/'.$cnum}) { - my ($start,$end) = split(/\./,$env{'user.role.'.$ccrole.'./'.$cdom.'/'.$cnum}); - if ((($start) && ($start<0)) || - (($end) && ($end<$now)) || - (($start) && ($now<$start))) { - $args->{'no_inline_menu'} = 1; - } - } else { - $args->{'no_inline_menu'} = 1; - } - } - } - } - } - - my $showncrumbs; + if (! exists($args->{'skip_phases'}{'body'}) ) { if ($args->{'frameset'}) { my $attr_string = &make_attr_string($args->{'force_register'}, @@ -9424,8 +8530,7 @@ sub start_page { $args->{'only_body'}, $args->{'domain'}, $args->{'force_register'}, $args->{'no_nav_bar'}, $args->{'bgcolor'}, $args->{'no_inline_link'}, - $args, \@advtools, - $ltiscope,$ltiuri,\%ltimenu,$menucoll,\%menu,\$showncrumbs); + $args, \@advtools); } } @@ -9447,7 +8552,6 @@ sub start_page { #Breadcrumbs if (exists($args->{'bread_crumbs'}) or exists($args->{'bread_crumbs_component'})) { - unless ($showncrumbs) { &Apache::lonhtmlcommon::clear_breadcrumbs(); #if any br links exists, add them to the breadcrumbs if (exists($args->{'bread_crumbs'}) and ref($args->{'bread_crumbs'}) eq 'ARRAY') { @@ -9461,26 +8565,17 @@ sub start_page { } my $menulink; # if arg: bread_crumbs_nomenu is true pass 0 as $menulink item. - if ((exists($args->{'bread_crumbs_nomenu'})) || - ($ltiscope eq 'map') || ($ltiscope eq 'resource')) { + if (exists($args->{'bread_crumbs_nomenu'})) { $menulink = 0; } else { undef($menulink); } - my $linkprotout; - if ($env{'request.deeplink.login'}) { - my $linkprotout = &Apache::lonmenu::linkprot_exit(); - if ($linkprotout) { - &Apache::lonhtmlcommon::add_breadcrumb_tool('tools',$linkprotout); - } - } #if bread_crumbs_component exists show it as headline else show only the breadcrumbs if(exists($args->{'bread_crumbs_component'})){ $result .= &Apache::lonhtmlcommon::breadcrumbs($args->{'bread_crumbs_component'},'',$menulink); - } else { + }else{ $result .= &Apache::lonhtmlcommon::breadcrumbs('','',$menulink); } - } } elsif (($env{'environment.remote'} eq 'on') && ($env{'form.inhibitmenu'} ne 'yes') && ($env{'request.noversionuri'} =~ m{^/res/}) && @@ -9522,147 +8617,6 @@ sub end_page { return $result; } -sub menucoll_in_effect { - my ($menucoll,$deeplinkmenu,%menu); - if ($env{'request.course.id'}) { - $menucoll = $env{'course.'.$env{'request.course.id'}.'.menudefault'}; - if ($env{'request.deeplink.login'}) { - my ($deeplink_symb,$deeplink,$check_login_symb); - my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; - my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; - if ($env{'request.noversionuri'} =~ m{^/(res|uploaded)/}) { - if ($env{'request.noversionuri'} =~ /\.(page|sequence)$/) { - my $navmap = Apache::lonnavmaps::navmap->new(); - if (ref($navmap)) { - $deeplink = $navmap->get_mapparam(undef, - &Apache::lonnet::declutter($env{'request.noversionuri'}), - '0.deeplink'); - } else { - $check_login_symb = 1; - } - } else { - my $symb=&Apache::lonnet::symbread(); - if ($symb) { - $deeplink = &Apache::lonnet::EXT('resource.0.deeplink',$symb); - } else { - $check_login_symb = 1; - } - } - } else { - $check_login_symb = 1; - } - if ($check_login_symb) { - $deeplink_symb = &deeplink_login_symb($cnum,$cdom); - if ($deeplink_symb =~ /\.(page|sequence)$/) { - my $mapname = &Apache::lonnet::deversion((&Apache::lonnet::decode_symb($deeplink_symb))[2]); - my $navmap = Apache::lonnavmaps::navmap->new(); - if (ref($navmap)) { - $deeplink = $navmap->get_mapparam(undef,$mapname,'0.deeplink'); - } - } else { - $deeplink = &Apache::lonnet::EXT('resource.0.deeplink',$deeplink_symb); - } - } - if ($deeplink ne '') { - my ($state,$others,$listed,$scope,$protect,$display,$target) = split(/,/,$deeplink); - if ($display =~ /^\d+$/) { - $deeplinkmenu = 1; - $menucoll = $display; - } - } - } - if ($menucoll) { - %menu = &page_menu($env{'course.'.$env{'request.course.id'}.'.menucollections'},$menucoll); - } - } - return ($menucoll,$deeplinkmenu,\%menu); -} - -sub deeplink_login_symb { - my ($cnum,$cdom) = @_; - my $login_symb; - if ($env{'request.deeplink.login'}) { - $login_symb = &symb_from_tinyurl($env{'request.deeplink.login'},$cnum,$cdom); - } - return $login_symb; -} - -sub symb_from_tinyurl { - my ($url,$cnum,$cdom) = @_; - if ($url =~ m{^\Q/tiny/$cdom/\E(\w+)$}) { - my $key = $1; - my ($tinyurl,$login); - my ($result,$cached)=&Apache::lonnet::is_cached_new('tiny',$cdom."\0".$key); - if (defined($cached)) { - $tinyurl = $result; - } else { - my $configuname = &Apache::lonnet::get_domainconfiguser($cdom); - my %currtiny = &Apache::lonnet::get('tiny',[$key],$cdom,$configuname); - if ($currtiny{$key} ne '') { - $tinyurl = $currtiny{$key}; - &Apache::lonnet::do_cache_new('tiny',$cdom."\0".$key,$currtiny{$key},600); - } - } - if ($tinyurl ne '') { - my ($cnumreq,$symb) = split(/\&/,$tinyurl); - if (wantarray) { - return ($cnumreq,$symb); - } elsif ($cnumreq eq $cnum) { - return $symb; - } - } - } - if (wantarray) { - return (); - } else { - return; - } -} - -sub usable_exttools { - my %tooltypes; - if ($env{'request.course.id'}) { - if ($env{'course.'.$env{'request.course.id'}.'.internal.exttool'}) { - if ($env{'course.'.$env{'request.course.id'}.'.internal.exttool'} eq 'both') { - %tooltypes = ( - crs => 1, - dom => 1, - ); - } elsif ($env{'course.'.$env{'request.course.id'}.'.internal.exttool'} eq 'crs') { - $tooltypes{'crs'} = 1; - } elsif ($env{'course.'.$env{'request.course.id'}.'.internal.exttool'} eq 'dom') { - $tooltypes{'dom'} = 1; - } - } else { - my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; - my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; - my $crstype = lc($env{'course.'.$env{'request.course.id'}.'.type'}); - if ($crstype eq '') { - $crstype = 'course'; - } - if ($crstype eq 'course') { - if ($env{'course.'.$env{'request.course.id'}.'internal.coursecode'}) { - $crstype = 'official'; - } elsif ($env{'course.'.$env{'request.course.id'}.'.internal.textbook'}) { - $crstype = 'textbook'; - } elsif ($env{'course.'.$env{'request.course.id'}.'.internal.lti'}) { - $crstype = 'lti'; - } else { - $crstype = 'unofficial'; - } - } - my %domdefaults = &Apache::lonnet::get_domain_defaults($cdom); - if ($domdefaults{$crstype.'domexttool'}) { - $tooltypes{'dom'} = 1; - } - if ($domdefaults{$crstype.'exttool'}) { - $tooltypes{'crs'} = 1; - } - } - } - return %tooltypes; -} - sub wishlist_window { return(<<'ENDWISHLIST');