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

raeburn raeburn@source.lon-capa.org
Thu, 15 Oct 2009 20:48:17 -0000


raeburn		Thu Oct 15 20:48:17 2009 EDT

  Modified files:              
    /loncom/interface	lonmenu.pm 
  Log:
  - Use 'Community' instead of 'Group' for alternative "course" container.
  - &secondary_menu().
     - Get values for conditions once (before looping) over secondary menu items.
  - Wording change for role selector in Community context.
  - Remove unused convert_menuitems() routine. 
  
  
Index: loncom/interface/lonmenu.pm
diff -u loncom/interface/lonmenu.pm:1.285 loncom/interface/lonmenu.pm:1.286
--- loncom/interface/lonmenu.pm:1.285	Tue Oct 13 13:18:25 2009
+++ loncom/interface/lonmenu.pm	Thu Oct 15 20:48:16 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Routines to control the menu
 #
-# $Id: lonmenu.pm,v 1.285 2009/10/13 13:18:25 wenzelju Exp $
+# $Id: lonmenu.pm,v 1.286 2009/10/15 20:48:16 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -200,34 +200,38 @@
 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    $$menuitem[4]   ne 'always'
                 && !$env{'request.course.id'};
         next if    $$menuitem[4]   eq 'showreturn'
-                && !show_return_link() 
+                && !$showlink
                 && !($env{'request.state'} eq 'construct');
         next if    $$menuitem[4]   =~ /^mdc/
-                && !Apache::lonnet::allowed('mdc', $env{'request.course.id'});
-        next if    $$menuitem[4]   =~ /nogrp$/
-                && Apache::loncommon::course_type() eq 'Group';
-        next if    $$menuitem[4]   =~ /group$/
-                && Apache::loncommon::course_type() ne 'Group';
-        next if    $$menuitem[4]   eq 'remotenav'
+                && !$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]   eq 'noremotenav'
+        next if    $$menuitem[4]  =~ /noremotenav/
                 && $env{'environment.remotenavmap'} eq 'on';
         next if    $$menuitem[4]   =~ /showgroups$/
-                && !Apache::lonnet::allowed('vcg', $env{'request.course.id'}
-                   . ($env{'request.course.sec'} ? "/$env{'request.course.sec'}"
-                                                 : ''))
-                && !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'});
+                && $canviewgrps
+                && !%groups;
 
-
-        if($$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'},
@@ -280,7 +284,7 @@
                                        'login' => 'Log In',
 				       'launch' => 'Launch Remote Control',
                                        'groups' => 'Groups',
-                                       'gdoc' => 'Group Documents',
+                                       'gdoc' => 'Community Documents',
                                        );
 }
 
@@ -381,9 +385,10 @@
 	    $navmaps=(<<ENDNAV);
 <li><a href="$link" target="_top">$lt{'nav'}</a></li>
 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=(<<ENDDOCS);
 <li><a href="/adm/coursedocs" target="_top">$text</a></li>
 ENDDOCS
@@ -1317,9 +1322,6 @@
         $prt=~s/\$requested_domain/$requested_domain/g;
         if ($category_names{$cat}!~/\w/) { $cat='oth'; }
         my $type = &Apache::loncommon::course_type();
-#
-# I don't think we support this
-#
 #        if ($type eq 'Group') {
 #            $desc = &convert_menu_function($desc,$type);
 #        }
@@ -1714,22 +1716,6 @@
     return $navstatus;
 }
 
-#FIXME this needs to move into mydesk.tab and the other locations 
-# the text is generated
-#
-# We currently do not support this anyway.
-#
-#sub convert_menu_function {
-#    my ($rolename,$type) = @_;
-#    if ($type eq 'Group') {
-#        $rolename =~ s/student/member/g;
-#        $rolename =~ s/group/team/g;
-#        $rolename =~ s/course/group/g;
-#        $rolename =~ s/Course/Group/g;
-#    }
-#    return $rolename;
-#}
-
 sub hidden_button_check {
     my $hidden;
     if ($env{'request.course.id'} eq '') {
@@ -1744,6 +1730,10 @@
 
 sub roles_selector {
     my ($cdom,$cnum) = @_;
+    my $crstype = $env{'course.'.$env{'request.course.id'}.'.type'};
+    if ($crstype eq '') {
+        $crstype = 'Course';
+    }
     my $now = time;
     my (%courseroles,%seccount);
     my $is_cc;
@@ -1793,12 +1783,18 @@
             }
         }
     }
+    my $switchtext;
+    if ($crstype eq 'Community') {
+        $switchtext = &mt('Switch community role to...')
+    } else {
+        $switchtext = &mt('Switch course role to...')
+    }
     my @roles_order = ('cc','in','ta','ep','ad','st');
     if (keys(%courseroles) > 1) {
         $role_selector = &jump_to_role($cdom,$cnum,\%seccount,\%courseroles);
         $role_selector .= '<form name="rolechooser" method="post" action="/adm/roles">
                           <select name="switchrole" onchange="javascript:adhocRole('."'switchrole'".')">';
-        $role_selector .= '<option value="">'.&mt('Switch course role to...').'</option>';
+        $role_selector .= '<option value="">'.$switchtext.'</option>';
         foreach my $role (@roles_order) {
             if (defined($courseroles{$role})) {
                 $role_selector .= "\n".'<option value="'.$role.'">'.&Apache::lonnet::plaintext($role).'</option>';