--- loncom/interface/lonannounce.pm 2009/03/25 15:49:47 1.78 +++ loncom/interface/lonannounce.pm 2013/05/27 00:19:32 1.87 @@ -1,7 +1,7 @@ # The LearningOnline Network # Announce # -# $Id: lonannounce.pm,v 1.78 2009/03/25 15:49:47 bisitz Exp $ +# $Id: lonannounce.pm,v 1.87 2013/05/27 00:19:32 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -45,7 +45,7 @@ my %todayhash; my %showedcheck; sub editfield { - my ($r,$start,$end,$text)=@_; + my ($r,$start,$end,$text,$crstype)=@_; # Deal with date forms my $startdateform = &Apache::lonhtmlcommon::date_setter('anno', 'startdate', @@ -61,17 +61,21 @@ sub editfield { 'start' => 'Starting date', 'end' => 'Ending date', '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(<$lt{'annon'} $help -
+
$lt{'start'}:$startdateform
$lt{'end'}:$enddateform

-

+

ENDFORM } @@ -224,7 +228,7 @@ sub normalcell { && ($env{'form.pickdate'} ne 'yes') && (!$internalflag)) { $output.=''; + $end.'" />'; $showedcheck{$start.'_'.$end}=1; } } @@ -416,6 +420,7 @@ sub picklink { sub dialscript { return (< +// ENDDIA } @@ -502,8 +508,8 @@ sub handler { # ---------------------------------------------- See if we are in pickdate mode my $pickdatemode=($env{'form.pickdate'} eq 'yes'); - my $pickinfo='&pickdate=yes&formname='.$env{'form.formname'}. - '&element='.$env{'form.element'}; + my $pickinfo='&pickdate=yes&formname='.$env{'form.formname'}. + '&element='.$env{'form.element'}; # --------------------------------------------- Find out first day of the month my $tk = &Apache::loncommon::maketime( 'day' => 1, @@ -518,6 +524,7 @@ sub handler { # ------------------------------------------------------------ Print the screen my $js = < +// ENDDOCUMENT @@ -561,16 +569,30 @@ ENDDOCUMENT } # ------------------------------------------------------------ Process commands if ($serverpost) { - if ($env{'form.serveraction'}) { - foreach my $key (keys(%env)) { - if ($key=~/^form\.postto\_(\w+)/) { - $r->print( - '
Posting '.$1.': '.&Apache::lonnet::postannounce - ($1,$env{'form.serverannnounce'})); - } - } - } - $r->print('' + if ($env{'form.serveraction'}) { + my $rc; + my $message; + foreach my $key (keys(%env)) { + if ($key=~/^form\.postto\_(\w+[\w\-]*)/) { + $rc = &Apache::lonnet::postannounce + ($1,$env{'form.serverannnounce'}); + if ($rc eq 'ok') { + $message .= + &Apache::lonhtmlcommon::confirm_success( + &mt('Announcement posted to [_1]',$1)) + .'
'; + } else { + $message .= + &Apache::lonhtmlcommon::confirm_success( + &mt('Posting announcement to [_1] failed: [_2]' + ,$1,$rc), 1) + .'
'; + } + } + } + $r->print(&Apache::loncommon::confirmwrapper($message)); + } + $r->print('' .'

'.&mt('Post Server Announcements').'

' .&mt('Post announcements to the system login and roles screen').'
' .''.&mt('(leave blank to delete announcement)').'
' @@ -590,11 +612,12 @@ ENDDOCUMENT } } $r->print( - '

'); + '

'); } if ($allowed) { my $coursenum=$env{'course.'.$env{'request.course.id'}.'.num'}; my $coursedom=$env{'course.'.$env{'request.course.id'}.'.domain'}; + my $crstype = &Apache::loncommon::course_type(); # ----------------------------------------------------- Store new submitted one if ($env{'form.action'} eq 'new') { my $startdate = @@ -612,7 +635,13 @@ ENDDOCUMENT $startdate.'_'.$enddate => $env{'form.msg'} },$coursedom,$coursenum); 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]', &Apache::lonlocal::locallocaltime($startdate), &Apache::lonlocal::locallocaltime($enddate)), @@ -634,7 +663,7 @@ ENDDOCUMENT $tomorrowhash{'day'}++; my $tomorrow=&Apache::loncommon::maketime(%tomorrowhash); - &editfield($r,$today,$tomorrow,''); + &editfield($r,$today,$tomorrow,'',$crstype); } # ----------------------------------------------------- Summarize all calendars my %allcal=&get_all_calendars(); @@ -656,7 +685,7 @@ ENDDOCUMENT .&mt('No calendar available for this date.') .'

' .''.&mt('Current Month').'' + .'&year='.$todayhash{'year'}.'">'.&mt('Current Month').'' .&Apache::loncommon::end_page()); return OK; } @@ -695,14 +724,14 @@ ENDDOCUMENT } $r->print( - ''.&mt('Previous Month').' '. - ''.&mt('Next Month').''. '   '.&mt('Current Month').'

'. - ''); + '&year='.$todayhash{'year'}. + ($pickdatemode?$pickinfo:'').'">'.&mt('Current Month').'
'. + '
'); for (my $i=0; $i<@localdays; $i++) { $r->print(''); } @@ -742,22 +771,23 @@ ENDDOCUMENT } } # ------------------------------------------------------------------- End table - $r->print('
'.&mt($localdays[$i]).'
'); + $r->print(''); # ----------------------------------------------------------------- Check marks undef(%showedcheck); # --------------------------------------------------------------- Remove button - if ($allowed) { $r->print('
'. + if ($allowed) { $r->print('
'. &Apache::loncommon::help_open_topic('Calendar_Remove_Announcement').''); } $r->print('

'. - ''.&mt('Previous Month').' '. - ''.&mt('Next Month').''. '   '.&mt('Current Month').'

'. - ($pickdatemode?'':'').&Apache::loncommon::end_page()); - $r->print(''.&mt('Download your Calendar as iCalendar File').''); + ($pickdatemode?'':''). + ''.&mt('Download your Calendar as iCalendar File').''. + &Apache::loncommon::end_page()); return OK; }