Revision 58e4b809
Von Sven Schöling vor mehr als 15 Jahren hinzugefügt
bin/mozilla/drafts.pl | ||
---|---|---|
require "bin/mozilla/common.pl";
|
||
|
||
sub save_draft {
|
||
$lxdebug->enter_sub();
|
||
$main::lxdebug->enter_sub();
|
||
|
||
my $form = $main::form;
|
||
my %myconfig = %main::myconfig;
|
||
my $locale = $main::locale;
|
||
|
||
if (!$form->{draft_id} && !$form->{draft_description}) {
|
||
restore_form($form->{SAVED_FORM}, 1) if ($form->{SAVED_FORM});
|
||
... | ... | |
$form->header();
|
||
print($form->parse_html_template("drafts/save_new"));
|
||
|
||
return $lxdebug->leave_sub();
|
||
return $main::lxdebug->leave_sub();
|
||
}
|
||
|
||
my ($draft_id, $draft_description) = ($form->{draft_id}, $form->{draft_description});
|
||
... | ... | |
|
||
update();
|
||
|
||
$lxdebug->leave_sub();
|
||
$main::lxdebug->leave_sub();
|
||
}
|
||
|
||
sub remove_draft {
|
||
$lxdebug->enter_sub();
|
||
$main::lxdebug->enter_sub();
|
||
|
||
my $form = $main::form;
|
||
my %myconfig = %main::myconfig;
|
||
|
||
Drafts->remove(\%myconfig, $form, $form->{draft_id}) if ($form->{draft_id});
|
||
|
||
delete @{$form}{qw(draft_id draft_description)};
|
||
|
||
$lxdebug->leave_sub();
|
||
$main::lxdebug->leave_sub();
|
||
}
|
||
|
||
sub load_draft_maybe {
|
||
$lxdebug->enter_sub();
|
||
$main::lxdebug->enter_sub();
|
||
|
||
$lxdebug->leave_sub() and return 0 if ($form->{DONT_LOAD_DRAFT});
|
||
my $form = $main::form;
|
||
my %myconfig = %main::myconfig;
|
||
|
||
$main::lxdebug->leave_sub() and return 0 if ($form->{DONT_LOAD_DRAFT});
|
||
|
||
my ($draft_nextsub) = @_;
|
||
|
||
my @drafts = Drafts->list(\%myconfig, $form);
|
||
|
||
$lxdebug->leave_sub() and return 0 unless (@drafts);
|
||
$main::lxdebug->leave_sub() and return 0 unless (@drafts);
|
||
|
||
$draft_nextsub = "add" unless ($draft_nextsub);
|
||
|
||
... | ... | |
"SAVED_FORM" => $saved_form,
|
||
"draft_nextsub" => $draft_nextsub }));
|
||
|
||
$lxdebug->leave_sub();
|
||
$main::lxdebug->leave_sub();
|
||
|
||
return 1;
|
||
}
|
||
|
||
sub dont_load_draft {
|
||
$lxdebug->enter_sub();
|
||
$main::lxdebug->enter_sub();
|
||
|
||
my $form = $main::form;
|
||
|
||
my $draft_nextsub = $form->{draft_nextsub} || "add";
|
||
|
||
... | ... | |
|
||
call_sub($draft_nextsub);
|
||
|
||
$lxdebug->leave_sub();
|
||
$main::lxdebug->leave_sub();
|
||
}
|
||
|
||
sub load_draft {
|
||
$lxdebug->enter_sub();
|
||
$main::lxdebug->enter_sub();
|
||
|
||
my $form = $main::form;
|
||
my %myconfig = %main::myconfig;
|
||
|
||
my ($old_form, $id, $description) = Drafts->load(\%myconfig, $form, $form->{id});
|
||
|
||
... | ... | |
$old_form = YAML::Load($old_form);
|
||
|
||
my %dont_save_vars = map { $_ => 1 } @Drafts::dont_save;
|
||
my @restore_vars = grep { !$skip_vars{$_} } keys %{ $old_form };
|
||
my @restore_vars = grep { !$dont_save_vars{$_} } keys %{ $old_form };
|
||
|
||
@{$form}{@restore_vars} = @{$old_form}{@restore_vars};
|
||
|
||
... | ... | |
|
||
update();
|
||
|
||
$lxdebug->leave_sub();
|
||
$main::lxdebug->leave_sub();
|
||
}
|
||
|
||
sub delete_drafts {
|
||
$lxdebug->enter_sub();
|
||
$main::lxdebug->enter_sub();
|
||
|
||
my $form = $main::form;
|
||
my %myconfig = %main::myconfig;
|
||
|
||
my @ids;
|
||
foreach (keys %{$form}) {
|
||
... | ... | |
|
||
add();
|
||
|
||
$lxdebug->leave_sub();
|
||
$main::lxdebug->leave_sub();
|
||
}
|
||
|
||
sub draft_action_dispatcher {
|
||
$lxdebug->enter_sub();
|
||
$main::lxdebug->enter_sub();
|
||
|
||
my $form = $main::form;
|
||
my $locale = $main::locale;
|
||
|
||
if ($form->{draft_action} eq $locale->text("Skip")) {
|
||
dont_load_draft();
|
||
... | ... | |
delete_drafts();
|
||
}
|
||
|
||
$lxdebug->leave_sub();
|
||
$main::lxdebug->leave_sub();
|
||
}
|
||
|
||
1;
|
Auch abrufbar als: Unified diff
draft strict