Now the admin and gm menuentries will show up when logged in with an account which has the necessary privileges.

This commit is contained in:
Relintai 2021-11-14 22:55:25 +01:00
parent ec4ac1b3bc
commit 88961d7005
2 changed files with 41 additions and 19 deletions

View File

@ -14,9 +14,9 @@
#include "core/http/http_session.h" #include "core/http/http_session.h"
#include "core/http/session_manager.h" #include "core/http/session_manager.h"
#include "modules/admin_panel/admin_panel.h"
#include "modules/users/user.h" #include "modules/users/user.h"
#include "modules/users/user_controller.h" #include "modules/users/user_controller.h"
#include "modules/admin_panel/admin_panel.h"
#include "buildings/building_initializer.h" #include "buildings/building_initializer.h"
#include "village/village_initializer.h" #include "village/village_initializer.h"
@ -69,6 +69,20 @@ void MourneApplication::add_menu(Request *request, const MenuEntries index) {
HTMLTag *t; HTMLTag *t;
int userlevel = 0;
if (request->session) {
Ref<User> user = request->reference_data["user"];
if (user.is_valid()) {
userlevel = user->rank;
}
}
if (userlevel > 4) {
request->head += admin_headers;
}
/* /*
<?php if ($weather): ?> <?php if ($weather): ?>
<div class="menu_base <?=$weather['css']; ?>"> <div class="menu_base <?=$weather['css']; ?>">
@ -142,21 +156,21 @@ void MourneApplication::add_menu(Request *request, const MenuEntries index) {
b.div()->cls("right"); b.div()->cls("right");
{ {
/* if (userlevel > 4) {
<?php if ($userlevel > 4): ?> b.div()->cls("menu_gm");
<div class="menu_gm"> {
<a href="<?=site_url($link_gm); ?>">GM</a> b.a()->href("/gm")->f()->w("GM")->ca();
</div> }
<?php endif; ?> b.cdiv();
*/ }
/* if (userlevel > 5) {
<?php if ($userlevel > 5): //dev+?> b.div()->cls("menu_admin");
<div class="menu_admin"> {
<a href="<?=site_url($link_admin); ?>">Admin</a> b.a()->href("/admin")->f()->w("Admin")->ca();
</div> }
<?php endif; ?> b.cdiv();
*/ }
b.div()->cls("menu_alliance_menu"); b.div()->cls("menu_alliance_menu");
{ {
@ -267,6 +281,11 @@ void MourneApplication::compile_menu() {
menu_head = bh.result; menu_head = bh.result;
bh.result = "";
bh.link()->rel("stylesheet")->type("text/css")->href("/css/admin.css")->f()->f();
admin_headers = bh.result;
HTMLBuilder bf; HTMLBuilder bf;
bf.cdiv(); bf.cdiv();
@ -308,5 +327,6 @@ MourneApplication::~MourneApplication() {
BuildingInitializer::free_all(); BuildingInitializer::free_all();
} }
std::string MourneApplication::menu_head = ""; String MourneApplication::menu_head = "";
std::string MourneApplication::footer = ""; String MourneApplication::admin_headers = "";
String MourneApplication::footer = "";

View File

@ -3,6 +3,7 @@
//#include "core/http/web_application.h" //#include "core/http/web_application.h"
#include "core/object.h" #include "core/object.h"
#include "core/string.h"
#include "modules/drogon/web_application.h" #include "modules/drogon/web_application.h"
#include "modules/list_page/list_page.h" #include "modules/list_page/list_page.h"
@ -63,8 +64,9 @@ public:
AdminPanel *_admin_panel; AdminPanel *_admin_panel;
static std::string menu_head; static String menu_head;
static std::string footer; static String admin_headers;
static String footer;
}; };
#endif #endif