1 #======================================================================
4 #======================================================================
6 # Saving and loading drafts
8 #======================================================================
12 require "bin/mozilla/common.pl";
15 $lxdebug->enter_sub();
17 if (!$form->{draft_id} && !$form->{draft_description}) {
18 restore_form($form->{SAVED_FORM}, 1) if ($form->{SAVED_FORM});
19 $form->{SAVED_FORM} = save_form();
22 print($form->parse_html_template("drafts/save_new"));
23 return $lxdebug->leave_sub();
26 my ($draft_id, $draft_description) =
27 ($form->{draft_id}, $form->{draft_description});
29 restore_form($form->{SAVED_FORM}, 1);
30 delete($form->{SAVED_FORM});
32 Drafts->save(\%myconfig, $form, $draft_id, $draft_description);
34 $form->{saved_message} = $locale->text("Draft saved.");
38 $lxdebug->leave_sub();
42 $lxdebug->enter_sub();
44 Drafts->remove(\%myconfig, $form, $form->{draft_id}) if ($form->{draft_id});
46 delete($form->{draft_id});
47 delete($form->{draft_description});
49 $lxdebug->leave_sub();
52 sub load_draft_maybe {
53 $lxdebug->enter_sub();
55 $lxdebug->leave_sub() and return 0 if ($form->{DONT_LOAD_DRAFT});
57 my ($draft_nextsub) = @_;
59 my @drafts = Drafts->list(\%myconfig, $form);
61 $lxdebug->leave_sub() and return 0 unless (@drafts);
63 $draft_nextsub = "add" unless ($draft_nextsub);
65 delete($form->{action});
66 my $saved_form = save_form();
69 print($form->parse_html_template("drafts/load",
70 { "DRAFTS" => \@drafts,
71 "SAVED_FORM" => $saved_form,
72 "draft_nextsub" => $draft_nextsub }));
74 $lxdebug->leave_sub();
80 $lxdebug->enter_sub();
82 my $draft_nextsub = $form->{draft_nextsub};
83 $draft_nextsub = "add" unless ($form->{draft_nextsub});
84 restore_form($form->{SAVED_FORM}, 1);
85 delete($form->{action});
86 $form->{DONT_LOAD_DRAFT} = 1;
88 &{ $draft_nextsub }();
90 $lxdebug->leave_sub();
94 $lxdebug->enter_sub();
96 my ($old_form, $id, $description) = Drafts->load(\%myconfig, $form, $form->{id});
98 restore_form($old_form, 1);
99 $form->{draft_id} = $id;
100 $form->{draft_description} = $description;
105 $lxdebug->leave_sub();