version 1.124, 2023/06/03 11:21:37
|
version 1.126, 2023/09/02 12:51:32
|
Line 694 sub get_allitems {
|
Line 694 sub get_allitems {
|
if ($item eq 'feedback') { |
if ($item eq 'feedback') { |
push(@allitems,(map { $_.'.text'; } @{$prefs{$item}{'ordered'}})); |
push(@allitems,(map { $_.'.text'; } @{$prefs{$item}{'ordered'}})); |
} |
} |
|
} elsif (($item eq 'linkprot') || ($item eq 'ltitools')) { |
|
push(@allitems,$item); |
} |
} |
} |
} |
} |
} |
Line 1914 sub process_ltitools {
|
Line 1916 sub process_ltitools {
|
if ($env{'form.ltitools_add'}) { |
if ($env{'form.ltitools_add'}) { |
my $title = $env{'form.ltitools_add_title'}; |
my $title = $env{'form.ltitools_add_title'}; |
$title =~ s/(`)/'/g; |
$title =~ s/(`)/'/g; |
my ($newid,$error) = &get_ltitools_id($context,$cdom,$cnum,$title); |
my ($newid,$error) = &Apache::lonnet::get_ltitools_id($context,$cdom,$cnum,$title); |
if ($newid) { |
if ($newid) { |
my $position = $env{'form.ltitools_add_pos'}; |
my $position = $env{'form.ltitools_add_pos'}; |
$position =~ s/\D+//g; |
$position =~ s/\D+//g; |
Line 2368 sub process_ltitools {
|
Line 2370 sub process_ltitools {
|
return $errors; |
return $errors; |
} |
} |
|
|
sub get_ltitools_id { |
|
my ($context,$cdom,$cnum,$title) = @_; |
|
my ($lockhash,$tries,$gotlock,$id,$error); |
|
|
|
# get lock on ltitools db |
|
$lockhash = { |
|
lock => $env{'user.name'}. |
|
':'.$env{'user.domain'}, |
|
}; |
|
$tries = 0; |
|
if ($context eq 'domain') { |
|
$gotlock = &Apache::lonnet::newput_dom('ltitools',$lockhash,$cdom); |
|
} else { |
|
$gotlock = &Apache::lonnet::newput('ltitools',$lockhash,$cdom,$cnum); |
|
} |
|
while (($gotlock ne 'ok') && ($tries<10)) { |
|
$tries ++; |
|
sleep (0.1); |
|
if ($context eq 'domain') { |
|
$gotlock = &Apache::lonnet::newput_dom('ltitools',$lockhash,$cdom); |
|
} else { |
|
$gotlock = &Apache::lonnet::newput('ltitools',$lockhash,$cdom,$cnum); |
|
} |
|
} |
|
if ($gotlock eq 'ok') { |
|
my %currids; |
|
if ($context eq 'domain') { |
|
%currids = &Apache::lonnet::dump_dom('ltitools',$cdom); |
|
} else { |
|
%currids = &Apache::lonnet::dump('ltitools',$cdom,$cnum); |
|
} |
|
if ($currids{'lock'}) { |
|
delete($currids{'lock'}); |
|
if (keys(%currids)) { |
|
my @curr = sort { $a <=> $b } keys(%currids); |
|
if ($curr[-1] =~ /^\d+$/) { |
|
$id = 1 + $curr[-1]; |
|
} |
|
} else { |
|
$id = 1; |
|
} |
|
if ($id) { |
|
if ($context eq 'domain') { |
|
unless (&Apache::lonnet::newput_dom('ltitools',{ $id => $title },$cdom) eq 'ok') { |
|
$error = 'nostore'; |
|
} |
|
} else { |
|
unless (&Apache::lonnet::newput('ltitools',{ $id => $title },$cdom,$cnum) eq 'ok') { |
|
$error = 'nostore'; |
|
} |
|
} |
|
} else { |
|
$error = 'nonumber'; |
|
} |
|
} |
|
my $dellockoutcome; |
|
if ($context eq 'domain') { |
|
$dellockoutcome = &Apache::lonnet::del_dom('ltitools',['lock'],$cdom); |
|
} else { |
|
$dellockoutcome = &Apache::lonnet::del('ltitools',['lock'],$cdom,$cnum); |
|
} |
|
} else { |
|
$error = 'nolock'; |
|
} |
|
return ($id,$error); |
|
} |
|
|
|
sub process_ltitools_image { |
sub process_ltitools_image { |
my ($r,$context,$dom,$cnum,$confname,$caller,$itemid,$configuserok,$switch,$author_ok,$currimg) = @_; |
my ($r,$context,$dom,$cnum,$confname,$caller,$itemid,$configuserok,$switch,$author_ok,$currimg) = @_; |
my $filename = $env{'form.'.$caller.'.filename'}; |
my $filename = $env{'form.'.$caller.'.filename'}; |