X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=tools%2Fkoha-news.pl;h=24519349448fff27d34b2bf45b820cfd845e3666;hb=52ebf8f3f0dde98386cf5a12917c19e6d236a465;hp=76e10935bd7bc48f9bd05d138a28a2176e918bcc;hpb=789eab7d430bbb9af3fbeb267ac4f43c98c55602;p=koha_gimpoz diff --git a/tools/koha-news.pl b/tools/koha-news.pl index 76e10935bd..2451934944 100755 --- a/tools/koha-news.pl +++ b/tools/koha-news.pl @@ -17,19 +17,20 @@ # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR # A PARTICULAR PURPOSE. See the GNU General Public License for more details. # -# You should have received a copy of the GNU General Public License along with -# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, -# Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. use strict; +#use warnings; FIXME - Bug 2505 use CGI; use C4::Auth; use C4::Koha; use C4::Context; -use C4::Date; +use C4::Dates qw(format_date_in_iso); use C4::Output; use C4::NewsChannels; -use C4::Languages; +use C4::Languages qw(getTranslatedLanguages); use Date::Calc qw/Date_to_Days Today/; my $cgi = new CGI; @@ -37,7 +38,8 @@ my $cgi = new CGI; my $id = $cgi->param('id'); my $title = $cgi->param('title'); my $new = $cgi->param('new'); -my $expirationdate = $cgi->param('expirationdate'); +my $expirationdate = format_date_in_iso($cgi->param('expirationdate')); +my $timestamp = format_date_in_iso($cgi->param('timestamp')); my $number = $cgi->param('number'); my $lang = $cgi->param('lang'); @@ -49,7 +51,7 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user( query => $cgi, type => "intranet", authnotrequired => 0, - flagsrequired => { tools => 1 }, + flagsrequired => { tools => 'edit_news' }, debug => 1, } ); @@ -60,8 +62,8 @@ my $tlangs = getTranslatedLanguages() ; foreach my $language ( @$tlangs ) { push @lang_list, { - language => $language->{'language_code'}, - selected => ( $new_detail->{lang} eq $language->{'language_code'} ? 1 : 0 ), + language => $language->{'rfc4646_subtag'}, + selected => ( $new_detail->{lang} eq $language->{'rfc4646_subtag'} ? 1 : 0 ), }; } @@ -72,6 +74,7 @@ my $op = $cgi->param('op'); if ( $op eq 'add_form' ) { $template->param( add_form => 1 ); if ($id) { + if($new_detail->{lang} eq "slip"){ $template->param( slip => 1); } $template->param( op => 'edit', id => $new_detail->{'idnew'} @@ -83,11 +86,11 @@ if ( $op eq 'add_form' ) { } } elsif ( $op eq 'add' ) { - add_opac_new( $title, $new, $lang, $expirationdate, $number ); + add_opac_new( $title, $new, $lang, $expirationdate, $timestamp, $number ); print $cgi->redirect("/cgi-bin/koha/tools/koha-news.pl"); } elsif ( $op eq 'edit' ) { - upd_opac_new( $id, $title, $new, $lang, $expirationdate, $number ); + upd_opac_new( $id, $title, $new, $lang, $expirationdate, $timestamp ,$number ); print $cgi->redirect("/cgi-bin/koha/tools/koha-news.pl"); } elsif ( $op eq 'del' ) { @@ -102,12 +105,11 @@ else { foreach my $new ( @$opac_news ) { next unless $new->{'expirationdate'}; - # next if $new->{'expirationdate'} eq '0000-00-00'; # now saved as null - $new->{'expirationdate'}=format_date_in_iso($new->{'expirationdate'}); - my @date = split (/-/,$new->{'expirationdate'}); - if ($date[0]*$date[1]*$date[2]>0 && Date_to_Days( @date ) < Date_to_Days(&Today) ){ - $new->{'hasexpirated'} = 1; - } + #$new->{'expirationdate'}=format_date_in_iso($new->{'expirationdate'}); + my @date = split (/-/,$new->{'expirationdate'}); + if ($date[0]*$date[1]*$date[2]>0 && Date_to_Days( @date ) < Date_to_Days(&Today) ){ + $new->{'expired'} = 1; + } } $template->param( @@ -117,6 +119,7 @@ else { ); } $template->param( - DHTMLcalendar_dateformat => get_date_format_string_for_DHTMLcalendar(C4::Context->preference('dateformat')) , + DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(), + dateformat => C4::Context->preference("dateformat"), ); output_html_with_http_headers $cgi, $cookie, $template->output;