Merge branch 'pr/316' into feature-igel-rewrite
commit
56814fa2fd
@ -1,6 +0,0 @@
|
||||
[submodule "vendor/parsedown"]
|
||||
path = vendor/parsedown
|
||||
url = https://github.com/erusev/parsedown.git
|
||||
[submodule "vendor/bootstrap"]
|
||||
path = themes/assets/bootstrap
|
||||
url = https://github.com/twbs/bootstrap.git
|
||||
@ -0,0 +1,29 @@
|
||||
{
|
||||
"name": "engelsystem/engelsystem",
|
||||
"description": "Shift planning system for chaos events",
|
||||
"type": "project",
|
||||
"license": "GPL-2.0",
|
||||
"authors": [
|
||||
{
|
||||
"name": "msquare",
|
||||
"email": "msquare@notrademark.de"
|
||||
},
|
||||
{
|
||||
"name": "MyIgel",
|
||||
"email": "igor.scheller@igorshp.de"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.4",
|
||||
"erusev/parsedown": "1.6.*",
|
||||
"twbs/bootstrap": "^3.3"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Engelsystem\\": "src/"
|
||||
},
|
||||
"files": [
|
||||
"src/helpers.php"
|
||||
]
|
||||
}
|
||||
}
|
||||
@ -1,103 +1,127 @@
|
||||
<?php
|
||||
|
||||
function event_config_title() {
|
||||
return _("Event config");
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
function event_config_title()
|
||||
{
|
||||
return _('Event config');
|
||||
}
|
||||
|
||||
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;
|
||||
$event_start_date = null;
|
||||
$event_end_date = null;
|
||||
$teardown_end_date = null;
|
||||
|
||||
$event_config = EventConfig();
|
||||
if ($event_config != null) {
|
||||
$event_name = $event_config['event_name'];
|
||||
$buildup_start_date = $event_config['buildup_start_date'];
|
||||
$event_start_date = $event_config['event_start_date'];
|
||||
$event_end_date = $event_config['event_end_date'];
|
||||
$teardown_end_date = $event_config['teardown_end_date'];
|
||||
$event_welcome_msg = $event_config['event_welcome_msg'];
|
||||
}
|
||||
|
||||
if (isset($_REQUEST['submit'])) {
|
||||
$valid = true;
|
||||
|
||||
if (isset($_REQUEST['event_name'])) {
|
||||
$event_name = strip_request_item('event_name');
|
||||
}
|
||||
if ($event_name == '') {
|
||||
$event_name = null;
|
||||
}
|
||||
|
||||
if (isset($_REQUEST['event_welcome_msg'])) {
|
||||
$event_welcome_msg = strip_request_item_nl('event_welcome_msg');
|
||||
}
|
||||
if ($event_welcome_msg == '') {
|
||||
$event_welcome_msg = null;
|
||||
}
|
||||
|
||||
$result = check_request_date('buildup_start_date', _("Please enter buildup start date."), true);
|
||||
$buildup_start_date = $result->getValue();
|
||||
$valid &= $result->isValid();
|
||||
|
||||
$result = check_request_date('event_start_date', _("Please enter event start date."), true);
|
||||
$event_start_date = $result->getValue();
|
||||
$valid &= $result->isValid();
|
||||
|
||||
$result = check_request_date('event_end_date', _("Please enter event end date."), true);
|
||||
$event_end_date = $result->getValue();
|
||||
$valid &= $result->isValid();
|
||||
|
||||
$result = check_request_date('teardown_end_date', _("Please enter teardown end date."), true);
|
||||
$teardown_end_date = $result->getValue();
|
||||
$valid &= $result->isValid();
|
||||
|
||||
if ($buildup_start_date != null && $event_start_date != null && $buildup_start_date > $event_start_date) {
|
||||
$valid = false;
|
||||
error(_("The buildup start date has to be before the event start date."));
|
||||
}
|
||||
|
||||
if ($event_start_date != null && $event_end_date != null && $event_start_date > $event_end_date) {
|
||||
$valid = false;
|
||||
error(_("The event start date has to be before the event end date."));
|
||||
}
|
||||
|
||||
if ($event_end_date != null && $teardown_end_date != null && $event_end_date > $teardown_end_date) {
|
||||
$valid = false;
|
||||
error(_("The event end date has to be before the teardown end date."));
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
function event_config_edit_controller()
|
||||
{
|
||||
global $privileges;
|
||||
|
||||
if (!in_array('admin_event_config', $privileges)) {
|
||||
redirect('?');
|
||||
}
|
||||
|
||||
if ($buildup_start_date != null && $teardown_end_date != null && $buildup_start_date > $teardown_end_date) {
|
||||
$valid = false;
|
||||
error(_("The buildup start date has to be before the teardown end date."));
|
||||
|
||||
$event_name = null;
|
||||
$event_welcome_msg = null;
|
||||
$buildup_start_date = null;
|
||||
$event_start_date = null;
|
||||
$event_end_date = null;
|
||||
$teardown_end_date = null;
|
||||
|
||||
$event_config = EventConfig();
|
||||
if ($event_config != null) {
|
||||
$event_name = $event_config['event_name'];
|
||||
$buildup_start_date = $event_config['buildup_start_date'];
|
||||
$event_start_date = $event_config['event_start_date'];
|
||||
$event_end_date = $event_config['event_end_date'];
|
||||
$teardown_end_date = $event_config['teardown_end_date'];
|
||||
$event_welcome_msg = $event_config['event_welcome_msg'];
|
||||
}
|
||||
|
||||
if ($valid) {
|
||||
$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 event config.");
|
||||
}
|
||||
|
||||
engelsystem_log("Changed event config: $event_name, $event_welcome_msg, " . date("Y-m-d", $buildup_start_date) . ", " . date("Y-m-d", $event_start_date) . ", " . date("Y-m-d", $event_end_date) . ", " . date("Y-m-d", $teardown_end_date));
|
||||
success(_("Settings saved."));
|
||||
redirect(page_link_to('admin_event_config'));
|
||||
|
||||
if (isset($_REQUEST['submit'])) {
|
||||
$valid = true;
|
||||
|
||||
if (isset($_REQUEST['event_name'])) {
|
||||
$event_name = strip_request_item('event_name');
|
||||
}
|
||||
if ($event_name == '') {
|
||||
$event_name = null;
|
||||
}
|
||||
|
||||
if (isset($_REQUEST['event_welcome_msg'])) {
|
||||
$event_welcome_msg = strip_request_item_nl('event_welcome_msg');
|
||||
}
|
||||
if ($event_welcome_msg == '') {
|
||||
$event_welcome_msg = null;
|
||||
}
|
||||
|
||||
$result = check_request_date('buildup_start_date', _('Please enter buildup start date.'), true);
|
||||
$buildup_start_date = $result->getValue();
|
||||
$valid &= $result->isValid();
|
||||
|
||||
$result = check_request_date('event_start_date', _('Please enter event start date.'), true);
|
||||
$event_start_date = $result->getValue();
|
||||
$valid &= $result->isValid();
|
||||
|
||||
$result = check_request_date('event_end_date', _('Please enter event end date.'), true);
|
||||
$event_end_date = $result->getValue();
|
||||
$valid &= $result->isValid();
|
||||
|
||||
$result = check_request_date('teardown_end_date', _('Please enter teardown end date.'), true);
|
||||
$teardown_end_date = $result->getValue();
|
||||
$valid &= $result->isValid();
|
||||
|
||||
if ($buildup_start_date != null && $event_start_date != null && $buildup_start_date > $event_start_date) {
|
||||
$valid = false;
|
||||
error(_('The buildup start date has to be before the event start date.'));
|
||||
}
|
||||
|
||||
if ($event_start_date != null && $event_end_date != null && $event_start_date > $event_end_date) {
|
||||
$valid = false;
|
||||
error(_('The event start date has to be before the event end date.'));
|
||||
}
|
||||
|
||||
if ($event_end_date != null && $teardown_end_date != null && $event_end_date > $teardown_end_date) {
|
||||
$valid = false;
|
||||
error(_('The event end date has to be before the teardown end date.'));
|
||||
}
|
||||
|
||||
if ($buildup_start_date != null && $teardown_end_date != null && $buildup_start_date > $teardown_end_date) {
|
||||
$valid = false;
|
||||
error(_('The buildup start date has to be before the teardown end date.'));
|
||||
}
|
||||
|
||||
if ($valid) {
|
||||
$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 event config.');
|
||||
}
|
||||
|
||||
engelsystem_log(
|
||||
'Changed event config: $event_name, $event_welcome_msg, '
|
||||
. date('Y-m-d', $buildup_start_date) . ', ' . date('Y-m-d', $event_start_date) . ', '
|
||||
. date('Y-m-d', $event_end_date) . ', ' . date('Y-m-d', $teardown_end_date)
|
||||
);
|
||||
success(_('Settings saved.'));
|
||||
redirect(page_link_to('admin_event_config'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
event_config_title(),
|
||||
EventConfig_edit_view($event_name, $event_welcome_msg, $buildup_start_date, $event_start_date, $event_end_date, $teardown_end_date)
|
||||
];
|
||||
}
|
||||
|
||||
?>
|
||||
return [
|
||||
event_config_title(),
|
||||
EventConfig_edit_view(
|
||||
$event_name,
|
||||
$event_welcome_msg,
|
||||
$buildup_start_date,
|
||||
$event_start_date,
|
||||
$event_end_date,
|
||||
$teardown_end_date
|
||||
)
|
||||
];
|
||||
}
|
||||
|
||||
@ -1,187 +1,291 @@
|
||||
<?php
|
||||
|
||||
use Engelsystem\Database\DB;
|
||||
|
||||
/**
|
||||
* Sign up for a shift.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function shift_entry_add_controller() {
|
||||
global $privileges, $user;
|
||||
|
||||
if (isset($_REQUEST['shift_id']) && preg_match("/^[0-9]*$/", $_REQUEST['shift_id'])) {
|
||||
$shift_id = $_REQUEST['shift_id'];
|
||||
} else {
|
||||
redirect(page_link_to('user_shifts'));
|
||||
}
|
||||
|
||||
// Locations laden
|
||||
$rooms = sql_select("SELECT * FROM `Room` WHERE `show`='Y' ORDER BY `Name`");
|
||||
$room_array = [];
|
||||
foreach ($rooms as $room) {
|
||||
$room_array[$room['RID']] = $room['Name'];
|
||||
}
|
||||
|
||||
$shift = Shift($shift_id);
|
||||
$shift['Name'] = $room_array[$shift['RID']];
|
||||
if ($shift == null) {
|
||||
redirect(page_link_to('user_shifts'));
|
||||
}
|
||||
|
||||
if (isset($_REQUEST['type_id']) && preg_match("/^[0-9]*$/", $_REQUEST['type_id'])) {
|
||||
$type_id = $_REQUEST['type_id'];
|
||||
} else {
|
||||
redirect(page_link_to('user_shifts'));
|
||||
}
|
||||
|
||||
if (in_array('user_shifts_admin', $privileges) || in_array('shiftentry_edit_angeltype_supporter', $privileges)) {
|
||||
$type = AngelType($type_id);
|
||||
} else {
|
||||
$type = sql_select("SELECT * FROM `UserAngelTypes` JOIN `AngelTypes` ON (`UserAngelTypes`.`angeltype_id` = `AngelTypes`.`id`) WHERE `AngelTypes`.`id` = '" . sql_escape($type_id) . "' AND (`AngelTypes`.`restricted` = 0 OR (`UserAngelTypes`.`user_id` = '" . sql_escape($user['UID']) . "' AND NOT `UserAngelTypes`.`confirm_user_id` IS NULL))");
|
||||
$type = $type[0];
|
||||
}
|
||||
|
||||
if ($type == null) {
|
||||
redirect(page_link_to('user_shifts'));
|
||||
}
|
||||
|
||||
if (isset($_REQUEST['user_id']) && preg_match("/^[0-9]*$/", $_REQUEST['user_id']) && (in_array('user_shifts_admin', $privileges) || in_array('shiftentry_edit_angeltype_supporter', $privileges))) {
|
||||
$user_id = $_REQUEST['user_id'];
|
||||
} else {
|
||||
$user_id = $user['UID'];
|
||||
}
|
||||
|
||||
$needed_angeltype = NeededAngeltype_by_Shift_and_Angeltype($shift, $type);
|
||||
$shift_entries = ShiftEntries_by_shift_and_angeltype($shift['SID'], $type['id']);
|
||||
|
||||
$shift_signup_allowed = Shift_signup_allowed(User($user_id), $shift, $type, null, null, $needed_angeltype, $shift_entries);
|
||||
if (! $shift_signup_allowed->isSignupAllowed()) {
|
||||
error(_("You are not allowed to sign up for this shift. Maybe shift is full or already running."));
|
||||
redirect(shift_link($shift));
|
||||
}
|
||||
|
||||
if (isset($_REQUEST['submit'])) {
|
||||
$selected_type_id = $type_id;
|
||||
if (in_array('user_shifts_admin', $privileges) || in_array('shiftentry_edit_angeltype_supporter', $privileges)) {
|
||||
|
||||
if (sql_num_query("SELECT * FROM `User` WHERE `UID`='" . sql_escape($user_id) . "' LIMIT 1") == 0) {
|
||||
function shift_entry_add_controller()
|
||||
{
|
||||
global $privileges, $user;
|
||||
|
||||
$shift_id = 0;
|
||||
if (isset($_REQUEST['shift_id']) && preg_match('/^\d*$/', $_REQUEST['shift_id'])) {
|
||||
$shift_id = $_REQUEST['shift_id'];
|
||||
} else {
|
||||
redirect(page_link_to('user_shifts'));
|
||||
}
|
||||
|
||||
if (isset($_REQUEST['angeltype_id']) && test_request_int('angeltype_id') && sql_num_query("SELECT * FROM `AngelTypes` WHERE `id`='" . sql_escape($_REQUEST['angeltype_id']) . "' LIMIT 1") > 0) {
|
||||
$selected_type_id = $_REQUEST['angeltype_id'];
|
||||
}
|
||||
}
|
||||
|
||||
if (sql_num_query("SELECT * FROM `ShiftEntry` WHERE `SID`='" . sql_escape($shift['SID']) . "' AND `UID` = '" . sql_escape($user_id) . "'")) {
|
||||
return error("This angel does already have an entry for this shift.", true);
|
||||
|
||||
// Locations laden
|
||||
$rooms = Rooms();
|
||||
$room_array = [];
|
||||
foreach ($rooms as $room) {
|
||||
$room_array[$room['RID']] = $room['Name'];
|
||||
}
|
||||
|
||||
$freeloaded = $shift['freeloaded'];
|
||||
$freeload_comment = $shift['freeload_comment'];
|
||||
if (in_array("user_shifts_admin", $privileges)) {
|
||||
$freeloaded = isset($_REQUEST['freeloaded']);
|
||||
$freeload_comment = strip_request_item_nl('freeload_comment');
|
||||
|
||||
$shift = Shift($shift_id);
|
||||
$shift['Name'] = $room_array[$shift['RID']];
|
||||
if ($shift == null) {
|
||||
redirect(page_link_to('user_shifts'));
|
||||
}
|
||||
|
||||
$comment = strip_request_item_nl('comment');
|
||||
$result = ShiftEntry_create([
|
||||
'SID' => $shift_id,
|
||||
'TID' => $selected_type_id,
|
||||
'UID' => $user_id,
|
||||
'Comment' => $comment,
|
||||
'freeloaded' => $freeloaded,
|
||||
'freeload_comment' => $freeload_comment
|
||||
]);
|
||||
if ($result === false) {
|
||||
engelsystem_error('Unable to create shift entry.');
|
||||
|
||||
$type_id = 0;
|
||||
if (isset($_REQUEST['type_id']) && preg_match('/^\d*$/', $_REQUEST['type_id'])) {
|
||||
$type_id = $_REQUEST['type_id'];
|
||||
} else {
|
||||
redirect(page_link_to('user_shifts'));
|
||||
}
|
||||
|
||||
if ($type['restricted'] == 0 && sql_num_query("SELECT * FROM `UserAngelTypes` INNER JOIN `AngelTypes` ON `AngelTypes`.`id` = `UserAngelTypes`.`angeltype_id` WHERE `angeltype_id` = '" . sql_escape($selected_type_id) . "' AND `user_id` = '" . sql_escape($user_id) . "'") == 0) {
|
||||
sql_query("INSERT INTO `UserAngelTypes` (`user_id`, `angeltype_id`) VALUES ('" . sql_escape($user_id) . "', '" . sql_escape($selected_type_id) . "')");
|
||||
|
||||
if (in_array('user_shifts_admin', $privileges) || in_array('shiftentry_edit_angeltype_supporter', $privileges)) {
|
||||
$type = AngelType($type_id);
|
||||
} else {
|
||||
// TODO: Move queries to model
|
||||
$type = DB::select('
|
||||
SELECT *
|
||||
FROM `UserAngelTypes`
|
||||
JOIN `AngelTypes` ON (`UserAngelTypes`.`angeltype_id` = `AngelTypes`.`id`)
|
||||
WHERE `AngelTypes`.`id` = ?
|
||||
AND (
|
||||
`AngelTypes`.`restricted` = 0
|
||||
OR (
|
||||
`UserAngelTypes`.`user_id` = ?
|
||||
AND NOT `UserAngelTypes`.`confirm_user_id` IS NULL
|
||||
)
|
||||
)
|
||||
', [$type_id, $user['UID']]);
|
||||
$type = array_shift($type);
|
||||
}
|
||||
|
||||
$user_source = User($user_id);
|
||||
engelsystem_log("User " . User_Nick_render($user_source) . " signed up for shift " . $shift['name'] . " from " . date("Y-m-d H:i", $shift['start']) . " to " . date("Y-m-d H:i", $shift['end']));
|
||||
success(_("You are subscribed. Thank you!") . ' <a href="' . page_link_to('user_myshifts') . '">' . _("My shifts") . ' »</a>');
|
||||
redirect(shift_link($shift));
|
||||
}
|
||||
|
||||
if (in_array('user_shifts_admin', $privileges)) {
|
||||
$users = sql_select("SELECT *, (SELECT count(*) FROM `ShiftEntry` WHERE `freeloaded`=1 AND `ShiftEntry`.`UID`=`User`.`UID`) AS `freeloaded` FROM `User` ORDER BY `Nick`");
|
||||
$users_select = [];
|
||||
foreach ($users as $usr) {
|
||||
$users_select[$usr['UID']] = $usr['Nick'] . ($usr['freeloaded'] == 0 ? "" : " (" . _("Freeloader") . ")");
|
||||
|
||||
if (empty($type)) {
|
||||
redirect(page_link_to('user_shifts'));
|
||||
}
|
||||
$user_text = html_select_key('user_id', 'user_id', $users_select, $user['UID']);
|
||||
|
||||
$angeltypes_source = sql_select("SELECT * FROM `AngelTypes` ORDER BY `name`");
|
||||
$angeltypes = [];
|
||||
foreach ($angeltypes_source as $angeltype) {
|
||||
$angeltypes[$angeltype['id']] = $angeltype['name'];
|
||||
|
||||
if (
|
||||
isset($_REQUEST['user_id'])
|
||||
&& preg_match('/^\d*$/', $_REQUEST['user_id'])
|
||||
&& (
|
||||
in_array('user_shifts_admin', $privileges)
|
||||
|| in_array('shiftentry_edit_angeltype_supporter', $privileges)
|
||||
)
|
||||
) {
|
||||
$user_id = $_REQUEST['user_id'];
|
||||
} else {
|
||||
$user_id = $user['UID'];
|
||||
}
|
||||
$angeltype_select = html_select_key('angeltype_id', 'angeltype_id', $angeltypes, $type['id']);
|
||||
} elseif (in_array('shiftentry_edit_angeltype_supporter', $privileges)) {
|
||||
$users = Users_by_angeltype($type);
|
||||
$users_select = [];
|
||||
foreach ($users as $usr) {
|
||||
if (! $type['restricted'] || $usr['confirm_user_id'] != null) {
|
||||
$users_select[$usr['UID']] = $usr['Nick'];
|
||||
}
|
||||
|
||||
$needed_angeltype = NeededAngeltype_by_Shift_and_Angeltype($shift, $type);
|
||||
$shift_entries = ShiftEntries_by_shift_and_angeltype($shift['SID'], $type['id']);
|
||||
|
||||
$shift_signup_allowed = Shift_signup_allowed(
|
||||
User($user_id),
|
||||
$shift,
|
||||
$type,
|
||||
null,
|
||||
null,
|
||||
$needed_angeltype,
|
||||
$shift_entries
|
||||
);
|
||||
if (!$shift_signup_allowed->isSignupAllowed()) {
|
||||
error(_('You are not allowed to sign up for this shift. Maybe shift is full or already running.'));
|
||||
redirect(shift_link($shift));
|
||||
}
|
||||
|
||||
if (isset($_REQUEST['submit'])) {
|
||||
$selected_type_id = $type_id;
|
||||
if (in_array('user_shifts_admin', $privileges) || in_array('shiftentry_edit_angeltype_supporter',
|
||||
$privileges)
|
||||
) {
|
||||
|
||||
if (count(DB::select('SELECT `UID` FROM `User` WHERE `UID`=? LIMIT 1', [$user_id])) == 0) {
|
||||
redirect(page_link_to('user_shifts'));
|
||||
}
|
||||
|
||||
if (
|
||||
isset($_REQUEST['angeltype_id'])
|
||||
&& test_request_int('angeltype_id')
|
||||
&& count(DB::select(
|
||||
'SELECT `id` FROM `AngelTypes` WHERE `id`=? LIMIT 1',
|
||||
[$_REQUEST['angeltype_id']]
|
||||
)) > 0
|
||||
) {
|
||||
$selected_type_id = $_REQUEST['angeltype_id'];
|
||||
}
|
||||
}
|
||||
|
||||
if (count(DB::select(
|
||||
'SELECT `id` FROM `ShiftEntry` WHERE `SID`= ? AND `UID` = ?',
|
||||
[$shift['SID'], $user_id]))
|
||||
) {
|
||||
return error('This angel does already have an entry for this shift.', true);
|
||||
}
|
||||
|
||||
$freeloaded = isset($shift['freeloaded']) ? $shift['freeloaded'] : false;
|
||||
$freeload_comment = isset($shift['freeload_comment']) ? $shift['freeload_comment'] : '';
|
||||
if (in_array('user_shifts_admin', $privileges)) {
|
||||
$freeloaded = isset($_REQUEST['freeloaded']);
|
||||
$freeload_comment = strip_request_item_nl('freeload_comment');
|
||||
}
|
||||
|
||||
$comment = strip_request_item_nl('comment');
|
||||
$result = ShiftEntry_create([
|
||||
'SID' => $shift_id,
|
||||
'TID' => $selected_type_id,
|
||||
'UID' => $user_id,
|
||||
'Comment' => $comment,
|
||||
'freeloaded' => $freeloaded,
|
||||
'freeload_comment' => $freeload_comment
|
||||
]);
|
||||
if ($result === false) {
|
||||
engelsystem_error('Unable to create shift entry.');
|
||||
}
|
||||
|
||||
if (
|
||||
$type['restricted'] == 0
|
||||
&& count(DB::select('
|
||||
SELECT `UserAngelTypes`.`id` FROM `UserAngelTypes`
|
||||
INNER JOIN `AngelTypes` ON `AngelTypes`.`id` = `UserAngelTypes`.`angeltype_id`
|
||||
WHERE `angeltype_id` = ?
|
||||
AND `user_id` = ?
|
||||
', [$selected_type_id, $user_id])) == 0
|
||||
) {
|
||||
DB::insert(
|
||||
'INSERT INTO `UserAngelTypes` (`user_id`, `angeltype_id`) VALUES (?, ?)',
|
||||
[$user_id, $selected_type_id]
|
||||
);
|
||||
}
|
||||
|
||||
$user_source = User($user_id);
|
||||
engelsystem_log(
|
||||
'User ' . User_Nick_render($user_source)
|
||||
. ' signed up for shift ' . $shift['name']
|
||||
. ' from ' . date('Y-m-d H:i', $shift['start'])
|
||||
. ' to ' . date('Y-m-d H:i', $shift['end'])
|
||||
);
|
||||
success(_('You are subscribed. Thank you!') . ' <a href="' . page_link_to('user_myshifts') . '">' . _('My shifts') . ' »</a>');
|
||||
redirect(shift_link($shift));
|
||||
}
|
||||
$user_text = html_select_key('user_id', 'user_id', $users_select, $user['UID']);
|
||||
|
||||
$angeltypes_source = User_angeltypes($user);
|
||||
$angeltypes = [];
|
||||
foreach ($angeltypes_source as $angeltype) {
|
||||
if ($angeltype['supporter']) {
|
||||
$angeltypes[$angeltype['id']] = $angeltype['name'];
|
||||
}
|
||||
$angeltype_select = html_select_key('angeltype_id', 'angeltype_id', $angeltypes, $type['id']);
|
||||
|
||||
$angeltype_select = '';
|
||||
if (in_array('user_shifts_admin', $privileges)) {
|
||||
$users = DB::select('
|
||||
SELECT *,
|
||||
(
|
||||
SELECT count(*)
|
||||
FROM `ShiftEntry`
|
||||
WHERE `freeloaded`=1
|
||||
AND `ShiftEntry`.`UID`=`User`.`UID`
|
||||
) AS `freeloaded`
|
||||
FROM `User`
|
||||
ORDER BY `Nick`
|
||||
');
|
||||
$users_select = [];
|
||||
foreach ($users as $usr) {
|
||||
$users_select[$usr['UID']] = $usr['Nick'] . ($usr['freeloaded'] == 0 ? '' : ' (' . _('Freeloader') . ')');
|
||||
}
|
||||
$user_text = html_select_key('user_id', 'user_id', $users_select, $user['UID']);
|
||||
|
||||
$angeltypes_source = DB::select('SELECT `id`, `name` FROM `AngelTypes` ORDER BY `name`');
|
||||
$angeltypes = [];
|
||||
foreach ($angeltypes_source as $angeltype) {
|
||||
$angeltypes[$angeltype['id']] = $angeltype['name'];
|
||||
}
|
||||
$angeltype_select = html_select_key('angeltype_id', 'angeltype_id', $angeltypes, $type['id']);
|
||||
} elseif (in_array('shiftentry_edit_angeltype_supporter', $privileges)) {
|
||||
$users = Users_by_angeltype($type);
|
||||
$users_select = [];
|
||||
foreach ($users as $usr) {
|
||||
if (!$type['restricted'] || $usr['confirm_user_id'] != null) {
|
||||
$users_select[$usr['UID']] = $usr['Nick'];
|
||||
}
|
||||
}
|
||||
$user_text = html_select_key('user_id', 'user_id', $users_select, $user['UID']);
|
||||
|
||||
$angeltypes_source = User_angeltypes($user);
|
||||
$angeltypes = [];
|
||||
foreach ($angeltypes_source as $angeltype) {
|
||||
if ($angeltype['supporter']) {
|
||||
$angeltypes[$angeltype['id']] = $angeltype['name'];
|
||||
}
|
||||
$angeltype_select = html_select_key('angeltype_id', 'angeltype_id', $angeltypes, $type['id']);
|
||||
}
|
||||
} else {
|
||||
$user_text = User_Nick_render($user);
|
||||
$angeltype_select = $type['name'];
|
||||
}
|
||||
} else {
|
||||
$user_text = User_Nick_render($user);
|
||||
$angeltype_select = $type['name'];
|
||||
}
|
||||
|
||||
return ShiftEntry_edit_view($user_text, date("Y-m-d H:i", $shift['start']) . ' – ' . date('Y-m-d H:i', $shift['end']) . ' (' . shift_length($shift) . ')', $shift['Name'], $shift['name'], $angeltype_select, "", false, null, in_array('user_shifts_admin', $privileges));
|
||||
|
||||
return ShiftEntry_edit_view(
|
||||
$user_text,
|
||||
date('Y-m-d H:i', $shift['start'])
|
||||
. ' – '
|
||||
. date('Y-m-d H:i', $shift['end'])
|
||||
. ' (' . shift_length($shift) . ')',
|
||||
$shift['Name'],
|
||||
$shift['name'],
|
||||
$angeltype_select, '',
|
||||
false,
|
||||
null,
|
||||
in_array('user_shifts_admin', $privileges)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove somebody from a shift.
|
||||
*/
|
||||
function shift_entry_delete_controller() {
|
||||
global $privileges, $user;
|
||||
|
||||
if (! isset($_REQUEST['entry_id']) || ! test_request_int('entry_id')) {
|
||||
redirect(page_link_to('user_shifts'));
|
||||
}
|
||||
$entry_id = $_REQUEST['entry_id'];
|
||||
|
||||
$shift_entry_source = sql_select("
|
||||
SELECT `User`.`Nick`, `ShiftEntry`.`Comment`, `ShiftEntry`.`UID`, `ShiftTypes`.`name`, `Shifts`.*, `Room`.`Name`, `AngelTypes`.`name` as `angel_type`, `AngelTypes`.`id` as `angeltype_id`
|
||||
function shift_entry_delete_controller()
|
||||
{
|
||||
global $privileges, $user;
|
||||
|
||||
if (!isset($_REQUEST['entry_id']) || !test_request_int('entry_id')) {
|
||||
redirect(page_link_to('user_shifts'));
|
||||
}
|
||||
$entry_id = $_REQUEST['entry_id'];
|
||||
|
||||
$shift_entry_source = DB::select('
|
||||
SELECT
|
||||
`User`.`Nick`,
|
||||
`ShiftEntry`.`Comment`,
|
||||
`ShiftEntry`.`UID`,
|
||||
`ShiftTypes`.`name`,
|
||||
`Shifts`.*,
|
||||
`Room`.`Name`,
|
||||
`AngelTypes`.`name` AS `angel_type`,
|
||||
`AngelTypes`.`id` AS `angeltype_id`
|
||||
FROM `ShiftEntry`
|
||||
JOIN `User` ON (`User`.`UID`=`ShiftEntry`.`UID`)
|
||||
JOIN `AngelTypes` ON (`ShiftEntry`.`TID` = `AngelTypes`.`id`)
|
||||
JOIN `Shifts` ON (`ShiftEntry`.`SID` = `Shifts`.`SID`)
|
||||
JOIN `ShiftTypes` ON (`ShiftTypes`.`id` = `Shifts`.`shifttype_id`)
|
||||
JOIN `Room` ON (`Shifts`.`RID` = `Room`.`RID`)
|
||||
WHERE `ShiftEntry`.`id`='" . sql_escape($entry_id) . "'");
|
||||
if (count($shift_entry_source) > 0) {
|
||||
$shift_entry_source = $shift_entry_source[0];
|
||||
|
||||
if (!in_array('user_shifts_admin', $privileges) && (!in_array('shiftentry_edit_angeltype_supporter', $privileges) || !User_is_AngelType_supporter($user, AngelType($shift_entry_source['angeltype_id'])))) {
|
||||
redirect(page_link_to('user_shifts'));
|
||||
}
|
||||
|
||||
$result = ShiftEntry_delete($entry_id);
|
||||
if ($result === false) {
|
||||
engelsystem_error('Unable to delete shift entry.');
|
||||
WHERE `ShiftEntry`.`id`=?',
|
||||
[$entry_id]
|
||||
);
|
||||
if (count($shift_entry_source) > 0) {
|
||||
$shift_entry_source = array_shift($shift_entry_source);
|
||||
|
||||
if (!in_array('user_shifts_admin', $privileges) && (!in_array('shiftentry_edit_angeltype_supporter',
|
||||
$privileges) || !User_is_AngelType_supporter($user, AngelType($shift_entry_source['angeltype_id'])))
|
||||
) {
|
||||
redirect(page_link_to('user_shifts'));
|
||||
}
|
||||
|
||||
$result = ShiftEntry_delete($entry_id);
|
||||
if ($result === false) {
|
||||
engelsystem_error('Unable to delete shift entry.');
|
||||
}
|
||||
|
||||
engelsystem_log(
|
||||
'Deleted ' . User_Nick_render($shift_entry_source) . '\'s shift: ' . $shift_entry_source['name']
|
||||
. ' at ' . $shift_entry_source['Name']
|
||||
. ' from ' . date('Y-m-d H:i', $shift_entry_source['start'])
|
||||
. ' to ' . date('Y-m-d H:i', $shift_entry_source['end'])
|
||||
. ' as ' . $shift_entry_source['angel_type']
|
||||
);
|
||||
success(_('Shift entry deleted.'));
|
||||
} else {
|
||||
error(_('Entry not found.'));
|
||||
}
|
||||
|
||||
engelsystem_log("Deleted " . User_Nick_render($shift_entry_source) . "'s shift: " . $shift_entry_source['name'] . " at " . $shift_entry_source['Name'] . " from " . date("Y-m-d H:i", $shift_entry_source['start']) . " to " . date("Y-m-d H:i", $shift_entry_source['end']) . " as " . $shift_entry_source['angel_type']);
|
||||
success(_("Shift entry deleted."));
|
||||
} else {
|
||||
error(_("Entry not found."));
|
||||
}
|
||||
redirect(shift_link($shift_entry_source));
|
||||
}
|
||||
|
||||
?>
|
||||
redirect(shift_link($shift_entry_source));
|
||||
}
|
||||
|
||||
@ -1,324 +1,393 @@
|
||||
<?php
|
||||
use Engelsystem\ShiftSignupState;
|
||||
|
||||
function shift_link($shift) {
|
||||
return page_link_to('shifts') . '&action=view&shift_id=' . $shift['SID'];
|
||||
/**
|
||||
* @param array $shift
|
||||
* @return string
|
||||
*/
|
||||
function shift_link($shift)
|
||||
{
|
||||
$link = page_link_to('shifts') . '&action=view';
|
||||
if (isset($shift['SID'])) {
|
||||
$link .= '&shift_id=' . $shift['SID'];
|
||||
}
|
||||
return $link;
|
||||
}
|
||||
|
||||
function shift_delete_link($shift) {
|
||||
return page_link_to('user_shifts') . '&delete_shift=' . $shift['SID'];
|
||||
/**
|
||||
* @param array $shift
|
||||
* @return string
|
||||
*/
|
||||
function shift_delete_link($shift)
|
||||
{
|
||||
return page_link_to('user_shifts') . '&delete_shift=' . $shift['SID'];
|
||||
}
|
||||
|
||||
function shift_edit_link($shift) {
|
||||
return page_link_to('user_shifts') . '&edit_shift=' . $shift['SID'];
|
||||
/**
|
||||
* @param array $shift
|
||||
* @return string
|
||||
*/
|
||||
function shift_edit_link($shift)
|
||||
{
|
||||
return page_link_to('user_shifts') . '&edit_shift=' . $shift['SID'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit a single shift.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function shift_edit_controller() {
|
||||
global $privileges;
|
||||
|
||||
// Schicht bearbeiten
|
||||
$msg = "";
|
||||
$valid = true;
|
||||
|
||||
if (! in_array('admin_shifts', $privileges)) {
|
||||
redirect(page_link_to('user_shifts'));
|
||||
}
|
||||
|
||||
if (! isset($_REQUEST['edit_shift']) || ! test_request_int('edit_shift')) {
|
||||
redirect(page_link_to('user_shifts'));
|
||||
}
|
||||
$shift_id = $_REQUEST['edit_shift'];
|
||||
|
||||
$shift = Shift($shift_id);
|
||||
|
||||
$room = select_array(Rooms(), 'RID', 'Name');
|
||||
$angeltypes = select_array(AngelTypes(), 'id', 'name');
|
||||
$shifttypes = select_array(ShiftTypes(), 'id', 'name');
|
||||
|
||||
$needed_angel_types = select_array(NeededAngelTypes_by_shift($shift_id), 'id', 'count');
|
||||
foreach (array_keys($angeltypes) as $angeltype_id) {
|
||||
if (! isset($needed_angel_types[$angeltype_id])) {
|
||||
$needed_angel_types[$angeltype_id] = 0;
|
||||
function shift_edit_controller()
|
||||
{
|
||||
global $privileges;
|
||||
|
||||
// Schicht bearbeiten
|
||||
$msg = '';
|
||||
$valid = true;
|
||||
|
||||
if (!in_array('admin_shifts', $privileges)) {
|
||||
redirect(page_link_to('user_shifts'));
|
||||
}
|
||||
}
|
||||
|
||||
$shifttype_id = $shift['shifttype_id'];
|
||||
$title = $shift['title'];
|
||||
$rid = $shift['RID'];
|
||||
$start = $shift['start'];
|
||||
$end = $shift['end'];
|
||||
|
||||
if (isset($_REQUEST['submit'])) {
|
||||
// Name/Bezeichnung der Schicht, darf leer sein
|
||||
$title = strip_request_item('title');
|
||||
|
||||
// Auswahl der sichtbaren Locations für die Schichten
|
||||
if (isset($_REQUEST['rid']) && preg_match("/^[0-9]+$/", $_REQUEST['rid']) && isset($room[$_REQUEST['rid']])) {
|
||||
$rid = $_REQUEST['rid'];
|
||||
} else {
|
||||
$valid = false;
|
||||
$msg .= error(_("Please select a room."), true);
|
||||
|
||||
if (!isset($_REQUEST['edit_shift']) || !test_request_int('edit_shift')) {
|
||||
redirect(page_link_to('user_shifts'));
|
||||
}
|
||||
|
||||
if (isset($_REQUEST['shifttype_id']) && isset($shifttypes[$_REQUEST['shifttype_id']])) {
|
||||
$shifttype_id = $_REQUEST['shifttype_id'];
|
||||
} else {
|
||||
$valid = false;
|
||||
$msg .= error(_('Please select a shifttype.'), true);
|
||||
$shift_id = $_REQUEST['edit_shift'];
|
||||
|
||||
$shift = Shift($shift_id);
|
||||
|
||||
$room = select_array(Rooms(), 'RID', 'Name');
|
||||
$angeltypes = select_array(AngelTypes(), 'id', 'name');
|
||||
$shifttypes = select_array(ShiftTypes(), 'id', 'name');
|
||||
|
||||
$needed_angel_types = select_array(NeededAngelTypes_by_shift($shift_id), 'id', 'count');
|
||||
foreach (array_keys($angeltypes) as $angeltype_id) {
|
||||
if (!isset($needed_angel_types[$angeltype_id])) {
|
||||
$needed_angel_types[$angeltype_id] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_REQUEST['start']) && $tmp = parse_date("Y-m-d H:i", $_REQUEST['start'])) {
|
||||
$start = $tmp;
|
||||
} else {
|
||||
$valid = false;
|
||||
$msg .= error(_("Please enter a valid starting time for the shifts."), true);
|
||||
|
||||
$shifttype_id = $shift['shifttype_id'];
|
||||
$title = $shift['title'];
|
||||
$rid = $shift['RID'];
|
||||
$start = $shift['start'];
|
||||
$end = $shift['end'];
|
||||
|
||||
if (isset($_REQUEST['submit'])) {
|
||||
// Name/Bezeichnung der Schicht, darf leer sein
|
||||
$title = strip_request_item('title');
|
||||
|
||||
// Auswahl der sichtbaren Locations für die Schichten
|
||||
if (isset($_REQUEST['rid']) && preg_match('/^\d+$/', $_REQUEST['rid']) && isset($room[$_REQUEST['rid']])) {
|
||||
$rid = $_REQUEST['rid'];
|
||||
} else {
|
||||
$valid = false;
|
||||
$msg .= error(_('Please select a room.'), true);
|
||||
}
|
||||
|
||||
if (isset($_REQUEST['shifttype_id']) && isset($shifttypes[$_REQUEST['shifttype_id']])) {
|
||||
$shifttype_id = $_REQUEST['shifttype_id'];
|
||||
} else {
|
||||
$valid = false;
|
||||
$msg .= error(_('Please select a shifttype.'), true);
|
||||
}
|
||||
|
||||
if (isset($_REQUEST['start']) && $tmp = parse_date('Y-m-d H:i', $_REQUEST['start'])) {
|
||||
$start = $tmp;
|
||||
} else {
|
||||
$valid = false;
|
||||
$msg .= error(_('Please enter a valid starting time for the shifts.'), true);
|
||||
}
|
||||
|
||||
if (isset($_REQUEST['end']) && $tmp = parse_date('Y-m-d H:i', $_REQUEST['end'])) {
|
||||
$end = $tmp;
|
||||
} else {
|
||||
$valid = false;
|
||||
$msg .= error(_('Please enter a valid ending time for the shifts.'), true);
|
||||
}
|
||||
|
||||
if ($start >= $end) {
|
||||
$valid = false;
|
||||
$msg .= error(_('The ending time has to be after the starting time.'), true);
|
||||
}
|
||||
|
||||
foreach ($needed_angel_types as $needed_angeltype_id => $needed_angeltype_name) {
|
||||
if (isset($_REQUEST['type_' . $needed_angeltype_id]) && test_request_int('type_' . $needed_angeltype_id)) {
|
||||
$needed_angel_types[$needed_angeltype_id] = trim($_REQUEST['type_' . $needed_angeltype_id]);
|
||||
} else {
|
||||
$valid = false;
|
||||
$msg .= error(sprintf(
|
||||
_('Please check your input for needed angels of type %s.'),
|
||||
$needed_angeltype_name
|
||||
), true);
|
||||
}
|
||||
}
|
||||
|
||||
if ($valid) {
|
||||
$shift['shifttype_id'] = $shifttype_id;
|
||||
$shift['title'] = $title;
|
||||
$shift['RID'] = $rid;
|
||||
$shift['start'] = $start;
|
||||
$shift['end'] = $end;
|
||||
|
||||
$result = Shift_update($shift);
|
||||
if ($result === false) {
|
||||
engelsystem_error('Unable to update shift.');
|
||||
}
|
||||
NeededAngelTypes_delete_by_shift($shift_id);
|
||||
$needed_angel_types_info = [];
|
||||
foreach ($needed_angel_types as $type_id => $count) {
|
||||
NeededAngelType_add($shift_id, $type_id, null, $count);
|
||||
$needed_angel_types_info[] = $angeltypes[$type_id] . ': ' . $count;
|
||||
}
|
||||
|
||||
engelsystem_log(
|
||||
'Updated shift \'' . $shifttypes[$shifttype_id] . ', ' . $title
|
||||
. '\' from ' . date('Y-m-d H:i', $start)
|
||||
. ' to ' . date('Y-m-d H:i', $end)
|
||||
. ' with angel types ' . join(', ', $needed_angel_types_info)
|
||||
);
|
||||
success(_('Shift updated.'));
|
||||
|
||||
redirect(shift_link([
|
||||
'SID' => $shift_id
|
||||
]));
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_REQUEST['end']) && $tmp = parse_date("Y-m-d H:i", $_REQUEST['end'])) {
|
||||
$end = $tmp;
|
||||
} else {
|
||||
$valid = false;
|
||||
$msg .= error(_("Please enter a valid ending time for the shifts."), true);
|
||||
|
||||
$angel_types_spinner = '';
|
||||
foreach ($angeltypes as $angeltype_id => $angeltype_name) {
|
||||
$angel_types_spinner .= form_spinner('type_' . $angeltype_id, $angeltype_name,
|
||||
$needed_angel_types[$angeltype_id]);
|
||||
}
|
||||
|
||||
if ($start >= $end) {
|
||||
$valid = false;
|
||||
$msg .= error(_("The ending time has to be after the starting time."), true);
|
||||
|
||||
return page_with_title(
|
||||
shifts_title(),
|
||||
[
|
||||
msg(),
|
||||
'<noscript>' . info(_('This page is much more comfortable with javascript.'), true) . '</noscript>',
|
||||
form([
|
||||
form_select('shifttype_id', _('Shifttype'), $shifttypes, $shifttype_id),
|
||||
form_text('title', _('Title'), $title),
|
||||
form_select('rid', _('Room:'), $room, $rid),
|
||||
form_text('start', _('Start:'), date('Y-m-d H:i', $start)),
|
||||
form_text('end', _('End:'), date('Y-m-d H:i', $end)),
|
||||
'<h2>' . _('Needed angels') . '</h2>',
|
||||
$angel_types_spinner,
|
||||
form_submit('submit', _('Save'))
|
||||
])
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
function shift_delete_controller()
|
||||
{
|
||||
global $privileges;
|
||||
|
||||
if (!in_array('user_shifts_admin', $privileges)) {
|
||||
redirect(page_link_to('user_shifts'));
|
||||
}
|
||||
|
||||
foreach ($needed_angel_types as $needed_angeltype_id => $needed_angeltype_name) {
|
||||
if (isset($_REQUEST['type_' . $needed_angeltype_id]) && test_request_int('type_' . $needed_angeltype_id)) {
|
||||
$needed_angel_types[$needed_angeltype_id] = trim($_REQUEST['type_' . $needed_angeltype_id]);
|
||||
} else {
|
||||
$valid = false;
|
||||
$msg .= error(sprintf(_("Please check your input for needed angels of type %s."), $needed_angeltype_name), true);
|
||||
}
|
||||
|
||||
// Schicht komplett löschen (nur für admins/user mit user_shifts_admin privileg)
|
||||
if (!isset($_REQUEST['delete_shift']) || !preg_match('/^\d*$/', $_REQUEST['delete_shift'])) {
|
||||
redirect(page_link_to('user_shifts'));
|
||||
}
|
||||
|
||||
if ($valid) {
|
||||
$shift['shifttype_id'] = $shifttype_id;
|
||||
$shift['title'] = $title;
|
||||
$shift['RID'] = $rid;
|
||||
$shift['start'] = $start;
|
||||
$shift['end'] = $end;
|
||||
|
||||
$result = Shift_update($shift);
|
||||
if ($result === false) {
|
||||
engelsystem_error('Unable to update shift.');
|
||||
}
|
||||
NeededAngelTypes_delete_by_shift($shift_id);
|
||||
$needed_angel_types_info = [];
|
||||
foreach ($needed_angel_types as $type_id => $count) {
|
||||
NeededAngelType_add($shift_id, $type_id, null, $count);
|
||||
$needed_angel_types_info[] = $angeltypes[$type_id] . ": " . $count;
|
||||
}
|
||||
|
||||
engelsystem_log("Updated shift '" . $shifttypes[$shifttype_id] . ", " . $title . "' from " . date("Y-m-d H:i", $start) . " to " . date("Y-m-d H:i", $end) . " with angel types " . join(", ", $needed_angel_types_info));
|
||||
success(_("Shift updated."));
|
||||
|
||||
redirect(shift_link([
|
||||
'SID' => $shift_id
|
||||
]));
|
||||
$shift_id = $_REQUEST['delete_shift'];
|
||||
|
||||
$shift = Shift($shift_id);
|
||||
if ($shift == null) {
|
||||
redirect(page_link_to('user_shifts'));
|
||||
}
|
||||
}
|
||||
|
||||
$angel_types_spinner = "";
|
||||
foreach ($angeltypes as $angeltype_id => $angeltype_name) {
|
||||
$angel_types_spinner .= form_spinner('type_' . $angeltype_id, $angeltype_name, $needed_angel_types[$angeltype_id]);
|
||||
}
|
||||
|
||||
return page_with_title(shifts_title(), [
|
||||
msg(),
|
||||
'<noscript>' . info(_("This page is much more comfortable with javascript."), true) . '</noscript>',
|
||||
form([
|
||||
form_select('shifttype_id', _('Shifttype'), $shifttypes, $shifttype_id),
|
||||
form_text('title', _("Title"), $title),
|
||||
form_select('rid', _("Room:"), $room, $rid),
|
||||
form_text('start', _("Start:"), date("Y-m-d H:i", $start)),
|
||||
form_text('end', _("End:"), date("Y-m-d H:i", $end)),
|
||||
'<h2>' . _("Needed angels") . '</h2>',
|
||||
$angel_types_spinner,
|
||||
form_submit('submit', _("Save"))
|
||||
])
|
||||
]);
|
||||
}
|
||||
|
||||
function shift_delete_controller() {
|
||||
global $privileges;
|
||||
|
||||
if (! in_array('user_shifts_admin', $privileges)) {
|
||||
redirect(page_link_to('user_shifts'));
|
||||
}
|
||||
|
||||
// Schicht komplett löschen (nur für admins/user mit user_shifts_admin privileg)
|
||||
if (! isset($_REQUEST['delete_shift']) || ! preg_match("/^[0-9]*$/", $_REQUEST['delete_shift'])) {
|
||||
redirect(page_link_to('user_shifts'));
|
||||
}
|
||||
$shift_id = $_REQUEST['delete_shift'];
|
||||
|
||||
$shift = Shift($shift_id);
|
||||
if ($shift == null) {
|
||||
redirect(page_link_to('user_shifts'));
|
||||
}
|
||||
|
||||
// Schicht löschen bestätigt
|
||||
if (isset($_REQUEST['delete'])) {
|
||||
Shift_delete($shift_id);
|
||||
|
||||
engelsystem_log("Deleted shift " . $shift['name'] . " from " . date("Y-m-d H:i", $shift['start']) . " to " . date("Y-m-d H:i", $shift['end']));
|
||||
success(_("Shift deleted."));
|
||||
redirect(page_link_to('user_shifts'));
|
||||
}
|
||||
|
||||
return page_with_title(shifts_title(), [
|
||||
error(sprintf(_("Do you want to delete the shift %s from %s to %s?"), $shift['name'], date("Y-m-d H:i", $shift['start']), date("H:i", $shift['end'])), true),
|
||||
'<a class="button" href="?p=user_shifts&delete_shift=' . $shift_id . '&delete">' . _("delete") . '</a>'
|
||||
]);
|
||||
// Schicht löschen bestätigt
|
||||
if (isset($_REQUEST['delete'])) {
|
||||
Shift_delete($shift_id);
|
||||
|
||||
engelsystem_log(
|
||||
'Deleted shift ' . $shift['name']
|
||||
. ' from ' . date('Y-m-d H:i', $shift['start'])
|
||||
. ' to ' . date('Y-m-d H:i', $shift['end'])
|
||||
);
|
||||
success(_('Shift deleted.'));
|
||||
redirect(page_link_to('user_shifts'));
|
||||
}
|
||||
|
||||
return page_with_title(shifts_title(), [
|
||||
error(sprintf(
|
||||
_('Do you want to delete the shift %s from %s to %s?'),
|
||||
$shift['name'],
|
||||
date('Y-m-d H:i', $shift['start']),
|
||||
date('H:i', $shift['end'])
|
||||
), true),
|
||||
'<a class="button" href="?p=user_shifts&delete_shift=' . $shift_id . '&delete">' . _('delete') . '</a>'
|
||||
]);
|
||||
}
|
||||
|
||||
function shift_controller() {
|
||||
global $user, $privileges;
|
||||
|
||||
if (! in_array('user_shifts', $privileges)) {
|
||||
redirect(page_link_to('?'));
|
||||
}
|
||||
|
||||
if (! isset($_REQUEST['shift_id'])) {
|
||||
redirect(page_link_to('user_shifts'));
|
||||
}
|
||||
|
||||
$shift = Shift($_REQUEST['shift_id']);
|
||||
if ($shift == null) {
|
||||
error(_("Shift could not be found."));
|
||||
redirect(page_link_to('user_shifts'));
|
||||
}
|
||||
|
||||
$shifttype = ShiftType($shift['shifttype_id']);
|
||||
$room = Room($shift['RID']);
|
||||
$angeltypes = AngelTypes();
|
||||
$user_shifts = Shifts_by_user($user);
|
||||
|
||||
$shift_signup_state = new ShiftSignupState(ShiftSignupState::OCCUPIED, 0);
|
||||
foreach ($angeltypes as &$angeltype) {
|
||||
$needed_angeltype = NeededAngeltype_by_Shift_and_Angeltype($shift, $angeltype);
|
||||
$shift_entries = ShiftEntries_by_shift_and_angeltype($shift['SID'], $angeltype['id']);
|
||||
|
||||
$angeltype_signup_state = Shift_signup_allowed($user, $shift, $angeltype, null, $user_shifts, $needed_angeltype, $shift_entries);
|
||||
if ($shift_signup_state == null) {
|
||||
$shift_signup_state = $angeltype_signup_state;
|
||||
} else {
|
||||
$shift_signup_state->combineWith($angeltype_signup_state);
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
function shift_controller()
|
||||
{
|
||||
global $user, $privileges;
|
||||
|
||||
if (!in_array('user_shifts', $privileges)) {
|
||||
redirect(page_link_to('?'));
|
||||
}
|
||||
|
||||
if (!isset($_REQUEST['shift_id'])) {
|
||||
redirect(page_link_to('user_shifts'));
|
||||
}
|
||||
|
||||
$shift = Shift($_REQUEST['shift_id']);
|
||||
if ($shift == null) {
|
||||
error(_('Shift could not be found.'));
|
||||
redirect(page_link_to('user_shifts'));
|
||||
}
|
||||
$angeltype['shift_signup_state'] = $angeltype_signup_state;
|
||||
}
|
||||
|
||||
return [
|
||||
$shift['name'],
|
||||
Shift_view($shift, $shifttype, $room, $angeltypes, $shift_signup_state)
|
||||
];
|
||||
|
||||
$shifttype = ShiftType($shift['shifttype_id']);
|
||||
$room = Room($shift['RID']);
|
||||
$angeltypes = AngelTypes();
|
||||
$user_shifts = Shifts_by_user($user);
|
||||
|
||||
$shift_signup_state = new ShiftSignupState(ShiftSignupState::OCCUPIED, 0);
|
||||
foreach ($angeltypes as &$angeltype) {
|
||||
$needed_angeltype = NeededAngeltype_by_Shift_and_Angeltype($shift, $angeltype);
|
||||
$shift_entries = ShiftEntries_by_shift_and_angeltype($shift['SID'], $angeltype['id']);
|
||||
|
||||
$angeltype_signup_state = Shift_signup_allowed(
|
||||
$user,
|
||||
$shift,
|
||||
$angeltype,
|
||||
null,
|
||||
$user_shifts,
|
||||
$needed_angeltype,
|
||||
$shift_entries
|
||||
);
|
||||
if ($shift_signup_state == null) {
|
||||
$shift_signup_state = $angeltype_signup_state;
|
||||
} else {
|
||||
$shift_signup_state->combineWith($angeltype_signup_state);
|
||||
}
|
||||
$angeltype['shift_signup_state'] = $angeltype_signup_state;
|
||||
}
|
||||
|
||||
return [
|
||||
$shift['name'],
|
||||
Shift_view($shift, $shifttype, $room, $angeltypes, $shift_signup_state)
|
||||
];
|
||||
}
|
||||
|
||||
function shifts_controller() {
|
||||
if (! isset($_REQUEST['action'])) {
|
||||
redirect(page_link_to('user_shifts'));
|
||||
}
|
||||
|
||||
switch ($_REQUEST['action']) {
|
||||
default:
|
||||
redirect(page_link_to('?'));
|
||||
case 'view':
|
||||
return shift_controller();
|
||||
case 'next':
|
||||
return shift_next_controller();
|
||||
}
|
||||
/**
|
||||
* @return array|false
|
||||
*/
|
||||
function shifts_controller()
|
||||
{
|
||||
if (!isset($_REQUEST['action'])) {
|
||||
redirect(page_link_to('user_shifts'));
|
||||
}
|
||||
|
||||
switch ($_REQUEST['action']) {
|
||||
case 'view':
|
||||
return shift_controller();
|
||||
case 'next':
|
||||
return shift_next_controller();
|
||||
default:
|
||||
redirect(page_link_to('?'));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Redirects the user to his next shift.
|
||||
*
|
||||
* @return false
|
||||
*/
|
||||
function shift_next_controller() {
|
||||
global $user, $privileges;
|
||||
|
||||
if (! in_array('user_shifts', $privileges)) {
|
||||
redirect(page_link_to('?'));
|
||||
}
|
||||
|
||||
$upcoming_shifts = ShiftEntries_upcoming_for_user($user);
|
||||
if ($upcoming_shifts === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (count($upcoming_shifts) > 0) {
|
||||
redirect(shift_link($upcoming_shifts[0]));
|
||||
}
|
||||
|
||||
redirect(page_link_to('user_shifts'));
|
||||
function shift_next_controller()
|
||||
{
|
||||
global $user, $privileges;
|
||||
|
||||
if (!in_array('user_shifts', $privileges)) {
|
||||
redirect(page_link_to('?'));
|
||||
}
|
||||
|
||||
$upcoming_shifts = ShiftEntries_upcoming_for_user($user);
|
||||
|
||||
if (!empty($upcoming_shifts)) {
|
||||
redirect(shift_link($upcoming_shifts[0]));
|
||||
}
|
||||
|
||||
redirect(page_link_to('user_shifts'));
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Export all shifts using api-key.
|
||||
*/
|
||||
function shifts_json_export_all_controller() {
|
||||
global $api_key;
|
||||
|
||||
if ($api_key == "") {
|
||||
engelsystem_error("Config contains empty apikey.");
|
||||
}
|
||||
|
||||
if (! isset($_REQUEST['api_key'])) {
|
||||
engelsystem_error("Missing parameter api_key.");
|
||||
}
|
||||
|
||||
if ($_REQUEST['api_key'] != $api_key) {
|
||||
engelsystem_error("Invalid api_key.");
|
||||
}
|
||||
|
||||
$shifts_source = Shifts();
|
||||
if ($shifts_source === false) {
|
||||
engelsystem_error("Unable to load shifts.");
|
||||
}
|
||||
|
||||
header("Content-Type: application/json; charset=utf-8");
|
||||
raw_output(json_encode($shifts_source));
|
||||
function shifts_json_export_all_controller()
|
||||
{
|
||||
$api_key = config('api_key');
|
||||
|
||||
if (empty($api_key)) {
|
||||
engelsystem_error('Config contains empty apikey.');
|
||||
}
|
||||
|
||||
if (!isset($_REQUEST['api_key'])) {
|
||||
engelsystem_error('Missing parameter api_key.');
|
||||
}
|
||||
|
||||
if ($_REQUEST['api_key'] != $api_key) {
|
||||
engelsystem_error('Invalid api_key.');
|
||||
}
|
||||
|
||||
$shifts_source = Shifts();
|
||||
if ($shifts_source === false) {
|
||||
engelsystem_error('Unable to load shifts.');
|
||||
}
|
||||
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
raw_output(json_encode($shifts_source));
|
||||
}
|
||||
|
||||
/**
|
||||
* Export filtered shifts via JSON.
|
||||
* (Like iCal Export or shifts view)
|
||||
*/
|
||||
function shifts_json_export_controller() {
|
||||
global $user;
|
||||
|
||||
if (! isset($_REQUEST['key']) || ! preg_match("/^[0-9a-f]{32}$/", $_REQUEST['key'])) {
|
||||
engelsystem_error("Missing key.");
|
||||
}
|
||||
|
||||
$key = $_REQUEST['key'];
|
||||
|
||||
$user = User_by_api_key($key);
|
||||
if ($user == null) {
|
||||
engelsystem_error("Key invalid.");
|
||||
}
|
||||
if (! in_array('shifts_json_export', privileges_for_user($user['UID']))) {
|
||||
engelsystem_error("No privilege for shifts_json_export.");
|
||||
}
|
||||
|
||||
$shifts = load_ical_shifts();
|
||||
|
||||
header("Content-Type: application/json; charset=utf-8");
|
||||
raw_output(json_encode($shifts));
|
||||
function shifts_json_export_controller()
|
||||
{
|
||||
global $user;
|
||||
|
||||
if (!isset($_REQUEST['key']) || !preg_match('/^[\da-f]{32}$/', $_REQUEST['key'])) {
|
||||
engelsystem_error('Missing key.');
|
||||
}
|
||||
|
||||
$key = $_REQUEST['key'];
|
||||
|
||||
$user = User_by_api_key($key);
|
||||
if ($user == null) {
|
||||
engelsystem_error('Key invalid.');
|
||||
}
|
||||
if (!in_array('shifts_json_export', privileges_for_user($user['UID']))) {
|
||||
engelsystem_error('No privilege for shifts_json_export.');
|
||||
}
|
||||
|
||||
$shifts = load_ical_shifts();
|
||||
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
raw_output(json_encode($shifts));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns users shifts to export.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function load_ical_shifts() {
|
||||
global $user;
|
||||
|
||||
return Shifts_by_user($user);
|
||||
}
|
||||
function load_ical_shifts()
|
||||
{
|
||||
global $user;
|
||||
|
||||
?>
|
||||
return Shifts_by_user($user);
|
||||
}
|
||||
|
||||
@ -1,179 +1,192 @@
|
||||
<?php
|
||||
|
||||
function shifttype_link($shifttype) {
|
||||
return page_link_to('shifttypes') . '&action=view&shifttype_id=' . $shifttype['id'];
|
||||
/**
|
||||
* @param array $shifttype
|
||||
* @return string
|
||||
*/
|
||||
function shifttype_link($shifttype)
|
||||
{
|
||||
return page_link_to('shifttypes') . '&action=view&shifttype_id=' . $shifttype['id'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a shifttype.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function shifttype_delete_controller() {
|
||||
if (! isset($_REQUEST['shifttype_id'])) {
|
||||
redirect(page_link_to('shifttypes'));
|
||||
}
|
||||
|
||||
$shifttype = ShiftType($_REQUEST['shifttype_id']);
|
||||
if ($shifttype === false) {
|
||||
engelsystem_error('Unable to load shifttype.');
|
||||
}
|
||||
|
||||
if ($shifttype == null) {
|
||||
redirect(page_link_to('shifttypes'));
|
||||
}
|
||||
|
||||
if (isset($_REQUEST['confirmed'])) {
|
||||
$result = ShiftType_delete($shifttype['id']);
|
||||
if ($result === false) {
|
||||
engelsystem_error('Unable to delete shifttype.');
|
||||
function shifttype_delete_controller()
|
||||
{
|
||||
if (!isset($_REQUEST['shifttype_id'])) {
|
||||
redirect(page_link_to('shifttypes'));
|
||||
}
|
||||
|
||||
engelsystem_log('Deleted shifttype ' . $shifttype['name']);
|
||||
success(sprintf(_('Shifttype %s deleted.'), $shifttype['name']));
|
||||
redirect(page_link_to('shifttypes'));
|
||||
}
|
||||
|
||||
return [
|
||||
sprintf(_("Delete shifttype %s"), $shifttype['name']),
|
||||
ShiftType_delete_view($shifttype)
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit or create shift type.
|
||||
*/
|
||||
function shifttype_edit_controller() {
|
||||
$shifttype_id = null;
|
||||
$name = "";
|
||||
$angeltype_id = null;
|
||||
$description = "";
|
||||
|
||||
$angeltypes = AngelTypes();
|
||||
|
||||
if (isset($_REQUEST['shifttype_id'])) {
|
||||
$shifttype = ShiftType($_REQUEST['shifttype_id']);
|
||||
if ($shifttype === false) {
|
||||
engelsystem_error('Unable to load shifttype.');
|
||||
}
|
||||
|
||||
if ($shifttype == null) {
|
||||
error(_('Shifttype not found.'));
|
||||
redirect(page_link_to('shifttypes'));
|
||||
}
|
||||
$shifttype_id = $shifttype['id'];
|
||||
$name = $shifttype['name'];
|
||||
$angeltype_id = $shifttype['angeltype_id'];
|
||||
$description = $shifttype['description'];
|
||||
}
|
||||
|
||||
if (isset($_REQUEST['submit'])) {
|
||||
$valid = true;
|
||||
|
||||
if (isset($_REQUEST['name']) && $_REQUEST['name'] != '') {
|
||||
$name = strip_request_item('name');
|
||||
} else {
|
||||
$valid = false;
|
||||
error(_('Please enter a name.'));
|
||||
redirect(page_link_to('shifttypes'));
|
||||
}
|
||||
|
||||
if (isset($_REQUEST['angeltype_id']) && preg_match("/^[0-9]+$/", $_REQUEST['angeltype_id'])) {
|
||||
$angeltype_id = $_REQUEST['angeltype_id'];
|
||||
} else {
|
||||
$angeltype_id = null;
|
||||
|
||||
if (isset($_REQUEST['confirmed'])) {
|
||||
$result = ShiftType_delete($shifttype['id']);
|
||||
if (empty($result)) {
|
||||
engelsystem_error('Unable to delete shifttype.');
|
||||
}
|
||||
|
||||
engelsystem_log('Deleted shifttype ' . $shifttype['name']);
|
||||
success(sprintf(_('Shifttype %s deleted.'), $shifttype['name']));
|
||||
redirect(page_link_to('shifttypes'));
|
||||
}
|
||||
|
||||
if (isset($_REQUEST['description'])) {
|
||||
$description = strip_request_item_nl('description');
|
||||
|
||||
return [
|
||||
sprintf(_('Delete shifttype %s'), $shifttype['name']),
|
||||
ShiftType_delete_view($shifttype)
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit or create shift type.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function shifttype_edit_controller()
|
||||
{
|
||||
$shifttype_id = null;
|
||||
$name = '';
|
||||
$angeltype_id = null;
|
||||
$description = '';
|
||||
|
||||
$angeltypes = AngelTypes();
|
||||
|
||||
if (isset($_REQUEST['shifttype_id'])) {
|
||||
$shifttype = ShiftType($_REQUEST['shifttype_id']);
|
||||
if ($shifttype == null) {
|
||||
error(_('Shifttype not found.'));
|
||||
redirect(page_link_to('shifttypes'));
|
||||
}
|
||||
$shifttype_id = $shifttype['id'];
|
||||
$name = $shifttype['name'];
|
||||
$angeltype_id = $shifttype['angeltype_id'];
|
||||
$description = $shifttype['description'];
|
||||
}
|
||||
|
||||
if ($valid) {
|
||||
if ($shifttype_id) {
|
||||
$result = ShiftType_update($shifttype_id, $name, $angeltype_id, $description);
|
||||
if ($result === false) {
|
||||
engelsystem_error('Unable to update shifttype.');
|
||||
|
||||
if (isset($_REQUEST['submit'])) {
|
||||
$valid = true;
|
||||
|
||||
if (isset($_REQUEST['name']) && $_REQUEST['name'] != '') {
|
||||
$name = strip_request_item('name');
|
||||
} else {
|
||||
$valid = false;
|
||||
error(_('Please enter a name.'));
|
||||
}
|
||||
|
||||
if (isset($_REQUEST['angeltype_id']) && preg_match('/^\d+$/', $_REQUEST['angeltype_id'])) {
|
||||
$angeltype_id = $_REQUEST['angeltype_id'];
|
||||
} else {
|
||||
$angeltype_id = null;
|
||||
}
|
||||
engelsystem_log('Updated shifttype ' . $name);
|
||||
success(_('Updated shifttype.'));
|
||||
} else {
|
||||
$shifttype_id = ShiftType_create($name, $angeltype_id, $description);
|
||||
if ($shifttype_id === false) {
|
||||
engelsystem_error('Unable to create shifttype.');
|
||||
|
||||
if (isset($_REQUEST['description'])) {
|
||||
$description = strip_request_item_nl('description');
|
||||
}
|
||||
|
||||
if ($valid) {
|
||||
if ($shifttype_id) {
|
||||
$result = ShiftType_update($shifttype_id, $name, $angeltype_id, $description);
|
||||
if ($result === false) {
|
||||
engelsystem_error('Unable to update shifttype.');
|
||||
}
|
||||
engelsystem_log('Updated shifttype ' . $name);
|
||||
success(_('Updated shifttype.'));
|
||||
} else {
|
||||
$shifttype_id = ShiftType_create($name, $angeltype_id, $description);
|
||||
if ($shifttype_id === false) {
|
||||
engelsystem_error('Unable to create shifttype.');
|
||||
}
|
||||
engelsystem_log('Created shifttype ' . $name);
|
||||
success(_('Created shifttype.'));
|
||||
}
|
||||
redirect(page_link_to('shifttypes') . '&action=view&shifttype_id=' . $shifttype_id);
|
||||
}
|
||||
engelsystem_log('Created shifttype ' . $name);
|
||||
success(_('Created shifttype.'));
|
||||
}
|
||||
redirect(page_link_to('shifttypes') . '&action=view&shifttype_id=' . $shifttype_id);
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
shifttypes_title(),
|
||||
ShiftType_edit_view($name, $angeltype_id, $angeltypes, $description, $shifttype_id)
|
||||
];
|
||||
|
||||
return [
|
||||
shifttypes_title(),
|
||||
ShiftType_edit_view($name, $angeltype_id, $angeltypes, $description, $shifttype_id)
|
||||
];
|
||||
}
|
||||
|
||||
function shifttype_controller() {
|
||||
if (! isset($_REQUEST['shifttype_id'])) {
|
||||
redirect(page_link_to('shifttypes'));
|
||||
}
|
||||
$shifttype = ShiftType($_REQUEST['shifttype_id']);
|
||||
if ($shifttype === false) {
|
||||
engelsystem_error('Unable to load shifttype.');
|
||||
}
|
||||
if ($shifttype == null) {
|
||||
redirect(page_link_to('shifttypes'));
|
||||
}
|
||||
|
||||
$angeltype = null;
|
||||
if ($shifttype['angeltype_id'] != null) {
|
||||
$angeltype = AngelType($shifttype['angeltype_id']);
|
||||
}
|
||||
|
||||
return [
|
||||
$shifttype['name'],
|
||||
ShiftType_view($shifttype, $angeltype)
|
||||
];
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
function shifttype_controller()
|
||||
{
|
||||
if (!isset($_REQUEST['shifttype_id'])) {
|
||||
redirect(page_link_to('shifttypes'));
|
||||
}
|
||||
$shifttype = ShiftType($_REQUEST['shifttype_id']);
|
||||
if ($shifttype == null) {
|
||||
redirect(page_link_to('shifttypes'));
|
||||
}
|
||||
|
||||
$angeltype = null;
|
||||
if ($shifttype['angeltype_id'] != null) {
|
||||
$angeltype = AngelType($shifttype['angeltype_id']);
|
||||
}
|
||||
|
||||
return [
|
||||
$shifttype['name'],
|
||||
ShiftType_view($shifttype, $angeltype)
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* List all shift types.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function shifttypes_list_controller() {
|
||||
$shifttypes = ShiftTypes();
|
||||
if ($shifttypes === false) {
|
||||
engelsystem_error("Unable to load shifttypes.");
|
||||
}
|
||||
|
||||
return [
|
||||
shifttypes_title(),
|
||||
ShiftTypes_list_view($shifttypes)
|
||||
];
|
||||
function shifttypes_list_controller()
|
||||
{
|
||||
$shifttypes = ShiftTypes();
|
||||
if ($shifttypes === false) {
|
||||
engelsystem_error('Unable to load shifttypes.');
|
||||
}
|
||||
|
||||
return [
|
||||
shifttypes_title(),
|
||||
ShiftTypes_list_view($shifttypes)
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Text for shift type related links.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function shifttypes_title() {
|
||||
return _("Shifttypes");
|
||||
function shifttypes_title()
|
||||
{
|
||||
return _('Shifttypes');
|
||||
}
|
||||
|
||||
/**
|
||||
* Route shift type actions
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function shifttypes_controller() {
|
||||
if (! isset($_REQUEST['action'])) {
|
||||
$_REQUEST['action'] = 'list';
|
||||
}
|
||||
|
||||
switch ($_REQUEST['action']) {
|
||||
default:
|
||||
case 'list':
|
||||
return shifttypes_list_controller();
|
||||
case 'view':
|
||||
return shifttype_controller();
|
||||
case 'edit':
|
||||
return shifttype_edit_controller();
|
||||
case 'delete':
|
||||
return shifttype_delete_controller();
|
||||
}
|
||||
}
|
||||
function shifttypes_controller()
|
||||
{
|
||||
if (!isset($_REQUEST['action'])) {
|
||||
$_REQUEST['action'] = 'list';
|
||||
}
|
||||
|
||||
?>
|
||||
switch ($_REQUEST['action']) {
|
||||
case 'view':
|
||||
return shifttype_controller();
|
||||
case 'edit':
|
||||
return shifttype_edit_controller();
|
||||
case 'delete':
|
||||
return shifttype_delete_controller();
|
||||
case 'list':
|
||||
default:
|
||||
return shifttypes_list_controller();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,132 +1,148 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Generates a hint, if user joined angeltypes that require a driving license and the user has no driver license information provided.
|
||||
* Generates a hint, if user joined angeltypes that require a driving license and the user has no driver license
|
||||
* information provided.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
function user_driver_license_required_hint() {
|
||||
global $user;
|
||||
|
||||
$angeltypes = User_angeltypes($user);
|
||||
$user_driver_license = UserDriverLicense($user['UID']);
|
||||
|
||||
// User has already entered data, no hint needed.
|
||||
if ($user_driver_license != null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
foreach ($angeltypes as $angeltype) {
|
||||
if ($angeltype['requires_driver_license']) {
|
||||
return sprintf(_("You joined an angeltype which requires a driving license. Please edit your driving license information here: %s."), '<a href="' . user_driver_license_edit_link() . '">' . _("driving license information") . '</a>');
|
||||
function user_driver_license_required_hint()
|
||||
{
|
||||
global $user;
|
||||
|
||||
$angeltypes = User_angeltypes($user);
|
||||
$user_driver_license = UserDriverLicense($user['UID']);
|
||||
|
||||
// User has already entered data, no hint needed.
|
||||
if ($user_driver_license != null) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
foreach ($angeltypes as $angeltype) {
|
||||
if ($angeltype['requires_driver_license']) {
|
||||
return sprintf(
|
||||
_('You joined an angeltype which requires a driving license. Please edit your driving license information here: %s.'),
|
||||
'<a href="' . user_driver_license_edit_link() . '">' . _('driving license information') . '</a>'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Route user driver licenses actions.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function user_driver_licenses_controller() {
|
||||
global $user;
|
||||
|
||||
if (! isset($user)) {
|
||||
redirect(page_link_to(''));
|
||||
}
|
||||
|
||||
$action = strip_request_item('action', 'edit');
|
||||
|
||||
switch ($action) {
|
||||
default:
|
||||
case 'edit':
|
||||
return user_driver_license_edit_controller();
|
||||
}
|
||||
function user_driver_licenses_controller()
|
||||
{
|
||||
global $user;
|
||||
|
||||
if (!isset($user)) {
|
||||
redirect(page_link_to(''));
|
||||
}
|
||||
|
||||
$action = strip_request_item('action', 'edit');
|
||||
|
||||
switch ($action) {
|
||||
default:
|
||||
case 'edit':
|
||||
return user_driver_license_edit_controller();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Link to user driver license edit page for given user.
|
||||
*
|
||||
* @param User $user
|
||||
* @param array $user
|
||||
* @return string
|
||||
*/
|
||||
function user_driver_license_edit_link($user = null) {
|
||||
if ($user == null) {
|
||||
return page_link_to('user_driver_licenses');
|
||||
}
|
||||
return page_link_to('user_driver_licenses') . '&user_id=' . $user['UID'];
|
||||
function user_driver_license_edit_link($user = null)
|
||||
{
|
||||
if ($user == null) {
|
||||
return page_link_to('user_driver_licenses');
|
||||
}
|
||||
return page_link_to('user_driver_licenses') . '&user_id=' . $user['UID'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the user for the driver license.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function user_driver_license_load_user() {
|
||||
global $user;
|
||||
|
||||
$user_source = $user;
|
||||
|
||||
if (isset($_REQUEST['user_id'])) {
|
||||
$user_source = User($_REQUEST['user_id']);
|
||||
if ($user_source == null) {
|
||||
redirect(user_driver_license_edit_link());
|
||||
function user_driver_license_load_user()
|
||||
{
|
||||
global $user;
|
||||
|
||||
$user_source = $user;
|
||||
|
||||
if (isset($_REQUEST['user_id'])) {
|
||||
$user_source = User($_REQUEST['user_id']);
|
||||
if ($user_source == null) {
|
||||
redirect(user_driver_license_edit_link());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $user_source;
|
||||
|
||||
return $user_source;
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit a users driver license information.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function user_driver_license_edit_controller() {
|
||||
global $privileges, $user;
|
||||
|
||||
$user_source = user_driver_license_load_user();
|
||||
|
||||
// only privilege admin_user can edit other users driver license information
|
||||
if ($user['UID'] != $user_source['UID'] && ! in_array('admin_user', $privileges)) {
|
||||
redirect(user_driver_license_edit_link());
|
||||
}
|
||||
|
||||
$user_driver_license = UserDriverLicense($user_source['UID']);
|
||||
if ($user_driver_license == null) {
|
||||
$wants_to_drive = false;
|
||||
$user_driver_license = UserDriverLicense_new();
|
||||
} else {
|
||||
$wants_to_drive = true;
|
||||
}
|
||||
|
||||
if (isset($_REQUEST['submit'])) {
|
||||
$wants_to_drive = isset($_REQUEST['wants_to_drive']);
|
||||
if ($wants_to_drive) {
|
||||
$user_driver_license['has_car'] = isset($_REQUEST['has_car']);
|
||||
$user_driver_license['has_license_car'] = isset($_REQUEST['has_license_car']);
|
||||
$user_driver_license['has_license_3_5t_transporter'] = isset($_REQUEST['has_license_3_5t_transporter']);
|
||||
$user_driver_license['has_license_7_5t_truck'] = isset($_REQUEST['has_license_7_5t_truck']);
|
||||
$user_driver_license['has_license_12_5t_truck'] = isset($_REQUEST['has_license_12_5t_truck']);
|
||||
$user_driver_license['has_license_forklift'] = isset($_REQUEST['has_license_forklift']);
|
||||
|
||||
if (UserDriverLicense_valid($user_driver_license)) {
|
||||
if ($user_driver_license['user_id'] == null) {
|
||||
$user_driver_license = UserDriverLicenses_create($user_driver_license, $user);
|
||||
} else {
|
||||
UserDriverLicenses_update($user_driver_license);
|
||||
function user_driver_license_edit_controller()
|
||||
{
|
||||
global $privileges, $user;
|
||||
|
||||
$user_source = user_driver_license_load_user();
|
||||
|
||||
// only privilege admin_user can edit other users driver license information
|
||||
if ($user['UID'] != $user_source['UID'] && !in_array('admin_user', $privileges)) {
|
||||
redirect(user_driver_license_edit_link());
|
||||
}
|
||||
|
||||
$user_driver_license = UserDriverLicense($user_source['UID']);
|
||||
if ($user_driver_license == null) {
|
||||
$wants_to_drive = false;
|
||||
$user_driver_license = UserDriverLicense_new();
|
||||
} else {
|
||||
$wants_to_drive = true;
|
||||
}
|
||||
|
||||
if (isset($_REQUEST['submit'])) {
|
||||
$wants_to_drive = isset($_REQUEST['wants_to_drive']);
|
||||
if ($wants_to_drive) {
|
||||
$user_driver_license['has_car'] = isset($_REQUEST['has_car']);
|
||||
$user_driver_license['has_license_car'] = isset($_REQUEST['has_license_car']);
|
||||
$user_driver_license['has_license_3_5t_transporter'] = isset($_REQUEST['has_license_3_5t_transporter']);
|
||||
$user_driver_license['has_license_7_5t_truck'] = isset($_REQUEST['has_license_7_5t_truck']);
|
||||
$user_driver_license['has_license_12_5t_truck'] = isset($_REQUEST['has_license_12_5t_truck']);
|
||||
$user_driver_license['has_license_forklift'] = isset($_REQUEST['has_license_forklift']);
|
||||
|
||||
if (UserDriverLicense_valid($user_driver_license)) {
|
||||
if ($user_driver_license['user_id'] == null) {
|
||||
$user_driver_license = UserDriverLicenses_create($user_driver_license, $user_source);
|
||||
} else {
|
||||
UserDriverLicenses_update($user_driver_license);
|
||||
}
|
||||
engelsystem_log('Driver license information updated.');
|
||||
success(_('Your driver license information has been saved.'));
|
||||
redirect(user_link($user_source));
|
||||
} else {
|
||||
error(_('Please select at least one driving license.'));
|
||||
}
|
||||
} elseif ($user_driver_license['user_id'] != null) {
|
||||
UserDriverLicenses_delete($user_source['UID']);
|
||||
engelsystem_log('Driver license information removed.');
|
||||
success(_('Your driver license information has been removed.'));
|
||||
redirect(user_link($user_source));
|
||||
}
|
||||
engelsystem_log("Driver license information updated.");
|
||||
success(_("Your driver license information has been saved."));
|
||||
redirect(user_link($user_source));
|
||||
} else {
|
||||
error(_("Please select at least one driving license."));
|
||||
}
|
||||
} elseif ($user_driver_license['id'] != null) {
|
||||
UserDriverLicenses_delete($user_source['UID']);
|
||||
engelsystem_log("Driver license information removed.");
|
||||
success(_("Your driver license information has been removed."));
|
||||
redirect(user_link($user_source));
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
sprintf(_("Edit %s driving license information"), $user_source['Nick']),
|
||||
UserDriverLicense_edit_view($user_source, $wants_to_drive, $user_driver_license)
|
||||
];
|
||||
}
|
||||
|
||||
?>
|
||||
return [
|
||||
sprintf(_('Edit %s driving license information'), $user_source['Nick']),
|
||||
UserDriverLicense_edit_view($user_source, $wants_to_drive, $user_driver_license)
|
||||
];
|
||||
}
|
||||
|
||||
@ -1,371 +1,467 @@
|
||||
<?php
|
||||
use Engelsystem\ShiftsFilter;
|
||||
|
||||
use Engelsystem\Database\DB;
|
||||
use Engelsystem\ShiftCalendarRenderer;
|
||||
use Engelsystem\ShiftsFilter;
|
||||
|
||||
/**
|
||||
* Route user actions.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function users_controller() {
|
||||
global $user;
|
||||
|
||||
if (! isset($user)) {
|
||||
redirect(page_link_to(''));
|
||||
}
|
||||
|
||||
if (! isset($_REQUEST['action'])) {
|
||||
$_REQUEST['action'] = 'list';
|
||||
}
|
||||
|
||||
switch ($_REQUEST['action']) {
|
||||
default:
|
||||
case 'list':
|
||||
return users_list_controller();
|
||||
case 'view':
|
||||
return user_controller();
|
||||
case 'edit':
|
||||
return user_edit_controller();
|
||||
case 'delete':
|
||||
return user_delete_controller();
|
||||
case 'edit_vouchers':
|
||||
return user_edit_vouchers_controller();
|
||||
}
|
||||
function users_controller()
|
||||
{
|
||||
global $user;
|
||||
|
||||
if (!isset($user)) {
|
||||
redirect(page_link_to(''));
|
||||
}
|
||||
|
||||
if (!isset($_REQUEST['action'])) {
|
||||
$_REQUEST['action'] = 'list';
|
||||
}
|
||||
|
||||
switch ($_REQUEST['action']) {
|
||||
case 'view':
|
||||
return user_controller();
|
||||
case 'delete':
|
||||
return user_delete_controller();
|
||||
case 'edit_vouchers':
|
||||
return user_edit_vouchers_controller();
|
||||
case 'list':
|
||||
default:
|
||||
return users_list_controller();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a user, requires to enter own password for reasons.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function user_delete_controller() {
|
||||
global $privileges, $user;
|
||||
|
||||
if (isset($_REQUEST['user_id'])) {
|
||||
$user_source = User($_REQUEST['user_id']);
|
||||
} else {
|
||||
$user_source = $user;
|
||||
}
|
||||
|
||||
if (! in_array('admin_user', $privileges)) {
|
||||
redirect(page_link_to(''));
|
||||
}
|
||||
|
||||
// You cannot delete yourself
|
||||
if ($user['UID'] == $user_source['UID']) {
|
||||
error(_("You cannot delete yourself."));
|
||||
redirect(user_link($user));
|
||||
}
|
||||
|
||||
if (isset($_REQUEST['submit'])) {
|
||||
$valid = true;
|
||||
|
||||
if (! (isset($_REQUEST['password']) && verify_password($_REQUEST['password'], $user['Passwort'], $user['UID']))) {
|
||||
$valid = false;
|
||||
error(_("Your password is incorrect. Please try it again."));
|
||||
function user_delete_controller()
|
||||
{
|
||||
global $privileges, $user;
|
||||
|
||||
if (isset($_REQUEST['user_id'])) {
|
||||
$user_source = User($_REQUEST['user_id']);
|
||||
} else {
|
||||
$user_source = $user;
|
||||
}
|
||||
|
||||
if (!in_array('admin_user', $privileges)) {
|
||||
redirect(page_link_to(''));
|
||||
}
|
||||
|
||||
if ($valid) {
|
||||
$result = User_delete($user_source['UID']);
|
||||
if ($result === false) {
|
||||
engelsystem_error('Unable to delete user.');
|
||||
}
|
||||
|
||||
mail_user_delete($user_source);
|
||||
success(_("User deleted."));
|
||||
engelsystem_log(sprintf("Deleted %s", User_Nick_render($user_source)));
|
||||
|
||||
redirect(users_link());
|
||||
|
||||
// You cannot delete yourself
|
||||
if ($user['UID'] == $user_source['UID']) {
|
||||
error(_('You cannot delete yourself.'));
|
||||
redirect(user_link($user));
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
sprintf(_("Delete %s"), $user_source['Nick']),
|
||||
User_delete_view($user_source)
|
||||
];
|
||||
|
||||
if (isset($_REQUEST['submit'])) {
|
||||
$valid = true;
|
||||
|
||||
if (!(isset($_REQUEST['password']) && verify_password($_REQUEST['password'], $user['Passwort'],
|
||||
$user['UID']))
|
||||
) {
|
||||
$valid = false;
|
||||
error(_('Your password is incorrect. Please try it again.'));
|
||||
}
|
||||
|
||||
if ($valid) {
|
||||
$result = User_delete($user_source['UID']);
|
||||
if ($result === false) {
|
||||
engelsystem_error('Unable to delete user.');
|
||||
}
|
||||
|
||||
mail_user_delete($user_source);
|
||||
success(_('User deleted.'));
|
||||
engelsystem_log(sprintf('Deleted %s', User_Nick_render($user_source)));
|
||||
|
||||
redirect(users_link());
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
sprintf(_('Delete %s'), $user_source['Nick']),
|
||||
User_delete_view($user_source)
|
||||
];
|
||||
}
|
||||
|
||||
function users_link() {
|
||||
return page_link_to('users');
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
function users_link()
|
||||
{
|
||||
return page_link_to('users');
|
||||
}
|
||||
|
||||
function user_edit_link($user) {
|
||||
return page_link_to('admin_user') . '&user_id=' . $user['UID'];
|
||||
/**
|
||||
* @param array $user
|
||||
* @return string
|
||||
*/
|
||||
function user_edit_link($user)
|
||||
{
|
||||
return page_link_to('admin_user') . '&user_id=' . $user['UID'];
|
||||
}
|
||||
|
||||
function user_delete_link($user) {
|
||||
return page_link_to('users') . '&action=delete&user_id=' . $user['UID'];
|
||||
/**
|
||||
* @param array $user
|
||||
* @return string
|
||||
*/
|
||||
function user_delete_link($user)
|
||||
{
|
||||
return page_link_to('users') . '&action=delete&user_id=' . $user['UID'];
|
||||
}
|
||||
|
||||
function user_link($user) {
|
||||
return page_link_to('users') . '&action=view&user_id=' . $user['UID'];
|
||||
/**
|
||||
* @param array $user
|
||||
* @return string
|
||||
*/
|
||||
function user_link($user)
|
||||
{
|
||||
return page_link_to('users') . '&action=view&user_id=' . $user['UID'];
|
||||
}
|
||||
|
||||
function user_edit_vouchers_controller() {
|
||||
global $privileges, $user;
|
||||
|
||||
if (isset($_REQUEST['user_id'])) {
|
||||
$user_source = User($_REQUEST['user_id']);
|
||||
} else {
|
||||
$user_source = $user;
|
||||
}
|
||||
|
||||
if (! in_array('admin_user', $privileges)) {
|
||||
redirect(page_link_to(''));
|
||||
}
|
||||
|
||||
if (isset($_REQUEST['submit'])) {
|
||||
$valid = true;
|
||||
|
||||
if (isset($_REQUEST['vouchers']) && test_request_int('vouchers') && trim($_REQUEST['vouchers']) >= 0) {
|
||||
$vouchers = trim($_REQUEST['vouchers']);
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
function user_edit_vouchers_controller()
|
||||
{
|
||||
global $privileges, $user;
|
||||
|
||||
if (isset($_REQUEST['user_id'])) {
|
||||
$user_source = User($_REQUEST['user_id']);
|
||||
} else {
|
||||
$valid = false;
|
||||
error(_("Please enter a valid number of vouchers."));
|
||||
$user_source = $user;
|
||||
}
|
||||
|
||||
if ($valid) {
|
||||
$user_source['got_voucher'] = $vouchers;
|
||||
|
||||
$result = User_update($user_source);
|
||||
if ($result === false) {
|
||||
engelsystem_error('Unable to update user.');
|
||||
}
|
||||
|
||||
success(_("Saved the number of vouchers."));
|
||||
engelsystem_log(User_Nick_render($user_source) . ': ' . sprintf("Got %s vouchers", $user_source['got_voucher']));
|
||||
|
||||
redirect(user_link($user_source));
|
||||
|
||||
if (!in_array('admin_user', $privileges)) {
|
||||
redirect(page_link_to(''));
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
sprintf(_("%s's vouchers"), $user_source['Nick']),
|
||||
User_edit_vouchers_view($user_source)
|
||||
];
|
||||
|
||||
if (isset($_REQUEST['submit'])) {
|
||||
$valid = true;
|
||||
|
||||
$vouchers = '';
|
||||
if (isset($_REQUEST['vouchers']) && test_request_int('vouchers') && trim($_REQUEST['vouchers']) >= 0) {
|
||||
$vouchers = trim($_REQUEST['vouchers']);
|
||||
} else {
|
||||
$valid = false;
|
||||
error(_('Please enter a valid number of vouchers.'));
|
||||
}
|
||||
|
||||
if ($valid) {
|
||||
$user_source['got_voucher'] = $vouchers;
|
||||
|
||||
$result = User_update($user_source);
|
||||
if ($result === false) {
|
||||
engelsystem_error('Unable to update user.');
|
||||
}
|
||||
|
||||
success(_('Saved the number of vouchers.'));
|
||||
engelsystem_log(User_Nick_render($user_source) . ': ' . sprintf('Got %s vouchers',
|
||||
$user_source['got_voucher']));
|
||||
|
||||
redirect(user_link($user_source));
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
sprintf(_('%s\'s vouchers'), $user_source['Nick']),
|
||||
User_edit_vouchers_view($user_source)
|
||||
];
|
||||
}
|
||||
|
||||
function user_controller() {
|
||||
global $privileges, $user;
|
||||
|
||||
$user_source = $user;
|
||||
if (isset($_REQUEST['user_id'])) {
|
||||
$user_source = User($_REQUEST['user_id']);
|
||||
if ($user_source == null) {
|
||||
error(_("User not found."));
|
||||
redirect('?');
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
function user_controller()
|
||||
{
|
||||
global $privileges, $user;
|
||||
|
||||
$user_source = $user;
|
||||
if (isset($_REQUEST['user_id'])) {
|
||||
$user_source = User($_REQUEST['user_id']);
|
||||
if ($user_source == null) {
|
||||
error(_('User not found.'));
|
||||
redirect('?');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$shifts = Shifts_by_user($user_source, in_array("user_shifts_admin", $privileges));
|
||||
foreach ($shifts as &$shift) {
|
||||
// TODO: Move queries to model
|
||||
$shift['needed_angeltypes'] = sql_select("SELECT DISTINCT `AngelTypes`.* FROM `ShiftEntry` JOIN `AngelTypes` ON `ShiftEntry`.`TID`=`AngelTypes`.`id` WHERE `ShiftEntry`.`SID`='" . sql_escape($shift['SID']) . "' ORDER BY `AngelTypes`.`name`");
|
||||
foreach ($shift['needed_angeltypes'] as &$needed_angeltype) {
|
||||
$needed_angeltype['users'] = sql_select("
|
||||
SELECT `ShiftEntry`.`freeloaded`, `User`.*
|
||||
FROM `ShiftEntry`
|
||||
JOIN `User` ON `ShiftEntry`.`UID`=`User`.`UID`
|
||||
WHERE `ShiftEntry`.`SID`='" . sql_escape($shift['SID']) . "'
|
||||
AND `ShiftEntry`.`TID`='" . sql_escape($needed_angeltype['id']) . "'");
|
||||
|
||||
$shifts = Shifts_by_user($user_source, in_array('user_shifts_admin', $privileges));
|
||||
foreach ($shifts as &$shift) {
|
||||
// TODO: Move queries to model
|
||||
$shift['needed_angeltypes'] = DB::select('
|
||||
SELECT DISTINCT `AngelTypes`.*
|
||||
FROM `ShiftEntry`
|
||||
JOIN `AngelTypes` ON `ShiftEntry`.`TID`=`AngelTypes`.`id`
|
||||
WHERE `ShiftEntry`.`SID` = ?
|
||||
ORDER BY `AngelTypes`.`name`
|
||||
',
|
||||
[$shift['SID']]
|
||||
);
|
||||
foreach ($shift['needed_angeltypes'] as &$needed_angeltype) {
|
||||
$needed_angeltype['users'] = DB::select('
|
||||
SELECT `ShiftEntry`.`freeloaded`, `User`.*
|
||||
FROM `ShiftEntry`
|
||||
JOIN `User` ON `ShiftEntry`.`UID`=`User`.`UID`
|
||||
WHERE `ShiftEntry`.`SID` = ?
|
||||
AND `ShiftEntry`.`TID` = ?
|
||||
',
|
||||
[$shift['SID'], $needed_angeltype['id']]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ($user_source['api_key'] == '') {
|
||||
User_reset_api_key($user_source, false);
|
||||
}
|
||||
}
|
||||
|
||||
if ($user_source['api_key'] == "") {
|
||||
User_reset_api_key($user_source, false);
|
||||
}
|
||||
|
||||
return [
|
||||
$user_source['Nick'],
|
||||
User_view($user_source, in_array('admin_user', $privileges), User_is_freeloader($user_source), User_angeltypes($user_source), User_groups($user_source), $shifts, $user['UID'] == $user_source['UID'])
|
||||
];
|
||||
|
||||
return [
|
||||
$user_source['Nick'],
|
||||
User_view(
|
||||
$user_source,
|
||||
in_array('admin_user', $privileges),
|
||||
User_is_freeloader($user_source),
|
||||
User_angeltypes($user_source),
|
||||
User_groups($user_source),
|
||||
$shifts,
|
||||
$user['UID'] == $user_source['UID']
|
||||
)
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* List all users.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function users_list_controller() {
|
||||
global $privileges;
|
||||
|
||||
if (! in_array('admin_user', $privileges)) {
|
||||
redirect(page_link_to(''));
|
||||
}
|
||||
|
||||
$order_by = 'Nick';
|
||||
if (isset($_REQUEST['OrderBy']) && in_array($_REQUEST['OrderBy'], User_sortable_columns())) {
|
||||
$order_by = $_REQUEST['OrderBy'];
|
||||
}
|
||||
|
||||
$users = Users($order_by);
|
||||
if ($users === false) {
|
||||
engelsystem_error('Unable to load users.');
|
||||
}
|
||||
|
||||
foreach ($users as &$user) {
|
||||
$user['freeloads'] = count(ShiftEntries_freeloaded_by_user($user));
|
||||
}
|
||||
|
||||
return [
|
||||
_('All users'),
|
||||
Users_view($users, $order_by, User_arrived_count(), User_active_count(), User_force_active_count(), ShiftEntries_freeleaded_count(), User_tshirts_count(), User_got_voucher_count())
|
||||
];
|
||||
function users_list_controller()
|
||||
{
|
||||
global $privileges;
|
||||
|
||||
if (!in_array('admin_user', $privileges)) {
|
||||
redirect(page_link_to(''));
|
||||
}
|
||||
|
||||
$order_by = 'Nick';
|
||||
if (isset($_REQUEST['OrderBy']) && in_array($_REQUEST['OrderBy'], User_sortable_columns())) {
|
||||
$order_by = $_REQUEST['OrderBy'];
|
||||
}
|
||||
|
||||
$users = Users($order_by);
|
||||
if ($users === false) {
|
||||
engelsystem_error('Unable to load users.');
|
||||
}
|
||||
|
||||
foreach ($users as &$user) {
|
||||
$user['freeloads'] = count(ShiftEntries_freeloaded_by_user($user));
|
||||
}
|
||||
|
||||
return [
|
||||
_('All users'),
|
||||
Users_view(
|
||||
$users,
|
||||
$order_by,
|
||||
User_arrived_count(),
|
||||
User_active_count(),
|
||||
User_force_active_count(),
|
||||
ShiftEntries_freeleaded_count(),
|
||||
User_tshirts_count(),
|
||||
User_got_voucher_count()
|
||||
)
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Second step of password recovery: set a new password using the token link from email
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function user_password_recovery_set_new_controller() {
|
||||
global $min_password_length;
|
||||
$user_source = User_by_password_recovery_token($_REQUEST['token']);
|
||||
if ($user_source == null) {
|
||||
error(_("Token is not correct."));
|
||||
redirect(page_link_to('login'));
|
||||
}
|
||||
|
||||
if (isset($_REQUEST['submit'])) {
|
||||
$valid = true;
|
||||
|
||||
if (isset($_REQUEST['password']) && strlen($_REQUEST['password']) >= $min_password_length) {
|
||||
if ($_REQUEST['password'] != $_REQUEST['password2']) {
|
||||
$valid = false;
|
||||
error(_("Your passwords don't match."));
|
||||
}
|
||||
} else {
|
||||
$valid = false;
|
||||
error(_("Your password is to short (please use at least 6 characters)."));
|
||||
function user_password_recovery_set_new_controller()
|
||||
{
|
||||
$user_source = User_by_password_recovery_token($_REQUEST['token']);
|
||||
if ($user_source == null) {
|
||||
error(_('Token is not correct.'));
|
||||
redirect(page_link_to('login'));
|
||||
}
|
||||
|
||||
if ($valid) {
|
||||
set_password($user_source['UID'], $_REQUEST['password']);
|
||||
success(_("Password saved."));
|
||||
redirect(page_link_to('login'));
|
||||
|
||||
if (isset($_REQUEST['submit'])) {
|
||||
$valid = true;
|
||||
|
||||
if (
|
||||
isset($_REQUEST['password'])
|
||||
&& strlen($_REQUEST['password']) >= config('min_password_length')
|
||||
) {
|
||||
if ($_REQUEST['password'] != $_REQUEST['password2']) {
|
||||
$valid = false;
|
||||
error(_('Your passwords don\'t match.'));
|
||||
}
|
||||
} else {
|
||||
$valid = false;
|
||||
error(_('Your password is to short (please use at least 6 characters).'));
|
||||
}
|
||||
|
||||
if ($valid) {
|
||||
set_password($user_source['UID'], $_REQUEST['password']);
|
||||
success(_('Password saved.'));
|
||||
redirect(page_link_to('login'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return User_password_set_view();
|
||||
|
||||
return User_password_set_view();
|
||||
}
|
||||
|
||||
/**
|
||||
* First step of password recovery: display a form that asks for your email and send email with recovery link
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function user_password_recovery_start_controller() {
|
||||
if (isset($_REQUEST['submit'])) {
|
||||
$valid = true;
|
||||
|
||||
if (isset($_REQUEST['email']) && strlen(strip_request_item('email')) > 0) {
|
||||
$email = strip_request_item('email');
|
||||
if (check_email($email)) {
|
||||
$user_source = User_by_email($email);
|
||||
if ($user_source == null) {
|
||||
$valid = false;
|
||||
error(_("E-mail address is not correct."));
|
||||
function user_password_recovery_start_controller()
|
||||
{
|
||||
if (isset($_REQUEST['submit'])) {
|
||||
$valid = true;
|
||||
|
||||
if (isset($_REQUEST['email']) && strlen(strip_request_item('email')) > 0) {
|
||||
$email = strip_request_item('email');
|
||||
if (check_email($email)) {
|
||||
$user_source = User_by_email($email);
|
||||
if ($user_source == null) {
|
||||
$valid = false;
|
||||
error(_('E-mail address is not correct.'));
|
||||
}
|
||||
} else {
|
||||
$valid = false;
|
||||
error(_('E-mail address is not correct.'));
|
||||
}
|
||||
} else {
|
||||
$valid = false;
|
||||
error(_('Please enter your e-mail.'));
|
||||
}
|
||||
|
||||
if ($valid) {
|
||||
$token = User_generate_password_recovery_token($user_source);
|
||||
engelsystem_email_to_user(
|
||||
$user_source,
|
||||
_('Password recovery'),
|
||||
sprintf(
|
||||
_('Please visit %s to recover your password.'),
|
||||
page_link_to_absolute('user_password_recovery') . '&token=' . $token
|
||||
)
|
||||
);
|
||||
success(_('We sent an email containing your password recovery link.'));
|
||||
redirect(page_link_to('login'));
|
||||
}
|
||||
} else {
|
||||
$valid = false;
|
||||
error(_("E-mail address is not correct."));
|
||||
}
|
||||
} else {
|
||||
$valid = false;
|
||||
error(_("Please enter your e-mail."));
|
||||
}
|
||||
|
||||
if ($valid) {
|
||||
$token = User_generate_password_recovery_token($user_source);
|
||||
engelsystem_email_to_user($user_source, _("Password recovery"), sprintf(_("Please visit %s to recover your password."), page_link_to_absolute('user_password_recovery') . '&token=' . $token));
|
||||
success(_("We sent an email containing your password recovery link."));
|
||||
redirect(page_link_to('login'));
|
||||
}
|
||||
}
|
||||
|
||||
return User_password_recovery_view();
|
||||
|
||||
return User_password_recovery_view();
|
||||
}
|
||||
|
||||
/**
|
||||
* User password recovery in 2 steps.
|
||||
* (By email)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function user_password_recovery_controller() {
|
||||
if (isset($_REQUEST['token'])) {
|
||||
return user_password_recovery_set_new_controller();
|
||||
} else {
|
||||
function user_password_recovery_controller()
|
||||
{
|
||||
if (isset($_REQUEST['token'])) {
|
||||
return user_password_recovery_set_new_controller();
|
||||
}
|
||||
|
||||
return user_password_recovery_start_controller();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Menu title for password recovery.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function user_password_recovery_title() {
|
||||
return _("Password recovery");
|
||||
function user_password_recovery_title()
|
||||
{
|
||||
return _('Password recovery');
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads a user from param user_id.
|
||||
*
|
||||
* return array
|
||||
*/
|
||||
function load_user() {
|
||||
if (! isset($_REQUEST['user_id'])) {
|
||||
redirect(page_link_to());
|
||||
}
|
||||
|
||||
$user = User($_REQUEST['user_id']);
|
||||
if ($user === false) {
|
||||
engelsystem_error("Unable to load user.");
|
||||
}
|
||||
|
||||
if ($user == null) {
|
||||
error(_("User doesn't exist."));
|
||||
redirect(page_link_to());
|
||||
}
|
||||
|
||||
return $user;
|
||||
function load_user()
|
||||
{
|
||||
if (!isset($_REQUEST['user_id'])) {
|
||||
redirect(page_link_to());
|
||||
}
|
||||
|
||||
$user = User($_REQUEST['user_id']);
|
||||
|
||||
if ($user == null) {
|
||||
error(_('User doesn\'t exist.'));
|
||||
redirect(page_link_to());
|
||||
}
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
||||
function shiftCalendarRendererByShiftFilter(ShiftsFilter $shiftsFilter) {
|
||||
$shifts = Shifts_by_ShiftsFilter($shiftsFilter);
|
||||
$needed_angeltypes_source = NeededAngeltypes_by_ShiftsFilter($shiftsFilter);
|
||||
$shift_entries_source = ShiftEntries_by_ShiftsFilter($shiftsFilter);
|
||||
|
||||
$needed_angeltypes = [];
|
||||
$shift_entries = [];
|
||||
foreach ($shifts as $shift) {
|
||||
$needed_angeltypes[$shift['SID']] = [];
|
||||
$shift_entries[$shift['SID']] = [];
|
||||
}
|
||||
foreach ($shift_entries_source as $shift_entry) {
|
||||
if (isset($shift_entries[$shift_entry['SID']])) {
|
||||
$shift_entries[$shift_entry['SID']][] = $shift_entry;
|
||||
/**
|
||||
* @param ShiftsFilter $shiftsFilter
|
||||
* @return ShiftCalendarRenderer
|
||||
*/
|
||||
function shiftCalendarRendererByShiftFilter(ShiftsFilter $shiftsFilter)
|
||||
{
|
||||
$shifts = Shifts_by_ShiftsFilter($shiftsFilter);
|
||||
$needed_angeltypes_source = NeededAngeltypes_by_ShiftsFilter($shiftsFilter);
|
||||
$shift_entries_source = ShiftEntries_by_ShiftsFilter($shiftsFilter);
|
||||
|
||||
$needed_angeltypes = [];
|
||||
$shift_entries = [];
|
||||
foreach ($shifts as $shift) {
|
||||
$needed_angeltypes[$shift['SID']] = [];
|
||||
$shift_entries[$shift['SID']] = [];
|
||||
}
|
||||
}
|
||||
foreach ($needed_angeltypes_source as $needed_angeltype) {
|
||||
if (isset($needed_angeltypes[$needed_angeltype['SID']])) {
|
||||
$needed_angeltypes[$needed_angeltype['SID']][] = $needed_angeltype;
|
||||
foreach ($shift_entries_source as $shift_entry) {
|
||||
if (isset($shift_entries[$shift_entry['SID']])) {
|
||||
$shift_entries[$shift_entry['SID']][] = $shift_entry;
|
||||
}
|
||||
}
|
||||
}
|
||||
unset($needed_angeltypes_source);
|
||||
unset($shift_entries_source);
|
||||
|
||||
if (in_array(ShiftsFilter::FILLED_FREE, $shiftsFilter->getFilled()) && in_array(ShiftsFilter::FILLED_FILLED, $shiftsFilter->getFilled())) {
|
||||
return new ShiftCalendarRenderer($shifts, $needed_angeltypes, $shift_entries, $shiftsFilter);
|
||||
}
|
||||
|
||||
$filtered_shifts = [];
|
||||
foreach ($shifts as $shift) {
|
||||
$needed_angels_count = 0;
|
||||
foreach ($needed_angeltypes[$shift['SID']] as $needed_angeltype) {
|
||||
$taken = 0;
|
||||
foreach ($shift_entries[$shift['SID']] as $shift_entry) {
|
||||
if ($needed_angeltype['angel_type_id'] == $shift_entry['TID'] && $shift_entry['freeloaded'] == 0) {
|
||||
$taken ++;
|
||||
foreach ($needed_angeltypes_source as $needed_angeltype) {
|
||||
if (isset($needed_angeltypes[$needed_angeltype['SID']])) {
|
||||
$needed_angeltypes[$needed_angeltype['SID']][] = $needed_angeltype;
|
||||
}
|
||||
}
|
||||
|
||||
$needed_angels_count += max(0, $needed_angeltype['count'] - $taken);
|
||||
}
|
||||
if (in_array(ShiftsFilter::FILLED_FREE, $shiftsFilter->getFilled()) && $taken < $needed_angels_count) {
|
||||
$filtered_shifts[] = $shift;
|
||||
unset($needed_angeltypes_source);
|
||||
unset($shift_entries_source);
|
||||
|
||||
if (
|
||||
in_array(ShiftsFilter::FILLED_FREE, $shiftsFilter->getFilled())
|
||||
&& in_array(ShiftsFilter::FILLED_FILLED, $shiftsFilter->getFilled())
|
||||
) {
|
||||
return new ShiftCalendarRenderer($shifts, $needed_angeltypes, $shift_entries, $shiftsFilter);
|
||||
}
|
||||
if (in_array(ShiftsFilter::FILLED_FILLED, $shiftsFilter->getFilled()) && $taken >= $needed_angels_count) {
|
||||
$filtered_shifts[] = $shift;
|
||||
|
||||
$filtered_shifts = [];
|
||||
foreach ($shifts as $shift) {
|
||||
$needed_angels_count = 0;
|
||||
$taken = 0;
|
||||
foreach ($needed_angeltypes[$shift['SID']] as $needed_angeltype) {
|
||||
$taken = 0;
|
||||
foreach ($shift_entries[$shift['SID']] as $shift_entry) {
|
||||
if ($needed_angeltype['angel_type_id'] == $shift_entry['TID'] && $shift_entry['freeloaded'] == 0) {
|
||||
$taken++;
|
||||
}
|
||||
}
|
||||
|
||||
$needed_angels_count += max(0, $needed_angeltype['count'] - $taken);
|
||||
}
|
||||
if (in_array(ShiftsFilter::FILLED_FREE, $shiftsFilter->getFilled()) && $taken < $needed_angels_count) {
|
||||
$filtered_shifts[] = $shift;
|
||||
}
|
||||
if (in_array(ShiftsFilter::FILLED_FILLED, $shiftsFilter->getFilled()) && $taken >= $needed_angels_count) {
|
||||
$filtered_shifts[] = $shift;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new ShiftCalendarRenderer($filtered_shifts, $needed_angeltypes, $shift_entries, $shiftsFilter);
|
||||
}
|
||||
|
||||
?>
|
||||
return new ShiftCalendarRenderer($filtered_shifts, $needed_angeltypes, $shift_entries, $shiftsFilter);
|
||||
}
|
||||
|
||||
@ -1,26 +1,50 @@
|
||||
<?php
|
||||
|
||||
function engelsystem_email_to_user($recipient_user, $title, $message, $not_if_its_me = false) {
|
||||
global $user;
|
||||
|
||||
if ($not_if_its_me && $user['UID'] == $recipient_user['UID']) {
|
||||
return true;
|
||||
}
|
||||
|
||||
gettext_locale($recipient_user['Sprache']);
|
||||
|
||||
$message = sprintf(_("Hi %s,"), $recipient_user['Nick']) . "\n\n" . _("here is a message for you from the engelsystem:") . "\n\n" . $message . "\n\n" . _("This email is autogenerated and has not to be signed. You got this email because you are registered in the engelsystem.");
|
||||
|
||||
gettext_locale();
|
||||
return engelsystem_email($recipient_user['email'], $title, $message);
|
||||
}
|
||||
/**
|
||||
* @param array $recipient_user
|
||||
* @param string $title
|
||||
* @param string $message
|
||||
* @param bool $not_if_its_me
|
||||
* @return bool
|
||||
*/
|
||||
function engelsystem_email_to_user($recipient_user, $title, $message, $not_if_its_me = false)
|
||||
{
|
||||
global $user;
|
||||
|
||||
if ($not_if_its_me && $user['UID'] == $recipient_user['UID']) {
|
||||
return true;
|
||||
}
|
||||
|
||||
gettext_locale($recipient_user['Sprache']);
|
||||
|
||||
$message = sprintf(_('Hi %s,'), $recipient_user['Nick']) . "\n\n"
|
||||
. _('here is a message for you from the engelsystem:') . "\n\n"
|
||||
. $message . "\n\n"
|
||||
. _('This email is autogenerated and has not to be signed. You got this email because you are registered in the engelsystem.');
|
||||
|
||||
function engelsystem_email($address, $title, $message) {
|
||||
global $no_reply_email;
|
||||
$result = mail($address, $title, $message, sprintf("Content-Type: text/plain; charset=UTF-8\r\nFrom: Engelsystem <%s>", $no_reply_email));
|
||||
if ($result === false) {
|
||||
engelsystem_error('Unable to send email.');
|
||||
}
|
||||
gettext_locale();
|
||||
|
||||
return engelsystem_email($recipient_user['email'], $title, $message);
|
||||
}
|
||||
|
||||
?>
|
||||
/**
|
||||
* @param string $address
|
||||
* @param string $title
|
||||
* @param string $message
|
||||
* @return bool
|
||||
*/
|
||||
function engelsystem_email($address, $title, $message)
|
||||
{
|
||||
$result = mail(
|
||||
$address,
|
||||
$title,
|
||||
$message,
|
||||
"Content-Type: text/plain; charset=UTF-8\r\nFrom: Engelsystem <noreply@engelsystem.de>"
|
||||
);
|
||||
|
||||
if ($result === false) {
|
||||
engelsystem_error('Unable to send email.');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1,71 +1,76 @@
|
||||
<?php
|
||||
$locales = [
|
||||
'de_DE.UTF-8' => "Deutsch",
|
||||
'en_US.UTF-8' => "English"
|
||||
];
|
||||
|
||||
$default_locale = 'en_US.UTF-8';
|
||||
|
||||
/**
|
||||
* Return currently active locale
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function locale() {
|
||||
return $_SESSION['locale'];
|
||||
function locale()
|
||||
{
|
||||
return $_SESSION['locale'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns two letter language code from currently active locale
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function locale_short() {
|
||||
return substr(locale(), 0, 2);
|
||||
function locale_short()
|
||||
{
|
||||
return substr(locale(), 0, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes gettext for internationalization and updates the sessions locale to use for translation.
|
||||
*/
|
||||
function gettext_init() {
|
||||
global $locales, $default_locale;
|
||||
function gettext_init()
|
||||
{
|
||||
$locales = config('locales');
|
||||
$default_locale = config('default_locale');
|
||||
|
||||
if (isset($_REQUEST['set_locale']) && isset($locales[$_REQUEST['set_locale']])) {
|
||||
$_SESSION['locale'] = $_REQUEST['set_locale'];
|
||||
} elseif (! isset($_SESSION['locale'])) {
|
||||
$_SESSION['locale'] = $default_locale;
|
||||
}
|
||||
if (isset($_REQUEST['set_locale']) && isset($locales[$_REQUEST['set_locale']])) {
|
||||
$_SESSION['locale'] = $_REQUEST['set_locale'];
|
||||
} elseif (!isset($_SESSION['locale'])) {
|
||||
$_SESSION['locale'] = $default_locale;
|
||||
}
|
||||
|
||||
gettext_locale();
|
||||
bindtextdomain('default', realpath(__DIR__ . '/../../locale'));
|
||||
bind_textdomain_codeset('default', 'UTF-8');
|
||||
textdomain('default');
|
||||
gettext_locale();
|
||||
bindtextdomain('default', realpath(__DIR__ . '/../../locale'));
|
||||
bind_textdomain_codeset('default', 'UTF-8');
|
||||
textdomain('default');
|
||||
}
|
||||
|
||||
/**
|
||||
* Swich gettext locale.
|
||||
*
|
||||
* @param string $locale
|
||||
* @param string $locale
|
||||
*/
|
||||
function gettext_locale($locale = null) {
|
||||
if ($locale == null) {
|
||||
$locale = $_SESSION['locale'];
|
||||
}
|
||||
|
||||
putenv('LC_ALL=' . $locale);
|
||||
setlocale(LC_ALL, $locale);
|
||||
function gettext_locale($locale = null)
|
||||
{
|
||||
if ($locale == null) {
|
||||
$locale = $_SESSION['locale'];
|
||||
}
|
||||
|
||||
putenv('LC_ALL=' . $locale);
|
||||
setlocale(LC_ALL, $locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders language selection.
|
||||
*
|
||||
* @return string
|
||||
* @return array
|
||||
*/
|
||||
function make_langselect() {
|
||||
global $locales;
|
||||
$URL = $_SERVER["REQUEST_URI"] . (strpos($_SERVER["REQUEST_URI"], "?") > 0 ? '&' : '?') . "set_locale=";
|
||||
|
||||
$items = [];
|
||||
foreach ($locales as $locale => $name) {
|
||||
$items[] = toolbar_item_link(htmlspecialchars($URL) . $locale, '', '<img src="pic/flag/' . $locale . '.png" alt="' . $name . '" title="' . $name . '"> ' . $name);
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
function make_langselect()
|
||||
{
|
||||
$url = $_SERVER['REQUEST_URI'] . (strpos($_SERVER['REQUEST_URI'], '?') > 0 ? '&' : '?') . 'set_locale=';
|
||||
|
||||
?>
|
||||
$items = [];
|
||||
foreach (config('locales') as $locale => $name) {
|
||||
$items[] = toolbar_item_link(
|
||||
htmlspecialchars($url) . $locale,
|
||||
'',
|
||||
'<img src="pic/flag/' . $locale . '.png" alt="' . $name . '" title="' . $name . '"> ' . $name
|
||||
);
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
|
||||
@ -1,104 +1,129 @@
|
||||
<?php
|
||||
|
||||
function mail_shift_change($old_shift, $new_shift) {
|
||||
$users = ShiftEntries_by_shift($old_shift["SID"]);
|
||||
$old_room = Room($old_shift["RID"]);
|
||||
$new_room = Room($new_shift["RID"]);
|
||||
|
||||
$noticable_changes = false;
|
||||
|
||||
$message = _("A Shift you are registered on has changed:");
|
||||
$message .= "\n";
|
||||
|
||||
if ($old_shift["name"] != $new_shift["name"]) {
|
||||
$message .= sprintf(_("* Shift type changed from %s to %s"), $old_shift["name"], $new_shift["name"]) . "\n";
|
||||
$noticable_changes = true;
|
||||
}
|
||||
|
||||
if ($old_shift["title"] != $new_shift["title"]) {
|
||||
$message .= sprintf(_("* Shift title changed from %s to %s"), $old_shift["title"], $new_shift["title"]) . "\n";
|
||||
$noticable_changes = true;
|
||||
}
|
||||
|
||||
if ($old_shift["start"] != $new_shift["start"]) {
|
||||
$message .= sprintf(_("* Shift Start changed from %s to %s"), date("Y-m-d H:i", $old_shift["start"]), date("Y-m-d H:i", $new_shift["start"])) . "\n";
|
||||
$noticable_changes = true;
|
||||
}
|
||||
|
||||
if ($old_shift["end"] != $new_shift["end"]) {
|
||||
$message .= sprintf(_("* Shift End changed from %s to %s"), date("Y-m-d H:i", $old_shift["end"]), date("Y-m-d H:i", $new_shift["end"])) . "\n";
|
||||
$noticable_changes = true;
|
||||
}
|
||||
|
||||
if ($old_shift["RID"] != $new_shift["RID"]) {
|
||||
$message .= sprintf(_("* Shift Location changed from %s to %s"), $old_room["Name"], $new_room["Name"]) . "\n";
|
||||
$noticable_changes = true;
|
||||
}
|
||||
|
||||
if (! $noticable_changes) {
|
||||
// There are no changes worth sending an E-Mail
|
||||
return;
|
||||
}
|
||||
|
||||
$message .= "\n";
|
||||
$message .= _("The updated Shift:") . "\n";
|
||||
|
||||
$message .= $new_shift["name"] . "\n";
|
||||
$message .= $new_shift["title"] . "\n";
|
||||
$message .= date("Y-m-d H:i", $new_shift["start"]) . " - " . date("H:i", $new_shift["end"]) . "\n";
|
||||
$message .= $new_room["Name"] . "\n";
|
||||
|
||||
foreach ($users as $user) {
|
||||
if ($user["email_shiftinfo"]) {
|
||||
engelsystem_email_to_user($user, '[engelsystem] ' . _("Your Shift has changed"), $message, true);
|
||||
/**
|
||||
* @param array $old_shift
|
||||
* @param array $new_shift
|
||||
*/
|
||||
function mail_shift_change($old_shift, $new_shift)
|
||||
{
|
||||
$users = ShiftEntries_by_shift($old_shift['SID']);
|
||||
$old_room = Room($old_shift['RID']);
|
||||
$new_room = Room($new_shift['RID']);
|
||||
|
||||
$noticeable_changes = false;
|
||||
|
||||
$message = _('A Shift you are registered on has changed:');
|
||||
$message .= "\n";
|
||||
|
||||
if ($old_shift['name'] != $new_shift['name']) {
|
||||
$message .= sprintf(_('* Shift type changed from %s to %s'), $old_shift['name'], $new_shift['name']) . "\n";
|
||||
$noticeable_changes = true;
|
||||
}
|
||||
|
||||
if ($old_shift['title'] != $new_shift['title']) {
|
||||
$message .= sprintf(_('* Shift title changed from %s to %s'), $old_shift['title'], $new_shift['title']) . "\n";
|
||||
$noticeable_changes = true;
|
||||
}
|
||||
|
||||
if ($old_shift['start'] != $new_shift['start']) {
|
||||
$message .= sprintf(
|
||||
_('* Shift Start changed from %s to %s'),
|
||||
date('Y-m-d H:i', $old_shift['start']),
|
||||
date('Y-m-d H:i', $new_shift['start'])
|
||||
) . "\n";
|
||||
$noticeable_changes = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function mail_shift_delete($shift) {
|
||||
$users = ShiftEntries_by_shift($shift["SID"]);
|
||||
$room = Room($shift["RID"]);
|
||||
|
||||
$message = _("A Shift you are registered on was deleted:") . "\n";
|
||||
|
||||
$message .= $shift["name"] . "\n";
|
||||
$message .= $shift["title"] . "\n";
|
||||
$message .= date("Y-m-d H:i", $shift["start"]) . " - " . date("H:i", $shift["end"]) . "\n";
|
||||
$message .= $room["Name"] . "\n";
|
||||
|
||||
foreach ($users as $user) {
|
||||
if ($user["email_shiftinfo"]) {
|
||||
engelsystem_email_to_user($user, '[engelsystem] ' . _("Your Shift was deleted"), $message, true);
|
||||
if ($old_shift['end'] != $new_shift['end']) {
|
||||
$message .= sprintf(
|
||||
_('* Shift End changed from %s to %s'),
|
||||
date('Y-m-d H:i', $old_shift['end']),
|
||||
date('Y-m-d H:i', $new_shift['end'])
|
||||
) . "\n";
|
||||
$noticeable_changes = true;
|
||||
}
|
||||
|
||||
if ($old_shift['RID'] != $new_shift['RID']) {
|
||||
$message .= sprintf(_('* Shift Location changed from %s to %s'), $old_room['Name'], $new_room['Name']) . "\n";
|
||||
$noticeable_changes = true;
|
||||
}
|
||||
|
||||
if (!$noticeable_changes) {
|
||||
// There are no changes worth sending an E-Mail
|
||||
return;
|
||||
}
|
||||
|
||||
$message .= "\n";
|
||||
$message .= _('The updated Shift:') . "\n";
|
||||
|
||||
$message .= $new_shift['name'] . "\n";
|
||||
$message .= $new_shift['title'] . "\n";
|
||||
$message .= date('Y-m-d H:i', $new_shift['start']) . ' - ' . date('H:i', $new_shift['end']) . "\n";
|
||||
$message .= $new_room['Name'] . "\n";
|
||||
|
||||
foreach ($users as $user) {
|
||||
if ($user['email_shiftinfo']) {
|
||||
engelsystem_email_to_user($user, '[engelsystem] ' . _('Your Shift has changed'), $message, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function mail_shift_assign($user, $shift) {
|
||||
if ($user["email_shiftinfo"]) {
|
||||
$room = Room($shift["RID"]);
|
||||
|
||||
$message = _("You have been assigned to a Shift:") . "\n";
|
||||
$message .= $shift["name"] . "\n";
|
||||
$message .= $shift["title"] . "\n";
|
||||
$message .= date("Y-m-d H:i", $shift["start"]) . " - " . date("H:i", $shift["end"]) . "\n";
|
||||
$message .= $room["Name"] . "\n";
|
||||
|
||||
engelsystem_email_to_user($user, '[engelsystem] ' . _("Assigned to Shift"), $message, true);
|
||||
}
|
||||
/**
|
||||
* @param array $shift
|
||||
*/
|
||||
function mail_shift_delete($shift)
|
||||
{
|
||||
$users = ShiftEntries_by_shift($shift['SID']);
|
||||
$room = Room($shift['RID']);
|
||||
|
||||
$message = _('A Shift you are registered on was deleted:') . "\n";
|
||||
|
||||
$message .= $shift['name'] . "\n";
|
||||
$message .= $shift['title'] . "\n";
|
||||
$message .= date('Y-m-d H:i', $shift['start']) . ' - ' . date('H:i', $shift['end']) . "\n";
|
||||
$message .= $room['Name'] . "\n";
|
||||
|
||||
foreach ($users as $user) {
|
||||
if ($user['email_shiftinfo']) {
|
||||
engelsystem_email_to_user($user, '[engelsystem] ' . _('Your Shift was deleted'), $message, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function mail_shift_removed($user, $shift) {
|
||||
if ($user["email_shiftinfo"]) {
|
||||
$room = Room($shift["RID"]);
|
||||
|
||||
$message = _("You have been removed from a Shift:") . "\n";
|
||||
$message .= $shift["name"] . "\n";
|
||||
$message .= $shift["title"] . "\n";
|
||||
$message .= date("Y-m-d H:i", $shift["start"]) . " - " . date("H:i", $shift["end"]) . "\n";
|
||||
$message .= $room["Name"] . "\n";
|
||||
|
||||
engelsystem_email_to_user($user, '[engelsystem] ' . _("Removed from Shift"), $message, true);
|
||||
}
|
||||
/**
|
||||
* @param array $user
|
||||
* @param array $shift
|
||||
*/
|
||||
function mail_shift_assign($user, $shift)
|
||||
{
|
||||
if (!$user['email_shiftinfo']) {
|
||||
return;
|
||||
}
|
||||
|
||||
$room = Room($shift['RID']);
|
||||
|
||||
$message = _('You have been assigned to a Shift:') . "\n";
|
||||
$message .= $shift['name'] . "\n";
|
||||
$message .= $shift['title'] . "\n";
|
||||
$message .= date('Y-m-d H:i', $shift['start']) . ' - ' . date('H:i', $shift['end']) . "\n";
|
||||
$message .= $room['Name'] . "\n";
|
||||
|
||||
engelsystem_email_to_user($user, '[engelsystem] ' . _('Assigned to Shift'), $message, true);
|
||||
}
|
||||
|
||||
?>
|
||||
function mail_shift_removed($user, $shift)
|
||||
{
|
||||
if (!$user['email_shiftinfo']) {
|
||||
return;
|
||||
}
|
||||
|
||||
$room = Room($shift['RID']);
|
||||
|
||||
$message = _('You have been removed from a Shift:') . "\n";
|
||||
$message .= $shift['name'] . "\n";
|
||||
$message .= $shift['title'] . "\n";
|
||||
$message .= date('Y-m-d H:i', $shift['start']) . ' - ' . date('H:i', $shift['end']) . "\n";
|
||||
$message .= $room['Name'] . "\n";
|
||||
|
||||
engelsystem_email_to_user($user, '[engelsystem] ' . _('Removed from Shift'), $message, true);
|
||||
}
|
||||
|
||||
@ -1,9 +1,14 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @param User $user_source
|
||||
* @param array $user
|
||||
* @return bool
|
||||
*/
|
||||
function mail_user_delete($user) {
|
||||
engelsystem_email_to_user($user, '[engelsystem] ' . _("Your account has been deleted"), _("Your angelsystem account has been deleted. If you have any questions regarding your account deletion, please contact heaven."));
|
||||
function mail_user_delete($user)
|
||||
{
|
||||
return engelsystem_email_to_user(
|
||||
$user,
|
||||
'[engelsystem] ' . _('Your account has been deleted'),
|
||||
_('Your angelsystem account has been deleted. If you have any questions regarding your account deletion, please contact heaven.')
|
||||
);
|
||||
}
|
||||
?>
|
||||
@ -1,236 +1,298 @@
|
||||
<?php
|
||||
|
||||
use Engelsystem\Database\DB;
|
||||
use Engelsystem\ValidationResult;
|
||||
|
||||
/**
|
||||
* Returns an array containing the basic attributes of angeltypes.
|
||||
* FIXME! This is the big sign for needing entity objects
|
||||
*/
|
||||
function AngelType_new() {
|
||||
return [
|
||||
'id' => null,
|
||||
'name' => "",
|
||||
'restricted' => false,
|
||||
'no_self_signup' => false,
|
||||
'description' => '',
|
||||
'requires_driver_license' => false,
|
||||
'contact_user_id' => null,
|
||||
'contact_name' => null,
|
||||
'contact_dect' => null,
|
||||
'contact_email' => null
|
||||
];
|
||||
function AngelType_new()
|
||||
{
|
||||
return [
|
||||
'id' => null,
|
||||
'name' => '',
|
||||
'restricted' => false,
|
||||
'no_self_signup' => false,
|
||||
'description' => '',
|
||||
'requires_driver_license' => false,
|
||||
'contact_user_id' => null,
|
||||
'contact_name' => null,
|
||||
'contact_dect' => null,
|
||||
'contact_email' => null
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the contact user
|
||||
*
|
||||
* @param Angeltype $angeltype
|
||||
* The angeltype
|
||||
* @param array $angeltype The angeltype
|
||||
* @return ValidationResult
|
||||
*/
|
||||
function AngelType_validate_contact_user_id($angeltype) {
|
||||
if (! isset($angeltype['contact_user_id'])) {
|
||||
return new ValidationResult(true, null);
|
||||
}
|
||||
if (isset($angeltype['contact_name']) || isset($angeltype['contact_dect']) || isset($angeltype['contact_email'])) {
|
||||
return new ValidationResult(false, $angeltype['contact_user_id']);
|
||||
}
|
||||
if (User($angeltype['contact_user_id']) == null) {
|
||||
return new ValidationResult(false, $angeltype['contact_user_id']);
|
||||
}
|
||||
return new ValidationResult(true, $angeltype['contact_user_id']);
|
||||
function AngelType_validate_contact_user_id($angeltype)
|
||||
{
|
||||
if (!isset($angeltype['contact_user_id'])) {
|
||||
return new ValidationResult(true, null);
|
||||
}
|
||||
if (isset($angeltype['contact_name']) || isset($angeltype['contact_dect']) || isset($angeltype['contact_email'])) {
|
||||
return new ValidationResult(false, $angeltype['contact_user_id']);
|
||||
}
|
||||
if (User($angeltype['contact_user_id']) == null) {
|
||||
return new ValidationResult(false, $angeltype['contact_user_id']);
|
||||
}
|
||||
return new ValidationResult(true, $angeltype['contact_user_id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns contact data (name, dect, email) for given angeltype or null
|
||||
*
|
||||
* @param Angeltype $angeltype
|
||||
* The angeltype
|
||||
* @param array $angeltype The angeltype
|
||||
* @return array|null
|
||||
*/
|
||||
function AngelType_contact_info($angeltype) {
|
||||
if (isset($angeltype['contact_user_id'])) {
|
||||
$contact_user = User($angeltype['contact_user_id']);
|
||||
$contact_data = [
|
||||
'contact_name' => $contact_user['Nick'],
|
||||
'contact_dect' => $contact_user['DECT']
|
||||
];
|
||||
if ($contact_user['email_by_human_allowed']) {
|
||||
$contact_data['contact_email'] = $contact_user['email'];
|
||||
function AngelType_contact_info($angeltype)
|
||||
{
|
||||
if (isset($angeltype['contact_user_id'])) {
|
||||
$contact_user = User($angeltype['contact_user_id']);
|
||||
$contact_data = [
|
||||
'contact_name' => $contact_user['Nick'],
|
||||
'contact_dect' => $contact_user['DECT']
|
||||
];
|
||||
if ($contact_user['email_by_human_allowed']) {
|
||||
$contact_data['contact_email'] = $contact_user['email'];
|
||||
}
|
||||
return $contact_data;
|
||||
}
|
||||
return $contact_data;
|
||||
}
|
||||
if (isset($angeltype['contact_name'])) {
|
||||
return [
|
||||
'contact_name' => $angeltype['contact_name'],
|
||||
'contact_dect' => $angeltype['contact_dect'],
|
||||
'contact_email' => $angeltype['contact_email']
|
||||
];
|
||||
}
|
||||
return null;
|
||||
if (isset($angeltype['contact_name'])) {
|
||||
return [
|
||||
'contact_name' => $angeltype['contact_name'],
|
||||
'contact_dect' => $angeltype['contact_dect'],
|
||||
'contact_email' => $angeltype['contact_email']
|
||||
];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete an Angeltype.
|
||||
*
|
||||
* @param Angeltype $angeltype
|
||||
* @param array $angeltype
|
||||
* @return bool
|
||||
*/
|
||||
function AngelType_delete($angeltype) {
|
||||
$result = sql_query("
|
||||
DELETE FROM `AngelTypes`
|
||||
WHERE `id`='" . sql_escape($angeltype['id']) . "'
|
||||
LIMIT 1");
|
||||
if ($result === false) {
|
||||
engelsystem_error("Unable to delete angeltype.");
|
||||
}
|
||||
engelsystem_log("Deleted angeltype: " . AngelType_name_render($angeltype));
|
||||
return $result;
|
||||
function AngelType_delete($angeltype)
|
||||
{
|
||||
$result = DB::delete('
|
||||
DELETE FROM `AngelTypes`
|
||||
WHERE `id`=?
|
||||
LIMIT 1
|
||||
', [$angeltype['id']]);
|
||||
if (is_null($result)) {
|
||||
engelsystem_error('Unable to delete angeltype.');
|
||||
}
|
||||
engelsystem_log('Deleted angeltype: ' . AngelType_name_render($angeltype));
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update Angeltype.
|
||||
*
|
||||
* @param Angeltype $angeltype
|
||||
* The angeltype
|
||||
* @param array $angeltype The angeltype
|
||||
* @return bool
|
||||
*/
|
||||
function AngelType_update($angeltype) {
|
||||
$result = sql_query("
|
||||
UPDATE `AngelTypes` SET
|
||||
`name`='" . sql_escape($angeltype['name']) . "',
|
||||
`restricted`=" . sql_bool($angeltype['restricted']) . ",
|
||||
`description`='" . sql_escape($angeltype['description']) . "',
|
||||
`requires_driver_license`=" . sql_bool($angeltype['requires_driver_license']) . ",
|
||||
`no_self_signup`=" . sql_bool($angeltype['no_self_signup']) . ",
|
||||
`contact_user_id`=" . sql_null($angeltype['contact_user_id']) . ",
|
||||
`contact_name`=" . sql_null($angeltype['contact_name']) . ",
|
||||
`contact_dect`=" . sql_null($angeltype['contact_dect']) . ",
|
||||
`contact_email`=" . sql_null($angeltype['contact_email']) . "
|
||||
WHERE `id`='" . sql_escape($angeltype['id']) . "'");
|
||||
if ($result === false) {
|
||||
engelsystem_error("Unable to update angeltype.");
|
||||
}
|
||||
engelsystem_log("Updated angeltype: " . $angeltype['name'] . ($angeltype['restricted'] ? ", restricted" : "") . ($angeltype['no_self_signup'] ? ", no_self_signup" : "") . ($angeltype['requires_driver_license'] ? ", requires driver license" : ""));
|
||||
return $result;
|
||||
function AngelType_update($angeltype)
|
||||
{
|
||||
$result = DB::update('
|
||||
UPDATE `AngelTypes` SET
|
||||
`name` = ?,
|
||||
`restricted` = ?,
|
||||
`description` = ?,
|
||||
`requires_driver_license` = ?,
|
||||
`no_self_signup` = ?,
|
||||
`contact_user_id` = ?,
|
||||
`contact_name` = ?,
|
||||
`contact_dect` = ?,
|
||||
`contact_email` = ?
|
||||
WHERE `id` = ?',
|
||||
[
|
||||
$angeltype['name'],
|
||||
$angeltype['restricted'],
|
||||
$angeltype['description'],
|
||||
$angeltype['requires_driver_license'],
|
||||
$angeltype['no_self_signup'],
|
||||
$angeltype['contact_user_id'],
|
||||
$angeltype['contact_name'],
|
||||
$angeltype['contact_dect'],
|
||||
$angeltype['contact_email'],
|
||||
$angeltype['id'],
|
||||
]
|
||||
);
|
||||
if (is_null($result)) {
|
||||
engelsystem_error('Unable to update angeltype.');
|
||||
}
|
||||
engelsystem_log(
|
||||
'Updated angeltype: ' . $angeltype['name'] . ($angeltype['restricted'] ? ', restricted' : '')
|
||||
. ($angeltype['no_self_signup'] ? ', no_self_signup' : '')
|
||||
. ($angeltype['requires_driver_license'] ? ', requires driver license' : '')
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an Angeltype.
|
||||
*
|
||||
* @param Angeltype $angeltype
|
||||
* The angeltype
|
||||
* @return the created angeltype
|
||||
* @param array $angeltype The angeltype
|
||||
* @return array the created angeltype
|
||||
*/
|
||||
function AngelType_create($angeltype) {
|
||||
$result = sql_query("
|
||||
INSERT INTO `AngelTypes` SET
|
||||
`name`='" . sql_escape($angeltype['name']) . "',
|
||||
`restricted`=" . sql_bool($angeltype['restricted']) . ",
|
||||
`description`='" . sql_escape($angeltype['description']) . "',
|
||||
`requires_driver_license`=" . sql_bool($angeltype['requires_driver_license']) . ",
|
||||
`no_self_signup`=" . sql_bool($angeltype['no_self_signup']) . ",
|
||||
`contact_user_id`=" . sql_null($angeltype['contact_user_id']) . ",
|
||||
`contact_name`=" . sql_null($angeltype['contact_name']) . ",
|
||||
`contact_dect`=" . sql_null($angeltype['contact_dect']) . ",
|
||||
`contact_email`=" . sql_null($angeltype['contact_email']));
|
||||
if ($result === false) {
|
||||
engelsystem_error("Unable to create angeltype.");
|
||||
}
|
||||
$angeltype['id'] = sql_id();
|
||||
engelsystem_log("Created angeltype: " . $angeltype['name'] . ($angeltype['restricted'] ? ", restricted" : "") . ($angeltype['requires_driver_license'] ? ", requires driver license" : ""));
|
||||
return $angeltype;
|
||||
function AngelType_create($angeltype)
|
||||
{
|
||||
$result = DB::insert('
|
||||
INSERT INTO `AngelTypes` (
|
||||
`name`,
|
||||
`restricted`,
|
||||
`description`,
|
||||
`requires_driver_license`,
|
||||
`no_self_signup`,
|
||||
`contact_user_id`,
|
||||
`contact_name`,
|
||||
`contact_dect`,
|
||||
`contact_email`
|
||||
)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
',
|
||||
[
|
||||
$angeltype['name'],
|
||||
(bool)$angeltype['restricted'],
|
||||
$angeltype['description'],
|
||||
(bool)$angeltype['requires_driver_license'],
|
||||
(bool)$angeltype['no_self_signup'],
|
||||
$angeltype['contact_user_id'],
|
||||
$angeltype['contact_name'],
|
||||
$angeltype['contact_dect'],
|
||||
$angeltype['contact_email'],
|
||||
]
|
||||
);
|
||||
if (is_null($result)) {
|
||||
engelsystem_error('Unable to create angeltype.');
|
||||
}
|
||||
$angeltype['id'] = DB::getPdo()->lastInsertId();
|
||||
engelsystem_log(
|
||||
'Created angeltype: ' . $angeltype['name']
|
||||
. ($angeltype['restricted'] ? ', restricted' : '')
|
||||
. ($angeltype['requires_driver_license'] ? ', requires driver license' : '')
|
||||
);
|
||||
return $angeltype;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates a name for angeltypes.
|
||||
* Returns ValidationResult containing validation success and validated name.
|
||||
*
|
||||
* @param string $name
|
||||
* Wanted name for the angeltype
|
||||
* @param AngelType $angeltype
|
||||
* The angeltype the name is for
|
||||
* @param string $name Wanted name for the angeltype
|
||||
* @param array $angeltype The angeltype the name is for
|
||||
*
|
||||
* @return ValidationResult result and validated name
|
||||
*/
|
||||
function AngelType_validate_name($name, $angeltype) {
|
||||
$name = strip_item($name);
|
||||
if ($name == "") {
|
||||
return new ValidationResult(false, "");
|
||||
}
|
||||
if ($angeltype != null && isset($angeltype['id'])) {
|
||||
$valid = sql_num_query("
|
||||
SELECT *
|
||||
FROM `AngelTypes`
|
||||
WHERE `name`='" . sql_escape($name) . "'
|
||||
AND NOT `id`='" . sql_escape($angeltype['id']) . "'
|
||||
LIMIT 1") == 0;
|
||||
function AngelType_validate_name($name, $angeltype)
|
||||
{
|
||||
$name = strip_item($name);
|
||||
if ($name == '') {
|
||||
return new ValidationResult(false, '');
|
||||
}
|
||||
if ($angeltype != null && isset($angeltype['id'])) {
|
||||
$valid = (count(DB::select('
|
||||
SELECT `id`
|
||||
FROM `AngelTypes`
|
||||
WHERE `name`=?
|
||||
AND NOT `id`=?
|
||||
LIMIT 1
|
||||
', [$name, $angeltype['id']])) == 0);
|
||||
return new ValidationResult($valid, $name);
|
||||
}
|
||||
$valid = (count(DB::select('
|
||||
SELECT `id`
|
||||
FROM `AngelTypes`
|
||||
WHERE `name`=?
|
||||
LIMIT 1', [$name])) == 0);
|
||||
return new ValidationResult($valid, $name);
|
||||
}
|
||||
$valid = sql_num_query("
|
||||
SELECT `id`
|
||||
FROM `AngelTypes`
|
||||
WHERE `name`='" . sql_escape($name) . "'
|
||||
LIMIT 1") == 0;
|
||||
return new ValidationResult($valid, $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all angeltypes and subscription state to each of them for given user.
|
||||
*
|
||||
* @param User $user
|
||||
* @param array $user
|
||||
* @return array
|
||||
*/
|
||||
function AngelTypes_with_user($user) {
|
||||
$result = sql_select("
|
||||
SELECT `AngelTypes`.*,
|
||||
`UserAngelTypes`.`id` as `user_angeltype_id`,
|
||||
function AngelTypes_with_user($user)
|
||||
{
|
||||
$result = DB::select('
|
||||
SELECT `AngelTypes`.*,
|
||||
`UserAngelTypes`.`id` AS `user_angeltype_id`,
|
||||
`UserAngelTypes`.`confirm_user_id`,
|
||||
`UserAngelTypes`.`supporter`
|
||||
FROM `AngelTypes`
|
||||
LEFT JOIN `UserAngelTypes` ON `AngelTypes`.`id`=`UserAngelTypes`.`angeltype_id`
|
||||
AND `UserAngelTypes`.`user_id`=" . $user['UID'] . "
|
||||
ORDER BY `name`");
|
||||
if ($result === false) {
|
||||
engelsystem_error("Unable to load angeltypes.");
|
||||
}
|
||||
return $result;
|
||||
FROM `AngelTypes`
|
||||
LEFT JOIN `UserAngelTypes` ON `AngelTypes`.`id`=`UserAngelTypes`.`angeltype_id`
|
||||
AND `UserAngelTypes`.`user_id` = ?
|
||||
ORDER BY `name`', [$user['UID']]);
|
||||
|
||||
if (DB::getStm()->errorCode() != '00000') {
|
||||
engelsystem_error('Unable to load angeltypes.');
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all angeltypes.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function AngelTypes() {
|
||||
$result = sql_select("
|
||||
SELECT *
|
||||
FROM `AngelTypes`
|
||||
ORDER BY `name`");
|
||||
if ($result === false) {
|
||||
engelsystem_error("Unable to load angeltypes.");
|
||||
}
|
||||
return $result;
|
||||
function AngelTypes()
|
||||
{
|
||||
$result = DB::select('
|
||||
SELECT *
|
||||
FROM `AngelTypes`
|
||||
ORDER BY `name`');
|
||||
|
||||
if (DB::getStm()->errorCode() != '00000') {
|
||||
engelsystem_error('Unable to load angeltypes.');
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns AngelType id array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function AngelType_ids() {
|
||||
$result = sql_select("SELECT `id` FROM `AngelTypes`");
|
||||
if ($result === false) {
|
||||
engelsystem_error("Unable to load angeltypes.");
|
||||
}
|
||||
return select_array($result, 'id', 'id');
|
||||
function AngelType_ids()
|
||||
{
|
||||
$result = DB::select('SELECT `id` FROM `AngelTypes`');
|
||||
|
||||
if (DB::getStm()->errorCode() != '00000') {
|
||||
engelsystem_error('Unable to load angeltypes.');
|
||||
}
|
||||
return select_array($result, 'id', 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns angelType by id.
|
||||
*
|
||||
* @param $angeltype_id angelType
|
||||
* ID
|
||||
* @param int $angeltype_id angelType ID
|
||||
* @return array|null
|
||||
*/
|
||||
function AngelType($angeltype_id) {
|
||||
$angelType_source = sql_select("SELECT * FROM `AngelTypes` WHERE `id`='" . sql_escape($angeltype_id) . "'");
|
||||
if ($angelType_source === false) {
|
||||
engelsystem_error("Unable to load angeltype.");
|
||||
}
|
||||
if (count($angelType_source) > 0) {
|
||||
return $angelType_source[0];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
function AngelType($angeltype_id)
|
||||
{
|
||||
$angelType_source = DB::select(
|
||||
'SELECT * FROM `AngelTypes` WHERE `id`=?',
|
||||
[$angeltype_id]
|
||||
);
|
||||
|
||||
if (DB::getStm()->errorCode() != '00000') {
|
||||
engelsystem_error('Unable to load angeltype.');
|
||||
}
|
||||
|
||||
?>
|
||||
if (empty($angelType_source)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return array_shift($angelType_source);
|
||||
}
|
||||
|
||||
@ -1,60 +1,82 @@
|
||||
<?php
|
||||
|
||||
use Engelsystem\Database\DB;
|
||||
|
||||
/**
|
||||
* returns a list of rooms.
|
||||
*
|
||||
* @param boolean $show_all returns also hidden rooms when true
|
||||
* @return array
|
||||
*/
|
||||
function Rooms($show_all = false) {
|
||||
return sql_select("SELECT * FROM `Room`" . ($show_all ? "" : " WHERE `show`='Y'") . " ORDER BY `Name`");
|
||||
function Rooms($show_all = false)
|
||||
{
|
||||
return DB::select('SELECT * FROM `Room`' . ($show_all ? '' : ' WHERE `show`=\'Y\'') . ' ORDER BY `Name`');
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a room
|
||||
*
|
||||
* @param int $room_id
|
||||
* @param int $room_id
|
||||
* @return bool
|
||||
*/
|
||||
function Room_delete($room_id) {
|
||||
return sql_query("DELETE FROM `Room` WHERE `RID`=" . sql_escape($room_id));
|
||||
function Room_delete($room_id)
|
||||
{
|
||||
return DB::delete('DELETE FROM `Room` WHERE `RID` = ?', [$room_id]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new room
|
||||
*
|
||||
* @param string $name
|
||||
* Name of the room
|
||||
* @param boolean $from_frab
|
||||
* Is this a frab imported room?
|
||||
* @param boolean $public
|
||||
* Is the room visible for angels?
|
||||
* @param string $name Name of the room
|
||||
* @param boolean $from_frab Is this a frab imported room?
|
||||
* @param boolean $public Is the room visible for angels?
|
||||
* @param int $number Room number
|
||||
* @return false|int
|
||||
*/
|
||||
function Room_create($name, $from_frab, $public) {
|
||||
$result = sql_query("
|
||||
INSERT INTO `Room` SET
|
||||
`Name`='" . sql_escape($name) . "',
|
||||
`FromPentabarf`='" . sql_escape($from_frab ? 'Y' : '') . "',
|
||||
`show`='" . sql_escape($public ? 'Y' : '') . "',
|
||||
`Number`=0");
|
||||
if ($result === false) {
|
||||
return false;
|
||||
}
|
||||
return sql_id();
|
||||
function Room_create($name, $from_frab, $public, $number = null)
|
||||
{
|
||||
$result = DB::insert('
|
||||
INSERT INTO `Room` (`Name`, `FromPentabarf`, `show`, `Number`)
|
||||
VALUES (?, ?, ?, ?)
|
||||
',
|
||||
[
|
||||
$name,
|
||||
$from_frab ? 'Y' : '',
|
||||
$public ? 'Y' : '',
|
||||
(int)$number,
|
||||
]
|
||||
);
|
||||
if (!$result) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return DB::getPdo()->lastInsertId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns room by id.
|
||||
*
|
||||
* @param $room_id RID
|
||||
* @param int $room_id RID
|
||||
* @param bool $show_only
|
||||
* @return array|false
|
||||
*/
|
||||
function Room($room_id) {
|
||||
$room_source = sql_select("SELECT * FROM `Room` WHERE `RID`='" . sql_escape($room_id) . "'");
|
||||
|
||||
if ($room_source === false) {
|
||||
return false;
|
||||
}
|
||||
if (count($room_source) > 0) {
|
||||
return $room_source[0];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
function Room($room_id, $show_only = true)
|
||||
{
|
||||
$room_source = DB::select('
|
||||
SELECT *
|
||||
FROM `Room`
|
||||
WHERE `RID` = ?
|
||||
' . ($show_only ? 'AND `show` = \'Y\'' : ''),
|
||||
[$room_id]
|
||||
);
|
||||
|
||||
?>
|
||||
if (DB::getStm()->errorCode() != '00000') {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (empty($room_source)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return array_shift($room_source);
|
||||
}
|
||||
|
||||
@ -1,69 +1,105 @@
|
||||
<?php
|
||||
|
||||
use Engelsystem\Database\DB;
|
||||
|
||||
/**
|
||||
* Delete a shift type.
|
||||
*
|
||||
* @param int $shifttype_id
|
||||
* @return bool
|
||||
*/
|
||||
function ShiftType_delete($shifttype_id) {
|
||||
return sql_query("DELETE FROM `ShiftTypes` WHERE `id`='" . sql_escape($shifttype_id) . "'");
|
||||
function ShiftType_delete($shifttype_id)
|
||||
{
|
||||
return DB::delete('DELETE FROM `ShiftTypes` WHERE `id`=?', [$shifttype_id]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a shift type.
|
||||
*
|
||||
* @param int $shifttype_id
|
||||
* @param string $name
|
||||
* @param int $angeltype_id
|
||||
* @param string $description
|
||||
* @param int $shifttype_id
|
||||
* @param string $name
|
||||
* @param int $angeltype_id
|
||||
* @param string $description
|
||||
* @return bool
|
||||
*/
|
||||
function ShiftType_update($shifttype_id, $name, $angeltype_id, $description) {
|
||||
return sql_query("UPDATE `ShiftTypes` SET
|
||||
`name`='" . sql_escape($name) . "',
|
||||
`angeltype_id`=" . sql_null($angeltype_id) . ",
|
||||
`description`='" . sql_escape($description) . "'
|
||||
WHERE `id`='" . sql_escape($shifttype_id) . "'");
|
||||
function ShiftType_update($shifttype_id, $name, $angeltype_id, $description)
|
||||
{
|
||||
DB::update('
|
||||
UPDATE `ShiftTypes` SET
|
||||
`name`=?,
|
||||
`angeltype_id`=?,
|
||||
`description`=?
|
||||
WHERE `id`=?
|
||||
',
|
||||
[
|
||||
$name,
|
||||
$angeltype_id,
|
||||
$description,
|
||||
$shifttype_id,
|
||||
]
|
||||
);
|
||||
|
||||
return DB::getStm()->errorCode() == '00000';
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a shift type.
|
||||
*
|
||||
* @param string $name
|
||||
* @param int $angeltype_id
|
||||
* @param string $description
|
||||
* @return new shifttype id
|
||||
* @param string $name
|
||||
* @param int $angeltype_id
|
||||
* @param string $description
|
||||
* @return int|false new shifttype id
|
||||
*/
|
||||
function ShiftType_create($name, $angeltype_id, $description) {
|
||||
$result = sql_query("INSERT INTO `ShiftTypes` SET
|
||||
`name`='" . sql_escape($name) . "',
|
||||
`angeltype_id`=" . sql_null($angeltype_id) . ",
|
||||
`description`='" . sql_escape($description) . "'");
|
||||
if ($result === false) {
|
||||
return false;
|
||||
}
|
||||
return sql_id();
|
||||
function ShiftType_create($name, $angeltype_id, $description)
|
||||
{
|
||||
$result = DB::insert('
|
||||
INSERT INTO `ShiftTypes` (`name`, `angeltype_id`, `description`)
|
||||
VALUES(?, ?, ?)
|
||||
',
|
||||
[
|
||||
$name,
|
||||
$angeltype_id,
|
||||
$description
|
||||
]
|
||||
);
|
||||
|
||||
if ($result === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return DB::getPdo()->lastInsertId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a shift type by id.
|
||||
*
|
||||
* @param int $shifttype_id
|
||||
* @param int $shifttype_id
|
||||
* @return array|null
|
||||
*/
|
||||
function ShiftType($shifttype_id) {
|
||||
$shifttype = sql_select("SELECT * FROM `ShiftTypes` WHERE `id`='" . sql_escape($shifttype_id) . "'");
|
||||
if ($shifttype === false) {
|
||||
engelsystem_error('Unable to load shift type.');
|
||||
}
|
||||
if ($shifttype == null) {
|
||||
return null;
|
||||
}
|
||||
return $shifttype[0];
|
||||
function ShiftType($shifttype_id)
|
||||
{
|
||||
$shifttype = DB::select('SELECT * FROM `ShiftTypes` WHERE `id`=?', [$shifttype_id]);
|
||||
if (DB::getStm()->errorCode() != '00000') {
|
||||
engelsystem_error('Unable to load shift type.');
|
||||
}
|
||||
if (empty($shifttype)) {
|
||||
return null;
|
||||
}
|
||||
return array_shift($shifttype);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all shift types.
|
||||
*
|
||||
* @return array|false
|
||||
*/
|
||||
function ShiftTypes() {
|
||||
return sql_select("SELECT * FROM `ShiftTypes` ORDER BY `name`");
|
||||
}
|
||||
function ShiftTypes()
|
||||
{
|
||||
$result = DB::select('SELECT * FROM `ShiftTypes` ORDER BY `name`');
|
||||
|
||||
?>
|
||||
if (DB::getStm()->errorCode() != '00000') {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@ -1,432 +1,641 @@
|
||||
<?php
|
||||
|
||||
use Engelsystem\Database\DB;
|
||||
use Engelsystem\ShiftsFilter;
|
||||
use Engelsystem\ShiftSignupState;
|
||||
|
||||
function Shifts_by_room($room) {
|
||||
$result = sql_select("SELECT * FROM `Shifts` WHERE `RID`=" . sql_escape($room['RID']) . " ORDER BY `start`");
|
||||
if ($result === false) {
|
||||
engelsystem_error("Unable to load shifts.");
|
||||
}
|
||||
return $result;
|
||||
/**
|
||||
* @param array $room
|
||||
* @return array
|
||||
*/
|
||||
function Shifts_by_room($room)
|
||||
{
|
||||
$result = DB::select('SELECT * FROM `Shifts` WHERE `RID`=? ORDER BY `start`', [$room['RID']]);
|
||||
if (DB::getStm()->errorCode() != '00000') {
|
||||
engelsystem_error('Unable to load shifts.');
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
function Shifts_by_ShiftsFilter(ShiftsFilter $shiftsFilter) {
|
||||
$SQL = "SELECT * FROM (
|
||||
SELECT DISTINCT `Shifts`.*, `ShiftTypes`.`name`, `Room`.`Name` as `room_name`
|
||||
/**
|
||||
* @param ShiftsFilter $shiftsFilter
|
||||
* @return array[]
|
||||
*/
|
||||
function Shifts_by_ShiftsFilter(ShiftsFilter $shiftsFilter)
|
||||
{
|
||||
$sql = 'SELECT * FROM (
|
||||
SELECT DISTINCT `Shifts`.*, `ShiftTypes`.`name`, `Room`.`Name` AS `room_name`
|
||||
FROM `Shifts`
|
||||
JOIN `Room` USING (`RID`)
|
||||
JOIN `ShiftTypes` ON `ShiftTypes`.`id` = `Shifts`.`shifttype_id`
|
||||
JOIN `NeededAngelTypes` ON `NeededAngelTypes`.`shift_id`=`Shifts`.`SID`
|
||||
WHERE `Shifts`.`RID` IN (" . implode(',', $shiftsFilter->getRooms()) . ")
|
||||
AND `start` BETWEEN " . $shiftsFilter->getStartTime() . " AND " . $shiftsFilter->getEndTime() . "
|
||||
AND `NeededAngelTypes`.`angel_type_id` IN (" . implode(',', $shiftsFilter->getTypes()) . ")
|
||||
WHERE `Shifts`.`RID` IN (' . implode(',', $shiftsFilter->getRooms()) . ')
|
||||
AND `start` BETWEEN ? AND ?
|
||||
AND `NeededAngelTypes`.`angel_type_id` IN (' . implode(',', $shiftsFilter->getTypes()) . ')
|
||||
AND `NeededAngelTypes`.`count` > 0
|
||||
AND `Shifts`.`PSID` IS NULL
|
||||
|
||||
|
||||
UNION
|
||||
|
||||
SELECT DISTINCT `Shifts`.*, `ShiftTypes`.`name`, `Room`.`Name` as `room_name`
|
||||
|
||||
SELECT DISTINCT `Shifts`.*, `ShiftTypes`.`name`, `Room`.`Name` AS `room_name`
|
||||
FROM `Shifts`
|
||||
JOIN `Room` USING (`RID`)
|
||||
JOIN `ShiftTypes` ON `ShiftTypes`.`id` = `Shifts`.`shifttype_id`
|
||||
JOIN `NeededAngelTypes` ON `NeededAngelTypes`.`room_id`=`Shifts`.`RID`
|
||||
WHERE `Shifts`.`RID` IN (" . implode(',', $shiftsFilter->getRooms()) . ")
|
||||
AND `start` BETWEEN " . $shiftsFilter->getStartTime() . " AND " . $shiftsFilter->getEndTime() . "
|
||||
AND `NeededAngelTypes`.`angel_type_id` IN (" . implode(',', $shiftsFilter->getTypes()) . ")
|
||||
WHERE `Shifts`.`RID` IN (' . implode(',', $shiftsFilter->getRooms()) . ')
|
||||
AND `start` BETWEEN ? AND ?
|
||||
AND `NeededAngelTypes`.`angel_type_id` IN (' . implode(',', $shiftsFilter->getTypes()) . ')
|
||||
AND `NeededAngelTypes`.`count` > 0
|
||||
AND NOT `Shifts`.`PSID` IS NULL) as tmp_shifts
|
||||
|
||||
ORDER BY `start`";
|
||||
$result = sql_select($SQL);
|
||||
if ($result === false) {
|
||||
engelsystem_error("Unable to load shifts by filter.");
|
||||
}
|
||||
return $result;
|
||||
AND NOT `Shifts`.`PSID` IS NULL) AS tmp_shifts
|
||||
|
||||
ORDER BY `start`';
|
||||
$result = DB::select(
|
||||
$sql,
|
||||
[
|
||||
$shiftsFilter->getStartTime(),
|
||||
$shiftsFilter->getEndTime(),
|
||||
$shiftsFilter->getStartTime(),
|
||||
$shiftsFilter->getEndTime(),
|
||||
]
|
||||
);
|
||||
if (DB::getStm()->errorCode() != '00000') {
|
||||
engelsystem_error('Unable to load shifts by filter.');
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
function NeededAngeltypes_by_ShiftsFilter(ShiftsFilter $shiftsFilter) {
|
||||
$SQL = "SELECT `NeededAngelTypes`.*, `Shifts`.`SID`, `AngelTypes`.`id`, `AngelTypes`.`name`, `AngelTypes`.`restricted`, `AngelTypes`.`no_self_signup`
|
||||
/**
|
||||
* @param ShiftsFilter $shiftsFilter
|
||||
* @return array[]
|
||||
*/
|
||||
function NeededAngeltypes_by_ShiftsFilter(ShiftsFilter $shiftsFilter)
|
||||
{
|
||||
$sql = '
|
||||
SELECT
|
||||
`NeededAngelTypes`.*,
|
||||
`Shifts`.`SID`,
|
||||
`AngelTypes`.`id`,
|
||||
`AngelTypes`.`name`,
|
||||
`AngelTypes`.`restricted`,
|
||||
`AngelTypes`.`no_self_signup`
|
||||
FROM `Shifts`
|
||||
JOIN `NeededAngelTypes` ON `NeededAngelTypes`.`shift_id`=`Shifts`.`SID`
|
||||
JOIN `AngelTypes` ON `AngelTypes`.`id`= `NeededAngelTypes`.`angel_type_id`
|
||||
WHERE `Shifts`.`RID` IN (" . implode(',', $shiftsFilter->getRooms()) . ")
|
||||
AND `start` BETWEEN " . $shiftsFilter->getStartTime() . " AND " . $shiftsFilter->getEndTime() . "
|
||||
WHERE `Shifts`.`RID` IN (' . implode(',', $shiftsFilter->getRooms()) . ')
|
||||
AND `start` BETWEEN ? AND ?
|
||||
AND `Shifts`.`PSID` IS NULL
|
||||
|
||||
UNION
|
||||
|
||||
SELECT `NeededAngelTypes`.*, `Shifts`.`SID`, `AngelTypes`.`id`, `AngelTypes`.`name`, `AngelTypes`.`restricted`, `AngelTypes`.`no_self_signup`
|
||||
SELECT
|
||||
`NeededAngelTypes`.*,
|
||||
`Shifts`.`SID`,
|
||||
`AngelTypes`.`id`,
|
||||
`AngelTypes`.`name`,
|
||||
`AngelTypes`.`restricted`,
|
||||
`AngelTypes`.`no_self_signup`
|
||||
FROM `Shifts`
|
||||
JOIN `NeededAngelTypes` ON `NeededAngelTypes`.`room_id`=`Shifts`.`RID`
|
||||
JOIN `AngelTypes` ON `AngelTypes`.`id`= `NeededAngelTypes`.`angel_type_id`
|
||||
WHERE `Shifts`.`RID` IN (" . implode(',', $shiftsFilter->getRooms()) . ")
|
||||
AND `start` BETWEEN " . $shiftsFilter->getStartTime() . " AND " . $shiftsFilter->getEndTime() . "
|
||||
AND NOT `Shifts`.`PSID` IS NULL";
|
||||
$result = sql_select($SQL);
|
||||
if ($result === false) {
|
||||
engelsystem_error("Unable to load needed angeltypes by filter.");
|
||||
}
|
||||
return $result;
|
||||
WHERE `Shifts`.`RID` IN (' . implode(',', $shiftsFilter->getRooms()) . ')
|
||||
AND `start` BETWEEN ? AND ?
|
||||
AND NOT `Shifts`.`PSID` IS NULL';
|
||||
$result = DB::select(
|
||||
$sql,
|
||||
[
|
||||
$shiftsFilter->getStartTime(),
|
||||
$shiftsFilter->getEndTime(),
|
||||
$shiftsFilter->getStartTime(),
|
||||
$shiftsFilter->getEndTime(),
|
||||
]
|
||||
);
|
||||
if (DB::getStm()->errorCode() != '00000') {
|
||||
engelsystem_error('Unable to load needed angeltypes by filter.');
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
function NeededAngeltype_by_Shift_and_Angeltype($shift, $angeltype) {
|
||||
$result = sql_select("SELECT `NeededAngelTypes`.*, `Shifts`.`SID`, `AngelTypes`.`id`, `AngelTypes`.`name`, `AngelTypes`.`restricted`, `AngelTypes`.`no_self_signup`
|
||||
FROM `Shifts`
|
||||
JOIN `NeededAngelTypes` ON `NeededAngelTypes`.`shift_id`=`Shifts`.`SID`
|
||||
JOIN `AngelTypes` ON `AngelTypes`.`id`= `NeededAngelTypes`.`angel_type_id`
|
||||
WHERE `Shifts`.`SID`=" . sql_escape($shift['SID']) . "
|
||||
AND `AngelTypes`.`id`=" . sql_escape($angeltype['id']) . "
|
||||
AND `Shifts`.`PSID` IS NULL
|
||||
|
||||
UNION
|
||||
|
||||
SELECT `NeededAngelTypes`.*, `Shifts`.`SID`, `AngelTypes`.`id`, `AngelTypes`.`name`, `AngelTypes`.`restricted`, `AngelTypes`.`no_self_signup`
|
||||
FROM `Shifts`
|
||||
JOIN `NeededAngelTypes` ON `NeededAngelTypes`.`room_id`=`Shifts`.`RID`
|
||||
JOIN `AngelTypes` ON `AngelTypes`.`id`= `NeededAngelTypes`.`angel_type_id`
|
||||
WHERE `Shifts`.`SID`=" . sql_escape($shift['SID']) . "
|
||||
AND `AngelTypes`.`id`=" . sql_escape($angeltype['id']) . "
|
||||
AND NOT `Shifts`.`PSID` IS NULL");
|
||||
if ($result === false) {
|
||||
engelsystem_error("Unable to load needed angeltypes by filter.");
|
||||
}
|
||||
if (count($result) == 0) {
|
||||
return null;
|
||||
}
|
||||
return $result[0];
|
||||
/**
|
||||
* @param array $shift
|
||||
* @param array $angeltype
|
||||
* @return array|null
|
||||
*/
|
||||
function NeededAngeltype_by_Shift_and_Angeltype($shift, $angeltype)
|
||||
{
|
||||
$result = DB::select('
|
||||
SELECT
|
||||
`NeededAngelTypes`.*,
|
||||
`Shifts`.`SID`,
|
||||
`AngelTypes`.`id`,
|
||||
`AngelTypes`.`name`,
|
||||
`AngelTypes`.`restricted`,
|
||||
`AngelTypes`.`no_self_signup`
|
||||
FROM `Shifts`
|
||||
JOIN `NeededAngelTypes` ON `NeededAngelTypes`.`shift_id`=`Shifts`.`SID`
|
||||
JOIN `AngelTypes` ON `AngelTypes`.`id`= `NeededAngelTypes`.`angel_type_id`
|
||||
WHERE `Shifts`.`SID`=?
|
||||
AND `AngelTypes`.`id`=?
|
||||
AND `Shifts`.`PSID` IS NULL
|
||||
|
||||
UNION
|
||||
|
||||
SELECT
|
||||
`NeededAngelTypes`.*,
|
||||
`Shifts`.`SID`,
|
||||
`AngelTypes`.`id`,
|
||||
`AngelTypes`.`name`,
|
||||
`AngelTypes`.`restricted`,
|
||||
`AngelTypes`.`no_self_signup`
|
||||
FROM `Shifts`
|
||||
JOIN `NeededAngelTypes` ON `NeededAngelTypes`.`room_id`=`Shifts`.`RID`
|
||||
JOIN `AngelTypes` ON `AngelTypes`.`id`= `NeededAngelTypes`.`angel_type_id`
|
||||
WHERE `Shifts`.`SID`=?
|
||||
AND `AngelTypes`.`id`=?
|
||||
AND NOT `Shifts`.`PSID` IS NULL
|
||||
',
|
||||
[
|
||||
$shift['SID'],
|
||||
$angeltype['id'],
|
||||
$shift['SID'],
|
||||
$angeltype['id']
|
||||
]
|
||||
);
|
||||
if (DB::getStm()->errorCode() != '00000') {
|
||||
engelsystem_error('Unable to load needed angeltypes by filter.');
|
||||
}
|
||||
if (empty($result)) {
|
||||
return null;
|
||||
}
|
||||
return $result[0];
|
||||
}
|
||||
|
||||
function ShiftEntries_by_ShiftsFilter(ShiftsFilter $shiftsFilter) {
|
||||
$SQL = "SELECT `User`.`Nick`, `User`.`email`, `User`.`email_shiftinfo`, `User`.`Sprache`, `User`.`Gekommen`, `ShiftEntry`.`UID`, `ShiftEntry`.`TID`, `ShiftEntry`.`SID`, `ShiftEntry`.`Comment`, `ShiftEntry`.`freeloaded`
|
||||
/**
|
||||
* @param ShiftsFilter $shiftsFilter
|
||||
* @return array
|
||||
*/
|
||||
function ShiftEntries_by_ShiftsFilter(ShiftsFilter $shiftsFilter)
|
||||
{
|
||||
$sql = '
|
||||
SELECT
|
||||
`User`.`Nick`,
|
||||
`User`.`email`,
|
||||
`User`.`email_shiftinfo`,
|
||||
`User`.`Sprache`,
|
||||
`User`.`Gekommen`,
|
||||
`ShiftEntry`.`UID`,
|
||||
`ShiftEntry`.`TID`,
|
||||
`ShiftEntry`.`SID`,
|
||||
`ShiftEntry`.`Comment`,
|
||||
`ShiftEntry`.`freeloaded`
|
||||
FROM `Shifts`
|
||||
JOIN `ShiftEntry` ON `ShiftEntry`.`SID`=`Shifts`.`SID`
|
||||
JOIN `User` ON `ShiftEntry`.`UID`=`User`.`UID`
|
||||
WHERE `Shifts`.`RID` IN (" . implode(',', $shiftsFilter->getRooms()) . ")
|
||||
AND `start` BETWEEN " . $shiftsFilter->getStartTime() . " AND " . $shiftsFilter->getEndTime() . "
|
||||
ORDER BY `Shifts`.`start`";
|
||||
$result = sql_select($SQL);
|
||||
if ($result === false) {
|
||||
engelsystem_error("Unable to load shift entries by filter.");
|
||||
}
|
||||
return $result;
|
||||
WHERE `Shifts`.`RID` IN (' . implode(',', $shiftsFilter->getRooms()) . ')
|
||||
AND `start` BETWEEN ? AND ?
|
||||
ORDER BY `Shifts`.`start`';
|
||||
$result = DB::select(
|
||||
$sql,
|
||||
[
|
||||
$shiftsFilter->getStartTime(),
|
||||
$shiftsFilter->getEndTime(),
|
||||
]
|
||||
);
|
||||
if (DB::getStm()->errorCode() != '00000') {
|
||||
engelsystem_error('Unable to load shift entries by filter.');
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a shift collides with other shifts (in time).
|
||||
*
|
||||
* @param Shift $shift
|
||||
* @param array<Shift> $shifts
|
||||
* @param array $shift
|
||||
* @param array $shifts
|
||||
* @return bool
|
||||
*/
|
||||
function Shift_collides($shift, $shifts) {
|
||||
foreach ($shifts as $other_shift) {
|
||||
if ($shift['SID'] != $other_shift['SID']) {
|
||||
if (! ($shift['start'] >= $other_shift['end'] || $shift['end'] <= $other_shift['start'])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
function Shift_collides($shift, $shifts)
|
||||
{
|
||||
foreach ($shifts as $other_shift) {
|
||||
if ($shift['SID'] != $other_shift['SID']) {
|
||||
if (!($shift['start'] >= $other_shift['end'] || $shift['end'] <= $other_shift['start'])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of needed angels/free shift entries for an angeltype.
|
||||
*
|
||||
* @param array $needed_angeltype
|
||||
* @param array[] $shift_entries
|
||||
* @return int
|
||||
*/
|
||||
function Shift_free_entries($needed_angeltype, $shift_entries) {
|
||||
$taken = 0;
|
||||
foreach ($shift_entries as $shift_entry) {
|
||||
if ($shift_entry['freeloaded'] == 0) {
|
||||
$taken ++;
|
||||
}
|
||||
}
|
||||
return max(0, $needed_angeltype['count'] - $taken);
|
||||
function Shift_free_entries($needed_angeltype, $shift_entries)
|
||||
{
|
||||
$taken = 0;
|
||||
foreach ($shift_entries as $shift_entry) {
|
||||
if ($shift_entry['freeloaded'] == 0) {
|
||||
$taken++;
|
||||
}
|
||||
}
|
||||
return max(0, $needed_angeltype['count'] - $taken);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if shift signup is allowed from the end users point of view (no admin like privileges)
|
||||
*
|
||||
* @param Shift $shift
|
||||
* The shift
|
||||
* @param AngelType $angeltype
|
||||
* The angeltype to which the user wants to sign up
|
||||
* @param array<Shift> $user_shifts
|
||||
* List of the users shifts
|
||||
* @param boolean $angeltype_supporter
|
||||
* True, if the user has angeltype supporter rights for the angeltype, which enables him to sign somebody up for the shift.
|
||||
* @param array $user
|
||||
* @param array $shift The shift
|
||||
* @param array $angeltype The angeltype to which the user wants to sign up
|
||||
* @param array|null $user_angeltype
|
||||
* @param array|null $user_shifts List of the users shifts
|
||||
* @param array $needed_angeltype
|
||||
* @param array[] $shift_entries
|
||||
* @return ShiftSignupState
|
||||
*/
|
||||
function Shift_signup_allowed_angel($user, $shift, $angeltype, $user_angeltype, $user_shifts, $needed_angeltype, $shift_entries) {
|
||||
$free_entries = Shift_free_entries($needed_angeltype, $shift_entries);
|
||||
|
||||
if ($user['Gekommen'] == 0) {
|
||||
return new ShiftSignupState(ShiftSignupState::SHIFT_ENDED, $free_entries);
|
||||
}
|
||||
|
||||
if ($user_shifts == null) {
|
||||
$user_shifts = Shifts_by_user($user);
|
||||
}
|
||||
|
||||
$signed_up = false;
|
||||
foreach ($user_shifts as $user_shift) {
|
||||
if ($user_shift['SID'] == $shift['SID']) {
|
||||
$signed_up = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($signed_up) {
|
||||
// you cannot join if you already singed up for this shift
|
||||
return new ShiftSignupState(ShiftSignupState::SIGNED_UP, $free_entries);
|
||||
}
|
||||
|
||||
if (time() > $shift['start']) {
|
||||
// you can only join if the shift is in future
|
||||
return new ShiftSignupState(ShiftSignupState::SHIFT_ENDED, $free_entries);
|
||||
}
|
||||
if ($free_entries == 0) {
|
||||
// you cannot join if shift is full
|
||||
return new ShiftSignupState(ShiftSignupState::OCCUPIED, $free_entries);
|
||||
}
|
||||
|
||||
if ($user_angeltype == null) {
|
||||
$user_angeltype = UserAngelType_by_User_and_AngelType($user, $angeltype);
|
||||
}
|
||||
|
||||
if ($user_angeltype == null || ($angeltype['no_self_signup'] == 1 && $user_angeltype != null) || ($angeltype['restricted'] == 1 && $user_angeltype != null && ! isset($user_angeltype['confirm_user_id']))) {
|
||||
// you cannot join if user is not of this angel type
|
||||
// you cannot join if you are not confirmed
|
||||
// you cannot join if angeltype has no self signup
|
||||
|
||||
return new ShiftSignupState(ShiftSignupState::ANGELTYPE, $free_entries);
|
||||
}
|
||||
|
||||
if (Shift_collides($shift, $user_shifts)) {
|
||||
// you cannot join if user alread joined a parallel or this shift
|
||||
return new ShiftSignupState(ShiftSignupState::COLLIDES, $free_entries);
|
||||
}
|
||||
|
||||
// Hooray, shift is free for you!
|
||||
return new ShiftSignupState(ShiftSignupState::FREE, $free_entries);
|
||||
function Shift_signup_allowed_angel(
|
||||
$user,
|
||||
$shift,
|
||||
$angeltype,
|
||||
$user_angeltype,
|
||||
$user_shifts,
|
||||
$needed_angeltype,
|
||||
$shift_entries
|
||||
) {
|
||||
$free_entries = Shift_free_entries($needed_angeltype, $shift_entries);
|
||||
|
||||
if ($user['Gekommen'] == 0) {
|
||||
return new ShiftSignupState(ShiftSignupState::SHIFT_ENDED, $free_entries);
|
||||
}
|
||||
|
||||
if ($user_shifts == null) {
|
||||
$user_shifts = Shifts_by_user($user);
|
||||
}
|
||||
|
||||
$signed_up = false;
|
||||
foreach ($user_shifts as $user_shift) {
|
||||
if ($user_shift['SID'] == $shift['SID']) {
|
||||
$signed_up = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($signed_up) {
|
||||
// you cannot join if you already singed up for this shift
|
||||
return new ShiftSignupState(ShiftSignupState::SIGNED_UP, $free_entries);
|
||||
}
|
||||
|
||||
if (time() > $shift['start']) {
|
||||
// you can only join if the shift is in future
|
||||
return new ShiftSignupState(ShiftSignupState::SHIFT_ENDED, $free_entries);
|
||||
}
|
||||
if ($free_entries == 0) {
|
||||
// you cannot join if shift is full
|
||||
return new ShiftSignupState(ShiftSignupState::OCCUPIED, $free_entries);
|
||||
}
|
||||
|
||||
if ($user_angeltype == null) {
|
||||
$user_angeltype = UserAngelType_by_User_and_AngelType($user, $angeltype);
|
||||
}
|
||||
|
||||
if (
|
||||
$user_angeltype == null
|
||||
|| ($angeltype['no_self_signup'] == 1 && $user_angeltype != null)
|
||||
|| ($angeltype['restricted'] == 1 && $user_angeltype != null && !isset($user_angeltype['confirm_user_id']))
|
||||
) {
|
||||
// you cannot join if user is not of this angel type
|
||||
// you cannot join if you are not confirmed
|
||||
// you cannot join if angeltype has no self signup
|
||||
|
||||
return new ShiftSignupState(ShiftSignupState::ANGELTYPE, $free_entries);
|
||||
}
|
||||
|
||||
if (Shift_collides($shift, $user_shifts)) {
|
||||
// you cannot join if user alread joined a parallel or this shift
|
||||
return new ShiftSignupState(ShiftSignupState::COLLIDES, $free_entries);
|
||||
}
|
||||
|
||||
// Hooray, shift is free for you!
|
||||
return new ShiftSignupState(ShiftSignupState::FREE, $free_entries);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if an angeltype supporter can sign up a user to a shift.
|
||||
*
|
||||
* @param array $needed_angeltype
|
||||
* @param array[] $shift_entries
|
||||
* @return ShiftSignupState
|
||||
*/
|
||||
function Shift_signup_allowed_angeltype_supporter($angeltype, $needed_angeltype, $shift_entries) {
|
||||
$free_entries = Shift_free_entries($needed_angeltype, $shift_entries);
|
||||
if ($free_entries == 0) {
|
||||
return new ShiftSignupState(ShiftSignupState::OCCUPIED, $free_entries);
|
||||
}
|
||||
|
||||
return new ShiftSignupState(ShiftSignupState::FREE, $free_entries);
|
||||
function Shift_signup_allowed_angeltype_supporter($needed_angeltype, $shift_entries)
|
||||
{
|
||||
$free_entries = Shift_free_entries($needed_angeltype, $shift_entries);
|
||||
if ($free_entries == 0) {
|
||||
return new ShiftSignupState(ShiftSignupState::OCCUPIED, $free_entries);
|
||||
}
|
||||
|
||||
return new ShiftSignupState(ShiftSignupState::FREE, $free_entries);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if an admin can sign up a user to a shift.
|
||||
*
|
||||
* @param Shift $shift
|
||||
* The shift
|
||||
* @param AngelType $angeltype
|
||||
* The angeltype to which the user wants to sign up
|
||||
* @param array $needed_angeltype
|
||||
* @param array[] $shift_entries
|
||||
* @return ShiftSignupState
|
||||
*/
|
||||
function Shift_signup_allowed_admin($angeltype, $needed_angeltype, $shift_entries) {
|
||||
$free_entries = Shift_free_entries($needed_angeltype, $shift_entries);
|
||||
|
||||
if ($free_entries == 0) {
|
||||
// User shift admins may join anybody in every shift
|
||||
return new ShiftSignupState(ShiftSignupState::ADMIN, $free_entries);
|
||||
}
|
||||
|
||||
return new ShiftSignupState(ShiftSignupState::FREE, $free_entries);
|
||||
function Shift_signup_allowed_admin($needed_angeltype, $shift_entries)
|
||||
{
|
||||
$free_entries = Shift_free_entries($needed_angeltype, $shift_entries);
|
||||
|
||||
if ($free_entries == 0) {
|
||||
// User shift admins may join anybody in every shift
|
||||
return new ShiftSignupState(ShiftSignupState::ADMIN, $free_entries);
|
||||
}
|
||||
|
||||
return new ShiftSignupState(ShiftSignupState::FREE, $free_entries);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if an angel can sign up for given shift.
|
||||
*
|
||||
* @param Shift $shift
|
||||
* The shift
|
||||
* @param AngelType $angeltype
|
||||
* The angeltype to which the user wants to sign up
|
||||
* @param array<Shift> $user_shifts
|
||||
* List of the users shifts
|
||||
* @param array $signup_user
|
||||
* @param array $shift The shift
|
||||
* @param array $angeltype The angeltype to which the user wants to sign up
|
||||
* @param array|null $user_angeltype
|
||||
* @param array|null $user_shifts List of the users shifts
|
||||
* @param array $needed_angeltype
|
||||
* @param array[] $shift_entries
|
||||
* @return ShiftSignupState
|
||||
*/
|
||||
function Shift_signup_allowed($signup_user, $shift, $angeltype, $user_angeltype = null, $user_shifts = null, $needed_angeltype, $shift_entries) {
|
||||
global $user, $privileges;
|
||||
|
||||
if (in_array('user_shifts_admin', $privileges)) {
|
||||
return Shift_signup_allowed_admin($angeltype, $needed_angeltype, $shift_entries);
|
||||
}
|
||||
|
||||
if (in_array('shiftentry_edit_angeltype_supporter', $privileges) && User_is_AngelType_supporter($user, $angeltype)) {
|
||||
return Shift_signup_allowed_angeltype_supporter($angeltype, $needed_angeltype, $shift_entries);
|
||||
}
|
||||
|
||||
return Shift_signup_allowed_angel($signup_user, $shift, $angeltype, $user_angeltype, $user_shifts, $needed_angeltype, $shift_entries);
|
||||
function Shift_signup_allowed(
|
||||
$signup_user,
|
||||
$shift,
|
||||
$angeltype,
|
||||
$user_angeltype,
|
||||
$user_shifts,
|
||||
$needed_angeltype,
|
||||
$shift_entries
|
||||
) {
|
||||
global $user, $privileges;
|
||||
|
||||
if (in_array('user_shifts_admin', $privileges)) {
|
||||
return Shift_signup_allowed_admin($needed_angeltype, $shift_entries);
|
||||
}
|
||||
|
||||
if (
|
||||
in_array('shiftentry_edit_angeltype_supporter', $privileges)
|
||||
&& User_is_AngelType_supporter($user, $angeltype)
|
||||
) {
|
||||
return Shift_signup_allowed_angeltype_supporter($needed_angeltype, $shift_entries);
|
||||
}
|
||||
|
||||
return Shift_signup_allowed_angel(
|
||||
$signup_user,
|
||||
$shift,
|
||||
$angeltype,
|
||||
$user_angeltype,
|
||||
$user_shifts,
|
||||
$needed_angeltype,
|
||||
$shift_entries
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a shift by its external id.
|
||||
*
|
||||
* @param int $shift_psid
|
||||
* @return bool
|
||||
*/
|
||||
function Shift_delete_by_psid($shift_psid) {
|
||||
return sql_query("DELETE FROM `Shifts` WHERE `PSID`='" . sql_escape($shift_psid) . "'");
|
||||
function Shift_delete_by_psid($shift_psid)
|
||||
{
|
||||
DB::delete('DELETE FROM `Shifts` WHERE `PSID`=?', [$shift_psid]);
|
||||
|
||||
if (DB::getStm()->errorCode() != '00000') {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a shift.
|
||||
*
|
||||
* @param int $shift_id
|
||||
* @return bool
|
||||
*/
|
||||
function Shift_delete($shift_id) {
|
||||
mail_shift_delete(Shift($shift_id));
|
||||
|
||||
$result = sql_query("DELETE FROM `Shifts` WHERE `SID`='" . sql_escape($shift_id) . "'");
|
||||
if ($result === false) {
|
||||
engelsystem_error('Unable to delete shift.');
|
||||
}
|
||||
return $result;
|
||||
function Shift_delete($shift_id)
|
||||
{
|
||||
mail_shift_delete(Shift($shift_id));
|
||||
|
||||
$result = DB::delete('DELETE FROM `Shifts` WHERE `SID`=?', [$shift_id]);
|
||||
if (DB::getStm()->errorCode() != '00000') {
|
||||
engelsystem_error('Unable to delete shift.');
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a shift.
|
||||
*
|
||||
* @param array $shift
|
||||
* @return bool
|
||||
*/
|
||||
function Shift_update($shift) {
|
||||
global $user;
|
||||
$shift['name'] = ShiftType($shift['shifttype_id'])['name'];
|
||||
mail_shift_change(Shift($shift['SID']), $shift);
|
||||
|
||||
return sql_query("UPDATE `Shifts` SET
|
||||
`shifttype_id`='" . sql_escape($shift['shifttype_id']) . "',
|
||||
`start`='" . sql_escape($shift['start']) . "',
|
||||
`end`='" . sql_escape($shift['end']) . "',
|
||||
`RID`='" . sql_escape($shift['RID']) . "',
|
||||
`title`=" . sql_null($shift['title']) . ",
|
||||
`URL`=" . sql_null($shift['URL']) . ",
|
||||
`PSID`=" . sql_null($shift['PSID']) . ",
|
||||
`edited_by_user_id`='" . sql_escape($user['UID']) . "',
|
||||
`edited_at_timestamp`=" . time() . "
|
||||
WHERE `SID`='" . sql_escape($shift['SID']) . "'");
|
||||
function Shift_update($shift)
|
||||
{
|
||||
global $user;
|
||||
$shift['name'] = ShiftType($shift['shifttype_id'])['name'];
|
||||
mail_shift_change(Shift($shift['SID']), $shift);
|
||||
|
||||
return (bool)DB::update('
|
||||
UPDATE `Shifts` SET
|
||||
`shifttype_id` = ?,
|
||||
`start` = ?,
|
||||
`end` = ?,
|
||||
`RID` = ?,
|
||||
`title` = ?,
|
||||
`URL` = ?,
|
||||
`PSID` = ?,
|
||||
`edited_by_user_id` = ?,
|
||||
`edited_at_timestamp` = ?
|
||||
WHERE `SID` = ?
|
||||
',
|
||||
[
|
||||
$shift['shifttype_id'],
|
||||
$shift['start'],
|
||||
$shift['end'],
|
||||
$shift['RID'],
|
||||
$shift['title'],
|
||||
$shift['URL'],
|
||||
$shift['PSID'],
|
||||
$user['UID'],
|
||||
time(),
|
||||
$shift['SID']
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a shift by its external id.
|
||||
*
|
||||
* @param array $shift
|
||||
* @return bool|null
|
||||
*/
|
||||
function Shift_update_by_psid($shift) {
|
||||
$shift_source = sql_select("SELECT `SID` FROM `Shifts` WHERE `PSID`=" . $shift['PSID']);
|
||||
if ($shift_source === false) {
|
||||
return false;
|
||||
}
|
||||
if (count($shift_source) == 0) {
|
||||
return null;
|
||||
}
|
||||
$shift['SID'] = $shift_source[0]['SID'];
|
||||
return Shift_update($shift);
|
||||
function Shift_update_by_psid($shift)
|
||||
{
|
||||
$shift_source = DB::select('SELECT `SID` FROM `Shifts` WHERE `PSID`=?', [$shift['PSID']]);
|
||||
if (DB::getStm()->errorCode() != '00000') {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (empty($shift_source)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$shift['SID'] = $shift_source[0]['SID'];
|
||||
return Shift_update($shift);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new shift.
|
||||
*
|
||||
* @return new shift id or false
|
||||
* @param array $shift
|
||||
* @return int|false shift id or false
|
||||
*/
|
||||
function Shift_create($shift) {
|
||||
global $user;
|
||||
$result = sql_query("INSERT INTO `Shifts` SET
|
||||
`shifttype_id`='" . sql_escape($shift['shifttype_id']) . "',
|
||||
`start`='" . sql_escape($shift['start']) . "',
|
||||
`end`='" . sql_escape($shift['end']) . "',
|
||||
`RID`='" . sql_escape($shift['RID']) . "',
|
||||
`title`=" . sql_null($shift['title']) . ",
|
||||
`URL`=" . sql_null($shift['URL']) . ",
|
||||
`PSID`=" . sql_null($shift['PSID']) . ",
|
||||
`created_by_user_id`='" . sql_escape($user['UID']) . "',
|
||||
`created_at_timestamp`=" . time());
|
||||
if ($result === false) {
|
||||
return false;
|
||||
}
|
||||
return sql_id();
|
||||
function Shift_create($shift)
|
||||
{
|
||||
global $user;
|
||||
DB::insert('
|
||||
INSERT INTO `Shifts` (
|
||||
`shifttype_id`,
|
||||
`start`,
|
||||
`end`,
|
||||
`RID`,
|
||||
`title`,
|
||||
`URL`,
|
||||
`PSID`,
|
||||
`created_by_user_id`,
|
||||
`created_at_timestamp`
|
||||
)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
',
|
||||
[
|
||||
$shift['shifttype_id'],
|
||||
$shift['start'],
|
||||
$shift['end'],
|
||||
$shift['RID'],
|
||||
$shift['title'],
|
||||
$shift['URL'],
|
||||
$shift['PSID'],
|
||||
$user['UID'],
|
||||
time(),
|
||||
]
|
||||
);
|
||||
if (DB::getStm()->errorCode() != '00000') {
|
||||
return false;
|
||||
}
|
||||
return DB::getPdo()->lastInsertId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return users shifts.
|
||||
*
|
||||
* @param array $user
|
||||
* @param bool $include_freeload_comments
|
||||
* @return array
|
||||
*/
|
||||
function Shifts_by_user($user, $include_freeload_comments = false) {
|
||||
$result = sql_select("
|
||||
SELECT `ShiftTypes`.`id` as `shifttype_id`, `ShiftTypes`.`name`,
|
||||
`ShiftEntry`.`id`, `ShiftEntry`.`SID`, `ShiftEntry`.`TID`, `ShiftEntry`.`UID`, `ShiftEntry`.`freeloaded`, `ShiftEntry`.`Comment`,
|
||||
" . ($include_freeload_comments ? "`ShiftEntry`.`freeload_comment`, " : "") . "
|
||||
`Shifts`.*, `Room`.*
|
||||
FROM `ShiftEntry`
|
||||
JOIN `Shifts` ON (`ShiftEntry`.`SID` = `Shifts`.`SID`)
|
||||
JOIN `ShiftTypes` ON (`ShiftTypes`.`id` = `Shifts`.`shifttype_id`)
|
||||
JOIN `Room` ON (`Shifts`.`RID` = `Room`.`RID`)
|
||||
WHERE `UID`='" . sql_escape($user['UID']) . "'
|
||||
ORDER BY `start`
|
||||
");
|
||||
if ($result === false) {
|
||||
engelsystem_error('Unable to load users shifts.');
|
||||
}
|
||||
return $result;
|
||||
function Shifts_by_user($user, $include_freeload_comments = false)
|
||||
{
|
||||
$result = DB::select('
|
||||
SELECT `ShiftTypes`.`id` AS `shifttype_id`, `ShiftTypes`.`name`,
|
||||
`ShiftEntry`.`id`, `ShiftEntry`.`SID`, `ShiftEntry`.`TID`, `ShiftEntry`.`UID`, `ShiftEntry`.`freeloaded`, `ShiftEntry`.`Comment`,
|
||||
' . ($include_freeload_comments ? '`ShiftEntry`.`freeload_comment`, ' : '') . '
|
||||
`Shifts`.*, `Room`.*
|
||||
FROM `ShiftEntry`
|
||||
JOIN `Shifts` ON (`ShiftEntry`.`SID` = `Shifts`.`SID`)
|
||||
JOIN `ShiftTypes` ON (`ShiftTypes`.`id` = `Shifts`.`shifttype_id`)
|
||||
JOIN `Room` ON (`Shifts`.`RID` = `Room`.`RID`)
|
||||
WHERE `UID` = ?
|
||||
ORDER BY `start`
|
||||
',
|
||||
[
|
||||
$user['UID']
|
||||
]
|
||||
);
|
||||
if (DB::getStm()->errorCode() != '00000') {
|
||||
engelsystem_error('Unable to load users shifts.');
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns Shift by id.
|
||||
*
|
||||
* @param $shift_id Shift
|
||||
* ID
|
||||
* @param int $shift_id Shift ID
|
||||
* @return array|null
|
||||
*/
|
||||
function Shift($shift_id) {
|
||||
$shifts_source = sql_select("
|
||||
function Shift($shift_id)
|
||||
{
|
||||
$shifts_source = DB::select('
|
||||
SELECT `Shifts`.*, `ShiftTypes`.`name`
|
||||
FROM `Shifts`
|
||||
FROM `Shifts`
|
||||
JOIN `ShiftTypes` ON (`ShiftTypes`.`id` = `Shifts`.`shifttype_id`)
|
||||
WHERE `SID`='" . sql_escape($shift_id) . "'");
|
||||
$shiftsEntry_source = sql_select("SELECT `id`, `TID` , `UID` , `freeloaded` FROM `ShiftEntry` WHERE `SID`='" . sql_escape($shift_id) . "'");
|
||||
|
||||
if ($shifts_source === false) {
|
||||
engelsystem_error('Unable to load shift.');
|
||||
}
|
||||
|
||||
if (empty($shifts_source)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$result = $shifts_source[0];
|
||||
|
||||
$result['ShiftEntry'] = $shiftsEntry_source;
|
||||
$result['NeedAngels'] = [];
|
||||
|
||||
$temp = NeededAngelTypes_by_shift($shift_id);
|
||||
foreach ($temp as $e) {
|
||||
$result['NeedAngels'][] = [
|
||||
'TID' => $e['angel_type_id'],
|
||||
'count' => $e['count'],
|
||||
'restricted' => $e['restricted'],
|
||||
'taken' => $e['taken']
|
||||
];
|
||||
}
|
||||
|
||||
return $result;
|
||||
WHERE `SID`=?', [$shift_id]);
|
||||
|
||||
if (DB::getStm()->errorCode() != '00000') {
|
||||
engelsystem_error('Unable to load shift.');
|
||||
}
|
||||
|
||||
if (empty($shifts_source)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$result = $shifts_source[0];
|
||||
|
||||
$shiftsEntry_source = DB::select('
|
||||
SELECT `id`, `TID` , `UID` , `freeloaded`
|
||||
FROM `ShiftEntry`
|
||||
WHERE `SID`=?', [$shift_id]);
|
||||
|
||||
$result['ShiftEntry'] = $shiftsEntry_source;
|
||||
$result['NeedAngels'] = [];
|
||||
|
||||
$angelTypes = NeededAngelTypes_by_shift($shift_id);
|
||||
foreach ($angelTypes as $type) {
|
||||
$result['NeedAngels'][] = [
|
||||
'TID' => $type['angel_type_id'],
|
||||
'count' => $type['count'],
|
||||
'restricted' => $type['restricted'],
|
||||
'taken' => $type['taken']
|
||||
];
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all shifts with needed angeltypes and count of subscribed jobs.
|
||||
*
|
||||
* @return array|false
|
||||
*/
|
||||
function Shifts() {
|
||||
$shifts_source = sql_select("
|
||||
SELECT `ShiftTypes`.`name`, `Shifts`.*, `Room`.`RID`, `Room`.`Name` as `room_name`
|
||||
FROM `Shifts`
|
||||
JOIN `ShiftTypes` ON (`ShiftTypes`.`id` = `Shifts`.`shifttype_id`)
|
||||
JOIN `Room` ON `Room`.`RID` = `Shifts`.`RID`
|
||||
");
|
||||
if ($shifts_source === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($shifts_source as &$shift) {
|
||||
$needed_angeltypes = NeededAngelTypes_by_shift($shift['SID']);
|
||||
if ($needed_angeltypes === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$shift['angeltypes'] = $needed_angeltypes;
|
||||
}
|
||||
|
||||
return $shifts_source;
|
||||
}
|
||||
function Shifts()
|
||||
{
|
||||
$shifts_source = DB::select('
|
||||
SELECT `ShiftTypes`.`name`, `Shifts`.*, `Room`.`RID`, `Room`.`Name` AS `room_name`
|
||||
FROM `Shifts`
|
||||
JOIN `ShiftTypes` ON (`ShiftTypes`.`id` = `Shifts`.`shifttype_id`)
|
||||
JOIN `Room` ON `Room`.`RID` = `Shifts`.`RID`
|
||||
');
|
||||
|
||||
if (DB::getStm()->errorCode() != '00000') {
|
||||
return false;
|
||||
}
|
||||
|
||||
?>
|
||||
foreach ($shifts_source as &$shift) {
|
||||
$needed_angeltypes = NeededAngelTypes_by_shift($shift['SID']);
|
||||
$shift['angeltypes'] = $needed_angeltypes;
|
||||
}
|
||||
|
||||
return $shifts_source;
|
||||
}
|
||||
|
||||
@ -1,104 +1,152 @@
|
||||
<?php
|
||||
|
||||
use Engelsystem\Database\DB;
|
||||
|
||||
/**
|
||||
* Returns a new empty UserDriverLicense
|
||||
* FIXME entity object needed
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function UserDriverLicense_new() {
|
||||
return [
|
||||
'user_id' => null,
|
||||
'has_car' => false,
|
||||
'has_license_car' => false,
|
||||
'has_license_3_5t_transporter' => false,
|
||||
'has_license_7_5t_truck' => false,
|
||||
'has_license_12_5t_truck' => false,
|
||||
'has_license_forklift' => false
|
||||
];
|
||||
function UserDriverLicense_new()
|
||||
{
|
||||
return [
|
||||
'user_id' => null,
|
||||
'has_car' => false,
|
||||
'has_license_car' => false,
|
||||
'has_license_3_5t_transporter' => false,
|
||||
'has_license_7_5t_truck' => false,
|
||||
'has_license_12_5t_truck' => false,
|
||||
'has_license_forklift' => false
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Is it valid?
|
||||
*
|
||||
* @param UserDriverLicense $user_driver_license
|
||||
* The UserDriverLicense to check
|
||||
* @param array $user_driver_license The UserDriverLicense to check
|
||||
* @return boolean
|
||||
*/
|
||||
function UserDriverLicense_valid($user_driver_license) {
|
||||
return $user_driver_license['has_license_car'] || $user_driver_license['has_license_3_5t_transporter'] || $user_driver_license['has_license_7_5t_truck'] || $user_driver_license['has_license_12_5t_truck'] || $user_driver_license['has_license_forklift'];
|
||||
function UserDriverLicense_valid($user_driver_license)
|
||||
{
|
||||
return $user_driver_license['has_car']
|
||||
|| $user_driver_license['has_license_car']
|
||||
|| $user_driver_license['has_license_3_5t_transporter']
|
||||
|| $user_driver_license['has_license_7_5t_truck']
|
||||
|| $user_driver_license['has_license_12_5t_truck']
|
||||
|| $user_driver_license['has_license_forklift'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a users driver license information
|
||||
*
|
||||
* @param int $user_id
|
||||
* The users id
|
||||
* @param int $user_id The users id
|
||||
* @return array|false|null
|
||||
*/
|
||||
function UserDriverLicense($user_id) {
|
||||
$user_driver_license = sql_select("SELECT * FROM `UserDriverLicenses` WHERE `user_id`='" . sql_escape($user_id) . "'");
|
||||
if ($user_driver_license === false) {
|
||||
engelsystem_error('Unable to load user driver license.');
|
||||
return false;
|
||||
}
|
||||
if (count($user_driver_license) > 0) {
|
||||
return $user_driver_license[0];
|
||||
}
|
||||
return null;
|
||||
function UserDriverLicense($user_id)
|
||||
{
|
||||
$user_driver_license = DB::select('
|
||||
SELECT *
|
||||
FROM `UserDriverLicenses`
|
||||
WHERE `user_id`=?', [$user_id]);
|
||||
|
||||
if (DB::getStm()->errorCode() != '00000') {
|
||||
engelsystem_error('Unable to load user driver license.');
|
||||
return false;
|
||||
}
|
||||
|
||||
if (empty($user_driver_license)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return array_shift($user_driver_license);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a user's driver license entry
|
||||
*
|
||||
* @param UserDriverLicense $user_driver_license
|
||||
* The UserDriverLicense to create
|
||||
* @param array $user_driver_license The UserDriverLicense to create
|
||||
* @param array $user
|
||||
* @return array
|
||||
*/
|
||||
function UserDriverLicenses_create($user_driver_license, $user) {
|
||||
$user_driver_license['user_id'] = $user['UID'];
|
||||
$result = sql_query("
|
||||
INSERT INTO `UserDriverLicenses` SET
|
||||
`user_id`=" . sql_escape($user_driver_license['user_id']) . ",
|
||||
`has_car`=" . sql_bool($user_driver_license['has_car']) . ",
|
||||
`has_license_car`=" . sql_bool($user_driver_license['has_license_car']) . ",
|
||||
`has_license_3_5t_transporter`=" . sql_bool($user_driver_license['has_license_3_5t_transporter']) . ",
|
||||
`has_license_7_5t_truck`=" . sql_bool($user_driver_license['has_license_7_5t_truck']) . ",
|
||||
`has_license_12_5t_truck`=" . sql_bool($user_driver_license['has_license_12_5t_truck']) . ",
|
||||
`has_license_forklift`=" . sql_bool($user_driver_license['has_license_forklift']));
|
||||
if ($result === false) {
|
||||
engelsystem_error('Unable to create user driver license');
|
||||
}
|
||||
return $user_driver_license;
|
||||
function UserDriverLicenses_create($user_driver_license, $user)
|
||||
{
|
||||
$user_driver_license['user_id'] = $user['UID'];
|
||||
DB::insert('
|
||||
INSERT INTO `UserDriverLicenses` (
|
||||
`user_id`,
|
||||
`has_car`,
|
||||
`has_license_car`,
|
||||
`has_license_3_5t_transporter`,
|
||||
`has_license_7_5t_truck`,
|
||||
`has_license_12_5t_truck`,
|
||||
`has_license_forklift`
|
||||
)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?)
|
||||
',
|
||||
[
|
||||
$user_driver_license['user_id'],
|
||||
(bool)$user_driver_license['has_car'],
|
||||
(bool)$user_driver_license['has_license_car'],
|
||||
(bool)$user_driver_license['has_license_3_5t_transporter'],
|
||||
(bool)$user_driver_license['has_license_7_5t_truck'],
|
||||
(bool)$user_driver_license['has_license_12_5t_truck'],
|
||||
(bool)$user_driver_license['has_license_forklift'],
|
||||
]
|
||||
);
|
||||
if (DB::getStm()->errorCode() != '00000') {
|
||||
engelsystem_error('Unable to create user driver license');
|
||||
}
|
||||
|
||||
return $user_driver_license;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a user's driver license entry
|
||||
*
|
||||
* @param UserDriverLicense $user_driver_license
|
||||
* The UserDriverLicense to update
|
||||
* @param array $user_driver_license The UserDriverLicense to update
|
||||
* @return bool
|
||||
*/
|
||||
function UserDriverLicenses_update($user_driver_license) {
|
||||
$result = sql_query("UPDATE `UserDriverLicenses` SET
|
||||
`has_car`=" . sql_bool($user_driver_license['has_car']) . ",
|
||||
`has_license_car`=" . sql_bool($user_driver_license['has_license_car']) . ",
|
||||
`has_license_3_5t_transporter`=" . sql_bool($user_driver_license['has_license_3_5t_transporter']) . ",
|
||||
`has_license_7_5t_truck`=" . sql_bool($user_driver_license['has_license_7_5t_truck']) . ",
|
||||
`has_license_12_5t_truck`=" . sql_bool($user_driver_license['has_license_12_5t_truck']) . ",
|
||||
`has_license_forklift`=" . sql_bool($user_driver_license['has_license_forklift']) . "
|
||||
WHERE `user_id`='" . sql_escape($user_driver_license['user_id']) . "'");
|
||||
if ($result === false) {
|
||||
engelsystem_error("Unable to update user driver license information");
|
||||
}
|
||||
return $result;
|
||||
function UserDriverLicenses_update($user_driver_license)
|
||||
{
|
||||
$result = DB::update('
|
||||
UPDATE `UserDriverLicenses`
|
||||
SET
|
||||
`has_car`=?,
|
||||
`has_license_car`=?,
|
||||
`has_license_3_5t_transporter`=?,
|
||||
`has_license_7_5t_truck`=?,
|
||||
`has_license_12_5t_truck`=?,
|
||||
`has_license_forklift`=?
|
||||
WHERE `user_id`=?
|
||||
',
|
||||
[
|
||||
(bool)$user_driver_license['has_car'],
|
||||
(bool)$user_driver_license['has_license_car'],
|
||||
(bool)$user_driver_license['has_license_3_5t_transporter'],
|
||||
(bool)$user_driver_license['has_license_7_5t_truck'],
|
||||
(bool)$user_driver_license['has_license_12_5t_truck'],
|
||||
(bool)$user_driver_license['has_license_forklift'],
|
||||
$user_driver_license['user_id'],
|
||||
]
|
||||
);
|
||||
if (DB::getStm()->errorCode() != '00000') {
|
||||
engelsystem_error('Unable to update user driver license information');
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a user's driver license entry
|
||||
*
|
||||
* @param int $user_id
|
||||
* @param int $user_id
|
||||
* @return bool
|
||||
*/
|
||||
function UserDriverLicenses_delete($user_id) {
|
||||
$result = sql_query("DELETE FROM `UserDriverLicenses` WHERE `user_id`=" . sql_escape($user_id));
|
||||
if ($result === false) {
|
||||
engelsystem_error("Unable to remove user driver license information");
|
||||
}
|
||||
return $result;
|
||||
function UserDriverLicenses_delete($user_id)
|
||||
{
|
||||
$result = DB::delete('DELETE FROM `UserDriverLicenses` WHERE `user_id`=?', [$user_id]);
|
||||
if (DB::getStm()->errorCode() != '00000') {
|
||||
engelsystem_error('Unable to remove user driver license information');
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
?>
|
||||
@ -1,17 +1,22 @@
|
||||
<?php
|
||||
|
||||
use Engelsystem\Database\DB;
|
||||
|
||||
/**
|
||||
* Returns users groups
|
||||
* @param User $user
|
||||
*
|
||||
* @param array $user
|
||||
* @return array
|
||||
*/
|
||||
function User_groups($user) {
|
||||
return sql_select("
|
||||
SELECT `Groups`.*
|
||||
FROM `UserGroups`
|
||||
JOIN `Groups` ON `Groups`.`UID`=`UserGroups`.`group_id`
|
||||
WHERE `UserGroups`.`uid`='" . sql_escape($user['UID']) . "'
|
||||
ORDER BY `UserGroups`.`group_id`
|
||||
");
|
||||
function User_groups($user)
|
||||
{
|
||||
return DB::select('
|
||||
SELECT `Groups`.*
|
||||
FROM `UserGroups`
|
||||
JOIN `Groups` ON `Groups`.`UID`=`UserGroups`.`group_id`
|
||||
WHERE `UserGroups`.`uid`=?
|
||||
ORDER BY `UserGroups`.`group_id`
|
||||
',
|
||||
[$user['UID']]
|
||||
);
|
||||
}
|
||||
|
||||
?>
|
||||
@ -1,216 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Close connection.
|
||||
*/
|
||||
function sql_close() {
|
||||
global $sql_connection;
|
||||
|
||||
return $sql_connection->close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return NULL if given value is null.
|
||||
*/
|
||||
function sql_null($value = null) {
|
||||
return $value == null ? 'NULL' : ("'" . sql_escape($value) . "'");
|
||||
}
|
||||
|
||||
/**
|
||||
* Start new transaction.
|
||||
*/
|
||||
function sql_transaction_start() {
|
||||
global $sql_nested_transaction_level;
|
||||
|
||||
if ($sql_nested_transaction_level ++ == 0) {
|
||||
return sql_query("BEGIN");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Commit transaction.
|
||||
*/
|
||||
function sql_transaction_commit() {
|
||||
global $sql_nested_transaction_level;
|
||||
|
||||
if (-- $sql_nested_transaction_level == 0) {
|
||||
return sql_query("COMMIT");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop transaction, revert database.
|
||||
*/
|
||||
function sql_transaction_rollback() {
|
||||
global $sql_nested_transaction_level;
|
||||
|
||||
if (-- $sql_nested_transaction_level == 0) {
|
||||
return sql_query("ROLLBACK");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs an sql error.
|
||||
*
|
||||
* @param string $message
|
||||
* @return false
|
||||
*/
|
||||
function sql_error($message) {
|
||||
sql_close();
|
||||
|
||||
$message = trim($message) . "\n";
|
||||
$message .= debug_string_backtrace() . "\n";
|
||||
|
||||
error_log('mysql_provider error: ' . $message);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Connect to mysql server.
|
||||
*
|
||||
* @param string $host
|
||||
* Host
|
||||
* @param string $user
|
||||
* Username
|
||||
* @param string $pass
|
||||
* Password
|
||||
* @param string $db_name
|
||||
* DB to select
|
||||
* @return mysqli The connection handler
|
||||
*/
|
||||
function sql_connect($host, $user, $pass, $db_name) {
|
||||
global $sql_connection;
|
||||
|
||||
$sql_connection = new mysqli($host, $user, $pass, $db_name);
|
||||
if ($sql_connection->connect_errno) {
|
||||
error("Unable to connect to MySQL: " . $sql_connection->connect_error);
|
||||
return sql_error("Unable to connect to MySQL: " . $sql_connection->connect_error);
|
||||
}
|
||||
|
||||
$result = $sql_connection->query("SET CHARACTER SET utf8;");
|
||||
if (! $result) {
|
||||
return sql_error("Unable to set utf8 character set (" . $sql_connection->errno . ") " . $sql_connection->error);
|
||||
}
|
||||
|
||||
$result = $sql_connection->set_charset('utf8');
|
||||
if (! $result) {
|
||||
return sql_error("Unable to set utf8 names (" . $sql_connection->errno . ") " . $sql_connection->error);
|
||||
}
|
||||
|
||||
return $sql_connection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the selected db in current mysql-connection.
|
||||
*
|
||||
* @param
|
||||
* $db_name
|
||||
* @return bool true on success, false on error
|
||||
*/
|
||||
function sql_select_db($db_name) {
|
||||
global $sql_connection;
|
||||
if (! $sql_connection->select_db($db_name)) {
|
||||
return sql_error("No database selected.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* MySQL SELECT query
|
||||
*
|
||||
* @param string $query
|
||||
* @return Result array or false on error
|
||||
*/
|
||||
function sql_select($query) {
|
||||
global $sql_connection;
|
||||
|
||||
// echo $query . ";\n";
|
||||
// echo debug_string_backtrace() . "\n";
|
||||
|
||||
$result = $sql_connection->query($query);
|
||||
if ($result) {
|
||||
$data = [];
|
||||
while ($line = $result->fetch_assoc()) {
|
||||
array_push($data, $line);
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
return sql_error("MySQL-query error: " . $query . " (" . $sql_connection->errno . ") " . $sql_connection->error);
|
||||
}
|
||||
|
||||
/**
|
||||
* MySQL execute a query
|
||||
*
|
||||
* @param string $query
|
||||
* @return mysqli_result boolean resource or false on error
|
||||
*/
|
||||
function sql_query($query) {
|
||||
global $sql_connection;
|
||||
|
||||
$result = $sql_connection->query($query);
|
||||
if ($result) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
return sql_error("MySQL-query error: " . $query . " (" . $sql_connection->errno . ") " . $sql_connection->error);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns last inserted id.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
function sql_id() {
|
||||
global $sql_connection;
|
||||
return $sql_connection->insert_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Escape a string for a sql query.
|
||||
*
|
||||
* @param string $query
|
||||
* @return string
|
||||
*/
|
||||
function sql_escape($query) {
|
||||
global $sql_connection;
|
||||
return $sql_connection->real_escape_string($query);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a boolean for mysql-queries.
|
||||
*
|
||||
* @param boolean $boolean
|
||||
* @return string
|
||||
*/
|
||||
function sql_bool($boolean) {
|
||||
return $boolean == true ? 'TRUE' : 'FALSE';
|
||||
}
|
||||
|
||||
/**
|
||||
* Count query result lines.
|
||||
*
|
||||
* @param string $query
|
||||
* @return int Count of result lines
|
||||
*/
|
||||
function sql_num_query($query) {
|
||||
return sql_query($query)->num_rows;
|
||||
}
|
||||
|
||||
function sql_select_single_col($query) {
|
||||
$result = sql_select($query);
|
||||
return array_map('array_shift', $result);
|
||||
}
|
||||
|
||||
function sql_select_single_cell($query) {
|
||||
return array_shift(array_shift(sql_select($query)));
|
||||
}
|
||||
|
||||
?>
|
||||
@ -1,67 +1,82 @@
|
||||
<?php
|
||||
|
||||
function admin_news() {
|
||||
global $user;
|
||||
|
||||
if (! isset($_GET["action"])) {
|
||||
redirect(page_link_to("news"));
|
||||
}
|
||||
|
||||
$html = '<div class="col-md-12"><h1>' . _("Edit news entry") . '</h1>' . msg();
|
||||
if (isset($_REQUEST['id']) && preg_match("/^[0-9]{1,11}$/", $_REQUEST['id'])) {
|
||||
$news_id = $_REQUEST['id'];
|
||||
} else {
|
||||
return error("Incomplete call, missing News ID.", true);
|
||||
}
|
||||
|
||||
$news = sql_select("SELECT * FROM `News` WHERE `ID`='" . sql_escape($news_id) . "' LIMIT 1");
|
||||
if (empty($news)) {
|
||||
return error("No News found.", true);
|
||||
}
|
||||
switch ($_REQUEST["action"]) {
|
||||
default:
|
||||
redirect(page_link_to('news'));
|
||||
case 'edit':
|
||||
list($news) = $news;
|
||||
|
||||
$user_source = User($news['UID']);
|
||||
|
||||
$html .= form([
|
||||
form_info(_("Date"), date("Y-m-d H:i", $news['Datum'])),
|
||||
form_info(_("Author"), User_Nick_render($user_source)),
|
||||
form_text('eBetreff', _("Subject"), $news['Betreff']),
|
||||
form_textarea('eText', _("Message"), $news['Text']),
|
||||
form_checkbox('eTreffen', _("Meeting"), $news['Treffen'] == 1, 1),
|
||||
form_submit('submit', _("Save"))
|
||||
], page_link_to('admin_news&action=save&id=' . $news_id));
|
||||
|
||||
$html .= '<a class="btn btn-danger" href="' . page_link_to('admin_news&action=delete&id=' . $news_id) . '"><span class="glyphicon glyphicon-trash"></span> ' . _("Delete") . '</a>';
|
||||
break;
|
||||
|
||||
case 'save':
|
||||
list($news) = $news;
|
||||
|
||||
sql_query("UPDATE `News` SET
|
||||
`Datum`='" . sql_escape(time()) . "',
|
||||
`Betreff`='" . sql_escape($_POST["eBetreff"]) . "',
|
||||
`Text`='" . sql_escape($_POST["eText"]) . "',
|
||||
`UID`='" . sql_escape($user['UID']) . "',
|
||||
`Treffen`='" . sql_escape($_POST["eTreffen"]) . "'
|
||||
WHERE `ID`='" . sql_escape($news_id) . "'");
|
||||
engelsystem_log("News updated: " . $_POST["eBetreff"]);
|
||||
success(_("News entry updated."));
|
||||
redirect(page_link_to("news"));
|
||||
break;
|
||||
|
||||
case 'delete':
|
||||
list($news) = $news;
|
||||
|
||||
sql_query("DELETE FROM `News` WHERE `ID`='" . sql_escape($news_id) . "' LIMIT 1");
|
||||
engelsystem_log("News deleted: " . $news['Betreff']);
|
||||
success(_("News entry deleted."));
|
||||
redirect(page_link_to("news"));
|
||||
break;
|
||||
}
|
||||
return $html . '</div>';
|
||||
use Engelsystem\Database\DB;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
function admin_news()
|
||||
{
|
||||
global $user;
|
||||
|
||||
if (!isset($_GET['action'])) {
|
||||
redirect(page_link_to('news'));
|
||||
}
|
||||
|
||||
$html = '<div class="col-md-12"><h1>' . _('Edit news entry') . '</h1>' . msg();
|
||||
if (isset($_REQUEST['id']) && preg_match('/^\d{1,11}$/', $_REQUEST['id'])) {
|
||||
$news_id = $_REQUEST['id'];
|
||||
} else {
|
||||
return error('Incomplete call, missing News ID.', true);
|
||||
}
|
||||
|
||||
$news = DB::select('SELECT * FROM `News` WHERE `ID`=? LIMIT 1', [$news_id]);
|
||||
if (empty($news)) {
|
||||
return error('No News found.', true);
|
||||
}
|
||||
|
||||
switch ($_REQUEST['action']) {
|
||||
case 'edit':
|
||||
$news = array_shift($news);
|
||||
$user_source = User($news['UID']);
|
||||
|
||||
$html .= form([
|
||||
form_info(_('Date'), date('Y-m-d H:i', $news['Datum'])),
|
||||
form_info(_('Author'), User_Nick_render($user_source)),
|
||||
form_text('eBetreff', _('Subject'), $news['Betreff']),
|
||||
form_textarea('eText', _('Message'), $news['Text']),
|
||||
form_checkbox('eTreffen', _('Meeting'), $news['Treffen'] == 1, 1),
|
||||
form_submit('submit', _('Save'))
|
||||
], page_link_to('admin_news&action=save&id=' . $news_id));
|
||||
|
||||
$html .= '<a class="btn btn-danger" href="' . page_link_to('admin_news&action=delete&id=' . $news_id) . '">'
|
||||
. '<span class="glyphicon glyphicon-trash"></span> ' . _('Delete')
|
||||
. '</a>';
|
||||
break;
|
||||
|
||||
case 'save':
|
||||
DB::update('
|
||||
UPDATE `News` SET
|
||||
`Datum`=?,
|
||||
`Betreff`=?,
|
||||
`Text`=?,
|
||||
`UID`=?,
|
||||
`Treffen`=?
|
||||
WHERE `ID`=?
|
||||
',
|
||||
[
|
||||
time(),
|
||||
$_POST["eBetreff"],
|
||||
$_POST["eText"],
|
||||
$user['UID'],
|
||||
isset($_POST["eTreffen"]) ? 1 : 0,
|
||||
$news_id
|
||||
]
|
||||
);
|
||||
engelsystem_log('News updated: ' . $_POST['eBetreff']);
|
||||
success(_('News entry updated.'));
|
||||
redirect(page_link_to('news'));
|
||||
break;
|
||||
|
||||
case 'delete':
|
||||
$news = array_shift($news);
|
||||
DB::delete('DELETE FROM `News` WHERE `ID`=? LIMIT 1', [$news_id]);
|
||||
engelsystem_log('News deleted: ' . $news['Betreff']);
|
||||
success(_('News entry deleted.'));
|
||||
redirect(page_link_to('news'));
|
||||
break;
|
||||
default:
|
||||
redirect(page_link_to('news'));
|
||||
}
|
||||
return $html . '</div>';
|
||||
}
|
||||
?>
|
||||
@ -1,9 +1,17 @@
|
||||
<?php
|
||||
function credits_title() {
|
||||
return _("Credits");
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
function credits_title()
|
||||
{
|
||||
return _('Credits');
|
||||
}
|
||||
|
||||
function guest_credits() {
|
||||
return template_render(__DIR__ . '/../../templates/guest_credits.html', []);
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
function guest_credits()
|
||||
{
|
||||
return template_render(__DIR__ . '/../../templates/guest_credits.html', []);
|
||||
}
|
||||
?>
|
||||
@ -1,400 +1,492 @@
|
||||
<?php
|
||||
|
||||
function login_title() {
|
||||
return _("Login");
|
||||
use Engelsystem\Database\DB;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
function login_title()
|
||||
{
|
||||
return _('Login');
|
||||
}
|
||||
|
||||
function register_title() {
|
||||
return _("Register");
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
function register_title()
|
||||
{
|
||||
return _('Register');
|
||||
}
|
||||
|
||||
function logout_title() {
|
||||
return _("Logout");
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
function logout_title()
|
||||
{
|
||||
return _('Logout');
|
||||
}
|
||||
|
||||
// Engel registrieren
|
||||
function guest_register() {
|
||||
global $tshirt_sizes, $enable_tshirt_size, $default_theme, $user, $min_password_length;
|
||||
|
||||
$event_config = EventConfig();
|
||||
|
||||
$msg = "";
|
||||
$nick = "";
|
||||
$lastname = "";
|
||||
$prename = "";
|
||||
$age = "";
|
||||
$tel = "";
|
||||
$dect = "";
|
||||
$mobile = "";
|
||||
$mail = "";
|
||||
$email_shiftinfo = false;
|
||||
$email_by_human_allowed = false;
|
||||
$jabber = "";
|
||||
$hometown = "";
|
||||
$comment = "";
|
||||
$tshirt_size = '';
|
||||
$password_hash = "";
|
||||
$selected_angel_types = [];
|
||||
$planned_arrival_date = null;
|
||||
|
||||
$angel_types_source = AngelTypes();
|
||||
$angel_types = [];
|
||||
foreach ($angel_types_source as $angel_type) {
|
||||
$angel_types[$angel_type['id']] = $angel_type['name'] . ($angel_type['restricted'] ? " (restricted)" : "");
|
||||
if (! $angel_type['restricted']) {
|
||||
$selected_angel_types[] = $angel_type['id'];
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_REQUEST['submit'])) {
|
||||
$valid = true;
|
||||
|
||||
if (isset($_REQUEST['nick']) && strlen(User_validate_Nick($_REQUEST['nick'])) > 1) {
|
||||
$nick = User_validate_Nick($_REQUEST['nick']);
|
||||
if (sql_num_query("SELECT * FROM `User` WHERE `Nick`='" . sql_escape($nick) . "' LIMIT 1") > 0) {
|
||||
$valid = false;
|
||||
$msg .= error(sprintf(_("Your nick "%s" already exists."), $nick), true);
|
||||
}
|
||||
} else {
|
||||
$valid = false;
|
||||
$msg .= error(sprintf(_("Your nick "%s" is too short (min. 2 characters)."), User_validate_Nick($_REQUEST['nick'])), true);
|
||||
}
|
||||
|
||||
if (isset($_REQUEST['mail']) && strlen(strip_request_item('mail')) > 0) {
|
||||
$mail = strip_request_item('mail');
|
||||
if (! check_email($mail)) {
|
||||
$valid = false;
|
||||
$msg .= error(_("E-mail address is not correct."), true);
|
||||
}
|
||||
} else {
|
||||
$valid = false;
|
||||
$msg .= error(_("Please enter your e-mail."), true);
|
||||
}
|
||||
|
||||
if (isset($_REQUEST['email_shiftinfo'])) {
|
||||
$email_shiftinfo = true;
|
||||
}
|
||||
|
||||
if (isset($_REQUEST['email_by_human_allowed'])) {
|
||||
$email_by_human_allowed = true;
|
||||
}
|
||||
|
||||
if (isset($_REQUEST['jabber']) && strlen(strip_request_item('jabber')) > 0) {
|
||||
$jabber = strip_request_item('jabber');
|
||||
if (! check_email($jabber)) {
|
||||
$valid = false;
|
||||
$msg .= error(_("Please check your jabber account information."), true);
|
||||
}
|
||||
}
|
||||
|
||||
if ($enable_tshirt_size) {
|
||||
if (isset($_REQUEST['tshirt_size']) && isset($tshirt_sizes[$_REQUEST['tshirt_size']]) && $_REQUEST['tshirt_size'] != '') {
|
||||
$tshirt_size = $_REQUEST['tshirt_size'];
|
||||
} else {
|
||||
$valid = false;
|
||||
$msg .= error(_("Please select your shirt size."), true);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_REQUEST['password']) && strlen($_REQUEST['password']) >= $min_password_length) {
|
||||
if ($_REQUEST['password'] != $_REQUEST['password2']) {
|
||||
$valid = false;
|
||||
$msg .= error(_("Your passwords don't match."), true);
|
||||
}
|
||||
} else {
|
||||
$valid = false;
|
||||
$msg .= error(sprintf(_("Your password is too short (please use at least %s characters)."), $min_password_length), true);
|
||||
}
|
||||
|
||||
if (isset($_REQUEST['planned_arrival_date'])) {
|
||||
$tmp = parse_date("Y-m-d H:i", $_REQUEST['planned_arrival_date'] . " 00:00");
|
||||
$result = User_validate_planned_arrival_date($tmp);
|
||||
$planned_arrival_date = $result->getValue();
|
||||
if (! $result->isValid()) {
|
||||
$valid = false;
|
||||
error(_("Please enter your planned date of arrival. It should be after the buildup start date and before teardown end date."));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Engel registrieren
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function guest_register()
|
||||
{
|
||||
global $user;
|
||||
$tshirt_sizes = config('tshirt_sizes');
|
||||
$enable_tshirt_size = config('enable_tshirt_size');
|
||||
$min_password_length = config('min_password_length');
|
||||
$event_config = EventConfig();
|
||||
|
||||
$msg = '';
|
||||
$nick = '';
|
||||
$lastName = '';
|
||||
$preName = '';
|
||||
$age = '';
|
||||
$tel = '';
|
||||
$dect = '';
|
||||
$mobile = '';
|
||||
$mail = '';
|
||||
$email_shiftinfo = false;
|
||||
$email_by_human_allowed = false;
|
||||
$jabber = '';
|
||||
$hometown = '';
|
||||
$comment = '';
|
||||
$tshirt_size = '';
|
||||
$password_hash = '';
|
||||
$selected_angel_types = [];
|
||||
foreach (array_keys($angel_types) as $angel_type_id) {
|
||||
if (isset($_REQUEST['angel_types_' . $angel_type_id])) {
|
||||
$selected_angel_types[] = $angel_type_id;
|
||||
}
|
||||
}
|
||||
|
||||
// Trivia
|
||||
if (isset($_REQUEST['lastname'])) {
|
||||
$lastname = strip_request_item('lastname');
|
||||
}
|
||||
if (isset($_REQUEST['prename'])) {
|
||||
$prename = strip_request_item('prename');
|
||||
}
|
||||
if (isset($_REQUEST['age']) && preg_match("/^[0-9]{0,4}$/", $_REQUEST['age'])) {
|
||||
$age = strip_request_item('age');
|
||||
}
|
||||
if (isset($_REQUEST['tel'])) {
|
||||
$tel = strip_request_item('tel');
|
||||
}
|
||||
if (isset($_REQUEST['dect'])) {
|
||||
$dect = strip_request_item('dect');
|
||||
}
|
||||
if (isset($_REQUEST['mobile'])) {
|
||||
$mobile = strip_request_item('mobile');
|
||||
}
|
||||
if (isset($_REQUEST['hometown'])) {
|
||||
$hometown = strip_request_item('hometown');
|
||||
}
|
||||
if (isset($_REQUEST['comment'])) {
|
||||
$comment = strip_request_item_nl('comment');
|
||||
$planned_arrival_date = null;
|
||||
|
||||
$angel_types_source = AngelTypes();
|
||||
$angel_types = [];
|
||||
foreach ($angel_types_source as $angel_type) {
|
||||
$angel_types[$angel_type['id']] = $angel_type['name'] . ($angel_type['restricted'] ? ' (restricted)' : '');
|
||||
if (!$angel_type['restricted']) {
|
||||
$selected_angel_types[] = $angel_type['id'];
|
||||
}
|
||||
}
|
||||
|
||||
if ($valid) {
|
||||
sql_query("
|
||||
INSERT INTO `User` SET
|
||||
`color`='" . sql_escape($default_theme) . "',
|
||||
`Nick`='" . sql_escape($nick) . "',
|
||||
`Vorname`='" . sql_escape($prename) . "',
|
||||
`Name`='" . sql_escape($lastname) . "',
|
||||
`Alter`='" . sql_escape($age) . "',
|
||||
`Telefon`='" . sql_escape($tel) . "',
|
||||
`DECT`='" . sql_escape($dect) . "',
|
||||
`Handy`='" . sql_escape($mobile) . "',
|
||||
`email`='" . sql_escape($mail) . "',
|
||||
`email_shiftinfo`=" . sql_bool($email_shiftinfo) . ",
|
||||
`email_by_human_allowed`=" . sql_bool($email_by_human_allowed) . ",
|
||||
`jabber`='" . sql_escape($jabber) . "',
|
||||
`Size`='" . sql_escape($tshirt_size) . "',
|
||||
`Passwort`='" . sql_escape($password_hash) . "',
|
||||
`kommentar`='" . sql_escape($comment) . "',
|
||||
`Hometown`='" . sql_escape($hometown) . "',
|
||||
`CreateDate`=NOW(),
|
||||
`Sprache`='" . sql_escape($_SESSION["locale"]) . "',
|
||||
`arrival_date`=NULL,
|
||||
`planned_arrival_date`='" . sql_escape($planned_arrival_date) . "'");
|
||||
|
||||
// Assign user-group and set password
|
||||
$user_id = sql_id();
|
||||
sql_query("INSERT INTO `UserGroups` SET `uid`='" . sql_escape($user_id) . "', `group_id`=-2");
|
||||
set_password($user_id, $_REQUEST['password']);
|
||||
|
||||
// Assign angel-types
|
||||
$user_angel_types_info = [];
|
||||
foreach ($selected_angel_types as $selected_angel_type_id) {
|
||||
sql_query("INSERT INTO `UserAngelTypes` SET `user_id`='" . sql_escape($user_id) . "', `angeltype_id`='" . sql_escape($selected_angel_type_id) . "'");
|
||||
$user_angel_types_info[] = $angel_types[$selected_angel_type_id];
|
||||
}
|
||||
|
||||
engelsystem_log("User " . User_Nick_render(User($user_id)) . " signed up as: " . join(", ", $user_angel_types_info));
|
||||
success(_("Angel registration successful!"));
|
||||
|
||||
// User is already logged in - that means a supporter has registered an angel. Return to register page.
|
||||
if (isset($user)) {
|
||||
redirect(page_link_to('register'));
|
||||
}
|
||||
|
||||
// If a welcome message is present, display registration success page.
|
||||
if ($event_config != null && $event_config['event_welcome_msg'] != null) {
|
||||
return User_registration_success_view($event_config['event_welcome_msg']);
|
||||
}
|
||||
|
||||
redirect('?');
|
||||
|
||||
foreach ($tshirt_sizes as $key => $size) {
|
||||
if (empty($size)) {
|
||||
unset($tshirt_sizes[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$buildup_start_date = time();
|
||||
$teardown_end_date = null;
|
||||
if ($event_config != null) {
|
||||
if (isset($event_config['buildup_start_date'])) {
|
||||
$buildup_start_date = $event_config['buildup_start_date'];
|
||||
|
||||
if (isset($_REQUEST['submit'])) {
|
||||
$valid = true;
|
||||
|
||||
if (isset($_REQUEST['nick']) && strlen(User_validate_Nick($_REQUEST['nick'])) > 1) {
|
||||
$nick = User_validate_Nick($_REQUEST['nick']);
|
||||
if (count(DB::select('SELECT `UID` FROM `User` WHERE `Nick`=? LIMIT 1', [$nick])) > 0) {
|
||||
$valid = false;
|
||||
$msg .= error(sprintf(_('Your nick "%s" already exists.'), $nick), true);
|
||||
}
|
||||
} else {
|
||||
$valid = false;
|
||||
$msg .= error(sprintf(
|
||||
_('Your nick "%s" is too short (min. 2 characters).'),
|
||||
User_validate_Nick($_REQUEST['nick'])
|
||||
), true);
|
||||
}
|
||||
|
||||
if (isset($_REQUEST['mail']) && strlen(strip_request_item('mail')) > 0) {
|
||||
$mail = strip_request_item('mail');
|
||||
if (!check_email($mail)) {
|
||||
$valid = false;
|
||||
$msg .= error(_('E-mail address is not correct.'), true);
|
||||
}
|
||||
} else {
|
||||
$valid = false;
|
||||
$msg .= error(_('Please enter your e-mail.'), true);
|
||||
}
|
||||
|
||||
if (isset($_REQUEST['email_shiftinfo'])) {
|
||||
$email_shiftinfo = true;
|
||||
}
|
||||
|
||||
if (isset($_REQUEST['email_by_human_allowed'])) {
|
||||
$email_by_human_allowed = true;
|
||||
}
|
||||
|
||||
if (isset($_REQUEST['jabber']) && strlen(strip_request_item('jabber')) > 0) {
|
||||
$jabber = strip_request_item('jabber');
|
||||
if (!check_email($jabber)) {
|
||||
$valid = false;
|
||||
$msg .= error(_('Please check your jabber account information.'), true);
|
||||
}
|
||||
}
|
||||
|
||||
if ($enable_tshirt_size) {
|
||||
if (isset($_REQUEST['tshirt_size']) && isset($tshirt_sizes[$_REQUEST['tshirt_size']]) && $_REQUEST['tshirt_size'] != '') {
|
||||
$tshirt_size = $_REQUEST['tshirt_size'];
|
||||
} else {
|
||||
$valid = false;
|
||||
$msg .= error(_('Please select your shirt size.'), true);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_REQUEST['password']) && strlen($_REQUEST['password']) >= $min_password_length) {
|
||||
if ($_REQUEST['password'] != $_REQUEST['password2']) {
|
||||
$valid = false;
|
||||
$msg .= error(_('Your passwords don\'t match.'), true);
|
||||
}
|
||||
} else {
|
||||
$valid = false;
|
||||
$msg .= error(sprintf(
|
||||
_('Your password is too short (please use at least %s characters).'),
|
||||
$min_password_length
|
||||
), true);
|
||||
}
|
||||
|
||||
if (isset($_REQUEST['planned_arrival_date'])) {
|
||||
$tmp = parse_date('Y-m-d H:i', $_REQUEST['planned_arrival_date'] . ' 00:00');
|
||||
$result = User_validate_planned_arrival_date($tmp);
|
||||
$planned_arrival_date = $result->getValue();
|
||||
if (!$result->isValid()) {
|
||||
$valid = false;
|
||||
error(_('Please enter your planned date of arrival. It should be after the buildup start date and before teardown end date.'));
|
||||
}
|
||||
}
|
||||
|
||||
$selected_angel_types = [];
|
||||
foreach (array_keys($angel_types) as $angel_type_id) {
|
||||
if (isset($_REQUEST['angel_types_' . $angel_type_id])) {
|
||||
$selected_angel_types[] = $angel_type_id;
|
||||
}
|
||||
}
|
||||
|
||||
// Trivia
|
||||
if (isset($_REQUEST['lastname'])) {
|
||||
$lastName = strip_request_item('lastname');
|
||||
}
|
||||
if (isset($_REQUEST['prename'])) {
|
||||
$preName = strip_request_item('prename');
|
||||
}
|
||||
if (isset($_REQUEST['age']) && preg_match('/^\d{0,4}$/', $_REQUEST['age'])) {
|
||||
$age = strip_request_item('age');
|
||||
}
|
||||
if (isset($_REQUEST['tel'])) {
|
||||
$tel = strip_request_item('tel');
|
||||
}
|
||||
if (isset($_REQUEST['dect'])) {
|
||||
$dect = strip_request_item('dect');
|
||||
}
|
||||
if (isset($_REQUEST['mobile'])) {
|
||||
$mobile = strip_request_item('mobile');
|
||||
}
|
||||
if (isset($_REQUEST['hometown'])) {
|
||||
$hometown = strip_request_item('hometown');
|
||||
}
|
||||
if (isset($_REQUEST['comment'])) {
|
||||
$comment = strip_request_item_nl('comment');
|
||||
}
|
||||
|
||||
if ($valid) {
|
||||
DB::insert('
|
||||
INSERT INTO `User` (
|
||||
`color`,
|
||||
`Nick`,
|
||||
`Vorname`,
|
||||
`Name`,
|
||||
`Alter`,
|
||||
`Telefon`,
|
||||
`DECT`,
|
||||
`Handy`,
|
||||
`email`,
|
||||
`email_shiftinfo`,
|
||||
`email_by_human_allowed`,
|
||||
`jabber`,
|
||||
`Size`,
|
||||
`Passwort`,
|
||||
`kommentar`,
|
||||
`Hometown`,
|
||||
`CreateDate`,
|
||||
`Sprache`,
|
||||
`arrival_date`,
|
||||
`planned_arrival_date`
|
||||
)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, NOW(), ?, NULL, ?)
|
||||
',
|
||||
[
|
||||
config('theme'),
|
||||
$nick,
|
||||
$preName,
|
||||
$lastName,
|
||||
$age,
|
||||
$tel,
|
||||
$dect,
|
||||
$mobile,
|
||||
$mail,
|
||||
(bool)$email_shiftinfo,
|
||||
(bool)$email_by_human_allowed,
|
||||
$jabber,
|
||||
$tshirt_size,
|
||||
$password_hash,
|
||||
$comment,
|
||||
$hometown,
|
||||
$_SESSION['locale'],
|
||||
$planned_arrival_date,
|
||||
]
|
||||
);
|
||||
|
||||
// Assign user-group and set password
|
||||
$user_id = DB::getPdo()->lastInsertId();
|
||||
DB::insert('INSERT INTO `UserGroups` (`uid`, `group_id`) VALUES (?, -2)', [$user_id]);
|
||||
set_password($user_id, $_REQUEST['password']);
|
||||
|
||||
// Assign angel-types
|
||||
$user_angel_types_info = [];
|
||||
foreach ($selected_angel_types as $selected_angel_type_id) {
|
||||
DB::insert(
|
||||
'INSERT INTO `UserAngelTypes` (`user_id`, `angeltype_id`) VALUES (?, ?)',
|
||||
[$user_id, $selected_angel_type_id]
|
||||
);
|
||||
$user_angel_types_info[] = $angel_types[$selected_angel_type_id];
|
||||
}
|
||||
|
||||
engelsystem_log(
|
||||
'User ' . User_Nick_render(User($user_id))
|
||||
. ' signed up as: ' . join(', ', $user_angel_types_info)
|
||||
);
|
||||
success(_('Angel registration successful!'));
|
||||
|
||||
// User is already logged in - that means a supporter has registered an angel. Return to register page.
|
||||
if (isset($user)) {
|
||||
redirect(page_link_to('register'));
|
||||
}
|
||||
|
||||
// If a welcome message is present, display registration success page.
|
||||
if ($event_config != null && $event_config['event_welcome_msg'] != null) {
|
||||
return User_registration_success_view($event_config['event_welcome_msg']);
|
||||
}
|
||||
|
||||
redirect('?');
|
||||
}
|
||||
}
|
||||
if(isset($event_config['teardown_end_date'])) {
|
||||
$teardown_end_date = $event_config['teardown_end_date'];
|
||||
|
||||
$buildup_start_date = time();
|
||||
$teardown_end_date = null;
|
||||
if ($event_config != null) {
|
||||
if (isset($event_config['buildup_start_date'])) {
|
||||
$buildup_start_date = $event_config['buildup_start_date'];
|
||||
}
|
||||
if (isset($event_config['teardown_end_date'])) {
|
||||
$teardown_end_date = $event_config['teardown_end_date'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return page_with_title(register_title(), [
|
||||
_("By completing this form you're registering as a Chaos-Angel. This script will create you an account in the angel task scheduler."),
|
||||
$msg,
|
||||
msg(),
|
||||
form([
|
||||
div('row', [
|
||||
div('col-md-6', [
|
||||
div('row', [
|
||||
div('col-sm-4', [
|
||||
form_text('nick', _("Nick") . ' ' . entry_required(), $nick)
|
||||
]),
|
||||
div('col-sm-8', [
|
||||
form_email('mail', _("E-Mail") . ' ' . entry_required(), $mail),
|
||||
form_checkbox('email_shiftinfo', _("The engelsystem is allowed to send me an email (e.g. when my shifts change)"), $email_shiftinfo),
|
||||
form_checkbox('email_by_human_allowed', _("Humans are allowed to send me an email (e.g. for ticket vouchers)"), $email_by_human_allowed)
|
||||
])
|
||||
]),
|
||||
div('row', [
|
||||
div('col-sm-6', [
|
||||
form_date('planned_arrival_date', _("Planned date of arrival") . ' ' . entry_required(), $planned_arrival_date, $buildup_start_date, $teardown_end_date)
|
||||
]),
|
||||
div('col-sm-6', [
|
||||
$enable_tshirt_size ? form_select('tshirt_size', _("Shirt size") . ' ' . entry_required(), $tshirt_sizes, $tshirt_size) : ''
|
||||
])
|
||||
]),
|
||||
div('row', [
|
||||
div('col-sm-6', [
|
||||
form_password('password', _("Password") . ' ' . entry_required())
|
||||
]),
|
||||
div('col-sm-6', [
|
||||
form_password('password2', _("Confirm password") . ' ' . entry_required())
|
||||
])
|
||||
]),
|
||||
form_checkboxes('angel_types', _("What do you want to do?") . sprintf(" (<a href=\"%s\">%s</a>)", page_link_to('angeltypes') . '&action=about', _("Description of job types")), $angel_types, $selected_angel_types),
|
||||
form_info("", _("Restricted angel types need will be confirmed later by a supporter. You can change your selection in the options section."))
|
||||
]),
|
||||
div('col-md-6', [
|
||||
div('row', [
|
||||
div('col-sm-4', [
|
||||
form_text('dect', _("DECT"), $dect)
|
||||
]),
|
||||
div('col-sm-4', [
|
||||
form_text('mobile', _("Mobile"), $mobile)
|
||||
]),
|
||||
div('col-sm-4', [
|
||||
form_text('tel', _("Phone"), $tel)
|
||||
])
|
||||
]),
|
||||
form_text('jabber', _("Jabber"), $jabber),
|
||||
div('row', [
|
||||
div('col-sm-6', [
|
||||
form_text('prename', _("First name"), $prename)
|
||||
]),
|
||||
div('col-sm-6', [
|
||||
form_text('lastname', _("Last name"), $lastname)
|
||||
])
|
||||
]),
|
||||
div('row', [
|
||||
div('col-sm-3', [
|
||||
form_text('age', _("Age"), $age)
|
||||
]),
|
||||
div('col-sm-9', [
|
||||
form_text('hometown', _("Hometown"), $hometown)
|
||||
])
|
||||
]),
|
||||
form_info(entry_required() . ' = ' . _("Entry required!"))
|
||||
])
|
||||
]),
|
||||
// form_textarea('comment', _("Did you help at former CCC events and which tasks have you performed then?"), $comment),
|
||||
form_submit('submit', _("Register"))
|
||||
])
|
||||
]);
|
||||
|
||||
return page_with_title(register_title(), [
|
||||
_('By completing this form you\'re registering as a Chaos-Angel. This script will create you an account in the angel task scheduler.'),
|
||||
$msg,
|
||||
msg(),
|
||||
form([
|
||||
div('row', [
|
||||
div('col-md-6', [
|
||||
div('row', [
|
||||
div('col-sm-4', [
|
||||
form_text('nick', _('Nick') . ' ' . entry_required(), $nick)
|
||||
]),
|
||||
div('col-sm-8', [
|
||||
form_email('mail', _('E-Mail') . ' ' . entry_required(), $mail),
|
||||
form_checkbox(
|
||||
'email_shiftinfo',
|
||||
_('The engelsystem is allowed to send me an email (e.g. when my shifts change)'),
|
||||
$email_shiftinfo
|
||||
),
|
||||
form_checkbox(
|
||||
'email_by_human_allowed',
|
||||
_('Humans are allowed to send me an email (e.g. for ticket vouchers)'),
|
||||
$email_by_human_allowed
|
||||
)
|
||||
])
|
||||
]),
|
||||
div('row', [
|
||||
div('col-sm-6', [
|
||||
form_date(
|
||||
'planned_arrival_date',
|
||||
_('Planned date of arrival') . ' ' . entry_required(),
|
||||
$planned_arrival_date, $buildup_start_date, $teardown_end_date
|
||||
)
|
||||
]),
|
||||
div('col-sm-6', [
|
||||
$enable_tshirt_size ? form_select('tshirt_size',
|
||||
_('Shirt size') . ' ' . entry_required(),
|
||||
$tshirt_sizes, $tshirt_size) : ''
|
||||
])
|
||||
]),
|
||||
div('row', [
|
||||
div('col-sm-6', [
|
||||
form_password('password', _('Password') . ' ' . entry_required())
|
||||
]),
|
||||
div('col-sm-6', [
|
||||
form_password('password2', _('Confirm password') . ' ' . entry_required())
|
||||
])
|
||||
]),
|
||||
form_checkboxes(
|
||||
'angel_types',
|
||||
_('What do you want to do?') . sprintf(
|
||||
' (<a href="%s">%s</a>)',
|
||||
page_link_to('angeltypes') . '&action=about',
|
||||
_('Description of job types')
|
||||
),
|
||||
$angel_types,
|
||||
$selected_angel_types
|
||||
),
|
||||
form_info(
|
||||
'',
|
||||
_('Restricted angel types need will be confirmed later by a supporter. You can change your selection in the options section.')
|
||||
)
|
||||
]),
|
||||
div('col-md-6', [
|
||||
div('row', [
|
||||
div('col-sm-4', [
|
||||
form_text('dect', _('DECT'), $dect)
|
||||
]),
|
||||
div('col-sm-4', [
|
||||
form_text('mobile', _('Mobile'), $mobile)
|
||||
]),
|
||||
div('col-sm-4', [
|
||||
form_text('tel', _('Phone'), $tel)
|
||||
])
|
||||
]),
|
||||
form_text('jabber', _('Jabber'), $jabber),
|
||||
div('row', [
|
||||
div('col-sm-6', [
|
||||
form_text('prename', _('First name'), $preName)
|
||||
]),
|
||||
div('col-sm-6', [
|
||||
form_text('lastname', _('Last name'), $lastName)
|
||||
])
|
||||
]),
|
||||
div('row', [
|
||||
div('col-sm-3', [
|
||||
form_text('age', _('Age'), $age)
|
||||
]),
|
||||
div('col-sm-9', [
|
||||
form_text('hometown', _('Hometown'), $hometown)
|
||||
])
|
||||
]),
|
||||
form_info(entry_required() . ' = ' . _('Entry required!'))
|
||||
])
|
||||
]),
|
||||
// form_textarea('comment', _('Did you help at former CCC events and which tasks have you performed then?'), $comment),
|
||||
form_submit('submit', _('Register'))
|
||||
])
|
||||
]);
|
||||
}
|
||||
|
||||
function entry_required() {
|
||||
return '<span class="text-info glyphicon glyphicon-warning-sign"></span>';
|
||||
function entry_required()
|
||||
{
|
||||
return '<span class="text-info glyphicon glyphicon-warning-sign"></span>';
|
||||
}
|
||||
|
||||
function guest_logout() {
|
||||
session_destroy();
|
||||
redirect(page_link_to("start"));
|
||||
function guest_logout()
|
||||
{
|
||||
session_destroy();
|
||||
redirect(page_link_to('start'));
|
||||
return true;
|
||||
}
|
||||
|
||||
function guest_login() {
|
||||
$nick = "";
|
||||
|
||||
unset($_SESSION['uid']);
|
||||
$valid = true;
|
||||
|
||||
if (isset($_REQUEST['submit'])) {
|
||||
|
||||
if (isset($_REQUEST['nick']) && strlen(User_validate_Nick($_REQUEST['nick'])) > 0) {
|
||||
$nick = User_validate_Nick($_REQUEST['nick']);
|
||||
$login_user = sql_select("SELECT * FROM `User` WHERE `Nick`='" . sql_escape($nick) . "'");
|
||||
if (count($login_user) > 0) {
|
||||
$login_user = $login_user[0];
|
||||
if (isset($_REQUEST['password'])) {
|
||||
if (! verify_password($_REQUEST['password'], $login_user['Passwort'], $login_user['UID'])) {
|
||||
$valid = false;
|
||||
error(_("Your password is incorrect. Please try it again."));
|
||||
}
|
||||
function guest_login()
|
||||
{
|
||||
$nick = '';
|
||||
|
||||
unset($_SESSION['uid']);
|
||||
$valid = true;
|
||||
|
||||
if (isset($_REQUEST['submit'])) {
|
||||
if (isset($_REQUEST['nick']) && strlen(User_validate_Nick($_REQUEST['nick'])) > 0) {
|
||||
$nick = User_validate_Nick($_REQUEST['nick']);
|
||||
$login_user = DB::select('SELECT * FROM `User` WHERE `Nick`=?', [$nick]);
|
||||
if (count($login_user) > 0) {
|
||||
$login_user = $login_user[0];
|
||||
if (isset($_REQUEST['password'])) {
|
||||
if (!verify_password($_REQUEST['password'], $login_user['Passwort'], $login_user['UID'])) {
|
||||
$valid = false;
|
||||
error(_('Your password is incorrect. Please try it again.'));
|
||||
}
|
||||
} else {
|
||||
$valid = false;
|
||||
error(_('Please enter a password.'));
|
||||
}
|
||||
} else {
|
||||
$valid = false;
|
||||
error(_('No user was found with that Nickname. Please try again. If you are still having problems, ask a Dispatcher.'));
|
||||
}
|
||||
} else {
|
||||
$valid = false;
|
||||
error(_("Please enter a password."));
|
||||
$valid = false;
|
||||
error(_('Please enter a nickname.'));
|
||||
}
|
||||
|
||||
if ($valid && !empty($login_user)) {
|
||||
$_SESSION['uid'] = $login_user['UID'];
|
||||
$_SESSION['locale'] = $login_user['Sprache'];
|
||||
|
||||
redirect(page_link_to('news'));
|
||||
}
|
||||
} else {
|
||||
$valid = false;
|
||||
error(_("No user was found with that Nickname. Please try again. If you are still having problems, ask a Dispatcher."));
|
||||
}
|
||||
} else {
|
||||
$valid = false;
|
||||
error(_("Please enter a nickname."));
|
||||
}
|
||||
|
||||
if ($valid) {
|
||||
$_SESSION['uid'] = $login_user['UID'];
|
||||
$_SESSION['locale'] = $login_user['Sprache'];
|
||||
|
||||
redirect(page_link_to('news'));
|
||||
}
|
||||
}
|
||||
|
||||
$event_config = EventConfig();
|
||||
|
||||
return page([
|
||||
div('col-md-12', [
|
||||
div('row', [
|
||||
EventConfig_countdown_page($event_config)
|
||||
]),
|
||||
div('row', [
|
||||
div('col-sm-6 col-sm-offset-3 col-md-4 col-md-offset-4', [
|
||||
div('panel panel-primary first', [
|
||||
div('panel-heading', [
|
||||
'<span class="icon-icon_angel"></span> ' . _("Login")
|
||||
]),
|
||||
div('panel-body', [
|
||||
msg(),
|
||||
form([
|
||||
form_text_placeholder('nick', _("Nick"), $nick),
|
||||
form_password_placeholder('password', _("Password")),
|
||||
form_submit('submit', _("Login")),
|
||||
! $valid ? buttons([
|
||||
button(page_link_to('user_password_recovery'), _("I forgot my password"))
|
||||
]) : ''
|
||||
])
|
||||
]),
|
||||
div('panel-footer', [
|
||||
glyph('info-sign') . _("Please note: You have to activate cookies!")
|
||||
])
|
||||
])
|
||||
])
|
||||
]),
|
||||
div('row', [
|
||||
div('col-sm-6 text-center', [
|
||||
heading(register_title(), 2),
|
||||
get_register_hint()
|
||||
]),
|
||||
div('col-sm-6 text-center', [
|
||||
heading(_("What can I do?"), 2),
|
||||
'<p>' . _("Please read about the jobs you can do to help us.") . '</p>',
|
||||
buttons([
|
||||
button(page_link_to('angeltypes') . '&action=about', _("Teams/Job description") . ' »')
|
||||
])
|
||||
])
|
||||
])
|
||||
])
|
||||
]);
|
||||
}
|
||||
|
||||
function get_register_hint() {
|
||||
global $privileges;
|
||||
|
||||
if (in_array('register', $privileges)) {
|
||||
return join('', [
|
||||
'<p>' . _("Please sign up, if you want to help us!") . '</p>',
|
||||
buttons([
|
||||
button(page_link_to('register'), register_title() . ' »')
|
||||
])
|
||||
$event_config = EventConfig();
|
||||
|
||||
return page([
|
||||
div('col-md-12', [
|
||||
div('row', [
|
||||
EventConfig_countdown_page($event_config)
|
||||
]),
|
||||
div('row', [
|
||||
div('col-sm-6 col-sm-offset-3 col-md-4 col-md-offset-4', [
|
||||
div('panel panel-primary first', [
|
||||
div('panel-heading', [
|
||||
'<span class="icon-icon_angel"></span> ' . _('Login')
|
||||
]),
|
||||
div('panel-body', [
|
||||
msg(),
|
||||
form([
|
||||
form_text_placeholder('nick', _('Nick'), $nick),
|
||||
form_password_placeholder('password', _('Password')),
|
||||
form_submit('submit', _('Login')),
|
||||
!$valid ? buttons([
|
||||
button(page_link_to('user_password_recovery'), _('I forgot my password'))
|
||||
]) : ''
|
||||
])
|
||||
]),
|
||||
div('panel-footer', [
|
||||
glyph('info-sign') . _('Please note: You have to activate cookies!')
|
||||
])
|
||||
])
|
||||
])
|
||||
]),
|
||||
div('row', [
|
||||
div('col-sm-6 text-center', [
|
||||
heading(register_title(), 2),
|
||||
get_register_hint()
|
||||
]),
|
||||
div('col-sm-6 text-center', [
|
||||
heading(_('What can I do?'), 2),
|
||||
'<p>' . _('Please read about the jobs you can do to help us.') . '</p>',
|
||||
buttons([
|
||||
button(page_link_to('angeltypes') . '&action=about', _('Teams/Job description') . ' »')
|
||||
])
|
||||
])
|
||||
])
|
||||
])
|
||||
]);
|
||||
}
|
||||
|
||||
//FIXME: return error(_("Registration is disabled."), true);
|
||||
return error("Registration is <a href='https://engelsystem.de/33c3/overwhelmed.html'>disabled</a>.", true);
|
||||
}
|
||||
?>
|
||||
|
||||
function get_register_hint()
|
||||
{
|
||||
global $privileges;
|
||||
|
||||
if (in_array('register', $privileges)) {
|
||||
return join('', [
|
||||
'<p>' . _('Please sign up, if you want to help us!') . '</p>',
|
||||
buttons([
|
||||
button(page_link_to('register'), register_title() . ' »')
|
||||
])
|
||||
]);
|
||||
}
|
||||
|
||||
//FIXME: return error(_('Registration is disabled.'), true);
|
||||
return error('Registration is <a href="https://engelsystem.de/33c3/overwhelmed.html">disabled</a>.', true);
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
<?php
|
||||
function guest_start() {
|
||||
redirect(page_link_to('login'));
|
||||
function guest_start()
|
||||
{
|
||||
redirect(page_link_to('login'));
|
||||
return true;
|
||||
}
|
||||
?>
|
||||
@ -1,57 +1,85 @@
|
||||
<?php
|
||||
|
||||
function questions_title() {
|
||||
return _("Ask the Heaven");
|
||||
use Engelsystem\Database\DB;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
function questions_title()
|
||||
{
|
||||
return _('Ask the Heaven');
|
||||
}
|
||||
|
||||
function user_questions() {
|
||||
global $user;
|
||||
|
||||
if (! isset($_REQUEST['action'])) {
|
||||
$open_questions = sql_select("SELECT * FROM `Questions` WHERE `AID` IS NULL AND `UID`='" . sql_escape($user['UID']) . "'");
|
||||
|
||||
$answered_questions = sql_select("SELECT * FROM `Questions` WHERE NOT `AID` IS NULL AND `UID`='" . sql_escape($user['UID']) . "'");
|
||||
foreach ($answered_questions as &$question) {
|
||||
$answer_user_source = User($question['AID']);
|
||||
$question['answer_user'] = User_Nick_render($answer_user_source);
|
||||
}
|
||||
|
||||
return Questions_view($open_questions, $answered_questions, page_link_to("user_questions") . '&action=ask');
|
||||
} else {
|
||||
switch ($_REQUEST['action']) {
|
||||
case 'ask':
|
||||
$question = strip_request_item_nl('question');
|
||||
if ($question != "") {
|
||||
$result = sql_query("INSERT INTO `Questions` SET `UID`='" . sql_escape($user['UID']) . "', `Question`='" . sql_escape($question) . "'");
|
||||
if ($result === false) {
|
||||
engelsystem_error(_("Unable to save question."));
|
||||
}
|
||||
success(_("You question was saved."));
|
||||
redirect(page_link_to("user_questions"));
|
||||
} else {
|
||||
return page_with_title(questions_title(), [
|
||||
error(_("Please enter a question!"), true)
|
||||
]);
|
||||
}
|
||||
break;
|
||||
case 'delete':
|
||||
if (isset($_REQUEST['id']) && preg_match("/^[0-9]{1,11}$/", $_REQUEST['id'])) {
|
||||
$question_id = $_REQUEST['id'];
|
||||
} else {
|
||||
return error(_("Incomplete call, missing Question ID."), true);
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
function user_questions()
|
||||
{
|
||||
global $user;
|
||||
|
||||
if (!isset($_REQUEST['action'])) {
|
||||
$open_questions = DB::select(
|
||||
'SELECT * FROM `Questions` WHERE `AID` IS NULL AND `UID`=?',
|
||||
[$user['UID']]
|
||||
);
|
||||
|
||||
$answered_questions = DB::select(
|
||||
'SELECT * FROM `Questions` WHERE NOT `AID` IS NULL AND `UID`=?',
|
||||
[$user['UID']]
|
||||
);
|
||||
foreach ($answered_questions as &$question) {
|
||||
$answer_user_source = User($question['AID']);
|
||||
$question['answer_user'] = User_Nick_render($answer_user_source);
|
||||
}
|
||||
|
||||
$question = sql_select("SELECT * FROM `Questions` WHERE `QID`='" . sql_escape($question_id) . "' LIMIT 1");
|
||||
if (count($question) > 0 && $question[0]['UID'] == $user['UID']) {
|
||||
sql_query("DELETE FROM `Questions` WHERE `QID`='" . sql_escape($question_id) . "' LIMIT 1");
|
||||
redirect(page_link_to("user_questions"));
|
||||
} else {
|
||||
return page_with_title(questions_title(), [
|
||||
error(_("No question found."), true)
|
||||
]);
|
||||
|
||||
return Questions_view($open_questions, $answered_questions, page_link_to('user_questions') . '&action=ask');
|
||||
} else {
|
||||
switch ($_REQUEST['action']) {
|
||||
case 'ask':
|
||||
$question = strip_request_item_nl('question');
|
||||
if ($question != '') {
|
||||
$result = DB::insert('
|
||||
INSERT INTO `Questions` (`UID`, `Question`)
|
||||
VALUES (?, ?)
|
||||
',
|
||||
[$user['UID'], $question]
|
||||
);
|
||||
if (!$result) {
|
||||
engelsystem_error(_('Unable to save question.'));
|
||||
}
|
||||
success(_('You question was saved.'));
|
||||
redirect(page_link_to('user_questions'));
|
||||
} else {
|
||||
return page_with_title(questions_title(), [
|
||||
error(_('Please enter a question!'), true)
|
||||
]);
|
||||
}
|
||||
break;
|
||||
case 'delete':
|
||||
if (isset($_REQUEST['id']) && preg_match('/^\d{1,11}$/', $_REQUEST['id'])) {
|
||||
$question_id = $_REQUEST['id'];
|
||||
} else {
|
||||
return error(_('Incomplete call, missing Question ID.'), true);
|
||||
}
|
||||
|
||||
$question = DB::select(
|
||||
'SELECT `UID` FROM `Questions` WHERE `QID`=? LIMIT 1',
|
||||
[$question_id]
|
||||
);
|
||||
if (count($question) > 0 && $question[0]['UID'] == $user['UID']) {
|
||||
DB::delete(
|
||||
'DELETE FROM `Questions` WHERE `QID`=? LIMIT 1',
|
||||
[$question_id]
|
||||
);
|
||||
redirect(page_link_to('user_questions'));
|
||||
} else {
|
||||
return page_with_title(questions_title(), [
|
||||
error(_('No question found.'), true)
|
||||
]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
?>
|
||||
@ -1,37 +1,42 @@
|
||||
<?php
|
||||
|
||||
function Questions_view($open_questions, $answered_questions, $ask_action) {
|
||||
foreach ($open_questions as &$question) {
|
||||
$question['actions'] = '<a href="' . page_link_to("user_questions") . '&action=delete&id=' . $question['QID'] . '">' . _("delete") . '</a>';
|
||||
$question['Question'] = str_replace("\n", '<br />', $question['Question']);
|
||||
}
|
||||
|
||||
foreach ($answered_questions as &$question) {
|
||||
$question['Question'] = str_replace("\n", '<br />', $question['Question']);
|
||||
$question['Answer'] = str_replace("\n", '<br />', $question['Answer']);
|
||||
$question['actions'] = '<a href="' . page_link_to("user_questions") . '&action=delete&id=' . $question['QID'] . '">' . _("delete") . '</a>';
|
||||
}
|
||||
|
||||
return page_with_title(questions_title(), [
|
||||
msg(),
|
||||
heading(_("Open questions"), 2),
|
||||
table([
|
||||
'Question' => _("Question"),
|
||||
'actions' => ""
|
||||
], $open_questions),
|
||||
heading(_("Answered questions"), 2),
|
||||
table([
|
||||
'Question' => _("Question"),
|
||||
'answer_user' => _("Answered by"),
|
||||
'Answer' => _("Answer"),
|
||||
'actions' => ""
|
||||
], $answered_questions),
|
||||
heading(_("Ask the Heaven"), 2),
|
||||
form([
|
||||
form_textarea('question', _("Your Question:"), ""),
|
||||
form_submit('submit', _("Save"))
|
||||
], $ask_action)
|
||||
]);
|
||||
}
|
||||
/**
|
||||
* @param array[] $open_questions
|
||||
* @param array[] $answered_questions
|
||||
* @param string $ask_action
|
||||
* @return string
|
||||
*/
|
||||
function Questions_view($open_questions, $answered_questions, $ask_action)
|
||||
{
|
||||
foreach ($open_questions as &$question) {
|
||||
$question['actions'] = '<a href="' . page_link_to('user_questions') . '&action=delete&id=' . $question['QID'] . '">' . _('delete') . '</a>';
|
||||
$question['Question'] = str_replace("\n", '<br />', $question['Question']);
|
||||
}
|
||||
|
||||
foreach ($answered_questions as &$question) {
|
||||
$question['Question'] = str_replace("\n", '<br />', $question['Question']);
|
||||
$question['Answer'] = str_replace("\n", '<br />', $question['Answer']);
|
||||
$question['actions'] = '<a href="' . page_link_to('user_questions') . '&action=delete&id=' . $question['QID'] . '">' . _('delete') . '</a>';
|
||||
}
|
||||
|
||||
?>
|
||||
return page_with_title(questions_title(), [
|
||||
msg(),
|
||||
heading(_('Open questions'), 2),
|
||||
table([
|
||||
'Question' => _('Question'),
|
||||
'actions' => ''
|
||||
], $open_questions),
|
||||
heading(_('Answered questions'), 2),
|
||||
table([
|
||||
'Question' => _('Question'),
|
||||
'answer_user' => _('Answered by'),
|
||||
'Answer' => _('Answer'),
|
||||
'actions' => ''
|
||||
], $answered_questions),
|
||||
heading(_('Ask the Heaven'), 2),
|
||||
form([
|
||||
form_textarea('question', _('Your Question:'), ''),
|
||||
form_submit('submit', _('Save'))
|
||||
], $ask_action)
|
||||
]);
|
||||
}
|
||||
|
||||
@ -1,20 +1,30 @@
|
||||
<?php
|
||||
use Engelsystem\ShiftsFilterRenderer;
|
||||
use Engelsystem\ShiftCalendarRenderer;
|
||||
use Engelsystem\ShiftsFilterRenderer;
|
||||
|
||||
function Room_view($room, ShiftsFilterRenderer $shiftsFilterRenderer, ShiftCalendarRenderer $shiftCalendarRenderer) {
|
||||
return page_with_title(glyph('map-marker') . $room['Name'], [
|
||||
$shiftsFilterRenderer->render(room_link($room)) ,
|
||||
$shiftCalendarRenderer->render()
|
||||
]);
|
||||
/**
|
||||
* @param array $room
|
||||
* @param ShiftsFilterRenderer $shiftsFilterRenderer
|
||||
* @param ShiftCalendarRenderer $shiftCalendarRenderer
|
||||
* @return string
|
||||
*/
|
||||
function Room_view($room, ShiftsFilterRenderer $shiftsFilterRenderer, ShiftCalendarRenderer $shiftCalendarRenderer)
|
||||
{
|
||||
return page_with_title(glyph('map-marker') . $room['Name'], [
|
||||
$shiftsFilterRenderer->render(room_link($room)),
|
||||
$shiftCalendarRenderer->render()
|
||||
]);
|
||||
}
|
||||
|
||||
function Room_name_render($room) {
|
||||
global $privileges;
|
||||
if (in_array('view_rooms', $privileges)) {
|
||||
return '<a href="' . room_link($room) . '">' . glyph('map-marker') . $room['Name'] . '</a>';
|
||||
}
|
||||
return glyph('map-marker') . $room['Name'];
|
||||
/**
|
||||
* @param array $room
|
||||
* @return string
|
||||
*/
|
||||
function Room_name_render($room)
|
||||
{
|
||||
global $privileges;
|
||||
if (in_array('view_rooms', $privileges)) {
|
||||
return '<a href="' . room_link($room) . '">' . glyph('map-marker') . $room['Name'] . '</a>';
|
||||
}
|
||||
return glyph('map-marker') . $room['Name'];
|
||||
}
|
||||
|
||||
?>
|
||||
@ -1,84 +1,127 @@
|
||||
<?php
|
||||
|
||||
function ShiftType_name_render($shifttype) {
|
||||
global $privileges;
|
||||
if (in_array('shifttypes', $privileges)) {
|
||||
return '<a href="' . shifttype_link($shifttype) . '">' . $shifttype['name'] . '</a>';
|
||||
}
|
||||
return $shifttype['name'];
|
||||
/**
|
||||
* @param array $shifttype
|
||||
* @return string
|
||||
*/
|
||||
function ShiftType_name_render($shifttype)
|
||||
{
|
||||
global $privileges;
|
||||
if (in_array('shifttypes', $privileges)) {
|
||||
return '<a href="' . shifttype_link($shifttype) . '">' . $shifttype['name'] . '</a>';
|
||||
}
|
||||
return $shifttype['name'];
|
||||
}
|
||||
|
||||
function ShiftType_delete_view($shifttype) {
|
||||
return page_with_title(sprintf(_("Delete shifttype %s"), $shifttype['name']), [
|
||||
info(sprintf(_("Do you want to delete shifttype %s?"), $shifttype['name']), true),
|
||||
buttons([
|
||||
button(page_link_to('shifttypes'), _("cancel"), 'cancel'),
|
||||
button(page_link_to('shifttypes') . '&action=delete&shifttype_id=' . $shifttype['id'] . '&confirmed', _("delete"), 'ok')
|
||||
])
|
||||
]);
|
||||
/**
|
||||
* @param array $shifttype
|
||||
* @return string
|
||||
*/
|
||||
function ShiftType_delete_view($shifttype)
|
||||
{
|
||||
return page_with_title(sprintf(_('Delete shifttype %s'), $shifttype['name']), [
|
||||
info(sprintf(_('Do you want to delete shifttype %s?'), $shifttype['name']), true),
|
||||
buttons([
|
||||
button(page_link_to('shifttypes'), _('cancel'), 'cancel'),
|
||||
button(
|
||||
page_link_to('shifttypes') . '&action=delete&shifttype_id=' . $shifttype['id'] . '&confirmed',
|
||||
_('delete'),
|
||||
'ok btn-danger'
|
||||
)
|
||||
])
|
||||
]);
|
||||
}
|
||||
|
||||
function ShiftType_edit_view($name, $angeltype_id, $angeltypes, $description, $shifttype_id) {
|
||||
$angeltypes_select = [
|
||||
'' => _('All')
|
||||
];
|
||||
foreach ($angeltypes as $angeltype) {
|
||||
$angeltypes_select[$angeltype['id']] = $angeltype['name'];
|
||||
}
|
||||
|
||||
return page_with_title($shifttype_id ? _('Edit shifttype') : _('Create shifttype'), [
|
||||
msg(),
|
||||
buttons([
|
||||
button(page_link_to('shifttypes'), shifttypes_title(), 'back')
|
||||
]),
|
||||
form([
|
||||
form_text('name', _('Name'), $name),
|
||||
form_select('angeltype_id', _('Angeltype'), $angeltypes_select, $angeltype_id),
|
||||
form_textarea('description', _('Description'), $description),
|
||||
form_info('', _('Please use markdown for the description.')),
|
||||
form_submit('submit', _('Save'))
|
||||
])
|
||||
]);
|
||||
}
|
||||
/**
|
||||
* @param string $name
|
||||
* @param int $angeltype_id
|
||||
* @param array[] $angeltypes
|
||||
* @param string $description
|
||||
* @param int|bool $shifttype_id
|
||||
* @return string
|
||||
*/
|
||||
function ShiftType_edit_view($name, $angeltype_id, $angeltypes, $description, $shifttype_id)
|
||||
{
|
||||
$angeltypes_select = [
|
||||
'' => _('All')
|
||||
];
|
||||
foreach ($angeltypes as $angeltype) {
|
||||
$angeltypes_select[$angeltype['id']] = $angeltype['name'];
|
||||
}
|
||||
|
||||
function ShiftType_view($shifttype, $angeltype) {
|
||||
$parsedown = new Parsedown();
|
||||
$title = $shifttype['name'];
|
||||
if ($angeltype) {
|
||||
$title .= ' <small>' . sprintf(_('for team %s'), $angeltype['name']) . '</small>';
|
||||
}
|
||||
return page_with_title($title, [
|
||||
msg(),
|
||||
buttons([
|
||||
button(page_link_to('shifttypes'), shifttypes_title(), 'back'),
|
||||
$angeltype ? button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], $angeltype['name']) : '',
|
||||
button(page_link_to('shifttypes') . '&action=edit&shifttype_id=' . $shifttype['id'], _('edit'), 'edit'),
|
||||
button(page_link_to('shifttypes') . '&action=delete&shifttype_id=' . $shifttype['id'], _('delete'), 'delete')
|
||||
]),
|
||||
heading(_("Description"), 2),
|
||||
$parsedown->parse($shifttype['description'])
|
||||
]);
|
||||
return page_with_title($shifttype_id ? _('Edit shifttype') : _('Create shifttype'), [
|
||||
msg(),
|
||||
buttons([
|
||||
button(page_link_to('shifttypes'), shifttypes_title(), 'back')
|
||||
]),
|
||||
form([
|
||||
form_text('name', _('Name'), $name),
|
||||
form_select('angeltype_id', _('Angeltype'), $angeltypes_select, $angeltype_id),
|
||||
form_textarea('description', _('Description'), $description),
|
||||
form_info('', _('Please use markdown for the description.')),
|
||||
form_submit('submit', _('Save'))
|
||||
])
|
||||
]);
|
||||
}
|
||||
|
||||
function ShiftTypes_list_view($shifttypes) {
|
||||
foreach ($shifttypes as &$shifttype) {
|
||||
$shifttype['name'] = '<a href="' . page_link_to('shifttypes') . '&action=view&shifttype_id=' . $shifttype['id'] . '">' . $shifttype['name'] . '</a>';
|
||||
$shifttype['actions'] = table_buttons([
|
||||
button(page_link_to('shifttypes') . '&action=edit&shifttype_id=' . $shifttype['id'], _('edit'), 'btn-xs'),
|
||||
button(page_link_to('shifttypes') . '&action=delete&shifttype_id=' . $shifttype['id'], _('delete'), 'btn-xs')
|
||||
/**
|
||||
* @param array $shifttype
|
||||
* @param array $angeltype
|
||||
* @return string
|
||||
*/
|
||||
function ShiftType_view($shifttype, $angeltype)
|
||||
{
|
||||
$parsedown = new Parsedown();
|
||||
$title = $shifttype['name'];
|
||||
if ($angeltype) {
|
||||
$title .= ' <small>' . sprintf(_('for team %s'), $angeltype['name']) . '</small>';
|
||||
}
|
||||
return page_with_title($title, [
|
||||
msg(),
|
||||
buttons([
|
||||
button(page_link_to('shifttypes'), shifttypes_title(), 'back'),
|
||||
$angeltype ? button(
|
||||
page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'],
|
||||
$angeltype['name']
|
||||
) : '',
|
||||
button(page_link_to('shifttypes') . '&action=edit&shifttype_id=' . $shifttype['id'], _('edit'), 'edit'),
|
||||
button(
|
||||
page_link_to('shifttypes') . '&action=delete&shifttype_id=' . $shifttype['id'],
|
||||
_('delete'),
|
||||
'delete'
|
||||
)
|
||||
]),
|
||||
heading(_('Description'), 2),
|
||||
$parsedown->parse($shifttype['description'])
|
||||
]);
|
||||
}
|
||||
|
||||
return page_with_title(shifttypes_title(), [
|
||||
msg(),
|
||||
buttons([
|
||||
button(page_link_to('shifttypes') . '&action=edit', _('New shifttype'), 'add')
|
||||
]),
|
||||
table([
|
||||
'name' => _('Name'),
|
||||
'actions' => ''
|
||||
], $shifttypes)
|
||||
]);
|
||||
}
|
||||
|
||||
?>
|
||||
/**
|
||||
* @param array[] $shifttypes
|
||||
* @return string
|
||||
*/
|
||||
function ShiftTypes_list_view($shifttypes)
|
||||
{
|
||||
foreach ($shifttypes as &$shifttype) {
|
||||
$shifttype['name'] = '<a href="' . page_link_to('shifttypes') . '&action=view&shifttype_id=' . $shifttype['id'] . '">' . $shifttype['name'] . '</a>';
|
||||
$shifttype['actions'] = table_buttons([
|
||||
button(page_link_to('shifttypes') . '&action=edit&shifttype_id=' . $shifttype['id'], _('edit'), 'btn-xs'),
|
||||
button(
|
||||
page_link_to('shifttypes') . '&action=delete&shifttype_id=' . $shifttype['id'],
|
||||
_('delete'),
|
||||
'btn-xs'
|
||||
)
|
||||
]);
|
||||
}
|
||||
|
||||
return page_with_title(shifttypes_title(), [
|
||||
msg(),
|
||||
buttons([
|
||||
button(page_link_to('shifttypes') . '&action=edit', _('New shifttype'), 'add')
|
||||
]),
|
||||
table([
|
||||
'name' => _('Name'),
|
||||
'actions' => ''
|
||||
], $shifttypes)
|
||||
]);
|
||||
}
|
||||
|
||||
@ -1,88 +1,164 @@
|
||||
<?php
|
||||
|
||||
function UserAngelType_update_view($user_angeltype, $user, $angeltype, $supporter) {
|
||||
return page_with_title($supporter ? _("Add supporter rights") : _("Remove supporter rights"), [
|
||||
msg(),
|
||||
info(sprintf($supporter ? _("Do you really want to add supporter rights for %s to %s?") : _("Do you really want to remove supporter rights for %s from %s?"), $angeltype['name'], User_Nick_render($user)), true),
|
||||
buttons([
|
||||
button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _("cancel"), 'cancel'),
|
||||
button(page_link_to('user_angeltypes') . '&action=update&user_angeltype_id=' . $user_angeltype['id'] . '&supporter=' . ($supporter ? '1' : '0') . '&confirmed', _("yes"), 'ok')
|
||||
])
|
||||
]);
|
||||
/**
|
||||
* @param array $user_angeltype
|
||||
* @param array $user
|
||||
* @param array $angeltype
|
||||
* @param bool $supporter
|
||||
* @return string
|
||||
*/
|
||||
function UserAngelType_update_view($user_angeltype, $user, $angeltype, $supporter)
|
||||
{
|
||||
return page_with_title($supporter ? _('Add supporter rights') : _('Remove supporter rights'), [
|
||||
msg(),
|
||||
info(sprintf(
|
||||
$supporter
|
||||
? _('Do you really want to add supporter rights for %s to %s?')
|
||||
: _('Do you really want to remove supporter rights for %s from %s?'),
|
||||
$angeltype['name'],
|
||||
User_Nick_render($user)
|
||||
), true),
|
||||
buttons([
|
||||
button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _('cancel'), 'cancel'),
|
||||
button(
|
||||
page_link_to('user_angeltypes')
|
||||
. '&action=update&user_angeltype_id=' . $user_angeltype['id']
|
||||
. '&supporter=' . ($supporter ? '1' : '0')
|
||||
. '&confirmed',
|
||||
_('yes'),
|
||||
'ok'
|
||||
)
|
||||
])
|
||||
]);
|
||||
}
|
||||
|
||||
function UserAngelTypes_delete_all_view($angeltype) {
|
||||
return page_with_title(_("Deny all users"), [
|
||||
msg(),
|
||||
info(sprintf(_("Do you really want to deny all users for %s?"), $angeltype['name']), true),
|
||||
buttons([
|
||||
button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _("cancel"), 'cancel'),
|
||||
button(page_link_to('user_angeltypes') . '&action=delete_all&angeltype_id=' . $angeltype['id'] . '&confirmed', _("yes"), 'ok')
|
||||
])
|
||||
]);
|
||||
/**
|
||||
* @param array $angeltype
|
||||
* @return string
|
||||
*/
|
||||
function UserAngelTypes_delete_all_view($angeltype)
|
||||
{
|
||||
return page_with_title(_('Deny all users'), [
|
||||
msg(),
|
||||
info(sprintf(_('Do you really want to deny all users for %s?'), $angeltype['name']), true),
|
||||
buttons([
|
||||
button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _('cancel'), 'cancel'),
|
||||
button(
|
||||
page_link_to('user_angeltypes') . '&action=delete_all&angeltype_id=' . $angeltype['id'] . '&confirmed',
|
||||
_('yes'),
|
||||
'ok'
|
||||
)
|
||||
])
|
||||
]);
|
||||
}
|
||||
|
||||
function UserAngelTypes_confirm_all_view($angeltype) {
|
||||
return page_with_title(_("Confirm all users"), [
|
||||
msg(),
|
||||
info(sprintf(_("Do you really want to confirm all users for %s?"), $angeltype['name']), true),
|
||||
buttons([
|
||||
button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _("cancel"), 'cancel'),
|
||||
button(page_link_to('user_angeltypes') . '&action=confirm_all&angeltype_id=' . $angeltype['id'] . '&confirmed', _("yes"), 'ok')
|
||||
])
|
||||
]);
|
||||
/**
|
||||
* @param array $angeltype
|
||||
* @return string
|
||||
*/
|
||||
function UserAngelTypes_confirm_all_view($angeltype)
|
||||
{
|
||||
return page_with_title(_('Confirm all users'), [
|
||||
msg(),
|
||||
info(sprintf(_('Do you really want to confirm all users for %s?'), $angeltype['name']), true),
|
||||
buttons([
|
||||
button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _('cancel'), 'cancel'),
|
||||
button(
|
||||
page_link_to('user_angeltypes') . '&action=confirm_all&angeltype_id=' . $angeltype['id'] . '&confirmed',
|
||||
_('yes'),
|
||||
'ok'
|
||||
)
|
||||
])
|
||||
]);
|
||||
}
|
||||
|
||||
function UserAngelType_confirm_view($user_angeltype, $user, $angeltype) {
|
||||
return page_with_title(_("Confirm angeltype for user"), [
|
||||
msg(),
|
||||
info(sprintf(_("Do you really want to confirm %s for %s?"), User_Nick_render($user), $angeltype['name']), true),
|
||||
buttons([
|
||||
button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _("cancel"), 'cancel'),
|
||||
button(page_link_to('user_angeltypes') . '&action=confirm&user_angeltype_id=' . $user_angeltype['id'] . '&confirmed', _("yes"), 'ok')
|
||||
])
|
||||
]);
|
||||
/**
|
||||
* @param array $user_angeltype
|
||||
* @param array $user
|
||||
* @param array $angeltype
|
||||
* @return string
|
||||
*/
|
||||
function UserAngelType_confirm_view($user_angeltype, $user, $angeltype)
|
||||
{
|
||||
return page_with_title(_('Confirm angeltype for user'), [
|
||||
msg(),
|
||||
info(sprintf(_('Do you really want to confirm %s for %s?'), User_Nick_render($user), $angeltype['name']), true),
|
||||
buttons([
|
||||
button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _('cancel'), 'cancel'),
|
||||
button(
|
||||
page_link_to('user_angeltypes') . '&action=confirm&user_angeltype_id=' . $user_angeltype['id'] . '&confirmed',
|
||||
_('yes'),
|
||||
'ok'
|
||||
)
|
||||
])
|
||||
]);
|
||||
}
|
||||
|
||||
function UserAngelType_delete_view($user_angeltype, $user, $angeltype) {
|
||||
return page_with_title(_("Remove angeltype"), [
|
||||
msg(),
|
||||
info(sprintf(_("Do you really want to delete %s from %s?"), User_Nick_render($user), $angeltype['name']), true),
|
||||
buttons([
|
||||
button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _("cancel"), 'cancel'),
|
||||
button(page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $user_angeltype['id'] . '&confirmed', _("yes"), 'ok')
|
||||
])
|
||||
]);
|
||||
/**
|
||||
* @param array $user_angeltype
|
||||
* @param array $user
|
||||
* @param array $angeltype
|
||||
* @return string
|
||||
*/
|
||||
function UserAngelType_delete_view($user_angeltype, $user, $angeltype)
|
||||
{
|
||||
return page_with_title(_('Remove angeltype'), [
|
||||
msg(),
|
||||
info(sprintf(_('Do you really want to delete %s from %s?'), User_Nick_render($user), $angeltype['name']), true),
|
||||
buttons([
|
||||
button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _('cancel'), 'cancel'),
|
||||
button(
|
||||
page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $user_angeltype['id'] . '&confirmed',
|
||||
_('yes'),
|
||||
'ok'
|
||||
)
|
||||
])
|
||||
]);
|
||||
}
|
||||
|
||||
function UserAngelType_add_view($angeltype, $users_source, $user_id) {
|
||||
$users = [];
|
||||
foreach ($users_source as $user_source) {
|
||||
$users[$user_source['UID']] = User_Nick_render($user_source);
|
||||
}
|
||||
|
||||
return page_with_title(_("Add user to angeltype"), [
|
||||
msg(),
|
||||
buttons([
|
||||
button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _("back"), 'back')
|
||||
]),
|
||||
form([
|
||||
form_info(_("Angeltype"), $angeltype['name']),
|
||||
form_select('user_id', _("User"), $users, $user_id),
|
||||
form_submit('submit', _("Add"))
|
||||
])
|
||||
]);
|
||||
}
|
||||
/**
|
||||
* @param array $angeltype
|
||||
* @param array[] $users_source
|
||||
* @param int $user_id
|
||||
* @return string
|
||||
*/
|
||||
function UserAngelType_add_view($angeltype, $users_source, $user_id)
|
||||
{
|
||||
$users = [];
|
||||
foreach ($users_source as $user_source) {
|
||||
$users[$user_source['UID']] = User_Nick_render($user_source);
|
||||
}
|
||||
|
||||
function UserAngelType_join_view($user, $angeltype) {
|
||||
return page_with_title(sprintf(_("Become a %s"), $angeltype['name']), [
|
||||
msg(),
|
||||
info(sprintf(_("Do you really want to add %s to %s?"), User_Nick_render($user), $angeltype['name']), true),
|
||||
buttons([
|
||||
button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _("cancel"), 'cancel'),
|
||||
button(page_link_to('user_angeltypes') . '&action=add&angeltype_id=' . $angeltype['id'] . '&user_id=' . $user['UID'] . '&confirmed', _("save"), 'ok')
|
||||
])
|
||||
]);
|
||||
return page_with_title(_('Add user to angeltype'), [
|
||||
msg(),
|
||||
buttons([
|
||||
button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _('back'), 'back')
|
||||
]),
|
||||
form([
|
||||
form_info(_('Angeltype'), $angeltype['name']),
|
||||
form_select('user_id', _('User'), $users, $user_id),
|
||||
form_submit('submit', _('Add'))
|
||||
])
|
||||
]);
|
||||
}
|
||||
|
||||
?>
|
||||
/**
|
||||
* @param array $user
|
||||
* @param array $angeltype
|
||||
* @return string
|
||||
*/
|
||||
function UserAngelType_join_view($user, $angeltype)
|
||||
{
|
||||
return page_with_title(sprintf(_('Become a %s'), $angeltype['name']), [
|
||||
msg(),
|
||||
info(sprintf(_('Do you really want to add %s to %s?'), User_Nick_render($user), $angeltype['name']), true),
|
||||
buttons([
|
||||
button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _('cancel'), 'cancel'),
|
||||
button(
|
||||
page_link_to('user_angeltypes') . '&action=add&angeltype_id=' . $angeltype['id'] . '&user_id=' . $user['UID'] . '&confirmed',
|
||||
_('save'),
|
||||
'ok'
|
||||
)
|
||||
])
|
||||
]);
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,24 +1,24 @@
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.5/phpunit.xsd"
|
||||
backupGlobals="false"
|
||||
bootstrap="./includes/engelsystem_provider.php"
|
||||
colors="true"
|
||||
convertErrorsToExceptions="true"
|
||||
convertNoticesToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
processIsolation="false">
|
||||
<testsuites>
|
||||
<testsuite name="Models">
|
||||
<directory>./test/model/</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<filter>
|
||||
<whitelist>
|
||||
<directory>./include/</directory>
|
||||
<directory>./public/</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
<php>
|
||||
<const name="PHPUNIT_TESTSUITE" value="true" />
|
||||
</php>
|
||||
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.5/phpunit.xsd"
|
||||
backupGlobals="false"
|
||||
bootstrap="./includes/engelsystem_provider.php"
|
||||
colors="true"
|
||||
convertErrorsToExceptions="true"
|
||||
convertNoticesToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
processIsolation="false">
|
||||
<testsuites>
|
||||
<testsuite name="Models">
|
||||
<directory>./test/model/</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<filter>
|
||||
<whitelist>
|
||||
<directory>./include/</directory>
|
||||
<directory>./public/</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
<php>
|
||||
<const name="PHPUNIT_TESTSUITE" value="true"/>
|
||||
</php>
|
||||
</phpunit>
|
||||
|
||||
@ -1,28 +1,28 @@
|
||||
/**
|
||||
* Runs through the DOM under the element with the given id, finds all
|
||||
* checkboxes and sets them to the wanted state.
|
||||
*
|
||||
*
|
||||
* @param String
|
||||
* id Id of the element containing all the checkboxes
|
||||
* @param Boolean
|
||||
* checked True if the checkboxes should be checked
|
||||
*/
|
||||
function checkAll(id, checked) {
|
||||
var obj = document.getElementById(id);
|
||||
var boxes = obj.getElementsByTagName("input");
|
||||
for (var i = 0; i < boxes.length; i++) {
|
||||
if (boxes[i].type === "checkbox" && !boxes[i].disabled) {
|
||||
boxes[i].checked = checked;
|
||||
}
|
||||
}
|
||||
var obj = document.getElementById(id);
|
||||
var boxes = obj.getElementsByTagName("input");
|
||||
for (var i = 0; i < boxes.length; i++) {
|
||||
if (boxes[i].type === "checkbox" && !boxes[i].disabled) {
|
||||
boxes[i].checked = checked;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$(function() {
|
||||
/**
|
||||
* Disable every submit button after clicking (to prevent double-clicking)
|
||||
*/
|
||||
$("form").submit(function(ev) {
|
||||
$("input[type='submit']").prop("readonly", true).addClass("disabled");
|
||||
return true;
|
||||
});
|
||||
$(function () {
|
||||
/**
|
||||
* Disable every submit button after clicking (to prevent double-clicking)
|
||||
*/
|
||||
$("form").submit(function (ev) {
|
||||
$("input[type='submit']").prop("readonly", true).addClass("disabled");
|
||||
return true;
|
||||
});
|
||||
});
|
||||
|
||||
@ -1,32 +1,31 @@
|
||||
/**
|
||||
* Enables the fixed headers and time lane for the shift-calendar and datatables
|
||||
*/
|
||||
$(document).ready(
|
||||
function() {
|
||||
if ($(".shift-calendar").length) {
|
||||
$(document).ready(function () {
|
||||
if ($(".shift-calendar").length) {
|
||||
var timeLanes = $(".shift-calendar .time");
|
||||
var headers = $(".shift-calendar .header");
|
||||
var topReference = $(".container-fluid .row");
|
||||
var top = headers.offset().top;
|
||||
var left = 15;
|
||||
timeLanes.css({
|
||||
"position" : "relative",
|
||||
"z-index" : 999
|
||||
"position": "relative",
|
||||
"z-index": 999
|
||||
});
|
||||
headers.css({
|
||||
"position" : "relative",
|
||||
"z-index" : 900
|
||||
"position": "relative",
|
||||
"z-index": 900
|
||||
});
|
||||
$(window).scroll(
|
||||
function() {
|
||||
timeLanes.css({
|
||||
"left" : Math.max(0, $(window).scrollLeft() - left) + "px"
|
||||
});
|
||||
headers.css({
|
||||
"top" : Math.max(0, $(window).scrollTop() - top
|
||||
+ topReference.offset().top)
|
||||
function () {
|
||||
timeLanes.css({
|
||||
"left": Math.max(0, $(window).scrollLeft() - left) + "px"
|
||||
});
|
||||
headers.css({
|
||||
"top": Math.max(0, $(window).scrollTop() - top
|
||||
+ topReference.offset().top)
|
||||
+ "px"
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@ -1,72 +1,86 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Maintenance - Engelsystem</title>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="stylesheet" type="text/css" href="css/theme0.css" />
|
||||
<link rel="stylesheet" type="text/css" href="vendor/icomoon/style.css" />
|
||||
<link rel="stylesheet" type="text/css" href="vendor/bootstrap-datepicker-1.4.0/css/bootstrap-datepicker3.min.css" />
|
||||
<script type="text/javascript" src="vendor/jquery-2.1.1.min.js"></script>
|
||||
<script type="text/javascript" src="vendor/jquery-ui.min.js"></script>
|
||||
<title>Maintenance - Engelsystem</title>
|
||||
<meta charset="UTF-8"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="stylesheet" type="text/css" href="css/theme0.css"/>
|
||||
<link rel="stylesheet" type="text/css" href="vendor/icomoon/style.css"/>
|
||||
<link rel="stylesheet" type="text/css" href="vendor/bootstrap-datepicker-1.4.0/css/bootstrap-datepicker3.min.css"/>
|
||||
<script type="text/javascript" src="vendor/jquery-2.1.1.min.js"></script>
|
||||
<script type="text/javascript" src="vendor/jquery-ui.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="container-fluid">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar-collapse-1">
|
||||
<span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span>
|
||||
</button>
|
||||
<a class="navbar-brand" href="?"><span class="icon-icon_angel"></span> <strong class="visible-lg-inline">ENGELSYSTEM</strong></a>
|
||||
</div>
|
||||
<div class="collapse navbar-collapse" id="navbar-collapse-1">
|
||||
<ul class="nav navbar-nav"></ul>
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
</ul>
|
||||
</div>
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle collapsed"
|
||||
data-toggle="collapse" data-target="#navbar-collapse-1">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<a class="navbar-brand" href="?">
|
||||
<span class="icon-icon_angel"></span> <strong class="visible-lg-inline">ENGELSYSTEM</strong>
|
||||
</a>
|
||||
</div>
|
||||
<div class="collapse navbar-collapse" id="navbar-collapse-1">
|
||||
<ul class="nav navbar-nav"></ul>
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container-fluid">
|
||||
</div>
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="jumbotron">
|
||||
<div class="container text-center">
|
||||
<h1>
|
||||
<span class="glyphicon glyphicon-scissors"></span> <span class="glyphicon glyphicon-wrench"></span> <span class="glyphicon glyphicon-fire"></span>
|
||||
</h1>
|
||||
<div class="col-md-6">
|
||||
<h2>
|
||||
The <span class="icon-icon_angel"></span> <strong>ENGELSYSTEM</strong> is in maintenance mode.
|
||||
</h2>
|
||||
<p>This may be due to...</p>
|
||||
<p>
|
||||
...archangels closing the gates of heaven. <br>...somebody's stolen the power chord and now the battery is empty. <br>...DHCP decided to give me another ip address.
|
||||
</p>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<iframe width="560" height="315" src="https://www.youtube.com/embed/0aV_vHcunSQ?rel=0" frameborder="0" allowfullscreen></iframe>
|
||||
</div>
|
||||
<div class="jumbotron">
|
||||
<div class="container text-center">
|
||||
<h1>
|
||||
<span class="glyphicon glyphicon-scissors"></span>
|
||||
<span class="glyphicon glyphicon-wrench"></span>
|
||||
<span class="glyphicon glyphicon-fire"></span>
|
||||
</h1>
|
||||
<div class="col-md-6">
|
||||
<h2>
|
||||
The <span class="icon-icon_angel"></span> <strong>ENGELSYSTEM</strong> is in maintenance mode.
|
||||
</h2>
|
||||
<p>This may be due to...</p>
|
||||
<p>
|
||||
...archangels closing the gates of heaven. <br>
|
||||
...somebody's stolen the power chord and now the battery is empty. <br>
|
||||
...DHCP decided to give me another ip address.
|
||||
</p>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<iframe width="560" height="315"
|
||||
src="https://www.youtube.com/embed/0aV_vHcunSQ?rel=0"
|
||||
frameborder="0" allowfullscreen>
|
||||
</iframe>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="text-center footer">
|
||||
<a href="https://github.com/engelsystem/engelsystem/issues">Bugs / Features</a> · <a href="https://github.com/engelsystem/engelsystem/">Development Platform</a>
|
||||
<div class="col-md-12">
|
||||
<div class="text-center footer">
|
||||
<a href="https://github.com/engelsystem/engelsystem/issues">Bugs / Features</a>
|
||||
· <a href="https://github.com/engelsystem/engelsystem/">Development Platform</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript" src="vendor/bootstrap/js/bootstrap.min.js"></script>
|
||||
<script type="text/javascript" src="vendor/bootstrap-datepicker-1.4.0/js/bootstrap-datepicker.min.js"></script>
|
||||
<script type="text/javascript" src="vendor/bootstrap-datepicker-1.4.0/locales/bootstrap-datepicker.de.min.js"></script>
|
||||
<script type="text/javascript" src="vendor/Chart.min.js"></script>
|
||||
<script type="text/javascript" src="js/forms.js"></script>
|
||||
<script type="text/javascript" src="vendor/moment-with-locales.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
$(function() {
|
||||
moment.locale("en_US.UTF-8");
|
||||
});
|
||||
</script>
|
||||
<script type="text/javascript" src="js/moment-countdown.js"></script>
|
||||
</div>
|
||||
<script type="text/javascript" src="vendor/bootstrap/js/bootstrap.min.js"></script>
|
||||
<script type="text/javascript" src="vendor/bootstrap-datepicker-1.4.0/js/bootstrap-datepicker.min.js"></script>
|
||||
<script type="text/javascript" src="vendor/bootstrap-datepicker-1.4.0/locales/bootstrap-datepicker.de.min.js"></script>
|
||||
<script type="text/javascript" src="vendor/Chart.min.js"></script>
|
||||
<script type="text/javascript" src="js/forms.js"></script>
|
||||
<script type="text/javascript" src="vendor/moment-with-locales.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
moment.locale("en_US.UTF-8");
|
||||
});
|
||||
</script>
|
||||
<script type="text/javascript" src="js/moment-countdown.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@ -1,57 +1,77 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Engelsystem</title>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="stylesheet" type="text/css" href="css/theme0.css" />
|
||||
<link rel="stylesheet" type="text/css" href="vendor/icomoon/style.css" />
|
||||
<link rel="stylesheet" type="text/css" href="vendor/bootstrap-datepicker-1.4.0/css/bootstrap-datepicker3.min.css" />
|
||||
<script type="text/javascript" src="vendor/jquery-2.1.1.min.js"></script>
|
||||
<script type="text/javascript" src="vendor/jquery-ui.min.js"></script>
|
||||
<title>Engelsystem</title>
|
||||
<meta charset="UTF-8"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="stylesheet" type="text/css" href="css/theme0.css"/>
|
||||
<link rel="stylesheet" type="text/css" href="vendor/icomoon/style.css"/>
|
||||
<link rel="stylesheet" type="text/css" href="vendor/bootstrap-datepicker-1.4.0/css/bootstrap-datepicker3.min.css"/>
|
||||
<script type="text/javascript" src="vendor/jquery-2.1.1.min.js"></script>
|
||||
<script type="text/javascript" src="vendor/jquery-ui.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="container-fluid">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar-collapse-1">
|
||||
<span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span>
|
||||
</button>
|
||||
<a class="navbar-brand" href="https://engelsystem.de"><span class="icon-icon_angel"></span> <strong class="visible-lg-inline">ENGELSYSTEM</strong></a>
|
||||
</div>
|
||||
<div class="collapse navbar-collapse" id="navbar-collapse-1">
|
||||
<ul class="nav navbar-nav"></ul>
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
</ul>
|
||||
</div>
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle collapsed"
|
||||
data-toggle="collapse" data-target="#navbar-collapse-1">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<a class="navbar-brand" href="https://engelsystem.de"><span class="icon-icon_angel"></span> <strong
|
||||
class="visible-lg-inline">ENGELSYSTEM</strong></a>
|
||||
</div>
|
||||
<div class="collapse navbar-collapse" id="navbar-collapse-1">
|
||||
<ul class="nav navbar-nav"></ul>
|
||||
<ul class="nav navbar-nav navbar-right"></ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container-fluid">
|
||||
</div>
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="jumbotron">
|
||||
<div class="container text-center">
|
||||
<div class="col-md-6 col-md-offset-3">
|
||||
<h2>Dear Angels,</h2>
|
||||
<p>The great interest in becoming an angel and participating at 33C3 is is something we are grateful for every time. There is a record number of angels and helping volunteers this year.</p>
|
||||
<p>We did anticipate a great number but we are overwhelmed by this endless wave of support. We do want to enable each and every one of you to be an angel at the congress, but sadly our resources and capacities at Heaven are limited. The amount of angels at this point is beyond our
|
||||
planing and to ensure we can support the angels already checked in. We did make a choice never thought possible on a chaos event:</p>
|
||||
<p>We closed the registration in the Engelsystem and at Heaven Desk at 19:00 27. Dec. 2016.</p>
|
||||
<p>Everyone of us works for you to support you in being an angel, but the Heaven Desk and the Kitchen among others are limited and so we decided to focus our effort to support those of you already arrived to the best of our abilities.</p>
|
||||
<p>
|
||||
For the Heaven Team<br /> Agnes, Jen, LLF and Knuth
|
||||
</p>
|
||||
</div>
|
||||
<div class="jumbotron">
|
||||
<div class="container text-center">
|
||||
<div class="col-md-6 col-md-offset-3">
|
||||
<h2>Dear Angels,</h2>
|
||||
<p>
|
||||
The great interest in becoming an angel and participating at 33C3 is is something we are
|
||||
grateful for every time. There is a record number of angels and helping volunteers this year.
|
||||
</p>
|
||||
<p>
|
||||
We did anticipate a great number but we are overwhelmed by this endless wave of support. We do
|
||||
want to enable each and every one of you to be an angel at the congress, but sadly our resources
|
||||
and capacities at Heaven are limited. The amount of angels at this point is beyond our
|
||||
planing and to ensure we can support the angels already checked in. We did make a choice never
|
||||
thought possible on a chaos event:
|
||||
</p>
|
||||
<p>
|
||||
We closed the registration in the Engelsystem and at Heaven Desk at 19:00 27. Dec. 2016.
|
||||
</p>
|
||||
<p>
|
||||
Everyone of us works for you to support you in being an angel, but the Heaven Desk and the
|
||||
Kitchen among others are limited and so we decided to focus our effort to support those of you
|
||||
already arrived to the best of our abilities.
|
||||
</p>
|
||||
<p>
|
||||
For the Heaven Team<br/>
|
||||
Agnes, Jen, LLF and Knuth
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="text-center footer">
|
||||
<a href="https://github.com/engelsystem/engelsystem/issues">Bugs / Features</a> · <a href="https://github.com/engelsystem/engelsystem/">Development Platform</a>
|
||||
<div class="col-md-12">
|
||||
<div class="text-center footer">
|
||||
<a href="https://github.com/engelsystem/engelsystem/issues">Bugs / Features</a>
|
||||
· <a href="https://github.com/engelsystem/engelsystem/">Development Platform</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript" src="vendor/bootstrap/js/bootstrap.min.js"></script>
|
||||
</div>
|
||||
<script type="text/javascript" src="vendor/bootstrap/js/bootstrap.min.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@ -1 +1 @@
|
||||
../../themes/assets/bootstrap/dist
|
||||
../../vendor/twbs/bootstrap/dist
|
||||
@ -0,0 +1,128 @@
|
||||
<?php
|
||||
|
||||
namespace Engelsystem\Config;
|
||||
|
||||
use ErrorException;
|
||||
|
||||
class Config
|
||||
{
|
||||
/**
|
||||
* @var self
|
||||
*/
|
||||
protected static $instance;
|
||||
|
||||
/**
|
||||
* The config values
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $data = [];
|
||||
|
||||
/**
|
||||
* @param string|null $key
|
||||
* @param mixed $default
|
||||
* @return mixed
|
||||
*/
|
||||
public function get($key, $default = null)
|
||||
{
|
||||
if (is_null($key)) {
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
if ($this->has($key)) {
|
||||
return $this->data[$key];
|
||||
}
|
||||
|
||||
return $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|array $key
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function set($key, $value = null)
|
||||
{
|
||||
if (is_array($key)) {
|
||||
foreach ($key as $configKey => $configValue) {
|
||||
$this->set($configKey, $configValue);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->data[$key] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $key
|
||||
* @return bool
|
||||
*/
|
||||
public function has($key)
|
||||
{
|
||||
return isset($this->data[$key]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $key
|
||||
*/
|
||||
public function remove($key)
|
||||
{
|
||||
unset($this->data[$key]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $key
|
||||
* @return mixed
|
||||
*/
|
||||
public function __get($key)
|
||||
{
|
||||
return $this->get($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function __set($key, $value)
|
||||
{
|
||||
$this->set($key, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $key
|
||||
* @return bool
|
||||
*/
|
||||
public function __isset($key)
|
||||
{
|
||||
return $this->has($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $key
|
||||
*/
|
||||
public function __unset($key)
|
||||
{
|
||||
$this->remove($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Config
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public static function getInstance()
|
||||
{
|
||||
if (!self::$instance instanceof self) {
|
||||
throw new ErrorException('Config not initialized');
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param self $instance
|
||||
*/
|
||||
public static function setInstance($instance)
|
||||
{
|
||||
self::$instance = $instance;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,170 @@
|
||||
<?php
|
||||
|
||||
namespace Engelsystem\Database;
|
||||
|
||||
use PDO;
|
||||
use PDOException;
|
||||
use PDOStatement;
|
||||
|
||||
class Db
|
||||
{
|
||||
/** @var PDO */
|
||||
protected static $db;
|
||||
|
||||
/** @var PDOStatement */
|
||||
protected static $stm = null;
|
||||
|
||||
/** @var bool */
|
||||
protected static $lastStatus = true;
|
||||
|
||||
/**
|
||||
* Connect to database
|
||||
*
|
||||
* @param string $dsn
|
||||
* @param string $username
|
||||
* @param string $password
|
||||
* @param array $options
|
||||
* @return bool
|
||||
*/
|
||||
public static function connect($dsn, $username = null, $password = null, $options = [])
|
||||
{
|
||||
try {
|
||||
self::$db = new PDO($dsn, $username, $password, $options);
|
||||
} catch (PDOException $e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run a prepared query
|
||||
*
|
||||
* @param string $query
|
||||
* @param array $bindings
|
||||
* @return PDOStatement
|
||||
*/
|
||||
public static function query($query, array $bindings = [])
|
||||
{
|
||||
self::$stm = self::$db->prepare($query);
|
||||
self::$lastStatus = self::$stm->execute($bindings);
|
||||
|
||||
return self::$stm;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run a sql query
|
||||
*
|
||||
* @param string $query
|
||||
* @return bool
|
||||
*/
|
||||
public static function unprepared($query)
|
||||
{
|
||||
self::$stm = self::$db->query($query);
|
||||
self::$lastStatus = (self::$stm instanceof PDOStatement);
|
||||
|
||||
return self::$lastStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run a select query
|
||||
*
|
||||
* @param string $query
|
||||
* @param array $bindings
|
||||
* @return array
|
||||
*/
|
||||
public static function select($query, array $bindings = [])
|
||||
{
|
||||
self::query($query, $bindings);
|
||||
|
||||
return self::$stm->fetchAll(PDO::FETCH_ASSOC);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run a insert query
|
||||
*
|
||||
* @param string $query
|
||||
* @param array $bindings
|
||||
* @return bool
|
||||
*/
|
||||
public static function insert($query, array $bindings = [])
|
||||
{
|
||||
self::query($query, $bindings);
|
||||
|
||||
return self::$lastStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run a update query
|
||||
*
|
||||
* @param string $query
|
||||
* @param array $bindings
|
||||
* @return int|null
|
||||
*/
|
||||
public static function update($query, array $bindings = [])
|
||||
{
|
||||
self::query($query, $bindings);
|
||||
|
||||
return (self::$lastStatus ? self::$stm->rowCount() : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run a delete query
|
||||
*
|
||||
* @param string $query
|
||||
* @param array $bindings
|
||||
* @return int|null
|
||||
*/
|
||||
public static function delete($query, array $bindings = [])
|
||||
{
|
||||
self::query($query, $bindings);
|
||||
|
||||
return (self::$lastStatus ? self::$stm->rowCount() : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run a single statement
|
||||
*
|
||||
* @param string $query
|
||||
* @param array $bindings
|
||||
* @return bool
|
||||
*/
|
||||
public static function statement($query, array $bindings = [])
|
||||
{
|
||||
self::query($query, $bindings);
|
||||
|
||||
return self::$lastStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the last error
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getError()
|
||||
{
|
||||
if (!self::$stm instanceof PDOStatement) {
|
||||
return [-1, null, null];
|
||||
}
|
||||
|
||||
return self::$stm->errorInfo();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the PDO instance
|
||||
*
|
||||
* @return PDO
|
||||
*/
|
||||
public static function getPdo()
|
||||
{
|
||||
return self::$db;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PDOStatement|false|null
|
||||
*/
|
||||
public static function getStm()
|
||||
{
|
||||
return self::$stm;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
namespace Engelsystem\Exceptions;
|
||||
|
||||
use Exception;
|
||||
|
||||
class Handler
|
||||
{
|
||||
/** @var string */
|
||||
protected $environment;
|
||||
|
||||
const ENV_PRODUCTION = 'prod';
|
||||
const ENV_DEVELOPMENT = 'dev';
|
||||
|
||||
/**
|
||||
* Handler constructor.
|
||||
*
|
||||
* @param string $environment production|development
|
||||
*/
|
||||
public function __construct($environment = self::ENV_PRODUCTION)
|
||||
{
|
||||
$this->environment = $environment;
|
||||
|
||||
set_error_handler([$this, 'errorHandler']);
|
||||
set_exception_handler([$this, 'exceptionHandler']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $number
|
||||
* @param string $string
|
||||
* @param string $file
|
||||
* @param int $line
|
||||
* @param array $context
|
||||
*/
|
||||
public function errorHandler($number, $string, $file, $line, $context)
|
||||
{
|
||||
$this->handle('error', $number, $string, $file, $line, $context);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Exception $e
|
||||
*/
|
||||
public function exceptionHandler(Exception $e)
|
||||
{
|
||||
$this->handle(
|
||||
'exception',
|
||||
$e->getCode(),
|
||||
get_class($e) . ': ' . $e->getMessage(),
|
||||
$e->getFile(),
|
||||
$e->getLine(),
|
||||
['exception' => $e]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $type
|
||||
* @param int $number
|
||||
* @param string $string
|
||||
* @param string $file
|
||||
* @param int $line
|
||||
* @param array $context
|
||||
*/
|
||||
protected function handle($type, $number, $string, $file, $line, $context = [])
|
||||
{
|
||||
error_log(sprintf('%s: Number: %s, String: %s, File: %s:%u, Context: %s',
|
||||
$type,
|
||||
$number,
|
||||
$string,
|
||||
$file,
|
||||
$line,
|
||||
json_encode($context)
|
||||
));
|
||||
|
||||
if ($this->environment == self::ENV_DEVELOPMENT) {
|
||||
echo '<pre style="background-color:#333;color:#ccc;z-index:1000;position:fixed;bottom:1em;padding:1em;width:97%;overflow-y:auto;">';
|
||||
echo sprintf('%s: (%s)' . PHP_EOL, ucfirst($type), $number);
|
||||
var_export([
|
||||
'string' => $string,
|
||||
'file' => $file . ':' . $line,
|
||||
'context' => ($this->environment == self::ENV_DEVELOPMENT ? $context : null),
|
||||
]);
|
||||
echo '</pre>';
|
||||
die();
|
||||
}
|
||||
|
||||
echo 'An <del>un</del>expected error occurred, a team of untrained monkeys has been dispatched to deal with it.';
|
||||
die();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $environment
|
||||
*/
|
||||
public function setEnvironment($environment)
|
||||
{
|
||||
$this->environment = $environment;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
// Some useful functions
|
||||
|
||||
use Engelsystem\Config\Config;
|
||||
|
||||
/**
|
||||
* Get or set config values
|
||||
*
|
||||
* @param string|array $key
|
||||
* @param mixed $default
|
||||
* @return mixed|Config
|
||||
*/
|
||||
function config($key = null, $default = null)
|
||||
{
|
||||
if (empty($key)) {
|
||||
return Config::getInstance();
|
||||
}
|
||||
|
||||
if (is_array($key)) {
|
||||
Config::getInstance()->set($key);
|
||||
}
|
||||
|
||||
return Config::getInstance()->get($key, $default);
|
||||
}
|
||||
@ -1,27 +1,35 @@
|
||||
<div class="container">
|
||||
<h1>Credits</h1>
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<h2>Source code</h2>
|
||||
<p>
|
||||
The original system was written by <a href="https://github.com/cookieBerlin/engelsystem">cookie</a>. It was then completely rewritten and greatly enhanced by <a href="http://notrademark.de/">msquare</a> and <a href="http://mortzu.de/">mortzu</a> of <a href="http://planetcyborg.de">planet
|
||||
cyborg</a>, <a href="http://jplitza.de/">jplitza</a> and gnomus.
|
||||
</p>
|
||||
<p>
|
||||
Please look at the <a href="https://github.com/engelsystem/engelsystem/graphs/contributors">contributor list on github</a> for a more complete version.
|
||||
</p>
|
||||
<h1>Credits</h1>
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<h2>Source code</h2>
|
||||
<p>
|
||||
The original system was written by <a href="https://github.com/cookieBerlin/engelsystem">cookie</a>.
|
||||
It was then completely rewritten and greatly enhanced by <a href="http://notrademark.de/">msquare</a>
|
||||
and <a href="http://myigel.name/">MyIgel</a>,
|
||||
<a href="http://mortzu.de/">mortzu</a> of <a href="http://planetcyborg.de">planet cyborg</a>,
|
||||
<a href="http://jplitza.de/">jplitza</a> and gnomus.
|
||||
</p>
|
||||
<p>
|
||||
Please look at the <a href="https://github.com/engelsystem/engelsystem/graphs/contributors">contributor
|
||||
list on github</a> for a more complete version.
|
||||
</p>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<h2>Hosting</h2>
|
||||
<p>
|
||||
Webspace, development platform and domain is currently provided by
|
||||
<a href="https://www.wybt.net/">would you buy this?</a> (ichdasich)<br/>
|
||||
and adminstrated by <a href="http://mortzu.de/">mortzu</a>,
|
||||
<a href="http://derf.homelinux.org/">derf</a>
|
||||
and ichdasich.
|
||||
</p>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<h2>Translation</h2>
|
||||
<p>
|
||||
Many thanks for the german translation: <a href="http://e7p.de">e7p</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<h2>Hosting</h2>
|
||||
<p>
|
||||
Webspace, development platform and domain is currently provided by <a href="https://www.wybt.net/">would you buy this?</a> (ichdasich)<br /> and adminstrated by <a href="http://mortzu.de/">mortzu</a>, <a href="http://derf.homelinux.org/">derf</a> and ichdasich.
|
||||
</p>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<h2>Translation</h2>
|
||||
<p>
|
||||
Many thanks for the german translation: <a href="http://e7p.de">e7p</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -1,53 +1,60 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>%title% - Engelsystem</title>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="stylesheet" type="text/css" href="css/theme%theme%.css" />
|
||||
<link rel="stylesheet" type="text/css" href="vendor/icomoon/style.css" />
|
||||
<link rel="stylesheet" type="text/css" href="vendor/bootstrap-datepicker-1.4.0/css/bootstrap-datepicker3.min.css" />
|
||||
<script type="text/javascript" src="vendor/jquery-2.1.1.min.js"></script>
|
||||
<script type="text/javascript" src="vendor/jquery-ui.min.js"></script>
|
||||
%atom_link%
|
||||
<title>%title% - Engelsystem</title>
|
||||
<meta charset="UTF-8"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="stylesheet" type="text/css" href="css/theme%theme%.css"/>
|
||||
<link rel="stylesheet" type="text/css" href="vendor/icomoon/style.css"/>
|
||||
<link rel="stylesheet" type="text/css" href="vendor/bootstrap-datepicker-1.4.0/css/bootstrap-datepicker3.min.css"/>
|
||||
<script type="text/javascript" src="vendor/jquery-2.1.1.min.js"></script>
|
||||
<script type="text/javascript" src="vendor/jquery-ui.min.js"></script>
|
||||
%atom_link%
|
||||
</head>
|
||||
<body>
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="container-fluid">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar-collapse-1">
|
||||
<span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span>
|
||||
</button>
|
||||
<a class="navbar-brand" href="?"><span class="icon-icon_angel"></span> <strong class="visible-lg-inline">ENGELSYSTEM</strong></a>
|
||||
</div>
|
||||
<div class="collapse navbar-collapse" id="navbar-collapse-1">%menu% %header_toolbar%</div>
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle collapsed"
|
||||
data-toggle="collapse" data-target="#navbar-collapse-1">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<a class="navbar-brand" href="?"><span class="icon-icon_angel"></span> <strong class="visible-lg-inline">ENGELSYSTEM</strong></a>
|
||||
</div>
|
||||
<div class="collapse navbar-collapse" id="navbar-collapse-1">%menu% %header_toolbar%</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container-fluid">
|
||||
</div>
|
||||
<div class="container-fluid">
|
||||
<div class="row">%content%</div>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<hr />
|
||||
<div class="text-center footer" style="margin-bottom: 10px;">
|
||||
%event_info%
|
||||
<a href="%faq_url%">FAQ</a> · <a href="%contact_email%"><span class="glyphicon glyphicon-envelope"></span> Contact</a> · <a href="https://github.com/engelsystem/engelsystem/issues">Bugs / Features</a> · <a href="https://github.com/engelsystem/engelsystem/">Development
|
||||
Platform</a> · <a href="?p=credits">Credits</a>
|
||||
<div class="col-md-12">
|
||||
<hr/>
|
||||
<div class="text-center footer" style="margin-bottom: 10px;">
|
||||
%event_info%
|
||||
<a href="%faq_url%">FAQ</a>
|
||||
· <a href="%contact_email%"><span class="glyphicon glyphicon-envelope"></span> Contact</a>
|
||||
· <a href="https://github.com/engelsystem/engelsystem/issues">Bugs / Features</a>
|
||||
· <a href="https://github.com/engelsystem/engelsystem/">Development Platform</a>
|
||||
· <a href="?p=credits">Credits</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript" src="vendor/bootstrap/js/bootstrap.min.js"></script>
|
||||
<script type="text/javascript" src="vendor/bootstrap-datepicker-1.4.0/js/bootstrap-datepicker.min.js"></script>
|
||||
<script type="text/javascript" src="vendor/bootstrap-datepicker-1.4.0/locales/bootstrap-datepicker.de.min.js"></script>
|
||||
<script type="text/javascript" src="vendor/Chart.min.js"></script>
|
||||
<script type="text/javascript" src="js/forms.js"></script>
|
||||
<script type="text/javascript" src="vendor/moment-with-locales.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
$(function() {
|
||||
moment.locale("%locale%");
|
||||
});
|
||||
</script>
|
||||
<script type="text/javascript" src="js/moment-countdown.js"></script>
|
||||
<script type="text/javascript" src="js/sticky-headers.js"></script>
|
||||
</div>
|
||||
<script type="text/javascript" src="vendor/bootstrap/js/bootstrap.min.js"></script>
|
||||
<script type="text/javascript" src="vendor/bootstrap-datepicker-1.4.0/js/bootstrap-datepicker.min.js"></script>
|
||||
<script type="text/javascript" src="vendor/bootstrap-datepicker-1.4.0/locales/bootstrap-datepicker.de.min.js"></script>
|
||||
<script type="text/javascript" src="vendor/Chart.min.js"></script>
|
||||
<script type="text/javascript" src="js/forms.js"></script>
|
||||
<script type="text/javascript" src="vendor/moment-with-locales.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
moment.locale("%locale%");
|
||||
});
|
||||
</script>
|
||||
<script type="text/javascript" src="js/moment-countdown.js"></script>
|
||||
<script type="text/javascript" src="js/sticky-headers.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@ -1,52 +1,54 @@
|
||||
<script type="text/javascript">
|
||||
function set_to_now(id) {
|
||||
document.getElementById(id + '_time').value = moment().format('HH:mm');
|
||||
var days = document.getElementById(id + '_day').getElementsByTagName(
|
||||
'option');
|
||||
for ( var i = 0; i < days.length; i++) {
|
||||
if (days[i].value == moment().format('YYYY-MM-DD'))
|
||||
days[i].selected = true;
|
||||
}
|
||||
}
|
||||
function set_to_now(id) {
|
||||
document.getElementById(id + '_time').value = moment().format('HH:mm');
|
||||
var days = document.getElementById(id + '_day').getElementsByTagName(
|
||||
'option');
|
||||
for (var i = 0; i < days.length; i++) {
|
||||
if (days[i].value == moment().format('YYYY-MM-DD'))
|
||||
days[i].selected = true;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<form class="form-inline" action="" method="get">
|
||||
<input type="hidden" name="p" value="user_shifts">
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<h1>%title%</h1>
|
||||
<div class="form-group">%start_select%</div>
|
||||
<div class="form-group">
|
||||
<div class="input-group">
|
||||
<input class="form-control" type="text" id="start_time" name="start_time" size="5" pattern="^\d{1,2}:\d{2}$" placeholder="HH:MM" maxlength="5" value="%start_time%">
|
||||
<div class="input-group-btn">
|
||||
<button class="btn btn-default" title="Now" type="button" onclick="set_to_now('start');">
|
||||
<span class="glyphicon glyphicon-time"></span>
|
||||
</button>
|
||||
</div>
|
||||
<input type="hidden" name="p" value="user_shifts">
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<h1>%title%</h1>
|
||||
<div class="form-group">%start_select%</div>
|
||||
<div class="form-group">
|
||||
<div class="input-group">
|
||||
<input class="form-control" type="text" id="start_time" name="start_time" size="5"
|
||||
pattern="^\d{1,2}:\d{2}$" placeholder="HH:MM" maxlength="5" value="%start_time%">
|
||||
<div class="input-group-btn">
|
||||
<button class="btn btn-default" title="Now" type="button" onclick="set_to_now('start');">
|
||||
<span class="glyphicon glyphicon-time"></span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
–
|
||||
<div class="form-group">%end_select%</div>
|
||||
<div class="form-group">
|
||||
<div class="input-group">
|
||||
<input class="form-control" type="text" id="end_time" name="end_time" size="5"
|
||||
pattern="^\d{1,2}:\d{2}$" placeholder="HH:MM" maxlength="5" value="%end_time%">
|
||||
<div class="input-group-btn">
|
||||
<button class="btn btn-default" title="Now" type="button" onclick="set_to_now('end');">
|
||||
<span class="glyphicon glyphicon-time"></span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
–
|
||||
<div class="form-group">%end_select%</div>
|
||||
<div class="form-group">
|
||||
<div class="input-group">
|
||||
<input class="form-control" type="text" id="end_time" name="end_time" size="5" pattern="^\d{1,2}:\d{2}$" placeholder="HH:MM" maxlength="5" value="%end_time%">
|
||||
<div class="input-group-btn">
|
||||
<button class="btn btn-default" title="Now" type="button" onclick="set_to_now('end');">
|
||||
<span class="glyphicon glyphicon-time"></span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="col-md-2">%room_select%</div>
|
||||
<div class="col-md-2">%type_select%</div>
|
||||
<div class="col-md-2">%filled_select%</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div>%task_notice%</div>
|
||||
<input class="btn btn-primary" type="submit" style="width: 75%; margin-bottom: 20px" value="%filter%">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-2">%room_select%</div>
|
||||
<div class="col-md-2">%type_select%</div>
|
||||
<div class="col-md-2">%filled_select%</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div>%task_notice%</div>
|
||||
<input class="btn btn-primary" type="submit" style="width: 75%; margin-bottom: 20px" value="%filter%">
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
%shifts_table% %ical_text%
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue