summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authormsquare <msquare@notrademark.de>2016-09-27 17:49:13 +0200
committermsquare <msquare@notrademark.de>2016-09-27 17:49:39 +0200
commit031fc3057c46245cd62fc39f2d11ee3f0a393e06 (patch)
treeba0b4fbf68e7bc8e706d1ee6dd8b9d2987dd9c65 /includes
parent45bbf95972777e9499996d56a873c2a304815b3f (diff)
rename settings to event config and implement mvc pattern on it
Diffstat (limited to 'includes')
-rw-r--r--includes/controller/event_config_controller.php (renamed from includes/pages/admin_settings.php)53
-rw-r--r--includes/engelsystem_provider.php4
-rw-r--r--includes/model/EventConfig_model.php (renamed from includes/model/Settings_model.php)10
-rw-r--r--includes/sys_menu.php2
-rw-r--r--includes/view/EventConfigView.php41
5 files changed, 69 insertions, 41 deletions
diff --git a/includes/pages/admin_settings.php b/includes/controller/event_config_controller.php
index ebee1305..7e951214 100644
--- a/includes/pages/admin_settings.php
+++ b/includes/controller/event_config_controller.php
@@ -1,10 +1,15 @@
<?php
-function admin_settings_title() {
- return _("Settings");
+function event_config_title() {
+ return _("Event config");
}
-function admin_settings() {
+function event_config_edit_controller() {
+ global $privileges;
+
+ if (! in_array('admin_event_config', $privileges))
+ redirect('?');
+
$event_name = null;
$event_welcome_msg = null;
$buildup_start_date = null;
@@ -12,9 +17,9 @@ function admin_settings() {
$event_end_date = null;
$teardown_end_date = null;
- $settings_source = Settings();
+ $settings_source = EventConfig();
if ($settings_source === false)
- engelsystem_error('Unable to load settings.');
+ engelsystem_error('Unable to load event config.');
if ($settings_source != null) {
$event_name = $settings_source['event_name'];
$buildup_start_date = $settings_source['buildup_start_date'];
@@ -54,41 +59,21 @@ function admin_settings() {
$ok &= $result->isOk();
if ($ok) {
- $result = Settings_update($event_name, $buildup_start_date, $event_start_date, $event_end_date, $teardown_end_date, $event_welcome_msg);
+ $result = EventConfig_update($event_name, $buildup_start_date, $event_start_date, $event_end_date, $teardown_end_date, $event_welcome_msg);
if ($result === false)
- engelsystem_error("Unable to update settings.");
+ engelsystem_error("Unable to update event config.");
+ engelsystem_log("Changed event config: $event_name, $event_welcome_msg, $buildup_start_date, $event_start_date, $event_end_date, $teardown_end_date");
success(_("Settings saved."));
redirect(page_link_to('admin_settings'));
}
}
- return page_with_title(admin_settings_title(), [
- msg(),
- form([
- div('row', [
- div('col-md-6', [
- form_text('event_name', _("Event Name"), $event_name),
- form_info('', _("Event Name is shown on the start page.")),
- form_textarea('event_welcome_msg', _("Event Welcome Message"), $event_welcome_msg),
- form_info('', _("Welcome message is shown after successful registration. You can use markdown."))
- ]),
- div('col-md-3', [
- form_date('buildup_start_date', _("Buildup date"), $buildup_start_date),
- form_date('event_start_date', _("Event start date"), $event_start_date)
- ]),
- div('col-md-3', [
- form_date('teardown_end_date', _("Teardown end date"), $teardown_end_date),
- form_date('event_end_date', _("Event end date"), $event_end_date)
- ])
- ]),
- div('row', [
- div('col-md-6', [
- form_submit('submit', _("Save"))
- ])
- ])
- ])
- ]);
+ return [
+ event_config_title(),
+ EventConfig_edit_view($event_name, $event_welcome_msg, $buildup_start_date, $event_start_date, $event_end_date, $teardown_end_date)
+ ];
}
-?>
+
+?> \ No newline at end of file
diff --git a/includes/engelsystem_provider.php b/includes/engelsystem_provider.php
index 70d40ce3..5e293366 100644
--- a/includes/engelsystem_provider.php
+++ b/includes/engelsystem_provider.php
@@ -11,6 +11,7 @@ require_once realpath(__DIR__ . '/../includes/sys_page.php');
require_once realpath(__DIR__ . '/../includes/sys_template.php');
require_once realpath(__DIR__ . '/../includes/model/AngelType_model.php');
+require_once realpath(__DIR__ . '/../includes/model/EventConfig_model.php');
require_once realpath(__DIR__ . '/../includes/model/LogEntries_model.php');
require_once realpath(__DIR__ . '/../includes/model/Message_model.php');
require_once realpath(__DIR__ . '/../includes/model/NeededAngelTypes_model.php');
@@ -22,9 +23,9 @@ require_once realpath(__DIR__ . '/../includes/model/UserAngelTypes_model.php');
require_once realpath(__DIR__ . '/../includes/model/UserDriverLicenses_model.php');
require_once realpath(__DIR__ . '/../includes/model/UserGroups_model.php');
require_once realpath(__DIR__ . '/../includes/model/User_model.php');
-require_once realpath(__DIR__ . '/../includes/model/Settings_model.php');
require_once realpath(__DIR__ . '/../includes/view/AngelTypes_view.php');
+require_once realpath(__DIR__ . '/../includes/view/EventConfig_view.php');
require_once realpath(__DIR__ . '/../includes/view/Questions_view.php');
require_once realpath(__DIR__ . '/../includes/view/Rooms_view.php');
require_once realpath(__DIR__ . '/../includes/view/Shifts_view.php');
@@ -35,6 +36,7 @@ require_once realpath(__DIR__ . '/../includes/view/UserDriverLicenses_view.php')
require_once realpath(__DIR__ . '/../includes/view/User_view.php');
require_once realpath(__DIR__ . '/../includes/controller/angeltypes_controller.php');
+require_once realpath(__DIR__ . '/../includes/controller/event_config_controller.php');
require_once realpath(__DIR__ . '/../includes/controller/rooms_controller.php');
require_once realpath(__DIR__ . '/../includes/controller/shifts_controller.php');
require_once realpath(__DIR__ . '/../includes/controller/shifttypes_controller.php');
diff --git a/includes/model/Settings_model.php b/includes/model/EventConfig_model.php
index 07e3b677..57ba1d0f 100644
--- a/includes/model/Settings_model.php
+++ b/includes/model/EventConfig_model.php
@@ -3,8 +3,8 @@
/**
* Get settings.
*/
-function Settings() {
- $settings = sql_select("SELECT * FROM `Settings` LIMIT 1");
+function EventConfig() {
+ $settings = sql_select("SELECT * FROM `EventConfig` LIMIT 1");
if ($settings === false)
return false;
if (count($settings) > 0)
@@ -22,9 +22,9 @@ function Settings() {
* @param int $teardown_end_date
* @param string $event_welcome_msg
*/
-function Settings_update($event_name, $buildup_start_date, $event_start_date, $event_end_date, $teardown_end_date, $event_welcome_msg) {
+function EventConfig_update($event_name, $buildup_start_date, $event_start_date, $event_end_date, $teardown_end_date, $event_welcome_msg) {
if (Settings() == null) {
- return sql_query("INSERT INTO `Settings` SET
+ return sql_query("INSERT INTO `EventConfig` SET
`event_name`=" . sql_null($event_name) . ",
`buildup_start_date`=" . sql_null($buildup_start_date) . ",
`event_start_date`=" . sql_null($event_start_date) . ",
@@ -32,7 +32,7 @@ function Settings_update($event_name, $buildup_start_date, $event_start_date, $e
`teardown_end_date`=" . sql_null($teardown_end_date) . ",
`event_welcome_msg`=" . sql_null($event_welcome_msg));
}
- return sql_query("UPDATE `Settings` SET
+ return sql_query("UPDATE `EventConfig` SET
`event_name`=" . sql_null($event_name) . ",
`buildup_start_date`=" . sql_null($buildup_start_date) . ",
`event_start_date`=" . sql_null($event_start_date) . ",
diff --git a/includes/sys_menu.php b/includes/sys_menu.php
index 96522fa7..c6e916b4 100644
--- a/includes/sys_menu.php
+++ b/includes/sys_menu.php
@@ -126,7 +126,7 @@ function make_navigation() {
"admin_groups" => admin_groups_title(),
"admin_import" => admin_import_title(),
"admin_log" => admin_log_title(),
- "admin_settings" => admin_settings_title()
+ "admin_event_config" => event_config_title()
);
foreach ($admin_pages as $page => $title)
diff --git a/includes/view/EventConfigView.php b/includes/view/EventConfigView.php
new file mode 100644
index 00000000..a00a26ed
--- /dev/null
+++ b/includes/view/EventConfigView.php
@@ -0,0 +1,41 @@
+<?php
+
+/**
+ * Render edit page for event config.
+ * @param string $event_name The event name
+ * @param string $event_welcome_msg The welcome message
+ * @param date $buildup_start_date
+ * @param date $event_start_date
+ * @param date $event_end_date
+ * @param date $teardown_end_date
+ */
+function EventConfig_edit_view($event_name, $event_welcome_msg, $buildup_start_date, $event_start_date, $event_end_date, $teardown_end_date) {
+ return page_with_title(admin_settings_title(), [
+ msg(),
+ form([
+ div('row', [
+ div('col-md-6', [
+ form_text('event_name', _("Event Name"), $event_name),
+ form_info('', _("Event Name is shown on the start page.")),
+ form_textarea('event_welcome_msg', _("Event Welcome Message"), $event_welcome_msg),
+ form_info('', _("Welcome message is shown after successful registration. You can use markdown."))
+ ]),
+ div('col-md-3', [
+ form_date('buildup_start_date', _("Buildup date"), $buildup_start_date),
+ form_date('event_start_date', _("Event start date"), $event_start_date)
+ ]),
+ div('col-md-3', [
+ form_date('teardown_end_date', _("Teardown end date"), $teardown_end_date),
+ form_date('event_end_date', _("Event end date"), $event_end_date)
+ ])
+ ]),
+ div('row', [
+ div('col-md-6', [
+ form_submit('submit', _("Save"))
+ ])
+ ])
+ ])
+ ]);
+}
+
+?> \ No newline at end of file