]> ruin.nu Git - ndwebbie.git/blobdiff - lib/NDWeb/Controller/Root.pm
Show birthdays in menu
[ndwebbie.git] / lib / NDWeb / Controller / Root.pm
index cda2e94f62f1f5d20958bf809ff7b9d640e3ce22..a1eac62c9f76b8cf7bd932a97dd14a4ba56d4c83 100644 (file)
@@ -32,6 +32,8 @@ NDWeb::Controller::Root - Root Controller for NDWeb
 
 sub index : Local Path Args(0) {
        my ( $self, $c ) = @_;
+
+       $c->res->redirect($c->uri_for('/wiki'));
 }
 
 sub default : Path {
@@ -58,7 +60,9 @@ sub login : Local {
                $log->execute($c->user->id,$c->req->address
                        ,$country,$c->sessionid,$remember);
 
-               $c->res->redirect($c->req->referer);
+               my $ref = $c->req->referer;
+               $ref =~ s/^http:/https:/ unless $c->debug;
+               $c->res->redirect($ref);
                return;
        }
 }
@@ -115,12 +119,18 @@ sub listAlliances : Private {
        $c->stash(alliances => \@alliances);
 }
 
+sub sslurl {
+       return $_[0];
+}
+
 sub auto : Private {
        my ($self, $c) = @_;
        my $dbh = $c ->model;
 
        $c->stash(dbh => $dbh);
 
+       $c->stash(sslurl => \&sslurl);
+
        $dbh->do(q{SET timezone = 'GMT'});
 
        $c->stash(TICK =>$dbh->selectrow_array('SELECT tick()',undef));
@@ -172,7 +182,8 @@ sub end : ActionClass('RenderView') {
                        $fleetupdate = 0 unless defined $fleetupdate;
                }
 
-               my ($unread,$newposts) = $dbh->selectrow_array(unread_query,undef,$c->user->id) or die $dbh->errstr;
+               my ($unread,$newposts) = $dbh->selectrow_array(q{SELECT * FROM unread_posts($1)}
+                       ,undef,$c->user->id);
 
                $c->stash(user => {
                        id => $c->user->id,
@@ -187,6 +198,15 @@ sub end : ActionClass('RenderView') {
                                        || $c->check_user_roles(qw/no_fleet_update/)))),
                $c->forward('listTargets');
        }
+       if ($c->res->status == 200){
+               my $birthdays = $dbh->prepare(q{SELECT username
+                       ,date_part('year',age(birthday)) AS age
+                       FROM users WHERE birthday IS NOT NULL
+                               AND mmdd(birthday) = mmdd(CURRENT_DATE)
+               });
+               $birthdays->execute;
+               $c->stash(birthdays => $birthdays->fetchall_arrayref({}));
+       }
 }
 
 =head1 AUTHOR