]> ruin.nu Git - ndwebbie.git/blob - lib/NDWeb/Controller/Settings.pm
79c66ed720e5b58d008e52b665663622744e85ad
[ndwebbie.git] / lib / NDWeb / Controller / Settings.pm
1 package NDWeb::Controller::Settings;
2
3 use strict;
4 use warnings;
5 use parent 'Catalyst::Controller';
6
7 use NDWeb::Include;
8
9 =head1 NAME
10
11 NDWeb::Controller::Settings - Catalyst Controller
12
13 =head1 DESCRIPTION
14
15 Catalyst Controller.
16
17 =head1 METHODS
18
19 =cut
20
21
22 =head2 index 
23
24 =cut
25
26 sub index :Path :Args(0) {
27         my ( $self, $c ) = @_;
28                 
29         my @stylesheets = ('Default');
30         my $dir = $c->path_to('root/static/css/black.css')->dir;
31         while (my $file = $dir->next){
32                 if(!$file->is_dir && $file->basename =~ m{^(\w+)\.css$}){
33                         push @stylesheets,$1;
34                 }
35         }
36         $c->stash(stylesheets => \@stylesheets);
37
38 }
39
40 sub changeStylesheet : Local {
41         my ( $self, $c ) = @_;
42         my $dbh = $c->model;
43
44         my $query = $dbh->prepare(q{UPDATE users SET css = NULLIF($2,'Default')
45                 WHERE uid = $1
46         });
47         $query->execute($c->user->id,html_escape $c->req->param('stylesheet'));
48
49         $c->res->redirect($c->uri_for(''));
50 }
51
52
53 sub changePassword : Local {
54         my ( $self, $c ) = @_;
55         my $dbh = $c->model;
56
57         my $query = $dbh->prepare(q{UPDATE users SET password = MD5($1)
58                 WHERE password = MD5($2) AND uid = $3
59                 });
60         $query->execute($c->req->param('pass'),$c->req->param('oldpass'),$c->user->id);
61
62         $c->res->redirect($c->uri_for(''));
63 }
64
65
66 =head1 AUTHOR
67
68 Michael Andreen (harv@ruin.nu)
69
70 =head1 LICENSE
71
72 GPL 2.0, or later.
73
74 =cut
75
76 1;