Diff for /loncom/interface/lonannounce.pm between versions 1.10 and 1.15

version 1.10, 2003/05/21 19:15:41 version 1.15, 2003/06/18 20:06:29
Line 32  use strict; Line 32  use strict;
 use Apache::Constants qw(:common);  use Apache::Constants qw(:common);
 use Apache::loncommon;  use Apache::loncommon;
 use Apache::lonhtmlcommon();  use Apache::lonhtmlcommon();
   use HTML::Entities();
   
   my %todayhash;
   
 sub editfield {  sub editfield {
     my ($r,$start,$end,$text)=@_;      my ($r,$start,$end,$text)=@_;
Line 72  sub emptycell { Line 75  sub emptycell {
 }  }
   
 sub normalcell {  sub normalcell {
     my ($day,$text)=@_;      my ($day,$month,$year,$text)=@_;
     my $output='';      my $output='';
     foreach (split(/\_\_\_\&\&\&\_\_\_/,$text)) {      foreach (split(/\_\_\_\&\&\&\_\_\_/,$text)) {
         if ($_) {          if ($_) {
     my ($courseid,$start,$end,@msg)=split(/\@/,$_);      my ($courseid,$start,$end,@msg)=split(/\@/,$_);
             my $msg=join('@',@msg);              my $msg=join('@',@msg);
             my $fullmsg=$ENV{'course.'.$courseid.'.description'}.': '.$msg;              my $fullmsg=$ENV{'course.'.$courseid.'.description'}.
    ', '.localtime($start).' - '.localtime($end).': '.$msg;
             if ($courseid eq $ENV{'request.course.id'}) {              if ($courseid eq $ENV{'request.course.id'}) {
               if (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'})) {                if (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'})) {
                $output.='<input type="checkbox" name="remove_'.$start.'_'.                 $output.='<input type="checkbox" name="remove_'.$start.'_'.
    $end.'">';     $end.'">';
       }        }
     }      }
               $fullmsg=&HTML::Entities::encode($fullmsg,'<>&"\'');
               $fullmsg=~s/&/\\&/g;
               $output.='<a href="javascript:alert('."'$fullmsg'".')">'.
          substr($msg,0,20).'...</a><br />';
          }
       }
       return '<td'.
    ((($day eq $todayhash{'day'}) &&
             ($month eq $todayhash{'month'}) &&
             ($year eq $todayhash{'year'}))?' bgcolor="#FFFF00"':'').
              '><b>'.$day.'</b><br>'.$output.'</td>';
   }
   
   sub plaincell {
       my ($text)=@_;
       my $output='';
       foreach (split(/\_\_\_\&\&\&\_\_\_/,$text)) {
           if ($_) {
       my ($courseid,$start,$end,@msg)=split(/\@/,$_);
               my $msg=join('@',@msg);
               my $fullmsg=$ENV{'course.'.$courseid.'.description'}.
    ', '.localtime($start).' - '.localtime($end).': '.$msg;
               $fullmsg=&HTML::Entities::encode($fullmsg,'<>&"\'');
               $fullmsg=~s/&/\\&/g;
             $output.='<a href="javascript:alert('."'$fullmsg'".')">'.              $output.='<a href="javascript:alert('."'$fullmsg'".')">'.
        substr($msg,0,20).'...</a><br>';         substr($msg,0,40).'...</a><br />';
        }         }
     }      }
     return '<td><b>'.$day.'</b><br>'.$output.'</td>';      return $output;
   }
   
   sub listcell {
       my ($text)=@_;
       my $output='';
       foreach (split(/\_\_\_\&\&\&\_\_\_/,$text)) {
           if ($_) {
       my ($courseid,$start,$end,@msg)=split(/\@/,$_);
               my $msg=join('@',@msg);
               my $fullmsg=localtime($start).' to '.localtime($end).':<br /><b>'.
                  $msg.'</b>';
               $output.='<li>'.$fullmsg.'</li>';
          }
       }
       return $output;
 }  }
   
 sub nextday {  sub nextday {
Line 99  sub nextday { Line 142  sub nextday {
 }  }
   
 sub showday {  sub showday {
     my ($tk,%allcal)=@_;      my ($tk,$mode,%allcal)=@_;
     my %th=&Apache::loncommon::timehash($tk);      my %th=&Apache::loncommon::timehash($tk);
     my ($nextday,$nextmonth)=&nextday(%th);      my ($nextday,$nextmonth)=&nextday(%th);
     my $outp='';      my $outp='';
Line 111  sub showday { Line 154  sub showday {
             $allcal{$_};              $allcal{$_};
         }          }
     }      }
     return ($nextday,$nextmonth,&normalcell($th{'day'},$outp));      unless ($mode) {
          return ($nextday,$nextmonth,&normalcell(
                  $th{'day'},$th{'month'},$th{'year'},$outp));
      } elsif ($outp) {
          if ($mode==1) {
             return '<br />'.&plaincell($outp);
         } else {
             return '<ul>'.&listcell($outp).'</ul>';
         }
      } else {
          return '';
      }
 }  }
   
 sub handler {  sub handler {
Line 122  sub handler { Line 176  sub handler {
   
 # ---------------------------------------------------------- Get time right now  # ---------------------------------------------------------- Get time right now
     my $today=time;      my $today=time;
     my %todayhash=&Apache::loncommon::timehash($today);      %todayhash=&Apache::loncommon::timehash($today);
   
 # ---------------------------------------------------------- Get month and year  # ---------------------------------------------------------- Get month and year
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},      &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
Line 214  ENDDOCUMENT Line 268  ENDDOCUMENT
     my ($pm,$py,$fm,$fy)=($month-1,$year,$month+1,$year);      my ($pm,$py,$fm,$fy)=($month-1,$year,$month+1,$year);
     if ($pm<1) { ($pm,$py)=(12,$year-1); }      if ($pm<1) { ($pm,$py)=(12,$year-1); }
     if ($fm>12){ ($fm,$fy)=(1,$year+1); }      if ($fm>12){ ($fm,$fy)=(1,$year+1); }
   
     $r->print('<h1>'.('','January','February','March','April','May',      $r->print('<h1>'.('','January','February','March','April','May',
       'June','July','August','September','October',        'June','July','August','September','October',
                       'November','December')[$month].' '.$year.'</h1>'.                        'November','December')[$month].' '.$year.'</h1>');
   # Reached the end of times, give up
       if (($year<1970) || ($year>2037)) {
    $r->print('<h3>No calendar available for this date.</h3>'.
    '<a href="/adm/announcements?month='.$todayhash{'month'}.
    '&year='.$todayhash{'year'}.'">Current Month</a></body></html>');
    return OK;
       }
       $r->print(
  '<a href="/adm/announcements?month='.$pm.'&year='.$py.'">Previous Month</a> '.   '<a href="/adm/announcements?month='.$pm.'&year='.$py.'">Previous Month</a> '.
  '<a href="/adm/announcements?month='.$fm.'&year='.$fy.'">Next Month</a><p>'.   '<a href="/adm/announcements?month='.$fm.'&year='.$fy.'">Next Month</a>'.
    '&nbsp;&nbsp;&nbsp;<a href="/adm/announcements?month='.$todayhash{'month'}.
    '&year='.$todayhash{'year'}.'">Current Month</a><p>'.
         '<table border="2" cols="7" rows="5"><tr><th>Sun</th><th>Mon</th>'.          '<table border="2" cols="7" rows="5"><tr><th>Sun</th><th>Mon</th>'.
         '<th>Tue</th><th>Wed</th><th>Thu</th><th>Fri</th><th>Sat</th></tr>');          '<th>Tue</th><th>Wed</th><th>Thu</th><th>Fri</th><th>Sat</th></tr>');
   
Line 230  ENDDOCUMENT Line 295  ENDDOCUMENT
     $r->print('<tr>');      $r->print('<tr>');
     for (my $i=0;$i<$weekday;$i++) { $r->print(&emptycell); }      for (my $i=0;$i<$weekday;$i++) { $r->print(&emptycell); }
     for (my $i=$weekday;$i<=6;$i++) {       for (my $i=$weekday;$i<=6;$i++) { 
         ($tk,$nm,$outp)=&showday($tk,%allcal);          ($tk,$nm,$outp)=&showday($tk,0,%allcal);
         $r->print($outp);          $r->print($outp);
     }      }
     $r->print('</tr>');      $r->print('</tr>');
Line 238  ENDDOCUMENT Line 303  ENDDOCUMENT
     for (my $k=0;$k<=3;$k++) {      for (my $k=0;$k<=3;$k++) {
         $r->print('<tr>');          $r->print('<tr>');
         for (my $i=0;$i<=6;$i++) {          for (my $i=0;$i<=6;$i++) {
             ($tk,$nm,$outp)=&showday($tk,%allcal);              ($tk,$nm,$outp)=&showday($tk,0,%allcal);
             if ($month!=$nm) { $outp=&emptycell; }              if ($month!=$nm) { $outp=&emptycell; }
             $r->print($outp);              $r->print($outp);
         }          }
Line 249  ENDDOCUMENT Line 314  ENDDOCUMENT
     if ($allowed) { $r->print('<input type="button" onClick="removesub()" value="Remove Checked Entries"></form>'); }      if ($allowed) { $r->print('<input type="button" onClick="removesub()" value="Remove Checked Entries"></form>'); }
     $r->print('<p>'.      $r->print('<p>'.
  '<a href="/adm/announcements?month='.$pm.'&year='.$py.'">Previous Month</a> '.   '<a href="/adm/announcements?month='.$pm.'&year='.$py.'">Previous Month</a> '.
  '<a href="/adm/announcements?month='.$fm.'&year='.$fy.'">Next Month</a><p>'.   '<a href="/adm/announcements?month='.$fm.'&year='.$fy.'">Next Month</a>'.
    '&nbsp;&nbsp;&nbsp;<a href="/adm/announcements?month='.$todayhash{'month'}.
    '&year='.$todayhash{'year'}.'">Current Month</a></p>'.
  '</body></html>');   '</body></html>');
     return OK;      return OK;
 }   } 

Removed from v.1.10  
changed lines
  Added in v.1.15


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