Lines 30-36
BEGIN {
Link Here
|
30 |
@ISA = qw(Exporter); |
30 |
@ISA = qw(Exporter); |
31 |
@EXPORT = qw( |
31 |
@EXPORT = qw( |
32 |
&GetNewsToDisplay |
32 |
&GetNewsToDisplay |
33 |
&add_opac_new &upd_opac_new |
33 |
&add_opac_new |
34 |
); |
34 |
); |
35 |
} |
35 |
} |
36 |
|
36 |
|
Lines 79-128
sub add_opac_new {
Link Here
|
79 |
return $retval; |
79 |
return $retval; |
80 |
} |
80 |
} |
81 |
|
81 |
|
82 |
=head2 upd_opac_new |
|
|
83 |
|
84 |
$retval = upd_opac_new($hashref); |
85 |
|
86 |
$hashref should contains all the fields found in opac_news, |
87 |
including idnew, since it is the key for the SQL UPDATE. |
88 |
|
89 |
=cut |
90 |
|
91 |
sub upd_opac_new { |
92 |
my ($href_entry) = @_; |
93 |
my $retval = 0; |
94 |
|
95 |
if ($href_entry) { |
96 |
$href_entry->{number} = 0 if $href_entry->{number} !~ /^\d+$/; |
97 |
# take the keys of hash entry and make a list, but... |
98 |
my @fields = keys %{$href_entry}; |
99 |
my @values; |
100 |
$#values = -1; |
101 |
my $field_string = q{}; |
102 |
foreach my $field_name (@fields) { |
103 |
# exclude idnew |
104 |
if ( $field_name ne 'idnew' ) { |
105 |
$field_string = $field_string . "$field_name = ?,"; |
106 |
push @values,$href_entry->{$field_name}; |
107 |
} |
108 |
} |
109 |
# put idnew at the end, so we know which record to update |
110 |
push @values,$href_entry->{'idnew'}; |
111 |
chop $field_string; # remove that excess , |
112 |
|
113 |
my $dbh = C4::Context->dbh; |
114 |
my $sth = $dbh->prepare("UPDATE opac_news SET $field_string WHERE idnew = ?;"); |
115 |
$sth->execute(@values); |
116 |
$retval = 1; |
117 |
} |
118 |
|
119 |
#Log news entry modification |
120 |
if (C4::Context->preference("NewsLog")) { |
121 |
logaction('NEWS', 'MODIFY' , undef, $href_entry->{lang} . ' | ' . $href_entry->{content}); |
122 |
} |
123 |
return $retval; |
124 |
} |
125 |
|
126 |
=head2 GetNewsToDisplay |
82 |
=head2 GetNewsToDisplay |
127 |
|
83 |
|
128 |
$news = &GetNewsToDisplay($lang,$branch); |
84 |
$news = &GetNewsToDisplay($lang,$branch); |