version 1.1172.2.55, 2014/10/13 15:47:14
|
version 1.1172.2.56, 2014/10/24 00:37:15
|
Line 6063 sub get_timebased_id {
|
Line 6063 sub get_timebased_id {
|
my %inuse = &Apache::lonnet::dump('nohist_'.$namespace,$cdom,$cnum,$prefix); |
my %inuse = &Apache::lonnet::dump('nohist_'.$namespace,$cdom,$cnum,$prefix); |
my $id = time; |
my $id = time; |
$newid = $id; |
$newid = $id; |
|
if ($idtype eq 'addcode') { |
|
$newid .= &sixnum_code(); |
|
} |
my $idtries = 0; |
my $idtries = 0; |
while (exists($inuse{$prefix."\0".$newid}) && $idtries < $maxtries) { |
while (exists($inuse{$prefix."\0".$newid}) && $idtries < $maxtries) { |
if ($idtype eq 'concat') { |
if ($idtype eq 'concat') { |
$newid = $id.$idtries; |
$newid = $id.$idtries; |
|
} elsif ($idtype eq 'addcode') { |
|
$newid = $newid.&sixnum_code(); |
} else { |
} else { |
$newid ++; |
$newid ++; |
} |
} |
Line 6083 sub get_timebased_id {
|
Line 6088 sub get_timebased_id {
|
$error = 'error saving new item: '.$putresult; |
$error = 'error saving new item: '.$putresult; |
} |
} |
} else { |
} else { |
|
undef($newid); |
$error = ('error: no unique suffix available for the new item '); |
$error = ('error: no unique suffix available for the new item '); |
} |
} |
# remove lock |
# remove lock |
Line 6095 sub get_timebased_id {
|
Line 6101 sub get_timebased_id {
|
return ($newid,$dellock,$error); |
return ($newid,$dellock,$error); |
} |
} |
|
|
|
sub sixnum_code { |
|
my $code; |
|
for (0..6) { |
|
$code .= int( rand(9) ); |
|
} |
|
return $code; |
|
} |
|
|
# -------------------------------------------------- portfolio access checking |
# -------------------------------------------------- portfolio access checking |
|
|
sub portfolio_access { |
sub portfolio_access { |