diff --git a/frontend_routes.pm b/frontend_routes.pm index 00e6b39..a19e5ab 100644 --- a/frontend_routes.pm +++ b/frontend_routes.pm @@ -39,7 +39,7 @@ sub handlePath { my $session = $aRequest->{"cookies"}{"session"}; if(frontend_session::isValidSession($session) && defined($frontend_session::sessions{$session}{"username"}) && $frontend_session::sessions{$session}{"logged"}) { my $username = $frontend_session::sessions{$session}{"username"}; - $userbar = "$username"; + $userbar = "$username | "; $userbar.="Log out"; $logged = 1; } @@ -63,7 +63,26 @@ sub handlePath { $table.="$channelName$serverName"; } - frontend::sendTemplate("templates/index.html", $aClient, {"userbar"=>$userbar, "publicChannels"=>$table}); + my $privateChannels = ""; + if($logged) { + $query = $aConnection->prepare(qq(select id from users where name=?;)); + $query->execute($frontend_session::sessions{$aRequest->{"cookies"}{"session"}}{"username"}); + my @row = $query->fetchrow_array(); + my $id = $row[0]; + $query = $aConnection->prepare(qq(select channel_id from accessors where user_id=?;)); + $query->execute($id); + while(@row = $query->fetchrow_array()) { + my $channelID = $row[0]; + my $channelQuery = $aConnection->prepare(qq(select channels.name, servers.name from channels inner join servers on channels.server_id=servers.id where channels.id=$channelID;)); + $channelQuery->execute(); + @row = $channelQuery->fetchrow_array(); + my $channelName = $row[0]; + my $serverName = $row[1]; + $privateChannels.="$channelName$serverName"; + } + } + + frontend::sendTemplate("templates/index.html", $aClient, {"userbar"=>$userbar, "publicChannels"=>$table, "privateChannels"=>$privateChannels}); return 1; } when("/login_action") { diff --git a/templates/index.html b/templates/index.html index 0c3fc4d..d21f42f 100644 --- a/templates/index.html +++ b/templates/index.html @@ -9,6 +9,7 @@ {{publicChannels}} + {{privateChannels}}
ChannelNetwork