summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--db/update.sql17
-rw-r--r--includes/engelsystem_provider.php2
-rw-r--r--includes/model/Settings_model.php40
-rw-r--r--includes/pages/admin_settings.php87
-rw-r--r--includes/sys_menu.php3
-rw-r--r--public/index.php3
6 files changed, 151 insertions, 1 deletions
diff --git a/db/update.sql b/db/update.sql
index ae9c68d7..ba0227d4 100644
--- a/db/update.sql
+++ b/db/update.sql
@@ -13,3 +13,20 @@ ALTER TABLE `UserDriverLicenses`
ADD CONSTRAINT `userdriverlicenses_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `User` (`UID`) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE `AngelTypes` ADD `requires_driver_license` BOOLEAN NOT NULL;
+
+-- ---------------------------------------------------------------------------------
+-- Settings table
+DROP TABLE IF EXISTS `Settings`;
+CREATE TABLE IF NOT EXISTS `Settings` (
+ `event_name` varchar(255) DEFAULT NULL,
+ `buildup_start_date` int(11) DEFAULT NULL,
+ `event_start_date` int(11) DEFAULT NULL,
+ `event_end_date` int(11) DEFAULT NULL,
+ `teardown_end_date` int(11) DEFAULT NULL,
+ `event_welcome_msg` varchar(255) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 ;
+
+-- Added privilege for Admin Settings
+INSERT INTO `Privileges` (`id`, `name`, `desc`) VALUES (39, 'admin_settings', 'Settings Page for Admin');
+
+INSERT INTO `GroupPrivileges` (`id`, `group_id`, `privilege_id`) VALUES (218, -4, 39);
diff --git a/includes/engelsystem_provider.php b/includes/engelsystem_provider.php
index fa5e86a4..70d40ce3 100644
--- a/includes/engelsystem_provider.php
+++ b/includes/engelsystem_provider.php
@@ -22,6 +22,7 @@ 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/Questions_view.php');
@@ -76,6 +77,7 @@ require_once realpath(__DIR__ . '/../includes/pages/user_news.php');
require_once realpath(__DIR__ . '/../includes/pages/user_questions.php');
require_once realpath(__DIR__ . '/../includes/pages/user_settings.php');
require_once realpath(__DIR__ . '/../includes/pages/user_shifts.php');
+require_once realpath(__DIR__ . '/../includes/pages/admin_settings.php');
require_once realpath(__DIR__ . '/../vendor/parsedown/Parsedown.php');
diff --git a/includes/model/Settings_model.php b/includes/model/Settings_model.php
new file mode 100644
index 00000000..2351e8c7
--- /dev/null
+++ b/includes/model/Settings_model.php
@@ -0,0 +1,40 @@
+<?php
+/**
+ * Update Setting.
+ *
+ * @param string $event_name
+ * @param int $buildup_start_date
+ * @param int $event_start_date
+ * @param int $event_end_date
+ * @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) {
+ return sql_query("UPDATE `Settings` SET
+ `event_name`='" . sql_escape($event_name) . "',
+ `buildup_start_date`='" . sql_escape($buildup_start_date) . "',
+ `event_start_date`='" . sql_escape($event_start_date) . "',
+ `event_end_date`='" . sql_escape($event_end_date) . "',
+ `teardown_end_date`='" . sql_escape($teardown_end_date) . "',
+ `event_welcome_msg`='" . sql_escape($event_welcome_msg) . "'");
+}
+/**
+ * Create Settings.
+ *
+ * @param string $event_name
+ * @param int $buildup_start_date
+ * @param int $event_start_date
+ * @param int $event_end_date
+ * @param int $teardown_end_date
+ * @param string $event_welcome_msg
+ */
+function Settings_create($event_name, $buildup_start_date, $event_start_date, $event_end_date, $teardown_end_date, $event_welcome_msg) {
+ return sql_query("INSERT INTO `Settings` SET
+ `event_name`='" . sql_escape($event_name) . "',
+ `buildup_start_date`='" . sql_escape($buildup_start_date) . "',
+ `event_start_date`='" . sql_escape($event_start_date) . "',
+ `event_end_date`='" . sql_escape($event_end_date) . "',
+ `teardown_end_date`='" . sql_escape($teardown_end_date) . "',
+ `event_welcome_msg`='" . sql_escape($event_welcome_msg) . "'");
+}
+?>
diff --git a/includes/pages/admin_settings.php b/includes/pages/admin_settings.php
new file mode 100644
index 00000000..6a78f97b
--- /dev/null
+++ b/includes/pages/admin_settings.php
@@ -0,0 +1,87 @@
+<?php
+function admin_settings_title() {
+ return _("Settings");
+}
+function admin_settings() {
+ $settings_source = sql_select("SELECT * FROM `Settings`");
+ if (count($settings_source) == 1) {
+ $event_name = $settings_source[0]['event_name'];
+ $buildup_start_date = $settings_source[0]['buildup_start_date'];
+ $event_start_date = $settings_source[0]['event_start_date'];
+ $event_end_date = $settings_source[0]['event_end_date'];
+ $teardown_end_date = $settings_source[0]['teardown_end_date'];
+ $event_welcome_msg = $settings_source[0]['event_welcome_msg'];
+ }
+ if (isset($_REQUEST['submit'])) {
+ $ok = true;
+ if (isset($_REQUEST['event_name']))
+ $event_name = strip_request_item('event_name');
+ if (isset($_REQUEST['buildup_start_date']) && $_REQUEST['buildup_start_date'] != '') {
+ if (DateTime::createFromFormat("Y-m-d", trim($_REQUEST['buildup_start_date']))) {
+ $buildup_start_date = DateTime::createFromFormat("Y-m-d", trim($_REQUEST['buildup_start_date']))->getTimestamp();
+ } else {
+ $ok = false;
+ $msg .= error(_("Please enter buildup start date."), true);
+ }
+ } else
+ $buildup_start_date = null;
+ if (isset($_REQUEST['event_start_date']) && $_REQUEST['event_start_date'] != '') {
+ if (DateTime::createFromFormat("Y-m-d", trim($_REQUEST['event_start_date']))) {
+ $event_start_date = DateTime::createFromFormat("Y-m-d", trim($_REQUEST['event_start_date']))->getTimestamp();
+ } else {
+ $ok = false;
+ $msg .= error(_("Please enter event start date."), true);
+ }
+ } else
+ $event_start_date = null;
+ if (isset($_REQUEST['event_end_date']) && $_REQUEST['event_end_date'] != '') {
+ if (DateTime::createFromFormat("Y-m-d", trim($_REQUEST['event_end_date']))) {
+ $event_end_date = DateTime::createFromFormat("Y-m-d", trim($_REQUEST['event_end_date']))->getTimestamp();
+ } else {
+ $ok = false;
+ $msg .= error(_("Please enter event end date."), true);
+ }
+ } else
+ $event_end_date = null;
+ if (isset($_REQUEST['teardown_end_date']) && $_REQUEST['teardown_end_date'] != '') {
+ if (DateTime::createFromFormat("Y-m-d", trim($_REQUEST['teardown_end_date']))) {
+ $teardown_end_date = DateTime::createFromFormat("Y-m-d", trim($_REQUEST['teardown_end_date']))->getTimestamp();
+ } else {
+ $ok = false;
+ $msg .= error(_("Please enter teardown end date."), true);
+ }
+ } else
+ $teardown_end_date = null;
+ if (isset($_REQUEST['event_welcome_msg']))
+ $event_welcome_msg = strip_request_item('event_welcome_msg');
+}
+if ($ok) {
+ if (count($settings_source) == 1)
+ Settings_update($event_name, $buildup_start_date, $event_start_date, $event_end_date, $teardown_end_date, $event_welcome_msg);
+ else
+ Settings_create($event_name, $buildup_start_date, $event_start_date, $event_end_date, $teardown_end_date, $event_welcome_msg);
+
+ success(_("Settings saved."));
+ redirect(page_link_to('admin_settings'));
+}
+ return page_with_title(admin_settings_title(), array(
+ $msg,
+ msg(),
+ div('row', array(
+ div('col-md-12', array(
+ form(array(
+ form_info('', _("Here you can change event information.")),
+ form_text('event_name', _("Event Name"), $event_name),
+ form_date('buildup_start_date', _("Buildup date"), $buildup_start_date, time()),
+ form_date('event_start_date', _("Event start date"), $event_start_date, time()),
+ form_date('event_end_date', _("Event end date"), $event_end_date, time()),
+ form_date('teardown_end_date', _("Teardown end date"), $teardown_end_date, time()),
+ form_info('', _("Here you can write your display message for registration:")),
+ form_text('event_welcome_msg', _("Event Welcome Message"), $event_welcome_msg),
+ form_submit('submit', _("Save"))
+ ))
+ ))
+ ))
+ ));
+}
+?>
diff --git a/includes/sys_menu.php b/includes/sys_menu.php
index b475136d..cf5b76fc 100644
--- a/includes/sys_menu.php
+++ b/includes/sys_menu.php
@@ -125,7 +125,8 @@ function make_navigation() {
"admin_rooms" => admin_rooms_title(),
"admin_groups" => admin_groups_title(),
"admin_import" => admin_import_title(),
- "admin_log" => admin_log_title()
+ "admin_log" => admin_log_title(),
+ "admin_settings" => admin_settings_title()
);
foreach ($admin_pages as $page => $title)
diff --git a/public/index.php b/public/index.php
index 08bbaead..0d7eb782 100644
--- a/public/index.php
+++ b/public/index.php
@@ -133,6 +133,9 @@ if (isset($_REQUEST['p']) && preg_match("/^[a-z0-9_]*$/i", $_REQUEST['p']) && (i
} elseif ($p == "admin_log") {
$title = admin_log_title();
$content = admin_log();
+ } elseif ($p == "admin_settings") {
+ $title = admin_settings_title();
+ $content = admin_settings();
} elseif ($p == "credits") {
require_once realpath(__DIR__ . '/../includes/pages/guest_credits.php');
$title = credits_title();