1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
#!/usr/bin/perl
use warnings;
use strict;
use sigtrap die => 'normal-signals';
use CGI;
use OpenGuides::Config;
use OpenGuides::CGI;
use OpenGuides::Utils;
use OpenGuides::Template;
my $config_file = $ENV{OPENGUIDES_CONFIG_FILE} || "wiki.conf";
my $config = OpenGuides::Config->new( file => $config_file );
my $wiki = OpenGuides::Utils->make_wiki_object( config => $config );
my $cgi = CGI->new();
my $action = $cgi->param('action') || '';
if ( $action eq "set_preferences" ) {
set_preferences();
} else {
show_form();
}
sub set_preferences {
my %prefs = OpenGuides::CGI->get_prefs_from_hash( $cgi->Vars );
my $prefs_cookie = OpenGuides::CGI->make_prefs_cookie(
config => $config,
%prefs,
);
my @cookies = ( $prefs_cookie );
# If they've asked not to have their recent changes visits tracked,
# clear any existing recentchanges cookie.
if ( ! $prefs{track_recent_changes_views} ) {
my $rc_cookie = OpenGuides::CGI->make_recent_changes_cookie(
config => $config,
clear_cookie => 1,
);
push @cookies, $rc_cookie;
}
print OpenGuides::Template->output(
wiki => $wiki,
config => $config,
template => "preferences.tt",
cookies => \@cookies,
vars => {
not_editable => 1,
not_deletable => 1,
}
);
}
sub show_form {
print OpenGuides::Template->output(
wiki => $wiki,
config => $config,
template => "preferences.tt",
vars => {
not_editable => 1,
show_form => 1,
not_deletable => 1,
}
);
}
|