|
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 | |
|---|
| 2 | |
|---|
| 3 | use warnings; |
|---|
| 4 | use strict; |
|---|
| 5 | |
|---|
| 6 | use CGI; |
|---|
| 7 | use OpenGuides::Config; |
|---|
| 8 | use OpenGuides::CGI; |
|---|
| 9 | use OpenGuides::Utils; |
|---|
| 10 | use OpenGuides::Template; |
|---|
| 11 | |
|---|
| 12 | my $config_file = $ENV{OPENGUIDES_CONFIG_FILE} || "wiki.conf"; |
|---|
| 13 | my $config = OpenGuides::Config->new( file => $config_file ); |
|---|
| 14 | my $wiki = OpenGuides::Utils->make_wiki_object( config => $config ); |
|---|
| 15 | my $cgi = CGI->new(); |
|---|
| 16 | my $action = $cgi->param('action') || ''; |
|---|
| 17 | |
|---|
| 18 | if ( $action eq "set_preferences" ) { |
|---|
| 19 | set_preferences(); |
|---|
| 20 | } else { |
|---|
| 21 | show_form(); |
|---|
| 22 | } |
|---|
| 23 | |
|---|
| 24 | sub 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 | |
|---|
| 32 | |
|---|
| 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 | |
|---|
| 51 | sub 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 | } |
|---|