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

(-)a/C4/Auth.pm (-2 / +4 lines)
Lines 347-352 sub get_template_and_user { Link Here
347
            LoginFirstname               => (C4::Context->userenv?C4::Context->userenv->{"firstname"}:"Bel"),
347
            LoginFirstname               => (C4::Context->userenv?C4::Context->userenv->{"firstname"}:"Bel"),
348
            LoginSurname                 => C4::Context->userenv?C4::Context->userenv->{"surname"}:"Inconnu",
348
            LoginSurname                 => C4::Context->userenv?C4::Context->userenv->{"surname"}:"Inconnu",
349
            TagsEnabled                  => C4::Context->preference("TagsEnabled"),
349
            TagsEnabled                  => C4::Context->preference("TagsEnabled"),
350
            RatingsEnabled               => C4::Context->preference("RatingsEnabled"),
350
            hide_marc                    => C4::Context->preference("hide_marc"),
351
            hide_marc                    => C4::Context->preference("hide_marc"),
351
            item_level_itypes            => C4::Context->preference('item-level_itypes'),
352
            item_level_itypes            => C4::Context->preference('item-level_itypes'),
352
            patronimages                 => C4::Context->preference("patronimages"),
353
            patronimages                 => C4::Context->preference("patronimages"),
Lines 975-983 sub checkauth { Link Here
975
        OpacAuthorities      => C4::Context->preference("OpacAuthorities"),
976
        OpacAuthorities      => C4::Context->preference("OpacAuthorities"),
976
        OpacBrowser          => C4::Context->preference("OpacBrowser"),
977
        OpacBrowser          => C4::Context->preference("OpacBrowser"),
977
        opacheader           => C4::Context->preference("opacheader"),
978
        opacheader           => C4::Context->preference("opacheader"),
978
        TagsEnabled                  => C4::Context->preference("TagsEnabled"),
979
        OPACUserCSS           => C4::Context->preference("OPACUserCSS"),
980
        opacstylesheet       => C4::Context->preference("opacstylesheet"),
979
        opacstylesheet       => C4::Context->preference("opacstylesheet"),
980
        TagsEnabled          => C4::Context->preference("TagsEnabled"),
981
        RatingsEnabled       => C4::Context->preference("RatingsEnabled"),
982
        OPACUserCSS          => C4::Context->preference("OPACUserCSS"),
981
        intranetcolorstylesheet =>
983
        intranetcolorstylesheet =>
982
								C4::Context->preference("intranetcolorstylesheet"),
984
								C4::Context->preference("intranetcolorstylesheet"),
983
        intranetstylesheet => C4::Context->preference("intranetstylesheet"),
985
        intranetstylesheet => C4::Context->preference("intranetstylesheet"),
(-)a/C4/Output.pm (-3 / +15 lines)
Lines 44-58 BEGIN { Link Here
44
    @ISA    = qw(Exporter);
44
    @ISA    = qw(Exporter);
45
	@EXPORT_OK = qw(&is_ajax ajax_fail); # More stuff should go here instead
45
	@EXPORT_OK = qw(&is_ajax ajax_fail); # More stuff should go here instead
46
	%EXPORT_TAGS = ( all =>[qw(&themelanguage &gettemplate setlanguagecookie pagination_bar
46
	%EXPORT_TAGS = ( all =>[qw(&themelanguage &gettemplate setlanguagecookie pagination_bar
47
								&output_with_http_headers &output_html_with_http_headers)],
47
								&output_with_http_headers &output_ajax_with_http_headers &output_html_with_http_headers)],
48
					ajax =>[qw(&output_with_http_headers is_ajax)],
48
					ajax =>[qw(&output_with_http_headers &output_ajax_with_http_headers is_ajax)],
49
					html =>[qw(&output_with_http_headers &output_html_with_http_headers)]
49
					html =>[qw(&output_with_http_headers &output_html_with_http_headers)]
50
				);
50
				);
51
    push @EXPORT, qw(
51
    push @EXPORT, qw(
52
        &themelanguage &gettemplate setlanguagecookie getlanguagecookie pagination_bar
52
        &themelanguage &gettemplate setlanguagecookie getlanguagecookie pagination_bar
53
    );
53
    );
54
    push @EXPORT, qw(
54
    push @EXPORT, qw(
55
        &output_html_with_http_headers &output_with_http_headers FormatData FormatNumber
55
        &output_html_with_http_headers &output_ajax_with_http_headers &output_with_http_headers FormatData FormatNumber
56
    );
56
    );
57
}
57
}
58
58
Lines 478-483 sub output_html_with_http_headers ($$$;$) { Link Here
478
    output_with_http_headers( $query, $cookie, $data, 'html', $status );
478
    output_with_http_headers( $query, $cookie, $data, 'html', $status );
479
}
479
}
480
480
481
482
sub output_ajax_with_http_headers ($$) {
483
    my ( $query, $js ) = @_;
484
    print $query->header(
485
        -type            => 'text/javascript',
486
        -charset         => 'UTF-8',
487
        -Pragma          => 'no-cache',
488
        -'Cache-Control' => 'no-cache',
489
        -expires         => '-1d',
490
    ), $js;
491
}
492
481
sub is_ajax () {
493
sub is_ajax () {
482
    my $x_req = $ENV{HTTP_X_REQUESTED_WITH};
494
    my $x_req = $ENV{HTTP_X_REQUESTED_WITH};
483
    return ( $x_req and $x_req =~ /XMLHttpRequest/i ) ? 1 : 0;
495
    return ( $x_req and $x_req =~ /XMLHttpRequest/i ) ? 1 : 0;
(-)a/C4/Ratings.pm (+145 lines)
Line 0 Link Here
1
package C4::Ratings;
2
3
# Copyright 2010 KohaAloha, NZ
4
# Parts copyright 2011, Catalyst IT, NZ.
5
#
6
# This file is part of Koha.
7
#
8
# Koha is free software; you can redistribute it and/or modify it under the
9
# terms of the GNU General Public License as published by the Free Software
10
# Foundation; either version 2 of the License, or (at your option) any later
11
# version.
12
#
13
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
14
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License along
18
# with Koha; if not, write to the Free Software Foundation, Inc.,
19
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20
21
=head1 C4::Ratings - the Koha API for dealing with star ratings for biblios
22
23
This provides an interface to the ratings system, in order to allow them
24
to be manipulated or queried.
25
26
=cut
27
28
use strict;
29
use warnings;
30
use Carp;
31
use Exporter;
32
33
use C4::Debug;
34
use C4::Context;
35
36
#use Smart::Comments '####';
37
38
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
39
40
BEGIN {
41
    $VERSION = 3.00;
42
    @ISA     = qw(Exporter);
43
44
    @EXPORT = qw(
45
      get_rating add_rating
46
    );
47
48
    #	%EXPORT_TAGS = ();
49
}
50
51
=head2 get_rating
52
53
    get_rating($biblionumber, $borrowernumber)
54
55
This returns the rating for the supplied biblionumber. It will also return
56
the rating that the supplied user gave to the provided biblio. If a particular
57
value can't be supplied, '0' is returned for that value.
58
59
=head 3 RETURNS
60
61
A hashref containing:
62
63
=over
64
65
=item total - the total number of ratings
66
=item avg - the average of the ratings
67
=item avgint - the integer form of the average
68
=item value - the user's rating
69
70
=back
71
72
=cut
73
74
my ($total_query_sth, $user_query_sth);
75
sub get_rating {
76
    my ( $biblionumber, $borrowernumber ) = @_;
77
    my $dbh = C4::Context->dbh;
78
79
    my $total_query = "
80
	SELECT    AVG(value) AS average,COUNT(value) AS total  FROM ratings
81
    WHERE       biblionumber = ?";
82
    $total_query_sth = $total_query_sth || $dbh->prepare($total_query);
83
84
    $total_query_sth->execute($biblionumber);
85
    my $total_query_res = $total_query_sth->fetchrow_hashref();
86
87
    my $user_rating = 0;
88
    if ($borrowernumber) {
89
        my $user_query = "
90
        SELECT    value  from ratings
91
        WHERE       biblionumber = ? and borrowernumber = ?";
92
        $user_query_sth ||= $dbh->prepare($user_query);
93
94
        $user_query_sth->execute( $biblionumber, $borrowernumber );
95
        my $user_query_res = $user_query_sth->fetchrow_hashref();
96
        $user_rating = $user_query_res->{value} || 0;
97
    }
98
    my ( $avg, $avgint ) = 0;
99
    $avg = $total_query_res->{average} || 0;
100
    $avgint = sprintf( "%.0f", $avg );
101
102
    my %rating_hash;
103
    $rating_hash{total}  = $total_query_res->{total} || 0;
104
    $rating_hash{avg}    = $avg;
105
    $rating_hash{avgint} = $avgint;
106
    $rating_hash{value}  = $user_rating;
107
    return \%rating_hash;
108
}
109
110
=head2 add_rating
111
112
    add_rating($biblionumber, $borrowernumber, $value)
113
114
This adds or updates a rating for a particular user on a biblio. If the value
115
is 0, then the rating will be deleted. If the value is out of the range of
116
0-5, nothing will happen.
117
118
=cut
119
120
my ($delete_query_sth, $insert_query_sth);
121
sub add_rating {
122
    my ( $biblionumber, $borrowernumber, $value ) = @_;
123
    if (!defined($biblionumber) || !defined($borrowernumber) ||
124
        $value < 0 || $value > 5) {
125
        # Seen this happen, want to know about it if it happens again.
126
        carp "Invalid input coming in to C4::Ratings::add_rating";
127
        return;
128
    }
129
    if ($borrowernumber == 0) {
130
    	carp "Attempted to add a rating for borrower number 0";
131
    	return;
132
    }
133
    my $dbh = C4::Context->dbh;
134
    my $delete_query = "DELETE FROM ratings WHERE borrowernumber = ? AND biblionumber = ? LIMIT 1";
135
    my $delete_query_sth ||= $dbh->prepare($delete_query);
136
    $delete_query_sth->execute( $borrowernumber, $biblionumber );
137
    return if $value == 0; # We don't add a rating for zero
138
139
    my $insert_query = "INSERT INTO ratings (borrowernumber,biblionumber,value)
140
    VALUES (?,?,?)";
141
    $insert_query_sth ||= $dbh->prepare($insert_query);
142
    $insert_query_sth->execute( $borrowernumber, $biblionumber, $value );
143
}
144
145
1;
(-)a/installer/data/mysql/kohastructure.sql (+16 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
---
2616
--- 'Ratings' table. This tracks the star ratings set by borrowers.
2617
---
2618
2619
DROP TABLE IF EXISTS `ratings`;
2620
CREATE TABLE `ratings` (
2621
    `borrowernumber` int(11) NOT NULL, --- the borrower this rating is for
2622
    `biblionumber` int(11) NOT NULL, --- the biblio it's for
2623
    `value` tinyint(1) NOT NULL, --- the rating, from 1-5
2624
    `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP,
2625
    PRIMARY KEY  (`borrowernumber`,`biblionumber`),
2626
    KEY `ratings_borrowers_fk_1` (`borrowernumber`),
2627
    KEY `ratings_biblionumber_fk_1` (`biblionumber`)
2628
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2629
2630
2615
2631
2616
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
2632
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
2617
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
2633
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
(-)a/installer/data/mysql/updatedatabase.pl (+20 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 `ratings` (
4439
  `borrowernumber` int(11) NOT NULL,
4440
  `biblionumber` int(11) NOT NULL,
4441
  `value` tinyint(1) NOT NULL,
4442
  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP,
4443
  PRIMARY KEY  (`borrowernumber`,`biblionumber`),
4444
  KEY `ratings_borrowers_fk_1` (`borrowernumber`),
4445
  KEY `ratings_biblionumber_fk_1` (`biblionumber`)
4446
) ENGINE=InnoDB DEFAULT CHARSET=utf8 |  );
4447
4448
    $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('RatingsEnabled','','Enabled or disables ratings feature in the OPAC',NULL,'YesNo')");
4449
4450
    print "Upgrade to $DBversion done (Added 'ratings' table, and 'RatingsEnabled' syspref\n";
4451
    SetVersion ($DBversion);
4452
}
4453
4454
4435
=head1 FUNCTIONS
4455
=head1 FUNCTIONS
4436
4456
4437
=head2 DropAllForeignKeys($table)
4457
=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: RatingsEnabled
273
              choices:
274
                  yes: Show
275
                  no: "Don't show"
276
            - star ratings
271
    Policy:
277
    Policy:
272
        -
278
        -
273
            - pref: singleBranchMode
279
            - pref: singleBranchMode
(-)a/koha-tmpl/opac-tmpl/prog/en/css/jquery.rating.css (+12 lines)
Line 0 Link Here
1
/* jQuery.Rating Plugin CSS - http://www.fyneworks.com/jquery/star-rating/ */
2
div.rating-cancel,div.star-rating{float:left;width:15px;height:15px;text-indent:-999em;cursor:pointer;display:block;background:transparent;overflow:hidden}
3
div.rating-cancel,div.rating-cancel a{background:url(../../images/delete.gif) no-repeat 0 -16px}
4
div.star-rating,div.star-rating a{background:url(../../images/star.gif) no-repeat 0 0px}
5
div.rating-cancel a,div.star-rating a{display:block;width:16px;height:100%;background-position:0 0px;border:0}
6
div.star-rating-on a{background-position:0 -32px!important}
7
div.star-rating-hover a{background-position:0 -16px}
8
/* Read Only CSS */
9
div.star-rating-readonly a{cursor:default !important}
10
/* Partial Star CSS */
11
div.star-rating{background:transparent!important;overflow:hidden!important}
12
/* END jQuery.Rating Plugin CSS */
(-)a/koha-tmpl/opac-tmpl/prog/en/lib/jquery/plugins/jquery.rating.js (+344 lines)
Line 0 Link Here
1
/*
2
 ### jQuery Star Rating Plugin v3.10 - 2009-03-23 ###
3
 * Home: http://www.fyneworks.com/jquery/star-rating/
4
 * Code: http://code.google.com/p/jquery-star-rating-plugin/
5
 *
6
	* Dual licensed under the MIT and GPL licenses:
7
 *   http://www.opensource.org/licenses/mit-license.php
8
 *   http://www.gnu.org/licenses/gpl.html
9
 ###
10
*/
11
12
/*# AVOID COLLISIONS #*/
13
;if(window.jQuery) (function($){
14
/*# AVOID COLLISIONS #*/
15
	
16
	// IE6 Background Image Fix
17
	if ($.browser.msie) try { document.execCommand("BackgroundImageCache", false, true)} catch(e) { }
18
	// Thanks to http://www.visualjquery.com/rating/rating_redux.html
19
	
20
	// plugin initialization
21
	$.fn.rating = function(options){
22
		if(this.length==0) return this; // quick fail
23
		
24
		// Handle API methods
25
		if(typeof arguments[0]=='string'){
26
			// Perform API methods on individual elements
27
			if(this.length>1){
28
				var args = arguments;
29
				return this.each(function(){
30
					$.fn.rating.apply($(this), args);
31
    });
32
			};
33
			// Invoke API method handler
34
			$.fn.rating[arguments[0]].apply(this, $.makeArray(arguments).slice(1) || []);
35
			// Quick exit...
36
			return this;
37
		};
38
		
39
		// Initialize options for this call
40
		var options = $.extend(
41
			{}/* new object */,
42
			$.fn.rating.options/* default options */,
43
			options || {} /* just-in-time options */
44
		);
45
		
46
		// loop through each matched element
47
		this
48
		 .not('.star-rating-applied')
49
			.addClass('star-rating-applied')
50
		.each(function(){
51
			
52
			// Load control parameters / find context / etc
53
			var eid = (this.name || 'unnamed-rating').replace(/\[|\]+/g, "_");
54
			var context = $(this.form || document.body);
55
			var input = $(this);
56
			var raters = context.data('rating') || { count:0 };
57
			var rater = raters[eid];
58
			var control;
59
			
60
			// if rater is available, verify that the control still exists
61
			if(rater) control = rater.data('rating');
62
			
63
			if(rater && control){
64
				// add star to control if rater is available and the same control still exists
65
				control.count++;
66
				
67
			}
68
			else{
69
				// create new control if first star or control element was removed/replaced
70
				
71
				// Initialize options for this raters
72
				control = $.extend(
73
					{}/* new object */,
74
					options || {} /* current call options */,
75
					($.metadata? input.metadata(): ($.meta?input.data():null)) || {}, /* metadata options */
76
					{ count:0, stars: [], inputs: [] }
77
				);
78
				
79
				// increment number of rating controls
80
				control.serial = raters.count++;
81
				
82
				// create rating element
83
				rater = $('<span class="star-rating-control"/>');
84
				input.before(rater);
85
				
86
				// Mark element for initialization (once all stars are ready)
87
				rater.addClass('rating-to-be-drawn');
88
				
89
				// Accept readOnly setting from 'disabled' property
90
				if(input.attr('disabled')) control.readOnly = true;
91
				
92
				// Create 'cancel' button
93
				rater.append(
94
					control.cancel = $('<div class="rating-cancel"><a title="' + control.cancel + '">' + control.cancelValue + '</a></div>')
95
					.mouseover(function(){
96
						$(this).rating('drain');
97
						$(this).addClass('star-rating-hover');
98
						//$(this).rating('focus');
99
					})
100
					.mouseout(function(){
101
						$(this).rating('draw');
102
						$(this).removeClass('star-rating-hover');
103
						//$(this).rating('blur');
104
					})
105
					.click(function(){
106
					 $(this).rating('select');
107
					})
108
					.data('rating', control)
109
				);
110
				
111
			}; // first element of group
112
			
113
			// insert rating star
114
			var star = $('<div class="star-rating rater-'+ control.serial +'"><a title="' + (this.title || this.value) + '">' + this.value + '</a></div>');
115
			rater.append(star);
116
			
117
			// inherit attributes from input element
118
			if(this.id) star.attr('id', this.id);
119
			if(this.className) star.addClass(this.className);
120
			
121
			// Half-stars?
122
			if(control.half) control.split = 2;
123
			
124
			// Prepare division control
125
			if(typeof control.split=='number' && control.split>0){
126
				var stw = ($.fn.width ? star.width() : 0) || control.starWidth;
127
				var spi = (control.count % control.split), spw = Math.floor(stw/control.split);
128
				star
129
				// restrict star's width and hide overflow (already in CSS)
130
				.width(spw)
131
				// move the star left by using a negative margin
132
				// this is work-around to IE's stupid box model (position:relative doesn't work)
133
				.find('a').css({ 'margin-left':'-'+ (spi*spw) +'px' })
134
			};
135
			
136
			// readOnly?
137
			if(control.readOnly)//{ //save a byte!
138
				// Mark star as readOnly so user can customize display
139
				star.addClass('star-rating-readonly');
140
			//}  //save a byte!
141
			else//{ //save a byte!
142
			 // Enable hover css effects
143
				star.addClass('star-rating-live')
144
				 // Attach mouse events
145
					.mouseover(function(){
146
						$(this).rating('fill');
147
						$(this).rating('focus');
148
					})
149
					.mouseout(function(){
150
						$(this).rating('draw');
151
						$(this).rating('blur');
152
					})
153
					.click(function(){
154
						$(this).rating('select');
155
					})
156
				;
157
			//}; //save a byte!
158
			
159
			// set current selection
160
			if(this.checked)	control.current = star;
161
			
162
			// hide input element
163
			input.hide();
164
			
165
			// backward compatibility, form element to plugin
166
			input.change(function(){
167
    $(this).rating('select');
168
   });
169
			
170
			// attach reference to star to input element and vice-versa
171
			star.data('rating.input', input.data('rating.star', star));
172
			
173
			// store control information in form (or body when form not available)
174
			control.stars[control.stars.length] = star[0];
175
			control.inputs[control.inputs.length] = input[0];
176
			control.rater = raters[eid] = rater;
177
			control.context = context;
178
			
179
			input.data('rating', control);
180
			rater.data('rating', control);
181
			star.data('rating', control);
182
			context.data('rating', raters);
183
  }); // each element
184
		
185
		// Initialize ratings (first draw)
186
		$('.rating-to-be-drawn').rating('draw').removeClass('rating-to-be-drawn');
187
		
188
		return this; // don't break the chain...
189
	};
190
	
191
	/*--------------------------------------------------------*/
192
	
193
	/*
194
		### Core functionality and API ###
195
	*/
196
	$.extend($.fn.rating, {
197
		
198
		focus: function(){
199
			var control = this.data('rating'); if(!control) return this;
200
			if(!control.focus) return this; // quick fail if not required
201
			// find data for event
202
			var input = $(this).data('rating.input') || $( this.tagName=='INPUT' ? this : null );
203
   // focus handler, as requested by focusdigital.co.uk
204
			if(control.focus) control.focus.apply(input[0], [input.val(), $('a', input.data('rating.star'))[0]]);
205
		}, // $.fn.rating.focus
206
		
207
		blur: function(){
208
			var control = this.data('rating'); if(!control) return this;
209
			if(!control.blur) return this; // quick fail if not required
210
			// find data for event
211
			var input = $(this).data('rating.input') || $( this.tagName=='INPUT' ? this : null );
212
   // blur handler, as requested by focusdigital.co.uk
213
			if(control.blur) control.blur.apply(input[0], [input.val(), $('a', input.data('rating.star'))[0]]);
214
		}, // $.fn.rating.blur
215
		
216
		fill: function(){ // fill to the current mouse position.
217
			var control = this.data('rating'); if(!control) return this;
218
			// do not execute when control is in read-only mode
219
			if(control.readOnly) return;
220
			// Reset all stars and highlight them up to this element
221
			this.rating('drain');
222
			this.prevAll().andSelf().filter('.rater-'+ control.serial).addClass('star-rating-hover');
223
		},// $.fn.rating.fill
224
		
225
		drain: function() { // drain all the stars.
226
			var control = this.data('rating'); if(!control) return this;
227
			// do not execute when control is in read-only mode
228
			if(control.readOnly) return;
229
			// Reset all stars
230
			control.rater.children().filter('.rater-'+ control.serial).removeClass('star-rating-on').removeClass('star-rating-hover');
231
		},// $.fn.rating.drain
232
		
233
		draw: function(){ // set value and stars to reflect current selection
234
			var control = this.data('rating'); if(!control) return this;
235
			// Clear all stars
236
			this.rating('drain');
237
			// Set control value
238
			if(control.current){
239
				control.current.data('rating.input').attr('checked','checked');
240
				control.current.prevAll().andSelf().filter('.rater-'+ control.serial).addClass('star-rating-on');
241
			}
242
			else
243
			 $(control.inputs).removeAttr('checked');
244
			// Show/hide 'cancel' button
245
			control.cancel[control.readOnly || control.required?'hide':'show']();
246
			// Add/remove read-only classes to remove hand pointer
247
			this.siblings()[control.readOnly?'addClass':'removeClass']('star-rating-readonly');
248
		},// $.fn.rating.draw
249
		
250
		select: function(value){ // select a value
251
			var control = this.data('rating'); if(!control) return this;
252
			// do not execute when control is in read-only mode
253
			if(control.readOnly) return;
254
			// clear selection
255
			control.current = null;
256
			// programmatically (based on user input)
257
			if(typeof value!='undefined'){
258
			 // select by index (0 based)
259
				if(typeof value=='number')
260
 			 return $(control.stars[value]).rating('select');
261
				// select by literal value (must be passed as a string
262
				if(typeof value=='string')
263
					//return 
264
					$.each(control.stars, function(){
265
						if($(this).data('rating.input').val()==value) $(this).rating('select');
266
					});
267
			}
268
			else
269
				control.current = this[0].tagName=='INPUT' ? 
270
				 this.data('rating.star') : 
271
					(this.is('.rater-'+ control.serial) ? this : null);
272
			
273
			// Update rating control state
274
			this.data('rating', control);
275
			// Update display
276
			this.rating('draw');
277
			// find data for event
278
			var input = $( control.current ? control.current.data('rating.input') : null );
279
			// click callback, as requested here: http://plugins.jquery.com/node/1655
280
			if(control.callback) control.callback.apply(input[0], [input.val(), $('a', control.current)[0]]);// callback event
281
		},// $.fn.rating.select
282
		
283
		readOnly: function(toggle, disable){ // make the control read-only (still submits value)
284
			var control = this.data('rating'); if(!control) return this;
285
			// setread-only status
286
			control.readOnly = toggle || toggle==undefined ? true : false;
287
			// enable/disable control value submission
288
			if(disable) $(control.inputs).attr("disabled", "disabled");
289
			else     			$(control.inputs).removeAttr("disabled");
290
			// Update rating control state
291
			this.data('rating', control);
292
			// Update display
293
			this.rating('draw');
294
		},// $.fn.rating.readOnly
295
		
296
		disable: function(){ // make read-only and never submit value
297
			this.rating('readOnly', true, true);
298
		},// $.fn.rating.disable
299
		
300
		enable: function(){ // make read/write and submit value
301
			this.rating('readOnly', false, false);
302
		}// $.fn.rating.select
303
		
304
 });
305
	
306
	/*--------------------------------------------------------*/
307
	
308
	/*
309
		### Default Settings ###
310
		eg.: You can override default control like this:
311
		$.fn.rating.options.cancel = 'Clear';
312
	*/
313
	$.fn.rating.options = { //$.extend($.fn.rating, { options: {
314
			cancel: 'Cancel Rating',   // advisory title for the 'cancel' link
315
			cancelValue: '',           // value to submit when user click the 'cancel' link
316
			split: 0,                  // split the star into how many parts?
317
			
318
			// Width of star image in case the plugin can't work it out. This can happen if
319
			// the jQuery.dimensions plugin is not available OR the image is hidden at installation
320
			starWidth: 16//,
321
			
322
			//NB.: These don't need to be pre-defined (can be undefined/null) so let's save some code!
323
			//half:     false,         // just a shortcut to control.split = 2
324
			//required: false,         // disables the 'cancel' button so user can only select one of the specified values
325
			//readOnly: false,         // disable rating plugin interaction/ values cannot be changed
326
			//focus:    function(){},  // executed when stars are focused
327
			//blur:     function(){},  // executed when stars are focused
328
			//callback: function(){},  // executed when a star is clicked
329
 }; //} });
330
	
331
	/*--------------------------------------------------------*/
332
	
333
	/*
334
		### Default implementation ###
335
		The plugin will attach itself to file inputs
336
		with the class 'multi' when the page loads
337
	*/
338
	$(function(){ $('input[type=radio].star').rating(); });
339
	
340
	
341
	
342
/*# AVOID COLLISIONS #*/
343
})(jQuery);
344
/*# AVOID COLLISIONS #*/
(-)a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt (-1 / +49 lines)
Lines 1-6 Link Here
1
[% INCLUDE 'doc-head-open.inc' %][% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha Online[% END %] Catalog &rsaquo; Details for: [% title |html %][% FOREACH subtitl IN subtitle %], [% subtitl.subfield %][% END %]
1
[% INCLUDE 'doc-head-open.inc' %][% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha Online[% END %] Catalog &rsaquo; Details for: [% title |html %][% FOREACH subtitl IN subtitle %], [% subtitl.subfield %][% END %]
2
[% INCLUDE 'doc-head-close.inc' %]
2
[% INCLUDE 'doc-head-close.inc' %]
3
<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.tablesorter.min.js"></script>
3
<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.tablesorter.min.js"></script>
4
<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.rating.js"></script>
5
<link rel="stylesheet" type="text/css" href="[% themelang %]/css/jquery.rating.css" />
4
<script type="text/JavaScript" language="JavaScript">
6
<script type="text/JavaScript" language="JavaScript">
5
//<![CDATA[
7
//<![CDATA[
6
     $(document).ready(function() { 
8
     $(document).ready(function() { 
Lines 47-53 YAHOO.util.Event.onContentReady("furtherm", function () { Link Here
47
		YAHOO.util.Event.addListener("furthersearches", "click", furthersearchesMenu.show, null, furthersearchesMenu);
49
		YAHOO.util.Event.addListener("furthersearches", "click", furthersearchesMenu.show, null, furthersearchesMenu);
48
		YAHOO.widget.Overlay.windowResizeEvent.subscribe(positionfurthersearchesMenu);
50
		YAHOO.widget.Overlay.windowResizeEvent.subscribe(positionfurthersearchesMenu);
49
 });
51
 });
50
	
52
53
[% IF (RatingsEnabled) %]
54
$(document).ready(function() { 
55
56
$(".auto-submit-star").rating({
57
    callback: function(value, link){
58
        $.post("/cgi-bin/koha/opac-ratings.pl", 
59
        {   rating: value, 
60
            biblionumber: "[% biblionumber %]"  
61
        },
62
        function(data){
63
            $("#rating_total").html('&nbsp;('+data.total+' '+ (data.total==1 ? _('vote') : _('votes'))+')');
64
            if (data.value) {
65
                $("#rating_user").text(_('your rating added: ')+data.value);
66
            } else {
67
                $("#rating_user").text('');
68
            }
69
        }
70
        , "json");
71
    }
72
});
73
74
});
75
[% END %]
51
//]]>
76
//]]>
52
</script>
77
</script>
53
[% IF ( opacuserlogin ) %][% IF ( loggedinusername ) %][% IF ( TagsEnabled ) %]<style type="text/css">
78
[% IF ( opacuserlogin ) %][% IF ( loggedinusername ) %][% IF ( TagsEnabled ) %]<style type="text/css">
Lines 311-316 YAHOO.util.Event.onContentReady("furtherm", function () { Link Here
311
        </span>
336
        </span>
312
        [% END %][% END %][% END %]
337
        [% END %][% END %][% END %]
313
338
339
 [% IF (RatingsEnabled) %]
340
 <div class="results_summary">   
341
    <input class="auto-submit-star" type="radio"  name="rating[% biblionumber %]"  value="1" [% IF (rating_val_1) %]checked="1"[% END %] [% IF (rating_readonly) %]disabled="disabled"[% END %]   />
342
    <input class="auto-submit-star" type="radio"  name="rating[% biblionumber %]"  value="2" [% IF (rating_val_2) %]checked="1"[% END %] [% IF (rating_readonly) %]disabled="disabled"[% END %]   />
343
    <input class="auto-submit-star" type="radio"  name="rating[% biblionumber %]"  value="3" [% IF (rating_val_3) %]checked="1"[% END %] [% IF (rating_readonly) %]disabled="disabled"[% END %]   />
344
    <input class="auto-submit-star" type="radio"  name="rating[% biblionumber %]"  value="4" [% IF (rating_val_4) %]checked="1"[% END %] [% IF (rating_readonly) %]disabled="disabled"[% END %]   />
345
    <input class="auto-submit-star" type="radio"  name="rating[% biblionumber %]"  value="5" [% IF (rating_val_5) %]checked="1"[% END %] [% IF (rating_readonly) %]disabled="disabled"[% END %]   />
346
347
    <input  type="hidden" name='biblionumber'  value="[% biblionumber %]" />
348
349
   <span  id="rating_total"  >
350
[% IF(rating_total) %]&nbsp;([% rating_total %] [% IF (rating_total==1) %]vote[% ELSE %]votes[% END %])[% END %]
351
</span>
352
353
   <span id="rating_user">[% IF (rating_value) %]your rating: [% rating_value %][% END %]</span>
354
    [% IF (rating_readonly) %]
355
        <span id="rating_login">Log in to add your rating.</span>
356
    [% END %]
357
</div>
358
359
[% END %]
360
361
314
    [% IF ( BakerTaylorContentURL ) %]
362
    [% IF ( BakerTaylorContentURL ) %]
315
        <span class="results_summary">
363
        <span class="results_summary">
316
        <span class="label">Enhanced Content: </span> 
364
        <span class="label">Enhanced Content: </span> 
(-)a/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt (+58 lines)
Lines 8-13 Link Here
8
[% INCLUDE 'doc-head-close.inc' %]
8
[% INCLUDE 'doc-head-close.inc' %]
9
<link rel="alternate" type="application/rss+xml" title="[% LibraryName |html %] Search RSS Feed" href="[% OPACBaseurl %]/cgi-bin/koha/opac-search.pl?[% query_cgi |html %][% limit_cgi |html %]&amp;count=[% countrss |html %]&amp;sort_by=acqdate_dsc&amp;format=rss2" />
9
<link rel="alternate" type="application/rss+xml" title="[% LibraryName |html %] Search RSS Feed" href="[% OPACBaseurl %]/cgi-bin/koha/opac-search.pl?[% query_cgi |html %][% limit_cgi |html %]&amp;count=[% countrss |html %]&amp;sort_by=acqdate_dsc&amp;format=rss2" />
10
10
11
<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.rating.js"></script>
12
13
<link rel="stylesheet" type="text/css" href="[% themelang %]/css/jquery.rating.css" />
14
11
15
12
<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.checkboxes.min.js"></script>
16
<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.checkboxes.min.js"></script>
13
[% IF ( OpacHighlightedWords ) %]<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.highlight-3.js"></script>
17
[% IF ( OpacHighlightedWords ) %]<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.highlight-3.js"></script>
Lines 78-83 function tagAdded() { Link Here
78
    KOHA.Tags.add_multitags_button(bibs, tag);
82
    KOHA.Tags.add_multitags_button(bibs, tag);
79
    return false;
83
    return false;
80
}[% END %][% END %]
84
}[% END %][% END %]
85
86
81
[% IF ( OpacHighlightedWords ) %]
87
[% IF ( OpacHighlightedWords ) %]
82
var q_array = new Array();  // holds search terms if available
88
var q_array = new Array();  // holds search terms if available
83
89
Lines 230-236 $(document).ready(function(){ Link Here
230
    [% END %][% END %]
236
    [% END %][% END %]
231
    [% IF OpenLibraryCovers %]KOHA.OpenLibrary.GetCoverFromIsbn();[% END %]
237
    [% IF OpenLibraryCovers %]KOHA.OpenLibrary.GetCoverFromIsbn();[% END %]
232
    [% IF ( GoogleJackets ) %]KOHA.Google.GetCoverFromIsbn();[% END %]
238
    [% IF ( GoogleJackets ) %]KOHA.Google.GetCoverFromIsbn();[% END %]
239
240
241
}); // end of $(document).ready
242
243
[% IF ( RatingsEnabled ) %]
244
$(document).ready(function() { 
245
    $('.auto-submit-star').rating({
246
        callback: function(value, link){
247
                      var bibnum = this.name.replace(/^rating/, "");
248
249
                      $.post("/cgi-bin/koha/opac-ratings.pl", {   
250
                          rating: value,
251
                          biblionumber: bibnum  
252
                      }, function(data){
253
                          $("#rating_total_"+bibnum).html("&nbsp;("+data.total+' '+ (data.total==1 ? _('vote') : _('votes'))+')');
254
                            if (data.value) {
255
                                $("#rating_value_"+bibnum).text(_('your rating added: ')+data.value);
256
                            } else {
257
                                $("#rating_value_"+bibnum).text('');
258
                            }
259
                      }, "json");
260
                  }
261
    });
233
});
262
});
263
[% END %]
264
234
//]]>
265
//]]>
235
</script>
266
</script>
236
</head>
267
</head>
Lines 504-509 $(document).ready(function(){ Link Here
504
                                    </div>[% END %]
535
                                    </div>[% END %]
505
                                [% END %]
536
                                [% END %]
506
                                [% END %][% END %]
537
                                [% END %][% END %]
538
539
[% IF ( RatingsEnabled ) %]
540
<div class="results_summary">
541
    <form name="ratingform[% SEARCH_RESULT.biblionumber %]" method="post" action="/cgi-bin/koha/opac-ratings.pl">
542
        <input class="auto-submit-star" type="radio"  name="rating[% SEARCH_RESULT.biblionumber %]"  value="1" [% IF ( SEARCH_RESULT.rating_val_1 ) %]checked="1"[% END %] [% IF ( rating_readonly ) %]disabled="disabled"[% END %]   />
543
        <input class="auto-submit-star" type="radio"  name="rating[% SEARCH_RESULT.biblionumber %]"  value="2" [% IF ( SEARCH_RESULT.rating_val_2 ) %]checked="1"[% END %] [% IF ( rating_readonly ) %]disabled="disabled"[% END %]   />
544
        <input class="auto-submit-star" type="radio"  name="rating[% SEARCH_RESULT.biblionumber %]"  value="3" [% IF ( SEARCH_RESULT.rating_val_3 ) %]checked="1"[% END %] [% IF ( rating_readonly ) %]disabled="disabled"[% END %]   />
545
        <input class="auto-submit-star" type="radio"  name="rating[% SEARCH_RESULT.biblionumber %]"  value="4" [% IF ( SEARCH_RESULT.rating_val_4 ) %]checked="1"[% END %] [% IF ( rating_readonly ) %]disabled="disabled"[% END %]   />
546
        <input class="auto-submit-star" type="radio"  name="rating[% SEARCH_RESULT.biblionumber %]"  value="5" [% IF ( SEARCH_RESULT.rating_val_5 ) %]checked="1"[% END %] [% IF ( rating_readonly ) %]disabled="disabled"[% END %]   />
547
        <input  type="hidden" name='[% SEARCH_RESULT.biblionumber %]'  value="[% SEARCH_RESULT.biblionumber %]" />
548
        <span id="rating_total_[% SEARCH_RESULT.biblionumber %]">
549
            [% IF (SEARCH_RESULT.rating_total) %]
550
            &nbsp;([% SEARCH_RESULT.rating_total %] [% IF (SEARCH_RESULT.rating_total==1) %]vote[% ELSE %]votes[% END %])
551
            [% END %]
552
        </span>
553
554
        <span id="rating_value_[% SEARCH_RESULT.biblionumber %]">
555
            [% IF ( SEARCH_RESULT.rating_value ) %]&nbsp;your rating: [% SEARCH_RESULT.rating_value %][% END %]
556
        </span>
557
558
    </form>
559
    <br />
560
</div>
561
[% END %]
562
563
564
507
				[% IF ( SEARCH_RESULT.searchhighlightblob ) %]<span class="results_summary"><span class="label">Match:</span> [% SEARCH_RESULT.searchhighlightblob %]</span>[% END %]
565
				[% IF ( SEARCH_RESULT.searchhighlightblob ) %]<span class="results_summary"><span class="label">Match:</span> [% SEARCH_RESULT.searchhighlightblob %]</span>[% END %]
508
566
509
<span class="results_summary actions"><span class="label">Actions:</span>
567
<span class="results_summary actions"><span class="label">Actions:</span>
(-)a/opac/opac-detail.pl (+32 lines)
Lines 37-42 use C4::XISBN qw(get_xisbns get_biblionumber_from_isbn); Link Here
37
use C4::External::Amazon;
37
use C4::External::Amazon;
38
use C4::External::Syndetics qw(get_syndetics_index get_syndetics_summary get_syndetics_toc get_syndetics_excerpt get_syndetics_reviews get_syndetics_anotes );
38
use C4::External::Syndetics qw(get_syndetics_index get_syndetics_summary get_syndetics_toc get_syndetics_excerpt get_syndetics_reviews get_syndetics_anotes );
39
use C4::Review;
39
use C4::Review;
40
use C4::Ratings;
40
use C4::Members;
41
use C4::Members;
41
use C4::VirtualShelves;
42
use C4::VirtualShelves;
42
use C4::XSLT;
43
use C4::XSLT;
Lines 46-51 use MARC::Record; Link Here
46
use MARC::Field;
47
use MARC::Field;
47
use List::MoreUtils qw/any none/;
48
use List::MoreUtils qw/any none/;
48
49
50
#use Smart::Comments '####';
51
49
BEGIN {
52
BEGIN {
50
	if (C4::Context->preference('BakerTaylorEnabled')) {
53
	if (C4::Context->preference('BakerTaylorEnabled')) {
51
		require C4::External::BakerTaylor;
54
		require C4::External::BakerTaylor;
Lines 318-323 foreach ( @$reviews ) { Link Here
318
    $_->{userid}    = $borrowerData->{'userid'};
321
    $_->{userid}    = $borrowerData->{'userid'};
319
    $_->{cardnumber}    = $borrowerData->{'cardnumber'};
322
    $_->{cardnumber}    = $borrowerData->{'cardnumber'};
320
    $_->{datereviewed} = format_date($_->{datereviewed});
323
    $_->{datereviewed} = format_date($_->{datereviewed});
324
325
326
327
328
#    my $value =  get_rating_by_review($_->{reviewid});
329
    my $rating =  get_rating(  $biblionumber ,  $_->{borrowernumber});
330
331
    $_->{"borr_rating_val_".$rating->{value}} = 1;
332
    $_->{rating} = $rating->{value} ;
333
334
    ####  $rating
335
#### $_
336
337
321
    if ($borrowerData->{'borrowernumber'} eq $borrowernumber) {
338
    if ($borrowerData->{'borrowernumber'} eq $borrowernumber) {
322
		$_->{your_comment} = 1;
339
		$_->{your_comment} = 1;
323
		$loggedincommenter = 1;
340
		$loggedincommenter = 1;
Lines 564-569 if (C4::Context->preference("OPACURLOpenInNewWindow")) { Link Here
564
    $template->param(covernewwindow => 'false');
581
    $template->param(covernewwindow => 'false');
565
}
582
}
566
583
584
if (C4::Context->preference('RatingsEnabled') ) {
585
my $rating = get_rating( $biblionumber, $borrowernumber );
586
$template->param(
587
  RatingsShowOnDetail => 1,
588
  RatingsEnabled => 1,
589
  rating_value        => $rating->{'value'},
590
  rating_total        => $rating->{'total'},
591
  rating_avg          => $rating->{'avg'},
592
  rating_avgint       => $rating->{'avgint'},
593
  rating_readonly     => ( $borrowernumber ? 0 : 1 ),
594
  borrowernumber      => $borrowernumber,
595
  "rating_val_" . "$rating->{'avgint'}" => $rating->{'avgint'},
596
  );
597
}
598
567
#Search for title in links
599
#Search for title in links
568
my $marccontrolnumber   = GetMarcControlnumber   ($record, $marcflavour);
600
my $marccontrolnumber   = GetMarcControlnumber   ($record, $marcflavour);
569
601
(-)a/opac/opac-ratings.pl (+104 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2010 KohaAloha, NZ
4
# Parts copyright 2011, Catalyst IT, NZ
5
#
6
# This file is part of Koha.
7
#
8
# Koha is free software; you can redistribute it and/or modify it under the
9
# terms of the GNU General Public License as published by the Free Software
10
# Foundation; either version 2 of the License, or (at your option) any later
11
# version.
12
#
13
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
14
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License along with
18
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
19
# Suite 330, Boston, MA  02111-1307 USA
20
21
=head1
22
23
opac-ratings.pl - API endpoint for setting rating values
24
25
This receives a POST containing biblionumber and rating. It
26
updates rating for the logged in user.
27
28
=cut
29
30
use strict;
31
use warnings;
32
use CGI;
33
use CGI::Cookie;    # need to check cookies before having CGI parse the POST request
34
use JSON;
35
36
use C4::Auth qw(:DEFAULT check_cookie_auth);
37
use C4::Context;
38
use C4::Debug;
39
use C4::Output 3.02 qw(:html :ajax pagination_bar);
40
use C4::Ratings;
41
42
use Data::Dumper;
43
44
my %ratings = ();
45
my %counts  = ();
46
my @errors  = ();
47
48
my $is_ajax = is_ajax();
49
50
my $query = ($is_ajax) ? &ajax_auth_cgi( {} ) : CGI->new();
51
52
my $biblionumber   = $query->param('biblionumber');
53
my $value;
54
55
foreach ( $query->param ) {
56
    if (/^rating(.*)/) {
57
        $value = $query->param($_);
58
        last;
59
    }
60
}
61
62
my ( $template, $loggedinuser, $cookie );
63
64
if ($is_ajax) {
65
    $loggedinuser = C4::Context->userenv->{'number'};
66
    add_rating( $biblionumber, $loggedinuser, $value );
67
    my $rating = get_rating($biblionumber, $loggedinuser);
68
    my $js_reply = "{total: $rating->{'total'}, value: $rating->{'value'}}";
69
70
    output_ajax_with_http_headers( $query, $js_reply );
71
    exit;
72
} else {
73
    # Future enhancements could have this have its own template to
74
    # display the users' ratings, or tie in with their reading history
75
    # to get them to rate things they read recently.
76
    ( $template, $loggedinuser, $cookie ) = get_template_and_user(
77
        {   template_name   => "opac-user.tmpl",
78
            query           => $query,
79
            type            => "opac",
80
            authnotrequired => 0,                  # auth required to add ratings
81
            debug           => 0,
82
        }
83
    );
84
}
85
86
my $results = [];
87
88
( scalar @errors ) and $template->param( ERRORS => \@errors );
89
90
output_html_with_http_headers $query, $cookie, $template->output;
91
92
sub ajax_auth_cgi ($) {                            # returns CGI object
93
    my $needed_flags = shift;
94
    my %cookies      = fetch CGI::Cookie;
95
    my $input        = CGI->new;
96
    my $sessid       = $cookies{'CGISESSID'}->value || $input->param('CGISESSID');
97
    my ( $auth_status, $auth_sessid ) = check_cookie_auth( $sessid, $needed_flags );
98
    if ( $auth_status ne "ok" ) {
99
        output_ajax_with_http_headers $input, "window.alert('Your CGI session cookie ($sessid) is not current.  " . "Please refresh the page and try again.');\n";
100
        exit 0;
101
    }
102
    return $input;
103
}
104
(-)a/opac/opac-search.pl (-8 / +33 lines)
Lines 36-45 use C4::Biblio; # GetBiblioData Link Here
36
use C4::Koha;
36
use C4::Koha;
37
use C4::Tags qw(get_tags);
37
use C4::Tags qw(get_tags);
38
use C4::Branch; # GetBranches
38
use C4::Branch; # GetBranches
39
use C4::Ratings;
40
39
use POSIX qw(ceil floor strftime);
41
use POSIX qw(ceil floor strftime);
40
use URI::Escape;
42
use URI::Escape;
41
use Storable qw(thaw freeze);
43
use Storable qw(thaw freeze);
42
44
45
#use Smart::Comments '####';
46
43
47
44
my $DisplayMultiPlaceHold = C4::Context->preference("DisplayMultiPlaceHold");
48
my $DisplayMultiPlaceHold = C4::Context->preference("DisplayMultiPlaceHold");
45
# create a new CGI object
49
# create a new CGI object
Lines 111-116 if (C4::Context->preference('BakerTaylorEnabled')) { Link Here
111
		BakerTaylorBookstoreURL => C4::Context->preference('BakerTaylorBookstoreURL'),
115
		BakerTaylorBookstoreURL => C4::Context->preference('BakerTaylorBookstoreURL'),
112
	);
116
	);
113
}
117
}
118
114
if (C4::Context->preference('TagsEnabled')) {
119
if (C4::Context->preference('TagsEnabled')) {
115
	$template->param(TagsEnabled => 1);
120
	$template->param(TagsEnabled => 1);
116
	foreach (qw(TagsShowOnList TagsInputOnList)) {
121
	foreach (qw(TagsShowOnList TagsInputOnList)) {
Lines 118-123 if (C4::Context->preference('TagsEnabled')) { Link Here
118
	}
123
	}
119
}
124
}
120
125
126
if (C4::Context->preference('RatingsEnabled')) {
127
####  $borrowernumber 
128
	$template->param(rating_readonly => 1)  unless $borrowernumber ;
129
	$template->param(borrowernumber =>  $borrowernumber );
130
}
131
132
133
121
## URI Re-Writing
134
## URI Re-Writing
122
# Deprecated, but preserved because it's interesting :-)
135
# Deprecated, but preserved because it's interesting :-)
123
# The same thing can be accomplished with mod_rewrite in
136
# The same thing can be accomplished with mod_rewrite in
Lines 485-496 for (my $i=0;$i<@servers;$i++) { Link Here
485
										limit=>$tag_quantity });
498
										limit=>$tag_quantity });
486
			}
499
			}
487
		}
500
		}
488
                if (C4::Context->preference('COinSinOPACResults')) {
501
        if (C4::Context->preference('COinSinOPACResults')) {
489
		    foreach (@newresults) {
502
            foreach (@newresults) {
490
		      $_->{coins} = GetCOinSBiblio($_->{'biblionumber'});
503
                $_->{coins} = GetCOinSBiblio($_->{'biblionumber'});
491
		    }
504
            }
492
                }
505
        }
493
      
506
507
        if (C4::Context->preference('RatingsEnabled')) {
508
            foreach (@newresults) {
509
                my $rating = get_rating( $_->{'biblionumber'}, $borrowernumber );
510
511
                my $bib = $_->{'biblionumber'};
512
                $_->{'rating_user'}                         = $rating->{'user'};
513
                $_->{'rating_total'}                        = $rating->{'total'};
514
                $_->{'rating_avg'}                          = $rating->{'avg'};
515
                $_->{'rating_avgint'}                       = $rating->{'avgint'};
516
                $_->{ 'rating_val_' . $rating->{'avgint'} } = $rating->{'avgint'};
517
                $_->{'rating_value'}                        = $rating->{'value'};
518
            }
519
        }
520
494
	if ($results_hashref->{$server}->{"hits"}){
521
	if ($results_hashref->{$server}->{"hits"}){
495
	    $total = $total + $results_hashref->{$server}->{"hits"};
522
	    $total = $total + $results_hashref->{$server}->{"hits"};
496
	}
523
	}
Lines 609-615 for (my $i=0;$i<@servers;$i++) { Link Here
609
                      };
636
                      };
610
637
611
                }
638
                }
612
                        
613
            }
639
            }
614
            # now, show twenty pages, with the current one smack in the middle
640
            # now, show twenty pages, with the current one smack in the middle
615
            else {
641
            else {
616
- 

Return to bug 5668