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

(-)a/Koha/UI/Form/Builder/Biblio.pm (-1 / +11 lines)
Lines 51-56 sub new { Link Here
51
    my $self = {};
51
    my $self = {};
52
52
53
    $self->{biblionumber} = $params->{biblionumber} =~ s/\D//gr;
53
    $self->{biblionumber} = $params->{biblionumber} =~ s/\D//gr;
54
    $self->{unique_keys} = {};
54
    # just in case biblionumber obtained from CGI and passed directly here contains weird characters like spaces
55
    # just in case biblionumber obtained from CGI and passed directly here contains weird characters like spaces
55
56
56
    bless $self, $class;
57
    bless $self, $class;
Lines 383-389 sub build_authorized_values_list { Link Here
383
=cut
384
=cut
384
385
385
sub create_key {
386
sub create_key {
386
    return int(rand(1000000));
387
    my ($self) = @_;
388
    my $unique_keys = $self->{unique_keys};
389
    my $max_num = 10000000;
390
    #TODO: Note this could lead to a near infinite loop
391
    while (my $value = int(rand($max_num)) ){
392
        if ( ! $unique_keys->{$value} ){
393
            $unique_keys->{$value} = 1;
394
            return $value;
395
        }
396
    }
387
}
397
}
388
398
389
1;
399
1;
(-)a/cataloguing/addbiblio.pl (-4 / +13 lines)
Lines 183-189 sub MARCfindbreeding { Link Here
183
=cut
183
=cut
184
184
185
sub CreateKey {
185
sub CreateKey {
186
    return int(rand(10000000));
186
    my ($unique_keys) = @_;
187
    my $max_num = 10000000;
188
    #TODO: Note this could lead to a near infinite loop
189
    while (my $value = int(rand($max_num)) ){
190
        if ( ! $unique_keys->{$value} ){
191
            $unique_keys->{$value} = 1;
192
            return $value;
193
        }
194
    }
187
}
195
}
188
196
189
=head2 GetMandatoryFieldZ3950
197
=head2 GetMandatoryFieldZ3950
Lines 228-233 sub format_indicator { Link Here
228
sub build_tabs {
236
sub build_tabs {
229
    my ( $template, $record, $dbh, $encoding,$input ) = @_;
237
    my ( $template, $record, $dbh, $encoding,$input ) = @_;
230
238
239
    my $unique_keys = {};
240
231
    # fill arrays
241
    # fill arrays
232
    my @loop_data = ();
242
    my @loop_data = ();
233
    my $tag;
243
    my $tag;
Lines 279-285 sub build_tabs { Link Here
279
            $i++;
289
            $i++;
280
            next if ! $tag;
290
            next if ! $tag;
281
            my ($indicator1, $indicator2);
291
            my ($indicator1, $indicator2);
282
            my $index_tag = CreateKey;
292
            my $index_tag = CreateKey($unique_keys);
283
293
284
            # if MARC::Record is not empty =>use it as master loop, then add missing subfields that should be in the tab.
294
            # if MARC::Record is not empty =>use it as master loop, then add missing subfields that should be in the tab.
285
            # if MARC::Record is empty => use tab as master loop.
295
            # if MARC::Record is empty => use tab as master loop.
Lines 409-415 sub build_tabs { Link Here
409
                            important       => $tagslib->{$tag}->{important},
419
                            important       => $tagslib->{$tag}->{important},
410
                            subfield_loop => \@subfields_data,
420
                            subfield_loop => \@subfields_data,
411
                            fixedfield    => $tag < 10?1:0,
421
                            fixedfield    => $tag < 10?1:0,
412
                            random        => CreateKey,
422
                            random        => CreateKey($unique_keys),
413
                        );
423
                        );
414
                        if ($tag >= 10){ # no indicator for 00x tags
424
                        if ($tag >= 10){ # no indicator for 00x tags
415
                           $tag_data{indicator1} = format_indicator($field->indicator(1)),
425
                           $tag_data{indicator1} = format_indicator($field->indicator(1)),
416
- 

Return to bug 37675