View | Details | Raw Unified | Return to bug 6772
Collapse All | Expand All

(-)a/C4/Recommendations.pm (+204 lines)
Line 0 Link Here
1
package C4::Recommendations;
2
3
# Copyright 2009,2011 Catalyst IT
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 with
17
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
18
# Suite 330, Boston, MA  02111-1307 USA
19
20
=head1 NAME
21
22
    C4::Recommendations - Koha module for producing reading recommendations
23
24
=head1 SYNOPSIS
25
26
    use C4::Recommendations;
27
28
    build_recommendations();
29
30
    my $recommended_books = get_recommendations($biblio);
31
32
=head1 DESCRIPTION
33
34
This looks at the issue history, and counts how many times each particular book
35
has been taken out by someone who also has taken out another particular book,
36
recording that as a hit for each pair.
37
38
For example, if 3 people have taken out book A and book B, then this is
39
recorded as three "hits" for that combination, and so it'll show as a
40
recommendation with that strength.
41
42
=head1 EXPORT
43
44
None by default, however C<build_recommendations> and C<get_recommendations>
45
can be imported optionally.
46
47
=head1 FUNCTIONS
48
49
=cut
50
51
use strict;
52
use warnings;
53
use C4::Context;
54
55
require Exporter;
56
57
our @ISA = qw(Exporter);
58
59
# Items to export into callers namespace by default. Note: do not export
60
# names by default without a very good reason. Use EXPORT_OK instead.
61
# Do not simply export all your public functions/methods/constants.
62
our @EXPORT_OK = qw(
63
    build_recommendations 
64
    get_recommendations
65
);
66
67
our $VERSION = '0.01';
68
69
=head2 build_recommendations
70
71
    build_recommendations
72
73
This runs through all the issues and generates the tables of recommendations.
74
Note that it'll likely take a long time to run, and put stress on the database,
75
so do it at a low peak time.
76
77
=cut
78
79
sub build_recommendations {
80
    my $dbh = C4::Context->dbh;
81
    $dbh->do("TRUNCATE recommendations");
82
    my $all_issues_query = qq/
83
SELECT biblio.biblionumber,borrowernumber 
84
FROM old_issues,biblio,items 
85
WHERE old_issues.itemnumber=items.itemnumber 
86
AND items.biblionumber=biblio.biblionumber
87
    /;
88
    my $all_issues_sth = $dbh->prepare($all_issues_query);
89
    my $borrower_issues_query = qq/
90
SELECT  biblio.biblionumber,borrowernumber 
91
FROM old_issues,biblio,items 
92
WHERE old_issues.itemnumber=items.itemnumber 
93
AND items.biblionumber=biblio.biblionumber 
94
AND old_issues.borrowernumber = ?
95
AND items.biblionumber > ?
96
    /;
97
    my $borrower_issues_sth = $dbh->prepare($borrower_issues_query);
98
    my $recommendations_select = $dbh->prepare(qq/
99
SELECT * FROM recommendations 
100
WHERE biblio_one = ? AND 
101
biblio_two = ?
102
    /);
103
    my $recommendations_update = $dbh->prepare(qq/
104
UPDATE recommendations 
105
SET hit_count = ? 
106
WHERE biblio_one = ? 
107
AND biblio_two = ?
108
    /);
109
    my $recommendations_insert = $dbh->prepare(qq/
110
INSERT INTO recommendations (biblio_one,biblio_two,hit_count) VALUES (?,?,?)
111
    /);
112
113
    $all_issues_sth->execute();
114
    while ( my $issue = $all_issues_sth->fetchrow_hashref() ) {
115
#	warn $issue->{'borrowernumber'};
116
        $borrower_issues_sth->execute( $issue->{'borrowernumber'}, $issue->{biblionumber} );
117
        while ( my $borrowers_issue = $borrower_issues_sth->fetchrow_hashref() ) {
118
#	    warn $borrowers_issue->{'biblionumber'};
119
            $recommendations_select->execute( $issue->{'biblionumber'},
120
                $borrowers_issue->{'biblionumber'} );
121
            if ( my $recommendation = $recommendations_select->fetchrow_hashref() ) {
122
                $recommendation->{'hit_count'}++;
123
                $recommendations_update->execute(
124
                    $recommendation->{'hit_count'},
125
                    $issue->{'biblionumber'},
126
                    $borrowers_issue->{'biblionumber'}
127
                );
128
            } else {
129
                $recommendations_insert->execute(
130
                    $issue->{'biblionumber'},
131
                    $borrowers_issue->{'biblionumber'},
132
		            1
133
                );
134
            }
135
        }
136
137
    }
138
}
139
140
=head2 get_recommendations
141
142
    my $recommendations = get_recommendations($biblionumber, $limit)
143
    foreach my $rec (@$recommendations) {
144
    	print $rec->{biblionumber}.": ".$rec->{title}."\n";
145
    }
146
147
This gets the recommendations for a particular biblio, returning an array of
148
hashes containing C<biblionumber> and C<title>. The array is ordered from
149
most-recommended to least.
150
151
C<$limit> restrictes the amount of results returned. If it's not supplied,
152
it defaults to 100.
153
154
=cut
155
156
sub get_recommendations {
157
    my ($biblionumber, $limit) = @_;
158
    $limit ||= 100;
159
160
    my $dbh = C4::Context->dbh();
161
162
    # Two parts: first get the biblio_one side, then get the 
163
    # biblio_two side. I'd love to know how to squish this into one query.
164
    my $sth = $dbh->prepare(qq/
165
SELECT biblio.biblionumber,biblio.title, hit_count
166
FROM biblio,recommendations 
167
WHERE biblio.biblionumber = biblio_two
168
AND biblio_one = ?
169
ORDER BY hit_count DESC
170
LIMIT ?
171
    /);
172
    $sth->execute($biblionumber, $limit);
173
    my $res = $sth->fetchall_arrayref({});
174
175
    $sth = $dbh->prepare(qq/
176
SELECT biblio.biblionumber,biblio.title, hit_count
177
FROM biblio,recommendations 
178
WHERE biblio.biblionumber = biblio_one
179
AND biblio_two = ?
180
ORDER BY hit_count DESC
181
LIMIT ?
182
    /);
183
    $sth->execute($biblionumber, $limit);
184
    push @{ $res }, @{$sth->fetchall_arrayref({})};
185
186
    $res = \@{ @{$res}[0..$limit] } if (@$res > $limit);
187
188
    my @res = sort { $b->{hit_count} <=> $a->{hit_count} } @$res;
189
    return \@res;
190
}
191
192
1;
193
__END__
194
195
=head1 AUTHOR
196
197
=over
198
199
=item Chris Cormack, E<lt>chrisc@catalyst.net.nzE<gt>
200
201
=item Robin Sheat, E<lt>robin@catalyst.net.nzE<gt>
202
203
=back
204
(-)a/debian/koha-common.cron.daily (+4 lines)
Lines 23-25 koha-foreach --enabled /usr/share/koha/bin/cronjobs/services_throttle.pl > /dev/ Link Here
23
koha-foreach --enabled /usr/share/koha/bin/cronjobs/cleanup_database.pl --sessions --zebraqueue 10
23
koha-foreach --enabled /usr/share/koha/bin/cronjobs/cleanup_database.pl --sessions --zebraqueue 10
24
koha-foreach --enabled --noemail /usr/share/koha/bin/cronjobs/cleanup_database.pl --mail
24
koha-foreach --enabled --noemail /usr/share/koha/bin/cronjobs/cleanup_database.pl --mail
25
koha-run-backups --days 2 --output /var/spool/koha
25
koha-run-backups --days 2 --output /var/spool/koha
26
27
# If recommendations are enabled, this may take a while to run. However, it'll
28
# stop pretty much immediately if it doesn't need to do anything.
29
koha-foreach --enabled /usr/share/koha/bin/cronjobs/recommendations.pl
(-)a/installer/data/mysql/de-DE/mandatory/sysprefs.sql (-1 / +1 lines)
Lines 317-320 INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ( Link Here
317
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('BasketConfirmations', '1', 'When closing or reopening a basket,', 'always ask for confirmation.|do not ask for confirmation.', 'Choice');
317
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('BasketConfirmations', '1', 'When closing or reopening a basket,', 'always ask for confirmation.|do not ask for confirmation.', 'Choice');
318
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('MARCAuthorityControlField008', '|| aca||aabn           | a|a     d', NULL, NULL, 'Textarea');
318
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('MARCAuthorityControlField008', '|| aca||aabn           | a|a     d', NULL, NULL, 'Textarea');
319
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpenLibraryCovers',0, 'If ON Openlibrary book covers will be show',NULL,'YesNo');
319
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpenLibraryCovers',0, 'If ON Openlibrary book covers will be show',NULL,'YesNo');
320
320
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('ShowRecommendations',0,'If ON recommendation information will be generated and displayed',NULL,'YesNo');
(-)a/installer/data/mysql/en/mandatory/sysprefs.sql (+1 lines)
Lines 317-319 INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ( Link Here
317
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('BasketConfirmations', '1', 'When closing or reopening a basket,', 'always ask for confirmation.|do not ask for confirmation.', 'Choice');
317
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('BasketConfirmations', '1', 'When closing or reopening a basket,', 'always ask for confirmation.|do not ask for confirmation.', 'Choice');
318
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('MARCAuthorityControlField008', '|| aca||aabn           | a|a     d', NULL, NULL, 'Textarea');
318
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('MARCAuthorityControlField008', '|| aca||aabn           | a|a     d', NULL, NULL, 'Textarea');
319
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpenLibraryCovers',0,'If ON Openlibrary book covers will be show',NULL,'YesNo');
319
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpenLibraryCovers',0,'If ON Openlibrary book covers will be show',NULL,'YesNo');
320
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('ShowRecommendations',0,'If ON recommendation information will be generated and displayed',NULL,'YesNo');
(-)a/installer/data/mysql/fr-FR/1-Obligatoire/unimarc_standard_systemprefs.sql (+1 lines)
Lines 318-321 INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ( Link Here
318
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('BasketConfirmations', '1', 'When closing or reopening a basket,', 'always ask for confirmation.|do not ask for confirmation.', 'Choice');
318
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('BasketConfirmations', '1', 'When closing or reopening a basket,', 'always ask for confirmation.|do not ask for confirmation.', 'Choice');
319
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('MARCAuthorityControlField008', '|| aca||aabn           | a|a     d', NULL, NULL, 'Textarea');
319
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('MARCAuthorityControlField008', '|| aca||aabn           | a|a     d', NULL, NULL, 'Textarea');
320
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpenLibraryCovers',0,'If ON Openlibrary book covers will be show',NULL,'YesNo');
320
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpenLibraryCovers',0,'If ON Openlibrary book covers will be show',NULL,'YesNo');
321
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('ShowRecommendations',0,'If ON recommendation information will be generated and displayed',NULL,'YesNo');
321
322
(-)a/installer/data/mysql/it-IT/necessari/sysprefs.sql (+1 lines)
Lines 304-307 INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ( Link Here
304
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('BasketConfirmations', '1', 'When closing or reopening a basket,', 'always ask for confirmation.|do not ask for confirmation.', 'Choice');
304
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('BasketConfirmations', '1', 'When closing or reopening a basket,', 'always ask for confirmation.|do not ask for confirmation.', 'Choice');
305
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('MARCAuthorityControlField008', '|| aca||aabn           | a|a     d', NULL, NULL, 'Textarea');
305
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('MARCAuthorityControlField008', '|| aca||aabn           | a|a     d', NULL, NULL, 'Textarea');
306
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpenLibraryCovers',0,'If ON Openlibrary book covers will be show',NULL,'YesNo');
306
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpenLibraryCovers',0,'If ON Openlibrary book covers will be show',NULL,'YesNo');
307
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('ShowRecommendations',0,'If ON recommendation information will be generated and displayed',NULL,'YesNo');
307
308
(-)a/installer/data/mysql/kohastructure.sql (+11 lines)
Lines 2612-2617 CREATE TABLE `fieldmapping` ( Link Here
2612
  PRIMARY KEY  (`id`)
2612
  PRIMARY KEY  (`id`)
2613
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2613
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2614
2614
2615
DROP TABLE IF EXISTS `recommendations`;
2616
CREATE TABLE `recommendations` (
2617
  `id` int(11) NOT NULL auto_increment,
2618
  `biblio_one` int(11),
2619
  `biblio_two` int(11),
2620
  `hit_count` int(11),
2621
  PRIMARY KEY  (`id`),
2622
  KEY `biblio_one_idx` (`biblio_one`),
2623
  KEY `biblio_two_idx` (`biblio_two`)
2624
) ENGINE=InnoDB DEFAULT CHARSET=utf8; 
2625
2615
2626
2616
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
2627
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
2617
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
2628
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
(-)a/installer/data/mysql/nb-NO/1-Obligatorisk/sysprefs.sql (+1 lines)
Lines 324-326 INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ( Link Here
324
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('BasketConfirmations', '1', 'When closing or reopening a basket,', 'always ask for confirmation.|do not ask for confirmation.', 'Choice');
324
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('BasketConfirmations', '1', 'When closing or reopening a basket,', 'always ask for confirmation.|do not ask for confirmation.', 'Choice');
325
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('MARCAuthorityControlField008', '|| aca||aabn           | a|a     d', NULL, NULL, 'Textarea');
325
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('MARCAuthorityControlField008', '|| aca||aabn           | a|a     d', NULL, NULL, 'Textarea');
326
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpenLibraryCovers',0,'If ON Openlibrary book covers will be show',NULL,'YesNo');
326
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpenLibraryCovers',0,'If ON Openlibrary book covers will be show',NULL,'YesNo');
327
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('ShowRecommendations',0,'If ON recommendation information will be generated and displayed',NULL,'YesNo');
(-)a/installer/data/mysql/pl-PL/mandatory/sysprefs.sql (+1 lines)
Lines 316-318 INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ( Link Here
316
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('BasketConfirmations', '1', 'When closing or reopening a basket,', 'always ask for confirmation.|do not ask for confirmation.', 'Choice');
316
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('BasketConfirmations', '1', 'When closing or reopening a basket,', 'always ask for confirmation.|do not ask for confirmation.', 'Choice');
317
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('MARCAuthorityControlField008', '|| aca||aabn           | a|a     d', NULL, NULL, 'Textarea');
317
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('MARCAuthorityControlField008', '|| aca||aabn           | a|a     d', NULL, NULL, 'Textarea');
318
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpenLibraryCovers',0, 'If ON Openlibrary book covers will be show',NULL,'YesNo');
318
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpenLibraryCovers',0, 'If ON Openlibrary book covers will be show',NULL,'YesNo');
319
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('ShowRecommendations',0,'If ON recommendation information will be generated and displayed',NULL,'YesNo');
(-)a/installer/data/mysql/ru-RU/mandatory/system_preferences_full_optimal_for_install_only.sql (+1 lines)
Lines 371-373 INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ( Link Here
371
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('BasketConfirmations', '1', 'When closing or reopening a basket,', 'always ask for confirmation.|do not ask for confirmation.', 'Choice');
371
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('BasketConfirmations', '1', 'When closing or reopening a basket,', 'always ask for confirmation.|do not ask for confirmation.', 'Choice');
372
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('MARCAuthorityControlField008', '|| aca||aabn           | a|a     d', NULL, NULL, 'Textarea');
372
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('MARCAuthorityControlField008', '|| aca||aabn           | a|a     d', NULL, NULL, 'Textarea');
373
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpenLibraryCovers',0,'If ON Openlibrary book covers will be show',NULL,'YesNo');
373
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpenLibraryCovers',0,'If ON Openlibrary book covers will be show',NULL,'YesNo');
374
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('ShowRecommendations',0,'If ON recommendation information will be generated and displayed',NULL,'YesNo');
(-)a/installer/data/mysql/uk-UA/mandatory/system_preferences_full_optimal_for_install_only.sql (+1 lines)
Lines 396-399 INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ( Link Here
396
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('BasketConfirmations', '1', 'When closing or reopening a basket,', 'always ask for confirmation.|do not ask for confirmation.', 'Choice');
396
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('BasketConfirmations', '1', 'When closing or reopening a basket,', 'always ask for confirmation.|do not ask for confirmation.', 'Choice');
397
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('MARCAuthorityControlField008', '|| aca||aabn           | a|a     d', NULL, NULL, 'Textarea');
397
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('MARCAuthorityControlField008', '|| aca||aabn           | a|a     d', NULL, NULL, 'Textarea');
398
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpenLibraryCovers',0, 'If ON Openlibrary book covers will be show',NULL,'YesNo');
398
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpenLibraryCovers',0, 'If ON Openlibrary book covers will be show',NULL,'YesNo');
399
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('ShowRecommendations',0,'If ON recommendation information will be generated and displayed',NULL,'YesNo');
399
400
(-)a/installer/data/mysql/updatedatabase.pl (+17 lines)
Lines 4432-4437 if (C4::Context->preference("Version") < TransformToNum($DBversion)) { Link Here
4432
    SetVersion ($DBversion);
4432
    SetVersion ($DBversion);
4433
}
4433
}
4434
4434
4435
$DBversion = "xxx";
4436
if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4437
    $dbh->do(qq/
4438
        CREATE TABLE `recommendations` (
4439
          `id` int(11) NOT NULL auto_increment,
4440
          `biblio_one` int(11),
4441
          `biblio_two` int(11),
4442
          `hit_count` int(11),
4443
          PRIMARY KEY  (`id`),
4444
          KEY `biblio_one_idx` (`biblio_one`),
4445
          KEY `biblio_two_idx` (`biblio_two`)
4446
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8
4447
    qq/);
4448
    $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('ShowRecommendations',0,'If ON recommendation information will be generated and displayed',NULL,'YesNo');");
4449
    print "Add table and syspref track the recommended reading data.\n";
4450
    SetVersion($DBversion);
4451
}
4435
=head1 FUNCTIONS
4452
=head1 FUNCTIONS
4436
4453
4437
=head2 DropAllForeignKeys($table)
4454
=head2 DropAllForeignKeys($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref (+6 lines)
Lines 268-273 OPAC: Link Here
268
            - pref: numSearchRSSResults
268
            - pref: numSearchRSSResults
269
              class: long
269
              class: long
270
            -  search results in the RSS feed.
270
            -  search results in the RSS feed.
271
        -
272
            - pref: ShowRecommendations
273
              choices:
274
                  yes: Do
275
                  no: "Don't"
276
            - "generate and display reading recommendations in the OPAC. <i>(Notes: this requires the <tt>recommendations.pl</tt> cron job to be configured to run regularly. This cron job will take a long time to run on catalogs with a sizable circulation history.)</i>"
271
    Policy:
277
    Policy:
272
        -
278
        -
273
            - pref: singleBranchMode
279
            - pref: singleBranchMode
(-)a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt (+11 lines)
Lines 363-368 YAHOO.util.Event.onContentReady("furtherm", function () { Link Here
363
    [% IF ( OPACFRBRizeEditions ) %][% IF ( XISBNS ) %]<li><a href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% biblionumber %]#editions">Editions</a></li>[% END %][% END %]
363
    [% IF ( OPACFRBRizeEditions ) %][% IF ( XISBNS ) %]<li><a href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% biblionumber %]#editions">Editions</a></li>[% END %][% END %]
364
    
364
    
365
    [% IF ( OPACAmazonEnabled ) %][% IF ( OPACAmazonReviews ) %]<li><a href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% biblionumber %]#amazonreviews">Amazon Reviews</a></li>[% END %][% END %]
365
    [% IF ( OPACAmazonEnabled ) %][% IF ( OPACAmazonReviews ) %]<li><a href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% biblionumber %]#amazonreviews">Amazon Reviews</a></li>[% END %][% END %]
366
    [% IF ( Recommendations ) %]<li><a href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% biblionumber %]#recommendations">Recommendations</a></li>[% END %]
366
    [% IF ( Babeltheque ) %]<li><a href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% biblionumber %]#babeltheque">Babelthèque</a></li>[% END %]
367
    [% IF ( Babeltheque ) %]<li><a href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% biblionumber %]#babeltheque">Babelthèque</a></li>[% END %]
367
368
368
    [% IF ( serialcollection ) %]
369
    [% IF ( serialcollection ) %]
Lines 728-733 YAHOO.util.Event.onContentReady("furtherm", function () { Link Here
728
</div>
729
</div>
729
[% END %]
730
[% END %]
730
731
732
[% IF (Recommendations) %]
733
<div id="recommendations">
734
<table>
735
[% FOREACH recommendation IN recommendation_loop %]
736
<tr><td><a href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% recommendation.biblionumber %]">[% recommendation.title | html %]</a></td></tr>
737
[% END %]
738
</table>
739
</div>
740
[% END %]
741
731
[% IF ( OPACFRBRizeEditions ) %][% IF ( XISBNS ) %]
742
[% IF ( OPACFRBRizeEditions ) %][% IF ( XISBNS ) %]
732
<div id="editions">
743
<div id="editions">
733
744
(-)a/misc/cronjobs/recommendations.pl (+53 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2009,2011 Catalyst IT Ltd.
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 with
17
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
18
# Suite 330, Boston, MA  02111-1307 USA
19
20
=head1 NAME
21
22
recommendations.pl - cron script to populate the recommendations table
23
24
=head1 SYNOPSIS
25
26
./recommendations.pl
27
28
or, in crontab:
29
0 1 * * * recommendations.pl
30
31
=head1 DESCRIPTION
32
33
=cut
34
35
use strict;
36
use warnings;
37
BEGIN {
38
    # find Koha's Perl modules
39
    # test carefully before changing this
40
    use FindBin;
41
    eval { require "$FindBin::Bin/../kohalib.pl" };
42
}
43
44
use C4::Context;
45
use C4::Recommendations qw/ build_recommendations /;
46
47
if (C4::Context->preference('ShowRecommendations')) {
48
    build_recommendations();
49
}
50
51
1;
52
53
__END__
(-)a/opac/opac-detail.pl (-1 / +8 lines)
Lines 42-47 use C4::VirtualShelves; Link Here
42
use C4::XSLT;
42
use C4::XSLT;
43
use C4::ShelfBrowser;
43
use C4::ShelfBrowser;
44
use C4::Charset;
44
use C4::Charset;
45
use C4::Recommendations qw/ get_recommendations /;
45
use MARC::Record;
46
use MARC::Record;
46
use MARC::Field;
47
use MARC::Field;
47
use List::MoreUtils qw/any none/;
48
use List::MoreUtils qw/any none/;
Lines 66-71 my ( $template, $borrowernumber, $cookie ) = get_template_and_user( Link Here
66
67
67
my $biblionumber = $query->param('biblionumber') || $query->param('bib');
68
my $biblionumber = $query->param('biblionumber') || $query->param('bib');
68
69
70
if ( C4::Context->preference('ShowRecommendations')){
71
    my $recommendations = get_recommendations($biblionumber);
72
    $template->param('Recommendations' => 1,
73
	'recommendation_loop' => $recommendations
74
	);
75
}
76
69
$template->param( 'AllowOnShelfHolds' => C4::Context->preference('AllowOnShelfHolds') );
77
$template->param( 'AllowOnShelfHolds' => C4::Context->preference('AllowOnShelfHolds') );
70
$template->param( 'ItemsIssued' => CountItemsIssued( $biblionumber ) );
78
$template->param( 'ItemsIssued' => CountItemsIssued( $biblionumber ) );
71
79
72
- 

Return to bug 6772