--- loncom/interface/lonannounce.pm 2008/09/19 03:27:04 1.71 +++ loncom/interface/lonannounce.pm 2017/02/16 18:17:49 1.88 @@ -1,7 +1,7 @@ # The LearningOnline Network # Announce # -# $Id: lonannounce.pm,v 1.71 2008/09/19 03:27:04 raeburn Exp $ +# $Id: lonannounce.pm,v 1.88 2017/02/16 18:17:49 damieng 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', @@ -53,22 +53,29 @@ sub editfield { my $enddateform = &Apache::lonhtmlcommon::date_setter('anno', 'enddate', $end); - my $help=&Apache::loncommon::help_open_menu('Calendar Add Announcement','Calendar_Add_Announcement',274,'Communication Tools'); - my %lt=&Apache::lonlocal::texthash('post' => 'Post Announcement', + #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', + 'post' => 'Post Announcement', '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 } @@ -110,7 +117,7 @@ sub readcalendar { foreach my $thiskey (keys(%$resourcedata)) { if ($resourcedata->{$thiskey.'.type'}=~/^date/) { 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')); if ($middle=~/^\[(.*)\]\./) { @@ -221,7 +228,7 @@ sub normalcell { && ($env{'form.pickdate'} ne 'yes') && (!$internalflag)) { $output.=''; + $end.'" />'; $showedcheck{$start.'_'.$end}=1; } } @@ -412,7 +419,8 @@ sub picklink { sub dialscript { return (< + ENDDIA } @@ -499,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, @@ -514,7 +523,8 @@ sub handler { # ------------------------------------------------------------ Print the screen my $js = < + ENDDOCUMENT @@ -535,8 +546,8 @@ ENDDOCUMENT &dialscript(). ''); } else { - $r->print(&Apache::loncommon::start_page("Announcements and Calendar", - $js)); + my $brcrum = [{href=>"/adm/announcements",text=>"Announcements and Calendar"}]; + $r->print(&Apache::loncommon::start_page("Communication",$js,{'bread_crumbs' => $brcrum})); } # does this user have privileges to post, etc? my $allowed=0; @@ -558,40 +569,55 @@ 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(< -

Post Server Announcements

-Post announcements to the system login and roles screen
-(leave blank to delete announcement)
-
-Check machines:
-SERVERANNOUNCE + 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)').'
' + .'
' + .&mt('Check machines:').'
' + ); # list servers my %hostname = &Apache::lonnet::all_hostnames(); foreach my $host (sort(keys(%hostname))) { if (&Apache::lonnet::allowed('psa', &Apache::lonnet::host_domain($host))) { - $r->print ('
':'').&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; }