Added Feature Admin Settings Page
parent
99c8751059
commit
8a20b43f6d
@ -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) . "'");
|
||||
}
|
||||
?>
|
@ -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"))
|
||||
))
|
||||
))
|
||||
))
|
||||
));
|
||||
}
|
||||
?>
|
Loading…
Reference in New Issue