Diff for /loncom/interface/lonfeedback.pm between versions 1.99 and 1.99.2.10

version 1.99, 2004/07/09 23:05:52 version 1.99.2.10, 2004/10/07 19:55:52
Line 36  use Apache::loncommon(); Line 36  use Apache::loncommon();
 use Apache::lontexconvert();  use Apache::lontexconvert();
 use Apache::lonlocal; # must not have ()  use Apache::lonlocal; # must not have ()
 use Apache::lonhtmlcommon();  use Apache::lonhtmlcommon();
   use Apache::lonnavmaps();
   
 sub discussion_open {  sub discussion_open {
     my ($status)=@_;      my ($status)=@_;
Line 92  sub list_discussion { Line 93  sub list_discussion {
 # Get discussion display settings for this discussion  # Get discussion display settings for this discussion
     my $lastkey = $ressymb.'_lastread';      my $lastkey = $ressymb.'_lastread';
     my $showkey = $ressymb.'_showonlyunread';      my $showkey = $ressymb.'_showonlyunread';
     my $visitkey = $ressymb.'_visit';  
     my $ondispkey = $ressymb.'_markondisp';      my $ondispkey = $ressymb.'_markondisp';
     my %dischash = &Apache::lonnet::get('nohist_'.$ENV{'request.course.id'}.'_discuss',[$lastkey,$showkey,$visitkey,$ondispkey],$ENV{'user.domain'},$ENV{'user.name'});      my %dischash = &Apache::lonnet::get('nohist_'.$ENV{'request.course.id'}.'_discuss',[$lastkey,$showkey,$ondispkey],$ENV{'user.domain'},$ENV{'user.name'});
     my %discinfo = ();      my %discinfo = ();
     my $showonlyunread = 0;      my $showonlyunread = 0;
     my $markondisp = 0;      my $markondisp = 0;
     my $prevread = 0;      my $prevread = 0;
     my $previous = 0;      my $previous = 0;
     my $visit = 0;  
     my $newpostsflag = 0;      my $newpostsflag = 0;
   
 # Retain identification of "NEW" posts identified in last display, if continuing 'previous' browsing of posts.  # Retain identification of "NEW" posts identified in last display, if continuing 'previous' browsing of posts.
Line 115  sub list_discussion { Line 114  sub list_discussion {
     }      }
   
 # Get discussion display default settings for user  # Get discussion display default settings for user
     my %userenv = &Apache::lonnet::get('environment',['discdisplay','discmarkread'],$ENV{'user.domain'},$ENV{'user.name'});      if ($ENV{'environment.discdisplay'} eq 'unread') {
     my $discdisplay=$userenv{'discdisplay'};  
     if ($discdisplay eq 'unread') {  
         $showonlyunread = 1;          $showonlyunread = 1;
     }      }
     my $discmarkread=$userenv{'discmarkread'};      if ($ENV{'environment.discmarkread'} eq 'ondisp') {
     if ($discmarkread eq 'ondisp') {  
         $markondisp = 1;          $markondisp = 1;
     }      }
   
 # Override user's default if user specified display setting for this discussion  # Override user's default if user specified display setting for this discussion
     if (defined($dischash{$ondispkey})) {      if (defined($dischash{$ondispkey})) {
         $markondisp = $dischash{$ondispkey};   unless ($dischash{$showkey} eq '') {
       $markondisp = $dischash{$ondispkey};
    }
     }      }
     if ($markondisp) {      if ($markondisp) {
         $discinfo{$lastkey} = time;          $discinfo{$lastkey} = time;
     }      }
   
     if (defined($dischash{$showkey})) {      if (defined($dischash{$showkey})) {
         $showonlyunread = $dischash{$showkey};   unless ($dischash{$showkey} eq '') {
     }      $showonlyunread = $dischash{$showkey};
    }
     if (defined($dischash{$visitkey})) {  
         $visit = $dischash{$visitkey};  
     }      }
     $visit ++;  
   
     my $seeid=&Apache::lonnet::allowed('rin',$crs);      my $seeid=&Apache::lonnet::allowed('rin',$crs);
     my $viewgrades=(&Apache::lonnet::allowed('vgr',$crs)      my $viewgrades=(&Apache::lonnet::allowed('vgr',$crs)
Line 166  sub list_discussion { Line 161  sub list_discussion {
     }      }
           
     my $now = time;      my $now = time;
     $discinfo{$visitkey} = $visit;      if (%discinfo) {
    &Apache::lonnet::put('nohist_'.$ENV{'request.course.id'}.'_discuss',\%discinfo,$ENV{'user.domain'},$ENV{'user.name'});
     &Apache::lonnet::put('nohist_'.$ENV{'request.course.id'}.'_discuss',\%discinfo,$ENV{'user.domain'},$ENV{'user.name'});      }
   
     if ($contrib{'version'}) {      if ($contrib{'version'}) {
         my $oldest = $contrib{'1:timestamp'};          my $oldest = $contrib{'1:timestamp'};
Line 223  sub list_discussion { Line 218  sub list_discussion {
     if ($hidden) {      if ($hidden) {
  $message='<font color="#888888">'.$message.'</font>';   $message='<font color="#888888">'.$message.'</font>';
     }      }
     my $screenname=&Apache::loncommon::screenname(  #    my $screenname=&Apache::loncommon::screenname(
     $contrib{$idx.':sendername'},  #    $contrib{$idx.':sendername'},
     $contrib{$idx.':senderdomain'});  #    $contrib{$idx.':senderdomain'});
     my $plainname=&Apache::loncommon::nickname(  #    my $plainname=&Apache::loncommon::nickname(
     $contrib{$idx.':sendername'},  #    $contrib{$idx.':sendername'},
     $contrib{$idx.':senderdomain'});  #    $contrib{$idx.':senderdomain'});
           my ($screenname,$plainname)=($contrib{$idx.':screenname'},
    $contrib{$idx.':plainname'});
     my $sender=&mt('Anonymous');      my $sender=&mt('Anonymous');
     if ((!$contrib{$idx.':anonymous'}) || ($seeid)) {      if ((!$contrib{$idx.':anonymous'}) || ($seeid)) {
  $sender=&Apache::loncommon::aboutmewrapper(   $sender=&Apache::loncommon::aboutmewrapper(
Line 552  sub mail_screen { Line 548  sub mail_screen {
   }    }
   my $latexHelp=&Apache::loncommon::helpLatexCheatsheet();    my $latexHelp=&Apache::loncommon::helpLatexCheatsheet();
   my $htmlheader=&Apache::lonhtmlcommon::htmlareaheaders();    my $htmlheader=&Apache::lonhtmlcommon::htmlareaheaders();
   my $onsubmit='';  
   if ((&Apache::lonhtmlcommon::htmlareabrowser()) &&  
       (!&Apache::lonhtmlcommon::htmlareablocked())) {  
       $onsubmit='document.mailform.onsubmit();';  
   }  
   my $send=&mt('Send');    my $send=&mt('Send');
   $r->print(<<ENDDOCUMENT);    $r->print(<<ENDDOCUMENT);
 <html>  <html>
Line 600  $htmlheader Line 591  $htmlheader
         }          }
   
         if (rec) {          if (rec) {
             $onsubmit              if (typeof(document.mailform.onsubmit)=='function') {
    document.mailform.onsubmit();
       }
     document.mailform.submit();      document.mailform.submit();
         } else {          } else {
             alert('Please check a feedback type.');              alert('Please check a feedback type.');
Line 782  sub fail_redirect { Line 775  sub fail_redirect {
 <body bgcolor="#FFFFFF">  <body bgcolor="#FFFFFF">
 <img align="right" src="/adm/lonIcons/lonlogos.gif" />  <img align="right" src="/adm/lonIcons/lonlogos.gif" />
 <b>Sorry, no recipients  ...</b>  <b>Sorry, no recipients  ...</b>
   <br /><a href="$feedurl">Continue</a>
 </body>  </body>
 </html>  </html>
 ENDFAILREDIR  ENDFAILREDIR
Line 821  $typestyle Line 815  $typestyle
 <form name="reldt" action="$feedurl" target="loncapaclient">  <form name="reldt" action="$feedurl" target="loncapaclient">
 $prevtag  $prevtag
 </form>  </form>
   <br /><a href="$feedurl">Continue</a>
 </body>  </body>
 </html>  </html>
 ENDREDIR  ENDREDIR
Line 843  ENDNOREDIR Line 838  ENDNOREDIR
 <body bgcolor="#FFFFFF" onLoad='if (window.name!="loncapaclient") { self.close(); }'>  <body bgcolor="#FFFFFF" onLoad='if (window.name!="loncapaclient") { self.close(); }'>
 <img align="right" src="/adm/lonIcons/lonlogos.gif" />  <img align="right" src="/adm/lonIcons/lonlogos.gif" />
 <b>Sorry, no feedback possible on this resource  ...</b>  <b>Sorry, no feedback possible on this resource  ...</b>
   <br /><a href="$feedurl">Continue</a>
 </body>  </body>
 </html>  </html>
 ENDNOREDIRTWO  ENDNOREDIRTWO
Line 1120  sub generate_preview_button { Line 1116  sub generate_preview_button {
 <input type="hidden" name="subject">  <input type="hidden" name="subject">
 <input type="hidden" name="comment" />  <input type="hidden" name="comment" />
 <input type="button" value="$pre"  <input type="button" value="$pre"
 onClick="document.mailform.onsubmit();this.form.comment.value=document.mailform.comment.value;this.form.subject.value=document.mailform.subject.value;this.form.submit();" />  onClick="if (typeof(document.mailform.onsubmit)=='function') {document.mailform.onsubmit();};this.form.comment.value=document.mailform.comment.value;this.form.subject.value=document.mailform.subject.value;this.form.submit();" />
 </form>  </form>
 ENDPREVIEW  ENDPREVIEW
 }  }
   
   sub has_discussion {
       my $resourcesref = shift;
       my $navmap = Apache::lonnavmaps::navmap->new();
       my @allres=$navmap->retrieveResources();
       foreach my $resource (@allres) {
    if ($resource->hasDiscussion()) {
       my $ressymb;
       if ($resource->symb() =~ m-(___adm/\w+/\w+)/(\d+)/bulletinboard$-) {
    $ressymb = 'bulletin___'.$2.$1.'/'.$2.'/bulletinboard';
       } else {
    $ressymb = $resource->symb();
       }
       push @{$resourcesref}, $ressymb;
    }
       }
       return;
   }
   
 sub handler {  sub handler {
   my $r = shift;    my $r = shift;
   if ($r->header_only) {    if ($r->header_only) {
Line 1136  sub handler { Line 1150  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','modifydisp','changes','navmaps','navurl']);           ['hide','unhide','deldisc','postdata','preview','replydisc','threadedon','threadedoff','onlyunread','allposts','previous','markread','markonread','markondisp','modifydisp','changes','navtime','navurl']);
   if ($ENV{'form.navmaps'}) {    if ($ENV{'form.navtime'}) {
       my %discinfo = ();        my %discinfo = ();
       my @resources = ();        my @resources = ();
       if ($ENV{'form.navmaps'} =~ /:/) {        &has_discussion(\@resources);
           @resources = split/:/,$ENV{'form.navmaps'};  
       } else {  
           @resources = ("$ENV{'form.navmaps'}");  
       }  
       my $numitems = @resources;        my $numitems = @resources;
       my $feedurl = '/adm/navmaps';        my $feedurl = '/adm/navmaps';
       if ($ENV{'form.navurl'}) {        if ($ENV{'form.navurl'}) {
Line 1152  sub handler { Line 1162  sub handler {
       }        }
       my %lt = &Apache::lonlocal::texthash(        my %lt = &Apache::lonlocal::texthash(
           'mnpa' => 'Marked "New" posts as read in a total of',            'mnpa' => 'Marked "New" posts as read in a total of',
           'robb' => 'resources/bulletin boards.'            'robb' => 'resources/bulletin boards.',
             'twnp' => 'There are currently no resources or bulletin boards with unread discussion postings.'
       );               );       
       foreach (@resources) {        foreach (@resources) {
 # backward compatibility (bulletin boards used to be 'wrapped')  # backward compatibility (bulletin boards used to be 'wrapped')
Line 1163  sub handler { Line 1174  sub handler {
               }                }
           }            }
           my $lastkey = $ressymb.'_lastread';            my $lastkey = $ressymb.'_lastread';
           $discinfo{$lastkey} = time;            $discinfo{$lastkey} = $ENV{'form.navtime'};
         }
         my $textline = "<b>$lt{'mnpa'} $numitems $lt{'robb'}</b>";
         if ($numitems > 0) {
             &Apache::lonnet::put('nohist_'.$ENV{'request.course.id'}.'_discuss',\%discinfo,$ENV{'user.domain'},$ENV{'user.name'});
         } else {
             $textline = "<b>$lt{'twnp'}</b>";
       }        }
       &Apache::lonnet::put('nohist_'.$ENV{'request.course.id'}.'_discuss',\%discinfo,$ENV{'user.domain'},$ENV{'user.name'});  
       &Apache::loncommon::content_type($r,'text/html');        &Apache::loncommon::content_type($r,'text/html');
       $r->send_http_header;        $r->send_http_header;
       $r->print (<<ENDREDIR);        $r->print (<<ENDREDIR);
Line 1177  sub handler { Line 1193  sub handler {
 </head>  </head>
 <body bgcolor="#FFFFFF" onLoad='if (window.name!="loncapaclient") { this.document.reldt.submit(); self.close(); }'>  <body bgcolor="#FFFFFF" onLoad='if (window.name!="loncapaclient") { this.document.reldt.submit(); self.close(); }'>
 <img align="right" src="/adm/lonIcons/lonlogos.gif" />  <img align="right" src="/adm/lonIcons/lonlogos.gif" />
 <b>$lt{'mnpa'} $numitems $lt{'robb'}</b>  $textline
 <form name="reldt" action="$feedurl" target="loncapaclient">  <form name="reldt" action="$feedurl" target="loncapaclient">
 </form>  </form>
   <br /><a href="$feedurl">Continue</a>
 </body>  </body>
 </html>  </html>
 ENDREDIR  ENDREDIR

Removed from v.1.99  
changed lines
  Added in v.1.99.2.10


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