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

raeburn lon-capa-cvs@mail.lon-capa.org
Thu, 29 Jul 2004 18:21:45 -0000


raeburn		Thu Jul 29 14:21:45 2004 EDT

  Modified files:              
    /loncom/interface	lonfeedback.pm 
  Log:
  Course Coordinators (and others with lonnet::allowed('rin',$crs)) can now display all versions of a discussion post.
  
  
Index: loncom/interface/lonfeedback.pm
diff -u loncom/interface/lonfeedback.pm:1.108 loncom/interface/lonfeedback.pm:1.109
--- loncom/interface/lonfeedback.pm:1.108	Wed Jul 28 14:50:26 2004
+++ loncom/interface/lonfeedback.pm	Thu Jul 29 14:21:44 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Feedback
 #
-# $Id: lonfeedback.pm,v 1.108 2004/07/28 18:50:26 raeburn Exp $
+# $Id: lonfeedback.pm,v 1.109 2004/07/29 18:21:44 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -508,11 +508,15 @@
                         $discussionitems[$idx] .= '<td align ="left">&nbsp;&nbsp;'.
                             '<b>'.$subject.'</b>&nbsp;&nbsp;'.
                             $sender.'</b> '.$vgrlink.' ('.
-                            localtime($posttime).')</td></tr>'.
+                            &Apache::lonlocal::locallocaltime($posttime).')</td></tr>'.
                             '</table><blockquote>'.$message.'</blockquote></p>';
                         if ($contrib{$idx.':history'}) {
                             my @postversions = ();
-                            $discussionitems[$idx] .= '<br />'.&mt('This post has been edited by the author.').'<br/>'.&mt('Earlier version(s) were posted on: ');
+                            $discussionitems[$idx] .= '<br />'.&mt('This post has been edited by the author.');
+                            if ($seeid) {
+                                $discussionitems[$idx] .= '&nbsp;&nbsp;<a href="/adm/feedback?allversions='.$ressymb.':::'.$idx.'">'.&mt('Display all versions').'</a>';
+                            }
+                            $discussionitems[$idx].='<br/>'.&mt('Earlier version(s) were posted on: ');
                             if ($contrib{$idx.':history'} =~ m/:/) {
                                 @postversions = split/:/,$contrib{$idx.':history'};
                             } else {
@@ -522,7 +526,6 @@
                                 my $version = $i+1;
                                 $discussionitems[$idx] .= '<b>'.$version.'.</b> - '.&Apache::lonlocal::locallocaltime($postversions[$i]).'  ';
                             }
-                            $discussionitems[$idx] .= '<br />';
                         }
                     }
                 }
@@ -2254,7 +2257,97 @@
 # --------------------------- Get query string for limited number of parameters
 
   &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
-         ['hide','unhide','deldisc','postdata','preview','replydisc','editdisc','threadedon','threadedoff','onlyunread','allposts','previous','markread','markonread','markondisp','modifydisp','changes','navmaps','navurl','sortfilter','sortposts','applysort','rolefilter','statusfilter','sectionpick','posterlist','userpick','attach','origpage','currnewattach','deloldattach','keepold']);
+         ['hide','unhide','deldisc','postdata','preview','replydisc','editdisc','threadedon','threadedoff','onlyunread','allposts','previous','markread','markonread','markondisp','modifydisp','changes','navmaps','navurl','sortfilter','sortposts','applysort','rolefilter','statusfilter','sectionpick','posterlist','userpick','attach','origpage','currnewattach','deloldattach','keepold','allversions']);
+  if ($ENV{'form.allversions'}) {
+      &Apache::loncommon::content_type($r,'text/html');
+      $r->send_http_header;
+      my $bodytag=&Apache::loncommon::bodytag('Discussion Post Versions',
+                                          '','');
+      $r->print (<<END);
+<html>
+<head>
+<title>Post Versions</title>
+<meta http-equiv="pragma" content="no-cache" />
+</head>
+$bodytag
+END
+      my $crs='/'.$ENV{'request.course.id'};
+      if ($ENV{'request.course.sec'}) {
+          $crs.='_'.$ENV{'request.course.sec'};
+      }
+      $crs=~s/\_/\//g;
+      my $seeid=&Apache::lonnet::allowed('rin',$crs);
+      my ($symb,$idx)=split(/\:\:\:/,$ENV{'form.allversions'});
+      my $ressymb=$symb;
+      unless ($ressymb =~ m|bulletin___\d+___adm/wrapper|) {
+          $ressymb=~s|(bulletin___\d+___)|$1adm/wrapper|;
+      }
+      if ($idx > 0) {
+          my %contrib=&Apache::lonnet::restore($ressymb,$ENV{'request.course.id'},
+               $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
+               $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
+          if ($contrib{$idx.':history'}) {
+              my $attachmenturls = $contrib{$idx.':attachmenturl'};
+              my @postversions = ();
+              if ($contrib{$idx.':history'} =~ m/:/) {
+                  @postversions = split/:/,$contrib{$idx.':history'};
+              } else {
+                  @postversions = ("$contrib{$idx.':history'}");
+              }
+              if (@postversions > 0) {
+                  push @postversions,$contrib{$idx.':timestamp'};
+                  my $screenname=&Apache::loncommon::screenname(
+                                            $contrib{$idx.':sendername'},
+                                            $contrib{$idx.':senderdomain'});
+                  my $plainname=&Apache::loncommon::nickname(
+                                            $contrib{$idx.':sendername'},
+                                            $contrib{$idx.':senderdomain'});
+                  my $sender=&Apache::loncommon::aboutmewrapper(
+                                     $plainname,
+                                     $contrib{$idx.':sendername'},
+                                     $contrib{$idx.':senderdomain'}).' ('.
+                                     $contrib{$idx.':sendername'}.' at '.
+                                     $contrib{$idx.':senderdomain'}.')';
+                  if ($contrib{$idx.':anonymous'}) {
+                      $sender.=' ['.&mt('anonymous').'] '.$screenname;
+                  }
+                  $r->print('<b>'.$sender.'</b><br /><ul>');
+                  for (my $i=0; $i<@postversions; $i++) {
+                      my ($timesent,$message,$subject,$attachmsg);
+                      $timesent = &Apache::lonlocal::locallocaltime($postversions[$i]);
+                      if ($i == @postversions-1) {
+                          ($message)=($contrib{$idx.':message'} =~ /.*::::\Q$i\E::::(.+?)$/si);
+                          ($subject)=($contrib{$idx.':subject'} =~ /.*::::\Q$i\E::::(.+?)$/si);
+                      } else { 
+                          ($message)=($contrib{$idx.':message'} =~ /::::\Q$i\E::::(.+?)::::/si);
+                          ($subject)=($contrib{$idx.':subject'} =~ /::::\Q$i\E::::(.+?)::::/si);
+                      }
+                      $message=~s/\n/\<br \/\>/g;
+                      $message=&Apache::lontexconvert::msgtexconverted($message);
+                      $subject=~s/\n/\<br \/\>/g;
+                      $subject=&Apache::lontexconvert::msgtexconverted($subject);
+                      if ($attachmenturls) {
+                          my @attachments = ();
+                          my %currattach = ();
+                          &extract_attachments($attachmenturls,$idx,$i,\$attachmsg,\@attachments,\%currattach);
+                      }
+                      if ($attachmsg) {
+                          $attachmsg = '<br />Attachments:'.$attachmsg.'<br />';
+                      } else {
+                          $attachmsg = '<br />';
+                      }
+                      $r->print (<<END);
+<li><b>$subject</b>, $timesent<br />
+$message<br />
+$attachmsg</li>
+END
+                  }
+                  $r->print('</ul></body></html>');
+              }
+          }
+      }
+      return OK;
+  }
   if ($ENV{'form.posterlist'}) {
       &Apache::loncommon::content_type($r,'text/html');
       $r->send_http_header;