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

(-)a/Koha/UI/Form/Builder/Biblio.pm (-9 / +5 lines)
Lines 16-21 package Koha::UI::Form::Builder::Biblio; Link Here
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
use UUID;
19
use C4::Context;
20
use C4::Context;
20
use C4::ClassSource qw( GetClassSources );
21
use C4::ClassSource qw( GetClassSources );
21
use Koha::DateUtils qw( dt_from_string );
22
use Koha::DateUtils qw( dt_from_string );
Lines 393-407 sub build_authorized_values_list { Link Here
393
394
394
sub create_key {
395
sub create_key {
395
    my ($self) = @_;
396
    my ($self) = @_;
396
    my $unique_keys = $self->{unique_keys};
397
    my ($uuid, $key);
397
    my $max_num = 10000000;
398
    UUID::generate($uuid);
398
    #TODO: Note this could lead to a near infinite loop
399
    UUID::unparse($uuid, $key);
399
    while (my $value = int(rand($max_num)) ){
400
    return $key;
400
        if ( ! $unique_keys->{$value} ){
401
            $unique_keys->{$value} = 1;
402
            return $value;
403
        }
404
    }
405
}
401
}
406
402
407
1;
403
1;
(-)a/cataloguing/addbiblio.pl (-12 / +6 lines)
Lines 23-28 use Modern::Perl; Link Here
23
use CGI;
23
use CGI;
24
use POSIX     qw( strftime );
24
use POSIX     qw( strftime );
25
use Try::Tiny qw(catch try);
25
use Try::Tiny qw(catch try);
26
use UUID;
26
27
27
use C4::Output qw( output_html_with_http_headers );
28
use C4::Output qw( output_html_with_http_headers );
28
use C4::Auth qw( get_template_and_user haspermission );
29
use C4::Auth qw( get_template_and_user haspermission );
Lines 183-197 sub MARCfindbreeding { Link Here
183
=cut
184
=cut
184
185
185
sub CreateKey {
186
sub CreateKey {
186
    my ($unique_keys) = @_;
187
    my ($uuid, $key);
187
    my $max_num = 10000000;
188
    UUID::generate($uuid);
188
    #TODO: Note this could lead to a near infinite loop
189
    UUID::unparse($uuid, $key);
189
    while (my $value = int(rand($max_num)) ){
190
    return $key;
190
        if ( ! $unique_keys->{$value} ){
191
            $unique_keys->{$value} = 1;
192
            return $value;
193
        }
194
    }
195
}
191
}
196
192
197
=head2 GetMandatoryFieldZ3950
193
=head2 GetMandatoryFieldZ3950
Lines 236-243 sub format_indicator { Link Here
236
sub build_tabs {
232
sub build_tabs {
237
    my ( $template, $record, $dbh, $encoding,$input ) = @_;
233
    my ( $template, $record, $dbh, $encoding,$input ) = @_;
238
234
239
    my $unique_keys = {};
240
241
    # fill arrays
235
    # fill arrays
242
    my @loop_data = ();
236
    my @loop_data = ();
243
    my $tag;
237
    my $tag;
Lines 423-429 sub build_tabs { Link Here
423
                            important       => $tagslib->{$tag}->{important},
417
                            important       => $tagslib->{$tag}->{important},
424
                            subfield_loop => \@subfields_data,
418
                            subfield_loop => \@subfields_data,
425
                            fixedfield    => $tag < 10?1:0,
419
                            fixedfield    => $tag < 10?1:0,
426
                            random        => CreateKey($unique_keys),
420
                            random        => CreateKey(),
427
                        );
421
                        );
428
                        if ($tag >= 10){ # no indicator for 00x tags
422
                        if ($tag >= 10){ # no indicator for 00x tags
429
                           $tag_data{indicator1} = format_indicator($field->indicator(1)),
423
                           $tag_data{indicator1} = format_indicator($field->indicator(1)),
(-)a/koha-tmpl/intranet-tmpl/prog/js/cataloging.js (-2 / +1 lines)
Lines 506-512 function UnCloneField(index) { Link Here
506
 * This function create a random number
506
 * This function create a random number
507
 */
507
 */
508
function CreateKey(){
508
function CreateKey(){
509
    return parseInt(Math.random() * 10000000);
509
    return crypto.randomUUID();
510
}
510
}
511
511
512
/* Functions developed for additem.tt */
512
/* Functions developed for additem.tt */
513
- 

Return to bug 37675