[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Koha-cvs] koha C4/NewsChannels.pm koha-tmpl/intranet-tmpl... [rel_3_0]
From: |
Antoine Farnault |
Subject: |
[Koha-cvs] koha C4/NewsChannels.pm koha-tmpl/intranet-tmpl... [rel_3_0] |
Date: |
Tue, 09 Jan 2007 16:43:04 +0000 |
CVSROOT: /sources/koha
Module name: koha
Branch: rel_3_0
Changes by: Antoine Farnault <toins> 07/01/09 16:43:04
Modified files:
C4 : NewsChannels.pm
koha-tmpl/intranet-tmpl/prog/en/tools: koha-news.tmpl
tools : koha-news.pl
Log message:
Now able to mark opac_news to be displayed or not with a checkbox
online and with an expiration date.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/C4/NewsChannels.pm?cvsroot=koha&only_with_tag=rel_3_0&r1=1.1.2.1&r2=1.1.2.2
http://cvs.savannah.gnu.org/viewcvs/koha/koha-tmpl/intranet-tmpl/prog/en/tools/koha-news.tmpl?cvsroot=koha&only_with_tag=rel_3_0&r1=1.1.2.3&r2=1.1.2.4
http://cvs.savannah.gnu.org/viewcvs/koha/tools/koha-news.pl?cvsroot=koha&only_with_tag=rel_3_0&r1=1.1.2.3&r2=1.1.2.4
Patches:
Index: C4/NewsChannels.pm
===================================================================
RCS file: /sources/koha/koha/C4/NewsChannels.pm,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -b -r1.1.2.1 -r1.1.2.2
--- C4/NewsChannels.pm 8 Dec 2006 17:33:27 -0000 1.1.2.1
+++ C4/NewsChannels.pm 9 Jan 2007 16:43:04 -0000 1.1.2.2
@@ -25,7 +25,7 @@
use vars qw($VERSION @ISA @EXPORT);
# set the version for version checking
-$VERSION = do { my @v = '$Revision: 1.1.2.1 $' =~ /\d+/g;
+$VERSION = do { my @v = '$Revision: 1.1.2.2 $' =~ /\d+/g;
shift(@v) . "." . join( "_", map { sprintf "%03d", $_ } @v );
};
@@ -46,6 +46,7 @@
@ISA = qw(Exporter);
@EXPORT = qw(
+ &GetNewsToDisplay
&news_channels &get_new_channel &del_channels &add_channel &update_channel
&news_channels_categories &get_new_channel_category &del_channels_categories
&add_channel_category &update_channel_category &news_channels_by_category
@@ -238,21 +239,28 @@
return 1;
}
-
sub add_opac_new {
- my ($title, $new, $lang) = @_;
+ my ($title, $new, $lang, $expirationdate, $displayed) = @_;
my $dbh = C4::Context->dbh;
- my $sth = $dbh->prepare("INSERT INTO opac_news (title, new, lang) VALUES
(?,?,?)");
- $sth->execute($title, $new, $lang);
+ my $sth = $dbh->prepare("INSERT INTO opac_news (title, new, lang,
expirationdate, displayed) VALUES (?,?,?,?,?)");
+ $sth->execute($title, $new, $lang, $expirationdate, $displayed);
$sth->finish;
return 1;
}
sub upd_opac_new {
- my ($idnew, $title, $new, $lang) = @_;
+ my ($idnew, $title, $new, $lang, $expirationdate, $displayed) = @_;
my $dbh = C4::Context->dbh;
- my $sth = $dbh->prepare("UPDATE opac_news SET title = ?, new = ?, lang = ?
WHERE idnew = ?");
- $sth->execute($title, $new, $lang, $idnew);
+ my $sth = $dbh->prepare("
+ UPDATE opac_news SET
+ title = ?,
+ new = ?,
+ lang = ?,
+ expirationdate = ?,
+ displayed = ?
+ WHERE idnew = ?
+ ");
+ $sth->execute($title, $new, $lang, $expirationdate,$displayed,$idnew);
$sth->finish;
return 1;
}
@@ -306,6 +314,37 @@
return ($count, address@hidden);
}
+=head2 GetNewsToDisplay
+
+ $news = &GetNewsToDisplay($lang);
+ C<$news> is a ref to an array which containts
+ all news with displayed = 1 and expirationdate > today.
+
+=cut
+
+sub GetNewsToDisplay {
+ my $lang = shift;
+ my $dbh = C4::Context->dbh;
+ my $query = "
+ SELECT *,DATE_FORMAT(timestamp, '%d/%m/%Y') AS newdate
+ FROM opac_news
+ WHERE displayed = 1
+ AND (
+ expirationdate > CURRENT_DATE()
+ OR expirationdate IS NULL
+ OR expirationdate = '00-00-0000'
+ )
+ AND lang = ?
+ ";
+ my $sth = $dbh->prepare($query);
+ $sth->execute($lang);
+ my @results;
+ while ( my $row = $sth->fetchrow_hashref ){
+ push @results, $row;
+ }
+ return address@hidden;
+}
+
### get electronic databases
sub add_opac_electronic {
Index: koha-tmpl/intranet-tmpl/prog/en/tools/koha-news.tmpl
===================================================================
RCS file:
/sources/koha/koha/koha-tmpl/intranet-tmpl/prog/en/tools/koha-news.tmpl,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -u -b -r1.1.2.3 -r1.1.2.4
--- koha-tmpl/intranet-tmpl/prog/en/tools/koha-news.tmpl 8 Dec 2006
17:33:27 -0000 1.1.2.3
+++ koha-tmpl/intranet-tmpl/prog/en/tools/koha-news.tmpl 9 Jan 2007
16:43:04 -0000 1.1.2.4
@@ -1,6 +1,15 @@
<!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
-<!-- TMPL_INCLUDE NAME="holidays-top.inc" -->
+ KOHA -- News Management
<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
+
+<!-- Additions to enable Calendar system -->
+<link rel="stylesheet" type="text/css" href="<!-- TMPL_VAR name="themelang"
-->/includes/calendar/calendar-system.css">
+<!-- End of additions --><!-- Additions to enable Calendar system -->
+<script type="text/javascript" src="<!-- TMPL_VAR name="themelang"
-->/includes/calendar/calendar.js"></script>
+<script type="text/javascript" src="<!-- TMPL_VAR name="themelang"
-->/includes/calendar/calendar-en.js"></script>
+<script type="text/javascript" src="<!-- TMPL_VAR name="themelang"
-->/includes/calendar/calendar-setup.js"></script>
+<!-- End of additions -->
+
<!-- TMPL_INCLUDE NAME="menus.inc" -->
<!-- TMPL_INCLUDE NAME="menu-tools.inc" -->
@@ -11,7 +20,8 @@
<input type="hidden" name="op" value="<!-- TMPL_VAR NAME="op" -->"
/>
<input type="hidden" name="id" value="<!-- TMPL_VAR NAME="id" -->"
/>
<p>
- <select name="lang">
+ <label for="lang">Language</label>
+ <select id="lang" name="lang">
<option value="koha">Librarian interface</option>
<!-- TMPL_LOOP name="lang_list" -->
<!-- TMPL_IF name="selected" -->
@@ -25,8 +35,28 @@
</select>
</p>
<p>
- <label>Title</label>
- <input size="30" type="text" name="title" value="<!-- TMPL_VAR
NAME="title" -->" />
+ <label for="title">Title</label>
+ <input id="title" size="30" type="text" name="title"
value="<!-- TMPL_VAR NAME="title" -->" />
+ </p>
+ <p>
+ <label for="expirationdate">Expiration date</label>
+ <input id="expirationdate" type="text" name="expirationdate"
value="<!-- TMPL_VAR NAME="expirationdate" -->"/>
+ <script type="text/javascript">
+ Calendar.setup(
+ {
+ inputField : "expirationdate",
+ ifFormat : "%Y-%m-%d",
+ }
+ );
+ </script>
+ </p>
+ <p>
+ <label for="displayed">Display online</label>
+ <!-- TMPL_IF NAME="displayed"-->
+ <input id="displayed" name="displayed" type="checkbox"
checked="1" />
+ <!-- TMPL_ELSE -->
+ <input id="displayed" name="displayed" type="checkbox" />
+ <!-- /TMPL_IF -->
</p>
<p>News</p>
<textarea name="new" cols="75" rows="10"><!-- TMPL_VAR NAME="new"
--></textarea>
@@ -62,7 +92,9 @@
<tr>
<th></th>
<th>Language</th>
- <th>Date</th>
+ <th>Online</th>
+ <th>Creation Date</th>
+ <th>Expiration Date</th>
<th>Title</th>
<th>News</th>
<th></th>
@@ -73,22 +105,21 @@
<input type="checkbox" name="ids" value="<!--
TMPL_VAR NAME="idnew" -->" />
</td>
<td><!-- TMPL_VAR NAME="lang" --></td>
+ <td><!-- TMPL_VAR NAME="displayed" --></td>
<td><!-- TMPL_VAR NAME="newdate" --></td>
+ <td><!-- TMPL_VAR NAME="expirationdate" --></td>
<td><!-- TMPL_VAR NAME="title" --></td>
<td><!-- TMPL_VAR NAME="new" --></td>
<td>
- <a
href="/cgi-bin/koha/tools/koha-news.pl?op=add_form&id=<!-- TMPL_VAR
NAME="idnew" -->">Edit</a>
+ <a
href="/cgi-bin/koha/tools/koha-news.pl?op=add_form&id=<!-- TMPL_VAR
NAME="idnew" -->">
+ Edit
+ </a>
</td>
</tr>
<!-- /TMPL_LOOP -->
- <tr>
- <td>
+ </table>
<input type="hidden" name="op" value="del" />
<input type="submit" class="button" value="Delete
selected" />
- </td>
- <td colspan="5"></td>
- </tr>
- </table>
</form>
<!-- TMPL_ELSE -->
<p>No news loaded</p>
@@ -98,6 +129,6 @@
</div>
</div>
<!-- /TMPL_IF -->
-
</div>
+
<!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->
Index: tools/koha-news.pl
===================================================================
RCS file: /sources/koha/koha/tools/koha-news.pl,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -u -b -r1.1.2.3 -r1.1.2.4
--- tools/koha-news.pl 22 Dec 2006 17:13:49 -0000 1.1.2.3
+++ tools/koha-news.pl 9 Jan 2007 16:43:04 -0000 1.1.2.4
@@ -23,7 +23,6 @@
use strict;
use CGI;
-
use C4::Auth;
use C4::Koha;
use C4::Context;
@@ -31,68 +30,82 @@
use C4::Interface::CGI::Output;
use C4::NewsChannels;
-
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 $displayed = $cgi->param('displayed') || 0;
my $lang = $cgi->param('lang');
+
+$displayed = 1 if $displayed eq "on";
+
my $new_detail = get_opac_new($id);
-my ($template, $borrowernumber, $cookie)
- = get_template_and_user({template_name => "tools/koha-news.tmpl",
+my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
+ {
+ template_name => "tools/koha-news.tmpl",
query => $cgi,
type => "intranet",
authnotrequired => 0,
- flagsrequired => {tools => 1},
+ flagsrequired => { tools => 1 },
debug => 1,
- });
+ }
+);
# get lang list
my @lang_list;
-foreach my $language (GetLanguages()) {
- push @lang_list, { language => $language,
- selected =>
($new_detail->{lang} eq $language?1:0),
+foreach my $language ( GetLanguages() ) {
+ push @lang_list,
+ {
+ language => $language,
+ selected => ( $new_detail->{lang} eq $language ? 1 : 0 ),
};
}
-$template->param(lang_list => address@hidden);
+
+$template->param( lang_list => address@hidden );
my $op = $cgi->param('op');
-if ($op eq 'add_form') {
- $template->param(add_form => 1);
+if ( $op eq 'add_form' ) {
+ $template->param( add_form => 1 );
if ($id) {
- $template->param(op => 'edit');
+ $template->param(
+ op => 'edit',
+ id => $new_detail->{'idnew'}
+ );
$template->param($new_detail);
- $template->param(id => $new_detail->{'idnew'});
- } else {
- $template->param(op => 'add');
}
+ else {
+ $template->param( op => 'add' );
+ }
+}
+elsif ( $op eq 'add' ) {
-} elsif ($op eq 'add') {
-
- add_opac_new($title, $new, $lang);
- print $cgi->redirect('/cgi-bin/koha/tools/koha-news.pl');
-
-} elsif ($op eq 'edit') {
-
- upd_opac_new($id, $title, $new, $lang);
- print $cgi->redirect('/cgi-bin/koha/tools/koha-news.pl');
-
-} elsif ($op eq 'del') {
+ add_opac_new( $title, $new, $lang, $expirationdate, $displayed );
+ print $cgi->redirect("/cgi-bin/koha/tools/koha-news.pl");
+}
+elsif ( $op eq 'edit' ) {
+ upd_opac_new( $id, $title, $new, $lang, $expirationdate, $displayed );
+ print $cgi->redirect("/cgi-bin/koha/tools/koha-news.pl");
+}
+elsif ( $op eq 'del' ) {
my @ids = $cgi->param('ids');
- del_opac_new(join ",", @ids);
- print $cgi->redirect('/cgi-bin/koha/tools/koha-news.pl');
+ del_opac_new( join ",", @ids );
+ print $cgi->redirect("/cgi-bin/koha/tools/koha-news.pl");
+}
-} else {
+else {
- my ($opac_news_count, $opac_news) = &get_opac_news(undef, $lang);
- $template->param($lang => 1);
- $template->param(opac_news => $opac_news);
- $template->param(opac_news_count => $opac_news_count);
+ my ( $opac_news_count, $opac_news ) = &get_opac_news( undef, $lang );
+ $template->param(
+ $lang => 1,
+ opac_news => $opac_news,
+ opac_news_count => $opac_news_count
+ );
}
output_html_with_http_headers $cgi, $cookie, $template->output;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Koha-cvs] koha C4/NewsChannels.pm koha-tmpl/intranet-tmpl... [rel_3_0],
Antoine Farnault <=