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

(-)a/C4/Biblio.pm (+7 lines)
Lines 2627-2632 sub _koha_marc_update_bib_ids { Link Here
2627
    } else {
2627
    } else {
2628
        C4::Biblio::UpsertMarcSubfield($record, $biblioitem_tag, $biblioitem_subfield, $biblioitemnumber);
2628
        C4::Biblio::UpsertMarcSubfield($record, $biblioitem_tag, $biblioitem_subfield, $biblioitemnumber);
2629
    }
2629
    }
2630
2631
    # update the control number (001) in MARC
2632
    if(C4::Context->preference('autoControlNumber') eq 'biblionumber'){
2633
        unless($record->field('001')){
2634
            $record->insert_fields_ordered(MARC::Field->new('001', $biblionumber));
2635
        }
2636
    }
2630
}
2637
}
2631
2638
2632
=head2 _koha_marc_update_biblioitem_cn_sort
2639
=head2 _koha_marc_update_biblioitem_cn_sort
(-)a/cataloguing/addbiblio.pl (-1 / +5 lines)
Lines 790-796 if (($biblionumber) && !($breedingid)){ Link Here
790
if ($breedingid) {
790
if ($breedingid) {
791
    ( $record, $encoding ) = MARCfindbreeding( $breedingid ) ;
791
    ( $record, $encoding ) = MARCfindbreeding( $breedingid ) ;
792
}
792
}
793
793
if ( $record && $op eq 'duplicate' &&
794
     C4::Context->preference('autoControlNumber') eq 'biblionumber' ){
795
    my @control_num = $record->field('001');
796
    $record->delete_fields(@control_num);
797
}
794
#populate hostfield if hostbiblionumber is available
798
#populate hostfield if hostbiblionumber is available
795
if ($hostbiblionumber) {
799
if ($hostbiblionumber) {
796
    my $marcflavour = C4::Context->preference("marcflavour");
800
    my $marcflavour = C4::Context->preference("marcflavour");
(-)a/installer/data/mysql/atomicupdate/bug_9921.perl (+11 lines)
Line 0 Link Here
1
$DBversion = 'XXX'; # will be replaced by the RM
2
if( CheckVersion( $DBversion ) ) {
3
    # $dbh->do( "ALTER TABLE biblio ADD COLUMN badtaste int" );
4
    $dbh->do(
5
        q{INSERT INTO systempreferences (variable, value, options, explanation, type) VALUES ('autoControlNumber','OFF','biblionumber|OFF',
6
        'Used to autogenerate a Control Number: biblionumber will be as biblionumber; OFF will leave it as is','Choice');}
7
    );
8
9
    # Always end with this (adjust the bug info)
10
    NewVersion( $DBversion, 9921, "Make it possible to force 001 = biblionumber");
11
}
(-)a/installer/data/mysql/mandatory/sysprefs.sql (+1 lines)
Lines 70-75 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
70
('AuthoritySeparator','--','10','Used to separate a list of authorities in a display. Usually --','free'),
70
('AuthoritySeparator','--','10','Used to separate a list of authorities in a display. Usually --','free'),
71
('AuthSuccessLog','0',NULL,'If enabled, log successful authentications','YesNo'),
71
('AuthSuccessLog','0',NULL,'If enabled, log successful authentications','YesNo'),
72
('autoBarcode','OFF','incremental|annual|hbyymmincr|EAN13|OFF','Used to autogenerate a barcode: incremental will be of the form 1, 2, 3; annual of the form 2007-0001, 2007-0002; hbyymmincr of the form HB08010001 where HB=Home Branch','Choice'),
72
('autoBarcode','OFF','incremental|annual|hbyymmincr|EAN13|OFF','Used to autogenerate a barcode: incremental will be of the form 1, 2, 3; annual of the form 2007-0001, 2007-0002; hbyymmincr of the form HB08010001 where HB=Home Branch','Choice'),
73
('autoControlNumber','OFF','biblionumber|OFF','Used to autogenerate a Control Number: biblionumber will be as biblionumber, OFF will leave the field as it is;','Choice'),
73
('AutoCreateAuthorities','0',NULL,'Automatically create authorities that do not exist when cataloging records.','YesNo'),
74
('AutoCreateAuthorities','0',NULL,'Automatically create authorities that do not exist when cataloging records.','YesNo'),
74
('AutoCreditNumber', '', '', 'Automatically generate a number for account credits', 'Choice'),
75
('AutoCreditNumber', '', '', 'Automatically generate a number for account credits', 'Choice'),
75
('AutoEmailOpacUser','0',NULL,'Sends notification emails containing new account details to patrons - when account is created.','YesNo'),
76
('AutoEmailOpacUser','0',NULL,'Sends notification emails containing new account details to patrons - when account is created.','YesNo'),
(-)a/koha-tmpl/intranet-tmpl/lib/koha/cateditor/koha-backend.js (-2 / +2 lines)
Lines 103-111 define( [ '/cgi-bin/koha/svc/cataloguing/framework?frameworkcode=&callback=defin Link Here
103
            return _framework_kohafields[kohafield];
103
            return _framework_kohafields[kohafield];
104
        },
104
        },
105
105
106
        GetRecord: function( id, callback ) {
106
        GetRecord: function( id, duplicate, callback ) {
107
            $.get(
107
            $.get(
108
                '/cgi-bin/koha/svc/bib/' + id
108
                '/cgi-bin/koha/svc/bib/'+ duplicate + id
109
            ).done( function( metadata ) {
109
            ).done( function( metadata ) {
110
                $.get(
110
                $.get(
111
                    '/cgi-bin/koha/svc/bib_framework/' + id
111
                    '/cgi-bin/koha/svc/bib_framework/' + id
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc (-2 / +2 lines)
Lines 252-258 require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr Link Here
252
            get: function( id, callback ) {
252
            get: function( id, callback ) {
253
                if ( !id ) return false;
253
                if ( !id ) return false;
254
254
255
                KohaBackend.GetRecord( id, callback );
255
                KohaBackend.GetRecord( id, "d", callback );
256
            },
256
            },
257
            save: function( id, record, done ) {
257
            save: function( id, record, done ) {
258
                function finishCb( data ) {
258
                function finishCb( data ) {
Lines 272-278 require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr Link Here
272
            get: function( id, callback ) {
272
            get: function( id, callback ) {
273
                if ( !id ) return false;
273
                if ( !id ) return false;
274
274
275
                KohaBackend.GetRecord( id, callback );
275
                KohaBackend.GetRecord( id, "", callback );
276
            },
276
            },
277
            save: function( id, record, done ) {
277
            save: function( id, record, done ) {
278
                function finishCb( data ) {
278
                function finishCb( data ) {
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref (+6 lines)
Lines 158-163 Cataloging: Link Here
158
            - and record's last modifier name in MARC subfield
158
            - and record's last modifier name in MARC subfield
159
            - pref: MarcFieldForModifierName
159
            - pref: MarcFieldForModifierName
160
            - ". <br/><strong>NOTE:</strong> Use a dollar sign between field and subfield like 123$a."
160
            - ". <br/><strong>NOTE:</strong> Use a dollar sign between field and subfield like 123$a."
161
        -
162
            - Control Number (001) is
163
            - pref: autoControlNumber
164
              choices:
165
                  biblionumber: generated as biblionumber.
166
                  "OFF": not generated automatically.
161
    Display:
167
    Display:
162
        -
168
        -
163
            - 'Separate main entry and subdivisions with '
169
            - 'Separate main entry and subdivisions with '
(-)a/svc/bib (-3 / +10 lines)
Lines 40-55 unless ($status eq "ok") { Link Here
40
# do initial validation
40
# do initial validation
41
my $path_info = $query->path_info();
41
my $path_info = $query->path_info();
42
42
43
my $duplicate = undef;
43
my $biblionumber = undef;
44
my $biblionumber = undef;
44
if ($path_info =~ m!^/(\d+)$!) {
45
if ($path_info =~ m!^/(d?)(\d+)$!) {
45
    $biblionumber = $1;
46
    $duplicate = $1;
47
    $biblionumber = $2;
46
} else {
48
} else {
47
    print $query->header(-type => 'text/xml', -status => '400 Bad Request');
49
    print $query->header(-type => 'text/xml', -status => '400 Bad Request');
48
}
50
}
49
51
50
# are we retrieving, updating or deleting a bib?
52
# are we retrieving, updating or deleting a bib?
51
if ($query->request_method eq "GET") {
53
if ($query->request_method eq "GET") {
52
    fetch_bib($query, $biblionumber);
54
    fetch_bib($query, $biblionumber, $duplicate);
53
} elsif ($query->request_method eq "POST") {
55
} elsif ($query->request_method eq "POST") {
54
    update_bib($query, $biblionumber);
56
    update_bib($query, $biblionumber);
55
} elsif ($query->request_method eq "DELETE") {
57
} elsif ($query->request_method eq "DELETE") {
Lines 65-74 exit 0; Link Here
65
sub fetch_bib {
67
sub fetch_bib {
66
    my $query = shift;
68
    my $query = shift;
67
    my $biblionumber = shift;
69
    my $biblionumber = shift;
70
    my $duplicate = shift;
68
    my $record = GetMarcBiblio({
71
    my $record = GetMarcBiblio({
69
        biblionumber => $biblionumber,
72
        biblionumber => $biblionumber,
70
        embed_items  => scalar $query->param('items') });
73
        embed_items  => scalar $query->param('items') });
71
    if  (defined $record) {
74
    if  (defined $record) {
75
        if( $duplicate && C4::Context->preference('autoControlNumber') eq 'biblionumber' ){
76
            my @control_nums = $record->field('001');
77
            $record->delete_fields(@control_nums);
78
        }
72
        print $query->header(-type => 'text/xml',-charset => 'utf-8',);
79
        print $query->header(-type => 'text/xml',-charset => 'utf-8',);
73
        print $record->as_xml_record();
80
        print $record->as_xml_record();
74
    } else {
81
    } else {
(-)a/t/db_dependent/Biblio.t (-2 / +25 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 15;
20
use Test::More tests => 16;
21
use Test::MockModule;
21
use Test::MockModule;
22
use Test::Warn;
22
use Test::Warn;
23
use List::MoreUtils qw( uniq );
23
use List::MoreUtils qw( uniq );
Lines 246-251 sub run_tests { Link Here
246
    # Authority tests don't interact well with Elasticsearch at the moment due to the fact that there's currently no way to
246
    # Authority tests don't interact well with Elasticsearch at the moment due to the fact that there's currently no way to
247
    # roll back ES index changes.
247
    # roll back ES index changes.
248
    t::lib::Mocks::mock_preference('SearchEngine', 'Zebra');
248
    t::lib::Mocks::mock_preference('SearchEngine', 'Zebra');
249
    t::lib::Mocks::mock_preference('autoControlNumber', 'OFF');
249
250
250
    my $isbn = '0590353403';
251
    my $isbn = '0590353403';
251
    my $title = 'Foundation';
252
    my $title = 'Foundation';
Lines 821-826 subtest "LinkBibHeadingsToAuthorities record generation tests" => sub { Link Here
821
    );
822
    );
822
};
823
};
823
824
825
subtest 'autoControlNumber tests' => sub {
826
    plan tests => 3;
827
828
    t::lib::Mocks::mock_preference('autoControlNumber', 'OFF');
829
830
    my $record = MARC::Record->new();
831
    my ($biblionumber) = C4::Biblio::AddBiblio($record, '');
832
    $record = GetMarcBiblio({biblionumber => $biblionumber});
833
    is($record->field('001'), undef, '001 not set when pref is off');
834
835
    t::lib::Mocks::mock_preference('autoControlNumber', 'biblionumber');
836
    C4::Biblio::ModBiblio($record, $biblionumber, "", 1);
837
    $record = GetMarcBiblio({biblionumber => $biblionumber});
838
    is($record->field('001')->as_string(), $biblionumber, '001 set to biblionumber when pref set and field is blank');
839
840
    $record->field('001')->update('Not biblionumber');
841
    C4::Biblio::ModBiblio($record, $biblionumber, "", 1);
842
    $record = GetMarcBiblio({biblionumber => $biblionumber});
843
    is($record->field('001')->as_string(), 'Not biblionumber', '001 not set to biblionumber when pref set and field exists');
844
845
};
846
847
824
# Cleanup
848
# Cleanup
825
Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" );
849
Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" );
826
$schema->storage->txn_rollback;
850
$schema->storage->txn_rollback;
827
- 

Return to bug 27981