2022-01-09 17:05:04 +01:00
|
|
|
#ifndef MOURNE_ROOT_H
|
|
|
|
#define MOURNE_ROOT_H
|
2021-10-30 22:48:02 +02:00
|
|
|
|
2022-02-05 23:02:06 +01:00
|
|
|
//#include "web/http/web_application.h"
|
|
|
|
#include "web/http/web_root.h"
|
2021-10-30 22:48:02 +02:00
|
|
|
#include "core/object.h"
|
2021-11-14 22:55:25 +01:00
|
|
|
#include "core/string.h"
|
2021-10-30 22:48:02 +02:00
|
|
|
|
2021-11-14 21:37:04 +01:00
|
|
|
class AdminPanel;
|
2022-01-09 17:05:04 +01:00
|
|
|
class RBACController;
|
|
|
|
class RBACModel;
|
|
|
|
class UserController;
|
|
|
|
class MenuNode;
|
|
|
|
class MourneUserController;
|
2021-11-14 21:37:04 +01:00
|
|
|
|
2021-10-31 02:11:47 +01:00
|
|
|
#define ENSURE_LOGIN(request) \
|
|
|
|
if (!is_logged_in(request)) { \
|
|
|
|
request->send_redirect("/user/login"); \
|
|
|
|
return; \
|
2021-10-31 02:07:50 +01:00
|
|
|
}
|
|
|
|
|
2022-01-09 17:05:04 +01:00
|
|
|
class MourneRoot : public WebRoot {
|
|
|
|
RCPP_OBJECT(MourneRoot, WebRoot);
|
|
|
|
|
2021-10-30 22:48:02 +02:00
|
|
|
public:
|
|
|
|
enum MenuEntries {
|
|
|
|
MENUENTRY_NEWS = 0,
|
|
|
|
MENUENTRY_MAIL,
|
|
|
|
MENUENTRY_HERO,
|
|
|
|
MENUENTRY_VILLAGE,
|
|
|
|
MENUENTRY_SELECT_VILLAGE,
|
|
|
|
MENUENTRY_ALLIANCE,
|
|
|
|
MENUENTRY_ALLIANCE_MENU,
|
|
|
|
MENUENTRY_FORUM,
|
|
|
|
MENUENTRY_CHANGELOG,
|
|
|
|
MENUENTRY_SETTINGS,
|
|
|
|
MENUENTRY_LOGOUT,
|
|
|
|
|
|
|
|
MENUENTRY_MAX,
|
|
|
|
};
|
|
|
|
|
|
|
|
public:
|
2022-01-09 17:05:04 +01:00
|
|
|
void handle_request_main(Request *request);
|
2021-10-30 22:48:02 +02:00
|
|
|
|
2022-01-09 17:05:04 +01:00
|
|
|
bool is_logged_in(Request *request);
|
2021-10-30 22:48:02 +02:00
|
|
|
|
2022-01-09 17:05:04 +01:00
|
|
|
void add_menu(Request *request, const MenuEntries index);
|
2021-10-30 22:48:02 +02:00
|
|
|
|
2022-01-09 17:05:04 +01:00
|
|
|
void index(Request *request);
|
2021-11-14 21:37:04 +01:00
|
|
|
|
2021-10-30 22:48:02 +02:00
|
|
|
virtual void setup_middleware();
|
|
|
|
|
2022-02-05 23:02:06 +01:00
|
|
|
void create_table();
|
|
|
|
void drop_table();
|
|
|
|
void udpate_table();
|
|
|
|
void create_default_entries();
|
2021-10-30 22:48:02 +02:00
|
|
|
|
|
|
|
void compile_menu();
|
|
|
|
|
2022-01-09 17:05:04 +01:00
|
|
|
MourneRoot();
|
|
|
|
~MourneRoot();
|
2021-10-30 22:48:02 +02:00
|
|
|
|
2022-01-09 17:05:04 +01:00
|
|
|
AdminPanel *_admin_panel;
|
|
|
|
MourneUserController *_user_controller;
|
|
|
|
MenuNode *_menu;
|
2021-11-14 21:37:04 +01:00
|
|
|
|
2021-11-14 22:55:25 +01:00
|
|
|
static String menu_head;
|
|
|
|
static String admin_headers;
|
|
|
|
static String footer;
|
2021-10-30 22:48:02 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|