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

raeburn raeburn at source.lon-capa.org
Thu Dec 13 12:38:41 EST 2012


raeburn		Thu Dec 13 17:38:41 2012 EDT

  Modified files:              (Branch: version_2_11_X)
    /loncom/interface	lonmenu.pm 
  Log:
  - For 2.11
    - Backport 1.391, 1.392, 1.393, 1.394, 1.395, 1.396, 1.397, 1.398
  
  
-------------- next part --------------
Index: loncom/interface/lonmenu.pm
diff -u loncom/interface/lonmenu.pm:1.369.2.26 loncom/interface/lonmenu.pm:1.369.2.27
--- loncom/interface/lonmenu.pm:1.369.2.26	Thu Dec 13 06:33:31 2012
+++ loncom/interface/lonmenu.pm	Thu Dec 13 17:38:40 2012
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Routines to control the menu
 #
-# $Id: lonmenu.pm,v 1.369.2.26 2012/12/13 06:33:31 raeburn Exp $
+# $Id: lonmenu.pm,v 1.369.2.27 2012/12/13 17:38:40 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -530,43 +530,72 @@
         $newmail= 'swmenu.setstatus("you have","messages");';
     }
 
-    my $resurl;
+    my ($mapurl,$resurl);
 
-    if ($env{'request.course.id'} && $env{'request.symb'} eq '') {
-        $resurl = $env{'request.noversionuri'};
-    }
-
-    if ( $env{'request.symb'} && $env{'request.course.id'} ) {
+    if ($env{'request.course.id'}) {
+        if ($env{'request.symb'}) {
+            ($mapurl, my $rid, $resurl) = &Apache::lonnet::decode_symb(&Apache::lonnet::symbread());
+            my $coursetitle = $env{'course.'.$env{'request.course.id'}.'.description'};
 
-        (my $mapurl, my $rid, $resurl) = &Apache::lonnet::decode_symb(&Apache::lonnet::symbread());
-        my $coursetitle = $env{'course.'.$env{'request.course.id'}.'.description'};
+            my $maptitle = &Apache::lonnet::gettitle($mapurl);
+            my $restitle = &Apache::lonnet::gettitle(&Apache::lonnet::symbread());
 
-        my $maptitle = &Apache::lonnet::gettitle($mapurl);
-        my $restitle = &Apache::lonnet::gettitle(&Apache::lonnet::symbread());
 
 #SD
 #course_type only Course and Community?
 #
-        my @crumbs;
-        unless (($forcereg) && ($env{'request.noversionuri'} eq '/adm/navmaps')
-                && ($mapurl eq $env{'course.'.$env{'request.course.id'}.'.url'})) {
-            @crumbs = ({text  => Apache::loncommon::course_type() 
-                                . ' Contents', 
-                        href  => "Javascript:gopost('/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);
+            my @crumbs;
+            unless (($forcereg) && 
+                    ($env{'request.noversionuri'} eq '/adm/navmaps') &&
+                    ($mapurl eq $env{'course.'.$env{'request.course.id'}.'.url'})) {
+                @crumbs = ({text  => Apache::loncommon::course_type() 
+                                    . ' Contents', 
+                            href  => "Javascript:gopost('/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);
+        } else {
+            $resurl = $env{'request.noversionuri'};
+            my $courseurl = &Apache::lonnet::courseid_to_courseurl($env{'request.course.id'});
+            my $crstype = &Apache::loncommon::course_type();
+            my $title = &mt('View Resource');
+            if ($resurl =~ m{^\Q/uploaded$courseurl/supplemental/\E(default|\d+)/}) {
+                &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['folderpath','title']);
+                &Apache::lonhtmlcommon::clear_breadcrumbs();
+                if ($env{'form.title'}) {
+                    $title = $env{'form.title'};
+                }
+                my $trail;
+                if ($env{'form.folderpath'}) {
+                    my $editbutton =
+                        &prepare_functions($resurl,$forcereg,$group,undef,undef,1);
+                    ($trail) =
+                        &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1);
+                } else {
+                    &Apache::lonhtmlcommon::add_breadcrumb(
+                    {text  => "Supplemental $crstype Content",
+                     href  => "javascript:gopost('/adm/supplemental','')"});
+                    $title = &mt('View Resource');
+                    ($trail) =
+                        &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1);
+                }
+                return $trail;
+            }
+            unless ($env{'request.state'} eq 'construct') {
+                &Apache::lonhtmlcommon::clear_breadcrumbs();
+                &Apache::lonhtmlcommon::add_breadcrumb({text => 'View Resource'});
+            }
+        }
     } elsif (! $const_space){
         #a situation when we're looking at a resource outside of context of a 
         #course or construction space (e.g. with cumulative rights)
@@ -582,15 +611,8 @@
                        || ($forcereg)) {
     my ($cdom,$cnum,%perms,$cfile,$switchserver,$home,$forceedit,
         $forceview,$editbutton);
-    if ($env{'request.noversionuri'} =~ m{^/adm/($match_domain)/($match_username)/aboutme$}) {
-        ($cfile,$home,$switchserver,$forceedit,$forceview) =
-            &Apache::lonnet::can_edit_resource($env{'request.noversionuri'},$cnum,$cdom,
-                &Apache::lonnet::clutter($resurl),$env{'request.symb'},$group);
-        if (($cfile) && ($home ne '') && ($home ne 'no_host')) {
-            $editbutton = &get_editbutton($cfile,$home,$switchserver,
-                                          $forceedit,$forceview,$forcereg);
-        }
-    } elsif ($env{'request.role'} !~/^(aa|ca|au)/) {
+    if (($resurl =~ m{^/adm/($match_domain)/($match_username)/aboutme$}) ||
+        ($env{'request.role'} !~/^(aa|ca|au)/)) {
         $editbutton = &prepare_functions($resurl,$forcereg,$group);
     }
     if ($editbutton eq '') {
@@ -644,7 +666,13 @@
 # This applies to items inside a folder/page modifiable in the course.
 #
         if (($env{'request.symb'}=~/^uploaded/) && ($perms{'mdc'})) {
-            &switch('','',7,4,'docs-22x22.png','Folder/Page Content','parms[_2]',
+            my $text = 'Edit Folder';
+            if (($mapurl =~ /\.page$/) ||
+                ($env{'request.symb'}=~
+                     m{uploaded/$cdom/$cnum/default_\d+\.page$}))  {
+                $text = 'Edit Page';
+            }
+            &switch('','',7,4,'docs-22x22.png',$text,'parms[_2]',
                     "gocmd('/adm/coursedocs','direct')",
                     'Folder/Page Content');
         }
@@ -1142,9 +1170,24 @@
 
 sub get_editbutton {
     my ($cfile,$home,$switchserver,$forceedit,$forceview,$forcereg) = @_;
-    my $jscall =
-        &Apache::lonhtmlcommon::jump_to_editres($cfile,$home,$switchserver,
-                                                $forceedit,$forcereg,$env{'request.symb'});
+    my $jscall;
+    if (($forceview) && ($env{'form.todocs'})) {
+        my ($folderpath,$command);
+        if ($env{'request.symb'}) {
+            $folderpath = &Apache::loncommon::symb_to_docspath($env{'request.symb'});
+        } elsif ($env{'form.folderpath'} =~ /^supplemental/) {
+            $folderpath = $env{'form.folderpath'};
+            $command = '&forcesupplement=1';
+        }
+        $folderpath = &escape(&HTML::Entities::encode(&escape($folderpath),'<>&"'));
+        $jscall = "go('/adm/coursedocs?folderpath=$folderpath$command')";
+    } else {
+        $jscall = &Apache::lonhtmlcommon::jump_to_editres($cfile,$home,$switchserver,
+                                                $forceedit,$forcereg,$env{'request.symb'},
+                                                &escape($env{'form.folderpath'}),
+                                                &escape($env{'form.title'}),$env{'form.idx'},
+                                                &escape($env{'form.suppurl'},$env{'form.todocs'}));
+    }
     if ($jscall) {
         my $icon = 'pcstr.png';
         my $label = 'Edit';
@@ -1160,7 +1203,7 @@
 }
 
 sub prepare_functions {
-    my ($resurl,$forcereg,$group,$bread_crumbs,$advtools) = @_;
+    my ($resurl,$forcereg,$group,$bread_crumbs,$advtools,$docscrumbs) = @_;
     unless ($env{'request.registered'}) {
         undef(@inlineremote);
     }
@@ -1178,19 +1221,16 @@
 # Determine whether or not to display 'Edit' icon/button
 #
     if ($resurl =~ m{^/?adm/($match_domain)/($match_username)/aboutme$}) {
-#
-# This applies to a user's own about me page
-#
-        my ($sdom,$sname) = ($1,$2);
+    if ($resurl =~ m{^/?adm/($match_domain)/($match_username)/aboutme$}) {
         my $file=&Apache::lonnet::declutter($env{'request.filename'});
-        if (($sdom eq $env{'user.domain'}) && ($sname eq $env{'user.name'})) {
-            ($cfile,$home,$switchserver,$forceedit,$forceview) =
-                &Apache::lonnet::can_edit_resource($file,$cnum,$cdom,
-                    &Apache::lonnet::clutter($resurl),$env{'request.symb'},$group);
-            $editbutton = &get_editbutton($cfile,$env{'user.home'},$switchserver,
+        ($cfile,$home,$switchserver,$forceedit,$forceview) =
+            &Apache::lonnet::can_edit_resource($file,$cnum,$cdom,
+                &Apache::lonnet::clutter($resurl),$env{'request.symb'},$group);
+        if (($cfile) && ($home ne '') && ($home ne 'no_host')) {
+            $editbutton = &get_editbutton($cfile,$home,$switchserver,
                                           $forceedit,$forceview,$forcereg);
         }
-    } elsif ((!$editbutton) && (!$env{'request.course.id'}) &&
+    } elsif ((!$env{'request.course.id'}) &&
              ($env{'user.author'}) && ($env{'request.filename'}) &&
              ($env{'request.role'} !~/^(aa|ca|au)/)) {
 #
@@ -1201,7 +1241,6 @@
         ($cfile,$home,$switchserver,$forceedit,$forceview) =
             &Apache::lonnet::can_edit_resource($file,$cnum,$cdom,
                 &Apache::lonnet::clutter($resurl),$env{'request.symb'},$group);
-        # Turn the button on or off
         if (($cfile) && ($home ne '') && ($home ne 'no_host')) {
             $editbutton = &get_editbutton($cfile,$home,$switchserver,
                                           $forceedit,$forceview,$forcereg);
@@ -1228,6 +1267,16 @@
                 $editbutton = &get_editbutton($cfile,$home,$switchserver,
                                               $forceedit,$forceview,$forcereg);
             }
+        } elsif (($resurl eq '/adm/extresedit') &&
+                 (($env{'form.symb'}) || ($env{'form.folderpath'}))) {
+            ($cfile,$home,$switchserver,$forceedit,$forceview) =
+            &Apache::lonnet::can_edit_resource($resurl,$cnum,$cdom,$resurl,
+                                               $env{'form.symb'});
+            if ($cfile ne '') {
+                $editbutton = &get_editbutton($cfile,$home,$switchserver,
+                                              $forceedit,$forceview,$forcereg,
+                                              $env{'form.title'},$env{'form.suppurl'});
+            }
         } elsif ($resurl !~ m{^adm/($match_domain)/($match_username)/aboutme$}) {
             if ($env{'request.filename'}) {
                 my $file=&Apache::lonnet::declutter($env{'request.filename'});
@@ -1243,8 +1292,8 @@
     }
 # End determination of 'Edit' icon/button display
 
-# This applies to about me page for users in a course
     if ($env{'request.course.id'}) {
+# This applies to about me page for users in a course
         if ($resurl =~ m{^adm/($match_domain)/($match_username)/aboutme$}) {
             my ($sdom,$sname) = ($1,$2);
             unless (&Apache::lonnet::is_course($sdom,$sname)) {
@@ -1253,7 +1302,9 @@
                         "go('/adm/email?compose=individual&recname=$sname&recdom=$sdom')",
                             'Send message to specific user');
             }
-            if (&Apache::lonnet::in_course($sdom,$sname,$cdom,$cnum)) {
+            my $hideprivileged = 1;
+            if (&Apache::lonnet::in_course($sdom,$sname,$cdom,$cnum,undef,
+                                           $hideprivileged)) {
                 foreach my $priv ('vsa','vgr','srm') {
                     $perms{$priv} = &Apache::lonnet::allowed($priv,$env{'request.course.id'});
                     if (!$perms{$priv} && $env{'request.course.sec'} ne '') {
@@ -1280,12 +1331,38 @@
                             'Add records');
                 }
             }
+        } elsif ($resurl =~ m{^/?adm/viewclasslist}) {
+# This applies to viewclasslist page for users in a course
+            if (&Apache::lonnet::allowed('opa',$env{'request.course.id'})) {
+                &switch('','',6,4,'pparm.png','Settings',
+                        '',
+                        "go('/adm/courseprefs?actions=classlists&phase=display')",
+                        'Student-viewable classlist options');
+            }
+        }
+        if (($env{'form.folderpath'} =~ /^supplemental/) &&
+            (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) &&
+            (($resurl =~ m{^/adm/wrapper/ext/}) ||
+             ($resurl =~ m{^/uploaded/$cdom/$cnum/supplemental/}) ||
+             ($resurl eq '/adm/supplemental') ||
+             ($resurl =~ m{^/public/$cdom/$cnum/syllabus$}) ||
+             ($resurl =~ m{^/adm/$match_domain/$match_username/aboutme$}))) {
+            my @folders=split('&',$env{'form.folderpath'});
+            if ((@folders > 2) || ($resurl ne '/adm/supplemental')) {
+                my $esc_path=&escape(&HTML::Entities::encode(&escape($env{'form.folderpath'}),'<>&"'));
+                &switch('','',7,4,'docs-22x22.png','Edit Folder','parms[_2]',
+                        "location.href='/adm/coursedocs?command=direct&forcesupplement=1&supppath=$esc_path'",
+                        'Folder/Page Content');
+            }
         }
     }
 
 # End checking for items for about me page for users in a course
-
-    if ($env{'request.registered'}) {
+    if ($docscrumbs) {
+        &Apache::lonhtmlcommon::clear_breadcrumb_tools();
+        &advtools_crumbs(@inlineremote);
+        return $editbutton;
+    } elsif ($env{'request.registered'}) {
         return $editbutton;
     } else {
         if (ref($bread_crumbs) eq 'ARRAY') {
@@ -1313,6 +1390,9 @@
     } elsif ($env{'request.noversionuri'} !~ m{^/adm/(navmaps|viewclasslist)(\?|$)}) {
         &Apache::lonhtmlcommon::add_breadcrumb_tool(
             'advtools', @funcs[61,71,72,73,74,92]);
+    } elsif ($env{'request.noversionuri'} eq '/adm/viewclasslist') {
+        &Apache::lonhtmlcommon::add_breadcrumb_tool(
+            'advtools', @funcs[64]);
     }
 }
 


More information about the LON-CAPA-cvs mailing list