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

raeburn raeburn at source.lon-capa.org
Thu Nov 8 16:15:02 EST 2012


raeburn		Thu Nov  8 21:15:02 2012 EDT

  Modified files:              
    /loncom/interface	lonsimplepage.pm 
  Log:
  - Consistent Interface for templated pages (bug 6128).
  - Functions for Templated "simple page" moved into standard location.
  
  
-------------- next part --------------
Index: loncom/interface/lonsimplepage.pm
diff -u loncom/interface/lonsimplepage.pm:1.98 loncom/interface/lonsimplepage.pm:1.99
--- loncom/interface/lonsimplepage.pm:1.98	Tue May  3 21:38:40 2011
+++ loncom/interface/lonsimplepage.pm	Thu Nov  8 21:15:02 2012
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Simple Page Editor
 #
-# $Id: lonsimplepage.pm,v 1.98 2011/05/03 21:38:40 www Exp $
+# $Id: lonsimplepage.pm,v 1.99 2012/11/08 21:15:02 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -88,8 +88,8 @@
 
     my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
     my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
-    my ($group,$group_desc,$group_home_view,$group_home_edit,
-        $group_view_perm,$group_edit_perm);
+    my ($group,$group_desc);
+
     my %curr_group = ();
     my %groupinfo = ();
     if ($db_name =~ /^grppage_/) {
@@ -122,13 +122,14 @@
 
 # ------------------------------------------------------------ Get query string
     &Apache::loncommon::get_unprocessed_cgi
-                        ($ENV{'QUERY_STRING'},['forcestudent','forceedit',
+                        ($ENV{'QUERY_STRING'},['forceedit',
                                                'register','ref']);
 # --------------------------------------------------------------- Force Student
-    my $forcestudent='';
-    if ($env{'form.forcestudent'} || $target eq 'tex' ) { $forcestudent='student'; };
-    my $forceedit='';
-    if ($env{'form.forceedit'}) { $forceedit='edit'; }
+    my ($forceedit,$forcestudent);
+    $forceedit = $env{'form.forceedit'};
+    if (!$forceedit) {
+        $forcestudent=1;
+    }
 
     my $refarg;
     if ($env{'form.ref'}) {
@@ -138,23 +139,11 @@
     my %syllabus=&Apache::lonnet::dump($db_name,$dom,$crs);
 
 # --------------------------------------- There is such a user, get environment
-
-    if ($target ne 'tex') {
-        my $title = 'Simple Course Page';
-        if ($group ne '') {
-            $title = 'Simple Group Page';
-        }
-        my $start_page =
-        &Apache::loncommon::start_page($title,undef,
-                       {'function'       => $forcestudent,
-                        'domain'         => $dom,
-                        'force_register' =>
-                        $env{'form.register'},});
-        $r->print($start_page);
-    }
-
+    my ($group_view_perm,$group_edit_perm,$group_home_view,$group_home_edit,
+        $has_group_access);
+    my $brcrum = []; 
     if ($group ne '') {
-        my $group_view_perm =
+        $group_view_perm =
                &Apache::lonnet::allowed('vcg',$env{'request.course.id'}.
                ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''));
         $group_edit_perm =
@@ -166,10 +155,31 @@
                                          $env{'request.course.id'}.'/'.$group);
         if ($group_view_perm || $group_edit_perm || $group_home_view ||
             $group_home_edit || &Apache::longroup::check_group_access($group)) {
+            $has_group_access = 1;
             if (($env{'form.ref'} eq 'grouplist') && ($target ne 'tex') &&
                 (!$env{'form.register'})) {
-                $r->print(&grouppage_breadcrumbs($dom,$crs,$group,$group_desc));
+                $brcrum = &grouppage_breadcrumbs($dom,$crs,$group,$group_desc);
             }
+        }
+    }
+
+    if ($target ne 'tex') {
+        my $title = 'Simple Course Page';
+        if ($group ne '') {
+            $title = 'Simple Group Page';
+        }
+        my $start_page =
+        &Apache::loncommon::start_page($title,undef,
+                       {'domain'         => $dom,
+                        'group'          => $group,
+                        'bread_crumbs'   => $brcrum,
+                        'force_register' => $env{'form.register'},
+                       }); 
+        $r->print($start_page);
+    }
+
+    if ($group ne '') {
+        if ($has_group_access) {
             if ((!$group_home_edit) && (!$group_home_view) &&
                 (!$group_view_perm) && (!$group_edit_perm)) {
                 &display_group_links($r,$target,$group,'view',$refarg,%groupinfo);
@@ -210,10 +220,6 @@
     } else {
         $allowed=&Apache::lonnet::allowed('mdc',$env{'request.course.id'});
     }
-    my $privileged=$allowed;
-    if (($syllabus{'uploaded.lastmodified'}) && (!$forceedit)) {
-        $forcestudent='student';
-    }
 
     if ($forcestudent or $target eq 'tex') { $allowed=0; }
 
@@ -255,50 +261,6 @@
         &Apache::lonnet::put($db_name,\%syllabus,$dom,$crs);
     }
 
-#---Print Function
-    if ($target ne 'tex') {
-        if ($allowed || $privileged) {
-            my $functions=&Apache::lonhtmlcommon::start_funclist();
-            my $url = $r->uri;
-            if ($group ne '') {
-                my $navmap=Apache::lonnavmaps::navmap->new();
-                if (ref($navmap)) {
-                    $url = &Apache::longroup::get_group_link($dom,$crs,$group,$navmap);
-                }
-            }
-            if ($allowed) {
-                $url .= (($url=~/\?/)?'&':'?').'forcestudent=1';
-                $functions.=&Apache::lonhtmlcommon::add_item_funclist(
-                                '<a href="'.$url.'">'
-                               .&mt('Show Student View').'</a>'
-                               .&Apache::loncommon::help_open_topic(
-                                    'Uploaded_Templates_PublicView'));
-            } elsif ($privileged) {
-                my $edittext = &mt('Edit');
-                $url .= (($url=~/\?/)?'&':'?').'forceedit=edit'.$refarg;
-                if ($group ne '') {
-                    $edittext = &mt('Edit Group Homepage');
-                }
-                $functions.=&Apache::lonhtmlcommon::add_item_funclist(
-                                '<a href="'.$url.'">'
-                               .$edittext.'</a>');
-                if ($group ne '') {
-                    if ($group_edit_perm) {
-                        $functions.=&Apache::lonhtmlcommon::add_item_funclist(
-                                        '<a href="/adm/coursegroups'
-                                       .'?action=modify&refpage=grouplist'
-                                       .'&state=pick_task&groupname='
-                                       .$group.'">'
-                                       .&mt('Edit Group Settings')
-                                       .'</a>');
-                       }
-                    }
-            }
-            $functions.=&Apache::lonhtmlcommon::end_funclist();
-            $r->print(&Apache::loncommon::head_subbox($functions));
-        }
-    }
-
 #---Print help Text
     if($target ne 'tex'){
         if ($allowed) {
@@ -323,7 +285,8 @@
         if ($allowed) {
             if ($env{'form.grade_target'} ne 'tex') {
                 #editbox for title
-                $r->print('<form method="post" action="" enctype="multipart/form-data">');
+                $r->print('<form method="post" action="" enctype="multipart/form-data">'."\n".
+                          '<input type="hidden" register="'.$env{'form.register'}.'" />');
 				&Apache::lontemplate::print_start_template($r,&mt('Title'),'LC_Box');
 				$r->print($titletext);
 				$r->print("<br /><div>");
@@ -493,17 +456,13 @@
 sub grouppage_breadcrumbs {
     my ($cdom,$cnum,$group,$description) = @_;
     &Apache::lonhtmlcommon::clear_breadcrumbs();
-    &Apache::lonhtmlcommon::add_breadcrumb
-        ({href=>"/adm/coursegroups",
-          text=>"Groups",
-          title=>"Display Groups"},
-        {href=>"/adm/$cdom/$cnum/$group/smppg?ref=grouplist",
-          text=>&mt('Group:')." $description",
-          title=>"Go to group's home page"},
-        );
-    my $output .= &Apache::lonhtmlcommon::breadcrumbs(&mt('Group page - [_1]',
-                                                           $description));
-    return $output;
+    return [{href=>"/adm/coursegroups",
+             text=>"Groups",
+             title=>"Display Groups"},
+            {href=>"/adm/$cdom/$cnum/$group/smppg?ref=grouplist",
+             text=>&mt('Group:')." $description",
+             title=>"Go to group's home page"},
+           ];
 }
 
 1;


More information about the LON-CAPA-cvs mailing list