Diff for /loncom/interface/lonannounce.pm between versions 1.73 and 1.88

version 1.73, 2008/10/13 15:33:02 version 1.88, 2017/02/16 18:17:49
Line 45  my %todayhash; Line 45  my %todayhash;
 my %showedcheck;  my %showedcheck;
   
 sub editfield {  sub editfield {
     my ($r,$start,$end,$text)=@_;      my ($r,$start,$end,$text,$crstype)=@_;
     # Deal with date forms      # Deal with date forms
     my $startdateform = &Apache::lonhtmlcommon::date_setter('anno',      my $startdateform = &Apache::lonhtmlcommon::date_setter('anno',
                                                             'startdate',                                                              'startdate',
Line 53  sub editfield { Line 53  sub editfield {
     my $enddateform = &Apache::lonhtmlcommon::date_setter('anno',      my $enddateform = &Apache::lonhtmlcommon::date_setter('anno',
                                                           'enddate',                                                            'enddate',
                                                           $end);                                                            $end);
     my $help=&Apache::loncommon::help_open_menu('Calendar Add Announcement','Calendar_Add_Announcement',274,'Communication Tools');      #my $help=&Apache::loncommon::help_open_menu('Calendar Add Announcement','Calendar_Add_Announcement',274,'Communication Tools');
       my $help=&Apache::loncommon::help_open_topic('Calendar_Add_Announcement');
       
     my %lt=&Apache::lonlocal::texthash('annon' => 'Course Announcements',      my %lt=&Apache::lonlocal::texthash('annon' => 'Course Announcements',
                                        'post' => 'Post Announcement',                                         'post' => 'Post Announcement',
        'start' => 'Starting date',         'start' => 'Starting date',
        'end' => 'Ending date',         'end' => 'Ending date',
        'incrss' => 'Include in course RSS newsfeed');         'incrss' => 'Include in course RSS newsfeed');
       if ($crstype eq 'Community') {
           $lt{'annon'} = &mt('Community Announcements');
           $lt{'incrss'} = &mt('Include in community RSS newsfeed');
       }
   
     $r->print(<<ENDFORM);      $r->print(<<ENDFORM);
 <h2>$lt{'annon'} $help</h2>  <h2>$lt{'annon'} $help</h2>
 <form name="anno" method="post">  <form name="anno" method="post" action="">
 <input type="hidden" value='' name="action" />  <input type="hidden" value='' name="action" />
 <table><tr><td>$lt{'start'}:</td><td>$startdateform</td></tr>  <table><tr><td>$lt{'start'}:</td><td>$startdateform</td></tr>
 <tr><td>$lt{'end'}:</td><td>$enddateform</td></tr></table>  <tr><td>$lt{'end'}:</td><td>$enddateform</td></tr></table>
 <textarea name="msg" rows="4" cols="60">$text</textarea>  <textarea name="msg" rows="4" cols="60">$text</textarea>
 <br />  <br />
 <label><input type="checkbox" name="rsspost" /> $lt{'incrss'}</label>  <label><input type="checkbox" name="rsspost" /> $lt{'incrss'}</label>
 <br /><input type="button" onClick="trysubmit()" value="$lt{'post'}" /><hr />  <br /><input type="button" onclick="trysubmit()" value="$lt{'post'}" /><hr />
 ENDFORM  ENDFORM
 }  }
   
Line 111  sub readcalendar { Line 117  sub readcalendar {
     foreach my $thiskey (keys(%$resourcedata)) {      foreach my $thiskey (keys(%$resourcedata)) {
  if ($resourcedata->{$thiskey.'.type'}=~/^date/) {   if ($resourcedata->{$thiskey.'.type'}=~/^date/) {
     my ($course,$middle,$part,$name)=      my ($course,$middle,$part,$name)=
  ($thiskey=~/^(\Q$courseid\E)\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/);   ($thiskey=~/^(\Q$courseid\E)\.(?:(.+)\.)*([\w\s\-]+)\.(\w+)$/);
   
     my %data = ( 'section' => &mt('All Students'));      my %data = ( 'section' => &mt('All Students'));
     if ($middle=~/^\[(.*)\]\./) {      if ($middle=~/^\[(.*)\]\./) {
Line 222  sub normalcell { Line 228  sub normalcell {
        && ($env{'form.pickdate'} ne 'yes')         && ($env{'form.pickdate'} ne 'yes')
        && (!$internalflag)) {         && (!$internalflag)) {
                $output.='<input type="checkbox" name="remove_'.$start.'_'.                 $output.='<input type="checkbox" name="remove_'.$start.'_'.
    $end.'">';     $end.'" />';
                $showedcheck{$start.'_'.$end}=1;                 $showedcheck{$start.'_'.$end}=1;
       }        }
     }      }
Line 413  sub picklink { Line 419  sub picklink {
   
 sub dialscript {  sub dialscript {
     return (<<ENDDIA);      return (<<ENDDIA);
 <script language="Javascript">  <script type="text/javascript" language="JavaScript">
   // <![CDATA[
 function dialin(day,month,year) {  function dialin(day,month,year) {
  opener.document.$env{'form.formname'}.$env{'form.element'}\_year.value=year;   opener.document.$env{'form.formname'}.$env{'form.element'}\_year.value=year;
     var slct=opener.document.$env{'form.formname'}.$env{'form.element'}\_month;      var slct=opener.document.$env{'form.formname'}.$env{'form.element'}\_month;
Line 425  function dialin(day,month,year) { Line 432  function dialin(day,month,year) {
     opener.$env{'form.element'}\_checkday();      opener.$env{'form.element'}\_checkday();
     self.close();      self.close();
 }  }
   // ]]>
 </script>  </script>
 ENDDIA  ENDDIA
 }  }
Line 500  sub handler { Line 508  sub handler {
   
 # ---------------------------------------------- See if we are in pickdate mode  # ---------------------------------------------- See if we are in pickdate mode
     my $pickdatemode=($env{'form.pickdate'} eq 'yes');      my $pickdatemode=($env{'form.pickdate'} eq 'yes');
     my $pickinfo='&pickdate=yes&formname='.$env{'form.formname'}.      my $pickinfo='&amp;pickdate=yes&amp;formname='.$env{'form.formname'}.
  '&element='.$env{'form.element'};   '&amp;element='.$env{'form.element'};
 # --------------------------------------------- Find out first day of the month  # --------------------------------------------- Find out first day of the month
   
     my $tk = &Apache::loncommon::maketime( 'day' => 1,      my $tk = &Apache::loncommon::maketime( 'day' => 1,
Line 515  sub handler { Line 523  sub handler {
   
 # ------------------------------------------------------------ Print the screen  # ------------------------------------------------------------ Print the screen
     my $js = <<ENDDOCUMENT;      my $js = <<ENDDOCUMENT;
 <script type="text/javascript">  <script type="text/javascript" language="JavaScript">
   // <![CDATA[
   
     function trysubmit() {      function trysubmit() {
         document.anno.action.value="new";          document.anno.action.value="new";
Line 526  sub handler { Line 535  sub handler {
         document.anno.action.value="del";          document.anno.action.value="del";
  document.anno.submit();   document.anno.submit();
     }      }
   // ]]>
 </script>  </script>
 ENDDOCUMENT  ENDDOCUMENT
   
Line 536  ENDDOCUMENT Line 546  ENDDOCUMENT
   &dialscript().    &dialscript().
   '<font size="1">');    '<font size="1">');
     } else {      } else {
        $r->print(&Apache::loncommon::start_page("Announcements and Calendar",          my $brcrum = [{href=>"/adm/announcements",text=>"Announcements and Calendar"}];
  $js));          $r->print(&Apache::loncommon::start_page("Communication",$js,{'bread_crumbs' => $brcrum}));
     }      }
 # does this user have privileges to post, etc?  # does this user have privileges to post, etc?
     my $allowed=0;      my $allowed=0;
Line 559  ENDDOCUMENT Line 569  ENDDOCUMENT
     }      }
 # ------------------------------------------------------------ Process commands  # ------------------------------------------------------------ Process commands
     if ($serverpost) {      if ($serverpost) {
  if ($env{'form.serveraction'}) {          if ($env{'form.serveraction'}) {
     foreach my $key (keys(%env)) {              my $rc;
  if ($key=~/^form\.postto\_(\w+)/) {              my $message;
     $r->print(               foreach my $key (keys(%env)) {
  '<br />Posting '.$1.': '.&Apache::lonnet::postannounce                  if ($key=~/^form\.postto\_(\w+[\w\-]*)/) {
  ($1,$env{'form.serverannnounce'}));                       $rc = &Apache::lonnet::postannounce
  }                             ($1,$env{'form.serverannnounce'});
     }                      if ($rc eq 'ok') {
  }                          $message .= 
  $r->print('<form name="serveranno" method="post">'                              &Apache::lonhtmlcommon::confirm_success(
                                   &mt('Announcement posted to [_1]',$1))
                                  .'<br />';
                       } else {
                           $message .=
                               &Apache::lonhtmlcommon::confirm_success(
                                   &mt('Posting announcement to [_1] failed: [_2]'
                                       ,$1,$rc), 1)
                                  .'<br />';
                       }
                   }
               }
               $r->print(&Apache::loncommon::confirmwrapper($message));
           }
    $r->print('<form name="serveranno" method="post" action="">'
                  .'<h2>'.&mt('Post Server Announcements').'</h2>'                   .'<h2>'.&mt('Post Server Announcements').'</h2>'
                  .&mt('Post announcements to the system login and roles screen').'<br />'                   .&mt('Post announcements to the system login and roles screen').'<br />'
                  .'<i>'.&mt('(leave blank to delete announcement)').'</i><br />'                   .'<i>'.&mt('(leave blank to delete announcement)').'</i><br />'
Line 588  ENDDOCUMENT Line 612  ENDDOCUMENT
  }   }
     }      }
     $r->print(      $r->print(
   '<br /><input type="submit" name="serveraction" value="'.&mt('Post').'"></form><hr />');    '<br /><input type="submit" name="serveraction" value="'.&mt('Post').'" /></form><hr />');
     }      }
     if ($allowed) {      if ($allowed) {
         my $coursenum=$env{'course.'.$env{'request.course.id'}.'.num'};          my $coursenum=$env{'course.'.$env{'request.course.id'}.'.num'};
         my $coursedom=$env{'course.'.$env{'request.course.id'}.'.domain'};          my $coursedom=$env{'course.'.$env{'request.course.id'}.'.domain'};
           my $crstype = &Apache::loncommon::course_type();
 # ----------------------------------------------------- Store new submitted one  # ----------------------------------------------------- Store new submitted one
         if ($env{'form.action'} eq 'new') {          if ($env{'form.action'} eq 'new') {
     my $startdate =       my $startdate = 
Line 610  ENDDOCUMENT Line 635  ENDDOCUMENT
  $startdate.'_'.$enddate =>    $startdate.'_'.$enddate => 
     $env{'form.msg'} },$coursedom,$coursenum);      $env{'form.msg'} },$coursedom,$coursenum);
     if ($env{'form.rsspost'}) {      if ($env{'form.rsspost'}) {
                &Apache::lonrss::addentry($coursenum,$coursedom,'Course_Announcements',                 my $feed;
                  if ($crstype eq 'Community') {
                      $feed = 'Community_Announcements';
                  } else {
                      $feed = 'Course_Announcements';
                  }
                  &Apache::lonrss::addentry($coursenum,$coursedom,$feed,
  &mt('Event from [_1] to [_2]',   &mt('Event from [_1] to [_2]',
      &Apache::lonlocal::locallocaltime($startdate),       &Apache::lonlocal::locallocaltime($startdate),
      &Apache::lonlocal::locallocaltime($enddate)),       &Apache::lonlocal::locallocaltime($enddate)),
Line 632  ENDDOCUMENT Line 663  ENDDOCUMENT
         $tomorrowhash{'day'}++;          $tomorrowhash{'day'}++;
         my $tomorrow=&Apache::loncommon::maketime(%tomorrowhash);          my $tomorrow=&Apache::loncommon::maketime(%tomorrowhash);
                   
         &editfield($r,$today,$tomorrow,'');          &editfield($r,$today,$tomorrow,'',$crstype);
     }      }
 # ----------------------------------------------------- Summarize all calendars  # ----------------------------------------------------- Summarize all calendars
     my %allcal=&get_all_calendars();      my %allcal=&get_all_calendars();
Line 654  ENDDOCUMENT Line 685  ENDDOCUMENT
                  .&mt('No calendar available for this date.')                   .&mt('No calendar available for this date.')
                  .'</p>'                   .'</p>'
                  .'<a href="/adm/announcements?month='.$todayhash{'month'}                   .'<a href="/adm/announcements?month='.$todayhash{'month'}
                  .'&year='.$todayhash{'year'}.'">'.&mt('Current Month').'</a>'                   .'&amp;year='.$todayhash{'year'}.'">'.&mt('Current Month').'</a>'
  .&Apache::loncommon::end_page());   .&Apache::loncommon::end_page());
  return OK;   return OK;
     }      }
Line 693  ENDDOCUMENT Line 724  ENDDOCUMENT
     }      }
   
     $r->print(      $r->print(
  '<a href="/adm/announcements?month='.$pm.'&year='.$py.   '<a href="/adm/announcements?month='.$pm.'&amp;year='.$py.
  ($pickdatemode?$pickinfo:'').'">'.&mt('Previous Month').'</a> '.   ($pickdatemode?$pickinfo:'').'">'.&mt('Previous Month').'</a> '.
  '<a href="/adm/announcements?month='.$fm.'&year='.$fy.   '<a href="/adm/announcements?month='.$fm.'&amp;year='.$fy.
  ($pickdatemode?$pickinfo:'').'">'.&mt('Next Month').'</a>'.   ($pickdatemode?$pickinfo:'').'">'.&mt('Next Month').'</a>'.
  '&nbsp;&nbsp;&nbsp;<a href="/adm/announcements?month='.$todayhash{'month'}.   '&nbsp;&nbsp;&nbsp;<a href="/adm/announcements?month='.$todayhash{'month'}.
  '&year='.$todayhash{'year'}.   '&amp;year='.$todayhash{'year'}.
  ($pickdatemode?$pickinfo:'').'">'.&mt('Current Month').'</a><p>'.   ($pickdatemode?$pickinfo:'').'">'.&mt('Current Month').'</a><div>'.
         '<table class="'.$class.'" cols="7" rows="5"><tr>');          '<table class="'.$class.'"><tr>');
     for (my $i=0; $i<@localdays; $i++) {      for (my $i=0; $i<@localdays; $i++) {
         $r->print('<th>'.&mt($localdays[$i]).'</th>');          $r->print('<th>'.&mt($localdays[$i]).'</th>');
     }      }
Line 740  ENDDOCUMENT Line 771  ENDDOCUMENT
         }          }
     }      }
 # ------------------------------------------------------------------- End table  # ------------------------------------------------------------------- End table
     $r->print('</table>');      $r->print('</table></div>');
 # ----------------------------------------------------------------- Check marks  # ----------------------------------------------------------------- Check marks
     undef(%showedcheck);      undef(%showedcheck);
 # --------------------------------------------------------------- Remove button  # --------------------------------------------------------------- Remove button
     if ($allowed) { $r->print('<br /><input type="button" onClick="removesub()" value="'.&mt('Remove Checked Entries').'">'.      if ($allowed) { $r->print('<br /><input type="button" onclick="removesub()" value="'.&mt('Remove Checked Entries').'" />'.
       &Apache::loncommon::help_open_topic('Calendar_Remove_Announcement').'</form>'); }        &Apache::loncommon::help_open_topic('Calendar_Remove_Announcement').'</form>'); }
     $r->print('<p>'.      $r->print('<p>'.
  '<a href="/adm/announcements?month='.$pm.'&year='.$py.   '<a href="/adm/announcements?month='.$pm.'&amp;year='.$py.
  ($pickdatemode?$pickinfo:'').'">'.&mt('Previous Month').'</a> '.   ($pickdatemode?$pickinfo:'').'">'.&mt('Previous Month').'</a> '.
  '<a href="/adm/announcements?month='.$fm.'&year='.$fy.   '<a href="/adm/announcements?month='.$fm.'&amp;year='.$fy.
  ($pickdatemode?$pickinfo:'').'">'.&mt('Next Month').'</a>'.   ($pickdatemode?$pickinfo:'').'">'.&mt('Next Month').'</a>'.
  '&nbsp;&nbsp;&nbsp;<a href="/adm/announcements?month='.$todayhash{'month'}.   '&nbsp;&nbsp;&nbsp;<a href="/adm/announcements?month='.$todayhash{'month'}.
  '&year='.$todayhash{'year'}.   '&amp;year='.$todayhash{'year'}.
  ($pickdatemode?$pickinfo:'').'">'.&mt('Current Month').'</a></p>'.   ($pickdatemode?$pickinfo:'').'">'.&mt('Current Month').'</a></p>'.
  ($pickdatemode?'</font>':'').&Apache::loncommon::end_page());   ($pickdatemode?'</font>':'').
     $r->print('<a href="/adm/announcements.ics">'.&mt('Download your Calendar as iCalendar File').'</a>');   '<a href="/adm/announcements.ics">'.&mt('Download your Calendar as iCalendar File').'</a>'.
       &Apache::loncommon::end_page());
     return OK;      return OK;
 }   } 
   

Removed from v.1.73  
changed lines
  Added in v.1.88


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