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

(-)a/Koha/Authority.pm (-1 / +59 lines)
Lines 37-42 use C4::Context; Link Here
37
use MARC::Record;
37
use MARC::Record;
38
use MARC::File::XML;
38
use MARC::File::XML;
39
use C4::Charset;
39
use C4::Charset;
40
use Koha::Util::MARC;
40
41
41
use base qw(Koha::Record);
42
use base qw(Koha::Record);
42
43
Lines 53-59 sub new { Link Here
53
    my $class = shift;
54
    my $class = shift;
54
    my $record = shift;
55
    my $record = shift;
55
56
56
    my $self = $class->SUPER::new( { record => $record });
57
    my $self = $class->SUPER::new(
58
        {
59
            'record' => $record,
60
            'schema' => lc C4::Context->preference("marcflavour")
61
        }
62
    );
57
63
58
    bless $self, $class;
64
    bless $self, $class;
59
    return $self;
65
    return $self;
Lines 84-89 sub get_from_authid { Link Here
84
    return if ($@);
90
    return if ($@);
85
    $record->encoding('UTF-8');
91
    $record->encoding('UTF-8');
86
92
93
    # NOTE: GuessAuthTypeCode has no business in Koha::Authority, which is an
94
    #       object-oriented class. Eventually perhaps there will be utility
95
    #       classes in the Koha:: namespace, but there are not at the moment,
96
    #       so this shim seems like the best option all-around.
97
    require C4::AuthoritiesMarc;
98
    $authtypecode ||= C4::AuthoritiesMarc::GuessAuthTypeCode($record);
99
87
    my $self = $class->SUPER::new( { authid => $authid,
100
    my $self = $class->SUPER::new( { authid => $authid,
88
                                     authtype => $authtypecode,
101
                                     authtype => $authtypecode,
89
                                     schema => $marcflavour,
102
                                     schema => $marcflavour,
Lines 93-96 sub get_from_authid { Link Here
93
    return $self;
106
    return $self;
94
}
107
}
95
108
109
=head2 get_from_breeding
110
111
    my $auth = Koha::Authority->get_from_authid($authid);
112
113
Create the Koha::Authority object associated with the provided authid.
114
115
=cut
116
sub get_from_breeding {
117
    my $class = shift;
118
    my $import_record_id = shift;
119
    my $marcflavour = lc C4::Context->preference("marcflavour");
120
121
    my $dbh=C4::Context->dbh;
122
    my $sth=$dbh->prepare("select marcxml from import_records where import_record_id=? and record_type='auth';");
123
    $sth->execute($import_record_id);
124
    my $marcxml = $sth->fetchrow;
125
    my $record=eval {MARC::Record->new_from_xml(StripNonXmlChars($marcxml),'UTF-8',
126
        (C4::Context->preference("marcflavour") eq "UNIMARC"?"UNIMARCAUTH":C4::Context->preference("marcflavour")))};
127
    return if ($@);
128
    $record->encoding('UTF-8');
129
130
    # NOTE: GuessAuthTypeCode has no business in Koha::Authority, which is an
131
    #       object-oriented class. Eventually perhaps there will be utility
132
    #       classes in the Koha:: namespace, but there are not at the moment,
133
    #       so this shim seems like the best option all-around.
134
    require C4::AuthoritiesMarc;
135
    my $authtypecode = C4::AuthoritiesMarc::GuessAuthTypeCode($record);
136
137
    my $self = $class->SUPER::new( {
138
                                     schema => $marcflavour,
139
                                     authtype => $authtypecode,
140
                                     record => $record });
141
142
    bless $self, $class;
143
    return $self;
144
}
145
146
sub authorized_heading {
147
    my ($self) = @_;
148
    if ($self->schema =~ m/marc/) {
149
        return Koha::Util::MARC::getAuthorityAuthorizedHeading($self->record, $self->schema);
150
    }
151
    return;
152
}
153
96
1;
154
1;
(-)a/Koha/Util/MARC.pm (+69 lines)
Lines 107-110 sub _createKey { Link Here
107
    return int(rand(1000000));
107
    return int(rand(1000000));
108
}
108
}
109
109
110
=head2 getAuthorityAuthorizedHeading
111
112
Retrieve the authorized heading from a MARC authority record
113
114
=cut
115
116
sub getAuthorityAuthorizedHeading {
117
    my ( $record, $schema ) = @_;
118
    return unless ( ref $record eq 'MARC::Record' );
119
    if ( $schema eq 'unimarc' ) {
120
121
        # construct UNIMARC summary, that is quite different from MARC21 one
122
        # accepted form
123
        foreach my $field ( $record->field('2..') ) {
124
            return $field->as_string('abcdefghijlmnopqrstuvwxyz');
125
        }
126
    }
127
    else {
128
        foreach my $field ( $record->field('1..') ) {
129
            my $tag = $field->tag();
130
            next if "152" eq $tag;
131
132
            # FIXME - 152 is not a good tag to use
133
            # in MARC21 -- purely local tags really ought to be
134
            # 9XX
135
            if ( $tag eq '100' ) {
136
                return $field->as_string('abcdefghjklmnopqrstvxyz68');
137
            }
138
            elsif ( $tag eq '110' ) {
139
                return $field->as_string('abcdefghklmnoprstvxyz68');
140
            }
141
            elsif ( $tag eq '111' ) {
142
                return $field->as_string('acdefghklnpqstvxyz68');
143
            }
144
            elsif ( $tag eq '130' ) {
145
                return $field->as_string('adfghklmnoprstvxyz68');
146
            }
147
            elsif ( $tag eq '148' ) {
148
                return $field->as_string('abvxyz68');
149
            }
150
            elsif ( $tag eq '150' ) {
151
                return $field->as_string('abvxyz68');
152
            }
153
            elsif ( $tag eq '151' ) {
154
                return $field->as_string('avxyz68');
155
            }
156
            elsif ( $tag eq '155' ) {
157
                return $field->as_string('abvxyz68');
158
            }
159
            elsif ( $tag eq '180' ) {
160
                return $field->as_string('vxyz68');
161
            }
162
            elsif ( $tag eq '181' ) {
163
                return $field->as_string('vxyz68');
164
            }
165
            elsif ( $tag eq '182' ) {
166
                return $field->as_string('vxyz68');
167
            }
168
            elsif ( $tag eq '185' ) {
169
                return $field->as_string('vxyz68');
170
            }
171
            else {
172
                return $field->as_string();
173
            }
174
        }
175
    }
176
    return;
177
}
178
110
1;
179
1;
(-)a/authorities/merge.pl (+187 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2013 C & P Bibliography Services
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
20
use strict;
21
use warnings;
22
use CGI;
23
use C4::Output;
24
use C4::Auth;
25
use C4::AuthoritiesMarc;
26
use Koha::Authority;
27
use C4::Koha;
28
use Koha::Record;
29
use C4::Biblio;
30
31
my $input  = new CGI;
32
my @authid = $input->param('authid');
33
my $merge  = $input->param('merge');
34
35
my @errors;
36
37
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
38
    {
39
        template_name   => "authorities/merge.tmpl",
40
        query           => $input,
41
        type            => "intranet",
42
        authnotrequired => 0,
43
        flagsrequired   => { editauthorities => 1 },
44
    }
45
);
46
47
#------------------------
48
# Merging
49
#------------------------
50
if ($merge) {
51
52
    # Creating a new record from the html code
53
    my $record   = TransformHtmlToMarc($input);
54
    my $recordid1   = $input->param('recordid1');
55
    my $recordid2   = $input->param('recordid2');
56
    my $typecode = $input->param('frameworkcode');
57
58
    # Rewriting the leader
59
    $record->leader( GetAuthority($recordid1)->leader() );
60
61
    # Modifying the reference record
62
    ModAuthority( $recordid1, $record, $typecode );
63
64
    # Deleting the other record
65
    if ( scalar(@errors) == 0 ) {
66
67
        my $error;
68
        if ($input->param('mergereference') eq 'breeding') {
69
            require C4::ImportBatch;
70
            C4::ImportBatch::SetImportRecordStatus( $recordid2, 'imported' );
71
        } else {
72
            $error = DelAuthority($recordid2);
73
        }
74
        push @errors, $error if ($error);
75
    }
76
77
    # Parameters
78
    $template->param(
79
        result  => 1,
80
        recordid1 => $recordid1
81
    );
82
83
    #-------------------------
84
    # Show records to merge
85
    #-------------------------
86
}
87
else {
88
    my $mergereference = $input->param('mergereference');
89
    $template->{'VARS'}->{'mergereference'} = $mergereference;
90
91
    if ( scalar(@authid) != 2 ) {
92
        push @errors, { code => "WRONG_COUNT", value => scalar(@authid) };
93
    }
94
    else {
95
        my $recordObj1 = Koha::Authority->get_from_authid($authid[0]) || Koha::Authority->new();
96
        my $recordObj2;
97
98
        if ($mergereference eq 'breeding') {
99
            $recordObj2 =  Koha::Authority->get_from_breeding($authid[1]) || Koha::Authority->new();
100
            $mergereference = $authid[0];
101
        } else {
102
            $recordObj2 =  Koha::Authority->get_from_authid($authid[1]) || Koha::Authority->new();
103
        }
104
105
        if ($mergereference) {
106
107
            my $framework;
108
            if ( $recordObj1->authtype ne $recordObj2->authtype && $mergereference ne 'breeding' ) {
109
                $framework = $input->param('frameworkcode')
110
                  or push @errors, "Framework not selected.";
111
            }
112
            else {
113
                $framework = $recordObj1->authtype;
114
            }
115
116
            # Getting MARC Structure
117
            my $tagslib = GetTagsLabels( 1, $framework );
118
119
            my $notreference =
120
              ( $authid[0] == $mergereference )
121
              ? $authid[1]
122
              : $authid[0];
123
124
            # Creating a loop for display
125
126
            my @record1 = $recordObj1->createMergeHash($tagslib);
127
            my @record2 = $recordObj2->createMergeHash($tagslib);
128
129
            # Parameters
130
            $template->param(
131
                recordid1        => $mergereference,
132
                recordid2        => $notreference,
133
                record1        => @record1,
134
                record2        => @record2,
135
                framework      => $framework,
136
            );
137
        }
138
        else {
139
140
            # Ask the user to choose which record will be the kept
141
            $template->param(
142
                choosereference => 1,
143
                recordid1         => $authid[0],
144
                recordid2         => $authid[1],
145
                title1          => $recordObj1->authorized_heading,
146
                title2          => $recordObj2->authorized_heading,
147
            );
148
            if ( $recordObj1->authtype ne $recordObj2->authtype ) {
149
                my $frameworks = getauthtypes;
150
                my @frameworkselect;
151
                foreach my $thisframeworkcode ( keys %$frameworks ) {
152
                    my %row = (
153
                        value => $thisframeworkcode,
154
                        frameworktext =>
155
                          $frameworks->{$thisframeworkcode}->{'authtypetext'},
156
                    );
157
                    if ( $recordObj1->authtype eq $thisframeworkcode ) {
158
                        $row{'selected'} = 1;
159
                    }
160
                    push @frameworkselect, \%row;
161
                }
162
                $template->param(
163
                    frameworkselect => \@frameworkselect,
164
                    frameworkcode1  => $recordObj1->authtype,
165
                    frameworkcode2  => $recordObj2->authtype,
166
                );
167
            }
168
        }
169
    }
170
}
171
172
if (@errors) {
173
174
    # Errors
175
    $template->param( errors => \@errors );
176
}
177
178
output_html_with_http_headers $input, $cookie, $template->output;
179
exit;
180
181
=head1 FUNCTIONS
182
183
=cut
184
185
# ------------------------
186
# Functions
187
# ------------------------
(-)a/authorities/merge_ajax.pl (+27 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
use strict;
4
use warnings;
5
6
use CGI;
7
use CGI::Session;
8
use C4::Context;
9
use C4::Auth qw/check_cookie_auth/;
10
use C4::AuthoritiesMarc;
11
use JSON;
12
use CGI::Cookie; # need to check cookies before
13
                 # having CGI parse the POST request
14
15
my %cookies = fetch CGI::Cookie;
16
my ($auth_status, $sessionID) = check_cookie_auth($cookies{'CGISESSID'}->value, { editcatalogue => 'edit_catalogue' });
17
if ($auth_status ne "ok") {
18
    my $reply = CGI->new("");
19
    print $reply->header(-type => 'text/html');
20
    exit 0;
21
}
22
23
my $reply = new CGI;
24
my $framework = $reply->param('frameworkcode');
25
my $tagslib = GetTagsLabels(1, $framework);
26
print $reply->header(-type => 'text/html');
27
print encode_json $tagslib;
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/authorities_js.inc (+39 lines)
Line 0 Link Here
1
function mergeAuth(authid, summary) {
2
    var alreadySelected = $.cookie('auth_to_merge');
3
    if (alreadySelected !== null) {
4
        alreadySelected = JSON.parse(alreadySelected);
5
        $.cookie('auth_to_merge', '', { 'path': '/', 'expires': -1 });
6
        var refstring = "";
7
        if (typeof alreadySelected.mergereference !== 'undefined') {
8
            refstring = "&mergereference=" + alreadySelected.mergereference;
9
        }
10
        window.location.href = "/cgi-bin/koha/authorities/merge.pl?authid=" + authid + "&authid=" + alreadySelected.authid + refstring;
11
    } else {
12
        $.cookie('auth_to_merge', JSON.stringify({ 'authid': authid, 'summary': summary }), { 'path' : '/' });
13
        showMergingInProgress();
14
    }
15
}
16
17
function showMergingInProgress() {
18
    var alreadySelected = $.cookie('auth_to_merge');
19
    if (alreadySelected !== null) {
20
        alreadySelected = JSON.parse(alreadySelected);
21
        $('#merge_in_progress').html(_("Merging with authority: ") + "<a href='detail.pl?authid=" + alreadySelected.authid + "'><span class='authorizedheading'>" + alreadySelected.summary + "</span> (" + alreadySelected.authid + ")</a> <a href='#' id='cancel_merge'>" + _("Cancel merge") + "</a>");
22
        $('#cancel_merge').click(function(event) {
23
            event.preventDefault();
24
            $.cookie('auth_to_merge', '', { 'path': '/', 'expires': -1 });
25
            $('#merge_in_progress').empty();
26
        });
27
    } else {
28
        $('#merge_in_progress').empty();
29
    }
30
}
31
32
$(document).ready(function () {
33
    showMergingInProgress();
34
    $('.merge_auth').click(function (event) {
35
        event.preventDefault();
36
        mergeAuth($(this).parents('tr').attr('data-authid'), $(this).parents('tr').find('div.authorizedheading').text());
37
    });
38
});
39
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/authorities-home.tt (+3 lines)
Lines 19-24 function searchauthority() { Link Here
19
function confirm_deletion() {   // not really implemented, but required by phantom delAuthButton code in authorities-toolbar.inc
19
function confirm_deletion() {   // not really implemented, but required by phantom delAuthButton code in authorities-toolbar.inc
20
    return true;
20
    return true;
21
}
21
}
22
[% INCLUDE 'authorities_js.inc' %]
22
//]]>
23
//]]>
23
</script>
24
</script>
24
</head>
25
</head>
Lines 35-40 function confirm_deletion() { // not really implemented, but required by phant Link Here
35
    
36
    
36
    [% INCLUDE 'authorities-toolbar.inc' %]
37
    [% INCLUDE 'authorities-toolbar.inc' %]
37
38
39
    <div id="merge_in_progress"></div>
40
38
    </div>
41
    </div>
39
    </div>
42
    </div>
40
  </div>
43
  </div>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/merge.tt (+143 lines)
Line 0 Link Here
1
[% PROCESS 'merge-record.inc' %]
2
[% INCLUDE 'doc-head-open.inc' %]
3
<title>Koha &rsaquo; Cataloging &rsaquo; Merging records</title>
4
[% INCLUDE 'greybox.inc' %]
5
[% INCLUDE 'doc-head-close.inc' %]
6
<style type="text/css">
7
div.record ul, div.record li { float:none; display:block; }
8
div#result { margin-top: 1em; }
9
/* We use this style "against" the li ui-tabs-nav style automatically applied */
10
</style>
11
<script type="text/javascript">
12
//<![CDATA[
13
14
    // When submiting the form
15
    function mergeformsubmit() {
16
        $("ul#ulrecord1").remove();
17
        $("ul#ulrecord2").remove();
18
}
19
20
$(document).ready(function(){
21
    // Getting marc structure via ajax
22
    tagslib = [];
23
    $.getJSON("/cgi-bin/koha/authorities/merge_ajax.pl", {frameworkcode : "[% framework %]" }, function(json) {
24
        tagslib = json;
25
    });
26
    [% PROCESS mergejs %]
27
});
28
29
30
function changeFramework(fw) {
31
    $("#Frameworks").val(fw);
32
}
33
34
//]]>
35
</script>
36
</head>
37
<body id="auth_merge" class="cat">
38
[% INCLUDE 'header.inc' %]
39
[% INCLUDE 'authorities-search.inc' %]
40
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/authorities/authorities-home.pl">Authorities</a>  &rsaquo; Merging records</div>
41
42
<div id="doc" class="yui-t7">
43
44
<div id="bd">
45
        <div id="yui-main">
46
47
48
<h1>Merging records</h1>
49
[% IF ( result ) %]
50
    [% IF ( errors ) %]
51
52
    [% FOREACH error IN errors %]
53
        <div class="dialog alert">
54
55
                [% IF error.code == 'CANNOT_MOVE' %]
56
                    The following items could not be moved from the old record to the new one: [% error.value %]
57
                [% ELSE %]
58
                    [% error %]
59
                [% END %]
60
61
            <br />Therefore, the record to be merged has not been deleted.</div>
62
    [% END %]
63
64
    [% ELSE %]
65
        <script type="text/javascript">window.location.href="/cgi-bin/koha/authorities/detail.pl?authid=[% recordid1 %]"</script>
66
        <p>The merging was successful. <a href="/cgi-bin/koha/authorities/detail.pl?authid=[% recordid1 %]">Click here to see the merged record.</a></p>
67
    [% END %]
68
69
[% ELSE %]
70
71
[% IF ( choosereference ) %]
72
<p>Please choose which record will be the reference for the merge. The record chosen as reference will be kept, and the other will be deleted.</p>
73
<form id="mergeform" action="/cgi-bin/koha/authorities/merge.pl" method="post">
74
    <fieldset class="rows">
75
    <legend>Merge reference</legend>
76
    <ol>
77
    <li class="radio"><input type="radio" value="[% recordid1 %]" checked="checked" id="mergereference1" name="mergereference" onclick="changeFramework('[% frameworkcode1 %]')" /><label for="mergereference1">[% title1 %] [% FOREACH subtitl1 IN subtitle1 %] [% subtitl1.subfield %][% END %] (<a href="/cgi-bin/koha/catalogue/showmarc.pl?id=[% recordid1 %]" title="MARC" rel="gb_page_center[600,500]">[% recordid1 %]</a>)</label></li>
78
    <li class="radio"><input type="radio" value="[% recordid2 %]" id="mergereference2" name="mergereference" onclick="changeFramework('[% frameworkcode2 %]')" /><label for="mergereference2">[% title2 %] [% FOREACH subtitl2 IN subtitle2 %] [% subtitl2.subfield %][% END %] (<a href="/cgi-bin/koha/catalogue/showmarc.pl?id=[% recordid2 %]" title="MARC" rel="gb_page_center[600,500]">[% recordid2 %]</a>)</label></li>
79
80
    [% IF frameworkselect %]
81
          <li><label for="frameworkcode">Using framework:</label>
82
                      <select name="frameworkcode" id="frameworkcode">
83
                                      <option value="Default">Default</option>
84
                                      [% FOREACH frameworkcodeloo IN frameworkselect %]
85
                                          [% IF ( frameworkcodeloo.selected ) %]
86
                                              <option value="[% frameworkcodeloo.value %]" selected="selected">
87
                                          [% ELSE %]
88
                                              <option value="[% frameworkcodeloo.value %]">
89
                                          [% END %]
90
                                           [% frameworkcodeloo.frameworktext %]
91
                                           </option>
92
                                      [% END %]
93
                      </select></li>
94
    [% END %]
95
</ol>
96
97
    <input type="hidden" name="authid" value="[% recordid1 %]" />
98
    <input type="hidden" name="authid" value="[% recordid2 %]" />
99
    <fieldset class="action"><input type="submit" value="Next" /></fieldset>
100
    </fieldset>
101
</form>
102
[% ELSE %]
103
[% IF ( errors ) %]
104
    <div class="dialog alert">
105
    [% FOREACH error IN errors %]
106
        <p>
107
                [% IF error.code == 'WRONG_COUNT' %]
108
                    Number of records provided for merging: [% error.value %]. Currently only 2 records can be merged at a time.
109
                [% ELSE %]
110
                    [% error %]
111
                [% END %]
112
113
            </p>
114
    [% END %]
115
    </div>
116
[% ELSE %]
117
<form id="mergeform" action="/cgi-bin/koha/authorities/merge.pl" method="post" onsubmit="return mergeformsubmit()">
118
119
<div class="yui-g">
120
<div class="yui-u first">
121
[% PROCESS mergesource %]
122
</div>
123
<div class="yui-u">
124
[% PROCESS mergetarget %]
125
</div> <!-- .yui-u -->
126
127
<input type="hidden" name="recordid1" value="[% recordid1 %]" />
128
<input type="hidden" name="recordid2" value="[% recordid2 %]" />
129
<input type="hidden" name="mergereference" value="[% mergereference %]" />
130
<input type="hidden" name="frameworkcode" value="[% framework %]" />
131
132
<fieldset class="action"><input type="submit" name="merge" value="Merge" /></fieldset>
133
</div>
134
</form>
135
[% END %]
136
[% END %]
137
[% END %]
138
139
</div>
140
</div>
141
</div>
142
143
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist.tt (-2 / +7 lines)
Lines 35-40 function searchauthority() { Link Here
35
    Y = document.forms[0].value.value;
35
    Y = document.forms[0].value.value;
36
    window.location="/cgi-bin/koha/authorities/authorities-home.pl?op=do_search&type=intranet&authtypecode="+X+"&value="+Y+"&marclist=&and_or=and&excluding=&operator=contains";
36
    window.location="/cgi-bin/koha/authorities/authorities-home.pl?op=do_search&type=intranet&authtypecode="+X+"&value="+Y+"&marclist=&and_or=and&excluding=&operator=contains";
37
}
37
}
38
39
[% INCLUDE 'authorities_js.inc' %]
38
//]]>
40
//]]>
39
</script>
41
</script>
40
</head>
42
</head>
Lines 53-58 function searchauthority() { Link Here
53
    [% INCLUDE 'authorities-toolbar.inc' %]
55
    [% INCLUDE 'authorities-toolbar.inc' %]
54
<h1>Authority search results</h1>
56
<h1>Authority search results</h1>
55
57
58
<div id="merge_in_progress"></div>
56
[% IF ( total ) %]
59
[% IF ( total ) %]
57
<div class="pages">[% pagination_bar %]</div>
60
<div class="pages">[% pagination_bar %]</div>
58
61
Lines 67-79 function searchauthority() { Link Here
67
[% UNLESS ( isEDITORS ) %]
70
[% UNLESS ( isEDITORS ) %]
68
      <th>Used in</th>
71
      <th>Used in</th>
69
[% END %]
72
[% END %]
73
      <th>Merge</th>
70
      <th>Delete</th>
74
      <th>Delete</th>
71
    </tr>
75
    </tr>
72
[% FOREACH resul IN result %]
76
[% FOREACH resul IN result %]
73
    [% UNLESS ( loop.odd ) %]
77
    [% UNLESS ( loop.odd ) %]
74
    <tr class="highlight">
78
    <tr data-authid="[% resul.authid %]" class="highlight">
75
    [% ELSE %]
79
    [% ELSE %]
76
    <tr>
80
    <tr data-authid="[% resul.authid %]">
77
    [% END %]
81
    [% END %]
78
      <td>[% PROCESS authresult summary=resul.summary link="/cgi-bin/koha/authorities/authorities-home.pl?op=do_search&type=intranet&marclist=any&operator=contains&orderby=HeadingAsc&value=" %]</td>
82
      <td>[% PROCESS authresult summary=resul.summary link="/cgi-bin/koha/authorities/authorities-home.pl?op=do_search&type=intranet&marclist=any&operator=contains&orderby=HeadingAsc&value=" %]</td>
79
      <td><a href="detail.pl?authid=[% resul.authid %]">Details</a></td>
83
      <td><a href="detail.pl?authid=[% resul.authid %]">Details</a></td>
Lines 82-87 function searchauthority() { Link Here
82
        <a href="../catalogue/search.pl?type=intranet&amp;op=do_search&amp;idx=an,phr&amp;q=[% resul.authid %]" class="button">[% resul.used %] biblio(s)</a>
86
        <a href="../catalogue/search.pl?type=intranet&amp;op=do_search&amp;idx=an,phr&amp;q=[% resul.authid %]" class="button">[% resul.used %] biblio(s)</a>
83
      </td>
87
      </td>
84
  [% END %]
88
  [% END %]
89
      <td><a class="merge_auth" href="#merge">Merge</a></td>
85
      <td>
90
      <td>
86
  [% UNLESS ( resul.used ) %]
91
  [% UNLESS ( resul.used ) %]
87
        <a href="javascript:confirm_deletion([% resul.authid %])">Delete</a>
92
        <a href="javascript:confirm_deletion([% resul.authid %])">Delete</a>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/manage-marc-import.tt (-3 / +17 lines)
Lines 12-20 Link Here
12
            [% IF ( record.record_type == 'biblio' ) %]
12
            [% IF ( record.record_type == 'biblio' ) %]
13
                <td class="highlight" colspan="4">Matches biblio [% record_lis.match_id %] (score = [% record_lis.match_score %]): <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% record_lis.match_id %]">[% record_lis.match_citation %]</a></td>
13
                <td class="highlight" colspan="4">Matches biblio [% record_lis.match_id %] (score = [% record_lis.match_score %]): <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% record_lis.match_id %]">[% record_lis.match_citation %]</a></td>
14
            [% ELSIF ( record.record_type == 'auth' ) %]
14
            [% ELSIF ( record.record_type == 'auth' ) %]
15
                <td class="highlight" colspan="4">Matches authority [% record_lis.match_id %] (score = [% record_lis.match_score %]): <a href="/cgi-bin/koha/authorities/detail.pl?authid=[% record_lis.match_id %]">[% record_lis.match_citation %]</a></td>
15
                <td class="highlight" colspan="4">Matches authority [% record_lis.match_id %] (score = [% record_lis.match_score %]): <a href="/cgi-bin/koha/authorities/detail.pl?authid=[% record_lis.match_id %]">[% record_lis.match_citation %]</a>
16
        <a href="/cgi-bin/koha/authorities/merge.pl?mergereference=breeding&authid=[% record_lis.match_id %]&authid=[% record_lis.import_record_id %]">Merge</a>
17
                </td>
16
            [% END %]
18
            [% END %]
17
        </tr>
19
        </tr>
20
    [% ELSIF ( record.record_type == 'auth') %]
21
        <tr data-authid="[% record_lis.import_record_id %]">
22
            <td />
23
            <td class="highlight" colspan="4"><a href="#" class="merge_auth">Search for a record to merge in a new window</a></td>
24
        </tr>
18
    [% END %]
25
    [% END %]
19
[% END %]
26
[% END %]
20
[% INCLUDE 'doc-head-open.inc' %]
27
[% INCLUDE 'doc-head-open.inc' %]
Lines 41-46 $(document).ready(function(){ Link Here
41
      $("#"+str+" option[selected='selected']").attr("selected","selected");
48
      $("#"+str+" option[selected='selected']").attr("selected","selected");
42
      $(this).parent().hide();
49
      $(this).parent().hide();
43
  });
50
  });
51
52
  $('.merge_auth').click(function(event) {
53
      event.preventDefault();
54
      var authid = $(this).parents('tr').attr('data-authid');
55
      $.cookie('auth_to_merge', JSON.stringify({ 'authid': authid, 'summary': $('tr[data-id="' + authid + '"] .citation').text(), 'mergereference': 'breeding' }), { 'path': '/' });
56
      window.open("/cgi-bin/koha/authorities/authorities-home.pl");
57
  });
44
});
58
});
45
//]]>
59
//]]>
46
</script>
60
</script>
Lines 339-347 Page Link Here
339
353
340
  </tr>
354
  </tr>
341
  [% FOREACH record_lis IN record_list %]
355
  [% FOREACH record_lis IN record_list %]
342
  [% UNLESS ( loop.odd ) %]<tr class="highlight">[% ELSE %]<tr>[% END %]
356
  [% UNLESS ( loop.odd ) %]<tr data-id="[% record_lis.import_record_id %]" class="highlight">[% ELSE %]<tr data-id="[% record_lis.import_record_id %]">[% END %]
343
    <td>[% record_lis.record_sequence %]</td>
357
    <td>[% record_lis.record_sequence %]</td>
344
    <td><a href="/cgi-bin/koha/catalogue/showmarc.pl?importid=[% record_lis.import_record_id %]" rel="gb_page_center[600,500]">[% record_lis.citation %]</a></td>
358
    <td><a class="citation" href="/cgi-bin/koha/catalogue/showmarc.pl?importid=[% record_lis.import_record_id %]" rel="gb_page_center[600,500]">[% record_lis.citation %]</a></td>
345
    <td>[% record_lis.status %]</td>
359
    <td>[% record_lis.status %]</td>
346
    <td>[% record_lis.overlay_status %]</td>
360
    <td>[% record_lis.overlay_status %]</td>
347
    <td>[% IF ( record_lis.final_match_id ) %]
361
    <td>[% IF ( record_lis.final_match_id ) %]
(-)a/t/Koha_Util_MARC.t (-1 / +2 lines)
Lines 23-29 Link Here
23
use strict;
23
use strict;
24
use warnings;
24
use warnings;
25
25
26
use Test::More tests => 3;
26
use Test::More tests => 4;
27
27
28
BEGIN {
28
BEGIN {
29
        use_ok('Koha::Util::MARC');
29
        use_ok('Koha::Util::MARC');
Lines 96-98 is_deeply($hash, $samplehash, 'Generated hash correctly'); Link Here
96
my $dupkeys = grep { $_ > 1 } values %fieldkeys;
96
my $dupkeys = grep { $_ > 1 } values %fieldkeys;
97
is($dupkeys, 0, 'No duplicate keys');
97
is($dupkeys, 0, 'No duplicate keys');
98
98
99
is(Koha::Util::MARC::getAuthorityAuthorizedHeading($marcrecord, 'marc21'), 'Cooking', 'Routine for retrieving authorized heading works');
(-)a/t/db_dependent/Koha_Authority.t (-1 / +26 lines)
Lines 38-43 my $authority = Koha::Authority->new($record); Link Here
38
38
39
is(ref($authority), 'Koha::Authority', 'Created valid Koha::Authority object');
39
is(ref($authority), 'Koha::Authority', 'Created valid Koha::Authority object');
40
40
41
is($authority->authorized_heading(), 'Cooking', 'Authorized heading was correct');
42
41
is_deeply($authority->record, $record, 'Saved record');
43
is_deeply($authority->record, $record, 'Saved record');
42
44
43
SKIP:
45
SKIP:
Lines 63-66 SKIP: Link Here
63
    is($authority, undef, 'No invalid record is retrieved');
65
    is($authority, undef, 'No invalid record is retrieved');
64
}
66
}
65
67
68
SKIP:
69
{
70
    my $dbh = C4::Context->dbh;
71
    my $sth = $dbh->prepare("SELECT import_record_id FROM import_records WHERE record_type = 'auth' LIMIT 1;");
72
    $sth->execute();
73
74
    my $import_record_id;
75
    for my $row ($sth->fetchrow_hashref) {
76
        $import_record_id = $row->{'import_record_id'};
77
    }
78
79
    skip 'No authorities in reservoir', 3 unless $import_record_id;
80
    $authority = Koha::Authority->get_from_breeding($import_record_id);
81
82
    is(ref($authority), 'Koha::Authority', 'Retrieved valid Koha::Authority object');
83
84
    is($authority->authid, undef, 'Records in reservoir do not have an authid');
85
86
    is(ref($authority->record), 'MARC::Record', 'MARC record attached to authority');
87
88
    $authority = Koha::Authority->get_from_breeding('alphabetsoup');
89
    is($authority, undef, 'No invalid record is retrieved from reservoir');
90
}
91
66
done_testing();
92
done_testing();
67
- 

Return to bug 5202