--- loncom/interface/lonmenu.pm 2009/05/19 14:05:19 1.267 +++ loncom/interface/lonmenu.pm 2009/12/24 18:28:58 1.309.2.5 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines to control the menu # -# $Id: lonmenu.pm,v 1.267 2009/05/19 14:05:19 droeschl Exp $ +# $Id: lonmenu.pm,v 1.309.2.5 2009/12/24 18:28:58 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -26,15 +26,10 @@ # http://www.lon-capa.org/ # # -# There are two parameters controlling the action of this module: -# -# browser.interface - if this is 'textual', it overrides the second parameter -# and goes to screen reader PDA mode +# There is one parameter controlling the action of this module: # # environment.remote - if this is 'on', the routines controll the remote -# control, otherwise they render the main window controls; ignored it -# browser.interface is 'textual' -# +# control, otherwise they render the main window controls; =head1 NAME @@ -118,11 +113,6 @@ The javascript is usually similar to "go =item get_nav_status() -=item convert_menu_function() - -FIXME this needs to move into mydesktab and the other locations -the text is generated - =item hidden_button_check() =item roles_selector() @@ -142,15 +132,204 @@ use Apache::loncommon(); use Apache::lonenc(); use Apache::lonlocal; use LONCAPA qw(:DEFAULT :match); +use HTML::Entities(); -use vars qw(@desklines %category_names %category_members %category_positions $readdesk); - +use vars qw(@desklines %category_names %category_members %category_positions + $readdesk @primary_menu @secondary_menu); my @inlineremote; +sub prep_menuitem { + my ($menuitem) = @_; + return '' unless(ref($menuitem) eq 'ARRAY'); + my $link; + if ($$menuitem[1]) { # graphical Link + $link = "\"""; + } else { # textual Link + $link = &mt($$menuitem[3]); + } + return '
  • '.$link.'
  • '; +} + +# primary_menu() evaluates @primary_menu and returns XHTML for the menu +# that contains following links: +# About, Message, Roles, Help, Logout +# @primary_menu is filled within the BEGIN block of this module with +# entries from mydesk.tab +sub primary_menu { + my $menu; + my $custommenu = &Apache::loncommon::needs_gci_custom(); + # each element of @primary contains following array: + # (link url, icon path, alt text, link text, condition) + foreach my $menuitem (@primary_menu) { + # evaluate conditions + next if ref($menuitem) ne 'ARRAY'; # + next if $$menuitem[4] eq 'nonewmsg' # show links depending on + && &Apache::lonmsg::mynewmail(); # whether a new msg + next if $$menuitem[4] eq 'newmsg' # arrived or not + && !&Apache::lonmsg::mynewmail(); # + next if $$menuitem[4] !~ /public/ ##we've a public user, + && $env{'user.name'} eq 'public' ##who should not see all + && $env{'user.domain'} eq 'public'; ##links + next if $$menuitem[4] eq 'onlypublic'# hide links which are + && $env{'user.name'} ne 'public' # only visible to public + && $env{'user.domain'} ne 'public'; # users + next if $$menuitem[4] eq 'roles' # hide links which are + && $custommenu; # not visible when GCI + next if $$menuitem[4] eq 'courses' # tabbed interface in use + && $custommenu; # + next if $$menuitem[4] eq 'roles' ##show links depending on + && &Apache::loncommon::show_course(); ##term 'Courses' or + next if $$menuitem[4] eq 'courses' ##'Roles' wanted + && !&Apache::loncommon::show_course(); ## + + + if ($$menuitem[3] eq 'Help') { # special treatment for helplink + $menu .= '
  • '.&Apache::loncommon::top_nav_help('Help').'
  • '; + } else { + my @items = @{$menuitem}; + $items[0] = 'javascript:'.$menuitem->[0].';'; + $menu .= &prep_menuitem(\@items); + } + } + + return "
      $menu
    "; +} + + +sub secondary_menu { + my $menu; + + my $crstype = &Apache::loncommon::course_type(); + my $canedit = &Apache::lonnet::allowed('mdc', $env{'request.course.id'}); + my $canviewgrps = &Apache::lonnet::allowed('vcg', $env{'request.course.id'} + . ($env{'request.course.sec'} ? "/$env{'request.course.sec'}" + : '')); + my $showlink = &show_return_link(); + my %groups = &Apache::lonnet::get_active_groups( + $env{'user.domain'}, $env{'user.name'}, + $env{'course.' . $env{'request.course.id'} . '.domain'}, + $env{'course.' . $env{'request.course.id'} . '.num'}); + foreach my $menuitem (@secondary_menu) { + # evaluate conditions + next if ref($menuitem) ne 'ARRAY'; + next if $$menuitem[4] ne 'always' + && !$env{'request.course.id'}; + next if $$menuitem[4] eq 'showreturn' + && !$showlink + && !($env{'request.state'} eq 'construct'); + next if $$menuitem[4] =~ /^mdc/ + && !$canedit; + next if $$menuitem[4] eq 'mdcCourse' + && $crstype eq 'Community'; + next if $$menuitem[4] eq 'mdcCommunity' + && $crstype ne 'Community'; + next if $$menuitem[4] =~ /^remotenav/ + && $env{'environment.remotenavmap'} ne 'on'; + next if $$menuitem[4] =~ /noremotenav/ + && $env{'environment.remotenavmap'} eq 'on'; + next if $$menuitem[4] =~ /^(no|)remotenav$/ + && $crstype eq 'Community'; + next if $$menuitem[4] =~ /^(no|)remotenavCommunity$/ + && $crstype ne 'Community'; + next if $$menuitem[4] =~ /showgroups$/ + && !$canviewgrps + && !%groups; + + if ($$menuitem[3] eq 'Roles' && $env{'request.course.id'}) { + # special treatment for role selector + my $roles_selector = &roles_selector( + $env{'course.' . $env{'request.course.id'} . '.domain'}, + $env{'course.' . $env{'request.course.id'} . '.num'} ); + + $menu .= $roles_selector ? "
  • $roles_selector
  • " + : ''; + } elsif ($env{'environment.remotenavmap'} eq 'on') { + # open link using javascript when remote navmap is activated + my @items = @{$menuitem}; + if ($menuitem->[4] eq 'remotenav') { + $items[0] = "javascript:gonav('$menuitem->[0]');"; + } else { + $items[0] = "javascript:go('$menuitem->[0]');"; + } + $menu .= &prep_menuitem(\@items); + } else { + $menu .= &prep_menuitem(\@$menuitem); + } + } + if ($menu =~ /\[url\].*\[symb\]/) { + my $escurl = &escape( &Apache::lonenc::check_encrypt( + $env{'request.noversionuri'})); + + my $escsymb = &escape( &Apache::lonenc::check_encrypt( + $env{'request.symb'})); + + if ( $env{'request.state'} eq 'construct' + and ( $env{'request.noversionuri'} eq '' + || !defined($env{'request.noversionuri'}))) + { + ($escurl = $env{'request.filename'}) =~ + s{^/home/([^/]+)/public_html/(.*)$}{/priv/$1/$2}; + + $escurl = &escape($escurl); + } + $menu =~ s/\[url\]/$escurl/g; + $menu =~ s/\[symb\]/$escsymb/g; + } + + return ""; +} + +sub gci_secondary_menu { + my %courses = ( + 'review' => 'gci_9615072b469884921gcil1', + 'submit' => 'gci_1H96711d710194bfegcil1', + ); + my %linktext = ( + 'review' => 'Review Questions', + 'submit' => 'Submit Questions', + 'managetest' => 'Manage Tests', + ); + my %links = ( + 'managetest' => '/adm/menu', + ); + my $current = 'managetest'; + if ($env{'form.destinationurl'} eq '/adm/gci_info') { + undef($current); + } + foreach my $key (keys(%courses)) { + $links{$key} = "javascript:switchpage('$key');"; + if ($env{'request.course.id'} eq $courses{$key}) { + $links{$key} = '/adm/navmaps'; + $current = $key; + $links{'managetest'} = '/adm/roles?selectrole=1&cm=1&orgurl=%2fadm%2fmenu'; + } + } + my @menutabs = ('review','submit','managetest'); + my $tabs; + foreach my $item (@menutabs) { + if ($item eq $current) { + $tabs .= '
  • '. + $linktext{$item}.'
  • '; + } else { + $tabs .= '
  • '. + $linktext{$item}.'
  • '; + } + } + return '
    '. + '

    '; +} + +# +# This routine returns a translated hash for the menu items in the top inline menu row +# Probably should be in mydesk.tab + +#SD this sub is deprecated - don't use it sub initlittle { return &Apache::lonlocal::texthash('ret' => 'Return to Last Location', - 'nav' => 'Navigate Contents', + 'nav' => 'Course Contents', 'main' => 'Main Menu', 'roles' => (&Apache::loncommon::show_course()? 'Courses':'Roles'), @@ -160,14 +339,18 @@ sub initlittle { 'login' => 'Log In', 'launch' => 'Launch Remote Control', 'groups' => 'Groups', - 'gdoc' => 'Group Documents', + 'gdoc' => 'Community Documents', ); } +#SD this sub is deprecated - don't use it +#SD functionality is covered by new loncommon::bodytag and primary_menu(), secondary_menu() sub menubuttons { my $forcereg=shift; - my $registration=shift; my $titletable=shift; +# +# Early-out for pages that should not have a menu, triggered by query string "inhibitmenu=yes" +# &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, ['inhibitmenu']); if (($env{'form.inhibitmenu'} eq 'yes') || @@ -184,6 +367,9 @@ sub menubuttons { my $role_selector; my $showgroups=0; my ($cnum,$cdom); +# +# if the URL is hidden, symbs and the non-versioned version of the URL would be encrypted +# my $escurl=&escape(&Apache::lonenc::check_encrypt($env{'request.noversionuri'})); my $escsymb=&escape(&Apache::lonenc::check_encrypt($env{'request.symb'})); @@ -192,6 +378,9 @@ sub menubuttons { $logo.'" alt="LON-CAPA Logo" class="LC_noBorder" />'; if ($env{'request.state'} eq 'construct') { +# +# We are in construction space +# if (($env{'request.noversionuri'} eq '') || (!defined($env{'request.noversionuri'}))) { my $returnurl = $env{'request.filename'}; $returnurl =~ s:^/home/([^/]+)/public_html/(.*)$:/priv/$1/$2:; @@ -199,6 +388,9 @@ sub menubuttons { } } if ($env{'request.course.id'}) { +# +# We are in a course +# $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; my %coursegroups; @@ -222,7 +414,7 @@ sub menubuttons { my %lt=&initlittle(); my $domain=&Apache::loncommon::determinedomain(); - my $function =&Apache::loncommon::get_users_function(); + my $function=&Apache::loncommon::get_users_function(); my $link=&Apache::loncommon::designparm($function.'.link',$domain); my $alink=&Apache::loncommon::designparm($function.'.alink',$domain); my $vlink=&Apache::loncommon::designparm($function.'.vlink',$domain); @@ -230,15 +422,11 @@ sub menubuttons { if ($env{'user.name'} eq 'public' && $env{'user.domain'} eq 'public') { return (< - - $logo - - - $lt{'login'} - - - +
      +
    1. $logo
    2. +
    3. $lt{'login'}
    4. +
    +
    ENDINLINEMENU } $roles = ''.$lt{'roles'}.''; @@ -252,9 +440,10 @@ ENDINLINEMENU $navmaps=(<$lt{'nav'} ENDNAV - my $is_group = (&Apache::loncommon::course_type() eq 'Group'); + my $is_community = + (&Apache::loncommon::course_type() eq 'Community'); if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) { - my $text = ($is_group) ? $lt{'gdoc'} : $lt{'docs'}; + my $text = ($is_community) ? $lt{'gdoc'} : $lt{'docs'}; $docs=(<$text ENDDOCS @@ -281,35 +470,31 @@ ENDRELOAD
  • $lt{'ret'}
  • ENDCRELOAD } - my $reg=''; - if ($registration) { - $reg=&innerregister($forcereg,$titletable); - } - my $form=&serverform(); - my $utility=&utilityfunctions(); - - my $messagelink = ""; - if(&Apache::lonmsg::mynewmail()){ - $messagelink = 'Message(new)' - }else{ - $messagelink = 'Message' - } - my $helplink=&Apache::loncommon::top_nav_help('Help'); + my $reg = $forcereg ? &innerregister($forcereg,$titletable) : ''; + my $form = &serverform(); + my $utility = &utilityfunctions(); + + #Prepare the message link that indicates the arrival of new mail + my $messagelink = &Apache::lonmsg::mynewmail() ? "Message (new)" : "Message"; + $messagelink = '' + . mt($messagelink) .''; + + my $helplink = &Apache::loncommon::top_nav_help('Help'); return (< -// BEGIN LON-CAPA Internal // -
      +
      1. $logo
      2. $messagelink
      3. $roles
      4. $helplink
      5. $lt{'exit'}
      -
        +
        • $lt{'main'}
        • $reloadlink $navmaps @@ -350,14 +535,19 @@ sub registerurl { if ($env{'request.state'} eq 'construct') { $force_title=&Apache::lonxml::display_title(); } - if (($env{'browser.interface'} eq 'textual') || - ($env{'environment.remote'} eq 'off') || + if (($env{'environment.remote'} eq 'off') || ((($env{'request.publicaccess'}) || (!&Apache::lonnet::is_on_map( &unescape($env{'request.noversionuri'})))) && (!$forcereg))) { - return $result. - ''.$force_title; + return + $result + .'' + .$force_title; } # Graphical display after login only if ($env{'request.registered'} && !$forcereg) { return ''; } @@ -366,7 +556,7 @@ sub registerurl { } sub innerregister { - my ($forcereg, $titletable) = @_; + my ($forcereg,$titletable,$bread_crumbs) = @_; my $result = ''; my ($uname,$thisdisfn); my $const_space = ($env{'request.state'} eq 'construct'); @@ -383,12 +573,13 @@ sub innerregister { my $reopen=&Apache::lonmenu::reopenmenu(); my $newmail=''; - my $breadcrumb; if (&Apache::lonmsg::newmail() && !$noremote) { # We have new mail and remote is up $newmail= 'swmenu.setstatus("you have","messages");'; } + + my ($breadcrumb,$separator); if ($noremote && ($env{'request.symb'}) && ($env{'request.course.id'})) { @@ -398,15 +589,34 @@ sub innerregister { my $maptitle = &Apache::lonnet::gettitle($mapurl); my $restitle = &Apache::lonnet::gettitle(&Apache::lonnet::symbread()); - my @crumbs = ({text => mt("Course Content"), href => "Javascript:gonav('/adm/navmaps')"}, - {text => '...'}); - push @crumbs, {text => $maptitle} if ($maptitle - && $maptitle ne 'default.sequence' - && $maptitle ne $coursetitle); - push @crumbs, {text => $restitle} if $restitle; - Apache::lonhtmlcommon::clear_breadcrumbs(); - Apache::lonhtmlcommon::add_breadcrumb(@crumbs); - $breadcrumb .= Apache::lonhtmlcommon::breadcrumbs(undef,undef,0); + my $contentstext; + if ($env{'course.'.$env{'request.course.id'}.'.type'} eq 'Community') { + $contentstext = &mt('Community Contents'); + } else { + $contentstext = &mt('Course Contents'); + } + my @crumbs = ({text => $contentstext, + href => "Javascript:gonav('/adm/navmaps')"}); + + if ($mapurl ne $env{'course.'.$env{'request.course.id'}.'.url'}) { + push(@crumbs, {text => '...', + no_mt => 1}); + } + + push @crumbs, {text => $maptitle, no_mt => 1} if ($maptitle + && $maptitle ne 'default.sequence' + && $maptitle ne $coursetitle); + + push @crumbs, {text => $restitle, no_mt => 1} if $restitle; + + &Apache::lonhtmlcommon::clear_breadcrumbs(); + &Apache::lonhtmlcommon::add_breadcrumb(@crumbs); + #$breadcrumb .= &Apache::lonhtmlcommon::breadcrumbs(undef,undef,0); + unless (($env{'request.state'} eq 'edit') || ($newmail) || + ($env{'request.state'} eq 'construct') || + ($env{'form.register'})) { + $separator = &Apache::loncommon::head_subbox(); + } # } if ($env{'request.state'} eq 'construct') { @@ -417,7 +627,7 @@ sub innerregister { my $tableend = ( $noremote ? '' : ''); # ============================================================================= # ============================ This is for URLs that actually can be registered - if (($env{'request.noversionuri'}!~m|^/(res/)*adm/|) || ($forcereg)) { + if (($env{'request.noversionuri'}!~m{^/(res/)*adm/}) || ($forcereg)) { # -- This applies to homework problems for users with grading privileges my $crs='/'.$env{'request.course.id'}; if ($env{'request.course.sec'}) { @@ -458,6 +668,9 @@ sub innerregister { } if ($env{'user.author'}) { if ($env{'request.role'}=~/^(aa|ca|au)/) { +# +# We have the role of an author +# # Set defaults for authors my ($top,$bottom) = ('con-','struct'); my $action = "go('/priv/".$env{'user.name'}."');"; @@ -486,6 +699,11 @@ sub innerregister { $noeditbutton = 0; } } +# +# We are an author for some stuff, but currently do not have the role of author. +# Figure out if we have authoring privileges for the resource we are looking at. +# This should maybe become a privilege check in lonnet +# ## ## Determine if user can edit url. ## @@ -515,10 +733,22 @@ sub innerregister { } # Finally, turn the button on or off if ($cfile && !$const_space) { - $editbutton=&switch - ('','',6,1,'pcstr.gif','edit[_1]','resource[_2]', + my $nocrsedit; + # Suppress display where CC has switched to student role. + if ($env{'request.course.id'}) { + unless(&Apache::lonnet::allowed('mdc', + $env{'request.course.id'})) { + $nocrsedit = 1; + } + } + if ($nocrsedit) { + $editbutton=&clear(6,1); + } else { + $editbutton=&switch + ('','',6,1,'pcstr.gif','edit[_1]','resource[_2]', "go('".$cfile."');","Edit this resource"); - $noeditbutton = 0; + $noeditbutton = 0; + } } elsif ($editbutton eq '') { $editbutton=&clear(6,1); } @@ -544,6 +774,9 @@ sub innerregister { # Prepare the rest of the buttons my $menuitems; if ($const_space) { +# +# We are in construction space +# my ($uname,$thisdisfn) = ($env{'request.filename'}=~m|^/home/([^/]+)/public_html/(.*)|); my $currdir = '/priv/'.$uname.'/'.$thisdisfn; @@ -553,6 +786,9 @@ sub innerregister { $currdir =~ s|[^/]+$||; my $cleandisfn = &Apache::loncommon::escape_single($thisdisfn); my $esc_currdir = &Apache::loncommon::escape_single($currdir); +# +# Probably should be in mydesk.tab +# $menuitems=(< 0){ $menuitems.="&anno-[_1]&tations[_1]&annotate()&"; $menuitems.="Make notes and annotations about this resource&&1\n"; + unless ($noremote) { + my $showreqcrs = &check_for_rcrs(); + if ($showreqcrs) { + $menuitems.="s&8&1&rcrs.gif&request[_1]&course[_16]". + "&go('/adm/requestcourse')&Course requests\n"; + } + } unless ($env{'request.noversionuri'}=~/\/(bulletinboard|smppg|navmaps|syllabus|aboutme)(\?|$)/) { - if (!$env{'request.enc'}) { + if ((!$env{'request.enc'}) && ($env{'request.noversionuri'} !~ m{^/adm/wrapper/ext/})) { $menuitems.=(< -$inlineremote[21] $inlineremote[23] -ENDARROWSINLINE - if (&hidden_button_check() ne 'yes') { - $inlinebuttons .= (< -ENDINLINEICONS - } - } else { - if ($inlineremote[21] ne '' || $inlineremote[23] ne '') { - $inlinebuttons=(<$inlineremote[21] $inlineremote[23] -ENDFIRSTLINE - } - if (&hidden_button_check() ne 'yes') { - foreach my $row (6..9) { - if ($inlineremote[${row}.'1'] ne '' - || $inlineremote[$row.'2'] ne '' - || $inlineremote[$row.'3'] ne '') { - $inlinebuttons .= <<"ENDLINE"; -$inlineremote["${row}1"]$inlineremote["${row}2"]$inlineremote["${row}3"] -ENDLINE - } - } - } - } - } + if ($addremote) { + + #SD START (work in progress!) + Apache::lonhtmlcommon::clear_breadcrumb_tools(); + # Arrows for navigation + Apache::lonhtmlcommon::add_breadcrumb_tool( 'A', $inlineremote[21] ); + Apache::lonhtmlcommon::add_breadcrumb_tool( 'A', $inlineremote[23] ); + if(hidden_button_check() ne 'yes'){ + # notes + Apache::lonhtmlcommon::add_breadcrumb_tool( 'B', $inlineremote[93]); + # bookmark + Apache::lonhtmlcommon::add_breadcrumb_tool( 'B', $inlineremote[91]); + # evaluate + Apache::lonhtmlcommon::add_breadcrumb_tool( 'B', $inlineremote[81]); + # feedback + Apache::lonhtmlcommon::add_breadcrumb_tool( 'B', $inlineremote[82]); + # print + Apache::lonhtmlcommon::add_breadcrumb_tool( 'B', $inlineremote[83]); + # metadata + Apache::lonhtmlcommon::add_breadcrumb_tool( 'B', $inlineremote[63]); + + # ? + Apache::lonhtmlcommon::add_breadcrumb_tool( 'C', $inlineremote[61]); + # ? + Apache::lonhtmlcommon::add_breadcrumb_tool( 'C', $inlineremote[71]); + # ? + Apache::lonhtmlcommon::add_breadcrumb_tool( 'C', $inlineremote[72]); + # ? + Apache::lonhtmlcommon::add_breadcrumb_tool( 'C', $inlineremote[73]); + # ? + Apache::lonhtmlcommon::add_breadcrumb_tool( 'C', $inlineremote[92]); + + } + + #SD END +# # Registered, textual output +# if ( $env{'environment.icons'} eq 'iconsonly' ) { +# $inlinebuttons = (< +#$inlineremote[21] $inlineremote[23] +#ENDARROWSINLINE +# if ( &hidden_button_check() ne 'yes' ) { +# $inlinebuttons .= (< +#ENDINLINEICONS +# } +# } else { # not iconsonly +# if ( $inlineremote[21] ne '' || $inlineremote[23] ne '' ) { +# $inlinebuttons = (<$inlineremote[21] $inlineremote[23] +#ENDFIRSTLINE +# } +# if ( &hidden_button_check() ne 'yes' ) { +# foreach my $row ( 6 .. 9 ) { +# if ( $inlineremote[ ${row} . '1' ] ne '' +# || $inlineremote[ $row . '2' ] ne '' +# || $inlineremote[ $row . '3' ] ne '' ) +# { +# $inlinebuttons .= <<"ENDLINE"; +#$inlineremote["${row}1"]$inlineremote["${row}2"]$inlineremote["${row}3"] +#ENDLINE +# } +# } +# } +# } + } + #SD see below + $breadcrumb = &Apache::lonhtmlcommon::breadcrumbs(undef,undef,0); $result =(< // BEGIN LON-CAPA Internal $timesync $breadcrumb -$tablestart -$inlinebuttons -$tableend + + + $newmail + @@ -687,6 +980,7 @@ ENDREGTEXT $result = (< +// ENDREGTHIS } @@ -729,7 +1024,7 @@ ENDREGTHIS } else { # ========================================== This can or will not be registered if ($noremote) { -# Not registered, textual +# Not registered $result= (< +// ENDDONOTREGTHIS } @@ -820,8 +1117,7 @@ sub unloadevents() { sub startupremote { my ($lowerurl)=@_; - if (($env{'browser.interface'} eq 'textual') || - ($env{'environment.remote'} eq 'off')) { + if ($env{'environment.remote'} eq 'off') { return (''); } # @@ -832,6 +1128,7 @@ sub startupremote { my $message=&mt('"Waiting for Remote Control window to load: "+[_1]','waited'); return(< +// ENDREMOTESTARTUP } @@ -889,18 +1187,21 @@ ENDREMOTESTARTUP sub setflags() { return(< +// ENDSETFLAGS } sub maincall() { - if (($env{'browser.interface'} eq 'textual') || - ($env{'environment.remote'} eq 'off')) { return ''; } + if ($env{'environment.remote'} eq 'off') { return ''; } return(< +// ENDMAINCALL } @@ -908,8 +1209,7 @@ ENDMAINCALL sub load_remote_msg { my ($lowerurl)=@_; - if (($env{'browser.interface'} eq 'textual') || - ($env{'environment.remote'} eq 'off')) { return ''; } + if ($env{'environment.remote'} eq 'off') { return ''; } my $esclowerurl=&escape($lowerurl); my $link=&mt('[_1]Continue[_2] on in Inline Menu mode' @@ -933,8 +1233,7 @@ sub get_menu_name { sub reopenmenu { - if (($env{'browser.interface'} eq 'textual') || - ($env{'environment.remote'} eq 'off')) { return ''; } + if ($env{'environment.remote'} eq 'off') { return ''; } my $menuname = &get_menu_name(); my $nothing = &Apache::lonhtmlcommon::javascript_nothing(); return('window.open('.$nothing.',"'.$menuname.'","",false);'); @@ -943,9 +1242,13 @@ sub reopenmenu { sub open { my $returnval=''; - if (($env{'browser.interface'} eq 'textual') || - ($env{'environment.remote'} eq 'off')) { - return ''; + if ($env{'environment.remote'} eq 'off') { + return + ''; } my $menuname = &get_menu_name(); @@ -958,11 +1261,13 @@ sub open { #} #ENDRESIZE # } - $returnval.=(< ENDOPEN return ''; } @@ -972,8 +1277,8 @@ ENDOPEN sub clear { my ($row,$col)=@_; - unless (($env{'browser.interface'} eq 'textual') || - ($env{'environment.remote'} eq 'off')) { + unless ($env{'environment.remote'} eq 'off') { + if (($row<1) || ($row>13)) { return ''; } return "\n".qq(window.status+='.';swmenu.clearbut($row,$col);); } else { $inlineremote[10*$row+$col]=''; @@ -998,23 +1303,11 @@ sub switch { my $idx=10*$row+$col; $category_members{$cat}.=':'.$idx; - unless (($env{'browser.interface'} eq 'textual') || - ($env{'environment.remote'} eq 'off')) { + unless ($env{'environment.remote'} eq 'off') { + if (($row<1) || ($row>13)) { return ''; } # Remote return "\n". qq(window.status+='.';swmenu.switchbutton($row,$col,"$img","$top","$bot","$act","$desc");); - } elsif ($env{'browser.interface'} eq 'textual') { -# Accessibility - if ($nobreak==2) { return ''; } - my $text=$top.' '.$bot; - $text=~s/\s*\-\s*//gs; - if ($nobreak) { - $inlineremote[$idx]= - ''.$text.''; - } else { - $inlineremote[$idx]="\n
          ". - $desc.' '.$text.''; - } } else { # Inline Remote if ($env{'environment.icons'} ne 'classic') { @@ -1027,9 +1320,9 @@ sub switch { my $pic= ''.$text.''; + '" align="'.($nobreak==3?'right':'left').'" class="LC_icon" />'; if ($env{'browser.interface'} eq 'faketextual') { -# Accessibility +# Main Menu if ($nobreak==3) { $inlineremote[$idx]="\n". ''.$text. @@ -1053,7 +1346,7 @@ sub switch { $inlineremote[$idx]=''.$pic.''; } else { $inlineremote[$idx]= - ''.$pic. + ''.$pic. ''.$desc.''; } } @@ -1077,50 +1370,83 @@ sub secondlevel { sub openmenu { my $menuname = &get_menu_name(); - if (($env{'browser.interface'} eq 'textual') || - ($env{'environment.remote'} eq 'off')) { return ''; } + if ($env{'environment.remote'} eq 'off') { return ''; } my $nothing = &Apache::lonhtmlcommon::javascript_nothing(); return "window.open(".$nothing.",'".$menuname."');"; } sub inlinemenu { + my ($context,$switcher) = @_; undef(@inlineremote); undef(%category_members); - &rawconfig(1); - my $output=''; - for (my $col=1; $col<=2; $col++) { - $output.='
          '; - for (my $row=1; $row<=8; $row++) { - foreach my $cat (keys(%category_members)) { - if ($category_positions{$cat} ne "$col,$row") { next; } - #$output.=''; - $output.='
          '; - $output.='

          '.&mt($category_names{$cat}).'

          '; - $output.='
          '.&mt($category_names{$cat}).'
          '; - my %active=(); - foreach my $menu_item (split(/\:/,$category_members{$cat})) { - if ($inlineremote[$menu_item]) { - $active{$menu_item}=1; - } - } - foreach my $item (sort(keys(%active))) { - $output.=$inlineremote[$item]; - } - $output.='
          '; - $output.=''; + my $output; + if ($context eq 'gcicustom') { + my $createtext = &mt('Create Concept Test'); + if ($switcher) { + $createtext = &mt('Create New Test'); + } + $output=''. + ''; + if (($env{'request.course.id'}) && + (&Apache::lonnet::allowed('mdc',$env{'request.course.id'}))) { + $output.= ''; + } + $output.='
          '. + '
          '. + '

          '.&mt('Utilities').'

          '. + ''; + if ($switcher) { + $output .= ''; + } + $output .= '
          choose role'.$createtext.'
          choose role'.$switcher.'
          communication'.&mt('Send/Display Messages').'
          '. + '
          '. + '

          '.&mt('Test Management').'

          '. + ''."\n". + ''."\n". + ''."\n". + '
          course contentsConcept Test Contents
          assemble testAssemble Concept Test
          user privs'.&mt('Manage Enrollment').'
          what is new'.&mt("What's New?").'
          '; + } else { + # calling rawconfig with "1" will evaluate mydesk.tab, + # even if there is no active remote control + &rawconfig(1); + $output=''; + for (my $col=1; $col<=2; $col++) { + $output.='"; + $output.=""; + } + $output.="
          '; + for (my $row=1; $row<=8; $row++) { + foreach my $cat (keys(%category_members)) { + if ($category_positions{$cat} ne "$col,$row") { next; } + $output.='
          '; + $output.='

          '.&mt($category_names{$cat}).'

          '; + $output.=''; + my %active=(); + foreach my $menu_item (split(/\:/,$category_members{$cat})) { + if ($inlineremote[$menu_item]) { + $active{$menu_item}=1; + } + } + foreach my $item (sort(keys(%active))) { + $output.=$inlineremote[$item]; + } + $output.='
          '; + $output.='
          '; + } } - } - $output.="
          "; } - $output.="
          "; return $output; } sub rawconfig { +# +# This evaluates mydesk.tab +# Need to add more positions and more privileges to deal with all +# menu items. +# my $textualoverride=shift; my $output=''; - unless (($env{'browser.interface'} eq 'textual') || - ($env{'environment.remote'} eq 'off')) { + unless ($env{'environment.remote'} eq 'off') { $output.= "window.status='Opening Remote Control';var swmenu=".&openmenu(). "\nwindow.status='Configuring Remote Control ';"; @@ -1133,12 +1459,14 @@ sub rawconfig { my $show_course=&Apache::loncommon::show_course(); my $author=$env{'user.author'}; my $crs=''; + my $crstype=''; if ($env{'request.course.id'}) { $crs='/'.$env{'request.course.id'}; if ($env{'request.course.sec'}) { $crs.='_'.$env{'request.course.sec'}; } $crs=~s/\_/\//g; + $crstype = &Apache::loncommon::course_type(); } my $pub=($env{'request.state'} eq 'published'); my $con=($env{'request.state'} eq 'construct'); @@ -1148,13 +1476,17 @@ sub rawconfig { my ($row,$col,$pro,$prt,$img,$top,$bot,$act,$desc,$cat)=split(/\:/,$line); $prt=~s/\$uname/$uname/g; $prt=~s/\$udom/$udom/g; - $prt=~s/\$crs/$crs/g; + if ($prt =~ /\$crs/) { + next unless ($env{'request.course.id'}); + next if ($crstype eq 'Community'); + $prt=~s/\$crs/$crs/g; + } elsif ($prt =~ /\$cmty/) { + next unless ($env{'request.course.id'}); + next if ($crstype ne 'Community'); + $prt=~s/\$cmty/$crs/g; + } $prt=~s/\$requested_domain/$requested_domain/g; if ($category_names{$cat}!~/\w/) { $cat='oth'; } - my $type = &Apache::loncommon::course_type(); - if ($type eq 'Group') { - $desc = &convert_menu_function($desc,$type); - } if ($pro eq 'clear') { $output.=&clear($row,$col); } elsif ($pro eq 'any') { @@ -1181,26 +1513,69 @@ sub rawconfig { $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat); } } elsif (($pro=~/^p(\w+)/) && ($prt)) { - if (&Apache::lonnet::allowed($1,$prt)) { + my $priv = $1; + if ($priv =~ /^mdc(Course|Community)/) { + if ($crstype eq $1) { + $priv = 'mdc'; + } else { + next; + } + } + if (&Apache::lonnet::allowed($priv,$prt)) { $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat); } - } elsif ($pro eq 'course') { - if ($env{'request.course.fn'}) { + } elsif ($pro eq 'course') { + if (($env{'request.course.fn'}) && ($crstype ne 'Community')) { $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat); } + } elsif ($pro eq 'community') { + if (($env{'request.course.fn'}) && ($crstype eq 'Community')) { + $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat); + } } elsif ($pro =~ /^courseenv_(.*)$/) { my $key = $1; - if ($env{'course.'.$env{'request.course.id'}.'.'.$key}) { - $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat); + if ($crstype ne 'Community') { + my $coursepref = $env{'course.'.$env{'request.course.id'}.'.'.$key}; + if ($key eq 'canuse_pdfforms') { + if ($env{'request.course.id'} && $coursepref eq '') { + my %domdefs = &Apache::lonnet::get_domain_defaults($env{'course.'.$env{'request.course.id'}.'.domain'}); + $coursepref = $domdefs{'canuse_pdfforms'}; + } + } + if ($coursepref) { + $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat); + } + } + } elsif ($pro =~ /^communityenv_(.*)$/) { + my $key = $1; + if ($crstype eq 'Community') { + my $coursepref = $env{'course.'.$env{'request.course.id'}.'.'.$key}; + if ($key eq 'canuse_pdfforms') { + if ($env{'request.course.id'} && $coursepref eq '') { + my %domdefs = &Apache::lonnet::get_domain_defaults($env{'course.'.$env{'request.course.id'}.'.domain'}); + $coursepref = $domdefs{'canuse_pdfforms'}; + } + } + if ($coursepref) { + $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat); + } } } elsif ($pro =~ /^course_(.*)$/) { # Check for permissions inside of a course - if (($env{'request.course.id'}) && + if (($env{'request.course.id'}) && ($crstype ne 'Community') && (&Apache::lonnet::allowed($1,$env{'request.course.id'}. ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:'')) )) { $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat); } + } elsif ($pro =~ /^community_(.*)$/) { + # Check for permissions inside of a community + if (($env{'request.course.id'}) && ($crstype eq 'Community') && + (&Apache::lonnet::allowed($1,$env{'request.course.id'}. + ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:'')) + )) { + $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat); + } } elsif ($pro eq 'author') { if ($author) { if ((($prt eq 'rca') && ($env{'request.role'}=~/^ca/)) || @@ -1233,16 +1608,14 @@ sub rawconfig { $output.=&clear($row,$col); next; } - } elsif ($prt eq 'reqcrs') { - my $showreqcrs = 0; - foreach my $type ('official','unofficial') { - if (&Apache::lonnet::usertools_access($env{'user.name'}, - $env{'user.domain'}, - $type,undef,'requestcourses')) { - $showreqcrs = 1; - last; - } + } elsif (($prt eq 'reqcrsnsc') || ($prt eq 'reqcrsshc')) { + if (($prt eq 'reqcrsnsc') && ($show_course)) { + next; } + if (($prt eq 'reqcrsshc') && (!$show_course)) { + next; + } + my $showreqcrs = &check_for_rcrs(); if (!$showreqcrs) { $output.=&clear($row,$col); next; @@ -1253,8 +1626,7 @@ sub rawconfig { $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat); } } - unless (($env{'browser.interface'} eq 'textual') || - ($env{'environment.remote'} eq 'off')) { + unless ($env{'environment.remote'} eq 'off') { $output.="\nwindow.status='Synchronizing Time';swmenu.syncclock(1000*".time.");\nwindow.status='Remote Control Configured.';"; if (&Apache::lonmsg::newmail()) { $output.='swmenu.setstatus("you have","messages");'; @@ -1264,14 +1636,36 @@ sub rawconfig { return $output; } +sub check_for_rcrs { + my $showreqcrs = 0; + my @reqtypes = ('official','unofficial','community'); + foreach my $type (@reqtypes) { + if (&Apache::lonnet::usertools_access($env{'user.name'}, + $env{'user.domain'}, + $type,undef,'requestcourses')) { + $showreqcrs = 1; + last; + } + } + if (!$showreqcrs) { + foreach my $type (@reqtypes) { + if ($env{'environment.reqcrsotherdom.'.$type} ne '') { + $showreqcrs = 1; + last; + } + } + } + return $showreqcrs; +} + # ======================================================================= Close sub close { - if (($env{'browser.interface'} eq 'textual') || - ($env{'environment.remote'} eq 'off')) { return ''; } + if ($env{'environment.remote'} eq 'off') { return ''; } my $menuname = &get_menu_name(); return(< +// ENDCLOSE } @@ -1308,16 +1703,95 @@ function gonav(url) { NAVCONTROL } +sub dc_popup_js { + my %lt = &Apache::lonlocal::texthash( + more => '(More ...)', + less => '(Less ...)', + ); + return <<"END"; + +function showCourseID() { + document.getElementById('dccid').style.display='block'; + document.getElementById('dccid').style.textAlign='left'; + document.getElementById('dccid').style.textFace='normal'; + document.getElementById('dccidtext').innerHTML ='$lt{'less'}'; + return; +} + +function hideCourseID() { + document.getElementById('dccid').style.display='none'; + document.getElementById('dccidtext').innerHTML ='$lt{'more'}'; + return; +} + +END + +} + sub utilityfunctions { - my $caller = shift; - unless (($env{'browser.interface'} eq 'textual') || - ($env{'environment.remote'} eq 'off') || ($caller eq '/adm/menu')) { return ''; } + my ($caller,$custommenu) = @_; + unless ($env{'environment.remote'} eq 'off' || + $caller eq '/adm/menu') { + return ''; } + + my $gcimenujs; + if ($custommenu) { + my %concepttests = &Apache::loncommon::existing_gcitest_courses(); + my $managetesturl = '/adm/menu'; + my $createtesturl = '/adm/requestcourse'; + if (($env{'request.course.id'}) && + ($env{'course.'.$env{'request.course.id'}.'.domain'} eq 'gci')) { + my @items = keys(%concepttests); + if (@items== 1) { + my $newrole = $items[0]; + $newrole =~ s{_}{/}; + $managetesturl = '/adm/roles?selectrole=1&cc./'.$newrole.'=1'; + } else { + $managetesturl = '/adm/roles?selectrole=1&cm=1&orgurl=%2fadm%2fmenu'; + } + } + if ($env{'request.course.id'}) { + $createtesturl = '/adm/roles?selectrole=1&cm=1&orgurl=%2fadm%2frequestcourse'; + } + $gcimenujs = <<"ENDCUSTOM"; + +function switchpage(caller) { + if (caller == 'review') { + document.location.href = '/adm/roles?selectrole=1&st./gci/9615072b469884921gcil1=1'; + } + if (caller == 'submit') { + document.location.href = '/adm/roles?selectrole=1&st./gci/1H96711d710194bfegcil1=1'; + } + if (caller == 'createtest') { + document.location.href = '$createtesturl'; + } + if (caller == 'managetest') { + document.location.href = '$managetesturl'; + } + return; +} + +ENDCUSTOM + } + my $currenturl=&Apache::lonnet::clutter(&Apache::lonnet::fixversion((split(/\?/,$env{'request.noversionuri'}))[0])); + if ($currenturl =~ m{^/adm/wrapper/ext/}) { + if ($env{'request.external.querystring'}) { + $currenturl .= ($currenturl=~/\?/)?'&':'?'.$env{'request.external.querystring'}; + } + } $currenturl=&Apache::lonenc::check_encrypt(&unescape($currenturl)); my $currentsymb=&Apache::lonenc::check_encrypt($env{'request.symb'}); my $nav_control=&nav_control_js(); + my $dc_popup_cid; + if ($env{'user.adv'} && exists($env{'user.role.dc./'. + $env{'course.'.$env{'request.course.id'}. + '.domain'}.'/'})) { + $dc_popup_cid = &dc_popup_js(); + } + my $start_page_annotate = &Apache::loncommon::start_page('Annotator',undef, {'only_body' => 1, @@ -1345,6 +1819,9 @@ return (< 1) { $role_selector = &jump_to_role($cdom,$cnum,\%seccount,\%courseroles); $role_selector .= '
          '."\n". ''."\n". + &HTML::Entities::encode($ENV{'REQUEST_URI'}).'" />'."\n". ''."\n". ''."\n". ''."\n". @@ -1713,8 +2196,9 @@ sub jump_to_role { ' numsec['.$i.'] = "'.$seccount->{$items[$i]}.'";'."\n"; } } - my $output = <<"END"; + return <<"END"; END - return $output; } @@ -1797,34 +2279,34 @@ END BEGIN { if (! defined($readdesk)) { - { - my $tabfile = $Apache::lonnet::perlvar{'lonTabDir'}.'/mydesk.tab'; - if ( CORE::open( my $config,"<$tabfile") ) { - while (my $configline=<$config>) { - $configline=(split(/\#/,$configline))[0]; - $configline=~s/^\s+//; - chomp($configline); + { + my $tabfile = $Apache::lonnet::perlvar{'lonTabDir'}.'/mydesk.tab'; + if ( CORE::open( my $config,"<$tabfile") ) { + while (my $configline=<$config>) { + $configline=(split(/\#/,$configline))[0]; + $configline=~s/^\s+//; + chomp($configline); if ($configline=~/^cat\:/) { - my @entries=split(/\:/,$configline); - $category_positions{$entries[2]}=$entries[1]; - $category_names{$entries[2]}=$entries[3]; - } elsif ($configline) { - push(@desklines,$configline); - } - } - CORE::close($config); - } - } - $readdesk='done'; + my @entries=split(/\:/,$configline); + $category_positions{$entries[2]}=$entries[1]; + $category_names{$entries[2]}=$entries[3]; + } elsif ($configline=~/^prim\:/) { + my @entries = (split(/\:/, $configline))[1..5]; + push @primary_menu, \@entries; + } elsif ($configline=~/^scnd\:/) { + my @entries = (split(/\:/, $configline))[1..5]; + push @secondary_menu, \@entries; + } elsif ($configline) { + push(@desklines,$configline); + } + } + CORE::close($config); + } + } + $readdesk='done'; } } 1; __END__ - - - - - -