Diff for /loncom/interface/lonfeedback.pm between versions 1.332 and 1.340

version 1.332, 2012/01/10 01:06:26 version 1.340, 2012/03/15 12:45:21
Line 1019  sub build_posting_display { Line 1019  sub build_posting_display {
         my $twoplus=$ave+2.*$stddev;          my $twoplus=$ave+2.*$stddev;
         my $oneminus=$ave-$stddev;          my $oneminus=$ave-$stddev;
         my $twominus=$ave-2.*$stddev;          my $twominus=$ave-2.*$stddev;
 #            &Apache::lonnet::logthis(join(',',@theselikes)." Ave $ave StdDev $stddev $twominus $oneminus $oneplus $twoplus");  
 #  #
 # This is now the real loop. Go through all entries, pick up what we need  # This is now the real loop. Go through all entries, pick up what we need
 #   # 
Line 1156  sub build_posting_display { Line 1155  sub build_posting_display {
                                 @{$$namesort{$lastname}{$firstname}} = ("$idx");                                  @{$$namesort{$lastname}{$firstname}} = ("$idx");
                             }                              }
                             if ($outputtarget ne 'tex') {                              if ($outputtarget ne 'tex') {
                                 unless ($likes{$symb.':'.$idx.':likers'}=~/\,\Q$thisuser\E\,/) {  # Add karma stars
                                     $sender.='&nbsp;'.&discussion_link($symb,'<img border="0" src="/res/adm/pages/thumbsup.png" alt="'.&mt('Like').'" />','like',$idx,$$newpostsflag,$prevread,&group_args($group),&mt("Like this posting"));                                  my $karma=&userkarma($contrib{$idx.':sendername'},$contrib{$idx.':senderdomain'});
                                 }                                  for (my $i=1;$i<=$karma;$i++) {
                                 unless ($likes{$symb.':'.$idx.':unlikers'}=~/\,\Q$thisuser\E\,/) {                                      $sender.='<img border="0" src="/res/adm/pages/star.gif" alt="'.&mt('Contributor Kudos').'" />';
                                     $sender.='&nbsp;'.&discussion_link($symb,'<img border="0" src="/res/adm/pages/thumbsdown.png" alt="'.&mt('Unlike').'" />',,'unlike',$idx,$$newpostsflag,$prevread,&group_args($group),&mt("Unlike this posting"));  
                                 }  
                                 my $thislikes=$likes{$symb.':'.$idx.':likes'};  
                                 if ($thislikes>0) {   
                                     $sender.='&nbsp;('.&mt("[_1] likes",$thislikes).')';  
                                 } elsif ($thislikes<0) {  
                                     $sender.='&nbsp;('.&mt("[_1] unlikes",abs($thislikes)).')';  
                                 }                                  }
   # Can people edit this?
                                 if (&editing_allowed($escsymb.':::'.$idx,$group)) {                                  if (&editing_allowed($escsymb.':::'.$idx,$group)) {
                                     if (($env{'user.domain'} eq $contrib{$idx.':senderdomain'}) && ($env{'user.name'} eq $contrib{$idx.':sendername'})) {                                      if (($env{'user.domain'} eq $contrib{$idx.':senderdomain'}) && ($env{'user.name'} eq $contrib{$idx.':sendername'})) {
                                         $sender.=' '.                                          $sender.=' '.
Line 1363  sub build_posting_display { Line 1356  sub build_posting_display {
                             } elsif ($thislikes<$oneminus) {                              } elsif ($thislikes<$oneminus) {
                                 $likesize="75";                                  $likesize="75";
                             }                              }
   # Actually glue in the message itself
                             $$discussionitems[$idx].= '<br /><blockquote>'.                              $$discussionitems[$idx].= '<br /><blockquote>'.
                                     "<div style='font-size:$likesize%'>".                                      "<div style='font-size:$likesize%'>".
                                     $message.                                      $message.
                                     '</div></blockquote>';                                      '</div></blockquote>';
   # Put in the like and unlike buttons
                               unless ($likes{$symb.':'.$idx.':likers'}=~/\,\Q$thisuser\E\,/) {
                                   $$discussionitems[$idx].='&nbsp;'.&discussion_link($symb,'<img border="0" src="/res/adm/pages/thumbsup.png" alt="'.&mt('Like').'" />','like',$idx,$$newpostsflag,$prevread,&group_args($group),&mt("Like this posting"));
                               } else {
                                   $$discussionitems[$idx].='<img border="0" src="/res/adm/pages/thumbsup_gray.png" alt="'.&mt('You like this posting').'" />';
                               }
                               unless ($likes{$symb.':'.$idx.':unlikers'}=~/\,\Q$thisuser\E\,/) {
                                   $$discussionitems[$idx].='&nbsp;'.&discussion_link($symb,'<img border="0" src="/res/adm/pages/thumbsdown.png" alt="'.&mt('Unlike').'" />',,'unlike',$idx,$$newpostsflag,$prevread,&group_args($group),&mt("Unlike this posting"));
                               } else {
                                   $$discussionitems[$idx].='<img border="0" src="/res/adm/pages/thumbsdown_gray.png" alt="'.&mt('You unlike this posting').'" />';
                               }
                               my $thislikes=$likes{$symb.':'.$idx.':likes'};
                               if ($thislikes>0) {
                                   $$discussionitems[$idx].='&nbsp;('.&mt("[_1] likes",$thislikes).')';
                               } elsif ($thislikes<0) {
                                   $$discussionitems[$idx].='&nbsp;('.&mt("[_1] unlikes",abs($thislikes)).')';
                               }
   # If there is any history to this post, inform the reader
                             if ($contrib{$idx.':history'}) {                              if ($contrib{$idx.':history'}) {
                                 my @postversions = ();                                  my @postversions = ();
                                 $$discussionitems[$idx] .= &mt('This post has been edited by the author.');                                  $$discussionitems[$idx] .= '&nbsp;&nbsp;'.&mt('This post has been edited by the author.');
                                 if ($seeid) {                                  if ($seeid) {
                                     $$discussionitems[$idx] .= '&nbsp;&nbsp;'.                                      $$discussionitems[$idx] .= '&nbsp;&nbsp;'.
                                          &discussion_link($symb,&mt('Display all versions'),'allversions',$idx,$$newpostsflag,$prevread,&group_args($group));                                           &discussion_link($symb,&mt('Display all versions'),'allversions',$idx,$$newpostsflag,$prevread,&group_args($group));
Line 1596  sub mail_screen { Line 1608  sub mail_screen {
   }    }
   
   my %lt = &Apache::lonlocal::texthash(    my %lt = &Apache::lonlocal::texthash(
             'myqu' => 'My question/comment/feedback:',              'myqu' => 'Question/comment/feedback:',
             'title' => 'Title',              'title' => 'Title',
             'reta' => 'Retained attachments',              'reta' => 'Retained attachments',
             'atta' => 'Attachment',              'atta' => 'Attachment',
            );             );
     if($env{'form.editdisc'} || $env{'form.replydisc'}){
       %lt = &Apache::lonlocal::texthash(
               'myqu' => 'Post Discussion',
       );
     }
   my $restitle = &get_resource_title($caller_symb,$feedurl);    my $restitle = &get_resource_title($caller_symb,$feedurl);
   my $quote='';    my $quote='';
   my $subject = '';    my $subject = '';
Line 1811  END Line 1828  END
   }    }
   $r->print(<<END);    $r->print(<<END);
 $start_page  $start_page
   <h1>$lt{'myqu'}</h1>
 $header  $header
 <form action="/adm/feedback" method="post" name="mailform"  <form action="/adm/feedback" method="post" name="mailform"
 enctype="multipart/form-data">  enctype="multipart/form-data">
Line 1831  END Line 1849  END
   $r->print(<<END);    $r->print(<<END);
 $options  $options
 $quote  $quote
 <p>$lt{'myqu'}  <p>
 $textareaheader  $textareaheader
 </p>  </p>
   <br>
 <p>  <p>
 $latexHelp  $latexHelp
 </p>  </p>
 <p>  <p>
 $lt{'title'}: <input type="text" name="subject" size="30" value="$subject" /></p>  
 <p>  
 <textarea name="comment" id="comment" cols="60" rows="10" $textareaclass>$comment  
 </textarea></p>  
 END  END
   
   $r->print(&Apache::lonhtmlcommon::start_pick_box());
   $r->print(&Apache::lonhtmlcommon::row_title(&mt('Subject')));
   $r->print('<input type="text" name="subject" size="30" value="'."$subject".'" /></p>');
   $r->print(&Apache::lonhtmlcommon::row_closure());
   $r->print(&Apache::lonhtmlcommon::row_title(&mt('Message')));
   $r->print('<textarea name="comment" id="comment" cols="60" rows="10" $textareaclass>'."$comment".
   '</textarea>');
   $r->print(&Apache::lonhtmlcommon::row_closure(1));
   $r->print(&Apache::lonhtmlcommon::end_pick_box());
   
     if ( ($env{'form.editdisc'}) || ($env{'form.replydisc'}) ) {      if ( ($env{'form.editdisc'}) || ($env{'form.replydisc'}) ) {
         if ($env{'form.origpage'}) {          if ($env{'form.origpage'}) {
             foreach my $attach (@currnewattach) {              foreach my $attach (@currnewattach) {
Line 3065  sub adddiscuss { Line 3091  sub adddiscuss {
        $newrecord{'subnumber'}=$record{'subnumber'}+1;         $newrecord{'subnumber'}=$record{'subnumber'}+1;
        $status.='<br />'.&mt('Registering').': '.         $status.='<br />'.&mt('Registering').': '.
                &Apache::lonnet::cstore(\%newrecord,'_discussion');                 &Apache::lonnet::cstore(\%newrecord,'_discussion');
          &updatekarma();
     }      }
     } else {      } else {
  $status.='Failed.';   $status.='Failed.';
Line 3112  sub updatekarma { Line 3139  sub updatekarma {
     unless ($udom)  { $udom=$env{'user.domain'}; }      unless ($udom)  { $udom=$env{'user.domain'}; }
     unless ($course) { $course=$env{'request.course.id'}; }      unless ($course) { $course=$env{'request.course.id'}; }
     my $karma=&calcdiscussionkarma($uname,$udom,$course);      my $karma=&calcdiscussionkarma($uname,$udom,$course);
       &Apache::lonnet::cstore({ 'karma' => $karma },'_discussion',$course,$udom,$uname);
       &Apache::lonnet::do_cache_new('karma',$uname.':'.$udom.':'.$course,$karma,3600);
       return $karma;
   }
   
   # Retrieve karma
   
   sub userkarma {
       my ($uname,$udom,$course)=@_;
       unless ($uname) { $uname=$env{'user.name'}; }
       unless ($udom)  { $udom=$env{'user.domain'}; }
       unless ($course) { $course=$env{'request.course.id'}; }
       my $hashkey=$uname.':'.$udom.':'.$course;
       my ($karma,$cached)=&Apache::lonnet::is_cached_new('karma',$hashkey);
       if ($cached) {
           return $karma;
       }
       my %userdisc=&getdiscussionrecords($uname,$udom,$course);
       $karma=$userdisc{'karma'};
       &Apache::lonnet::do_cache_new('karma',$hashkey,$karma,3600);
       return $karma;
 }  }
   
 # Store discussion credit  # Store discussion credit
Line 3148  sub storediscussionlikes { Line 3196  sub storediscussionlikes {
                    'likes' => $likes,                     'likes' => $likes,
                    'totallikes' => $totallikes,                     'totallikes' => $totallikes,
                    'totalvotes' => $totalvotes);                     'totalvotes' => $totalvotes);
     return &Apache::lonnet::cstore(\%newrecord,'_discussion',$course,$udom,$uname);      my $status=&Apache::lonnet::cstore(\%newrecord,'_discussion',$course,$udom,$uname);
       if ($status eq 'ok') {
           &updatekarma($uname,$udom,$course);
       }
       return $status;
 }  }
   
 sub get_discussion_info {  sub get_discussion_info {
Line 3296  sub modify_attachments { Line 3348  sub modify_attachments {
   
     my %lt = &Apache::lonlocal::texthash(      my %lt = &Apache::lonlocal::texthash(
                'subj' => 'Subject',                 'subj' => 'Subject',
                'thfo' => 'The following attachments were part of the most recent saved version of this posting.',  
                'chth' => 'Check the checkboxes for any you wish to remove.',                 'chth' => 'Check the checkboxes for any you wish to remove.',
                'thef' => 'The following attachments have been uploaded for inclusion with this posting.',                 'thef' => 'The following attachments have been uploaded for inclusion with this posting.',
                'adda' => 'Add a new attachment to this post.',                 'adda' => 'Add a new attachment to this post',
                'stch' => 'Save Changes',                 'stch' => 'Save Changes',
                  'clic' => 'Add/remove attachments',
              );               );
     my $js = <<END;      my $js = <<END;
 <script type="text/javascript">  <script type="text/javascript">
Line 3314  END Line 3366  END
     # Breadcrumbs      # Breadcrumbs
     my $brcrum = [{'href' => '',      my $brcrum = [{'href' => '',
                    'text' => 'Discussion Post Attachments'}];                     'text' => 'Discussion Post Attachments'}];
     my %parms=();      my %parms=('only_body' => 1);
     if ($env{'form.modal'} ne 'yes') { 'bread_crumbs' => $brcrum }      if ($env{'form.modal'} ne 'yes') { 'bread_crumbs' => $brcrum }
   
     my $start_page =       my $start_page = 
Line 3343  $start_page Line 3395  $start_page
 $toolarge  $toolarge
 <form name="modattachments" method="post" enctype="multipart/form-data" action="/adm/feedback?attach=$symb">  <form name="modattachments" method="post" enctype="multipart/form-data" action="/adm/feedback?attach=$symb">
  <br />   <br />
  <table class="LC_data_table">   <h1>$lt{'clic'}</h1>
   <tr>  
    <td colspan="2">  
     <b>Subject:</b> <b>$subject</b><br /><br />  
 END  END
     if ($idx) {      $r->print(&Apache::lonhtmlcommon::start_pick_box());
         if ($attachmenturls) {      $r->print(&Apache::lonhtmlcommon::row_title(&mt('Subject')));
             my @currold = keys(%currattach);      $r->print('<b>'.$subject.'</b>');
             if (@currold > 0) {      $r->print(&Apache::lonhtmlcommon::row_closure());
                 $r->print($lt{'thfo'}.'<br />'.$lt{'chth'}.'<br />'."\n");        $r->print(&Apache::lonhtmlcommon::row_title($lt{'adda'}));
                 foreach my $id (@currold) {      $r->print('<input type="file" name="addnewattach" /><input type="button" name="upload" value="Upload" onclick="this.form.submit()" />  '.$attachmaxtext);
                     my $attachurl = &HTML::Entities::decode($attachments{$id}{'filename'});   
                     $attachurl =~ m#/([^/]+)$#;      if(($idx)||(ref($currnewattach) eq 'ARRAY') && (@{$currnewattach} > 0)){
                     $r->print('<label><input type="checkbox" name="deloldattach" value="'.$id.'" />&nbsp;'.$1.'</label><br />'."\n");          $r->print(&Apache::lonhtmlcommon::row_closure());
           $r->print(&Apache::lonhtmlcommon::row_title(&mt('Attachments')));
           if ($idx) {
               if ($attachmenturls) {
                   my @currold = keys(%currattach);
                   if (@currold > 0) {
                       $r->print($lt{'thfo'}.'<br />'.$lt{'chth'}.'<br />'."\n");  
                       foreach my $id (@currold) {
                           my $attachurl = &HTML::Entities::decode($attachments{$id}{'filename'}); 
                           $attachurl =~ m#/([^/]+)$#;
                           $r->print('<label><input type="checkbox" name="deloldattach" value="'.$id.'" />&nbsp;'.$1.'</label><br />'."\n");
                       }
                       $r->print("<br />");
                 }                  }
                 $r->print("<br />");  
             }              }
         }          }
     }          if ((ref($currnewattach) eq 'ARRAY') && (@{$currnewattach} > 0)) {
     if ((ref($currnewattach) eq 'ARRAY') && (@{$currnewattach} > 0)) {              $r->print($lt{'chth'}.'<br />'."\n");
         $r->print($lt{'thef'}.'<br />'.$lt{'chth'}.'<br />'."\n");              foreach my $attach (@{$currnewattach}) {
         foreach my $attach (@{$currnewattach}) {                  $attach =~ m#/([^/]+)$#;
             $attach =~ m#/([^/]+)$#;                  $r->print('<label><input type="checkbox" name="delnewattach" value="'.$attach.'" />&nbsp;'.$1.'</label><br />'."\n");
             $r->print('<label><input type="checkbox" name="delnewattach" value="'.$attach.'" />&nbsp;'.$1.'</label><br />'."\n");              }
         }          }
         $r->print("<br />");   
     }      }
       $r->print(&Apache::lonhtmlcommon::row_closure(1));
       $r->print(&Apache::lonhtmlcommon::end_pick_box());
     $r->print(<<END);      $r->print(<<END);
    </td></tr>  
    <tr>  
     <td>  
    $lt{'adda'}</td><td><input type="file" name="addnewattach" /><input type="button" name="upload" value="Upload" onclick="this.form.submit()" />      
    </td>  
   </tr>  
   <tr>  
    <td colspan="2">$attachmaxtext</td>  
   </tr>  
  </table>  
 <input type="hidden" name="subject" value="$env{'form.subject'}" />  <input type="hidden" name="subject" value="$env{'form.subject'}" />
 <input type="hidden" name="comment" value="$env{'form.comment'}" />  <input type="hidden" name="comment" value="$env{'form.comment'}" />
 <input type="hidden" name="timestamp" value="$env{'form.timestamp'}" />  <input type="hidden" name="timestamp" value="$env{'form.timestamp'}" />
Line 3438  sub generate_attachments_button { Line 3489  sub generate_attachments_button {
     my $origpage = $ENV{'REQUEST_URI'};      my $origpage = $ENV{'REQUEST_URI'};
     my $att=$attachnum.' '.&mt("attachments");      my $att=$attachnum.' '.&mt("attachments");
     my %lt = &Apache::lonlocal::texthash(      my %lt = &Apache::lonlocal::texthash(
                 'clic' => 'Click to add/remove attachments',                  'clic' => 'Add/remove attachments',
     );       ); 
     my $response = (<<END);      my $response = (<<END);
 <br />  <br />
 <form name="attachment" action="/adm/feedback?attach=$ressymb" method="post">  <form name="attachment" action="/adm/feedback?attach=$ressymb" method="post">
 $lt{'clic'}:&nbsp;<input type="button" value="$att"  <input type="button" value="$lt{'clic'}"
 onclick="if (typeof(document.mailform.onsubmit)=='function') {document.mailform.onsubmit();};this.form.comment.value=escape(document.mailform.comment.value);this.form.subject.value=escape(document.mailform.subject.value);  onclick="if (typeof(document.mailform.onsubmit)=='function') {document.mailform.onsubmit();};this.form.comment.value=escape(document.mailform.comment.value);this.form.subject.value=escape(document.mailform.subject.value);
 END  END
     if (!$blockblog) {      if (!$blockblog) {

Removed from v.1.332  
changed lines
  Added in v.1.340


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>