--- loncom/interface/lonmenu.pm 2012/05/23 00:29:22 1.369.2.5
+++ loncom/interface/lonmenu.pm 2012/05/15 01:41:27 1.370
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines to control the menu
#
-# $Id: lonmenu.pm,v 1.369.2.5 2012/05/23 00:29:22 raeburn Exp $
+# $Id: lonmenu.pm,v 1.370 2012/05/15 01:41:27 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -26,6 +26,8 @@
# http://www.lon-capa.org/
#
#
+# There is one parameter controlling the action of this module:
+#
=head1 NAME
@@ -33,8 +35,7 @@ Apache::lonmenu
=head1 SYNOPSIS
-Loads contents of /home/httpd/lonTabs/mydesk.tab,
-used to generate inline menu, and Main Menu page.
+Coordinates the response to clicking an image.
This is part of the LearningOnline Network with CAPA project
described at http://www.lon-capa.org.
@@ -73,19 +74,10 @@ It is set to 'done' in the BEGIN block o
=item @primary_menu
The elements of this array reference arrays that are made up of the components
-of those lines of mydesk.tab that start with prim:.
+of those lines of mydesk.tab that start with prim.
It is used by primary_menu() to generate the corresponding menu.
It gets filled in the BEGIN block of this module.
-=item %primary_sub_menu
-
-The keys of this hash reference are the names of items in the primary_menu array
-which have sub-menus. For each key, the corresponding value is a reference to
-an array containing components extracted from lines in mydesk.tab which begin
-with primsub:.
-This hash, which is used by primary_menu to generate sub-menus, is populated in
-the BEGIN block.
-
=item @secondary_menu
The elements of this array reference arrays that are made up of the components
@@ -164,9 +156,10 @@ use Apache::lonlocal;
use Apache::lonmsg();
use LONCAPA qw(:DEFAULT :match);
use HTML::Entities();
+use Apache::lonwishlist();
use vars qw(@desklines %category_names %category_members %category_positions
- $readdesk @primary_menu %primary_submenu @secondary_menu %secondary_submenu);
+ $readdesk @primary_menu @secondary_menu);
my @inlineremote;
@@ -189,7 +182,7 @@ sub prep_menuitem {
# primary_menu() evaluates @primary_menu and returns XHTML for the menu
# that contains following links:
-# About, Message, Personal, Roles, Help, Logout
+# About, Message, Roles, Help, Logout
# @primary_menu is filled within the BEGIN block of this module with
# entries from mydesk.tab
sub primary_menu {
@@ -219,54 +212,8 @@ sub primary_menu {
next if $$menuitem[4] eq 'courses' ##'Roles' wanted
&& !&Apache::loncommon::show_course(); ##
- my $title = $menuitem->[3];
- if (defined($primary_submenu{$title})) {
- my ($link,$target,$numsub);
- if ($menuitem->[0] ne '') {
- $link = $menuitem->[0];
- $target = '_top';
- } else {
- $link = '#';
- }
- if (ref($primary_submenu{$title}) eq 'ARRAY') {
- $numsub = @{$primary_submenu{$title}};
- if ($numsub) {
- $title =
- ''.$title.
- ''.
- ' ▼';
- }
- }
- $menu .= '
'.
- ''.$title.'';
- if ($numsub) {
- $menu .= '';
- foreach my $item (@{$primary_submenu{$menuitem->[3]}}) {
- if (ref($item) eq 'ARRAY') {
- if ($item->[2] eq 'wishlist') {
- next unless ((&Apache::lonnet::allowed('bre',"/res/$env{'user.domain'}/")) ||
- (&Apache::lonnet::allowed('bro',"/res/$env{'user.domain'}/")));
- } elsif ($item->[2] eq 'reqcrs') {
- next unless(&check_for_rcrs());
- } elsif (($item->[2] eq 'portfolio') ||
- ($item->[2] eq 'blog')) {
- if (!&Apache::lonnet::usertools_access(
- $env{'user.name'},
- $env{'user.domain'},
- $item->[2],undef,'tools')) {
- next;
- }
- }
- $menu .= '- '.
- ''.
- $item->[1].'
';
- }
- }
- $menu .= '
';
- }
- $menu .= '';
- } elsif ($$menuitem[3] eq 'Help') { # special treatment for helplink
+
+ if ($$menuitem[3] eq 'Help') { # special treatment for helplink
if ($public) {
my $origmail = $Apache::lonnet::perlvar{'lonSupportEMail'};
my $defdom = &Apache::lonnet::default_login_domain();
@@ -322,13 +269,12 @@ sub secondary_menu {
? "/$env{'request.course.sec'}"
: '');
my $canedit = &Apache::lonnet::allowed('mdc', $env{'request.course.id'});
- my $canviewroster = $env{'course.'.$env{'request.course.id'}.'.student_classlist_view'};
- my $canviewgrps = &Apache::lonnet::allowed('vcg', $crs_sec);
- my $canmodifyuser = &Apache::lonnet::allowed('cst', $crs_sec);
- my $canviewwnew = &Apache::lonnet::allowed('whn', $crs_sec);
+ my $canviewgrps = &Apache::lonnet::allowed('vcg', $crs_sec);
+ my $canmodifyuser = &Apache::lonnet::allowed('cst', $crs_sec);
+ my $canviewwnew = &Apache::lonnet::allowed('whn', $crs_sec);
my $canmodpara = &Apache::lonnet::allowed('opa', $crs_sec);
my $canvgr = &Apache::lonnet::allowed('vgr', $crs_sec);
- my $canmgr = &Apache::lonnet::allowed('mgr', $crs_sec);
+ my $canmgr = &Apache::lonnet::allowed('mgr', $crs_sec);
my $author = &getauthor();
my %groups = &Apache::lonnet::get_active_groups(
@@ -344,10 +290,6 @@ sub secondary_menu {
&& !$env{'request.course.id'};
next if $$menuitem[4] =~ /^mdc/
&& !$canedit;
- next if $$menuitem[4] eq 'mdcCourse'
- && ($crstype eq 'Community');
- next if $$menuitem[4] eq 'mdcCommunity'
- && ($crstype eq 'Course');
next if $$menuitem[4] eq 'nvgr'
&& $canvgr;
next if $$menuitem[4] eq 'vgr'
@@ -355,7 +297,7 @@ sub secondary_menu {
next if $$menuitem[4] eq 'cst'
&& !$canmodifyuser;
next if $$menuitem[4] eq 'ncst'
- && ($canmodifyuser || !$canviewroster);
+ && $canmodifyuser;
next if $$menuitem[4] eq 'mgr'
&& !$canmgr;
next if $$menuitem[4] eq 'nmgr'
@@ -364,76 +306,19 @@ sub secondary_menu {
&& !$canviewwnew;
next if $$menuitem[4] eq 'opa'
&& !$canmodpara;
- next if $$menuitem[4] eq 'nvcg'
- && ($canviewgrps || !%groups);
+ next if $$menuitem[4] =~ /showgroups$/
+ && !$canviewgrps
+ && !%groups;
next if $$menuitem[4] eq 'author'
&& !$author;
- my $title = $menuitem->[3];
- if (defined($secondary_submenu{$title})) {
- my ($link,$target,$numsub);
- if ($menuitem->[0] ne '') {
- $link = $menuitem->[0];
- $target = '_top';
- } else {
- $link = '#';
- }
-
- my @scndsub;
- if (ref($secondary_submenu{$title}) eq 'ARRAY') {
- $numsub = 0;
- foreach my $item (@{$secondary_submenu{$title}}) {
- if (ref($item) eq 'ARRAY') {
- next if ($item->[2] eq 'vgr' && !$canvgr);
- next if ($item->[2] eq 'opa' && !$canmodpara);
- next if ($item->[2] eq 'cst' && !$canmodifyuser);
- next if ($item->[2] eq 'mgr' && !$canmgr);
- next if ($item->[2] eq 'vcg' && !$canviewgrps);
- push(@scndsub,$item);
- $numsub ++;
- }
- }
- if ($numsub) {
- $title =
- ''.$title.
- ''.
- ' ▼';
- }
- }
- $menu .= ''.
- ''.$title.'';
- if ($numsub) {
- $menu .= '';
- my $count = 0;
- foreach my $item (@scndsub) {
- $count ++;
- if (ref($item) eq 'ARRAY') {
- my $borderbot;
- my ($padtop,$padbot) = (0,0);
- if ($count == 1) {
- $padtop = '5px';
- }
- if ($count == $numsub) {
- $padbot = '5px';
- $borderbot = 'border-bottom:1px solid black;';
- }
- $menu .= '- '.
- $item->[1].'
';
- }
- }
- $menu .= '
';
- }
- $menu .= '';
- } elsif ($$menuitem[3] eq 'Roles' && $env{'request.course.id'}) {
+ 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"
+ $menu .= $roles_selector ? "$roles_selector"
: '';
} else {
$menu .= &prep_menuitem(\@$menuitem);
@@ -743,9 +628,14 @@ c&6&3
c&8&1
c&8&2
s&8&3&prt.png&Print&printout[_1]&gopost('/adm/printout',currentURL)&Prepare a printable document
-s&9&1&sbkm.png&Bookmark&set[_1]bookmark[_2]&set_bookmark()&Set a bookmark for this resource&&1
-
ENDMENUITEMS
+ if (&Apache::lonnet::allowed('bre', $env{'request.course.id'}) eq 'F' && $env{'request.uri'} =~ /^\/res/) {
+ # wishlist is only available for users with access to resource-pool
+ # and links can only be set for resources within the resource-pool
+ $menuitems .= (<');
- }
-#
-# The Remote actually gets launched!
-#
- my $configmenu=&rawconfig();
- my $esclowerurl=&escape($lowerurl);
- my $message=&mt('"Waiting for Remote Control window to load: "+[_1]','waited');
- return(<
-//
-
-ENDREMOTESTARTUP
-}
-
-sub setflags() {
- return(<
-//
-
-ENDSETFLAGS
-}
-
-sub maincall() {
- if ($env{'environment.remote'} eq 'off') { return ''; }
- return(<
-//
-
-ENDMAINCALL
-}
-
-sub load_remote_msg {
- my ($lowerurl)=@_;
-
- if ($env{'environment.remote'} eq 'off') { return ''; }
-
- my $esclowerurl=&escape($lowerurl);
- my $link=&mt('[_1]Continue[_2] on in Inline Menu mode'
- ,''
- ,'');
- return(<
-
-
-$link
-ENDREMOTEFORM
-}
-
-sub get_menu_name {
- my $hostid = $Apache::lonnet::perlvar{'lonHostID'};
- $hostid =~ s/\W//g;
- return 'LCmenu'.$hostid;
-}
-
-
-sub reopenmenu {
- if ($env{'environment.remote'} eq 'off') { return ''; }
- my $menuname = &get_menu_name();
- my $nothing = &Apache::lonhtmlcommon::javascript_nothing();
- return('window.open('.$nothing.',"'.$menuname.'","",false);');
-}
-
-
-sub open {
- my $returnval='';
- if ($env{'environment.remote'} eq 'off') {
- return
- '';
- }
- my $menuname = &get_menu_name();
-
-# unless (shift eq 'unix') {
-# resizing does not work on linux because of virtual desktop sizes
-# $returnval.=(<
-ENDOPEN
- return '';
-}
-
-
# ================================================================== Raw Config
sub clear {
@@ -1338,28 +1076,6 @@ sub check_for_rcrs {
return $showreqcrs;
}
-# ======================================================================= Close
-
-sub close {
- if ($env{'environment.remote'} eq 'off') { return ''; }
- my $menuname = &get_menu_name();
- return(<
-//
-
-ENDCLOSE
-}
-
sub dc_popup_js {
my %lt = &Apache::lonlocal::texthash(
more => '(More ...)',
@@ -1413,15 +1129,6 @@ sub utilityfunctions {
my $end_page_annotate =
&Apache::loncommon::end_page({'js_ready' => 1});
- my $start_page_bookmark =
- &Apache::loncommon::start_page('Bookmarks',undef,
- {'only_body' => 1,
- 'js_ready' => 1,
- 'bgcolor' => '#BBBBBB',});
-
- my $end_page_bookmark =
- &Apache::loncommon::end_page({'js_ready' => 1});
-
my $confirm_switch = &mt("Editing requires switching to the resource's home server.").'\n'.
&mt('Switch server?');
@@ -1538,13 +1245,6 @@ function group_chat(group) {
grpchat=window.open(url,winName,'height=320,width=280,resizable=yes,location=no,menubar=no,toolbar=no');
}
-function edit_bookmarks() {
- go('');
- w_BookmarkPal_flag=1;
- bookmarkpal=window.open("/adm/bookmarks",
- "BookmarkPal", "width=500,height=505,scrollbars=0");
-}
-
function annotate() {
w_Annotator_flag=1;
annotator=window.open('','Annotator','width=365,height=265,scrollbars=0');
@@ -1558,40 +1258,17 @@ function annotate() {
annotator.document.close();
}
-(function (\$) {
- \$(document).ready(function () {
- \$.single=function(a){return function(b){a[0]=b;return a}}(\$([1]));
- /*\@cc_on
- if (!window.XMLHttpRequest) {
- \$('.LC_hoverable').each(function () {
- this.attachEvent('onmouseenter', function (evt) { \$.single(evt.srcElement).addClass('hover'); });
- this.attachEvent('onmouseleave', function (evt) { \$.single(evt.srcElement).removeClass('hover'); });
- });
- }
- \@*/
- });
-}(jQuery));
-
-function set_bookmark() {
- go('');
- clienttitle=document.title;
- clienthref=location.pathname;
- w_bmquery_flag=1;
- bmquery=window.open('','bmquery','width=365,height=165,scrollbars=0');
- bmquery.document.write(
- '$start_page_bookmark'
- +''
- +'$end_page_bookmark' );
- bmquery.document.close();
+function open_StoredLinks_Import(rat) {
+ var newWin;
+ if (rat) {
+ newWin = window.open('/adm/wishlist?inhibitmenu=yes&mode=import&rat='+rat,
+ 'wishlistImport','scrollbars=1,resizable=1,menubar=0');
+ }
+ else {
+ newWin = window.open('/adm/wishlist?inhibitmenu=yes&mode=import',
+ 'wishlistImport','scrollbars=1,resizable=1,menubar=0');
+ }
+ newWin.focus();
}
ENDUTILITY
@@ -2010,15 +1687,9 @@ BEGIN {
} elsif ($configline=~/^prim\:/) {
my @entries = (split(/\:/, $configline))[1..5];
push @primary_menu, \@entries;
- } elsif ($configline=~/^primsub\:/) {
- my ($parent,@entries) = (split(/\:/, $configline))[1..4];
- push (@{$primary_submenu{$parent}},\@entries);
} elsif ($configline=~/^scnd\:/) {
my @entries = (split(/\:/, $configline))[1..5];
push @secondary_menu, \@entries;
- } elsif ($configline=~/^scndsub\:/) {
- my ($parent,@entries) = (split(/\:/, $configline))[1..4];
- push (@{$secondary_submenu{$parent}},\@entries);
} elsif ($configline) {
push(@desklines,$configline);
}