Diff for /loncom/interface/lonfeedback.pm between versions 1.96 and 1.97

version 1.96, 2004/06/28 16:41:08 version 1.97, 2004/07/04 23:56:58
Line 325  sub list_discussion { Line 325  sub list_discussion {
     my $color = &Apache::loncommon::designparm($function.'.tabbg',      my $color = &Apache::loncommon::designparm($function.'.tabbg',
                                                     $ENV{'user.domain'});                                                      $ENV{'user.domain'});
     my %lt = &Apache::lonlocal::texthash(      my %lt = &Apache::lonlocal::texthash(
         'cuse' => 'Current settings for this discussion',          'cuse' => 'Current discussion settings',
         'allposts' => 'All posts',          'allposts' => 'All posts',
         'unread' => 'New posts only',          'unread' => 'New posts only',
         'ondisp' => 'Once displayed',          'ondisp' => 'Once displayed',
         'onmark' => 'Once marked read',          'onmark' => 'Once marked read',
         'disa' => 'Posts to be displayed',          'disa' => 'Posts to be displayed',
         'npce' => 'Posts cease to be marked "NEW"',          'npce' => 'Posts cease to be marked "NEW"',
         'chgt' => 'Change to ',          'chgt' => 'Change',
           'disp' => 'Display',
           'nolo' => 'Not new',
     );      );
   
     my $currdisp = $lt{'allposts'};      my $currdisp = $lt{'allposts'};
     my $currmark = $lt{'onmark'};      my $currmark = $lt{'onmark'};
     my $dispchange = $lt{'unread'};      my $dispchange = $lt{'unread'};
     my $markchange = $lt{'ondisp'};      my $markchange = $lt{'ondisp'};
     my $displink = '/adm/feedback?onlyunread='.$ressymb;      my $chglink = '/adm/feedback?modifydisp='.$ressymb;
     my $marklink = '/adm/feedback?markondisp='.$ressymb;      my $displink = 'onlyunread';
       my $marklink = 'markondisp';
   
     if ($markondisp) {      if ($markondisp) {
         $currmark = $lt{'ondisp'};          $currmark = $lt{'ondisp'};
         $markchange = $lt{'onmark'};          $markchange = $lt{'onmark'};
         $marklink = '/adm/feedback?markonread='.$ressymb;          $marklink = 'markonread';
         if ($newpostsflag) {  
             $marklink .= '&previous='.$prevread;  
         }  
     }      }
   
     if ($showonlyunread) {      if ($showonlyunread) {
         $currdisp = $lt{'unread'};          $currdisp = $lt{'unread'};
         $dispchange = $lt{'allposts'};          $dispchange = $lt{'allposts'};
         $displink = '/adm/feedback?allposts='.$ressymb;          $displink = 'allposts';
     }      }
      
       $chglink .= '&changes='.$displink.'_'.$marklink;
   
     if ($newpostsflag) {      if ($newpostsflag) {
         $displink .= '&previous='.$prevread;          $chglink .= '&previous='.$prevread;
     }      }
   
     if ($visible) {      if ($visible) {
 # Print the discusssion  # Print the discusssion
  if ($outputtarget ne 'tex') {   if ($outputtarget ne 'tex') {
               my $colspan=$maxdepth+1;
     $discussion.='<table bgcolor="#AAAAAA" cellpadding="2" cellspacing="2" border="0">';      $discussion.='<table bgcolor="#AAAAAA" cellpadding="2" cellspacing="2" border="0">';
     my $colspan=$maxdepth+1;      $discussion .='<tr><td bgcolor="#DDDDBB" colspan="'.$colspan.'">'.
     $discussion .= '<tr bgcolor="#FFFFFF"><td colspan="'.$colspan.'" valign="top">'.  
  '<table border="0" bgcolor="#FFFFFF" width="100%" cellspacing="2" cellpadding="2">'.  
  '<tr><td align="left"><b>'.$lt{'cuse'}.'</b></td><td>&nbsp;&nbsp;&nbsp;&nbsp;</td><td align="right"><b>'.$lt{'chgt'}.'</b></td></tr>'.  
  '<tr><td>'.$lt{'disa'}.':&nbsp;<i>'.$currdisp.'</i></td><td>&nbsp;&nbsp;&nbsp;&nbsp;</td><td align="right"><a href="'.$displink.'">'.$dispchange.'</a></td></tr>'.  
  '<tr><td>'.$lt{'npce'}.':&nbsp;<i>'.$currmark.'</i></td><td>&nbsp;&nbsp;&nbsp;&nbsp;</td><td align="right"><a href="'.$marklink.'">'.$markchange.'</a></td></tr>'.  
  '</table></td></tr>'.  
  '<tr><td bgcolor="#DDDDBB" colspan="'.$colspan.'">'.  
  '<table border="0" width="100%" bgcolor="#DDDDBB"><tr>';   '<table border="0" width="100%" bgcolor="#DDDDBB"><tr>';
     if ($visible>2) {      if ($visible>2) {
  $discussion.='<td align="left">'.   $discussion.='<td align="left">'.
Line 456  sub list_discussion { Line 452  sub list_discussion {
     }      }
         }          }
  if ($outputtarget ne 'tex') {   if ($outputtarget ne 'tex') {
     $discussion.='</table><br /><br />';              my $colspan=$maxdepth+1;
               $discussion .= <<END; 
               <tr bgcolor="#FFFFFF">
                <td colspan="'.$colspan.'" valign="top">
                 <table border="0" bgcolor="#FFFFFF" width="100%" cellspacing="2" cellpadding="2">
                  <tr>
                   <td align="left">
                    <table border="0" cellpadding="0" cellspacing="4">
                     <tr>
                      <td>
                       <font size="-1"><b>$lt{'cuse'}</b>:</td>
                      <td>&nbsp;</td>
   END
               if ($newpostsflag) {
                   $discussion .= 
                      '<td><font size="-1">1.&nbsp;'.$lt{'disp'}.'&nbsp;-&nbsp;<i>'.$currdisp.'</i>&nbsp;&nbsp;2.&nbsp;'.$lt{'nolo'}.'&nbsp;-&nbsp;<i>'.$currmark.'</i></font></td>';
               } else {
                   $discussion .=
                      '<td><font size="-1">'.$lt{'disp'}.'&nbsp;-&nbsp;<i>'.$currdisp.'</i></font></td>';
               }
               $discussion .= <<END;
                      <td>&nbsp;</td>
                      <td>
                       <font size="-1"><b><a href="$chglink">$lt{'chgt'}</a>?</font></b></td>
                     </tr>
                    </table>
                   </td>
                  </tr>
                 </table>
                </td>
               </tr>
              </table>
              <br /><br />
   END
  }   }
     }      }
     if ($discussiononly) {      if ($discussiononly) {
Line 611  $r->print(&generate_preview_button(). Line 640  $r->print(&generate_preview_button().
 '</body></html>');  '</body></html>');
 }  }
   
   sub print_display_options {
       my ($r,$symb,$previous,$dispchg,$markchg,$feedurl) = @_;
       my $function = &Apache::loncommon::get_users_function();
       my $tabcolor = &Apache::loncommon::designparm($function.'.tabbg',
                                                       $ENV{'user.domain'});
       my $bodytag=&Apache::loncommon::bodytag('Discussion options',
                                             '','');
   
       my %lt = &Apache::lonlocal::texthash(
           'dido' => 'Discussion display options',
           'pref' => 'Display Preference',
           'curr' => 'Current setting ',
           'actn' => 'Action',
           'deff' => 'Default for all discussions',
           'prca' => 'Preferences can be set for this discussion that determine ....',
           'whpo' => 'Which posts are displayed when you display this bulletin board or resource, and',
           'unwh' => 'Under what circumstances posts are identfied as "New."',
           'allposts' => 'All posts',
           'unread' => 'New posts only',
           'ondisp' => 'Once displayed',
           'onmark' => 'Once marked as read',
           'disa' => 'Posts displayed?',
           'npmr' => 'New posts cease to be identified as "New"?',
           'chgt' => 'Change to ',
           'mkdf' => 'Set to ',
           'yhni' => 'You have not indicated that you wish to change either of the discussion settings',
           'ywbr' => 'You will be returned to the previous page if you click OK.'
       );
   
       my $dispchange = $lt{'unread'};
       my $markchange = $lt{'ondisp'};
       my $currdisp = $lt{'allposts'};
       my $currmark = $lt{'onmark'};
       my $discdisp = 'allposts';
       my $discmark = 'onmark';
                                                                                         
       if ($dispchg eq 'allposts') {
           $dispchange = $lt{'allposts'};
           $currdisp = $lt{'unread'};
           $discdisp = 'unread';
       }
                                                                                         
       if ($markchg eq 'markonread') {
           $markchange = $lt{'onmark'};
           $currmark = $lt{'ondisp'};
           $discmark = 'ondisp';
       }
       $r->print(<<END);
   <html>
   <head>
   <title>$lt{'dido'}</title>
   <meta http-equiv="pragma" content="no-cache" />
   <script>
   function setDisp() {
       var prev = "$previous"
       var chktotal = 0
       if (document.modifydisp.discdisp.checked == true) {
           document.modifydisp.$dispchg.value = "$symb"
           chktotal ++
       }
       if (document.modifydisp.discmark.checked == true) {
           document.modifydisp.$markchg.value = "$symb"
           chktotal ++
       }
       if (chktotal > 0) { 
           document.modifydisp.submit()
       } else {
           if(confirm("$lt{'yhni'}. \\n$lt{'ywbr'}"))      {
               if (prev > 0) {
                   location.href = "$feedurl?previous=$previous"
               } else {
                   location.href = "$feedurl"
               }
           }
       }
   }
   </script>
   </head>
   $bodytag
   <form name="modifydisp" method="post" action="/adm/feedback">
   $lt{'sdpf'}<br/> $lt{'prca'}  <ol><li>$lt{'whpo'}</li><li>$lt{'unwh'}</li></ol>
   <br />
   <table border="0" cellpadding="0" cellspacing="0">
    <tr>
     <td width="100%" bgcolor="#000000">
      <table width="100%" border="0" cellpadding="1" cellspacing="0">
       <tr>
        <td width="100%" bgcolor="#000000">
         <table border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
          <tr bgcolor="$tabcolor">
           <td><b>$lt{'pref'}</b></td>
           <td><b>$lt{'curr'}</b></td>
           <td><b>$lt{'actn'}?</b></td>
          </tr>
          <tr bgcolor="#dddddd">
          <td>$lt{'disa'}</td>
          <td>$lt{$discdisp}</td>
          <td><input type="checkbox" name="discdisp" />&nbsp;$lt{'chgt'} "$dispchange"</td>
         </tr><tr bgcolor="#eeeeee">
          <td>$lt{'npmr'}</td>
          <td>$lt{$discmark}</td>
          <td><input type="checkbox" name="discmark" />$lt{'chgt'} "$markchange"</td>
         </tr>
        </table>
       </td>
      </tr>
     </table>
    </td>
   </tr>
   </table>
   <br />
   <br />
   <input type="hidden" name="previous" value="$previous" />
   <input type="hidden" name="$dispchg" value=""/>
   <input type="hidden" name="$markchg" value=""/>
   <input type="button" name="sub" value="Store Changes" onClick="javascript:setDisp()" />
   <br />
   <br />
   </form>
   </body>
   </html>
   END
       return;
   }
   
 sub fail_redirect {  sub fail_redirect {
   my ($r,$feedurl) = @_;    my ($r,$feedurl) = @_;
   if ($feedurl=~/^\/adm\//) { $feedurl.='?register=1' };    if ($feedurl=~/^\/adm\//) { $feedurl.='?register=1' };
Line 971  sub handler { Line 1125  sub handler {
   
 # --------------------------- Get query string for limited number of parameters  # --------------------------- Get query string for limited number of parameters
   
    &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},    &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
          ['hide','unhide','deldisc','postdata','preview','replydisc','threadedon','threadedoff','onlyunread','allposts','previous','markread','markonread','markondisp']);           ['hide','unhide','deldisc','postdata','preview','replydisc','threadedon','threadedoff','onlyunread','allposts','previous','markread','markonread','markondisp','modifydisp','changes']);
     if ($ENV{'form.modifydisp'}) {
   if (($ENV{'form.markondisp'}) || ($ENV{'form.markonread'})) {  
 # ---------------------- Modify setting for identification of 'NEW' posts in this discussion  
   
       &Apache::loncommon::content_type($r,'text/html');        &Apache::loncommon::content_type($r,'text/html');
       $r->send_http_header;        $r->send_http_header;
       my $symb=$ENV{'form.markondisp'}?$ENV{'form.markondisp'}:$ENV{'form.markonread'};        my $symb=$ENV{'form.modifydisp'};
       my $ressymb = $symb;  
       my ($map,$ind,$url)=&Apache::lonnet::decode_symb($symb);        my ($map,$ind,$url)=&Apache::lonnet::decode_symb($symb);
       unless ($ressymb =~ m|bulletin___\d+___adm/wrapper|) {        my $previous=$ENV{'form.previous'};
           $ressymb=~s|(bulletin___\d+___)|$1adm/wrapper|;        my ($dispchg,$markchg) = split/_/,$ENV{'form.changes'};
       }        my $feedurl = &Apache::lonnet::clutter($url);
                                                                                                   &print_display_options($r,$symb,$previous,$dispchg,$markchg,$feedurl);
       my %discinfo = ();  
       my $lastkey = $ressymb.'_lastread';  
       my $ondispkey = $ressymb.'_markondisp';  
       if ($ENV{'form.markondisp'}) {  
           $discinfo{$lastkey} = time;  
           $discinfo{$ondispkey} = 1;  
       } elsif ($ENV{'form.markonread'}) {  
           if ( defined($ENV{'previous'}) ) {  
               $discinfo{$lastkey} = $ENV{'previous'};  
           }  
           $discinfo{$ondispkey} = 0;  
       }  
       &Apache::lonnet::put('nohist_'.$ENV{'request.course.id'}.'_discuss',\%discinfo,$ENV{'user.domain'},$ENV{'user.name'});  
       if ($ENV{'form.markondisp'}) {  
           &redirect_back($r,&Apache::lonnet::clutter($url),&mt('Changed display status').'<br />','0','0');  
       } else {  
           &redirect_back($r,&Apache::lonnet::clutter($url),&mt('Changed display status').'<br />','0','0','',$ENV{'form.previous'});  
       }  
       return OK;        return OK;
   } elsif (($ENV{'form.allposts'}) || ($ENV{'form.onlyunread'})) {    } elsif (($ENV{'form.markondisp'}) || ($ENV{'form.markonread'}) || ($ENV{'form.allposts'}) || ($ENV{'form.onlyunread'}) ) {
 # ----------------------------------------------------------------- Modify display setting for this discussion   
       &Apache::loncommon::content_type($r,'text/html');        &Apache::loncommon::content_type($r,'text/html');
       $r->send_http_header;        $r->send_http_header;
       my $symb=$ENV{'form.allposts'}?$ENV{'form.allposts'}:$ENV{'form.onlyunread'};        my $previous=$ENV{'form.previous'};
       my $ressymb = $symb;        my ($map,$ind,$url);
       my ($map,$ind,$url)=&Apache::lonnet::decode_symb($symb);        if (($ENV{'form.markondisp'}) || ($ENV{'form.markonread'})) {
       unless ($ressymb =~ m|bulletin___\d+___adm/wrapper|) {  # ---------------------- Modify setting for identification of 'NEW' posts in this discussion
           $ressymb=~s|(bulletin___\d+___)|$1adm/wrapper|;            my $symb=$ENV{'form.markondisp'}?$ENV{'form.markondisp'}:$ENV{'form.markonread'};
             my $ressymb = $symb;
             ($map,$ind,$url)=&Apache::lonnet::decode_symb($symb);
             unless ($ressymb =~ m|bulletin___\d+___adm/wrapper|) {
                 $ressymb=~s|(bulletin___\d+___)|$1adm/wrapper|;
             }
             my %discinfo = ();
             my $lastkey = $ressymb.'_lastread';
             my $ondispkey = $ressymb.'_markondisp';
             if ($ENV{'form.markondisp'}) {
                 $discinfo{$lastkey} = time;
                 $discinfo{$ondispkey} = 1;
             } elsif ($ENV{'form.markonread'}) {
                 if ( $previous > 0 ) {
                     $discinfo{$lastkey} = $previous;
                 }
                 $discinfo{$ondispkey} = 0;
             }
             &Apache::lonnet::put('nohist_'.$ENV{'request.course.id'}.'_discuss',\%discinfo,$ENV{'user.domain'},$ENV{'user.name'});
         }
         if (($ENV{'form.allposts'}) || ($ENV{'form.onlyunread'})) {
   # ----------------------------------------------------------------- Modify display setting for this discussion 
             my $symb=$ENV{'form.allposts'}?$ENV{'form.allposts'}:$ENV{'form.onlyunread'};
             my $ressymb = $symb;
             ($map,$ind,$url)=&Apache::lonnet::decode_symb($symb);
             unless ($ressymb =~ m|bulletin___\d+___adm/wrapper|) {
                 $ressymb=~s|(bulletin___\d+___)|$1adm/wrapper|;
             }
             my %discinfo = ();
             if ($ENV{'form.allposts'}) {
                 $discinfo{$ressymb.'_showonlyunread'} = 0;
             } elsif ($ENV{'form.onlyunread'}) {
                 $discinfo{$ressymb.'_showonlyunread'} = 1;
             }
             &Apache::lonnet::put('nohist_'.$ENV{'request.course.id'}.'_discuss',\%discinfo,$ENV{'user.domain'},$ENV{'user.name'});
       }        }
       my %discinfo = ();        if (($ENV{'form.markonread'}) || ($ENV{'form.allposts'}) || ($ENV{'form.onlyunread'}) ) {
       if ($ENV{'form.allposts'}) {            &redirect_back($r,&Apache::lonnet::clutter($url),&mt('Changed display status').'<br />','0','0','',$previous);
           $discinfo{$ressymb.'_showonlyunread'} = 0;        } else {
       } elsif ($ENV{'form.onlyunread'}) {            &redirect_back($r,&Apache::lonnet::clutter($url),&mt('Changed display status').'<br />','0','0');
           $discinfo{$ressymb.'_showonlyunread'} = 1;  
       }        }
       &Apache::lonnet::put('nohist_'.$ENV{'request.course.id'}.'_discuss',\%discinfo,$ENV{'user.domain'},$ENV{'user.name'});  
       &redirect_back($r,&Apache::lonnet::clutter($url),&mt('Changed display status').'<br />','0','0','',$ENV{'form.previous'});  
       return OK;        return OK;
   } elsif ($ENV{'form.markread'}) {    } elsif ($ENV{'form.markread'}) {
 # ----------------------------------------------------------------- Mark new posts as read  # ----------------------------------------------------------------- Mark new posts as read

Removed from v.1.96  
changed lines
  Added in v.1.97


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