sub import { #{{{
hook(type => "getsetup", id => "websetup", call => \&getsetup);
+ hook(type => "checkconfig", id => "websetup", call => \&checkconfig);
hook(type => "sessioncgi", id => "websetup", call => \&sessioncgi);
hook(type => "formbuilder_setup", id => "websetup",
call => \&formbuilder_setup);
safe => 0,
rebuild => 0,
},
+ websetup_show_unsafe => {
+ type => "boolean",
+ example => 1,
+ description => "show unsafe settings, read-only, in web interface?",
+ safe => 0,
+ rebuild => 0,
+ },
+} #}}}
+
+sub checkconfig () { #{{{
+ if (! exists $config{websetup_show_unsafe}) {
+ $config{websetup_show_unsafe}=1;
+ }
} #}}}
-sub formatexample ($) { #{{{
+sub formatexample ($$) { #{{{
my $example=shift;
+ my $value=shift;
- if (defined $example && ! ref $example && length $example) {
+ if (defined $value && length $value) {
+ return "";
+ }
+ elsif (defined $example && ! ref $example && length $example) {
return "<br/ ><small>Example: <tt>$example</tt></small>";
}
else {
my $key=shift;
my %info=%{shift()};
- # skip complex, unsafe, or internal settings
- next if ref $config{$key} || ! $info{safe} || $info{type} eq "internal";
+ # skip complex or internal settings
+ next if ref $config{$key} || ref $info{example} || $info{type} eq "internal";
+ # maybe skip unsafe settings
+ next if ! $info{safe} && ! $config{websetup_show_unsafe};
# these are handled specially, so don't show
next if $key eq 'add_plugins' || $key eq 'disable_plugins';
$form->field(
name => $name,
label => $description,
- comment => defined $value && length $value ? "" : formatexample($info{example}),
+ comment => formatexample($info{example}, $value),
type => "text",
value => $value,
size => 60,
$form->field(
name => $name,
label => $description,
- comment => formatexample($info{example}),
+ comment => formatexample($info{example}, $value),
type => "text",
value => $value,
size => 60,
$form->field(
name => $name,
label => $description,
+ comment => formatexample($info{example}, $value),
type => "text",
value => $value,
size => 5,
fieldset => $section,
);
}
+
+ if (! $info{safe}) {
+ $form->field(name => $name, disabled => 1);
+ $form->text(gettext("Note: Disabled options cannot be configured here, but only by editing the setup file."));
+ }
}
return 1;