Frontend: Show private channels if user has access to them
This commit is contained in:
parent
c4a694948d
commit
8e9425e2c3
@ -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 = "<a href=\"panel\">$username</a>";
|
||||
$userbar = "<a href=\"panel\">$username</a> | ";
|
||||
$userbar.="<a href=\"logout_action\">Log out</a>";
|
||||
$logged = 1;
|
||||
}
|
||||
@ -63,7 +63,26 @@ sub handlePath {
|
||||
$table.="<tr><td><a href=\"view_logs?channel=$channelID\">$channelName</a></td><td>$serverName</td></tr>";
|
||||
}
|
||||
|
||||
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.="<tr><td><a href=\"view_logs?channel=$channelID\">$channelName</a></td><td>$serverName</td></tr>";
|
||||
}
|
||||
}
|
||||
|
||||
frontend::sendTemplate("templates/index.html", $aClient, {"userbar"=>$userbar, "publicChannels"=>$table, "privateChannels"=>$privateChannels});
|
||||
return 1;
|
||||
}
|
||||
when("/login_action") {
|
||||
|
@ -9,6 +9,7 @@
|
||||
<table border>
|
||||
<tr><th>Channel</th><th>Network</th></tr>
|
||||
{{publicChannels}}
|
||||
{{privateChannels}}
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
|
Loading…
Reference in New Issue
Block a user