X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=lib%2FNDWeb%2FController%2FSettings.pm;h=9277c7fadc2d2519cc82465981d165693907642b;hb=15e271f8e65bfc35d311f9b9cad581e3a1c70def;hp=79c66ed720e5b58d008e52b665663622744e85ad;hpb=bb8b18a775b0c6017a16003bfe79ec3eae159403;p=ndwebbie.git diff --git a/lib/NDWeb/Controller/Settings.pm b/lib/NDWeb/Controller/Settings.pm index 79c66ed..9277c7f 100644 --- a/lib/NDWeb/Controller/Settings.pm +++ b/lib/NDWeb/Controller/Settings.pm @@ -25,7 +25,10 @@ Catalyst Controller. sub index :Path :Args(0) { my ( $self, $c ) = @_; - + my $dbh = $c->model; + + $c->stash(error => $c->flash->{error}); + my @stylesheets = ('Default'); my $dir = $c->path_to('root/static/css/black.css')->dir; while (my $file = $dir->next){ @@ -34,7 +37,10 @@ sub index :Path :Args(0) { } } $c->stash(stylesheets => \@stylesheets); - + $c->stash(birthday => $dbh->selectrow_array(q{ + SELECT birthday FROM users WHERE uid = $1 + },undef,$c->user->id) + ); } sub changeStylesheet : Local { @@ -49,6 +55,26 @@ sub changeStylesheet : Local { $c->res->redirect($c->uri_for('')); } +sub changeBirthday : Local { + my ( $self, $c ) = @_; + my $dbh = $c->model; + + my $query = $dbh->prepare(q{UPDATE users SET birthday = NULLIF($2,'')::date + WHERE uid = $1 + }); + eval{ + $query->execute($c->user->id,html_escape $c->req->param('birthday')); + }; + if ($@){ + if ($@ =~ /invalid input syntax for type date/){ + $c->flash(error => 'Bad syntax for day, use YYYY-MM-DD.'); + }else{ + $c->flash(error => $@); + } + } + $c->res->redirect($c->uri_for('')); +} + sub changePassword : Local { my ( $self, $c ) = @_;