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

(-)a/C4/Biblio.pm (+9 lines)
Lines 2623-2628 sub _koha_marc_update_bib_ids { Link Here
2623
    } else {
2623
    } else {
2624
        C4::Biblio::UpsertMarcSubfield($record, $biblioitem_tag, $biblioitem_subfield, $biblioitemnumber);
2624
        C4::Biblio::UpsertMarcSubfield($record, $biblioitem_tag, $biblioitem_subfield, $biblioitemnumber);
2625
    }
2625
    }
2626
2627
    # update the control number (001) in MARC
2628
    if(C4::Context->preference('autoControlNumber') eq 'biblionumber'){
2629
        unless($record->field('001')){
2630
            $record->insert_fields_ordered(MARC::Field->new('001', $biblionumber));
2631
        }elsif($record->field('001')->data() eq 'biblionumber'){
2632
            $record->field('001')->update($biblionumber);
2633
        }
2634
    }
2626
}
2635
}
2627
2636
2628
=head2 _koha_marc_update_biblioitem_cn_sort
2637
=head2 _koha_marc_update_biblioitem_cn_sort
(-)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 69-74 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
69
('AuthoritySeparator','--','10','Used to separate a list of authorities in a display. Usually --','free'),
69
('AuthoritySeparator','--','10','Used to separate a list of authorities in a display. Usually --','free'),
70
('AuthSuccessLog','0',NULL,'If enabled, log successful authentications','YesNo'),
70
('AuthSuccessLog','0',NULL,'If enabled, log successful authentications','YesNo'),
71
('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'),
71
('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
('autoControlNumber','OFF','biblionumber|OFF','Used to autogenerate a Control Number: biblionumber will be as biblionumber, OFF will leave the field as it is;','Choice'),
72
('AutoCreateAuthorities','0',NULL,'Automatically create authorities that do not exist when cataloging records.','YesNo'),
73
('AutoCreateAuthorities','0',NULL,'Automatically create authorities that do not exist when cataloging records.','YesNo'),
73
('AutoCreditNumber', '', '', 'Automatically generate a number for account credits', 'Choice'),
74
('AutoCreditNumber', '', '', 'Automatically generate a number for account credits', 'Choice'),
74
('AutoEmailOpacUser','0',NULL,'Sends notification emails containing new account details to patrons - when account is created.','YesNo'),
75
('AutoEmailOpacUser','0',NULL,'Sends notification emails containing new account details to patrons - when account is created.','YesNo'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref (-1 / +6 lines)
Lines 158-164 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
    Display:
161
        -
162
            - Control Number (001) is
163
            - pref: autoControlNumber
164
              choices:
165
                  biblionumber: generated as biblionumber.
166
                  "OFF": not generated automatically.
162
        -
167
        -
163
            - 'Separate main entry and subdivisions with '
168
            - 'Separate main entry and subdivisions with '
164
            - pref: AuthoritySeparator
169
            - pref: AuthoritySeparator
(-)a/t/db_dependent/Biblio.t (-2 / +24 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 808-813 subtest "LinkBibHeadingsToAuthorities record generation tests" => sub { Link Here
808
    );
808
    );
809
};
809
};
810
810
811
subtest 'autoControlNumber tests' => sub {
812
    plan tests => 3;
813
814
    t::lib::Mocks::mock_preference('autoControlNumber', 'OFF');
815
816
    my $record = MARC::Record->new();
817
    my ($biblionumber) = C4::Biblio::AddBiblio($record, '');
818
    $record = GetMarcBiblio({biblionumber => $biblionumber});
819
    is($record->field('001'), undef, '001 not set when pref is off');
820
821
    t::lib::Mocks::mock_preference('autoControlNumber', 'biblionumber');
822
    C4::Biblio::ModBiblio($record, $biblionumber, "", 1);
823
    $record = GetMarcBiblio({biblionumber => $biblionumber});
824
    is($record->field('001')->as_string(), $biblionumber, '001 set to biblionumber when pref set and field is blank');
825
826
    $record->field('001')->update('Not biblionumber');
827
    C4::Biblio::ModBiblio($record, $biblionumber, "", 1);
828
    $record = GetMarcBiblio({biblionumber => $biblionumber});
829
    is($record->field('001')->as_string(), 'Not biblionumber', '001 not set to biblionumber when pref set and field exists');
830
831
};
832
833
811
# Cleanup
834
# Cleanup
812
Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" );
835
Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" );
813
$schema->storage->txn_rollback;
836
$schema->storage->txn_rollback;
814
- 

Return to bug 27981