+ # Add the toggle javascript; the attachments interface uses
+ # it to toggle visibility.
+ require IkiWiki::Plugin::toggle;
+ $form->tmpl_param("javascript" => IkiWiki::Plugin::toggle::include_javascript($params{page}, 1));
+ # Start with the attachments interface toggled invisible,
+ # but if it was used, keep it open.
+ if ($form->submitted ne "Upload Attachment" &&
+ (! defined $q->param("attachment_select") ||
+ ! length $q->param("attachment_select"))) {
+ $form->tmpl_param("attachments-class" => "toggleable");
+ }
+ else {
+ $form->tmpl_param("attachments-class" => "toggleable-open");
+ }
+ }
+ elsif ($form->title eq "preferences") {
+ # XXX deprecated, should remove eventually
+ my $session=$params{session};
+ my $user_name=$session->param("name");
+
+ $form->field(name => "allowed_attachments", size => 50,
+ fieldset => "admin",
+ comment => "deprecated; please move to allowed_attachments in setup file",
+ );
+ if (! IkiWiki::is_admin($user_name)) {
+ $form->field(name => "allowed_attachments", type => "hidden");
+ }
+ if (! $form->submitted) {
+ my $value=IkiWiki::userinfo_get($user_name, "allowed_attachments");
+ if (length $value) {
+ $form->field(name => "allowed_attachments", force => 1,
+ value => IkiWiki::userinfo_get($user_name, "allowed_attachments"));
+ }
+ else {
+ $form->field(name => "allowed_attachments", type => "hidden");
+ }
+ }
+ if ($form->submitted && $form->submitted eq 'Save Preferences') {
+ if (defined $form->field("allowed_attachments")) {
+ IkiWiki::userinfo_set($user_name, "allowed_attachments",
+ $form->field("allowed_attachments")) ||
+ error("failed to set allowed_attachments");
+ if (! length $form->field("allowed_attachments")) {
+ $form->field(name => "allowed_attachments", type => "hidden");
+ }
+ }
+ }
+ }