root/branches/new-install-process/bin/openguides-preferences-script

Revision 1158, 1.6 kB (checked in by kake, 8 months ago)

First bash at new install process - do not expect this commit to be bug-free.

  • Property svn:executable set to *
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.