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

(-)a/cataloguing/automatic_linker.pl (-12 / +17 lines)
Lines 6-12 Link Here
6
#
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
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
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
9
# Foundation; either version 3 of the License, or (at your option) any later
10
# version.
10
# version.
11
#
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
Lines 17-24 Link Here
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
19
20
use strict;
20
use Modern::Perl;
21
use warnings;
22
use CGI;
21
use CGI;
23
use CGI::Cookie;
22
use CGI::Cookie;
24
use JSON;
23
use JSON;
Lines 26-40 use C4::Auth; Link Here
26
use C4::Biblio;
25
use C4::Biblio;
27
use C4::Context;
26
use C4::Context;
28
27
29
my $input        = new CGI;
28
my $input = new CGI;
30
print $input->header('application/json');
29
print $input->header('application/json');
31
30
32
# Check the user's permissions
31
# Check the user's permissions
33
my %cookies = fetch CGI::Cookie;
32
my %cookies = fetch CGI::Cookie;
34
my $sessid = $cookies{'CGISESSID'}->value || $input->param('CGISESSID');
33
my $sessid = $cookies{'CGISESSID'}->value || $input->param('CGISESSID');
35
my ($auth_status, $auth_sessid) = C4::Auth::check_cookie_auth($sessid, {catalogue => 1});
34
my ( $auth_status, $auth_sessid ) =
36
if ($auth_status ne "ok") {
35
  C4::Auth::check_cookie_auth( $sessid, { editauthorities => 1 } );
37
    print to_json({status => 'UNAUTHORIZED'});
36
if ( $auth_status ne "ok" ) {
37
    print to_json( { status => 'UNAUTHORIZED' } );
38
    exit 0;
38
    exit 0;
39
}
39
}
40
40
Lines 47-56 if ($auth_status ne "ok") { Link Here
47
47
48
my $json;
48
my $json;
49
49
50
my $record = TransformHtmlToMarc( $input );
50
my $record = TransformHtmlToMarc($input);
51
51
52
52
my $linker_module =
53
my $linker_module = "C4::Linker::" . ( C4::Context->preference("LinkerModule") || 'Default' );
53
  "C4::Linker::" . ( C4::Context->preference("LinkerModule") || 'Default' );
54
eval { eval "require $linker_module"; };
54
eval { eval "require $linker_module"; };
55
if ($@) {
55
if ($@) {
56
    $linker_module = 'C4::Linker::Default';
56
    $linker_module = 'C4::Linker::Default';
Lines 59-67 if ($@) { Link Here
59
if ($@) {
59
if ($@) {
60
    return 0, 0;
60
    return 0, 0;
61
}
61
}
62
my $linker = $linker_module->new( { 'options' => C4::Context->preference("LinkerOptions") } );
62
my $linker = $linker_module->new(
63
    { 'options' => C4::Context->preference("LinkerOptions") } );
63
64
64
my ( $headings_changed, $results ) = LinkBibHeadingsToAuthorities( $linker, $record, $input->param('frameworkcode'), C4::Context->preference("CatalogModuleRelink") || '', 1 );
65
my ( $headings_changed, $results ) = LinkBibHeadingsToAuthorities(
66
    $linker, $record,
67
    $input->param('frameworkcode'),
68
    C4::Context->preference("CatalogModuleRelink") || '', 1
69
);
65
70
66
$json->{status} = 'OK';
71
$json->{status} = 'OK';
67
$json->{links} = $results->{details} || '';
72
$json->{links} = $results->{details} || '';
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt (-40 / +39 lines)
Lines 144-189 function PopupZ3950() { Link Here
144
}
144
}
145
145
146
function addCreateAuthorityButton(tag_subfield_line, tag, index) {
146
function addCreateAuthorityButton(tag_subfield_line, tag, index) {
147
	var title = _("Create authority");
147
    var title = _("Create authority");
148
	var elem = $('<a class="subfield_status" href="#"><img src="/intranet-tmpl/[% theme %]/img/edit-tag.png" title="' + title + '" /></a>');
148
    var elem = $('<a class="subfield_status" href="#"><img src="[% interface %]/[% theme %]/img/edit-tag.png" title="' + title + '" /></a>');
149
	tag_subfield_line.append(elem);
149
    tag_subfield_line.append(elem);
150
150
151
	elem.click(function() {
151
    elem.click(function() {
152
        var biblioindex = $(this).parents('.subfield_line').find('input').eq(1).attr('id');
152
        var biblioindex = $(this).parents('.subfield_line').find('input').eq(1).attr('id');
153
		var popup = window.open("", "new_auth_popup",'width=700,height=550,toolbar=false,scrollbars=yes');
153
        var popup = window.open("", "new_auth_popup",'width=700,height=550,toolbar=false,scrollbars=yes');
154
154
155
		if(popup !== null) {
155
    if(popup !== null) {
156
			// Create a new form that will be POSTed in the new window
156
        // Create a new form that will be POSTed in the new window
157
			var form = $('<form>').attr({
157
        var form = $('<form>').attr({
158
				method: 'post',
158
        method: 'post',
159
				action: "../authorities/authorities.pl",
159
        action: "../authorities/authorities.pl",
160
				target: "new_auth_popup"
160
        target: "new_auth_popup"
161
			});
161
        });
162
162
163
			// Add the biblioindex
163
        // Add the biblioindex
164
			form.append($('<input>').attr({
164
        form.append($('<input>').attr({
165
				type: 'hidden',
165
        type: 'hidden',
166
				name: 'biblioindex',
166
        name: 'biblioindex',
167
				value: biblioindex
167
        value: biblioindex
168
			}));
168
        }));
169
169
170
			// Get all form datas for the current heading field
170
    // Get all form datas for the current heading field
171
			$('.tag[id^=tag_' + tag + '_]').eq(index).find(':input').each(function(){
171
        $('.tag[id^=tag_' + tag + '_]').eq(index).find(':input').each(function(){
172
				form.append($('<input>').attr({
172
        form.append($('<input>').attr({
173
					type: 'hidden',
173
            type: 'hidden',
174
					name: this.name,
174
            name: this.name,
175
					value: $(this).val()
175
            value: $(this).val()
176
				}));
176
        }));
177
			});
177
        });
178
179
			// We need to add the temporary form to the body so we can submit it
180
			$('body').append(form);
181
			form.submit();
182
			form.remove();
183
		}
184
178
185
		return false;
179
        // We need to add the temporary form to the body so we can submit it
186
	});
180
        $('body').append(form);
181
        form.submit();
182
        form.remove();
183
    }
184
185
    return false;
186
    });
187
}
187
}
188
188
189
/**
189
/**
Lines 253-266 function updateHeadingLinks(links) { Link Here
253
        }
253
        }
254
254
255
        subfield.css({backgroundColor:field_color});
255
        subfield.css({backgroundColor:field_color});
256
        tag_subfield_line.append('<img class="subfield_status" src="/intranet-tmpl/[% theme %]/img/' + image + '" title="' + message + '" />');
256
        tag_subfield_line.append('<img class="subfield_status" src="[% interface %]/[% theme %]/img/' + image + '" title="' + message + '" />');
257
257
258
        // Add the message to the dialog
258
        // Add the message to the dialog
259
        message_dialog_ul.append('<li><strong>' + heading.tag + '</strong> - ' + message + '</li>');
259
        message_dialog_ul.append('<li><strong>' + heading.tag + '</strong> - ' + message + '</li>');
260
260
261
        // Add a link to create a new authority if none was found
261
        // Add a link to create a new authority if none was found
262
        if(heading.status == 'NONE_FOUND') {
262
        if(heading.status == 'NONE_FOUND') {
263
			addCreateAuthorityButton(tag_subfield_line, heading.tag, tag_index);
263
            addCreateAuthorityButton(tag_subfield_line, heading.tag, tag_index);
264
        }
264
        }
265
    });
265
    });
266
266
267
- 

Return to bug 11299