[LON-CAPA-cvs] cvs: loncom /interface lonmenu.pm mydesk.tab

raeburn raeburn@source.lon-capa.org
Fri, 16 Oct 2009 23:35:08 -0000


This is a MIME encoded message

--raeburn1255736108
Content-Type: text/plain

raeburn		Fri Oct 16 23:35:08 2009 EDT

  Modified files:              
    /loncom/interface	lonmenu.pm mydesk.tab 
  Log:
  lonmenu.pm
  - Bug 6091. - do not use javascript in links in inline menu.
  - Coding style: & before subroutine calls.
                  unless(), ref()
  
  mydesk.tab
  - Bug 6091. - do not use javascript in links in inline menu.
  - Group -> Community
  - Catalog is for Courses and Communities.  
  
  
--raeburn1255736108
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20091016233508.txt"

Index: loncom/interface/lonmenu.pm
diff -u loncom/interface/lonmenu.pm:1.290 loncom/interface/lonmenu.pm:1.291
--- loncom/interface/lonmenu.pm:1.290	Fri Oct 16 20:22:06 2009
+++ loncom/interface/lonmenu.pm	Fri Oct 16 23:35:08 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Routines to control the menu
 #
-# $Id: lonmenu.pm,v 1.290 2009/10/16 20:22:06 raeburn Exp $
+# $Id: lonmenu.pm,v 1.291 2009/10/16 23:35:08 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -137,21 +137,20 @@
 use vars qw(@desklines %category_names %category_members %category_positions 
             $readdesk @primary_menu @secondary_menu);
 
-
 my @inlineremote;
 
 sub prep_menuitem {
-    my $menuitem = shift;
-    return '' unless ref $menuitem eq 'ARRAY';
+    my ($menuitem) = @_;
+    return '' unless(ref($menuitem) eq 'ARRAY');
     my $link;
     if ($$menuitem[1]) { # graphical Link
         $link = "<img class=\"LC_noBorder\""
-              . " src=\"" . Apache::loncommon::lonhttpdurl($$menuitem[1]) . "\""
-              . " alt=\"" . mt($$menuitem[2]) . "\" />";
+              . " src=\"" . &Apache::loncommon::lonhttpdurl($$menuitem[1]) . "\"" 
+              . " alt=\"" . &mt($$menuitem[2]) . "\" />";
     } else {             # textual Link
-        $link = mt($$menuitem[3]);
-    }     
-    return "<li><a href=\"javascript:$$menuitem[0]\">$link</a></li>";
+        $link = &mt($$menuitem[3]);
+    }
+    return '<li><a href="'.$$menuitem[0].'">'.$link.'</a></li>';
 }
 
 # primary_menu() evaluates @primary_menu and returns XHTML for the menu
@@ -166,9 +165,9 @@
     foreach my $menuitem (@primary_menu) {
         # evaluate conditions 
         next if    $$menuitem[4]        eq 'nonewmsg'  # show links depending on
-                && Apache::lonmsg::mynewmail();        # whether a new msg 
+                && &Apache::lonmsg::mynewmail();       # whether a new msg 
         next if    $$menuitem[4]        eq 'newmsg'    # arrived or not
-                && !Apache::lonmsg::mynewmail();       # 
+                && !&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
@@ -176,19 +175,23 @@
                 && $env{'user.name'}    ne 'public'    # only visible to public
                 && $env{'user.domain'}  ne 'public';   # users
         next if    $$menuitem[4]        eq 'roles'     ##show links depending on
-                && Apache::loncommon::show_course();   ##term 'Courses' or 
+                && &Apache::loncommon::show_course();  ##term 'Courses' or 
         next if    $$menuitem[4]        eq 'courses'   ##'Roles' wanted
-                && !Apache::loncommon::show_course();  ##
-
-
+                && !&Apache::loncommon::show_course(); ##
+        
+            
         if ($$menuitem[3] eq 'Help') { # special treatment for helplink
-            $menu .= '<li>'.Apache::loncommon::top_nav_help('Help').'</li>';
+            $menu .= '<li>'.&Apache::loncommon::top_nav_help('Help').'</li>';
         } else {
-            $menu .= prep_menuitem(\@$menuitem);
+            if (ref($menuitem) eq 'ARRAY') { 
+                my @items = @{$menuitem};
+                $items[0] = 'javascript:'.$menuitem;
+                $menu .= &prep_menuitem(\@items);
+            }
         }
-     }
+    }
 
-     return "<ol class=\"LC_primary_menu LC_right\">$menu</ol>";
+    return "<ol class=\"LC_primary_menu LC_right\">$menu</ol>";
 }
 
 
@@ -235,15 +238,25 @@
             $menu .= $roles_selector ? "<li>$roles_selector</li>"
                                      : '';
         } else {
-            $menu .= prep_menuitem(\@$menuitem);
+            if ($env{'environment.remotenavmap'} eq 'on') {
+                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 $escurl  = &escape( &Apache::lonenc::check_encrypt(
+                             $env{'request.noversionuri'}));
 
-        my $escsymb = escape( Apache::lonenc::check_encrypt(
-                            $env{'request.symb'})); 
+        my $escsymb = &escape( &Apache::lonenc::check_encrypt(
+                             $env{'request.symb'})); 
 
         if (    $env{'request.state'} eq 'construct'
             and (   $env{'request.noversionuri'} eq '' 
@@ -252,7 +265,7 @@
             ($escurl = $env{'request.filename'}) =~ 
                 s{^/home/([^/]+)/public_html/(.*)$}{/priv/$1/$2};
 
-            $escurl  = escape($escurl);
+            $escurl  = &escape($escurl);
         }    
         $menu =~ s/\[url\]/$escurl/g;
         $menu =~ s/\[symb\]/$escsymb/g;
@@ -354,7 +367,7 @@
         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);
@@ -415,7 +428,7 @@
     my $utility = &utilityfunctions();
 
     #Prepare the message link that indicates the arrival of new mail
-    my $messagelink = Apache::lonmsg::mynewmail() ? "Message (new)" : "Message";
+    my $messagelink = &Apache::lonmsg::mynewmail() ? "Message (new)" : "Message";
        $messagelink = '<a href="javascript:go(\'/adm/communicate\');">'
                       . mt($messagelink) .'</a>';
 
@@ -543,9 +556,9 @@
 
         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);
+        &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'})) {
Index: loncom/interface/mydesk.tab
diff -u loncom/interface/mydesk.tab:1.114 loncom/interface/mydesk.tab:1.115
--- loncom/interface/mydesk.tab:1.114	Sun Oct  4 17:47:21 2009
+++ loncom/interface/mydesk.tab	Fri Oct 16 23:35:08 2009
@@ -35,21 +35,21 @@
 #   possible conditions:
 #   - empty: 
 #   - showreturn: link is displayed if return link is wanted
-#   - mdcgroup: mdc from below and course is of type Group
-#   - mdcnogrp: mdc from below and course is a regular course
+#   - mdcCommunity: mdc from below and course is of type Community
+#   - mdcCourse: mdc from below and course is a regular course
 #   - showgroups: user is member of a group
 #   - always: show this link even if user hasn't selected a role
 #   - remotenav: remote navmap is activated
 #   - noremotenav: remote navmap is _not_ activated
 # prim:link:icon:alt:text:condition
-scnd:go('/adm/menu'):::Main Menu:always
-scnd:go('/adm/flip?postdata=return%3a'):::Return to Last Location:showreturn
-scnd:go('/adm/navmaps?postdata=[url]&amp;postsymb=[symb]'):::Course Contents:noremotenav
-scnd:gonav('/adm/navmaps?postdata=[url]&amp;postsymb=[symb]'):::Course Contents:remotenav
-scnd:go('/adm/coursedocs'):::Edit Course:mdcnogrp
-scnd:go('/adm/coursedocs'):::Group Documents:mdcgroup
-scnd:go('/adm/coursegroups'):::Groups:showgroups
-scnd:go(''):::Roles:
+scnd:/adm/menu:::Main Menu:always
+scnd:/adm/flip?postdata=return%3a:::Return to Last Location:showreturn
+scnd:/adm/navmaps?postdata=[url]&amp;postsymb=[symb]:::Course Contents:noremotenav
+scnd:/adm/navmaps?postdata=[url]&amp;postsymb=[symb]:::Course Contents:remotenav
+scnd:/adm/coursedocs:::Edit Course:mdcCourse
+scnd:/adm/coursedocs:::Edit Community:mdcCommunity
+scnd:/adm/coursegroups:::Groups:showgroups
+scnd:/adm/roles:::Roles:
 
 
 # Categories
@@ -136,7 +136,7 @@
 4:3:clear
 4:3:pvgr:$crs:stat.gif:course[_6]:stats[_1]:gopost('/adm/statistics','Problem Statistics');:View course assessment statistics:grd
 5:1:clear
-5:1:any:any:ccat.gif:course[_13]:catalog[_1]:go('/adm/coursecatalog');:Display catalog of courses:oth
+5:1:any:any:ccat.gif:course[_13]:catalog[_1]:go('/adm/coursecatalog');:Display catalog of courses and communities:oth
 5:2:courseenv_student_classlist_view:any:clst.gif:course[_12]:roster[_1]:go('/adm/viewclasslist');:View course roster:umn
 5:2:pvcl:$crs:clst.gif:course[_12]:roster[_1]:go('/adm/createuser?action=listusers');:View class lists:umn
 5:2:pcst:$crs:cprv.gif:user[_1]:privs[_1]:go('/adm/createuser');:Manage course users:umn

--raeburn1255736108--