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

(-)a/C4/Biblio.pm (+9 lines)
Lines 2625-2630 sub _koha_marc_update_bib_ids { Link Here
2625
    } else {
2625
    } else {
2626
        C4::Biblio::UpsertMarcSubfield($record, $biblioitem_tag, $biblioitem_subfield, $biblioitemnumber);
2626
        C4::Biblio::UpsertMarcSubfield($record, $biblioitem_tag, $biblioitem_subfield, $biblioitemnumber);
2627
    }
2627
    }
2628
2629
    # update the control number (001) in MARC
2630
    if(C4::Context->preference('autoControlNumber') eq 'biblionumber'){
2631
        unless($record->field('001')){
2632
            $record->insert_fields_ordered(MARC::Field->new('001', $biblionumber));
2633
        }elsif($record->field('001')->data() eq 'biblionumber'){
2634
            $record->field('001')->update($biblionumber);
2635
        }
2636
    }
2628
}
2637
}
2629
2638
2630
=head2 _koha_marc_update_biblioitem_cn_sort
2639
=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 805-810 subtest "LinkBibHeadingsToAuthorities record generation tests" => sub { Link Here
805
    );
805
    );
806
};
806
};
807
807
808
subtest 'autoControlNumber tests' => sub {
809
    plan tests => 3;
810
811
    t::lib::Mocks::mock_preference('autoControlNumber', 'OFF');
812
813
    my $record = MARC::Record->new();
814
    my ($biblionumber) = C4::Biblio::AddBiblio($record, '');
815
    $record = GetMarcBiblio({biblionumber => $biblionumber});
816
    is($record->field('001'), undef, '001 not set when pref is off');
817
818
    t::lib::Mocks::mock_preference('autoControlNumber', 'biblionumber');
819
    C4::Biblio::ModBiblio($record, $biblionumber, "", 1);
820
    $record = GetMarcBiblio({biblionumber => $biblionumber});
821
    is($record->field('001')->as_string(), $biblionumber, '001 set to biblionumber when pref set and field is blank');
822
823
    $record->field('001')->update('Not biblionumber');
824
    C4::Biblio::ModBiblio($record, $biblionumber, "", 1);
825
    $record = GetMarcBiblio({biblionumber => $biblionumber});
826
    is($record->field('001')->as_string(), 'Not biblionumber', '001 not set to biblionumber when pref set and field exists');
827
828
};
829
830
808
# Cleanup
831
# Cleanup
809
Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" );
832
Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" );
810
$schema->storage->txn_rollback;
833
$schema->storage->txn_rollback;
811
- 

Return to bug 27981