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

raeburn raeburn at source.lon-capa.org
Thu Nov 8 17:01:00 EST 2012


raeburn		Thu Nov  8 22:01:00 2012 EDT

  Modified files:              
    /loncom/interface	lonbulletin.pm 
  Log:
  - Consistent Interface for templated pages (bug 6128).
  - Function for Templated "Bulletin Board" page moved into standard location,
    is either "Edit" (go to editing mode) or "Exit Edit" (go to viewing mode).
  
  
-------------- next part --------------
Index: loncom/interface/lonbulletin.pm
diff -u loncom/interface/lonbulletin.pm:1.63 loncom/interface/lonbulletin.pm:1.64
--- loncom/interface/lonbulletin.pm:1.63	Mon May  2 18:32:30 2011
+++ loncom/interface/lonbulletin.pm	Thu Nov  8 22:01:00 2012
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Bulletin Board Handler
 #
-# $Id: lonbulletin.pm,v 1.63 2011/05/02 18:32:30 raeburn Exp $
+# $Id: lonbulletin.pm,v 1.64 2012/11/08 22:01:00 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -78,7 +78,7 @@
 
 # ------------------------------------------------------------ Get Query String
     &Apache::loncommon::get_unprocessed_cgi
-                ($ENV{'QUERY_STRING'},['forcestudent','forceedit','register',
+                ($ENV{'QUERY_STRING'},['forceedit','register',
                                        'origpage','group','ref']);
 # ----------------------------------------------------- Force menu registration
     my %addentries;
@@ -86,11 +86,11 @@
         $addentries{'onload'} = "document.location='#newpost';";
     }
 # --------------------------------------------------------------- Force Student
-    my $forcestudent='';
-    if ($env{'form.forcestudent'}) { $forcestudent='student'; }
-
-    my $forceedit='';
-    if ($env{'form.forceedit'}) { $forceedit='edit'; }
+    my ($forceedit,$forcestudent);
+    $forceedit = $env{'form.forceedit'};
+    if (!$forceedit) {
+        $forcestudent=1;
+    }
     my $refarg = '';
     if (exists($env{'form.ref'})) { $refarg = 'ref='.$env{'form.ref'}; }
 
@@ -125,20 +125,12 @@
 
 # --------------------------------------- There is such a user, get environment
     if ($target ne 'tex') {
-        my $course_or_group;
+        my ($course_or_group,$brcrum);
         if($group eq '') {
             $course_or_group="Course";
         } else {
             $course_or_group="Group";
         }
-        my $start_page =
-            &Apache::loncommon::start_page("$course_or_group Discussion Board",undef,
-                                           {'function'       => $forcestudent,
-                                            'add_entries'    => \%addentries,
-                                            'domain'         => $dom,
-                                            'force_register' =>
-                                                $env{'form.register'}});
-        $r->print($start_page);
         if ($group ne '' && $env{'form.group'} eq $group) {
             my $gpterm =  &Apache::loncommon::group_term();
             my $ucgpterm = $gpterm;
@@ -150,9 +142,21 @@
                 $boardtitle = $$boards{$$groupboards[0]}{'title'};
             }
             $boardurl .= '?register=1&group='.$group;
-            $r->print(&groupboard_breadcrumbs($dom,$crs,$group,$refarg,$gpterm,
-                                $ucgpterm,$grp_desc,$boardurl,$boardtitle));
+            $brcrum = 
+                &groupboard_breadcrumbs($dom,$crs,$group,$refarg,$gpterm,
+                                        $ucgpterm,$grp_desc,$boardurl,$boardtitle);
+        } else {
+            $brcrum = [];
         }
+        my $start_page =
+            &Apache::loncommon::start_page("$course_or_group Discussion Board",undef,
+                                           {'add_entries'    => \%addentries,
+                                            'domain'         => $dom,
+                                            'bread_crumbs'   => $brcrum, 
+                                            'group'          => $group,
+                                            'force_register' =>
+                                                $env{'form.register'}});
+        $r->print($start_page);
     }
     my ($allowed);
     if ($group ne '') {
@@ -173,43 +177,8 @@
         $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; }
 
-    if ($allowed) {
-        my $query_str = 'forcestudent=1';
-        if (($group ne '') && ($env{'form.group'} eq $group)) {
-            $query_str.='&group='.$group.'&'.$refarg;
-        }
-        if ($env{'form.register'}) {
-            $query_str .= '&register='.$env{'form.register'};
-        }
-        #Function Box for Edit Mode.
-        my $functionbox = &Apache::lonhtmlcommon::start_funclist();
-        $functionbox .=  &Apache::lonhtmlcommon::add_item_funclist(
-                             '<a href="'.$r->uri.'?'.$query_str.'">'.&mt('Show Student View').'</a>'.
-                              &Apache::loncommon::help_open_topic('Uploaded_Templates_PublicView'));
-        $functionbox.=&Apache::lonhtmlcommon::end_funclist();
-        $r->print(&Apache::loncommon::head_subbox($functionbox).&Apache::loncommon::help_open_topic('Uploaded_Templates_TextBoxes',&mt('Help with filling in text boxes')));
-    } elsif ($privileged and $target ne 'tex') {
-        my $query_str = 'forceedit=edit';
-        if (($group ne '') && ($env{'form.group'} eq $group)) {
-            $query_str.='&group='.$group.'&'.$refarg;
-        }
-        if ($env{'form.register'}) {
-            $query_str .= '&register='.$env{'form.register'};
-        }
-        #Functionbox for Student view.
-        my $functionbox = &Apache::lonhtmlcommon::start_funclist();
-        $functionbox .=  &Apache::lonhtmlcommon::add_item_funclist(
-                             "<a href='".$r->uri.'?'.$query_str."'>".&mt('Edit')."</a>");
-        $functionbox.=&Apache::lonhtmlcommon::end_funclist();
-        $r->print(&Apache::loncommon::head_subbox($functionbox));
-    }
-
     if (($env{'form.uploaddoc.filename'}) &&
         ($env{'form.storeupl'}) && ($allowed)) {
         if ($env{'form.uploaddoc.filename'}=~/\.(gif|jpg|png|jpeg)$/i) {
@@ -272,10 +241,9 @@
             $r->print($message);
             $r->print("<br /><br />");
             $r->print(
-                '<input type="hidden" name="forceedit" value="edit" />'.
+                '<input type="hidden" name="forceedit" value="'.$env{'form.forceedit'}.'" />'.
                 '<input type="file" name="uploaddoc" size="50" />'.
-                '<input type="submit" name="storeupl" value="'.&mt('Upload').'" />'.
-                '<input type="hidden" name="forceedit" value="edit" />');
+                '<input type="submit" name="storeupl" value="'.&mt('Upload').'" />');
             &Apache::lontemplate::print_end_template($r);
         }
         #Image in Student view.
@@ -327,25 +295,25 @@
     my ($cdom,$cnum,$group,$refarg,$gpterm,$ucgpterm,$description,$boardurl,
         $boardtitle)= @_;
     &Apache::lonhtmlcommon::clear_breadcrumbs();
+    my $brcrum = [];
     if ($refarg ne '') {
-        &Apache::lonhtmlcommon::add_breadcrumb
-            ({href=>"/adm/coursegroups",
-              text=>"Groups",
-              title=>"View course groups"});
-    }
-    &Apache::lonhtmlcommon::add_breadcrumb
-        ({href=>"/adm/$cdom/$cnum/$group/smppg?$refarg",
-          text=>"$ucgpterm: $description",
-          title=>"Go to group's home page"},
-         {href=>"/adm/groupboards?group=$group&$refarg",
-          text=>"Discussion Boards",
-          title=>"Display group discussion boards"},
-         {href=>"$boardurl",
-          text=>"$boardtitle",
-          title=>"$boardtitle"},
+        push(@{$brcrum},
+              {href=>"/adm/coursegroups",
+               text=>"Groups",
+               title=>"View course groups"});
+    }
+    push(@{$brcrum},
+           {href=>"/adm/$cdom/$cnum/$group/smppg?$refarg",
+            text=>"$ucgpterm: $description",
+            title=>"Go to group's home page"},
+           {href=>"/adm/groupboards?group=$group&$refarg",
+            text=>"Discussion Boards",
+            title=>"Display group discussion boards"},
+           {href=>"$boardurl",
+            text=>"$boardtitle",
+            title=>"$boardtitle"},
         );
-    my $output .= &Apache::lonhtmlcommon::breadcrumbs(&mt('[_1] discussion boards - [_2]',$gpterm,$description));
-    return $output;
+    return $brcrum;
 }
 
 1;


More information about the LON-CAPA-cvs mailing list