Diff for /loncom/interface/lonfeedback.pm between versions 1.339 and 1.344

version 1.339, 2012/03/13 05:37:49 version 1.344, 2012/03/15 21:55:13
Line 1680  sub mail_screen { Line 1680  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 1895  END Line 1900  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 1915  END Line 1921  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 3396  sub modify_attachments { Line 3412  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 3414  END Line 3430  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 3443  $start_page Line 3459  $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'});       if(($idx)||(ref($currnewattach) eq 'ARRAY') && (@{$currnewattach} > 0)){
                     $attachurl =~ m#/([^/]+)$#;          $r->print(&Apache::lonhtmlcommon::row_closure());
                     $r->print('<label><input type="checkbox" name="deloldattach" value="'.$id.'" />&nbsp;'.$1.'</label><br />'."\n");          $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 3536  sub generate_attachments_button { Line 3550  sub generate_attachments_button {
     my ($idx,$attachnum,$ressymb,$now,$currnewattach,$deloldattach,      my ($idx,$attachnum,$ressymb,$now,$currnewattach,$deloldattach,
         $numoldver,$mode,$blockblog) = @_;          $numoldver,$mode,$blockblog) = @_;
     my $origpage = $ENV{'REQUEST_URI'};      my $origpage = $ENV{'REQUEST_URI'};
       my $att=$attachnum.' '.&mt("attachments");
     my %lt = &Apache::lonlocal::texthash(      my %lt = &Apache::lonlocal::texthash(
                 'clic' => 'Add/remove attachments',                  'clic' => 'Add/remove attachments',
     );       ); 
Line 4066  ENDREDIR Line 4081  ENDREDIR
       my $result;        my $result;
       my $realsymb = &get_realsymb($symb);        my $realsymb = &get_realsymb($symb);
       if (&discussion_vote_available($status,$realsymb)) {        if (&discussion_vote_available($status,$realsymb)) {
             my %contrib=&Apache::lonnet::restore($symb,$env{'request.course.id'},
                              $env{'course.'.$env{'request.course.id'}.'.domain'},
                              $env{'course.'.$env{'request.course.id'}.'.num'});
 #  #
 # 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,
 # and the $idx to identify the entry  # and the $idx to identify the entry
 #  #
           my $prefix=$symb.':'.$idx.':';            my $prefix=$symb.':'.$idx.':';
           my %contrib=&Apache::lonnet::dump('disclikes',            my %likes=&Apache::lonnet::dump('disclikes',
                                         $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'},
                                         '^'.$prefix);                                '^'.$prefix);
   
 # Get current like or unlike status for the $idx for this user.  # Get current like or unlike status for the $idx for this user.
           my $thisuser=$env{'user.name'}.':'.$env{'user.domain'};            my $thisuser=$env{'user.name'}.':'.$env{'user.domain'};
           my ($userlikes,$userunlikes);            my ($userlikes,$userunlikes);
           if (ref($contrib{$prefix.'likers'}) eq 'HASH') {            if (ref($likes{$prefix.'likers'}) eq 'HASH') {
               if (exists($contrib{$prefix.'likers'}{$thisuser})) {                if (exists($likes{$prefix.'likers'}{$thisuser})) {
                   $userlikes = 1;                    $userlikes = 1;
               }                }
           }            }
           if (ref($contrib{$prefix.'unlikers'}) eq 'HASH') {            if (ref($likes{$prefix.'unlikers'}) eq 'HASH') {
               if (exists($contrib{$prefix.'unlikers'}{$thisuser})) {                if (exists($likes{$prefix.'unlikers'}{$thisuser})) {
                   $userunlikes = 1;                    $userunlikes = 1;
               }                }
           }            }
 # Get the current "likes" count  # Get the current "likes" count
           my $likes=$contrib{$prefix.'likes'};            my $likescount=$likes{$prefix.'likes'};
 # Find out if they already voted  # Find out if they already voted
 # Users cannot like a post twice, or unlike it twice.  # Users cannot like a post twice, or unlike it twice.
 # They can change their mind, though.  # They can change their mind, though.
Line 4101  ENDREDIR Line 4119  ENDREDIR
               if ($userlikes) {                if ($userlikes) {
                   $alreadyflag=1;                    $alreadyflag=1;
               } elsif ($userunlikes) {                } elsif ($userunlikes) {
                   delete($contrib{$prefix.'unlikers'}{$thisuser});                    delete($likes{$prefix.'unlikers'}{$thisuser});
                   $likes++;                    $likescount++;
               } else {                } else {
                   if (ref($contrib{$prefix.'likers'}) eq 'HASH') {                    if (ref($likes{$prefix.'likers'}) eq 'HASH') {
                       $contrib{$prefix.'likers'}{$thisuser} = 1;                        $likes{$prefix.'likers'}{$thisuser} = 1;
                   } else {                    } else {
                       $contrib{$prefix.'likers'} = {$thisuser => 1};                        $likes{$prefix.'likers'} = {$thisuser => 1};
                   }                    }
                   $likes++;                    $likescount++;
               }                }
           } else {            } else {
               if ($userunlikes) {                if ($userunlikes) {
                   $alreadyflag=1;                    $alreadyflag=1;
               } elsif ($userlikes) {                } elsif ($userlikes) {
                   delete($contrib{$prefix.'likers'}{$thisuser});                    delete($likes{$prefix.'likers'}{$thisuser});
                   $likes--;                    $likescount--;
               } else {                } else {
                   if (ref($contrib{$prefix.'unlikers'}) eq 'HASH') {                    if (ref($likes{$prefix.'unlikers'}) eq 'HASH') {
                       $contrib{$prefix.'unlikers'}{$thisuser} = 1;                        $likes{$prefix.'unlikers'}{$thisuser} = 1;
                   } else {                    } else {
                       $contrib{$prefix.'unlikers'} = {$thisuser => 1};                        $likes{$prefix.'unlikers'} = {$thisuser => 1};
                   }                    }
                   $likes--;                    $likescount--;
               }                }
           }            }
 # $alreadyflag would be 1 if they tried to double-like or double-unlike  # $alreadyflag would be 1 if they tried to double-like or double-unlike
           unless ($alreadyflag) {            unless ($alreadyflag) {
               my %newhash=($prefix.'likes'    => $likes,                my %newhash=($prefix.'likes'    => $likescount,
                            $prefix.'likers'   => $contrib{$prefix.'likers'},                             $prefix.'likers'   => $likes{$prefix.'likers'},
                            $prefix.'unlikers' => $contrib{$prefix.'unlikers'});                             $prefix.'unlikers' => $likes{$prefix.'unlikers'});
 # Store data in db-file "disclikes"  # Store data in db-file "disclikes"
               if (&Apache::lonnet::put('disclikes',                if (&Apache::lonnet::put('disclikes',
                                        \%newhash,                                         \%newhash,

Removed from v.1.339  
changed lines
  Added in v.1.344


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