← Index
NYTProf Performance Profile   « block view • line view • sub view »
For /usr/share/koha/opac/cgi-bin/opac/opac-search.pl
  Run on Tue Oct 15 17:10:45 2013
Reported on Tue Oct 15 17:12:02 2013

Filename/usr/share/koha/lib/C4/NewsChannels.pm
StatementsExecuted 19 statements in 815µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11122µs30µsC4::NewsChannels::::BEGIN@20C4::NewsChannels::BEGIN@20
11119µs43µsC4::NewsChannels::::BEGIN@21C4::NewsChannels::BEGIN@21
11117µs17µsC4::NewsChannels::::BEGIN@28C4::NewsChannels::BEGIN@28
11116µs21µsC4::NewsChannels::::BEGIN@23C4::NewsChannels::BEGIN@23
11112µs50µsC4::NewsChannels::::BEGIN@24C4::NewsChannels::BEGIN@24
11111µs72µsC4::NewsChannels::::BEGIN@26C4::NewsChannels::BEGIN@26
0000s0sC4::NewsChannels::::GetNewsToDisplayC4::NewsChannels::GetNewsToDisplay
0000s0sC4::NewsChannels::::add_opac_newC4::NewsChannels::add_opac_new
0000s0sC4::NewsChannels::::del_opac_newC4::NewsChannels::del_opac_new
0000s0sC4::NewsChannels::::get_opac_newC4::NewsChannels::get_opac_new
0000s0sC4::NewsChannels::::get_opac_newsC4::NewsChannels::get_opac_news
0000s0sC4::NewsChannels::::upd_opac_newC4::NewsChannels::upd_opac_new
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package C4::NewsChannels;
2
3# Copyright 2000-2002 Katipo Communications
4#
5# This file is part of Koha.
6#
7# Koha is free software; you can redistribute it and/or modify it under the
8# terms of the GNU General Public License as published by the Free Software
9# Foundation; either version 2 of the License, or (at your option) any later
10# version.
11#
12# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License along
17# with Koha; if not, write to the Free Software Foundation, Inc.,
18# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20334µs236µs
# spent 30µs (22+7) within C4::NewsChannels::BEGIN@20 which was called: # once (22µs+7µs) by C4::Members::BEGIN@38 at line 20
use strict;
# spent 30µs making 1 call to C4::NewsChannels::BEGIN@20 # spent 7µs making 1 call to strict::import
21334µs267µs
# spent 43µs (19+24) within C4::NewsChannels::BEGIN@21 which was called: # once (19µs+24µs) by C4::Members::BEGIN@38 at line 21
use warnings;
# spent 43µs making 1 call to C4::NewsChannels::BEGIN@21 # spent 24µs making 1 call to warnings::import
22
23334µs225µs
# spent 21µs (16+4) within C4::NewsChannels::BEGIN@23 which was called: # once (16µs+4µs) by C4::Members::BEGIN@38 at line 23
use C4::Context;
# spent 21µs making 1 call to C4::NewsChannels::BEGIN@23 # spent 4µs making 1 call to C4::Context::import
24335µs287µs
# spent 50µs (12+38) within C4::NewsChannels::BEGIN@24 which was called: # once (12µs+38µs) by C4::Members::BEGIN@38 at line 24
use C4::Dates qw(format_date);
# spent 50µs making 1 call to C4::NewsChannels::BEGIN@24 # spent 38µs making 1 call to Exporter::import
25
26373µs2133µs
# spent 72µs (11+61) within C4::NewsChannels::BEGIN@26 which was called: # once (11µs+61µs) by C4::Members::BEGIN@38 at line 26
use vars qw($VERSION @ISA @EXPORT);
# spent 72µs making 1 call to C4::NewsChannels::BEGIN@26 # spent 61µs making 1 call to vars::import
27
28
# spent 17µs within C4::NewsChannels::BEGIN@28 which was called: # once (17µs+0s) by C4::Members::BEGIN@38 at line 35
BEGIN {
29318µs $VERSION = 3.07.00.049; # set the version for version checking
30 @ISA = qw(Exporter);
31 @EXPORT = qw(
32 &GetNewsToDisplay
33 &add_opac_new &upd_opac_new &del_opac_new &get_opac_new &get_opac_news
34 );
351584µs117µs}
# spent 17µs making 1 call to C4::NewsChannels::BEGIN@28
36
37=head1 NAME
38
- -
49sub add_opac_new {
50 my ($title, $new, $lang, $expirationdate, $timestamp, $number) = @_;
51 my $dbh = C4::Context->dbh;
52 my $sth = $dbh->prepare("INSERT INTO opac_news (title, new, lang, expirationdate, timestamp, number) VALUES (?,?,?,?,?,?)");
53 $sth->execute($title, $new, $lang, $expirationdate, $timestamp, $number);
54 $sth->finish;
55 return 1;
56}
57
58sub upd_opac_new {
59 my ($idnew, $title, $new, $lang, $expirationdate, $timestamp,$number) = @_;
60 my $dbh = C4::Context->dbh;
61 my $sth = $dbh->prepare("
62 UPDATE opac_news SET
63 title = ?,
64 new = ?,
65 lang = ?,
66 expirationdate = ?,
67 timestamp = ?,
68 number = ?
69 WHERE idnew = ?
70 ");
71 $sth->execute($title, $new, $lang, $expirationdate, $timestamp,$number,$idnew);
72 $sth->finish;
73 return 1;
74}
75
76sub del_opac_new {
77 my ($ids) = @_;
78 if ($ids) {
79 my $dbh = C4::Context->dbh;
80 my $sth = $dbh->prepare("DELETE FROM opac_news WHERE idnew IN ($ids)");
81 $sth->execute();
82 $sth->finish;
83 return 1;
84 } else {
85 return 0;
86 }
87}
88
89sub get_opac_new {
90 my ($idnew) = @_;
91 my $dbh = C4::Context->dbh;
92 my $sth = $dbh->prepare("SELECT * FROM opac_news WHERE idnew = ?");
93 $sth->execute($idnew);
94 my $data = $sth->fetchrow_hashref;
95 $data->{$data->{'lang'}} = 1 if defined $data->{lang};
96 $data->{expirationdate} = format_date($data->{expirationdate});
97 $data->{timestamp} = format_date($data->{timestamp});
98 $sth->finish;
99 return $data;
100}
101
102sub get_opac_news {
103 my ($limit, $lang) = @_;
104 my $dbh = C4::Context->dbh;
105 my $query = "SELECT *, timestamp AS newdate FROM opac_news";
106 if ($lang) {
107 $query.= " WHERE lang = '" .$lang ."' ";
108 }
109 $query.= " ORDER BY timestamp DESC ";
110 #if ($limit) {
111 # $query.= "LIMIT 0, " . $limit;
112 #}
113 my $sth = $dbh->prepare($query);
114 $sth->execute();
115 my @opac_news;
116 my $count = 0;
117 while (my $row = $sth->fetchrow_hashref) {
118 if ((($limit) && ($count < $limit)) || (!$limit)) {
119 $row->{'newdate'} = format_date($row->{'newdate'});
120 $row->{'expirationdate'} = format_date($row->{'expirationdate'});
121 push @opac_news, $row;
122 }
123 $count++;
124 }
125 return ($count, \@opac_news);
126}
127
128=head2 GetNewsToDisplay
129
- -
136sub GetNewsToDisplay {
137 my $lang = shift;
138 my $dbh = C4::Context->dbh;
139 # SELECT *,DATE_FORMAT(timestamp, '%d/%m/%Y') AS newdate
140 my $query = "
141 SELECT *,timestamp AS newdate
142 FROM opac_news
143 WHERE (
144 expirationdate >= CURRENT_DATE()
145 OR expirationdate IS NULL
146 OR expirationdate = '00-00-0000'
147 )
148 AND `timestamp` <= CURRENT_DATE()
149 AND lang = ?
150 ORDER BY number
151 "; # expirationdate field is NOT in ISO format?
152 my $sth = $dbh->prepare($query);
153 $sth->execute($lang);
154 my @results;
155 while ( my $row = $sth->fetchrow_hashref ){
156 $row->{newdate} = format_date($row->{newdate});
157 push @results, $row;
158 }
159 return \@results;
160}
161
16213µs1;
163__END__