diff --git a/bootstrap/bootstrap.cpp b/bootstrap/bootstrap.cpp index c95cad9f6..813e5fa3f 100644 --- a/bootstrap/bootstrap.cpp +++ b/bootstrap/bootstrap.cpp @@ -686,53 +686,53 @@ void bootstrap_index (Webserver_Request& webserver_request) return; } - if ((url == manage_accounts_url ()) && browser_request_security_okay (webserver_request) && manage_accounts_acl (std::addressof(webserver_request))) { - webserver_request.reply = manage_accounts (std::addressof(webserver_request)); + if ((url == manage_accounts_url ()) && browser_request_security_okay (webserver_request) && manage_accounts_acl (webserver_request)) { + webserver_request.reply = manage_accounts (webserver_request); return; } - if ((url == manage_index_url ()) && browser_request_security_okay (webserver_request) && manage_index_acl (std::addressof(webserver_request))) { - webserver_request.reply = manage_index (std::addressof(webserver_request)); + if ((url == manage_index_url ()) && browser_request_security_okay (webserver_request) && manage_index_acl (webserver_request)) { + webserver_request.reply = manage_index (webserver_request); return; } - if ((url == system_index_url ()) && browser_request_security_okay (webserver_request) && system_index_acl (std::addressof(webserver_request))) { - webserver_request.reply = system_index (std::addressof(webserver_request)); + if ((url == system_index_url ()) && browser_request_security_okay (webserver_request) && system_index_acl (webserver_request)) { + webserver_request.reply = system_index (webserver_request); return; } - if ((url == system_googletranslate_url ()) && browser_request_security_okay (webserver_request) && system_googletranslate_acl (std::addressof(webserver_request))) { - webserver_request.reply = system_googletranslate (std::addressof(webserver_request)); + if ((url == system_googletranslate_url ()) && browser_request_security_okay (webserver_request) && system_googletranslate_acl (webserver_request)) { + webserver_request.reply = system_googletranslate (webserver_request); return; } - if ((url == email_index_url ()) && browser_request_security_okay (webserver_request) && email_index_acl (std::addressof(webserver_request))) { - webserver_request.reply = email_index (std::addressof(webserver_request)); + if ((url == email_index_url ()) && browser_request_security_okay (webserver_request) && email_index_acl (webserver_request)) { + webserver_request.reply = email_index (webserver_request); return; } - if ((url == styles_indexm_url ()) && browser_request_security_okay (webserver_request) && styles_indexm_acl (std::addressof(webserver_request))) { - webserver_request.reply = styles_indexm (std::addressof(webserver_request)); + if ((url == styles_indexm_url ()) && browser_request_security_okay (webserver_request) && styles_indexm_acl (webserver_request)) { + webserver_request.reply = styles_indexm (webserver_request); return; } - if ((url == styles_sheetm_url ()) && browser_request_security_okay (webserver_request) && styles_sheetm_acl (std::addressof(webserver_request))) { - webserver_request.reply = styles_sheetm (std::addressof(webserver_request)); + if ((url == styles_sheetm_url ()) && browser_request_security_okay (webserver_request) && styles_sheetm_acl (webserver_request)) { + webserver_request.reply = styles_sheetm (webserver_request); return; } - if ((url == styles_view_url ()) && browser_request_security_okay (webserver_request) && styles_view_acl (std::addressof(webserver_request))) { - webserver_request.reply = styles_view (std::addressof(webserver_request)); + if ((url == styles_view_url ()) && browser_request_security_okay (webserver_request) && styles_view_acl (webserver_request)) { + webserver_request.reply = styles_view (webserver_request); return; } - if ((url == versification_index_url ()) && browser_request_security_okay (webserver_request) && versification_index_acl (std::addressof(webserver_request))) { - webserver_request.reply = versification_index (std::addressof(webserver_request)); + if ((url == versification_index_url ()) && browser_request_security_okay (webserver_request) && versification_index_acl (webserver_request)) { + webserver_request.reply = versification_index (webserver_request); return; } - if ((url == versification_system_url ()) && browser_request_security_okay (webserver_request) && versification_system_acl (std::addressof(webserver_request))) { - webserver_request.reply = versification_system (std::addressof(webserver_request)); + if ((url == versification_system_url ()) && browser_request_security_okay (webserver_request) && versification_system_acl (webserver_request)) { + webserver_request.reply = versification_system (webserver_request); return; } diff --git a/email/index.cpp b/email/index.cpp index e9e03a59c..f7db50c7c 100644 --- a/email/index.cpp +++ b/email/index.cpp @@ -39,29 +39,27 @@ string email_index_url () } -bool email_index_acl (void * webserver_request) +bool email_index_acl (Webserver_Request& webserver_request) { - return Filter_Roles::access_control (webserver_request, Filter_Roles::admin ()); + return Filter_Roles::access_control (std::addressof(webserver_request), Filter_Roles::admin ()); } -string email_index (void * webserver_request) +string email_index (Webserver_Request& webserver_request) { - Webserver_Request * request = static_cast(webserver_request); - string page; - Assets_Header header = Assets_Header (translate("Mail"), webserver_request); + Assets_Header header = Assets_Header (translate("Mail"), std::addressof(webserver_request)); header.add_bread_crumb (menu_logic_settings_menu (), menu_logic_settings_text ()); page = header.run (); Assets_View view; // Site name and email. - if (request->post ["email"] != "") { + if (webserver_request.post ["email"] != "") { bool form_is_valid = true; - string sitename = request->post ["sitename"]; - string sitemail = request->post ["sitemail"]; + string sitename = webserver_request.post ["sitename"]; + string sitemail = webserver_request.post ["sitemail"]; if (sitemail.length () > 0) { if (!filter_url_email_is_valid (sitemail)) { form_is_valid = false; @@ -78,12 +76,12 @@ string email_index (void * webserver_request) view.set_variable ("sitemail", Database_Config_General::getSiteMailAddress ()); // Email retrieval. - if (request->post ["retrieve"] != "") { - string storagehost = request->post ["storagehost"]; - string storageusername = request->post ["storageusername"]; - string storagepassword = request->post ["storagepassword"]; - string storagesecurity = request->post ["storagesecurity"]; - string storageport = request->post ["storageport"]; + if (webserver_request.post ["retrieve"] != "") { + string storagehost = webserver_request.post ["storagehost"]; + string storageusername = webserver_request.post ["storageusername"]; + string storagepassword = webserver_request.post ["storagepassword"]; + string storagesecurity = webserver_request.post ["storagesecurity"]; + string storageport = webserver_request.post ["storageport"]; Database_Config_General::setMailStorageHost (storagehost); Database_Config_General::setMailStorageUsername (storageusername); Database_Config_General::setMailStoragePassword (storagepassword); @@ -111,13 +109,13 @@ string email_index (void * webserver_request) view.set_variable ("storageport", Database_Config_General::getMailStoragePort ()); // Sending email. - if (request->post ["send"] != "") { - string sendhost = request->post ["sendhost"]; - string sendauthentication = request->post ["sendauthentication"]; - string sendusername = request->post ["sendusername"]; - string sendpassword = request->post ["sendpassword"]; - string sendsecurity = request->post ["sendsecurity"]; - string sendport = request->post ["sendport"]; + if (webserver_request.post ["send"] != "") { + string sendhost = webserver_request.post ["sendhost"]; + string sendauthentication = webserver_request.post ["sendauthentication"]; + string sendusername = webserver_request.post ["sendusername"]; + string sendpassword = webserver_request.post ["sendpassword"]; + string sendsecurity = webserver_request.post ["sendsecurity"]; + string sendport = webserver_request.post ["sendport"]; Database_Config_General::setMailSendHost (sendhost); Database_Config_General::setMailSendUsername (sendusername); Database_Config_General::setMailSendPassword (sendpassword); diff --git a/email/index.h b/email/index.h index 5336dcc84..d4d79d0e1 100644 --- a/email/index.h +++ b/email/index.h @@ -24,5 +24,5 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. class Webserver_Request; std::string email_index_url (); -bool email_index_acl (void * webserver_request); -std::string email_index (void * webserver_request); +bool email_index_acl (Webserver_Request& webserver_request); +std::string email_index (Webserver_Request& webserver_request); diff --git a/manage/accounts.cpp b/manage/accounts.cpp index 3ce1c1491..346100136 100644 --- a/manage/accounts.cpp +++ b/manage/accounts.cpp @@ -50,36 +50,34 @@ string manage_accounts_url () } -bool manage_accounts_acl (void * webserver_request) +bool manage_accounts_acl (Webserver_Request& webserver_request) { - return Filter_Roles::access_control (webserver_request, Filter_Roles::manager ()); + return Filter_Roles::access_control (std::addressof(webserver_request), Filter_Roles::manager ()); } -string manage_accounts (void * webserver_request) +string manage_accounts (Webserver_Request& webserver_request) { - Webserver_Request * request = static_cast(webserver_request); - bool user_updated = false; bool privileges_updated = false; string page; - Assets_Header header = Assets_Header (translate("Accounts"), webserver_request); + Assets_Header header = Assets_Header (translate("Accounts"), std::addressof(webserver_request)); header.add_bread_crumb (menu_logic_settings_menu (), menu_logic_settings_text ()); page = header.run (); Assets_View view; // The user to act on. - string objectUsername = request->query["user"]; - int user_level = request->database_users ()->get_level (objectUsername); + string objectUsername = webserver_request.query["user"]; + int user_level = webserver_request.database_users ()->get_level (objectUsername); // Delete a user. - if (request->query.count ("delete")) { + if (webserver_request.query.count ("delete")) { string role = Filter_Roles::text (user_level); - string email = request->database_users ()->get_email (objectUsername); - vector users = request->database_users ()->get_users (); - vector administrators = request->database_users ()->getAdministrators (); + string email = webserver_request.database_users ()->get_email (objectUsername); + vector users = webserver_request.database_users ()->get_users (); + vector administrators = webserver_request.database_users ()->getAdministrators (); if (users.size () == 1) { page += assets_page::error (translate("Cannot remove the last user")); } else if ((user_level >= Filter_Roles::admin ()) && (administrators.size () == 1)) { @@ -108,15 +106,15 @@ string manage_accounts (void * webserver_request) } // Retrieve assigned users. - vector users = access_user::assignees (webserver_request); - for (auto & username : users) { + const vector users = access_user::assignees (std::addressof(webserver_request)); + for (const auto& username : users) { // Gather details for this user account. - user_level = request->database_users ()->get_level (username); - string role = Filter_Roles::text (user_level); - string email = request->database_users ()->get_email (username); - int seconds = filter::date::seconds_since_epoch() - account_creation_times[username]; - string days = filter::strings::convert_to_string (seconds / (3600 * 24)); + user_level = webserver_request.database_users ()->get_level (username); + const string role = Filter_Roles::text (user_level); + const string email = webserver_request.database_users ()->get_email (username); + const int seconds = filter::date::seconds_since_epoch() - account_creation_times[username]; + const string days = filter::strings::convert_to_string (seconds / (3600 * 24)); // Pass information about this user to the flate engine for display. view.add_iteration ("tbody", { diff --git a/manage/accounts.h b/manage/accounts.h index 8cdd3008f..fb2de22c5 100644 --- a/manage/accounts.h +++ b/manage/accounts.h @@ -24,5 +24,5 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. class Webserver_Request; std::string manage_accounts_url (); -bool manage_accounts_acl (void * webserver_request); -std::string manage_accounts (void * webserver_request); +bool manage_accounts_acl (Webserver_Request& webserver_request); +std::string manage_accounts (Webserver_Request& webserver_request); diff --git a/manage/index.cpp b/manage/index.cpp index 0e8daf669..e3ad2ab61 100644 --- a/manage/index.cpp +++ b/manage/index.cpp @@ -33,16 +33,16 @@ string manage_index_url () } -bool manage_index_acl (void * webserver_request) +bool manage_index_acl (Webserver_Request& webserver_request) { - return Filter_Roles::access_control (webserver_request, Filter_Roles::manager ()); + return Filter_Roles::access_control (std::addressof(webserver_request), Filter_Roles::manager ()); } -string manage_index (void * webserver_request) +string manage_index (Webserver_Request& webserver_request) { string page; - Assets_Header header = Assets_Header (translate("Manage"), webserver_request); + Assets_Header header = Assets_Header (translate("Manage"), std::addressof(webserver_request)); header.add_bread_crumb (menu_logic_settings_menu (), menu_logic_settings_text ()); page = header.run (); Assets_View view; diff --git a/manage/index.h b/manage/index.h index fa8ece8ba..f8344e108 100644 --- a/manage/index.h +++ b/manage/index.h @@ -24,5 +24,5 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. class Webserver_Request; std::string manage_index_url (); -bool manage_index_acl (void * webserver_request); -std::string manage_index (void * webserver_request); +bool manage_index_acl (Webserver_Request& webserver_request); +std::string manage_index (Webserver_Request& webserver_request); diff --git a/menu/logic.cpp b/menu/logic.cpp index 6c688ad61..8998fe2ab 100644 --- a/menu/logic.cpp +++ b/menu/logic.cpp @@ -788,7 +788,7 @@ string menu_logic_settings_category (void * webserver_request, string * tooltip) if (label == mail) { #ifndef HAVE_CLIENT - if (email_index_acl (webserver_request)) { + if (email_index_acl (*request)) { html.push_back (menu_logic_create_item (email_index_url (), label, true, "", "")); tiplabels.push_back (label); } @@ -796,14 +796,14 @@ string menu_logic_settings_category (void * webserver_request, string * tooltip) } if (label == styles) { - if (styles_indexm_acl (webserver_request)) { + if (styles_indexm_acl (*request)) { html.push_back (menu_logic_create_item (styles_indexm_url (), menu_logic_styles_text (), true, "", "")); tiplabels.push_back (menu_logic_styles_text ()); } } if (label == versifications) { - if (versification_index_acl (webserver_request)) { + if (versification_index_acl (*request)) { html.push_back (menu_logic_create_item (versification_index_url (), menu_logic_versification_index_text (), true, "", "")); tiplabels.push_back (menu_logic_versification_index_text ()); } @@ -896,7 +896,7 @@ string menu_logic_settings_category (void * webserver_request, string * tooltip) } if (label == system) { - if (system_index_acl (webserver_request)) { + if (system_index_acl (*request)) { html.push_back (menu_logic_create_item (system_index_url (), label, true, "", "")); tiplabels.push_back (label); } diff --git a/styles/indexm.cpp b/styles/indexm.cpp index 8a8d671e2..e66e5b1c3 100644 --- a/styles/indexm.cpp +++ b/styles/indexm.cpp @@ -46,19 +46,17 @@ string styles_indexm_url () } -bool styles_indexm_acl (void * webserver_request) +bool styles_indexm_acl (Webserver_Request& webserver_request) { - return Filter_Roles::access_control (webserver_request, Filter_Roles::translator ()); + return Filter_Roles::access_control (std::addressof(webserver_request), Filter_Roles::translator ()); } -string styles_indexm (void * webserver_request) +string styles_indexm (Webserver_Request& webserver_request) { - Webserver_Request * request = static_cast(webserver_request); - string page {}; - Assets_Header header = Assets_Header (translate("Styles"), webserver_request); + Assets_Header header = Assets_Header (translate("Styles"), std::addressof(webserver_request)); header.add_bread_crumb (menu_logic_settings_menu (), menu_logic_settings_text ()); page = header.run (); @@ -66,11 +64,11 @@ string styles_indexm (void * webserver_request) Database_Styles database_styles {}; - string username {request->session_logic ()->currentUser ()}; - int userlevel {request->session_logic ()->currentLevel ()}; + string username {webserver_request.session_logic ()->currentUser ()}; + int userlevel {webserver_request.session_logic ()->currentLevel ()}; - if (request->post.count ("new")) { - string name {request->post["entry"]}; + if (webserver_request.post.count ("new")) { + string name {webserver_request.post["entry"]}; // Remove spaces at the ends of the name for the new stylesheet. // Because predictive keyboards can add a space to the name, // and the stylesheet system is not built for whitespace at the start / end of the name of the stylesheet. @@ -85,16 +83,16 @@ string styles_indexm (void * webserver_request) page += assets_page::success (translate("The stylesheet has been created")); } } - if (request->query.count ("new")) { + if (webserver_request.query.count ("new")) { Dialog_Entry dialog_entry = Dialog_Entry ("indexm", translate("Please enter the name for the new stylesheet"), string(), "new", string()); page += dialog_entry.run(); return page; } - if (request->query.count ("delete")) { - string del {request->query ["delete"]}; + if (webserver_request.query.count ("delete")) { + string del {webserver_request.query ["delete"]}; if (!del.empty()) { - string confirm {request->query ["confirm"]}; + string confirm {webserver_request.query ["confirm"]}; if (confirm == "yes") { bool write = database_styles.hasWriteAccess (username, del); if (userlevel >= Filter_Roles::admin ()) write = true; diff --git a/styles/indexm.h b/styles/indexm.h index e8875b31a..2c584ed3c 100644 --- a/styles/indexm.h +++ b/styles/indexm.h @@ -24,5 +24,5 @@ class Webserver_Request; std::string styles_indexm_url (); -bool styles_indexm_acl (void * webserver_request); -std::string styles_indexm (void * webserver_request); +bool styles_indexm_acl (Webserver_Request& webserver_request); +std::string styles_indexm (Webserver_Request& webserver_request); diff --git a/styles/sheetm.cpp b/styles/sheetm.cpp index 9a08db829..aed2cc6dd 100644 --- a/styles/sheetm.cpp +++ b/styles/sheetm.cpp @@ -46,37 +46,35 @@ string styles_sheetm_url () } -bool styles_sheetm_acl (void * webserver_request) +bool styles_sheetm_acl (Webserver_Request& webserver_request) { - return Filter_Roles::access_control (webserver_request, Filter_Roles::translator ()); + return Filter_Roles::access_control (std::addressof(webserver_request), Filter_Roles::translator ()); } -string styles_sheetm (void * webserver_request) +string styles_sheetm (Webserver_Request& webserver_request) { - Webserver_Request * request = static_cast(webserver_request); - string page; - Assets_Header header = Assets_Header (translate("Stylesheet"), webserver_request); + Assets_Header header = Assets_Header (translate("Stylesheet"), std::addressof(webserver_request)); header.add_bread_crumb (menu_logic_settings_menu (), menu_logic_settings_text ()); header.add_bread_crumb (styles_indexm_url (), menu_logic_styles_indexm_text ()); page = header.run (); Assets_View view; - string name = request->query["name"]; + string name = webserver_request.query["name"]; view.set_variable ("name", filter::strings::escape_special_xml_characters (name)); Database_Styles database_styles; - string username = request->session_logic ()->currentUser (); - int userlevel = request->session_logic ()->currentLevel (); + string username = webserver_request.session_logic ()->currentUser (); + int userlevel = webserver_request.session_logic ()->currentLevel (); bool write = database_styles.hasWriteAccess (username, name); if (userlevel >= Filter_Roles::admin ()) write = true; - if (request->post.count ("new")) { - string newstyle = request->post["entry"]; + if (webserver_request.post.count ("new")) { + string newstyle = webserver_request.post["entry"]; vector existing_markers = database_styles.getMarkers (name); if (find (existing_markers.begin(), existing_markers.end(), newstyle) != existing_markers.end()) { page += assets_page::error (translate("This style already exists")); @@ -86,14 +84,14 @@ string styles_sheetm (void * webserver_request) page += assets_page::success (translate("The style has been created")); } } - if (request->query.count("new")) { + if (webserver_request.query.count("new")) { Dialog_Entry dialog_entry = Dialog_Entry ("sheetm", translate("Please enter the name for the new style"), "", "new", ""); dialog_entry.add_query ("name", name); page += dialog_entry.run (); return page; } - string del = request->query["delete"]; + string del = webserver_request.query["delete"]; if (del != "") { if (write) database_styles.deleteMarker (name, del); } diff --git a/styles/sheetm.h b/styles/sheetm.h index 56cda6798..baf828c31 100644 --- a/styles/sheetm.h +++ b/styles/sheetm.h @@ -24,5 +24,5 @@ class Webserver_Request; std::string styles_sheetm_url (); -bool styles_sheetm_acl (void * webserver_request); -std::string styles_sheetm (void * webserver_request); +bool styles_sheetm_acl (Webserver_Request& webserver_request); +std::string styles_sheetm (Webserver_Request& webserver_request); diff --git a/styles/view.cpp b/styles/view.cpp index 3833c3ba0..0cc166027 100644 --- a/styles/view.cpp +++ b/styles/view.cpp @@ -47,19 +47,17 @@ string styles_view_url () } -bool styles_view_acl (void * webserver_request) +bool styles_view_acl (Webserver_Request& webserver_request) { - return Filter_Roles::access_control (webserver_request, Filter_Roles::translator ()); + return Filter_Roles::access_control (std::addressof(webserver_request), Filter_Roles::translator ()); } -string styles_view (void * webserver_request) +string styles_view (Webserver_Request& webserver_request) { - Webserver_Request * request = static_cast(webserver_request); - string page {}; - Assets_Header header = Assets_Header (translate("Style"), webserver_request); + Assets_Header header = Assets_Header (translate("Style"), std::addressof(webserver_request)); header.add_bread_crumb (menu_logic_settings_menu (), menu_logic_settings_text ()); header.add_bread_crumb (styles_indexm_url (), menu_logic_styles_indexm_text ()); page = header.run (); @@ -67,11 +65,11 @@ string styles_view (void * webserver_request) Assets_View view {}; - string sheet = request->query ["sheet"]; + string sheet = webserver_request.query ["sheet"]; view.set_variable ("sheet", filter::strings::escape_special_xml_characters (sheet)); - string style = request->query ["style"]; + string style = webserver_request.query ["style"]; view.set_variable ("style", filter::strings::escape_special_xml_characters (style)); @@ -80,8 +78,8 @@ string styles_view (void * webserver_request) // Whether the logged-in user has write access to the stylesheet. - const string username = request->session_logic ()->currentUser (); - const int userlevel = request->session_logic ()->currentLevel (); + const string username = webserver_request.session_logic ()->currentUser (); + const int userlevel = webserver_request.session_logic ()->currentLevel (); bool write = database_styles.hasWriteAccess (username, sheet); if (userlevel >= Filter_Roles::admin ()) write = true; @@ -92,15 +90,15 @@ string styles_view (void * webserver_request) // The style's name. string name = marker_data.name; - if (request->query.count ("name")) { + if (webserver_request.query.count ("name")) { Dialog_Entry dialog_entry = Dialog_Entry ("view", translate("Please enter the name for the style"), name, "name", string()); dialog_entry.add_query ("sheet", sheet); dialog_entry.add_query ("style", style); page += dialog_entry.run (); return page; } - if (request->post.count ("name")) { - name = request->post["entry"]; + if (webserver_request.post.count ("name")) { + name = webserver_request.post["entry"]; if (write) { database_styles.updateName (sheet, style, name); style_is_edited = true; @@ -111,15 +109,15 @@ string styles_view (void * webserver_request) // The style's info. string info = marker_data.info; - if (request->query.count ("info")) { + if (webserver_request.query.count ("info")) { Dialog_Entry dialog_entry = Dialog_Entry ("view", translate("Please enter the description for the style"), info, "info", string()); dialog_entry.add_query ("sheet", sheet); dialog_entry.add_query ("style", style); page += dialog_entry.run (); return page; } - if (request->post.count("info")) { - info = request->post["entry"]; + if (webserver_request.post.count("info")) { + info = webserver_request.post["entry"]; if (write) { database_styles.updateInfo (sheet, style, info); style_is_edited = true; @@ -130,8 +128,8 @@ string styles_view (void * webserver_request) // The style's category. string category = marker_data.category; - if (request->query.count("category")) { - category = request->query["category"]; + if (webserver_request.query.count("category")) { + category = webserver_request.query["category"]; if (category.empty()) { Dialog_List dialog_list = Dialog_List ("view", translate("Would you like to change the category of this style?"),translate("Here are the various categories:"), translate("Please pick one.")); dialog_list.add_query ("sheet", sheet); @@ -169,8 +167,8 @@ string styles_view (void * webserver_request) // The style's type. int type = marker_data.type; - if (request->query.count ("type")) { - const string s = request->query["type"]; + if (webserver_request.query.count ("type")) { + const string s = webserver_request.query["type"]; type = filter::strings::convert_to_int (s); if (s.empty()) { Dialog_List dialog_list = Dialog_List ("view", translate("Would you like to change the type of this style?"), translate("Here are the various types:"), translate("Please pick one.")); @@ -197,8 +195,8 @@ string styles_view (void * webserver_request) // The style's subtype. int subtype = marker_data.subtype; - if (request->query.count ("subtype")) { - const string s = request->query["subtype"]; + if (webserver_request.query.count ("subtype")) { + const string s = webserver_request.query["subtype"]; subtype = filter::strings::convert_to_int (s); if (s.empty()) { Dialog_List dialog_list = Dialog_List ("view", translate("Would you like to change the sub type of this style?"), string(), string()); @@ -230,15 +228,15 @@ string styles_view (void * webserver_request) // The fontsize. if (styles_logic_fontsize_is_relevant (type, subtype)) view.enable_zone ("fontsize_relevant"); float fontsize = marker_data.fontsize; - if (request->query.count ("fontsize")) { + if (webserver_request.query.count ("fontsize")) { Dialog_Entry dialog_entry = Dialog_Entry ("view", translate("Please enter a fontsize between 5 and 60 points"), filter::strings::convert_to_string (fontsize), "fontsize", translate ("The value to enter is just a number, e.g. 12.")); dialog_entry.add_query ("sheet", sheet); dialog_entry.add_query ("style", style); page += dialog_entry.run (); return page; } - if (request->post.count("fontsize")) { - const float fs = filter::strings::convert_to_float (request->post["entry"]); + if (webserver_request.post.count("fontsize")) { + const float fs = filter::strings::convert_to_float (webserver_request.post["entry"]); if ((fs >= 5) && (fs <= 60)) { fontsize = fs; if (write) { @@ -258,8 +256,8 @@ string styles_view (void * webserver_request) // Italic. int italic = marker_data.italic; - if (request->query.count ("italic")) { - const string s = request->query["italic"]; + if (webserver_request.query.count ("italic")) { + const string s = webserver_request.query["italic"]; if (s.empty()) { Dialog_List dialog_list = Dialog_List ("view", translate("Would you like to change whether this style is in italics?"), string(), string()); dialog_list.add_query ("sheet", sheet); @@ -286,8 +284,8 @@ string styles_view (void * webserver_request) // Bold. int bold = marker_data.bold; - if (request->query.count ("bold")) { - const string s = request->query["bold"]; + if (webserver_request.query.count ("bold")) { + const string s = webserver_request.query["bold"]; if (s.empty()) { Dialog_List dialog_list = Dialog_List ("view", translate("Would you like to change whether this style is in bold?"), string(), string()); dialog_list.add_query ("sheet", sheet); @@ -314,8 +312,8 @@ string styles_view (void * webserver_request) // Underline. int underline = marker_data.underline; - if (request->query.count ("underline")) { - const string s = request->query["underline"]; + if (webserver_request.query.count ("underline")) { + const string s = webserver_request.query["underline"]; if (s.empty()) { Dialog_List dialog_list = Dialog_List ("view", translate("Would you like to change whether this style is underlined?"), string(), string()); dialog_list.add_query ("sheet", sheet); @@ -342,8 +340,8 @@ string styles_view (void * webserver_request) // Small caps. int smallcaps = marker_data.smallcaps; - if (request->query.count ("smallcaps")) { - const string s = request->query["smallcaps"]; + if (webserver_request.query.count ("smallcaps")) { + const string s = webserver_request.query["smallcaps"]; if (s.empty()) { Dialog_List dialog_list = Dialog_List ("view", translate("Would you like to change whether this style is in small caps?"), string(), string()); dialog_list.add_query ("sheet", sheet); @@ -371,8 +369,8 @@ string styles_view (void * webserver_request) // Superscript. if (styles_logic_superscript_is_relevant (type, subtype)) view.enable_zone ("superscript_relevant"); int superscript = marker_data.superscript; - if (request->query.count ("superscript")) { - superscript = filter::strings::convert_to_int (request->query["superscript"]); + if (webserver_request.query.count ("superscript")) { + superscript = filter::strings::convert_to_int (webserver_request.query["superscript"]); if (write) { database_styles.updateSuperscript (sheet, style, superscript); style_is_edited = true; @@ -388,7 +386,7 @@ string styles_view (void * webserver_request) // Text alignment. int justification = marker_data.justification; - if (request->query.count ("alignment")) { + if (webserver_request.query.count ("alignment")) { Dialog_List dialog_list = Dialog_List ("view", translate("Would you like to change the text alignment of this style?"), string(), string()); dialog_list.add_query ("sheet", sheet); dialog_list.add_query ("style", style); @@ -398,8 +396,8 @@ string styles_view (void * webserver_request) page += dialog_list.run (); return page; } - if (request->query.count ("justification")) { - justification = filter::strings::convert_to_int (request->query["justification"]); + if (webserver_request.query.count ("justification")) { + justification = filter::strings::convert_to_int (webserver_request.query["justification"]); if (write) { database_styles.updateJustification (sheet, style, justification); style_is_edited = true; @@ -410,15 +408,15 @@ string styles_view (void * webserver_request) // Space before paragraph. float spacebefore = marker_data.spacebefore; - if (request->query.count ("spacebefore")) { + if (webserver_request.query.count ("spacebefore")) { Dialog_Entry dialog_entry = Dialog_Entry ("view", translate("Please enter a space of between 0 and 100 mm before the paragraph"), filter::strings::convert_to_string (spacebefore), "spacebefore", translate ("This is the space before, or in other words, above the paragraph. The value to enter is just a number, e.g. 0.")); dialog_entry.add_query ("sheet", sheet); dialog_entry.add_query ("style", style); page += dialog_entry.run (); return page; } - if (request->post.count ("spacebefore")) { - spacebefore = filter::strings::convert_to_float (request->post["entry"]); + if (webserver_request.post.count ("spacebefore")) { + spacebefore = filter::strings::convert_to_float (webserver_request.post["entry"]); if (spacebefore < 0) spacebefore = 0; if (spacebefore > 100) spacebefore = 100; if (write) { @@ -431,15 +429,15 @@ string styles_view (void * webserver_request) // Space after paragraph. float spaceafter = marker_data.spaceafter; - if (request->query.count ("spaceafter")) { + if (webserver_request.query.count ("spaceafter")) { Dialog_Entry dialog_entry = Dialog_Entry ("view", translate("Please enter a space of between 0 and 100 mm after the paragraph"), filter::strings::convert_to_string (spaceafter), "spaceafter", translate ("This is the space after, or in other words, below the paragraph. The value to enter is just a number, e.g. 0.")); dialog_entry.add_query ("sheet", sheet); dialog_entry.add_query ("style", style); page += dialog_entry.run (); return page; } - if (request->post.count("spaceafter")) { - spaceafter = filter::strings::convert_to_float (request->post["entry"]); + if (webserver_request.post.count("spaceafter")) { + spaceafter = filter::strings::convert_to_float (webserver_request.post["entry"]); if (spaceafter < 0) spaceafter = 0; if (spaceafter > 100) spaceafter = 100; if (write) { @@ -452,15 +450,15 @@ string styles_view (void * webserver_request) // Left margin. float leftmargin = marker_data.leftmargin; - if (request->query.count ("leftmargin")) { + if (webserver_request.query.count ("leftmargin")) { Dialog_Entry dialog_entry = Dialog_Entry ("view", translate("Please enter a left margin of between -100 and 100 mm"), filter::strings::convert_to_string (leftmargin), "leftmargin", translate ("This is the left margin of the paragraph. The value to enter is just a number, e.g. 0.")); dialog_entry.add_query ("sheet", sheet); dialog_entry.add_query ("style", style); page += dialog_entry.run (); return page; } - if (request->post.count("leftmargin")) { - leftmargin = filter::strings::convert_to_float (request->post ["entry"]); + if (webserver_request.post.count("leftmargin")) { + leftmargin = filter::strings::convert_to_float (webserver_request.post ["entry"]); if (leftmargin < 0) leftmargin = 0; if (leftmargin > 100) leftmargin = 100; if (write) { @@ -473,15 +471,15 @@ string styles_view (void * webserver_request) // Right margin. float rightmargin = marker_data.rightmargin; - if (request->query.count ("rightmargin")) { + if (webserver_request.query.count ("rightmargin")) { Dialog_Entry dialog_entry = Dialog_Entry ("view", translate("Please enter a right margin of between -100 and 100 mm"), filter::strings::convert_to_string (rightmargin), "rightmargin", translate ("This is the right margin of the paragraph. The value to enter is just a number, e.g. 0.")); dialog_entry.add_query ("sheet", sheet); dialog_entry.add_query ("style", style); page += dialog_entry.run (); return page; } - if (request->post.count("rightmargin")) { - rightmargin = filter::strings::convert_to_float (request->post["entry"]); + if (webserver_request.post.count("rightmargin")) { + rightmargin = filter::strings::convert_to_float (webserver_request.post["entry"]); if (rightmargin < -100) rightmargin = -100; if (rightmargin > 100) rightmargin = 100; if (write) { @@ -494,15 +492,15 @@ string styles_view (void * webserver_request) // First line indent. float firstlineindent = marker_data.firstlineindent; - if (request->query.count ("firstlineindent")) { + if (webserver_request.query.count ("firstlineindent")) { Dialog_Entry dialog_entry = Dialog_Entry ("view", translate("Please enter a first line indent of between -100 and 100 mm"), filter::strings::convert_to_string (firstlineindent), "firstlineindent", translate ("This is the indent of the first line of the the paragraph. The value to enter is just a number, e.g. 0.")); dialog_entry.add_query ("sheet", sheet); dialog_entry.add_query ("style", style); page += dialog_entry.run (); return page; } - if (request->post.count ("firstlineindent")) { - firstlineindent = filter::strings::convert_to_float (request->post["entry"]); + if (webserver_request.post.count ("firstlineindent")) { + firstlineindent = filter::strings::convert_to_float (webserver_request.post["entry"]); if (firstlineindent < -100) firstlineindent = -100; if (firstlineindent > 100) firstlineindent = 100; if (write) { @@ -520,8 +518,8 @@ string styles_view (void * webserver_request) /* if (styles_logic_columns_are_relevant (type, subtype)) view.enable_zone ("columns_relevant"); bool spancolumns = marker_data.spancolumns; - if (request->query.count ("spancolumns")) { - spancolumns = filter::strings::convert_to_bool (request->query["spancolumns"]); + if (webserver_request.query.count ("spancolumns")) { + spancolumns = filter::strings::convert_to_bool (webserver_request.query["spancolumns"]); if (write) database_styles.updateSpanColumns (sheet, style, spancolumns); } view.set_variable ("spancolumns", styles_logic_off_on_inherit_toggle_text (spancolumns)); @@ -533,8 +531,8 @@ string styles_view (void * webserver_request) if (styles_logic_color_is_relevant (type, subtype)) view.enable_zone ("color_relevant"); string color = marker_data.color; - if (request->query.count ("fgcolor")) { - color = request->query["fgcolor"]; + if (webserver_request.query.count ("fgcolor")) { + color = webserver_request.query["fgcolor"]; if (color.find ("#") == std::string::npos) color.insert (0, "#"); if (color.length () != 7) color = "#000000"; if (write) { @@ -547,8 +545,8 @@ string styles_view (void * webserver_request) view.set_variable ("color", color); string backgroundcolor {marker_data.backgroundcolor}; - if (request->query.count ("bgcolor")) { - color = request->query["bgcolor"]; + if (webserver_request.query.count ("bgcolor")) { + color = webserver_request.query["bgcolor"]; if (color.find ("#") == std::string::npos) color.insert (0, "#"); if (color.length () != 7) color = "#FFFFFF"; if (write) { @@ -564,8 +562,8 @@ string styles_view (void * webserver_request) // Whether to print this style. if (styles_logic_print_is_relevant (type, subtype)) view.enable_zone ("print_relevant"); bool print {marker_data.print}; - if (request->query.count ("print")) { - print = filter::strings::convert_to_bool (request->query["print"]); + if (webserver_request.query.count ("print")) { + print = filter::strings::convert_to_bool (webserver_request.query["print"]); if (write) { database_styles.updatePrint (sheet, style, print); style_is_edited = true; @@ -580,8 +578,8 @@ string styles_view (void * webserver_request) if (userbool1_function.length () > 2) view.enable_zone ("userbool1_relevant"); view.set_variable ("userbool1_function", userbool1_function); bool userbool1 {marker_data.userbool1}; - if (request->query.count ("userbool1")) { - userbool1 = filter::strings::convert_to_bool (request->query["userbool1"]); + if (webserver_request.query.count ("userbool1")) { + userbool1 = filter::strings::convert_to_bool (webserver_request.query["userbool1"]); if (write) { database_styles.updateUserbool1 (sheet, style, userbool1); style_is_edited = true; @@ -596,8 +594,8 @@ string styles_view (void * webserver_request) if (userbool2_function.length () > 2) view.enable_zone ("userbool2_relevant"); view.set_variable ("userbool2_function", userbool2_function); bool userbool2 {marker_data.userbool2}; - if (request->query.count ("userbool2")) { - userbool2 = filter::strings::convert_to_bool (request->query["userbool2"]); + if (webserver_request.query.count ("userbool2")) { + userbool2 = filter::strings::convert_to_bool (webserver_request.query["userbool2"]); if (write) { database_styles.updateUserbool2 (sheet, style, userbool2); style_is_edited = true; @@ -612,8 +610,8 @@ string styles_view (void * webserver_request) if (userbool3_function.length () > 2) view.enable_zone ("userbool3_relevant"); view.set_variable ("userbool3_function", userbool3_function); bool userbool3 {marker_data.userbool3}; - if (request->query.count ("userbool3")) { - userbool3 = filter::strings::convert_to_bool (request->query["userbool3"]); + if (webserver_request.query.count ("userbool3")) { + userbool3 = filter::strings::convert_to_bool (webserver_request.query["userbool3"]); if (write) { database_styles.updateUserbool3 (sheet, style, userbool3); style_is_edited = true; @@ -630,7 +628,7 @@ string styles_view (void * webserver_request) break; case UserInt1NoteNumbering : view.enable_zone ("userint1_notenumbering"); - if (request->query.count ("notenumbering")) { + if (webserver_request.query.count ("notenumbering")) { Dialog_List dialog_list = Dialog_List ("view", translate("Would you like to change the numbering of the note?"), string(), string()); dialog_list.add_query ("sheet", sheet); dialog_list.add_query ("style", style); @@ -640,8 +638,8 @@ string styles_view (void * webserver_request) page += dialog_list.run (); return page; } - if (request->query.count ("userint1")) { - userint1 = filter::strings::convert_to_int (request->query["userint1"]); + if (webserver_request.query.count ("userint1")) { + userint1 = filter::strings::convert_to_int (webserver_request.query["userint1"]); if (write) { database_styles.updateUserint1 (sheet, style, userint1); style_is_edited = true; @@ -651,15 +649,15 @@ string styles_view (void * webserver_request) break; case UserInt1TableColumnNumber : view.enable_zone ("userint1_columnnumber"); - if (request->query.count ("userint1")) { + if (webserver_request.query.count ("userint1")) { Dialog_Entry dialog_entry = Dialog_Entry ("view", translate("Please enter a column number between 1 and 4"), filter::strings::convert_to_string (userint1), "userint1", translate ("This is the column number for the style. The first columm is number 1.")); dialog_entry.add_query ("sheet", sheet); dialog_entry.add_query ("style", style); page += dialog_entry.run (); return page; } - if (request->post.count ("userint1")) { - int value = filter::strings::convert_to_int (request->post["entry"]); + if (webserver_request.post.count ("userint1")) { + int value = filter::strings::convert_to_int (webserver_request.post["entry"]); if ((value >= 1) && (value <= 4)) { userint1 = value; if (write) { @@ -681,7 +679,7 @@ string styles_view (void * webserver_request) break; case UserInt2NoteNumberingRestart : view.enable_zone ("userint2_notenumberingrestart"); - if (request->query.count ("notenumberingrestart")) { + if (webserver_request.query.count ("notenumberingrestart")) { Dialog_List dialog_list = Dialog_List ("view", translate("Would you like to change when the note numbering restarts?"), string(), string()); dialog_list.add_query ("sheet", sheet); dialog_list.add_query ("style", style); @@ -691,8 +689,8 @@ string styles_view (void * webserver_request) page += dialog_list.run (); return page; } - if (request->query.count ("userint2")) { - userint2 = filter::strings::convert_to_int (request->query["userint2"]); + if (webserver_request.query.count ("userint2")) { + userint2 = filter::strings::convert_to_int (webserver_request.query["userint2"]); if (write) { database_styles.updateUserint2 (sheet, style, userint2); style_is_edited = true; @@ -702,7 +700,7 @@ string styles_view (void * webserver_request) break; case UserInt2EndnotePosition : view.enable_zone ("userint2_endnoteposition"); - if (request->query.count ("endnoteposition")) { + if (webserver_request.query.count ("endnoteposition")) { Dialog_List dialog_list = Dialog_List ("view", translate("Would you like to change the position where to dump the endnotes?"), string(), string()); dialog_list.add_query ("sheet", sheet); dialog_list.add_query ("style", style); @@ -712,8 +710,8 @@ string styles_view (void * webserver_request) page += dialog_list.run (); return page; } - if (request->query.count ("userint2")) { - userint2 = filter::strings::convert_to_int (request->query["userint2"]); + if (webserver_request.query.count ("userint2")) { + userint2 = filter::strings::convert_to_int (webserver_request.query["userint2"]); if (write) { database_styles.updateUserint2 (sheet, style, userint2); style_is_edited = true; @@ -749,15 +747,15 @@ string styles_view (void * webserver_request) break; default: break; } - if (request->query.count ("userstring1")) { + if (webserver_request.query.count ("userstring1")) { Dialog_Entry dialog_entry = Dialog_Entry ("view", userstring1_question, userstring1, "userstring1", userstring1_help); dialog_entry.add_query ("sheet", sheet); dialog_entry.add_query ("style", style); page += dialog_entry.run (); return page; } - if (request->post.count ("userstring1")) { - userstring1 = request->post["entry"]; + if (webserver_request.post.count ("userstring1")) { + userstring1 = webserver_request.post["entry"]; if (write) { database_styles.updateUserstring1 (sheet, style, userstring1); style_is_edited = true; @@ -783,15 +781,15 @@ string styles_view (void * webserver_request) break; default: break; } - if (request->query.count ("userstring2")) { + if (webserver_request.query.count ("userstring2")) { Dialog_Entry dialog_entry = Dialog_Entry ("view", userstring2_question, userstring2, "userstring2", userstring2_info); dialog_entry.add_query ("sheet", sheet); dialog_entry.add_query ("style", style); page += dialog_entry.run (); return page; } - if (request->post.count("userstring2")) { - userstring2 = request->post["entry"]; + if (webserver_request.post.count("userstring2")) { + userstring2 = webserver_request.post["entry"]; if (write) { database_styles.updateUserstring2 (sheet, style, userstring2); style_is_edited = true; diff --git a/styles/view.h b/styles/view.h index 2483c3850..f8e402ad1 100644 --- a/styles/view.h +++ b/styles/view.h @@ -24,5 +24,5 @@ class Webserver_Request; std::string styles_view_url (); -bool styles_view_acl (void * webserver_request); -std::string styles_view (void * webserver_request); +bool styles_view_acl (Webserver_Request& webserver_request); +std::string styles_view (Webserver_Request& webserver_request); diff --git a/system/googletranslate.cpp b/system/googletranslate.cpp index d9a7bf52f..3a9c9aaab 100644 --- a/system/googletranslate.cpp +++ b/system/googletranslate.cpp @@ -38,22 +38,20 @@ string system_googletranslate_url () } -bool system_googletranslate_acl ([[maybe_unused]] void * webserver_request) +bool system_googletranslate_acl (Webserver_Request& webserver_request) { - return Filter_Roles::access_control (webserver_request, Filter_Roles::manager ()); + return Filter_Roles::access_control (std::addressof(webserver_request), Filter_Roles::manager ()); } -string system_googletranslate (void * webserver_request) +string system_googletranslate (Webserver_Request& webserver_request) { -// Webserver_Request * request = static_cast(webserver_request); - string page {}; string success {}; string error {}; // The header. - Assets_Header header = Assets_Header (translate("Google Translate"), webserver_request); + Assets_Header header = Assets_Header (translate("Google Translate"), std::addressof(webserver_request)); header.add_bread_crumb (menu_logic_settings_menu (), menu_logic_settings_text ()); page = header.run (); diff --git a/system/googletranslate.h b/system/googletranslate.h index 98c3199d8..f070972c8 100644 --- a/system/googletranslate.h +++ b/system/googletranslate.h @@ -24,5 +24,5 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. class Webserver_Request; std::string system_googletranslate_url (); -bool system_googletranslate_acl (void * webserver_request); -std::string system_googletranslate (void * webserver_request); +bool system_googletranslate_acl (Webserver_Request& webserver_request); +std::string system_googletranslate (Webserver_Request& webserver_request); diff --git a/system/index.cpp b/system/index.cpp index 5ed9fc6ab..27c3ed8a3 100644 --- a/system/index.cpp +++ b/system/index.cpp @@ -55,23 +55,20 @@ std::string system_index_url () } -bool system_index_acl ([[maybe_unused]] void * webserver_request) +bool system_index_acl ([[maybe_unused]] Webserver_Request& webserver_request) { #ifdef HAVE_CLIENT // Client: Anyone can make system settings. return true; #else // Cloud: Manager can make system settings. - return Filter_Roles::access_control (webserver_request, Filter_Roles::manager ()); + return Filter_Roles::access_control (std::addressof(webserver_request), Filter_Roles::manager ()); #endif } -std::string system_index (void * webserver_request) +std::string system_index (Webserver_Request& webserver_request) { - Webserver_Request * request = static_cast(webserver_request); - - std::string page {}; std::string success {}; std::string error {}; @@ -79,14 +76,14 @@ std::string system_index (void * webserver_request) // User can set the system language. // This is to be done before displaying the header. - if (request->post.count ("languageselection")) { - std::string languageselection {request->post ["languageselection"]}; + if (webserver_request.post.count ("languageselection")) { + std::string languageselection {webserver_request.post ["languageselection"]}; Database_Config_General::setSiteLanguage (languageselection); } // The header: The language has been set already. - Assets_Header header = Assets_Header (translate("System"), webserver_request); + Assets_Header header = Assets_Header (translate("System"), std::addressof(webserver_request)); header.add_bread_crumb (menu_logic_settings_menu (), menu_logic_settings_text ()); page = header.run (); @@ -95,8 +92,8 @@ std::string system_index (void * webserver_request) // Get values for setting checkboxes. - const std::string checkbox = request->post ["checkbox"]; - [[maybe_unused]] const bool checked = filter::strings::convert_to_bool (request->post ["checked"]); + const std::string checkbox = webserver_request.post ["checkbox"]; + [[maybe_unused]] const bool checked = filter::strings::convert_to_bool (webserver_request.post ["checked"]); // The available localizations. @@ -117,8 +114,8 @@ std::string system_index (void * webserver_request) // Entry of time zone offset in hours. - if (request->post.count ("timezone")) { - std::string input = request->post ["timezone"]; + if (webserver_request.post.count ("timezone")) { + std::string input = webserver_request.post ["timezone"]; input = filter::strings::replace ("UTC", std::string(), input); int input_timezone = filter::strings::convert_to_int (input); input_timezone = clip (input_timezone, MINIMUM_TIMEZONE, MAXIMUM_TIMEZONE); @@ -166,9 +163,9 @@ std::string system_index (void * webserver_request) #ifdef HAVE_CLIENT - const bool producebibles = request->query.count ("producebibles"); - const bool producenotes = request->query.count ("producenotes"); - const bool produceresources = request->query.count ("produceresources"); + const bool producebibles = webserver_request.query.count ("producebibles"); + const bool producenotes = webserver_request.query.count ("producenotes"); + const bool produceresources = webserver_request.query.count ("produceresources"); if (producebibles || producenotes || produceresources) { Database_Jobs database_jobs; const int jobId = database_jobs.get_new_id (); @@ -186,10 +183,10 @@ std::string system_index (void * webserver_request) #ifdef HAVE_CLIENT const std::string importbibles = "importbibles"; - if (request->query.count (importbibles)) { - if (request->post.count ("upload")) { - const std::string datafile = filter_url_tempfile () + request->post ["filename"]; - const std::string data = request->post ["data"]; + if (webserver_request.query.count (importbibles)) { + if (webserver_request.post.count ("upload")) { + const std::string datafile = filter_url_tempfile () + webserver_request.post ["filename"]; + const std::string data = webserver_request.post ["data"]; if (!data.empty ()) { filter_url_file_put_contents (datafile, data); success = translate("Import has started."); @@ -210,10 +207,10 @@ std::string system_index (void * webserver_request) #ifdef HAVE_CLIENT const std::string importnotes = "importnotes"; - if (request->query.count (importnotes)) { - if (request->post.count ("upload")) { - const std::string datafile = filter_url_tempfile () + request->post ["filename"]; - const std::string data = request->post ["data"]; + if (webserver_request.query.count (importnotes)) { + if (webserver_request.post.count ("upload")) { + const std::string datafile = filter_url_tempfile () + webserver_request.post ["filename"]; + const std::string data = webserver_request.post ["data"]; if (!data.empty ()) { filter_url_file_put_contents (datafile, data); success = translate("Import has started."); @@ -234,10 +231,10 @@ std::string system_index (void * webserver_request) #ifdef HAVE_CLIENT const std::string importresources = "importresources"; - if (request->query.count (importresources)) { - if (request->post.count ("upload")) { - const std::string datafile = filter_url_tempfile () + request->post ["filename"]; - const std::string data = request->post ["data"]; + if (webserver_request.query.count (importresources)) { + if (webserver_request.post.count ("upload")) { + const std::string datafile = filter_url_tempfile () + webserver_request.post ["filename"]; + const std::string data = webserver_request.post ["data"]; if (!data.empty ()) { filter_url_file_put_contents (datafile, data); success = translate("Import has started."); @@ -257,29 +254,29 @@ std::string system_index (void * webserver_request) // Force re-index Bibles. - if (request->query ["reindex"] == "bibles") { + if (webserver_request.query ["reindex"] == "bibles") { Database_Config_General::setIndexBibles (true); tasks_logic_queue (REINDEXBIBLES, {"1"}); - redirect_browser (request, journal_index_url ()); + redirect_browser (std::addressof(webserver_request), journal_index_url ()); return std::string(); } // Re-index consultation notes. - if (request->query ["reindex"] == "notes") { + if (webserver_request.query ["reindex"] == "notes") { Database_Config_General::setIndexNotes (true); tasks_logic_queue (REINDEXNOTES); - redirect_browser (request, journal_index_url ()); + redirect_browser (std::addressof(webserver_request), journal_index_url ()); return std::string(); } // Delete a font. - const std::string deletefont = request->query ["deletefont"]; + const std::string deletefont = webserver_request.query ["deletefont"]; if (!deletefont.empty ()) { const std::string font = filter_url_basename_web (deletefont); bool font_in_use = false; - const std::vector bibles = request->database_bibles()->get_bibles (); + const std::vector bibles = webserver_request.database_bibles()->get_bibles (); for (const auto& bible : bibles) { if (font == fonts::logic::get_text_font (bible)) font_in_use = true; } @@ -293,10 +290,10 @@ std::string system_index (void * webserver_request) // Upload a font. - if (request->post.count ("uploadfont")) { - const std::string filename = request->post ["filename"]; + if (webserver_request.post.count ("uploadfont")) { + const std::string filename = webserver_request.post ["filename"]; const std::string path = filter_url_create_root_path ({"fonts", filename}); - const std::string fontdata = request->post ["fontdata"]; + const std::string fontdata = webserver_request.post ["fontdata"]; filter_url_file_put_contents (path, fontdata); success = translate("The font has been uploaded."); } @@ -317,9 +314,9 @@ std::string system_index (void * webserver_request) // Handle the command to clear the web and resources caches. - if (request->query.count ("clearcache")) { + if (webserver_request.query.count ("clearcache")) { tasks_logic_queue (CLEARCACHES); - redirect_browser (request, journal_index_url ()); + redirect_browser (std::addressof(webserver_request), journal_index_url ()); return std::string(); } @@ -336,8 +333,8 @@ std::string system_index (void * webserver_request) // Handle display the number of unsent emails and clearing them. #ifdef HAVE_CLOUD - Database_Mail database_mail (webserver_request); - if (request->query.count ("clearemails")) { + Database_Mail database_mail (std::addressof(webserver_request)); + if (webserver_request.query.count ("clearemails")) { const std::vector mails = database_mail.getAllMails (); for (auto rowid : mails) { database_mail.erase (rowid); diff --git a/system/index.h b/system/index.h index f08af4c4c..2c044ee29 100644 --- a/system/index.h +++ b/system/index.h @@ -27,5 +27,5 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. class Webserver_Request; std::string system_index_url (); -bool system_index_acl (void * webserver_request); -std::string system_index (void * webserver_request); +bool system_index_acl (Webserver_Request& webserver_request); +std::string system_index (Webserver_Request& webserver_request); diff --git a/versification/index.cpp b/versification/index.cpp index 285c45b25..32c0d48b6 100644 --- a/versification/index.cpp +++ b/versification/index.cpp @@ -37,19 +37,17 @@ string versification_index_url () } -bool versification_index_acl (void * webserver_request) +bool versification_index_acl (Webserver_Request& webserver_request) { - return Filter_Roles::access_control (webserver_request, Filter_Roles::manager ()); + return Filter_Roles::access_control (std::addressof(webserver_request), Filter_Roles::manager ()); } -string versification_index (void * webserver_request) +string versification_index (Webserver_Request& webserver_request) { - Webserver_Request * request = static_cast(webserver_request); - string page; - Assets_Header header = Assets_Header (translate("Versifications"), webserver_request); + Assets_Header header = Assets_Header (translate("Versifications"), std::addressof(webserver_request)); header.add_bread_crumb (menu_logic_settings_menu (), menu_logic_settings_text ()); page = header.run (); @@ -57,19 +55,19 @@ string versification_index (void * webserver_request) Database_Versifications database_versifications = Database_Versifications(); - if (request->post.count ("new")) { - string name = request->post["entry"]; + if (webserver_request.post.count ("new")) { + string name = webserver_request.post["entry"]; database_versifications.createSystem (name); } - if (request->query.count ("new")) { + if (webserver_request.query.count ("new")) { Dialog_Entry dialog_entry = Dialog_Entry ("index", translate("Please enter the name for the new versification system"), "", "new", ""); page += dialog_entry.run(); return page; } - if (request->query.count ("delete")) { - string name = request->query ["delete"]; - string confirm = request->query ["confirm"]; + if (webserver_request.query.count ("delete")) { + string name = webserver_request.query ["delete"]; + string confirm = webserver_request.query ["confirm"]; if (confirm == "yes") { database_versifications.erase (name); } else if (confirm == "cancel") { diff --git a/versification/index.h b/versification/index.h index 302099dfd..f61092cee 100644 --- a/versification/index.h +++ b/versification/index.h @@ -24,5 +24,5 @@ class Webserver_Request; std::string versification_index_url (); -bool versification_index_acl (void * webserver_request); -std::string versification_index (void * webserver_request); +bool versification_index_acl (Webserver_Request& webserver_request); +std::string versification_index (Webserver_Request& webserver_request); diff --git a/versification/system.cpp b/versification/system.cpp index 655a1c95e..f544e309f 100644 --- a/versification/system.cpp +++ b/versification/system.cpp @@ -40,19 +40,17 @@ string versification_system_url () } -bool versification_system_acl (void * webserver_request) +bool versification_system_acl (Webserver_Request& webserver_request) { - return Filter_Roles::access_control (webserver_request, Filter_Roles::manager ()); + return Filter_Roles::access_control (std::addressof(webserver_request), Filter_Roles::manager ()); } -string versification_system (void * webserver_request) +string versification_system (Webserver_Request& webserver_request) { - Webserver_Request * request = static_cast(webserver_request); - string page; - Assets_Header header = Assets_Header (translate("Versification system"), webserver_request); + Assets_Header header = Assets_Header (translate("Versification system"), std::addressof(webserver_request)); header.add_bread_crumb (menu_logic_settings_menu (), menu_logic_settings_text ()); header.add_bread_crumb (versification_index_url (), menu_logic_versification_index_text ()); page = header.run (); @@ -61,11 +59,11 @@ string versification_system (void * webserver_request) Database_Versifications database_versifications = Database_Versifications(); - string name = request->query["name"]; + string name = webserver_request.query["name"]; view.set_variable ("name", filter::strings::escape_special_xml_characters (name)); - if (request->post.count ("submit")) { - string data = request->post["data"]; + if (webserver_request.post.count ("submit")) { + string data = webserver_request.post["data"]; if (data != "") { database_versifications.input (data, name); } diff --git a/versification/system.h b/versification/system.h index 19c9eae47..70c9382f3 100644 --- a/versification/system.h +++ b/versification/system.h @@ -24,5 +24,5 @@ class Webserver_Request; std::string versification_system_url (); -bool versification_system_acl (void * webserver_request); -std::string versification_system (void * webserver_request); +bool versification_system_acl (Webserver_Request& webserver_request); +std::string versification_system (Webserver_Request& webserver_request);