Diff for /loncom/interface/lonfeedback.pm between versions 1.350 and 1.363

version 1.350, 2012/03/17 04:55:10 version 1.363, 2013/01/03 20:51:23
Line 821  sub can_see_hidden { Line 821  sub can_see_hidden {
   
 sub discussion_link {  sub discussion_link {
    my ($ressymb,$linktext,$cmd,$item,$flag,$prev,$adds,$title)=@_;     my ($ressymb,$linktext,$cmd,$item,$flag,$prev,$adds,$title)=@_;
    my $link='/adm/feedback?inhibitmenu=yes&modal=yes&'.$cmd.'='.&escape($ressymb).':::'.$item;     my $link='/adm/feedback?inhibitmenu=yes&modal=yes&'.$cmd.'='.&escape($ressymb).':::'.$item;
    if ($flag) { $link .= '&previous='.$prev; }     if ($flag) { $link .= '&previous='.$prev; }
    if ($adds) { $link .= $adds; }     if ($adds) { $link .= $adds; }
    my $width=600;     my $width=600;
Line 1056  sub build_posting_display { Line 1056  sub build_posting_display {
                      &filter_regexp($rolefilter,$sectionpick,$statusfilter);                       &filter_regexp($rolefilter,$sectionpick,$statusfilter);
             $rolematch = $roleregexp.':'.$secregexp.':'.$statusregexp;              $rolematch = $roleregexp.':'.$secregexp.':'.$statusregexp;
         }          }
           my %votestyle;
         if ($seeid || $canvote) {          if ($seeid || $canvote) {
 # We need to go through this twice, first to get the likes/dislikes, then to actually build the display  # We need to go through this twice, first to get the likes/dislikes, then to actually build the display
             for (my $id=1;$id<=$contrib{'version'};$id++) {              for (my $id=1;$id<=$contrib{'version'};$id++) {
Line 1063  sub build_posting_display { Line 1064  sub build_posting_display {
                 next if ($contrib{$idx.':deleted'});                  next if ($contrib{$idx.':deleted'});
                 next if ($contrib{$idx.':hidden'});                  next if ($contrib{$idx.':hidden'});
                 unless ((($hiddens{$idx}) && (!$seehidden)) || ($deletions{$idx}) || (!$contrib{$idx.':message'})) {                  unless ((($hiddens{$idx}) && (!$seehidden)) || ($deletions{$idx}) || (!$contrib{$idx.':message'})) {
                       push(@theselikes,$likes{$symb.':'.$idx.':likes'});
                     if ($likes{$symb.':'.$idx.':likes'} ne '') {                      if ($likes{$symb.':'.$idx.':likes'} ne '') {
                         push(@theselikes,$likes{$symb.':'.$idx.':likes'});  
                         if (ref($likes{$symb.':'.$idx.':likers'}) eq 'HASH') {                          if (ref($likes{$symb.':'.$idx.':likers'}) eq 'HASH') {
                             if (exists($likes{$symb.':'.$idx.':likers'}{$thisuser})) {                              if (exists($likes{$symb.':'.$idx.':likers'}{$thisuser})) {
                                 $userlikes{$idx} = 1;                                  $userlikes{$idx} = 1;
Line 1101  sub build_posting_display { Line 1102  sub build_posting_display {
             $twoplus=$ave+2.*$stddev;              $twoplus=$ave+2.*$stddev;
             $oneminus=$ave-$stddev;              $oneminus=$ave-$stddev;
             $twominus=$ave-2.*$stddev;              $twominus=$ave-2.*$stddev;
               if ($#theselikes>1) {
                   foreach my $class ('twoplus','oneplus','zero','oneminus','twominus') {
                       my $fontstyle = $env{'course.'.$env{'request.course.id'}.'.discussion_post_fonts_'.$class};
                       if ($fontstyle ne '') {
                           my ($size,$weight,$style,$other) = split(/,/,$fontstyle);
                           if ($size ne '') {
                               $votestyle{$class} .= 'font-size: '.$size.';';
                           }
                           if ($weight ne '') {
                               $votestyle{$class} .= 'font-weight: '.$weight.';';
                           }
                           if ($style ne '') {
                               $votestyle{$class} .= 'font-style: '.$style.';';
                           }
                           if ($other ne '') {
                               $votestyle{$class} .= $other;
                           }
                           if ($votestyle{$class} ne '') {
                               $votestyle{$class} = 'style="'.$votestyle{$class}.'"';
                           }
                       }
                   }
               }
         }          }
 #  #
 # 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 1436  sub build_posting_display { Line 1460  sub build_posting_display {
                                 $$discussionitems[$idx].='&nbsp;&nbsp;'.$ctlink;                                  $$discussionitems[$idx].='&nbsp;&nbsp;'.$ctlink;
                             }                              }
                             my $thislikes=$likes{$symb.':'.$idx.':likes'};                              my $thislikes=$likes{$symb.':'.$idx.':likes'};
                             my $likesize="100";                              my $likestyle;
                             if ($seeid || $canvote) {                              if ($seeid || $canvote) {
 # Figure out size based on likes  # Figure out size based on likes
                                   my $class = 'zero';
                                 my $thislikes=$likes{$symb.':'.$idx.':likes'};                                  my $thislikes=$likes{$symb.':'.$idx.':likes'};
                                 if ($thislikes>$twoplus) {                                  if ($thislikes>$twoplus) {
                                     $likesize="200";                                      $class = 'twoplus';
                                 } elsif ($thislikes>$oneplus) {                                  } elsif ($thislikes>$oneplus) {
                                     $likesize="150";                                      $class = 'oneplus';
                                 }                                  }
                                 if ($thislikes<$twominus) {                                  if ($thislikes<$twominus) {
                                     $likesize="50";                                      $class = 'twominus';
                                 } elsif ($thislikes<$oneminus) {                                  } elsif ($thislikes<$oneminus) {
                                     $likesize="75";                                      $class = 'oneminus';
                                 }                                  }
                                   $likestyle = $votestyle{$class};
                             }                              }
 # Actually glue in the message itself  # Actually glue in the message itself
                             $$discussionitems[$idx].= '<br /><blockquote>'.                              $$discussionitems[$idx].= '<br /><blockquote>'.
                                     "<div style='font-size:$likesize%'>".                                      "<div $likestyle>".
                                     $message.                                      $message.
                                     '</div></blockquote>';                                      '</div></blockquote>';
                             if ($canvote) {                              if ($canvote) {
                                   my $ownpost;
                                   if (($uname eq $env{'user.name'}) &&
                                       ($udom eq $env{'user.domain'})) {
                                       $ownpost = 1;
                                   }   
 # Put in the like and unlike buttons  # Put in the like and unlike buttons
                                 if (($uname eq $env{'user.name'}) && ($udom eq $env{'user.domain'})) {                                  if ($ownpost || (($hiddens{$idx}) && ($seehidden))) { 
                                     my $novote = &mt('No voting for your own posts');                                      my $novote;
                                       if ($ownpost) { 
                                           $novote = &mt('No voting for your own posts.');
                                       } else {
                                           $novote = &mt('No voting for hidden posts.');
                                       }
                                     $$discussionitems[$idx].=                                      $$discussionitems[$idx].=
                                         '<a href="javascript:alert('."'$novote'".');" style="text-decoration: none;">'.                                          '<a href="javascript:alert('."'$novote'".');" style="text-decoration: none;">'.
                                         '<img border="0" src="/res/adm/pages/thumbsup_novote.png" alt="'.$novote.'" />&nbsp;'.                                          '<img border="0" src="/res/adm/pages/thumbsup_novote.png" alt="'.$novote.'" />&nbsp;'.
                                         '<img border="0" src="/res/adm/pages/thumbsdown_novote.png" alt="'.$novote.'" /></a>';                                           '<img border="0" src="/res/adm/pages/thumbsdown_novote.png" alt="'.$novote.'" /></a>'; 
   
                                 } else {                                  } else {
                                     if ($userlikes{$idx}) {                                      if ($userlikes{$idx}) {
                                         $$discussionitems[$idx].='<img border="0" src="/res/adm/pages/thumbsup_gray.png" alt="'.&mt('You like this posting').'" />';                                          $$discussionitems[$idx].='<img border="0" src="/res/adm/pages/thumbsup_gray.png" alt="'.&mt('You like this posting').'" />';
Line 1796  END Line 1833  END
    $env{'course.'.$env{'request.course.id'}.'.domain'},     $env{'course.'.$env{'request.course.id'}.'.domain'},
    $env{'course.'.$env{'request.course.id'}.'.num'});     $env{'course.'.$env{'request.course.id'}.'.num'});
       unless (($contrib{'hidden'}=~/\.$idx\./) || ($contrib{'deleted'}=~/\.$idx\./)) {        unless (($contrib{'hidden'}=~/\.$idx\./) || ($contrib{'deleted'}=~/\.$idx\./)) {
             my $numoldver = 0;
           if ($contrib{$idx.':history'}) {            if ($contrib{$idx.':history'}) {
               if ($contrib{$idx.':history'} =~ /:/) {                if ($contrib{$idx.':history'} =~ /:/) {
                   my @oldversions = split(/:/,$contrib{$idx.':history'});                    my @oldversions = split(/:/,$contrib{$idx.':history'});
Line 1804  END Line 1842  END
                   $numoldver = 1;                    $numoldver = 1;
               }                }
           }            }
           if ($env{'form.replydisc'}) {            if ($idx > 0) {
               if ($contrib{$idx.':history'}) {                my (%msgversions,%subversions,$htmldecode);
                   if ($contrib{$idx.':history'} =~ /:/) {                $htmldecode = 0;
                       my @oldversions = split(/:/,$contrib{$idx.':history'});                if ($env{'form.replydisc'}) {
                       $numoldver = @oldversions;                    $htmldecode = 1;
                   } else {  
                       $numoldver = 1;  
                   }  
               }                }
               if ($idx > 0) {                &get_post_versions(\%msgversions,$contrib{$idx.':message'},0,$numoldver);
                   my %msgversions = ();                &get_post_versions(\%subversions,$contrib{$idx.':subject'},$htmldecode,
                   &get_post_versions(\%msgversions,$contrib{$idx.':message'},0,$numoldver);                                   $numoldver);
                 $subject = $subversions{$numoldver};
                 if ($env{'form.replydisc'}) {
                   $quote = $msgversions{$numoldver};                    $quote = $msgversions{$numoldver};
               }                    $subject = &HTML::Entities::encode(&mt('Re: ').$subject,'<>&"');
               if ($idx > 0) {                } else {
                   my %subversions = ();  
                   &get_post_versions(\%subversions,$contrib{$idx.':subject'},1,$numoldver);  
                   $subject = &mt('Re: ').$subversions{$numoldver};  
               }  
               $subject = &HTML::Entities::encode($subject,'<>&"');  
           } else {  
               $attachmenturls = $contrib{$idx.':attachmenturl'};  
               if ($idx > 0) {  
                   my %msgversions = ();  
                   &get_post_versions(\%msgversions,$contrib{$idx.':message'},0,$numoldver);  
                   $comment = $msgversions{$numoldver};                    $comment = $msgversions{$numoldver};
                   my %subversions = ();  
                   &get_post_versions(\%subversions,$contrib{$idx.':subject'},0,$numoldver);  
                   $subject = $subversions{$numoldver};   
               }                }
             }
             if ($env{'form.editdisc'}) {
                 $attachmenturls = $contrib{$idx.':attachmenturl'};
               if (defined($contrib{$idx.':replyto'})) {                if (defined($contrib{$idx.':replyto'})) {
                   $parentmsg = $contrib{$idx.':replyto'};                    $parentmsg = $contrib{$idx.':replyto'};
               }                }
Line 1925  END Line 1952  END
   
   my %onload = ('onload' => 'window.focus();setposttype();');    my %onload = ('onload' => 'window.focus();setposttype();');
   my %parms=('add_entries' => \%onload);    my %parms=('add_entries' => \%onload);
   if ($env{'form.modal'} ne 'yes') { 'bread_crumbs' => $brcrum }    if ($env{'form.modal'} ne 'yes') { $parms{'bread_crumbs'} = $brcrum; }
   my $start_page=    my $start_page=
       &Apache::loncommon::start_page('Resource Feedback and Discussion',$js,\%parms);        &Apache::loncommon::start_page('Resource Feedback and Discussion',$js,\%parms);
   
Line 1934  END Line 1961  END
       unless (&contains_block_html($quote)) {        unless (&contains_block_html($quote)) {
           &newline_to_br(\$quote);            &newline_to_br(\$quote);
       }        }
       $quote='<blockquote>'.&Apache::lontexconvert::msgtexconverted($quote).'</blockquote>';          $quote=&Apache::lonhtmlcommon::start_pick_box().
                  &Apache::lonhtmlcommon::row_title(&mt('Quote')).
                  &Apache::lontexconvert::msgtexconverted($quote).
                  &Apache::lonhtmlcommon::row_closure(1).
                  &Apache::lonhtmlcommon::end_pick_box();
   }    }
   my $header='';    my $header='';
   unless ($env{'form.modal'}) {    unless ($env{'form.modal'}) {
Line 1962  END Line 1993  END
   }    }
   $r->print(<<END);    $r->print(<<END);
 $options  $options
   <br />
   END
   $r->print(&Apache::lonhtmlcommon::start_pick_box());
   $r->print(<<END);
 $quote  $quote
 <p>  <p>
 $textareaheader  $textareaheader
 </p>  </p>
 <br>  
 <p>  <p>
 $latexHelp  $latexHelp
 </p>  </p>
 <p>  <p>
 END  END
   
     $r->print(&Apache::lonhtmlcommon::start_pick_box());      
     $r->print(&Apache::lonhtmlcommon::row_title(&mt('Subject')));      $r->print(&Apache::lonhtmlcommon::row_title(&mt('Subject')));
     $r->print('<input type="text" name="subject" size="30" value="'.      $r->print('<input type="text" name="subject" size="30" value="'.
               $subject.'" /></p>');                $subject.'" /></p>');
     $r->print(&Apache::lonhtmlcommon::row_closure());      $r->print(&Apache::lonhtmlcommon::row_closure());
     $r->print(&Apache::lonhtmlcommon::row_title(&mt('Message')));      $r->print(&Apache::lonhtmlcommon::row_title(&mt('Message')));
     $r->print('<textarea name="comment" id="comment" cols="60" rows="10" '.      $r->print('<textarea name="comment" id="comment" cols="55" rows="10" '.
               $textareaclass.'>'.$comment.                $textareaclass.'>'.$comment.
               '</textarea>');                '</textarea>');
     $r->print(&Apache::lonhtmlcommon::row_closure(1));      $r->print(&Apache::lonhtmlcommon::row_closure(1));
Line 2017  END Line 2051  END
         $r->print('<input type="hidden" name="ref" value="'.$env{'form.ref'}.'" />');          $r->print('<input type="hidden" name="ref" value="'.$env{'form.ref'}.'" />');
     }      }
     $r->print(<<END);      $r->print(<<END);
 <p>  
 <input type="hidden" name="sendit" value="1" />  <input type="hidden" name="sendit" value="1" />
 <input type="button" value="$send" onclick='gosubmit();' />  <input type="button" value="$send" onclick='gosubmit();' />
 </p>  
 </form>  </form>
 END  END
     if ($env{'form.editdisc'} || $env{'form.replydisc'}) {      if ($env{'form.editdisc'} || $env{'form.replydisc'}) {
Line 2035  END Line 2067  END
             $attachnum += @currnewattach;              $attachnum += @currnewattach;
         }          }
         my $blockblog = &Apache::loncommon::blocking_status('blogs');          my $blockblog = &Apache::loncommon::blocking_status('blogs');
         $r->print(&generate_attachments_button($postidx,$attachnum,$ressymb,$now,\@currnewattach,\@currdelold,$numoldver,'',$blockblog));  
         if ($attachnum > 0) {          if ($attachnum > 0) {
             if (@currnewattach > 0) {              if (@currnewattach > 0) {
                 $newattachmsg .= '<br /><b>'.&mt('New attachments').'</b><br />';                  $newattachmsg .= '<br /><b>'.&mt('New attachments').'</b><br />';
Line 2055  END Line 2086  END
                 $r->print("<br /><b>$lt{'reta'}</b>:$attachmsg<br />\n");                  $r->print("<br /><b>$lt{'reta'}</b>:$attachmsg<br />\n");
             }              }
             if ($newattachmsg) {              if ($newattachmsg) {
                 $r->print("$newattachmsg<br />");                  $r->print("$newattachmsg");
             }              }
         }          }
           $r->print(&generate_attachments_button($postidx,$attachnum,$ressymb,$now,\@currnewattach,\@currdelold,$numoldver,'',$blockblog));
     }      }
     $r->print(&generate_preview_button().      $r->print(&generate_preview_button().
       &Apache::loncommon::end_page());        &Apache::loncommon::end_page());
Line 2666  sub fail_redirect { Line 2698  sub fail_redirect {
     'only_body' => 1,}));      'only_body' => 1,}));
   $r->print(<<ENDFAILREDIR);    $r->print(<<ENDFAILREDIR);
 <img align="right" src="$logo" />  <img align="right" src="$logo" />
 <b>$lt{'sorr'}</b>  <p class="LC_warning">$lt{'sorr'}</p>
 ENDFAILREDIR  ENDFAILREDIR
   $r->print(&Apache::loncommon::end_page());    $r->print(&Apache::loncommon::end_page());
 }  }
Line 3458  END Line 3490  END
     my $brcrum = [{'href' => '',      my $brcrum = [{'href' => '',
                    'text' => 'Discussion Post Attachments'}];                     'text' => 'Discussion Post Attachments'}];
     my %parms=('only_body' => 1);      my %parms=('only_body' => 1);
     if ($env{'form.modal'} ne 'yes') { 'bread_crumbs' => $brcrum }      if ($env{'form.modal'} ne 'yes') { $parms{'bread_crumbs'} = $brcrum; }
   
     my $start_page =       my $start_page = 
  &Apache::loncommon::start_page('Discussion Post Attachments',$js,\%parms);   &Apache::loncommon::start_page('Discussion Post Attachments',$js,\%parms);
Line 3485  END Line 3517  END
 $start_page  $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 />  
  <h1>$lt{'clic'}</h1>   <h1>$lt{'clic'}</h1>
 END  END
     $r->print(&Apache::lonhtmlcommon::start_pick_box());      $r->print(&Apache::lonhtmlcommon::start_pick_box());
Line 3876  sub handler { Line 3908  sub handler {
                      'text' => 'Discussion Post Versions'}];                       'text' => 'Discussion Post Versions'}];
               
       my %parms=();        my %parms=();
       if ($env{'form.modal'} ne 'yes') { 'bread_crumbs' => $brcrum }        if ($env{'form.modal'} ne 'yes') { $parms{'bread_crumbs'} = $brcrum; }
   
       $r->print(&Apache::loncommon::start_page('Discussion Post Versions',undef,\%parms));        $r->print(&Apache::loncommon::start_page('Discussion Post Versions',undef,\%parms));
   
Line 3949  sub handler { Line 3981  sub handler {
       my $feedurl = '/adm/navmaps';        my $feedurl = '/adm/navmaps';
       if ($env{'form.navurl'}) { $feedurl .= '?'.$env{'form.navurl'}; }        if ($env{'form.navurl'}) { $feedurl .= '?'.$env{'form.navurl'}; }
       my %lt = &Apache::lonlocal::texthash(        my %lt = &Apache::lonlocal::texthash(
           'mnpa' => 'Marked "New" posts as read in a total of',  
           'robb' => 'resources/bulletin boards.',  
           'twnp' => 'There are currently no resources or discussion boards with unread discussion postings.'            'twnp' => 'There are currently no resources or discussion boards with unread discussion postings.'
       );               );       
       foreach my $res (@resources) {        foreach my $res (@resources) {
Line 3959  sub handler { Line 3989  sub handler {
           my $lastkey = $ressymb.'_lastread';            my $lastkey = $ressymb.'_lastread';
           $discinfo{$lastkey} = $env{'form.navtime'};            $discinfo{$lastkey} = $env{'form.navtime'};
       }        }
       my $textline = "<b>$lt{'mnpa'} $numitems $lt{'robb'}</b>";        my $textline = '<b>'.
                        &mt('Marked "New" posts as read in a total of [_1] resources/bulletin boards.',
                            $numitems).
                        '</b>';
       if ($numitems > 0) {        if ($numitems > 0) {
           &Apache::lonnet::put('nohist_'.$env{'request.course.id'}.'_discuss',            &Apache::lonnet::put('nohist_'.$env{'request.course.id'}.'_discuss',
      \%discinfo,$env{'user.domain'},$env{'user.name'});       \%discinfo,$env{'user.domain'},$env{'user.name'});
Line 4127  ENDREDIR Line 4160  ENDREDIR
           if (&discussion_vote_available($status,$realsymb)) {            if (&discussion_vote_available($status,$realsymb)) {
               my %contrib=&Apache::lonnet::restore($symb,$env{'request.course.id'},                my %contrib=&Apache::lonnet::restore($symb,$env{'request.course.id'},
                                                    $cdom,$cnum);                                                     $cdom,$cnum);
                 my $ownpost;
               if (($contrib{$idx.':sendername'} eq $env{'user.name'}) &&                 if (($contrib{$idx.':sendername'} eq $env{'user.name'}) && 
                   ($contrib{$idx.':senderdomain'} eq $env{'user.domain'})) {                    ($contrib{$idx.':senderdomain'} eq $env{'user.domain'})) {
                   $result = &mt("Vote not registered. No voting for your own posts.");                    $ownpost = 1;
                 }
                 if ($ownpost || $contrib{$idx.':hidden'} || $contrib{$idx.':deleted'}) {
                     $result = &mt('Vote not registered.').' ';
                 }
                 if ($ownpost) {
                     $result .= &mt('No voting for your own posts.');
                 } elsif ($contrib{$idx.':hidden'}) {
                     $result .= &mt('No voting for hidden posts.');
                 } elsif ($contrib{$idx.':deleted'}) {
                     $result .= &mt('No voting for deleted posts.');
               } else {                } else {
   
 #  #
 # Likes and unlikes are in db-file "disclikes" of the course  # Likes and unlikes are in db-file "disclikes" of the course
 # The prefix is the $symb to identify the resource discussion,  # The prefix is the $symb to identify the resource discussion,
Line 4773  None Line 4816  None
   
 =item list_discussion()  =item list_discussion()
   
 =item can_see_discussion()  =item can_see_hidden()
   
   =item discussion_link()
   
 =item send_feedback_link()  =item send_feedback_link()
   

Removed from v.1.350  
changed lines
  Added in v.1.363


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