root/tags/rel0_61/preferences.cgi

Revision 1085, 1.6 kB (checked in by ilmari, 17 months ago)

Clean up fallout from prefs cleanup
- Make OpenGuides::Template->output pass the provided cookies to

OpenGuides::CGI->get_prefs_from_cookie, where this overrides any
browser-supplied cookie.

- Use the prefs hash explcitly where needed (fixes #216).

Targets to commit (you may delete items from it)


M /home/ilmari/src/openguides-trunk/lib/Changes.pm
M /home/ilmari/src/openguides-trunk/lib/OpenGuides/CGI.pm
M /home/ilmari/src/openguides-trunk/lib/OpenGuides/Template.pm
M /home/ilmari/src/openguides-trunk/preferences.cgi
M /home/ilmari/src/openguides-trunk/t/59_preferences.t
M /home/ilmari/src/openguides-trunk/templates/preferences.tt
M /home/ilmari/src/openguides-trunk/templates/navbar_tools.tt

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