root/trunk/preferences.cgi

Revision 1162, 1.7 kB (checked in by dom, 4 months ago)

Install signal handlers in reindex.pl and CGI scripts to allow
temporary files (eg from Plucene) to be cleaned up. (fixes #247)

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