Formatting
This commit is contained in:
parent
7313e15ce8
commit
d71e7bbfad
|
@ -49,7 +49,7 @@ $shift_sum_formula = "SUM(
|
||||||
|
|
||||||
// voucher calculation
|
// voucher calculation
|
||||||
$voucher_settings = [
|
$voucher_settings = [
|
||||||
"initial_vouchers" => 2,
|
"initial_vouchers" => 2,
|
||||||
"shifts_per_voucher" => 1
|
"shifts_per_voucher" => 1
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -63,6 +63,6 @@ $api_key = "";
|
||||||
$config = [
|
$config = [
|
||||||
'host' => "localhost",
|
'host' => "localhost",
|
||||||
'user' => "root",
|
'user' => "root",
|
||||||
'pw' => "",
|
'pw' => "",
|
||||||
'db' => "engelsystem"
|
'db' => "engelsystem"
|
||||||
];
|
];
|
||||||
|
|
|
@ -14,20 +14,20 @@ function angeltypes_title()
|
||||||
function angeltypes_controller()
|
function angeltypes_controller()
|
||||||
{
|
{
|
||||||
$action = strip_request_item('action', 'list');
|
$action = strip_request_item('action', 'list');
|
||||||
|
|
||||||
switch ($action) {
|
switch ($action) {
|
||||||
default:
|
default:
|
||||||
case 'list':
|
case 'list':
|
||||||
return angeltypes_list_controller();
|
return angeltypes_list_controller();
|
||||||
case 'view':
|
case 'view':
|
||||||
return angeltype_controller();
|
return angeltype_controller();
|
||||||
case 'edit':
|
case 'edit':
|
||||||
return angeltype_edit_controller();
|
return angeltype_edit_controller();
|
||||||
case 'delete':
|
case 'delete':
|
||||||
return angeltype_delete_controller();
|
return angeltype_delete_controller();
|
||||||
case 'about':
|
case 'about':
|
||||||
return angeltypes_about_controller();
|
return angeltypes_about_controller();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -46,17 +46,17 @@ function angeltype_link($angeltype_id)
|
||||||
function angeltypes_about_controller()
|
function angeltypes_about_controller()
|
||||||
{
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
if (isset($user)) {
|
if (isset($user)) {
|
||||||
$angeltypes = AngelTypes_with_user($user);
|
$angeltypes = AngelTypes_with_user($user);
|
||||||
} else {
|
} else {
|
||||||
$angeltypes = AngelTypes();
|
$angeltypes = AngelTypes();
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
_("Teams/Job description"),
|
_("Teams/Job description"),
|
||||||
AngelTypes_about_view($angeltypes, isset($user))
|
AngelTypes_about_view($angeltypes, isset($user))
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -65,23 +65,23 @@ function angeltypes_about_controller()
|
||||||
function angeltype_delete_controller()
|
function angeltype_delete_controller()
|
||||||
{
|
{
|
||||||
global $privileges;
|
global $privileges;
|
||||||
|
|
||||||
if (! in_array('admin_angel_types', $privileges)) {
|
if (!in_array('admin_angel_types', $privileges)) {
|
||||||
redirect(page_link_to('angeltypes'));
|
redirect(page_link_to('angeltypes'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$angeltype = load_angeltype();
|
$angeltype = load_angeltype();
|
||||||
|
|
||||||
if (isset($_REQUEST['confirmed'])) {
|
if (isset($_REQUEST['confirmed'])) {
|
||||||
AngelType_delete($angeltype);
|
AngelType_delete($angeltype);
|
||||||
success(sprintf(_("Angeltype %s deleted."), AngelType_name_render($angeltype)));
|
success(sprintf(_("Angeltype %s deleted."), AngelType_name_render($angeltype)));
|
||||||
redirect(page_link_to('angeltypes'));
|
redirect(page_link_to('angeltypes'));
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
sprintf(_("Delete angeltype %s"), $angeltype['name']),
|
sprintf(_("Delete angeltype %s"), $angeltype['name']),
|
||||||
AngelType_delete_view($angeltype)
|
AngelType_delete_view($angeltype)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -90,63 +90,63 @@ function angeltype_delete_controller()
|
||||||
function angeltype_edit_controller()
|
function angeltype_edit_controller()
|
||||||
{
|
{
|
||||||
global $privileges, $user;
|
global $privileges, $user;
|
||||||
|
|
||||||
// In supporter mode only allow to modify description
|
// In supporter mode only allow to modify description
|
||||||
$supporter_mode = ! in_array('admin_angel_types', $privileges);
|
$supporter_mode = !in_array('admin_angel_types', $privileges);
|
||||||
|
|
||||||
if (isset($_REQUEST['angeltype_id'])) {
|
if (isset($_REQUEST['angeltype_id'])) {
|
||||||
// Edit existing angeltype
|
// Edit existing angeltype
|
||||||
$angeltype = load_angeltype();
|
$angeltype = load_angeltype();
|
||||||
|
|
||||||
if (! User_is_AngelType_supporter($user, $angeltype)) {
|
if (!User_is_AngelType_supporter($user, $angeltype)) {
|
||||||
redirect(page_link_to('angeltypes'));
|
redirect(page_link_to('angeltypes'));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// New angeltype
|
// New angeltype
|
||||||
if ($supporter_mode) {
|
if ($supporter_mode) {
|
||||||
// Supporters aren't allowed to create new angeltypes.
|
// Supporters aren't allowed to create new angeltypes.
|
||||||
redirect(page_link_to('angeltypes'));
|
redirect(page_link_to('angeltypes'));
|
||||||
}
|
}
|
||||||
$angeltype = AngelType_new();
|
$angeltype = AngelType_new();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_REQUEST['submit'])) {
|
if (isset($_REQUEST['submit'])) {
|
||||||
$valid = true;
|
$valid = true;
|
||||||
|
|
||||||
if (! $supporter_mode) {
|
if (!$supporter_mode) {
|
||||||
if (isset($_REQUEST['name'])) {
|
if (isset($_REQUEST['name'])) {
|
||||||
$result = AngelType_validate_name($_REQUEST['name'], $angeltype);
|
$result = AngelType_validate_name($_REQUEST['name'], $angeltype);
|
||||||
$angeltype['name'] = $result->getValue();
|
$angeltype['name'] = $result->getValue();
|
||||||
if (! $result->isValid()) {
|
if (!$result->isValid()) {
|
||||||
$valid = false;
|
$valid = false;
|
||||||
error(_("Please check the name. Maybe it already exists."));
|
error(_("Please check the name. Maybe it already exists."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$angeltype['restricted'] = isset($_REQUEST['restricted']);
|
$angeltype['restricted'] = isset($_REQUEST['restricted']);
|
||||||
$angeltype['no_self_signup'] = isset($_REQUEST['no_self_signup']);
|
$angeltype['no_self_signup'] = isset($_REQUEST['no_self_signup']);
|
||||||
|
|
||||||
$angeltype['requires_driver_license'] = isset($_REQUEST['requires_driver_license']);
|
$angeltype['requires_driver_license'] = isset($_REQUEST['requires_driver_license']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$angeltype['description'] = strip_request_item_nl('description', $angeltype['description']);
|
$angeltype['description'] = strip_request_item_nl('description', $angeltype['description']);
|
||||||
|
|
||||||
if ($valid) {
|
if ($valid) {
|
||||||
if ($angeltype['id'] != null) {
|
if ($angeltype['id'] != null) {
|
||||||
AngelType_update($angeltype);
|
AngelType_update($angeltype);
|
||||||
} else {
|
} else {
|
||||||
$angeltype = AngelType_create($angeltype);
|
$angeltype = AngelType_create($angeltype);
|
||||||
}
|
}
|
||||||
|
|
||||||
success("Angel type saved.");
|
success("Angel type saved.");
|
||||||
redirect(angeltype_link($angeltype['id']));
|
redirect(angeltype_link($angeltype['id']));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
sprintf(_("Edit %s"), $angeltype['name']),
|
sprintf(_("Edit %s"), $angeltype['name']),
|
||||||
AngelType_edit_view($angeltype, $supporter_mode)
|
AngelType_edit_view($angeltype, $supporter_mode)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -155,20 +155,29 @@ function angeltype_edit_controller()
|
||||||
function angeltype_controller()
|
function angeltype_controller()
|
||||||
{
|
{
|
||||||
global $privileges, $user;
|
global $privileges, $user;
|
||||||
|
|
||||||
if (! in_array('angeltypes', $privileges)) {
|
if (!in_array('angeltypes', $privileges)) {
|
||||||
redirect('?');
|
redirect('?');
|
||||||
}
|
}
|
||||||
|
|
||||||
$angeltype = load_angeltype();
|
$angeltype = load_angeltype();
|
||||||
$user_angeltype = UserAngelType_by_User_and_AngelType($user, $angeltype);
|
$user_angeltype = UserAngelType_by_User_and_AngelType($user, $angeltype);
|
||||||
$user_driver_license = UserDriverLicense($user['UID']);
|
$user_driver_license = UserDriverLicense($user['UID']);
|
||||||
$members = Users_by_angeltype($angeltype);
|
$members = Users_by_angeltype($angeltype);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
sprintf(_("Team %s"), $angeltype['name']),
|
sprintf(_("Team %s"), $angeltype['name']),
|
||||||
AngelType_view($angeltype, $members, $user_angeltype, in_array('admin_user_angeltypes', $privileges) || $user_angeltype['supporter'], in_array('admin_angel_types', $privileges), $user_angeltype['supporter'], $user_driver_license, $user)
|
AngelType_view(
|
||||||
];
|
$angeltype,
|
||||||
|
$members,
|
||||||
|
$user_angeltype,
|
||||||
|
in_array('admin_user_angeltypes', $privileges) || $user_angeltype['supporter'],
|
||||||
|
in_array('admin_angel_types', $privileges),
|
||||||
|
$user_angeltype['supporter'],
|
||||||
|
$user_driver_license,
|
||||||
|
$user
|
||||||
|
)
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -177,42 +186,58 @@ function angeltype_controller()
|
||||||
function angeltypes_list_controller()
|
function angeltypes_list_controller()
|
||||||
{
|
{
|
||||||
global $privileges, $user;
|
global $privileges, $user;
|
||||||
|
|
||||||
if (! in_array('angeltypes', $privileges)) {
|
if (!in_array('angeltypes', $privileges)) {
|
||||||
redirect('?');
|
redirect('?');
|
||||||
}
|
}
|
||||||
|
|
||||||
$angeltypes = AngelTypes_with_user($user);
|
$angeltypes = AngelTypes_with_user($user);
|
||||||
|
|
||||||
foreach ($angeltypes as &$angeltype) {
|
foreach ($angeltypes as &$angeltype) {
|
||||||
$actions = [
|
$actions = [
|
||||||
button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _("view"), "btn-xs")
|
button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _("view"), "btn-xs")
|
||||||
];
|
];
|
||||||
|
|
||||||
if (in_array('admin_angel_types', $privileges)) {
|
if (in_array('admin_angel_types', $privileges)) {
|
||||||
$actions[] = button(page_link_to('angeltypes') . '&action=edit&angeltype_id=' . $angeltype['id'], _("edit"), "btn-xs");
|
$actions[] = button(
|
||||||
$actions[] = button(page_link_to('angeltypes') . '&action=delete&angeltype_id=' . $angeltype['id'], _("delete"), "btn-xs");
|
page_link_to('angeltypes') . '&action=edit&angeltype_id=' . $angeltype['id'],
|
||||||
|
_("edit"),
|
||||||
|
"btn-xs"
|
||||||
|
);
|
||||||
|
$actions[] = button(
|
||||||
|
page_link_to('angeltypes') . '&action=delete&angeltype_id=' . $angeltype['id'],
|
||||||
|
_("delete"),
|
||||||
|
"btn-xs"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$angeltype['membership'] = AngelType_render_membership($angeltype);
|
$angeltype['membership'] = AngelType_render_membership($angeltype);
|
||||||
if ($angeltype['user_angeltype_id'] != null) {
|
if ($angeltype['user_angeltype_id'] != null) {
|
||||||
$actions[] = button(page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $angeltype['user_angeltype_id'], _("leave"), "btn-xs");
|
$actions[] = button(
|
||||||
|
page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $angeltype['user_angeltype_id'],
|
||||||
|
_("leave"),
|
||||||
|
"btn-xs"
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
$actions[] = button(page_link_to('user_angeltypes') . '&action=add&angeltype_id=' . $angeltype['id'], _("join"), "btn-xs");
|
$actions[] = button(
|
||||||
|
page_link_to('user_angeltypes') . '&action=add&angeltype_id=' . $angeltype['id'],
|
||||||
|
_("join"),
|
||||||
|
"btn-xs"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$angeltype['restricted'] = $angeltype['restricted'] ? glyph('lock') : '';
|
$angeltype['restricted'] = $angeltype['restricted'] ? glyph('lock') : '';
|
||||||
$angeltype['no_self_signup'] = $angeltype['no_self_signup'] ? '' : glyph('share');
|
$angeltype['no_self_signup'] = $angeltype['no_self_signup'] ? '' : glyph('share');
|
||||||
|
|
||||||
$angeltype['name'] = '<a href="' . page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'] . '">' . $angeltype['name'] . '</a>';
|
$angeltype['name'] = '<a href="' . page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'] . '">' . $angeltype['name'] . '</a>';
|
||||||
|
|
||||||
$angeltype['actions'] = table_buttons($actions);
|
$angeltype['actions'] = table_buttons($actions);
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
angeltypes_title(),
|
angeltypes_title(),
|
||||||
AngelTypes_list_view($angeltypes, in_array('admin_angel_types', $privileges))
|
AngelTypes_list_view($angeltypes, in_array('admin_angel_types', $privileges))
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -220,15 +245,15 @@ function angeltypes_list_controller()
|
||||||
*/
|
*/
|
||||||
function load_angeltype()
|
function load_angeltype()
|
||||||
{
|
{
|
||||||
if (! isset($_REQUEST['angeltype_id'])) {
|
if (!isset($_REQUEST['angeltype_id'])) {
|
||||||
redirect(page_link_to('angeltypes'));
|
redirect(page_link_to('angeltypes'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$angeltype = AngelType($_REQUEST['angeltype_id']);
|
$angeltype = AngelType($_REQUEST['angeltype_id']);
|
||||||
if ($angeltype == null) {
|
if ($angeltype == null) {
|
||||||
error(_("Angeltype doesn't exist."));
|
error(_("Angeltype doesn't exist."));
|
||||||
redirect(page_link_to('angeltypes'));
|
redirect(page_link_to('angeltypes'));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $angeltype;
|
return $angeltype;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,18 +8,18 @@ function event_config_title()
|
||||||
function event_config_edit_controller()
|
function event_config_edit_controller()
|
||||||
{
|
{
|
||||||
global $privileges;
|
global $privileges;
|
||||||
|
|
||||||
if (! in_array('admin_event_config', $privileges)) {
|
if (!in_array('admin_event_config', $privileges)) {
|
||||||
redirect('?');
|
redirect('?');
|
||||||
}
|
}
|
||||||
|
|
||||||
$event_name = null;
|
$event_name = null;
|
||||||
$event_welcome_msg = null;
|
$event_welcome_msg = null;
|
||||||
$buildup_start_date = null;
|
$buildup_start_date = null;
|
||||||
$event_start_date = null;
|
$event_start_date = null;
|
||||||
$event_end_date = null;
|
$event_end_date = null;
|
||||||
$teardown_end_date = null;
|
$teardown_end_date = null;
|
||||||
|
|
||||||
$event_config = EventConfig();
|
$event_config = EventConfig();
|
||||||
if ($event_config != null) {
|
if ($event_config != null) {
|
||||||
$event_name = $event_config['event_name'];
|
$event_name = $event_config['event_name'];
|
||||||
|
@ -29,75 +29,93 @@ function event_config_edit_controller()
|
||||||
$teardown_end_date = $event_config['teardown_end_date'];
|
$teardown_end_date = $event_config['teardown_end_date'];
|
||||||
$event_welcome_msg = $event_config['event_welcome_msg'];
|
$event_welcome_msg = $event_config['event_welcome_msg'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_REQUEST['submit'])) {
|
if (isset($_REQUEST['submit'])) {
|
||||||
$valid = true;
|
$valid = true;
|
||||||
|
|
||||||
if (isset($_REQUEST['event_name'])) {
|
if (isset($_REQUEST['event_name'])) {
|
||||||
$event_name = strip_request_item('event_name');
|
$event_name = strip_request_item('event_name');
|
||||||
}
|
}
|
||||||
if ($event_name == '') {
|
if ($event_name == '') {
|
||||||
$event_name = null;
|
$event_name = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_REQUEST['event_welcome_msg'])) {
|
if (isset($_REQUEST['event_welcome_msg'])) {
|
||||||
$event_welcome_msg = strip_request_item_nl('event_welcome_msg');
|
$event_welcome_msg = strip_request_item_nl('event_welcome_msg');
|
||||||
}
|
}
|
||||||
if ($event_welcome_msg == '') {
|
if ($event_welcome_msg == '') {
|
||||||
$event_welcome_msg = null;
|
$event_welcome_msg = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = check_request_date('buildup_start_date', _("Please enter buildup start date."), true);
|
$result = check_request_date('buildup_start_date', _("Please enter buildup start date."), true);
|
||||||
$buildup_start_date = $result->getValue();
|
$buildup_start_date = $result->getValue();
|
||||||
$valid &= $result->isValid();
|
$valid &= $result->isValid();
|
||||||
|
|
||||||
$result = check_request_date('event_start_date', _("Please enter event start date."), true);
|
$result = check_request_date('event_start_date', _("Please enter event start date."), true);
|
||||||
$event_start_date = $result->getValue();
|
$event_start_date = $result->getValue();
|
||||||
$valid &= $result->isValid();
|
$valid &= $result->isValid();
|
||||||
|
|
||||||
$result = check_request_date('event_end_date', _("Please enter event end date."), true);
|
$result = check_request_date('event_end_date', _("Please enter event end date."), true);
|
||||||
$event_end_date = $result->getValue();
|
$event_end_date = $result->getValue();
|
||||||
$valid &= $result->isValid();
|
$valid &= $result->isValid();
|
||||||
|
|
||||||
$result = check_request_date('teardown_end_date', _("Please enter teardown end date."), true);
|
$result = check_request_date('teardown_end_date', _("Please enter teardown end date."), true);
|
||||||
$teardown_end_date = $result->getValue();
|
$teardown_end_date = $result->getValue();
|
||||||
$valid &= $result->isValid();
|
$valid &= $result->isValid();
|
||||||
|
|
||||||
if ($buildup_start_date != null && $event_start_date != null && $buildup_start_date > $event_start_date) {
|
if ($buildup_start_date != null && $event_start_date != null && $buildup_start_date > $event_start_date) {
|
||||||
$valid = false;
|
$valid = false;
|
||||||
error(_("The buildup start date has to be before the event start date."));
|
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) {
|
if ($event_start_date != null && $event_end_date != null && $event_start_date > $event_end_date) {
|
||||||
$valid = false;
|
$valid = false;
|
||||||
error(_("The event start date has to be before the event end date."));
|
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) {
|
if ($event_end_date != null && $teardown_end_date != null && $event_end_date > $teardown_end_date) {
|
||||||
$valid = false;
|
$valid = false;
|
||||||
error(_("The event end date has to be before the teardown end date."));
|
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) {
|
if ($buildup_start_date != null && $teardown_end_date != null && $buildup_start_date > $teardown_end_date) {
|
||||||
$valid = false;
|
$valid = false;
|
||||||
error(_("The buildup start date has to be before the teardown end date."));
|
error(_("The buildup start date has to be before the teardown end date."));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($valid) {
|
if ($valid) {
|
||||||
$result = EventConfig_update($event_name, $buildup_start_date, $event_start_date, $event_end_date, $teardown_end_date, $event_welcome_msg);
|
$result = EventConfig_update(
|
||||||
|
$event_name,
|
||||||
|
$buildup_start_date,
|
||||||
|
$event_start_date,
|
||||||
|
$event_end_date,
|
||||||
|
$teardown_end_date,
|
||||||
|
$event_welcome_msg
|
||||||
|
);
|
||||||
|
|
||||||
if ($result === false) {
|
if ($result === false) {
|
||||||
engelsystem_error("Unable to update event config.");
|
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));
|
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."));
|
success(_("Settings saved."));
|
||||||
redirect(page_link_to('admin_event_config'));
|
redirect(page_link_to('admin_event_config'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
event_config_title(),
|
event_config_title(),
|
||||||
EventConfig_edit_view($event_name, $event_welcome_msg, $buildup_start_date, $event_start_date, $event_end_date, $teardown_end_date)
|
EventConfig_edit_view(
|
||||||
];
|
$event_name,
|
||||||
|
$event_welcome_msg,
|
||||||
|
$buildup_start_date,
|
||||||
|
$event_start_date,
|
||||||
|
$event_end_date,
|
||||||
|
$teardown_end_date
|
||||||
|
)
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
use Engelsystem\ShiftsFilterRenderer;
|
|
||||||
use Engelsystem\ShiftsFilter;
|
use Engelsystem\ShiftsFilter;
|
||||||
use Engelsystem\ShiftCalendarRenderer;
|
use Engelsystem\ShiftsFilterRenderer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Room controllers for managing everything room related.
|
* Room controllers for managing everything room related.
|
||||||
|
@ -13,26 +12,28 @@ use Engelsystem\ShiftCalendarRenderer;
|
||||||
function room_controller()
|
function room_controller()
|
||||||
{
|
{
|
||||||
global $privileges;
|
global $privileges;
|
||||||
|
|
||||||
if (! in_array('view_rooms', $privileges)) {
|
if (!in_array('view_rooms', $privileges)) {
|
||||||
redirect(page_link_to());
|
redirect(page_link_to());
|
||||||
}
|
}
|
||||||
|
|
||||||
$room = load_room();
|
$room = load_room();
|
||||||
$all_shifts = Shifts_by_room($room);
|
$all_shifts = Shifts_by_room($room);
|
||||||
$days = [];
|
$days = [];
|
||||||
foreach ($all_shifts as $shift) {
|
foreach ($all_shifts as $shift) {
|
||||||
$day = date("Y-m-d", $shift['start']);
|
$day = date("Y-m-d", $shift['start']);
|
||||||
if (! in_array($day, $days)) {
|
if (!in_array($day, $days)) {
|
||||||
$days[] = $day;
|
$days[] = $day;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$shiftsFilter = new ShiftsFilter(true, [
|
$shiftsFilter = new ShiftsFilter(
|
||||||
$room['RID']
|
true,
|
||||||
], AngelType_ids());
|
[$room['RID']],
|
||||||
|
AngelType_ids()
|
||||||
|
);
|
||||||
$selected_day = date("Y-m-d");
|
$selected_day = date("Y-m-d");
|
||||||
if (! empty($days)) {
|
if (!empty($days)) {
|
||||||
$selected_day = $days[0];
|
$selected_day = $days[0];
|
||||||
}
|
}
|
||||||
if (isset($_REQUEST['shifts_filter_day'])) {
|
if (isset($_REQUEST['shifts_filter_day'])) {
|
||||||
|
@ -40,16 +41,16 @@ function room_controller()
|
||||||
}
|
}
|
||||||
$shiftsFilter->setStartTime(parse_date("Y-m-d H:i", $selected_day . ' 00:00'));
|
$shiftsFilter->setStartTime(parse_date("Y-m-d H:i", $selected_day . ' 00:00'));
|
||||||
$shiftsFilter->setEndTime(parse_date("Y-m-d H:i", $selected_day . ' 23:59'));
|
$shiftsFilter->setEndTime(parse_date("Y-m-d H:i", $selected_day . ' 23:59'));
|
||||||
|
|
||||||
$shiftsFilterRenderer = new ShiftsFilterRenderer($shiftsFilter);
|
$shiftsFilterRenderer = new ShiftsFilterRenderer($shiftsFilter);
|
||||||
$shiftsFilterRenderer->enableDaySelection($days);
|
$shiftsFilterRenderer->enableDaySelection($days);
|
||||||
|
|
||||||
$shiftCalendarRenderer = shiftCalendarRendererByShiftFilter($shiftsFilter);
|
$shiftCalendarRenderer = shiftCalendarRendererByShiftFilter($shiftsFilter);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
$room['Name'],
|
$room['Name'],
|
||||||
Room_view($room, $shiftsFilterRenderer, $shiftCalendarRenderer)
|
Room_view($room, $shiftsFilterRenderer, $shiftCalendarRenderer)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -57,17 +58,17 @@ function room_controller()
|
||||||
*/
|
*/
|
||||||
function rooms_controller()
|
function rooms_controller()
|
||||||
{
|
{
|
||||||
if (! isset($_REQUEST['action'])) {
|
if (!isset($_REQUEST['action'])) {
|
||||||
$_REQUEST['action'] = 'list';
|
$_REQUEST['action'] = 'list';
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ($_REQUEST['action']) {
|
switch ($_REQUEST['action']) {
|
||||||
default:
|
default:
|
||||||
case 'list':
|
case 'list':
|
||||||
redirect(page_link_to('admin_rooms'));
|
redirect(page_link_to('admin_rooms'));
|
||||||
case 'view':
|
case 'view':
|
||||||
return room_controller();
|
return room_controller();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function room_link($room)
|
function room_link($room)
|
||||||
|
@ -85,14 +86,14 @@ function room_edit_link($room)
|
||||||
*/
|
*/
|
||||||
function load_room()
|
function load_room()
|
||||||
{
|
{
|
||||||
if (! test_request_int('room_id')) {
|
if (!test_request_int('room_id')) {
|
||||||
redirect(page_link_to());
|
redirect(page_link_to());
|
||||||
}
|
}
|
||||||
|
|
||||||
$room = Room($_REQUEST['room_id']);
|
$room = Room($_REQUEST['room_id']);
|
||||||
if ($room == null) {
|
if ($room == null) {
|
||||||
redirect(page_link_to());
|
redirect(page_link_to());
|
||||||
}
|
}
|
||||||
|
|
||||||
return $room;
|
return $room;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,112 +6,157 @@
|
||||||
function shift_entry_add_controller()
|
function shift_entry_add_controller()
|
||||||
{
|
{
|
||||||
global $privileges, $user;
|
global $privileges, $user;
|
||||||
|
|
||||||
if (isset($_REQUEST['shift_id']) && preg_match("/^[0-9]*$/", $_REQUEST['shift_id'])) {
|
if (isset($_REQUEST['shift_id']) && preg_match("/^[0-9]*$/", $_REQUEST['shift_id'])) {
|
||||||
$shift_id = $_REQUEST['shift_id'];
|
$shift_id = $_REQUEST['shift_id'];
|
||||||
} else {
|
} else {
|
||||||
redirect(page_link_to('user_shifts'));
|
redirect(page_link_to('user_shifts'));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Locations laden
|
// Locations laden
|
||||||
$rooms = sql_select("SELECT * FROM `Room` WHERE `show`='Y' ORDER BY `Name`");
|
$rooms = sql_select("SELECT * FROM `Room` WHERE `show`='Y' ORDER BY `Name`");
|
||||||
$room_array = [];
|
$room_array = [];
|
||||||
foreach ($rooms as $room) {
|
foreach ($rooms as $room) {
|
||||||
$room_array[$room['RID']] = $room['Name'];
|
$room_array[$room['RID']] = $room['Name'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$shift = Shift($shift_id);
|
$shift = Shift($shift_id);
|
||||||
$shift['Name'] = $room_array[$shift['RID']];
|
$shift['Name'] = $room_array[$shift['RID']];
|
||||||
if ($shift == null) {
|
if ($shift == null) {
|
||||||
redirect(page_link_to('user_shifts'));
|
redirect(page_link_to('user_shifts'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_REQUEST['type_id']) && preg_match("/^[0-9]*$/", $_REQUEST['type_id'])) {
|
if (isset($_REQUEST['type_id']) && preg_match("/^[0-9]*$/", $_REQUEST['type_id'])) {
|
||||||
$type_id = $_REQUEST['type_id'];
|
$type_id = $_REQUEST['type_id'];
|
||||||
} else {
|
} else {
|
||||||
redirect(page_link_to('user_shifts'));
|
redirect(page_link_to('user_shifts'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (in_array('user_shifts_admin', $privileges) || in_array('shiftentry_edit_angeltype_supporter', $privileges)) {
|
if (in_array('user_shifts_admin', $privileges) || in_array('shiftentry_edit_angeltype_supporter', $privileges)) {
|
||||||
$type = AngelType($type_id);
|
$type = AngelType($type_id);
|
||||||
} else {
|
} 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 = 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];
|
$type = $type[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($type == null) {
|
if ($type == null) {
|
||||||
redirect(page_link_to('user_shifts'));
|
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))) {
|
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'];
|
$user_id = $_REQUEST['user_id'];
|
||||||
} else {
|
} else {
|
||||||
$user_id = $user['UID'];
|
$user_id = $user['UID'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$needed_angeltype = NeededAngeltype_by_Shift_and_Angeltype($shift, $type);
|
$needed_angeltype = NeededAngeltype_by_Shift_and_Angeltype($shift, $type);
|
||||||
$shift_entries = ShiftEntries_by_shift_and_angeltype($shift['SID'], $type['id']);
|
$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);
|
$shift_signup_allowed = Shift_signup_allowed(
|
||||||
if (! $shift_signup_allowed->isSignupAllowed()) {
|
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."));
|
error(_("You are not allowed to sign up for this shift. Maybe shift is full or already running."));
|
||||||
redirect(shift_link($shift));
|
redirect(shift_link($shift));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_REQUEST['submit'])) {
|
if (isset($_REQUEST['submit'])) {
|
||||||
$selected_type_id = $type_id;
|
$selected_type_id = $type_id;
|
||||||
if (in_array('user_shifts_admin', $privileges) || in_array('shiftentry_edit_angeltype_supporter', $privileges)) {
|
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) {
|
if (sql_num_query("SELECT * FROM `User` WHERE `UID`='" . sql_escape($user_id) . "' LIMIT 1") == 0) {
|
||||||
redirect(page_link_to('user_shifts'));
|
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) {
|
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'];
|
$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) . "'")) {
|
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);
|
return error("This angel does already have an entry for this shift.", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
$freeloaded = $shift['freeloaded'];
|
$freeloaded = $shift['freeloaded'];
|
||||||
$freeload_comment = $shift['freeload_comment'];
|
$freeload_comment = $shift['freeload_comment'];
|
||||||
if (in_array("user_shifts_admin", $privileges)) {
|
if (in_array("user_shifts_admin", $privileges)) {
|
||||||
$freeloaded = isset($_REQUEST['freeloaded']);
|
$freeloaded = isset($_REQUEST['freeloaded']);
|
||||||
$freeload_comment = strip_request_item_nl('freeload_comment');
|
$freeload_comment = strip_request_item_nl('freeload_comment');
|
||||||
}
|
}
|
||||||
|
|
||||||
$comment = strip_request_item_nl('comment');
|
$comment = strip_request_item_nl('comment');
|
||||||
$result = ShiftEntry_create([
|
$result = ShiftEntry_create([
|
||||||
'SID' => $shift_id,
|
'SID' => $shift_id,
|
||||||
'TID' => $selected_type_id,
|
'TID' => $selected_type_id,
|
||||||
'UID' => $user_id,
|
'UID' => $user_id,
|
||||||
'Comment' => $comment,
|
'Comment' => $comment,
|
||||||
'freeloaded' => $freeloaded,
|
'freeloaded' => $freeloaded,
|
||||||
'freeload_comment' => $freeload_comment
|
'freeload_comment' => $freeload_comment
|
||||||
]);
|
]);
|
||||||
if ($result === false) {
|
if ($result === false) {
|
||||||
engelsystem_error('Unable to create shift entry.');
|
engelsystem_error('Unable to create shift entry.');
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
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) . "')");
|
sql_query("INSERT INTO `UserAngelTypes` (`user_id`, `angeltype_id`) VALUES ('" . sql_escape($user_id) . "', '" . sql_escape($selected_type_id) . "')");
|
||||||
}
|
}
|
||||||
|
|
||||||
$user_source = User($user_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']));
|
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>');
|
success(_("You are subscribed. Thank you!") . ' <a href="' . page_link_to('user_myshifts') . '">' . _("My shifts") . ' »</a>');
|
||||||
redirect(shift_link($shift));
|
redirect(shift_link($shift));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (in_array('user_shifts_admin', $privileges)) {
|
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 = sql_select("
|
||||||
|
SELECT *, (SELECT count(*) FROM `ShiftEntry` WHERE `freeloaded`=1 AND `ShiftEntry`.`UID`=`User`.`UID`) AS `freeloaded`
|
||||||
|
FROM `User`
|
||||||
|
ORDER BY `Nick`
|
||||||
|
");
|
||||||
$users_select = [];
|
$users_select = [];
|
||||||
foreach ($users as $usr) {
|
foreach ($users as $usr) {
|
||||||
$users_select[$usr['UID']] = $usr['Nick'] . ($usr['freeloaded'] == 0 ? "" : " (" . _("Freeloader") . ")");
|
$users_select[$usr['UID']] = $usr['Nick'] . ($usr['freeloaded'] == 0 ? "" : " (" . _("Freeloader") . ")");
|
||||||
}
|
}
|
||||||
$user_text = html_select_key('user_id', 'user_id', $users_select, $user['UID']);
|
$user_text = html_select_key('user_id', 'user_id', $users_select, $user['UID']);
|
||||||
|
|
||||||
$angeltypes_source = sql_select("SELECT * FROM `AngelTypes` ORDER BY `name`");
|
$angeltypes_source = sql_select("SELECT * FROM `AngelTypes` ORDER BY `name`");
|
||||||
$angeltypes = [];
|
$angeltypes = [];
|
||||||
foreach ($angeltypes_source as $angeltype) {
|
foreach ($angeltypes_source as $angeltype) {
|
||||||
|
@ -122,12 +167,12 @@ function shift_entry_add_controller()
|
||||||
$users = Users_by_angeltype($type);
|
$users = Users_by_angeltype($type);
|
||||||
$users_select = [];
|
$users_select = [];
|
||||||
foreach ($users as $usr) {
|
foreach ($users as $usr) {
|
||||||
if (! $type['restricted'] || $usr['confirm_user_id'] != null) {
|
if (!$type['restricted'] || $usr['confirm_user_id'] != null) {
|
||||||
$users_select[$usr['UID']] = $usr['Nick'];
|
$users_select[$usr['UID']] = $usr['Nick'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$user_text = html_select_key('user_id', 'user_id', $users_select, $user['UID']);
|
$user_text = html_select_key('user_id', 'user_id', $users_select, $user['UID']);
|
||||||
|
|
||||||
$angeltypes_source = User_angeltypes($user);
|
$angeltypes_source = User_angeltypes($user);
|
||||||
$angeltypes = [];
|
$angeltypes = [];
|
||||||
foreach ($angeltypes_source as $angeltype) {
|
foreach ($angeltypes_source as $angeltype) {
|
||||||
|
@ -140,8 +185,10 @@ function shift_entry_add_controller()
|
||||||
$user_text = User_Nick_render($user);
|
$user_text = User_Nick_render($user);
|
||||||
$angeltype_select = $type['name'];
|
$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));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -150,14 +197,22 @@ function shift_entry_add_controller()
|
||||||
function shift_entry_delete_controller()
|
function shift_entry_delete_controller()
|
||||||
{
|
{
|
||||||
global $privileges, $user;
|
global $privileges, $user;
|
||||||
|
|
||||||
if (! isset($_REQUEST['entry_id']) || ! test_request_int('entry_id')) {
|
if (!isset($_REQUEST['entry_id']) || !test_request_int('entry_id')) {
|
||||||
redirect(page_link_to('user_shifts'));
|
redirect(page_link_to('user_shifts'));
|
||||||
}
|
}
|
||||||
$entry_id = $_REQUEST['entry_id'];
|
$entry_id = $_REQUEST['entry_id'];
|
||||||
|
|
||||||
$shift_entry_source = sql_select("
|
$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`
|
SELECT
|
||||||
|
`User`.`Nick`,
|
||||||
|
`ShiftEntry`.`Comment`,
|
||||||
|
`ShiftEntry`.`UID`,
|
||||||
|
`ShiftTypes`.`name`,
|
||||||
|
`Shifts`.*,
|
||||||
|
`Room`.`Name`,
|
||||||
|
`AngelTypes`.`name` AS `angel_type`,
|
||||||
|
`AngelTypes`.`id` AS `angeltype_id`
|
||||||
FROM `ShiftEntry`
|
FROM `ShiftEntry`
|
||||||
JOIN `User` ON (`User`.`UID`=`ShiftEntry`.`UID`)
|
JOIN `User` ON (`User`.`UID`=`ShiftEntry`.`UID`)
|
||||||
JOIN `AngelTypes` ON (`ShiftEntry`.`TID` = `AngelTypes`.`id`)
|
JOIN `AngelTypes` ON (`ShiftEntry`.`TID` = `AngelTypes`.`id`)
|
||||||
|
@ -167,17 +222,25 @@ function shift_entry_delete_controller()
|
||||||
WHERE `ShiftEntry`.`id`='" . sql_escape($entry_id) . "'");
|
WHERE `ShiftEntry`.`id`='" . sql_escape($entry_id) . "'");
|
||||||
if (count($shift_entry_source) > 0) {
|
if (count($shift_entry_source) > 0) {
|
||||||
$shift_entry_source = $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'])))) {
|
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'));
|
redirect(page_link_to('user_shifts'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = ShiftEntry_delete($entry_id);
|
$result = ShiftEntry_delete($entry_id);
|
||||||
if ($result === false) {
|
if ($result === false) {
|
||||||
engelsystem_error('Unable to delete shift entry.');
|
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']);
|
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."));
|
success(_("Shift entry deleted."));
|
||||||
} else {
|
} else {
|
||||||
error(_("Entry not found."));
|
error(_("Entry not found."));
|
||||||
|
|
|
@ -22,93 +22,96 @@ function shift_edit_link($shift)
|
||||||
function shift_edit_controller()
|
function shift_edit_controller()
|
||||||
{
|
{
|
||||||
global $privileges;
|
global $privileges;
|
||||||
|
|
||||||
// Schicht bearbeiten
|
// Schicht bearbeiten
|
||||||
$msg = "";
|
$msg = "";
|
||||||
$valid = true;
|
$valid = true;
|
||||||
|
|
||||||
if (! in_array('admin_shifts', $privileges)) {
|
if (!in_array('admin_shifts', $privileges)) {
|
||||||
redirect(page_link_to('user_shifts'));
|
redirect(page_link_to('user_shifts'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! isset($_REQUEST['edit_shift']) || ! test_request_int('edit_shift')) {
|
if (!isset($_REQUEST['edit_shift']) || !test_request_int('edit_shift')) {
|
||||||
redirect(page_link_to('user_shifts'));
|
redirect(page_link_to('user_shifts'));
|
||||||
}
|
}
|
||||||
$shift_id = $_REQUEST['edit_shift'];
|
$shift_id = $_REQUEST['edit_shift'];
|
||||||
|
|
||||||
$shift = Shift($shift_id);
|
$shift = Shift($shift_id);
|
||||||
|
|
||||||
$room = select_array(Rooms(), 'RID', 'Name');
|
$room = select_array(Rooms(), 'RID', 'Name');
|
||||||
$angeltypes = select_array(AngelTypes(), 'id', 'name');
|
$angeltypes = select_array(AngelTypes(), 'id', 'name');
|
||||||
$shifttypes = select_array(ShiftTypes(), 'id', 'name');
|
$shifttypes = select_array(ShiftTypes(), 'id', 'name');
|
||||||
|
|
||||||
$needed_angel_types = select_array(NeededAngelTypes_by_shift($shift_id), 'id', 'count');
|
$needed_angel_types = select_array(NeededAngelTypes_by_shift($shift_id), 'id', 'count');
|
||||||
foreach (array_keys($angeltypes) as $angeltype_id) {
|
foreach (array_keys($angeltypes) as $angeltype_id) {
|
||||||
if (! isset($needed_angel_types[$angeltype_id])) {
|
if (!isset($needed_angel_types[$angeltype_id])) {
|
||||||
$needed_angel_types[$angeltype_id] = 0;
|
$needed_angel_types[$angeltype_id] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$shifttype_id = $shift['shifttype_id'];
|
$shifttype_id = $shift['shifttype_id'];
|
||||||
$title = $shift['title'];
|
$title = $shift['title'];
|
||||||
$rid = $shift['RID'];
|
$rid = $shift['RID'];
|
||||||
$start = $shift['start'];
|
$start = $shift['start'];
|
||||||
$end = $shift['end'];
|
$end = $shift['end'];
|
||||||
|
|
||||||
if (isset($_REQUEST['submit'])) {
|
if (isset($_REQUEST['submit'])) {
|
||||||
// Name/Bezeichnung der Schicht, darf leer sein
|
// Name/Bezeichnung der Schicht, darf leer sein
|
||||||
$title = strip_request_item('title');
|
$title = strip_request_item('title');
|
||||||
|
|
||||||
// Auswahl der sichtbaren Locations für die Schichten
|
// Auswahl der sichtbaren Locations für die Schichten
|
||||||
if (isset($_REQUEST['rid']) && preg_match("/^[0-9]+$/", $_REQUEST['rid']) && isset($room[$_REQUEST['rid']])) {
|
if (isset($_REQUEST['rid']) && preg_match("/^[0-9]+$/", $_REQUEST['rid']) && isset($room[$_REQUEST['rid']])) {
|
||||||
$rid = $_REQUEST['rid'];
|
$rid = $_REQUEST['rid'];
|
||||||
} else {
|
} else {
|
||||||
$valid = false;
|
$valid = false;
|
||||||
$msg .= error(_("Please select a room."), true);
|
$msg .= error(_("Please select a room."), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_REQUEST['shifttype_id']) && isset($shifttypes[$_REQUEST['shifttype_id']])) {
|
if (isset($_REQUEST['shifttype_id']) && isset($shifttypes[$_REQUEST['shifttype_id']])) {
|
||||||
$shifttype_id = $_REQUEST['shifttype_id'];
|
$shifttype_id = $_REQUEST['shifttype_id'];
|
||||||
} else {
|
} else {
|
||||||
$valid = false;
|
$valid = false;
|
||||||
$msg .= error(_('Please select a shifttype.'), true);
|
$msg .= error(_('Please select a shifttype.'), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_REQUEST['start']) && $tmp = parse_date("Y-m-d H:i", $_REQUEST['start'])) {
|
if (isset($_REQUEST['start']) && $tmp = parse_date("Y-m-d H:i", $_REQUEST['start'])) {
|
||||||
$start = $tmp;
|
$start = $tmp;
|
||||||
} else {
|
} else {
|
||||||
$valid = false;
|
$valid = false;
|
||||||
$msg .= error(_("Please enter a valid starting time for the shifts."), true);
|
$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'])) {
|
if (isset($_REQUEST['end']) && $tmp = parse_date("Y-m-d H:i", $_REQUEST['end'])) {
|
||||||
$end = $tmp;
|
$end = $tmp;
|
||||||
} else {
|
} else {
|
||||||
$valid = false;
|
$valid = false;
|
||||||
$msg .= error(_("Please enter a valid ending time for the shifts."), true);
|
$msg .= error(_("Please enter a valid ending time for the shifts."), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($start >= $end) {
|
if ($start >= $end) {
|
||||||
$valid = false;
|
$valid = false;
|
||||||
$msg .= error(_("The ending time has to be after the starting time."), true);
|
$msg .= error(_("The ending time has to be after the starting time."), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($needed_angel_types as $needed_angeltype_id => $needed_angeltype_name) {
|
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)) {
|
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]);
|
$needed_angel_types[$needed_angeltype_id] = trim($_REQUEST['type_' . $needed_angeltype_id]);
|
||||||
} else {
|
} else {
|
||||||
$valid = false;
|
$valid = false;
|
||||||
$msg .= error(sprintf(_("Please check your input for needed angels of type %s."), $needed_angeltype_name), true);
|
$msg .= error(sprintf(
|
||||||
|
_("Please check your input for needed angels of type %s."),
|
||||||
|
$needed_angeltype_name
|
||||||
|
), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($valid) {
|
if ($valid) {
|
||||||
$shift['shifttype_id'] = $shifttype_id;
|
$shift['shifttype_id'] = $shifttype_id;
|
||||||
$shift['title'] = $title;
|
$shift['title'] = $title;
|
||||||
$shift['RID'] = $rid;
|
$shift['RID'] = $rid;
|
||||||
$shift['start'] = $start;
|
$shift['start'] = $start;
|
||||||
$shift['end'] = $end;
|
$shift['end'] = $end;
|
||||||
|
|
||||||
$result = Shift_update($shift);
|
$result = Shift_update($shift);
|
||||||
if ($result === false) {
|
if ($result === false) {
|
||||||
engelsystem_error('Unable to update shift.');
|
engelsystem_error('Unable to update shift.');
|
||||||
|
@ -119,100 +122,119 @@ function shift_edit_controller()
|
||||||
NeededAngelType_add($shift_id, $type_id, null, $count);
|
NeededAngelType_add($shift_id, $type_id, null, $count);
|
||||||
$needed_angel_types_info[] = $angeltypes[$type_id] . ": " . $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));
|
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."));
|
success(_("Shift updated."));
|
||||||
|
|
||||||
redirect(shift_link([
|
redirect(shift_link([
|
||||||
'SID' => $shift_id
|
'SID' => $shift_id
|
||||||
]));
|
]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$angel_types_spinner = "";
|
$angel_types_spinner = "";
|
||||||
foreach ($angeltypes as $angeltype_id => $angeltype_name) {
|
foreach ($angeltypes as $angeltype_id => $angeltype_name) {
|
||||||
$angel_types_spinner .= form_spinner('type_' . $angeltype_id, $angeltype_name, $needed_angel_types[$angeltype_id]);
|
$angel_types_spinner .= form_spinner('type_' . $angeltype_id, $angeltype_name,
|
||||||
|
$needed_angel_types[$angeltype_id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return page_with_title(shifts_title(), [
|
return page_with_title(
|
||||||
msg(),
|
shifts_title(),
|
||||||
'<noscript>' . info(_("This page is much more comfortable with javascript."), true) . '</noscript>',
|
[
|
||||||
form([
|
msg(),
|
||||||
form_select('shifttype_id', _('Shifttype'), $shifttypes, $shifttype_id),
|
'<noscript>' . info(_("This page is much more comfortable with javascript."), true) . '</noscript>',
|
||||||
form_text('title', _("Title"), $title),
|
form([
|
||||||
form_select('rid', _("Room:"), $room, $rid),
|
form_select('shifttype_id', _('Shifttype'), $shifttypes, $shifttype_id),
|
||||||
form_text('start', _("Start:"), date("Y-m-d H:i", $start)),
|
form_text('title', _("Title"), $title),
|
||||||
form_text('end', _("End:"), date("Y-m-d H:i", $end)),
|
form_select('rid', _("Room:"), $room, $rid),
|
||||||
'<h2>' . _("Needed angels") . '</h2>',
|
form_text('start', _("Start:"), date("Y-m-d H:i", $start)),
|
||||||
$angel_types_spinner,
|
form_text('end', _("End:"), date("Y-m-d H:i", $end)),
|
||||||
form_submit('submit', _("Save"))
|
'<h2>' . _("Needed angels") . '</h2>',
|
||||||
])
|
$angel_types_spinner,
|
||||||
]);
|
form_submit('submit', _("Save"))
|
||||||
|
])
|
||||||
|
]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function shift_delete_controller()
|
function shift_delete_controller()
|
||||||
{
|
{
|
||||||
global $privileges;
|
global $privileges;
|
||||||
|
|
||||||
if (! in_array('user_shifts_admin', $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'));
|
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_id = $_REQUEST['delete_shift'];
|
||||||
|
|
||||||
$shift = Shift($shift_id);
|
$shift = Shift($shift_id);
|
||||||
if ($shift == null) {
|
if ($shift == null) {
|
||||||
redirect(page_link_to('user_shifts'));
|
redirect(page_link_to('user_shifts'));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Schicht löschen bestätigt
|
// Schicht löschen bestätigt
|
||||||
if (isset($_REQUEST['delete'])) {
|
if (isset($_REQUEST['delete'])) {
|
||||||
Shift_delete($shift_id);
|
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']));
|
engelsystem_log(
|
||||||
success(_("Shift deleted."));
|
"Deleted shift " . $shift['name']
|
||||||
redirect(page_link_to('user_shifts'));
|
. " 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(), [
|
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),
|
error(sprintf(
|
||||||
'<a class="button" href="?p=user_shifts&delete_shift=' . $shift_id . '&delete">' . _("delete") . '</a>'
|
_("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()
|
function shift_controller()
|
||||||
{
|
{
|
||||||
global $user, $privileges;
|
global $user, $privileges;
|
||||||
|
|
||||||
if (! in_array('user_shifts', $privileges)) {
|
if (!in_array('user_shifts', $privileges)) {
|
||||||
redirect(page_link_to('?'));
|
redirect(page_link_to('?'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! isset($_REQUEST['shift_id'])) {
|
if (!isset($_REQUEST['shift_id'])) {
|
||||||
redirect(page_link_to('user_shifts'));
|
redirect(page_link_to('user_shifts'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$shift = Shift($_REQUEST['shift_id']);
|
$shift = Shift($_REQUEST['shift_id']);
|
||||||
if ($shift == null) {
|
if ($shift == null) {
|
||||||
error(_("Shift could not be found."));
|
error(_("Shift could not be found."));
|
||||||
redirect(page_link_to('user_shifts'));
|
redirect(page_link_to('user_shifts'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$shifttype = ShiftType($shift['shifttype_id']);
|
$shifttype = ShiftType($shift['shifttype_id']);
|
||||||
$room = Room($shift['RID']);
|
$room = Room($shift['RID']);
|
||||||
$angeltypes = AngelTypes();
|
$angeltypes = AngelTypes();
|
||||||
$user_shifts = Shifts_by_user($user);
|
$user_shifts = Shifts_by_user($user);
|
||||||
|
|
||||||
$shift_signup_state = new ShiftSignupState(ShiftSignupState::OCCUPIED, 0);
|
$shift_signup_state = new ShiftSignupState(ShiftSignupState::OCCUPIED, 0);
|
||||||
foreach ($angeltypes as &$angeltype) {
|
foreach ($angeltypes as &$angeltype) {
|
||||||
$needed_angeltype = NeededAngeltype_by_Shift_and_Angeltype($shift, $angeltype);
|
$needed_angeltype = NeededAngeltype_by_Shift_and_Angeltype($shift, $angeltype);
|
||||||
$shift_entries = ShiftEntries_by_shift_and_angeltype($shift['SID'], $angeltype['id']);
|
$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);
|
$angeltype_signup_state = Shift_signup_allowed($user, $shift, $angeltype, null, $user_shifts, $needed_angeltype,
|
||||||
|
$shift_entries);
|
||||||
if ($shift_signup_state == null) {
|
if ($shift_signup_state == null) {
|
||||||
$shift_signup_state = $angeltype_signup_state;
|
$shift_signup_state = $angeltype_signup_state;
|
||||||
} else {
|
} else {
|
||||||
|
@ -220,27 +242,27 @@ function shift_controller()
|
||||||
}
|
}
|
||||||
$angeltype['shift_signup_state'] = $angeltype_signup_state;
|
$angeltype['shift_signup_state'] = $angeltype_signup_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
$shift['name'],
|
$shift['name'],
|
||||||
Shift_view($shift, $shifttype, $room, $angeltypes, $shift_signup_state)
|
Shift_view($shift, $shifttype, $room, $angeltypes, $shift_signup_state)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
function shifts_controller()
|
function shifts_controller()
|
||||||
{
|
{
|
||||||
if (! isset($_REQUEST['action'])) {
|
if (!isset($_REQUEST['action'])) {
|
||||||
redirect(page_link_to('user_shifts'));
|
redirect(page_link_to('user_shifts'));
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ($_REQUEST['action']) {
|
switch ($_REQUEST['action']) {
|
||||||
default:
|
default:
|
||||||
redirect(page_link_to('?'));
|
redirect(page_link_to('?'));
|
||||||
case 'view':
|
case 'view':
|
||||||
return shift_controller();
|
return shift_controller();
|
||||||
case 'next':
|
case 'next':
|
||||||
return shift_next_controller();
|
return shift_next_controller();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -249,20 +271,20 @@ function shifts_controller()
|
||||||
function shift_next_controller()
|
function shift_next_controller()
|
||||||
{
|
{
|
||||||
global $user, $privileges;
|
global $user, $privileges;
|
||||||
|
|
||||||
if (! in_array('user_shifts', $privileges)) {
|
if (!in_array('user_shifts', $privileges)) {
|
||||||
redirect(page_link_to('?'));
|
redirect(page_link_to('?'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$upcoming_shifts = ShiftEntries_upcoming_for_user($user);
|
$upcoming_shifts = ShiftEntries_upcoming_for_user($user);
|
||||||
if ($upcoming_shifts === false) {
|
if ($upcoming_shifts === false) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($upcoming_shifts) > 0) {
|
if (count($upcoming_shifts) > 0) {
|
||||||
redirect(shift_link($upcoming_shifts[0]));
|
redirect(shift_link($upcoming_shifts[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
redirect(page_link_to('user_shifts'));
|
redirect(page_link_to('user_shifts'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -272,24 +294,24 @@ function shift_next_controller()
|
||||||
function shifts_json_export_all_controller()
|
function shifts_json_export_all_controller()
|
||||||
{
|
{
|
||||||
global $api_key;
|
global $api_key;
|
||||||
|
|
||||||
if ($api_key == "") {
|
if ($api_key == "") {
|
||||||
engelsystem_error("Config contains empty apikey.");
|
engelsystem_error("Config contains empty apikey.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! isset($_REQUEST['api_key'])) {
|
if (!isset($_REQUEST['api_key'])) {
|
||||||
engelsystem_error("Missing parameter api_key.");
|
engelsystem_error("Missing parameter api_key.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($_REQUEST['api_key'] != $api_key) {
|
if ($_REQUEST['api_key'] != $api_key) {
|
||||||
engelsystem_error("Invalid api_key.");
|
engelsystem_error("Invalid api_key.");
|
||||||
}
|
}
|
||||||
|
|
||||||
$shifts_source = Shifts();
|
$shifts_source = Shifts();
|
||||||
if ($shifts_source === false) {
|
if ($shifts_source === false) {
|
||||||
engelsystem_error("Unable to load shifts.");
|
engelsystem_error("Unable to load shifts.");
|
||||||
}
|
}
|
||||||
|
|
||||||
header("Content-Type: application/json; charset=utf-8");
|
header("Content-Type: application/json; charset=utf-8");
|
||||||
raw_output(json_encode($shifts_source));
|
raw_output(json_encode($shifts_source));
|
||||||
}
|
}
|
||||||
|
@ -301,23 +323,23 @@ function shifts_json_export_all_controller()
|
||||||
function shifts_json_export_controller()
|
function shifts_json_export_controller()
|
||||||
{
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
if (! isset($_REQUEST['key']) || ! preg_match("/^[0-9a-f]{32}$/", $_REQUEST['key'])) {
|
if (!isset($_REQUEST['key']) || !preg_match("/^[0-9a-f]{32}$/", $_REQUEST['key'])) {
|
||||||
engelsystem_error("Missing key.");
|
engelsystem_error("Missing key.");
|
||||||
}
|
}
|
||||||
|
|
||||||
$key = $_REQUEST['key'];
|
$key = $_REQUEST['key'];
|
||||||
|
|
||||||
$user = User_by_api_key($key);
|
$user = User_by_api_key($key);
|
||||||
if ($user == null) {
|
if ($user == null) {
|
||||||
engelsystem_error("Key invalid.");
|
engelsystem_error("Key invalid.");
|
||||||
}
|
}
|
||||||
if (! in_array('shifts_json_export', privileges_for_user($user['UID']))) {
|
if (!in_array('shifts_json_export', privileges_for_user($user['UID']))) {
|
||||||
engelsystem_error("No privilege for shifts_json_export.");
|
engelsystem_error("No privilege for shifts_json_export.");
|
||||||
}
|
}
|
||||||
|
|
||||||
$shifts = load_ical_shifts();
|
$shifts = load_ical_shifts();
|
||||||
|
|
||||||
header("Content-Type: application/json; charset=utf-8");
|
header("Content-Type: application/json; charset=utf-8");
|
||||||
raw_output(json_encode($shifts));
|
raw_output(json_encode($shifts));
|
||||||
}
|
}
|
||||||
|
@ -328,6 +350,6 @@ function shifts_json_export_controller()
|
||||||
function load_ical_shifts()
|
function load_ical_shifts()
|
||||||
{
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
return Shifts_by_user($user);
|
return Shifts_by_user($user);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,34 +10,34 @@ function shifttype_link($shifttype)
|
||||||
*/
|
*/
|
||||||
function shifttype_delete_controller()
|
function shifttype_delete_controller()
|
||||||
{
|
{
|
||||||
if (! isset($_REQUEST['shifttype_id'])) {
|
if (!isset($_REQUEST['shifttype_id'])) {
|
||||||
redirect(page_link_to('shifttypes'));
|
redirect(page_link_to('shifttypes'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$shifttype = ShiftType($_REQUEST['shifttype_id']);
|
$shifttype = ShiftType($_REQUEST['shifttype_id']);
|
||||||
if ($shifttype === false) {
|
if ($shifttype === false) {
|
||||||
engelsystem_error('Unable to load shifttype.');
|
engelsystem_error('Unable to load shifttype.');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($shifttype == null) {
|
if ($shifttype == null) {
|
||||||
redirect(page_link_to('shifttypes'));
|
redirect(page_link_to('shifttypes'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_REQUEST['confirmed'])) {
|
if (isset($_REQUEST['confirmed'])) {
|
||||||
$result = ShiftType_delete($shifttype['id']);
|
$result = ShiftType_delete($shifttype['id']);
|
||||||
if ($result === false) {
|
if ($result === false) {
|
||||||
engelsystem_error('Unable to delete shifttype.');
|
engelsystem_error('Unable to delete shifttype.');
|
||||||
}
|
}
|
||||||
|
|
||||||
engelsystem_log('Deleted shifttype ' . $shifttype['name']);
|
engelsystem_log('Deleted shifttype ' . $shifttype['name']);
|
||||||
success(sprintf(_('Shifttype %s deleted.'), $shifttype['name']));
|
success(sprintf(_('Shifttype %s deleted.'), $shifttype['name']));
|
||||||
redirect(page_link_to('shifttypes'));
|
redirect(page_link_to('shifttypes'));
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
sprintf(_("Delete shifttype %s"), $shifttype['name']),
|
sprintf(_("Delete shifttype %s"), $shifttype['name']),
|
||||||
ShiftType_delete_view($shifttype)
|
ShiftType_delete_view($shifttype)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -49,9 +49,9 @@ function shifttype_edit_controller()
|
||||||
$name = "";
|
$name = "";
|
||||||
$angeltype_id = null;
|
$angeltype_id = null;
|
||||||
$description = "";
|
$description = "";
|
||||||
|
|
||||||
$angeltypes = AngelTypes();
|
$angeltypes = AngelTypes();
|
||||||
|
|
||||||
if (isset($_REQUEST['shifttype_id'])) {
|
if (isset($_REQUEST['shifttype_id'])) {
|
||||||
$shifttype = ShiftType($_REQUEST['shifttype_id']);
|
$shifttype = ShiftType($_REQUEST['shifttype_id']);
|
||||||
if ($shifttype === false) {
|
if ($shifttype === false) {
|
||||||
|
@ -66,27 +66,27 @@ function shifttype_edit_controller()
|
||||||
$angeltype_id = $shifttype['angeltype_id'];
|
$angeltype_id = $shifttype['angeltype_id'];
|
||||||
$description = $shifttype['description'];
|
$description = $shifttype['description'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_REQUEST['submit'])) {
|
if (isset($_REQUEST['submit'])) {
|
||||||
$valid = true;
|
$valid = true;
|
||||||
|
|
||||||
if (isset($_REQUEST['name']) && $_REQUEST['name'] != '') {
|
if (isset($_REQUEST['name']) && $_REQUEST['name'] != '') {
|
||||||
$name = strip_request_item('name');
|
$name = strip_request_item('name');
|
||||||
} else {
|
} else {
|
||||||
$valid = false;
|
$valid = false;
|
||||||
error(_('Please enter a name.'));
|
error(_('Please enter a name.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_REQUEST['angeltype_id']) && preg_match("/^[0-9]+$/", $_REQUEST['angeltype_id'])) {
|
if (isset($_REQUEST['angeltype_id']) && preg_match("/^[0-9]+$/", $_REQUEST['angeltype_id'])) {
|
||||||
$angeltype_id = $_REQUEST['angeltype_id'];
|
$angeltype_id = $_REQUEST['angeltype_id'];
|
||||||
} else {
|
} else {
|
||||||
$angeltype_id = null;
|
$angeltype_id = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_REQUEST['description'])) {
|
if (isset($_REQUEST['description'])) {
|
||||||
$description = strip_request_item_nl('description');
|
$description = strip_request_item_nl('description');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($valid) {
|
if ($valid) {
|
||||||
if ($shifttype_id) {
|
if ($shifttype_id) {
|
||||||
$result = ShiftType_update($shifttype_id, $name, $angeltype_id, $description);
|
$result = ShiftType_update($shifttype_id, $name, $angeltype_id, $description);
|
||||||
|
@ -106,16 +106,16 @@ function shifttype_edit_controller()
|
||||||
redirect(page_link_to('shifttypes') . '&action=view&shifttype_id=' . $shifttype_id);
|
redirect(page_link_to('shifttypes') . '&action=view&shifttype_id=' . $shifttype_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
shifttypes_title(),
|
shifttypes_title(),
|
||||||
ShiftType_edit_view($name, $angeltype_id, $angeltypes, $description, $shifttype_id)
|
ShiftType_edit_view($name, $angeltype_id, $angeltypes, $description, $shifttype_id)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
function shifttype_controller()
|
function shifttype_controller()
|
||||||
{
|
{
|
||||||
if (! isset($_REQUEST['shifttype_id'])) {
|
if (!isset($_REQUEST['shifttype_id'])) {
|
||||||
redirect(page_link_to('shifttypes'));
|
redirect(page_link_to('shifttypes'));
|
||||||
}
|
}
|
||||||
$shifttype = ShiftType($_REQUEST['shifttype_id']);
|
$shifttype = ShiftType($_REQUEST['shifttype_id']);
|
||||||
|
@ -125,16 +125,16 @@ function shifttype_controller()
|
||||||
if ($shifttype == null) {
|
if ($shifttype == null) {
|
||||||
redirect(page_link_to('shifttypes'));
|
redirect(page_link_to('shifttypes'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$angeltype = null;
|
$angeltype = null;
|
||||||
if ($shifttype['angeltype_id'] != null) {
|
if ($shifttype['angeltype_id'] != null) {
|
||||||
$angeltype = AngelType($shifttype['angeltype_id']);
|
$angeltype = AngelType($shifttype['angeltype_id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
$shifttype['name'],
|
$shifttype['name'],
|
||||||
ShiftType_view($shifttype, $angeltype)
|
ShiftType_view($shifttype, $angeltype)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -146,11 +146,11 @@ function shifttypes_list_controller()
|
||||||
if ($shifttypes === false) {
|
if ($shifttypes === false) {
|
||||||
engelsystem_error("Unable to load shifttypes.");
|
engelsystem_error("Unable to load shifttypes.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
shifttypes_title(),
|
shifttypes_title(),
|
||||||
ShiftTypes_list_view($shifttypes)
|
ShiftTypes_list_view($shifttypes)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -166,19 +166,19 @@ function shifttypes_title()
|
||||||
*/
|
*/
|
||||||
function shifttypes_controller()
|
function shifttypes_controller()
|
||||||
{
|
{
|
||||||
if (! isset($_REQUEST['action'])) {
|
if (!isset($_REQUEST['action'])) {
|
||||||
$_REQUEST['action'] = 'list';
|
$_REQUEST['action'] = 'list';
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ($_REQUEST['action']) {
|
switch ($_REQUEST['action']) {
|
||||||
default:
|
default:
|
||||||
case 'list':
|
case 'list':
|
||||||
return shifttypes_list_controller();
|
return shifttypes_list_controller();
|
||||||
case 'view':
|
case 'view':
|
||||||
return shifttype_controller();
|
return shifttype_controller();
|
||||||
case 'edit':
|
case 'edit':
|
||||||
return shifttype_edit_controller();
|
return shifttype_edit_controller();
|
||||||
case 'delete':
|
case 'delete':
|
||||||
return shifttype_delete_controller();
|
return shifttype_delete_controller();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,18 +6,21 @@
|
||||||
function user_angeltypes_unconfirmed_hint()
|
function user_angeltypes_unconfirmed_hint()
|
||||||
{
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
$unconfirmed_user_angeltypes = User_unconfirmed_AngelTypes($user);
|
$unconfirmed_user_angeltypes = User_unconfirmed_AngelTypes($user);
|
||||||
if (count($unconfirmed_user_angeltypes) == 0) {
|
if (count($unconfirmed_user_angeltypes) == 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$unconfirmed_links = [];
|
$unconfirmed_links = [];
|
||||||
foreach ($unconfirmed_user_angeltypes as $user_angeltype) {
|
foreach ($unconfirmed_user_angeltypes as $user_angeltype) {
|
||||||
$unconfirmed_links[] = '<a href="' . page_link_to('angeltypes') . '&action=view&angeltype_id=' . $user_angeltype['angeltype_id'] . '">' . $user_angeltype['name'] . ' (+' . $user_angeltype['count'] . ')' . '</a>';
|
$unconfirmed_links[] = '<a href="' . page_link_to('angeltypes') . '&action=view&angeltype_id=' . $user_angeltype['angeltype_id'] . '">' . $user_angeltype['name'] . ' (+' . $user_angeltype['count'] . ')' . '</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
return sprintf(ngettext("There is %d unconfirmed angeltype.", "There are %d unconfirmed angeltypes.", count($unconfirmed_user_angeltypes)), count($unconfirmed_user_angeltypes)) . " " . _('Angel types which need approvals:') . ' ' . join(', ', $unconfirmed_links);
|
return sprintf(ngettext("There is %d unconfirmed angeltype.", "There are %d unconfirmed angeltypes.",
|
||||||
|
count($unconfirmed_user_angeltypes)),
|
||||||
|
count($unconfirmed_user_angeltypes)) . " " . _('Angel types which need approvals:') . ' ' . join(', ',
|
||||||
|
$unconfirmed_links);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -26,35 +29,35 @@ function user_angeltypes_unconfirmed_hint()
|
||||||
function user_angeltypes_delete_all_controller()
|
function user_angeltypes_delete_all_controller()
|
||||||
{
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
if (! isset($_REQUEST['angeltype_id'])) {
|
if (!isset($_REQUEST['angeltype_id'])) {
|
||||||
error(_("Angeltype doesn't exist."));
|
error(_("Angeltype doesn't exist."));
|
||||||
redirect(page_link_to('angeltypes'));
|
redirect(page_link_to('angeltypes'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$angeltype = AngelType($_REQUEST['angeltype_id']);
|
$angeltype = AngelType($_REQUEST['angeltype_id']);
|
||||||
if ($angeltype == null) {
|
if ($angeltype == null) {
|
||||||
error(_("Angeltype doesn't exist."));
|
error(_("Angeltype doesn't exist."));
|
||||||
redirect(page_link_to('angeltypes'));
|
redirect(page_link_to('angeltypes'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! User_is_AngelType_supporter($user, $angeltype)) {
|
if (!User_is_AngelType_supporter($user, $angeltype)) {
|
||||||
error(_("You are not allowed to delete all users for this angeltype."));
|
error(_("You are not allowed to delete all users for this angeltype."));
|
||||||
redirect(page_link_to('angeltypes'));
|
redirect(page_link_to('angeltypes'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_REQUEST['confirmed'])) {
|
if (isset($_REQUEST['confirmed'])) {
|
||||||
UserAngelTypes_delete_all($angeltype['id']);
|
UserAngelTypes_delete_all($angeltype['id']);
|
||||||
|
|
||||||
engelsystem_log(sprintf("Denied all users for angeltype %s", AngelType_name_render($angeltype)));
|
engelsystem_log(sprintf("Denied all users for angeltype %s", AngelType_name_render($angeltype)));
|
||||||
success(sprintf(_("Denied all users for angeltype %s."), AngelType_name_render($angeltype)));
|
success(sprintf(_("Denied all users for angeltype %s."), AngelType_name_render($angeltype)));
|
||||||
redirect(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id']);
|
redirect(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
_("Deny all users"),
|
_("Deny all users"),
|
||||||
UserAngelTypes_delete_all_view($angeltype)
|
UserAngelTypes_delete_all_view($angeltype)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -63,41 +66,41 @@ function user_angeltypes_delete_all_controller()
|
||||||
function user_angeltypes_confirm_all_controller()
|
function user_angeltypes_confirm_all_controller()
|
||||||
{
|
{
|
||||||
global $user, $privileges;
|
global $user, $privileges;
|
||||||
|
|
||||||
if (! isset($_REQUEST['angeltype_id'])) {
|
if (!isset($_REQUEST['angeltype_id'])) {
|
||||||
error(_("Angeltype doesn't exist."));
|
error(_("Angeltype doesn't exist."));
|
||||||
redirect(page_link_to('angeltypes'));
|
redirect(page_link_to('angeltypes'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$angeltype = AngelType($_REQUEST['angeltype_id']);
|
$angeltype = AngelType($_REQUEST['angeltype_id']);
|
||||||
if ($angeltype == null) {
|
if ($angeltype == null) {
|
||||||
error(_("Angeltype doesn't exist."));
|
error(_("Angeltype doesn't exist."));
|
||||||
redirect(page_link_to('angeltypes'));
|
redirect(page_link_to('angeltypes'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$user_angeltype = UserAngelType_by_User_and_AngelType($user, $angeltype);
|
$user_angeltype = UserAngelType_by_User_and_AngelType($user, $angeltype);
|
||||||
if ($user_angeltype == null) {
|
if ($user_angeltype == null) {
|
||||||
error(_("User angeltype doesn't exist."));
|
error(_("User angeltype doesn't exist."));
|
||||||
redirect(page_link_to('angeltypes'));
|
redirect(page_link_to('angeltypes'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! in_array('admin_user_angeltypes', $privileges) && ! $user_angeltype['supporter']) {
|
if (!in_array('admin_user_angeltypes', $privileges) && !$user_angeltype['supporter']) {
|
||||||
error(_("You are not allowed to confirm all users for this angeltype."));
|
error(_("You are not allowed to confirm all users for this angeltype."));
|
||||||
redirect(page_link_to('angeltypes'));
|
redirect(page_link_to('angeltypes'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_REQUEST['confirmed'])) {
|
if (isset($_REQUEST['confirmed'])) {
|
||||||
UserAngelTypes_confirm_all($angeltype['id'], $user);
|
UserAngelTypes_confirm_all($angeltype['id'], $user);
|
||||||
|
|
||||||
engelsystem_log(sprintf("Confirmed all users for angeltype %s", AngelType_name_render($angeltype)));
|
engelsystem_log(sprintf("Confirmed all users for angeltype %s", AngelType_name_render($angeltype)));
|
||||||
success(sprintf(_("Confirmed all users for angeltype %s."), AngelType_name_render($angeltype)));
|
success(sprintf(_("Confirmed all users for angeltype %s."), AngelType_name_render($angeltype)));
|
||||||
redirect(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id']);
|
redirect(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
_("Confirm all users"),
|
_("Confirm all users"),
|
||||||
UserAngelTypes_confirm_all_view($angeltype)
|
UserAngelTypes_confirm_all_view($angeltype)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -106,50 +109,58 @@ function user_angeltypes_confirm_all_controller()
|
||||||
function user_angeltype_confirm_controller()
|
function user_angeltype_confirm_controller()
|
||||||
{
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
if (! isset($_REQUEST['user_angeltype_id'])) {
|
if (!isset($_REQUEST['user_angeltype_id'])) {
|
||||||
error(_("User angeltype doesn't exist."));
|
error(_("User angeltype doesn't exist."));
|
||||||
redirect(page_link_to('angeltypes'));
|
redirect(page_link_to('angeltypes'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$user_angeltype = UserAngelType($_REQUEST['user_angeltype_id']);
|
$user_angeltype = UserAngelType($_REQUEST['user_angeltype_id']);
|
||||||
if ($user_angeltype == null) {
|
if ($user_angeltype == null) {
|
||||||
error(_("User angeltype doesn't exist."));
|
error(_("User angeltype doesn't exist."));
|
||||||
redirect(page_link_to('angeltypes'));
|
redirect(page_link_to('angeltypes'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$angeltype = AngelType($user_angeltype['angeltype_id']);
|
$angeltype = AngelType($user_angeltype['angeltype_id']);
|
||||||
if ($angeltype == null) {
|
if ($angeltype == null) {
|
||||||
error(_("Angeltype doesn't exist."));
|
error(_("Angeltype doesn't exist."));
|
||||||
redirect(page_link_to('angeltypes'));
|
redirect(page_link_to('angeltypes'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! User_is_AngelType_supporter($user, $angeltype)) {
|
if (!User_is_AngelType_supporter($user, $angeltype)) {
|
||||||
error(_("You are not allowed to confirm this users angeltype."));
|
error(_("You are not allowed to confirm this users angeltype."));
|
||||||
redirect(page_link_to('angeltypes'));
|
redirect(page_link_to('angeltypes'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$user_source = User($user_angeltype['user_id']);
|
$user_source = User($user_angeltype['user_id']);
|
||||||
if ($user_source == null) {
|
if ($user_source == null) {
|
||||||
error(_("User doesn't exist."));
|
error(_("User doesn't exist."));
|
||||||
redirect(page_link_to('angeltypes'));
|
redirect(page_link_to('angeltypes'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_REQUEST['confirmed'])) {
|
if (isset($_REQUEST['confirmed'])) {
|
||||||
$result = UserAngelType_confirm($user_angeltype['id'], $user);
|
$result = UserAngelType_confirm($user_angeltype['id'], $user);
|
||||||
if ($result === false) {
|
if ($result === false) {
|
||||||
engelsystem_error("Unable to confirm user angeltype.");
|
engelsystem_error("Unable to confirm user angeltype.");
|
||||||
}
|
}
|
||||||
|
|
||||||
engelsystem_log(sprintf("%s confirmed for angeltype %s", User_Nick_render($user_source), AngelType_name_render($angeltype)));
|
engelsystem_log(sprintf(
|
||||||
success(sprintf(_("%s confirmed for angeltype %s."), User_Nick_render($user_source), AngelType_name_render($angeltype)));
|
"%s confirmed for angeltype %s",
|
||||||
|
User_Nick_render($user_source),
|
||||||
|
AngelType_name_render($angeltype)
|
||||||
|
));
|
||||||
|
success(sprintf(
|
||||||
|
_("%s confirmed for angeltype %s."),
|
||||||
|
User_Nick_render($user_source),
|
||||||
|
AngelType_name_render($angeltype)
|
||||||
|
));
|
||||||
redirect(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id']);
|
redirect(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
_("Confirm angeltype for user"),
|
_("Confirm angeltype for user"),
|
||||||
UserAngelType_confirm_view($user_angeltype, $user_source, $angeltype)
|
UserAngelType_confirm_view($user_angeltype, $user_source, $angeltype)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -158,52 +169,52 @@ function user_angeltype_confirm_controller()
|
||||||
function user_angeltype_delete_controller()
|
function user_angeltype_delete_controller()
|
||||||
{
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
if (! isset($_REQUEST['user_angeltype_id'])) {
|
if (!isset($_REQUEST['user_angeltype_id'])) {
|
||||||
error(_("User angeltype doesn't exist."));
|
error(_("User angeltype doesn't exist."));
|
||||||
redirect(page_link_to('angeltypes'));
|
redirect(page_link_to('angeltypes'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$user_angeltype = UserAngelType($_REQUEST['user_angeltype_id']);
|
$user_angeltype = UserAngelType($_REQUEST['user_angeltype_id']);
|
||||||
if ($user_angeltype == null) {
|
if ($user_angeltype == null) {
|
||||||
error(_("User angeltype doesn't exist."));
|
error(_("User angeltype doesn't exist."));
|
||||||
redirect(page_link_to('angeltypes'));
|
redirect(page_link_to('angeltypes'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$angeltype = AngelType($user_angeltype['angeltype_id']);
|
$angeltype = AngelType($user_angeltype['angeltype_id']);
|
||||||
if ($angeltype == null) {
|
if ($angeltype == null) {
|
||||||
error(_("Angeltype doesn't exist."));
|
error(_("Angeltype doesn't exist."));
|
||||||
redirect(page_link_to('angeltypes'));
|
redirect(page_link_to('angeltypes'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$user_source = User($user_angeltype['user_id']);
|
$user_source = User($user_angeltype['user_id']);
|
||||||
if ($user_source == null) {
|
if ($user_source == null) {
|
||||||
error(_("User doesn't exist."));
|
error(_("User doesn't exist."));
|
||||||
redirect(page_link_to('angeltypes'));
|
redirect(page_link_to('angeltypes'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($user['UID'] != $user_angeltype['user_id'] && ! User_is_AngelType_supporter($user, $angeltype)) {
|
if ($user['UID'] != $user_angeltype['user_id'] && !User_is_AngelType_supporter($user, $angeltype)) {
|
||||||
error(_("You are not allowed to delete this users angeltype."));
|
error(_("You are not allowed to delete this users angeltype."));
|
||||||
redirect(page_link_to('angeltypes'));
|
redirect(page_link_to('angeltypes'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_REQUEST['confirmed'])) {
|
if (isset($_REQUEST['confirmed'])) {
|
||||||
$result = UserAngelType_delete($user_angeltype);
|
$result = UserAngelType_delete($user_angeltype);
|
||||||
if ($result === false) {
|
if ($result === false) {
|
||||||
engelsystem_error("Unable to delete user angeltype.");
|
engelsystem_error("Unable to delete user angeltype.");
|
||||||
}
|
}
|
||||||
|
|
||||||
$success_message = sprintf(_("User %s removed from %s."), User_Nick_render($user_source), $angeltype['name']);
|
$success_message = sprintf(_("User %s removed from %s."), User_Nick_render($user_source), $angeltype['name']);
|
||||||
engelsystem_log($success_message);
|
engelsystem_log($success_message);
|
||||||
success($success_message);
|
success($success_message);
|
||||||
|
|
||||||
redirect(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id']);
|
redirect(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
_("Remove angeltype"),
|
_("Remove angeltype"),
|
||||||
UserAngelType_delete_view($user_angeltype, $user_source, $angeltype)
|
UserAngelType_delete_view($user_angeltype, $user_source, $angeltype)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -212,56 +223,60 @@ function user_angeltype_delete_controller()
|
||||||
function user_angeltype_update_controller()
|
function user_angeltype_update_controller()
|
||||||
{
|
{
|
||||||
global $privileges;
|
global $privileges;
|
||||||
|
|
||||||
if (! in_array('admin_angel_types', $privileges)) {
|
if (!in_array('admin_angel_types', $privileges)) {
|
||||||
error(_("You are not allowed to set supporter rights."));
|
error(_("You are not allowed to set supporter rights."));
|
||||||
redirect(page_link_to('angeltypes'));
|
redirect(page_link_to('angeltypes'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! isset($_REQUEST['user_angeltype_id'])) {
|
if (!isset($_REQUEST['user_angeltype_id'])) {
|
||||||
error(_("User angeltype doesn't exist."));
|
error(_("User angeltype doesn't exist."));
|
||||||
redirect(page_link_to('angeltypes'));
|
redirect(page_link_to('angeltypes'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_REQUEST['supporter']) && preg_match("/^[01]$/", $_REQUEST['supporter'])) {
|
if (isset($_REQUEST['supporter']) && preg_match("/^[01]$/", $_REQUEST['supporter'])) {
|
||||||
$supporter = $_REQUEST['supporter'] == "1";
|
$supporter = $_REQUEST['supporter'] == "1";
|
||||||
} else {
|
} else {
|
||||||
error(_("No supporter update given."));
|
error(_("No supporter update given."));
|
||||||
redirect(page_link_to('angeltypes'));
|
redirect(page_link_to('angeltypes'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$user_angeltype = UserAngelType($_REQUEST['user_angeltype_id']);
|
$user_angeltype = UserAngelType($_REQUEST['user_angeltype_id']);
|
||||||
if ($user_angeltype == null) {
|
if ($user_angeltype == null) {
|
||||||
error(_("User angeltype doesn't exist."));
|
error(_("User angeltype doesn't exist."));
|
||||||
redirect(page_link_to('angeltypes'));
|
redirect(page_link_to('angeltypes'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$angeltype = AngelType($user_angeltype['angeltype_id']);
|
$angeltype = AngelType($user_angeltype['angeltype_id']);
|
||||||
if ($angeltype == null) {
|
if ($angeltype == null) {
|
||||||
error(_("Angeltype doesn't exist."));
|
error(_("Angeltype doesn't exist."));
|
||||||
redirect(page_link_to('angeltypes'));
|
redirect(page_link_to('angeltypes'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$user_source = User($user_angeltype['user_id']);
|
$user_source = User($user_angeltype['user_id']);
|
||||||
if ($user_source == null) {
|
if ($user_source == null) {
|
||||||
error(_("User doesn't exist."));
|
error(_("User doesn't exist."));
|
||||||
redirect(page_link_to('angeltypes'));
|
redirect(page_link_to('angeltypes'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_REQUEST['confirmed'])) {
|
if (isset($_REQUEST['confirmed'])) {
|
||||||
UserAngelType_update($user_angeltype['id'], $supporter);
|
UserAngelType_update($user_angeltype['id'], $supporter);
|
||||||
|
|
||||||
$success_message = sprintf($supporter ? _("Added supporter rights for %s to %s.") : _("Removed supporter rights for %s from %s."), AngelType_name_render($angeltype), User_Nick_render($user_source));
|
$success_message = sprintf(
|
||||||
|
$supporter ? _("Added supporter rights for %s to %s.") : _("Removed supporter rights for %s from %s."),
|
||||||
|
AngelType_name_render($angeltype),
|
||||||
|
User_Nick_render($user_source)
|
||||||
|
);
|
||||||
engelsystem_log($success_message);
|
engelsystem_log($success_message);
|
||||||
success($success_message);
|
success($success_message);
|
||||||
|
|
||||||
redirect(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id']);
|
redirect(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
$supporter ? _("Add supporter rights") : _("Remove supporter rights"),
|
$supporter ? _("Add supporter rights") : _("Remove supporter rights"),
|
||||||
UserAngelType_update_view($user_angeltype, $user_source, $angeltype, $supporter)
|
UserAngelType_update_view($user_angeltype, $user_source, $angeltype, $supporter)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -270,42 +285,54 @@ function user_angeltype_update_controller()
|
||||||
function user_angeltype_add_controller()
|
function user_angeltype_add_controller()
|
||||||
{
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
$angeltype = load_angeltype();
|
$angeltype = load_angeltype();
|
||||||
|
|
||||||
// User is joining by itself
|
// User is joining by itself
|
||||||
if (! User_is_AngelType_supporter($user, $angeltype)) {
|
if (!User_is_AngelType_supporter($user, $angeltype)) {
|
||||||
return user_angeltype_join_controller($angeltype);
|
return user_angeltype_join_controller($angeltype);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allow to add any user
|
// Allow to add any user
|
||||||
|
|
||||||
// Default selection
|
// Default selection
|
||||||
$user_source = $user;
|
$user_source = $user;
|
||||||
|
|
||||||
// Load possible users, that are not in the angeltype already
|
// Load possible users, that are not in the angeltype already
|
||||||
$users_source = Users_by_angeltype_inverted($angeltype);
|
$users_source = Users_by_angeltype_inverted($angeltype);
|
||||||
|
|
||||||
if (isset($_REQUEST['submit'])) {
|
if (isset($_REQUEST['submit'])) {
|
||||||
$user_source = load_user();
|
$user_source = load_user();
|
||||||
|
|
||||||
if (! UserAngelType_exists($user_source, $angeltype)) {
|
if (!UserAngelType_exists($user_source, $angeltype)) {
|
||||||
$user_angeltype_id = UserAngelType_create($user_source, $angeltype);
|
$user_angeltype_id = UserAngelType_create($user_source, $angeltype);
|
||||||
|
|
||||||
engelsystem_log(sprintf("User %s added to %s.", User_Nick_render($user_source), AngelType_name_render($angeltype)));
|
engelsystem_log(sprintf(
|
||||||
success(sprintf(_("User %s added to %s."), User_Nick_render($user_source), AngelType_name_render($angeltype)));
|
"User %s added to %s.",
|
||||||
|
User_Nick_render($user_source),
|
||||||
|
AngelType_name_render($angeltype)
|
||||||
|
));
|
||||||
|
success(sprintf(
|
||||||
|
_("User %s added to %s."),
|
||||||
|
User_Nick_render($user_source),
|
||||||
|
AngelType_name_render($angeltype)
|
||||||
|
));
|
||||||
|
|
||||||
UserAngelType_confirm($user_angeltype_id, $user_source);
|
UserAngelType_confirm($user_angeltype_id, $user_source);
|
||||||
engelsystem_log(sprintf("User %s confirmed as %s.", User_Nick_render($user), AngelType_name_render($angeltype)));
|
engelsystem_log(sprintf(
|
||||||
|
"User %s confirmed as %s.",
|
||||||
|
User_Nick_render($user),
|
||||||
|
AngelType_name_render($angeltype)
|
||||||
|
));
|
||||||
|
|
||||||
redirect(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id']);
|
redirect(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
_("Add user to angeltype"),
|
_("Add user to angeltype"),
|
||||||
UserAngelType_add_view($angeltype, $users_source, $user_source['UID'])
|
UserAngelType_add_view($angeltype, $users_source, $user_source['UID'])
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -314,32 +341,36 @@ function user_angeltype_add_controller()
|
||||||
function user_angeltype_join_controller($angeltype)
|
function user_angeltype_join_controller($angeltype)
|
||||||
{
|
{
|
||||||
global $user, $privileges;
|
global $user, $privileges;
|
||||||
|
|
||||||
$user_angeltype = UserAngelType_by_User_and_AngelType($user, $angeltype);
|
$user_angeltype = UserAngelType_by_User_and_AngelType($user, $angeltype);
|
||||||
if ($user_angeltype != null) {
|
if ($user_angeltype != null) {
|
||||||
error(sprintf(_("You are already a %s."), $angeltype['name']));
|
error(sprintf(_("You are already a %s."), $angeltype['name']));
|
||||||
redirect(page_link_to('angeltypes'));
|
redirect(page_link_to('angeltypes'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_REQUEST['confirmed'])) {
|
if (isset($_REQUEST['confirmed'])) {
|
||||||
$user_angeltype_id = UserAngelType_create($user, $angeltype);
|
$user_angeltype_id = UserAngelType_create($user, $angeltype);
|
||||||
|
|
||||||
$success_message = sprintf(_("You joined %s."), $angeltype['name']);
|
$success_message = sprintf(_("You joined %s."), $angeltype['name']);
|
||||||
engelsystem_log(sprintf("User %s joined %s.", User_Nick_render($user), AngelType_name_render($angeltype)));
|
engelsystem_log(sprintf("User %s joined %s.", User_Nick_render($user), AngelType_name_render($angeltype)));
|
||||||
success($success_message);
|
success($success_message);
|
||||||
|
|
||||||
if (in_array('admin_user_angeltypes', $privileges)) {
|
if (in_array('admin_user_angeltypes', $privileges)) {
|
||||||
UserAngelType_confirm($user_angeltype_id, $user);
|
UserAngelType_confirm($user_angeltype_id, $user);
|
||||||
engelsystem_log(sprintf("User %s confirmed as %s.", User_Nick_render($user), AngelType_name_render($angeltype)));
|
engelsystem_log(sprintf(
|
||||||
|
"User %s confirmed as %s.",
|
||||||
|
User_Nick_render($user),
|
||||||
|
AngelType_name_render($angeltype)
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
redirect(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id']);
|
redirect(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
sprintf(_("Become a %s"), $angeltype['name']),
|
sprintf(_("Become a %s"), $angeltype['name']),
|
||||||
UserAngelType_join_view($user, $angeltype)
|
UserAngelType_join_view($user, $angeltype)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -347,24 +378,24 @@ function user_angeltype_join_controller($angeltype)
|
||||||
*/
|
*/
|
||||||
function user_angeltypes_controller()
|
function user_angeltypes_controller()
|
||||||
{
|
{
|
||||||
if (! isset($_REQUEST['action'])) {
|
if (!isset($_REQUEST['action'])) {
|
||||||
redirect(page_link_to('angeltypes'));
|
redirect(page_link_to('angeltypes'));
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ($_REQUEST['action']) {
|
switch ($_REQUEST['action']) {
|
||||||
case 'delete_all':
|
case 'delete_all':
|
||||||
return user_angeltypes_delete_all_controller();
|
return user_angeltypes_delete_all_controller();
|
||||||
case 'confirm_all':
|
case 'confirm_all':
|
||||||
return user_angeltypes_confirm_all_controller();
|
return user_angeltypes_confirm_all_controller();
|
||||||
case 'confirm':
|
case 'confirm':
|
||||||
return user_angeltype_confirm_controller();
|
return user_angeltype_confirm_controller();
|
||||||
case 'delete':
|
case 'delete':
|
||||||
return user_angeltype_delete_controller();
|
return user_angeltype_delete_controller();
|
||||||
case 'update':
|
case 'update':
|
||||||
return user_angeltype_update_controller();
|
return user_angeltype_update_controller();
|
||||||
case 'add':
|
case 'add':
|
||||||
return user_angeltype_add_controller();
|
return user_angeltype_add_controller();
|
||||||
default:
|
default:
|
||||||
redirect(page_link_to('angeltypes'));
|
redirect(page_link_to('angeltypes'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,26 +1,30 @@
|
||||||
<?php
|
<?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.
|
||||||
*/
|
*/
|
||||||
function user_driver_license_required_hint()
|
function user_driver_license_required_hint()
|
||||||
{
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
$angeltypes = User_angeltypes($user);
|
$angeltypes = User_angeltypes($user);
|
||||||
$user_driver_license = UserDriverLicense($user['UID']);
|
$user_driver_license = UserDriverLicense($user['UID']);
|
||||||
|
|
||||||
// User has already entered data, no hint needed.
|
// User has already entered data, no hint needed.
|
||||||
if ($user_driver_license != null) {
|
if ($user_driver_license != null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($angeltypes as $angeltype) {
|
foreach ($angeltypes as $angeltype) {
|
||||||
if ($angeltype['requires_driver_license']) {
|
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 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;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,18 +34,18 @@ function user_driver_license_required_hint()
|
||||||
function user_driver_licenses_controller()
|
function user_driver_licenses_controller()
|
||||||
{
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
if (! isset($user)) {
|
if (!isset($user)) {
|
||||||
redirect(page_link_to(''));
|
redirect(page_link_to(''));
|
||||||
}
|
}
|
||||||
|
|
||||||
$action = strip_request_item('action', 'edit');
|
$action = strip_request_item('action', 'edit');
|
||||||
|
|
||||||
switch ($action) {
|
switch ($action) {
|
||||||
default:
|
default:
|
||||||
case 'edit':
|
case 'edit':
|
||||||
return user_driver_license_edit_controller();
|
return user_driver_license_edit_controller();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -63,16 +67,16 @@ function user_driver_license_edit_link($user = null)
|
||||||
function user_driver_license_load_user()
|
function user_driver_license_load_user()
|
||||||
{
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
$user_source = $user;
|
$user_source = $user;
|
||||||
|
|
||||||
if (isset($_REQUEST['user_id'])) {
|
if (isset($_REQUEST['user_id'])) {
|
||||||
$user_source = User($_REQUEST['user_id']);
|
$user_source = User($_REQUEST['user_id']);
|
||||||
if ($user_source == null) {
|
if ($user_source == null) {
|
||||||
redirect(user_driver_license_edit_link());
|
redirect(user_driver_license_edit_link());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $user_source;
|
return $user_source;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,14 +86,14 @@ function user_driver_license_load_user()
|
||||||
function user_driver_license_edit_controller()
|
function user_driver_license_edit_controller()
|
||||||
{
|
{
|
||||||
global $privileges, $user;
|
global $privileges, $user;
|
||||||
|
|
||||||
$user_source = user_driver_license_load_user();
|
$user_source = user_driver_license_load_user();
|
||||||
|
|
||||||
// only privilege admin_user can edit other users driver license information
|
// only privilege admin_user can edit other users driver license information
|
||||||
if ($user['UID'] != $user_source['UID'] && ! in_array('admin_user', $privileges)) {
|
if ($user['UID'] != $user_source['UID'] && !in_array('admin_user', $privileges)) {
|
||||||
redirect(user_driver_license_edit_link());
|
redirect(user_driver_license_edit_link());
|
||||||
}
|
}
|
||||||
|
|
||||||
$user_driver_license = UserDriverLicense($user_source['UID']);
|
$user_driver_license = UserDriverLicense($user_source['UID']);
|
||||||
if ($user_driver_license == null) {
|
if ($user_driver_license == null) {
|
||||||
$wants_to_drive = false;
|
$wants_to_drive = false;
|
||||||
|
@ -97,7 +101,7 @@ function user_driver_license_edit_controller()
|
||||||
} else {
|
} else {
|
||||||
$wants_to_drive = true;
|
$wants_to_drive = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_REQUEST['submit'])) {
|
if (isset($_REQUEST['submit'])) {
|
||||||
$wants_to_drive = isset($_REQUEST['wants_to_drive']);
|
$wants_to_drive = isset($_REQUEST['wants_to_drive']);
|
||||||
if ($wants_to_drive) {
|
if ($wants_to_drive) {
|
||||||
|
@ -107,7 +111,7 @@ function user_driver_license_edit_controller()
|
||||||
$user_driver_license['has_license_7_5t_truck'] = isset($_REQUEST['has_license_7_5t_truck']);
|
$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_12_5t_truck'] = isset($_REQUEST['has_license_12_5t_truck']);
|
||||||
$user_driver_license['has_license_forklift'] = isset($_REQUEST['has_license_forklift']);
|
$user_driver_license['has_license_forklift'] = isset($_REQUEST['has_license_forklift']);
|
||||||
|
|
||||||
if (UserDriverLicense_valid($user_driver_license)) {
|
if (UserDriverLicense_valid($user_driver_license)) {
|
||||||
if ($user_driver_license['user_id'] == null) {
|
if ($user_driver_license['user_id'] == null) {
|
||||||
$user_driver_license = UserDriverLicenses_create($user_driver_license, $user);
|
$user_driver_license = UserDriverLicenses_create($user_driver_license, $user);
|
||||||
|
@ -127,9 +131,9 @@ function user_driver_license_edit_controller()
|
||||||
redirect(user_link($user_source));
|
redirect(user_link($user_source));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
sprintf(_("Edit %s driving license information"), $user_source['Nick']),
|
sprintf(_("Edit %s driving license information"), $user_source['Nick']),
|
||||||
UserDriverLicense_edit_view($user_source, $wants_to_drive, $user_driver_license)
|
UserDriverLicense_edit_view($user_source, $wants_to_drive, $user_driver_license)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
use Engelsystem\ShiftsFilter;
|
|
||||||
use Engelsystem\ShiftCalendarRenderer;
|
use Engelsystem\ShiftCalendarRenderer;
|
||||||
|
use Engelsystem\ShiftsFilter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Route user actions.
|
* Route user actions.
|
||||||
|
@ -8,28 +8,28 @@ use Engelsystem\ShiftCalendarRenderer;
|
||||||
function users_controller()
|
function users_controller()
|
||||||
{
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
if (! isset($user)) {
|
if (!isset($user)) {
|
||||||
redirect(page_link_to(''));
|
redirect(page_link_to(''));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! isset($_REQUEST['action'])) {
|
if (!isset($_REQUEST['action'])) {
|
||||||
$_REQUEST['action'] = 'list';
|
$_REQUEST['action'] = 'list';
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ($_REQUEST['action']) {
|
switch ($_REQUEST['action']) {
|
||||||
default:
|
default:
|
||||||
case 'list':
|
case 'list':
|
||||||
return users_list_controller();
|
return users_list_controller();
|
||||||
case 'view':
|
case 'view':
|
||||||
return user_controller();
|
return user_controller();
|
||||||
case 'edit':
|
case 'edit':
|
||||||
return user_edit_controller();
|
return user_edit_controller();
|
||||||
case 'delete':
|
case 'delete':
|
||||||
return user_delete_controller();
|
return user_delete_controller();
|
||||||
case 'edit_vouchers':
|
case 'edit_vouchers':
|
||||||
return user_edit_vouchers_controller();
|
return user_edit_vouchers_controller();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -38,49 +38,51 @@ function users_controller()
|
||||||
function user_delete_controller()
|
function user_delete_controller()
|
||||||
{
|
{
|
||||||
global $privileges, $user;
|
global $privileges, $user;
|
||||||
|
|
||||||
if (isset($_REQUEST['user_id'])) {
|
if (isset($_REQUEST['user_id'])) {
|
||||||
$user_source = User($_REQUEST['user_id']);
|
$user_source = User($_REQUEST['user_id']);
|
||||||
} else {
|
} else {
|
||||||
$user_source = $user;
|
$user_source = $user;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! in_array('admin_user', $privileges)) {
|
if (!in_array('admin_user', $privileges)) {
|
||||||
redirect(page_link_to(''));
|
redirect(page_link_to(''));
|
||||||
}
|
}
|
||||||
|
|
||||||
// You cannot delete yourself
|
// You cannot delete yourself
|
||||||
if ($user['UID'] == $user_source['UID']) {
|
if ($user['UID'] == $user_source['UID']) {
|
||||||
error(_("You cannot delete yourself."));
|
error(_("You cannot delete yourself."));
|
||||||
redirect(user_link($user));
|
redirect(user_link($user));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_REQUEST['submit'])) {
|
if (isset($_REQUEST['submit'])) {
|
||||||
$valid = true;
|
$valid = true;
|
||||||
|
|
||||||
if (! (isset($_REQUEST['password']) && verify_password($_REQUEST['password'], $user['Passwort'], $user['UID']))) {
|
if (!(isset($_REQUEST['password']) && verify_password($_REQUEST['password'], $user['Passwort'],
|
||||||
|
$user['UID']))
|
||||||
|
) {
|
||||||
$valid = false;
|
$valid = false;
|
||||||
error(_("Your password is incorrect. Please try it again."));
|
error(_("Your password is incorrect. Please try it again."));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($valid) {
|
if ($valid) {
|
||||||
$result = User_delete($user_source['UID']);
|
$result = User_delete($user_source['UID']);
|
||||||
if ($result === false) {
|
if ($result === false) {
|
||||||
engelsystem_error('Unable to delete user.');
|
engelsystem_error('Unable to delete user.');
|
||||||
}
|
}
|
||||||
|
|
||||||
mail_user_delete($user_source);
|
mail_user_delete($user_source);
|
||||||
success(_("User deleted."));
|
success(_("User deleted."));
|
||||||
engelsystem_log(sprintf("Deleted %s", User_Nick_render($user_source)));
|
engelsystem_log(sprintf("Deleted %s", User_Nick_render($user_source)));
|
||||||
|
|
||||||
redirect(users_link());
|
redirect(users_link());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
sprintf(_("Delete %s"), $user_source['Nick']),
|
sprintf(_("Delete %s"), $user_source['Nick']),
|
||||||
User_delete_view($user_source)
|
User_delete_view($user_source)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
function users_link()
|
function users_link()
|
||||||
|
@ -106,52 +108,53 @@ function user_link($user)
|
||||||
function user_edit_vouchers_controller()
|
function user_edit_vouchers_controller()
|
||||||
{
|
{
|
||||||
global $privileges, $user;
|
global $privileges, $user;
|
||||||
|
|
||||||
if (isset($_REQUEST['user_id'])) {
|
if (isset($_REQUEST['user_id'])) {
|
||||||
$user_source = User($_REQUEST['user_id']);
|
$user_source = User($_REQUEST['user_id']);
|
||||||
} else {
|
} else {
|
||||||
$user_source = $user;
|
$user_source = $user;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! in_array('admin_user', $privileges)) {
|
if (!in_array('admin_user', $privileges)) {
|
||||||
redirect(page_link_to(''));
|
redirect(page_link_to(''));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_REQUEST['submit'])) {
|
if (isset($_REQUEST['submit'])) {
|
||||||
$valid = true;
|
$valid = true;
|
||||||
|
|
||||||
if (isset($_REQUEST['vouchers']) && test_request_int('vouchers') && trim($_REQUEST['vouchers']) >= 0) {
|
if (isset($_REQUEST['vouchers']) && test_request_int('vouchers') && trim($_REQUEST['vouchers']) >= 0) {
|
||||||
$vouchers = trim($_REQUEST['vouchers']);
|
$vouchers = trim($_REQUEST['vouchers']);
|
||||||
} else {
|
} else {
|
||||||
$valid = false;
|
$valid = false;
|
||||||
error(_("Please enter a valid number of vouchers."));
|
error(_("Please enter a valid number of vouchers."));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($valid) {
|
if ($valid) {
|
||||||
$user_source['got_voucher'] = $vouchers;
|
$user_source['got_voucher'] = $vouchers;
|
||||||
|
|
||||||
$result = User_update($user_source);
|
$result = User_update($user_source);
|
||||||
if ($result === false) {
|
if ($result === false) {
|
||||||
engelsystem_error('Unable to update user.');
|
engelsystem_error('Unable to update user.');
|
||||||
}
|
}
|
||||||
|
|
||||||
success(_("Saved the number of vouchers."));
|
success(_("Saved the number of vouchers."));
|
||||||
engelsystem_log(User_Nick_render($user_source) . ': ' . sprintf("Got %s vouchers", $user_source['got_voucher']));
|
engelsystem_log(User_Nick_render($user_source) . ': ' . sprintf("Got %s vouchers",
|
||||||
|
$user_source['got_voucher']));
|
||||||
|
|
||||||
redirect(user_link($user_source));
|
redirect(user_link($user_source));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
sprintf(_("%s's vouchers"), $user_source['Nick']),
|
sprintf(_("%s's vouchers"), $user_source['Nick']),
|
||||||
User_edit_vouchers_view($user_source)
|
User_edit_vouchers_view($user_source)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
function user_controller()
|
function user_controller()
|
||||||
{
|
{
|
||||||
global $privileges, $user;
|
global $privileges, $user;
|
||||||
|
|
||||||
$user_source = $user;
|
$user_source = $user;
|
||||||
if (isset($_REQUEST['user_id'])) {
|
if (isset($_REQUEST['user_id'])) {
|
||||||
$user_source = User($_REQUEST['user_id']);
|
$user_source = User($_REQUEST['user_id']);
|
||||||
|
@ -160,11 +163,11 @@ function user_controller()
|
||||||
redirect('?');
|
redirect('?');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$shifts = Shifts_by_user($user_source, in_array("user_shifts_admin", $privileges));
|
$shifts = Shifts_by_user($user_source, in_array("user_shifts_admin", $privileges));
|
||||||
foreach ($shifts as &$shift) {
|
foreach ($shifts as &$shift) {
|
||||||
// TODO: Move queries to model
|
// 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`");
|
$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) {
|
foreach ($shift['needed_angeltypes'] as &$needed_angeltype) {
|
||||||
$needed_angeltype['users'] = sql_select("
|
$needed_angeltype['users'] = sql_select("
|
||||||
SELECT `ShiftEntry`.`freeloaded`, `User`.*
|
SELECT `ShiftEntry`.`freeloaded`, `User`.*
|
||||||
|
@ -174,15 +177,23 @@ function user_controller()
|
||||||
AND `ShiftEntry`.`TID`='" . sql_escape($needed_angeltype['id']) . "'");
|
AND `ShiftEntry`.`TID`='" . sql_escape($needed_angeltype['id']) . "'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($user_source['api_key'] == "") {
|
if ($user_source['api_key'] == "") {
|
||||||
User_reset_api_key($user_source, false);
|
User_reset_api_key($user_source, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
$user_source['Nick'],
|
$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'])
|
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']
|
||||||
|
)
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -191,29 +202,38 @@ function user_controller()
|
||||||
function users_list_controller()
|
function users_list_controller()
|
||||||
{
|
{
|
||||||
global $privileges;
|
global $privileges;
|
||||||
|
|
||||||
if (! in_array('admin_user', $privileges)) {
|
if (!in_array('admin_user', $privileges)) {
|
||||||
redirect(page_link_to(''));
|
redirect(page_link_to(''));
|
||||||
}
|
}
|
||||||
|
|
||||||
$order_by = 'Nick';
|
$order_by = 'Nick';
|
||||||
if (isset($_REQUEST['OrderBy']) && in_array($_REQUEST['OrderBy'], User_sortable_columns())) {
|
if (isset($_REQUEST['OrderBy']) && in_array($_REQUEST['OrderBy'], User_sortable_columns())) {
|
||||||
$order_by = $_REQUEST['OrderBy'];
|
$order_by = $_REQUEST['OrderBy'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$users = Users($order_by);
|
$users = Users($order_by);
|
||||||
if ($users === false) {
|
if ($users === false) {
|
||||||
engelsystem_error('Unable to load users.');
|
engelsystem_error('Unable to load users.');
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($users as &$user) {
|
foreach ($users as &$user) {
|
||||||
$user['freeloads'] = count(ShiftEntries_freeloaded_by_user($user));
|
$user['freeloads'] = count(ShiftEntries_freeloaded_by_user($user));
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
_('All users'),
|
_('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())
|
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()
|
||||||
|
)
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -227,7 +247,7 @@ function user_password_recovery_set_new_controller()
|
||||||
error(_("Token is not correct."));
|
error(_("Token is not correct."));
|
||||||
redirect(page_link_to('login'));
|
redirect(page_link_to('login'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_REQUEST['submit'])) {
|
if (isset($_REQUEST['submit'])) {
|
||||||
$valid = true;
|
$valid = true;
|
||||||
|
|
||||||
|
@ -240,14 +260,14 @@ function user_password_recovery_set_new_controller()
|
||||||
$valid = false;
|
$valid = false;
|
||||||
error(_("Your password is to short (please use at least 6 characters)."));
|
error(_("Your password is to short (please use at least 6 characters)."));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($valid) {
|
if ($valid) {
|
||||||
set_password($user_source['UID'], $_REQUEST['password']);
|
set_password($user_source['UID'], $_REQUEST['password']);
|
||||||
success(_("Password saved."));
|
success(_("Password saved."));
|
||||||
redirect(page_link_to('login'));
|
redirect(page_link_to('login'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return User_password_set_view();
|
return User_password_set_view();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -258,7 +278,7 @@ function user_password_recovery_start_controller()
|
||||||
{
|
{
|
||||||
if (isset($_REQUEST['submit'])) {
|
if (isset($_REQUEST['submit'])) {
|
||||||
$valid = true;
|
$valid = true;
|
||||||
|
|
||||||
if (isset($_REQUEST['email']) && strlen(strip_request_item('email')) > 0) {
|
if (isset($_REQUEST['email']) && strlen(strip_request_item('email')) > 0) {
|
||||||
$email = strip_request_item('email');
|
$email = strip_request_item('email');
|
||||||
if (check_email($email)) {
|
if (check_email($email)) {
|
||||||
|
@ -275,15 +295,22 @@ function user_password_recovery_start_controller()
|
||||||
$valid = false;
|
$valid = false;
|
||||||
error(_("Please enter your e-mail."));
|
error(_("Please enter your e-mail."));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($valid) {
|
if ($valid) {
|
||||||
$token = User_generate_password_recovery_token($user_source);
|
$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));
|
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."));
|
success(_("We sent an email containing your password recovery link."));
|
||||||
redirect(page_link_to('login'));
|
redirect(page_link_to('login'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return User_password_recovery_view();
|
return User_password_recovery_view();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -313,20 +340,20 @@ function user_password_recovery_title()
|
||||||
*/
|
*/
|
||||||
function load_user()
|
function load_user()
|
||||||
{
|
{
|
||||||
if (! isset($_REQUEST['user_id'])) {
|
if (!isset($_REQUEST['user_id'])) {
|
||||||
redirect(page_link_to());
|
redirect(page_link_to());
|
||||||
}
|
}
|
||||||
|
|
||||||
$user = User($_REQUEST['user_id']);
|
$user = User($_REQUEST['user_id']);
|
||||||
if ($user === false) {
|
if ($user === false) {
|
||||||
engelsystem_error("Unable to load user.");
|
engelsystem_error("Unable to load user.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($user == null) {
|
if ($user == null) {
|
||||||
error(_("User doesn't exist."));
|
error(_("User doesn't exist."));
|
||||||
redirect(page_link_to());
|
redirect(page_link_to());
|
||||||
}
|
}
|
||||||
|
|
||||||
return $user;
|
return $user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -335,7 +362,7 @@ function shiftCalendarRendererByShiftFilter(ShiftsFilter $shiftsFilter)
|
||||||
$shifts = Shifts_by_ShiftsFilter($shiftsFilter);
|
$shifts = Shifts_by_ShiftsFilter($shiftsFilter);
|
||||||
$needed_angeltypes_source = NeededAngeltypes_by_ShiftsFilter($shiftsFilter);
|
$needed_angeltypes_source = NeededAngeltypes_by_ShiftsFilter($shiftsFilter);
|
||||||
$shift_entries_source = ShiftEntries_by_ShiftsFilter($shiftsFilter);
|
$shift_entries_source = ShiftEntries_by_ShiftsFilter($shiftsFilter);
|
||||||
|
|
||||||
$needed_angeltypes = [];
|
$needed_angeltypes = [];
|
||||||
$shift_entries = [];
|
$shift_entries = [];
|
||||||
foreach ($shifts as $shift) {
|
foreach ($shifts as $shift) {
|
||||||
|
@ -354,11 +381,14 @@ function shiftCalendarRendererByShiftFilter(ShiftsFilter $shiftsFilter)
|
||||||
}
|
}
|
||||||
unset($needed_angeltypes_source);
|
unset($needed_angeltypes_source);
|
||||||
unset($shift_entries_source);
|
unset($shift_entries_source);
|
||||||
|
|
||||||
if (in_array(ShiftsFilter::FILLED_FREE, $shiftsFilter->getFilled()) && in_array(ShiftsFilter::FILLED_FILLED, $shiftsFilter->getFilled())) {
|
if (
|
||||||
|
in_array(ShiftsFilter::FILLED_FREE, $shiftsFilter->getFilled())
|
||||||
|
&& in_array(ShiftsFilter::FILLED_FILLED, $shiftsFilter->getFilled())
|
||||||
|
) {
|
||||||
return new ShiftCalendarRenderer($shifts, $needed_angeltypes, $shift_entries, $shiftsFilter);
|
return new ShiftCalendarRenderer($shifts, $needed_angeltypes, $shift_entries, $shiftsFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
$filtered_shifts = [];
|
$filtered_shifts = [];
|
||||||
foreach ($shifts as $shift) {
|
foreach ($shifts as $shift) {
|
||||||
$needed_angels_count = 0;
|
$needed_angels_count = 0;
|
||||||
|
@ -366,10 +396,10 @@ function shiftCalendarRendererByShiftFilter(ShiftsFilter $shiftsFilter)
|
||||||
$taken = 0;
|
$taken = 0;
|
||||||
foreach ($shift_entries[$shift['SID']] as $shift_entry) {
|
foreach ($shift_entries[$shift['SID']] as $shift_entry) {
|
||||||
if ($needed_angeltype['angel_type_id'] == $shift_entry['TID'] && $shift_entry['freeloaded'] == 0) {
|
if ($needed_angeltype['angel_type_id'] == $shift_entry['TID'] && $shift_entry['freeloaded'] == 0) {
|
||||||
$taken ++;
|
$taken++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$needed_angels_count += max(0, $needed_angeltype['count'] - $taken);
|
$needed_angels_count += max(0, $needed_angeltype['count'] - $taken);
|
||||||
}
|
}
|
||||||
if (in_array(ShiftsFilter::FILLED_FREE, $shiftsFilter->getFilled()) && $taken < $needed_angels_count) {
|
if (in_array(ShiftsFilter::FILLED_FREE, $shiftsFilter->getFilled()) && $taken < $needed_angels_count) {
|
||||||
|
@ -379,6 +409,6 @@ function shiftCalendarRendererByShiftFilter(ShiftsFilter $shiftsFilter)
|
||||||
$filtered_shifts[] = $shift;
|
$filtered_shifts[] = $shift;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ShiftCalendarRenderer($filtered_shifts, $needed_angeltypes, $shift_entries, $shiftsFilter);
|
return new ShiftCalendarRenderer($filtered_shifts, $needed_angeltypes, $shift_entries, $shiftsFilter);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,22 +3,26 @@
|
||||||
function engelsystem_email_to_user($recipient_user, $title, $message, $not_if_its_me = false)
|
function engelsystem_email_to_user($recipient_user, $title, $message, $not_if_its_me = false)
|
||||||
{
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
if ($not_if_its_me && $user['UID'] == $recipient_user['UID']) {
|
if ($not_if_its_me && $user['UID'] == $recipient_user['UID']) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
gettext_locale($recipient_user['Sprache']);
|
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.");
|
$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();
|
gettext_locale();
|
||||||
return engelsystem_email($recipient_user['email'], $title, $message);
|
return engelsystem_email($recipient_user['email'], $title, $message);
|
||||||
}
|
}
|
||||||
|
|
||||||
function engelsystem_email($address, $title, $message)
|
function engelsystem_email($address, $title, $message)
|
||||||
{
|
{
|
||||||
$result = mail($address, $title, $message, "Content-Type: text/plain; charset=UTF-8\r\nFrom: Engelsystem <noreply@engelsystem.de>");
|
$result = mail($address, $title, $message,
|
||||||
|
"Content-Type: text/plain; charset=UTF-8\r\nFrom: Engelsystem <noreply@engelsystem.de>");
|
||||||
if ($result === false) {
|
if ($result === false) {
|
||||||
engelsystem_error('Unable to send email.');
|
engelsystem_error('Unable to send email.');
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,10 +2,11 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renders a bargraph
|
* Renders a bargraph
|
||||||
* @param string $key keyname of the x-axis
|
*
|
||||||
* @param array $row_names keynames for the data rows
|
* @param string $key keyname of the x-axis
|
||||||
* @param unknown $colors colors for the data rows
|
* @param array $row_names keynames for the data rows
|
||||||
* @param unknown $data the data
|
* @param unknown $colors colors for the data rows
|
||||||
|
* @param unknown $data the data
|
||||||
*/
|
*/
|
||||||
function bargraph($dom_id, $key, $row_names, $colors, $data)
|
function bargraph($dom_id, $key, $row_names, $colors, $data)
|
||||||
{
|
{
|
||||||
|
@ -13,7 +14,7 @@ function bargraph($dom_id, $key, $row_names, $colors, $data)
|
||||||
foreach ($data as $dataset) {
|
foreach ($data as $dataset) {
|
||||||
$labels[] = $dataset[$key];
|
$labels[] = $dataset[$key];
|
||||||
}
|
}
|
||||||
|
|
||||||
$datasets = [];
|
$datasets = [];
|
||||||
foreach ($row_names as $row_key => $name) {
|
foreach ($row_names as $row_key => $name) {
|
||||||
$values = [];
|
$values = [];
|
||||||
|
@ -21,20 +22,20 @@ function bargraph($dom_id, $key, $row_names, $colors, $data)
|
||||||
$values[] = $dataset[$row_key];
|
$values[] = $dataset[$row_key];
|
||||||
}
|
}
|
||||||
$datasets[] = [
|
$datasets[] = [
|
||||||
'label' => $name,
|
'label' => $name,
|
||||||
'fillColor' => $colors[$row_key],
|
'fillColor' => $colors[$row_key],
|
||||||
'data' => $values
|
'data' => $values
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
return '<canvas id="' . $dom_id . '" style="width: 100%; height: 300px;"></canvas>
|
return '<canvas id="' . $dom_id . '" style="width: 100%; height: 300px;"></canvas>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(function(){
|
$(function(){
|
||||||
var ctx = $("#' . $dom_id . '").get(0).getContext("2d");
|
var ctx = $("#' . $dom_id . '").get(0).getContext("2d");
|
||||||
var chart = new Chart(ctx).Bar(' . json_encode([
|
var chart = new Chart(ctx).Bar(' . json_encode([
|
||||||
'labels' => $labels,
|
'labels' => $labels,
|
||||||
'datasets' => $datasets
|
'datasets' => $datasets
|
||||||
]) . ');
|
]) . ');
|
||||||
});
|
});
|
||||||
</script>';
|
</script>';
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ function gettext_init()
|
||||||
|
|
||||||
if (isset($_REQUEST['set_locale']) && isset($locales[$_REQUEST['set_locale']])) {
|
if (isset($_REQUEST['set_locale']) && isset($locales[$_REQUEST['set_locale']])) {
|
||||||
$_SESSION['locale'] = $_REQUEST['set_locale'];
|
$_SESSION['locale'] = $_REQUEST['set_locale'];
|
||||||
} elseif (! isset($_SESSION['locale'])) {
|
} elseif (!isset($_SESSION['locale'])) {
|
||||||
$_SESSION['locale'] = $default_locale;
|
$_SESSION['locale'] = $default_locale;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ function gettext_locale($locale = null)
|
||||||
if ($locale == null) {
|
if ($locale == null) {
|
||||||
$locale = $_SESSION['locale'];
|
$locale = $_SESSION['locale'];
|
||||||
}
|
}
|
||||||
|
|
||||||
putenv('LC_ALL=' . $locale);
|
putenv('LC_ALL=' . $locale);
|
||||||
setlocale(LC_ALL, $locale);
|
setlocale(LC_ALL, $locale);
|
||||||
}
|
}
|
||||||
|
@ -65,10 +65,14 @@ function make_langselect()
|
||||||
{
|
{
|
||||||
global $locales;
|
global $locales;
|
||||||
$URL = $_SERVER["REQUEST_URI"] . (strpos($_SERVER["REQUEST_URI"], "?") > 0 ? '&' : '?') . "set_locale=";
|
$URL = $_SERVER["REQUEST_URI"] . (strpos($_SERVER["REQUEST_URI"], "?") > 0 ? '&' : '?') . "set_locale=";
|
||||||
|
|
||||||
$items = [];
|
$items = [];
|
||||||
foreach ($locales as $locale => $name) {
|
foreach ($locales as $locale => $name) {
|
||||||
$items[] = toolbar_item_link(htmlspecialchars($URL) . $locale, '', '<img src="pic/flag/' . $locale . '.png" alt="' . $name . '" title="' . $name . '"> ' . $name);
|
$items[] = toolbar_item_link(
|
||||||
|
htmlspecialchars($URL) . $locale,
|
||||||
|
'',
|
||||||
|
'<img src="pic/flag/' . $locale . '.png" alt="' . $name . '" title="' . $name . '"> ' . $name
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return $items;
|
return $items;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
function msg()
|
function msg()
|
||||||
{
|
{
|
||||||
if (! isset($_SESSION['msg'])) {
|
if (!isset($_SESSION['msg'])) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
$msg = $_SESSION['msg'];
|
$msg = $_SESSION['msg'];
|
||||||
|
@ -48,8 +48,8 @@ function alert($class, $msg, $immediatly = false)
|
||||||
}
|
}
|
||||||
return '<div class="alert alert-' . $class . '">' . $msg . '</div>';
|
return '<div class="alert alert-' . $class . '">' . $msg . '</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! isset($_SESSION['msg'])) {
|
if (!isset($_SESSION['msg'])) {
|
||||||
$_SESSION['msg'] = "";
|
$_SESSION['msg'] = "";
|
||||||
}
|
}
|
||||||
$_SESSION['msg'] .= alert($class, $msg, true);
|
$_SESSION['msg'] .= alert($class, $msg, true);
|
||||||
|
|
|
@ -5,50 +5,58 @@ function mail_shift_change($old_shift, $new_shift)
|
||||||
$users = ShiftEntries_by_shift($old_shift["SID"]);
|
$users = ShiftEntries_by_shift($old_shift["SID"]);
|
||||||
$old_room = Room($old_shift["RID"]);
|
$old_room = Room($old_shift["RID"]);
|
||||||
$new_room = Room($new_shift["RID"]);
|
$new_room = Room($new_shift["RID"]);
|
||||||
|
|
||||||
$noticable_changes = false;
|
$noticable_changes = false;
|
||||||
|
|
||||||
$message = _("A Shift you are registered on has changed:");
|
$message = _("A Shift you are registered on has changed:");
|
||||||
$message .= "\n";
|
$message .= "\n";
|
||||||
|
|
||||||
if ($old_shift["name"] != $new_shift["name"]) {
|
if ($old_shift["name"] != $new_shift["name"]) {
|
||||||
$message .= sprintf(_("* Shift type changed from %s to %s"), $old_shift["name"], $new_shift["name"]) . "\n";
|
$message .= sprintf(_("* Shift type changed from %s to %s"), $old_shift["name"], $new_shift["name"]) . "\n";
|
||||||
$noticable_changes = true;
|
$noticable_changes = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($old_shift["title"] != $new_shift["title"]) {
|
if ($old_shift["title"] != $new_shift["title"]) {
|
||||||
$message .= sprintf(_("* Shift title changed from %s to %s"), $old_shift["title"], $new_shift["title"]) . "\n";
|
$message .= sprintf(_("* Shift title changed from %s to %s"), $old_shift["title"], $new_shift["title"]) . "\n";
|
||||||
$noticable_changes = true;
|
$noticable_changes = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($old_shift["start"] != $new_shift["start"]) {
|
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";
|
$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;
|
$noticable_changes = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($old_shift["end"] != $new_shift["end"]) {
|
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";
|
$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;
|
$noticable_changes = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($old_shift["RID"] != $new_shift["RID"]) {
|
if ($old_shift["RID"] != $new_shift["RID"]) {
|
||||||
$message .= sprintf(_("* Shift Location changed from %s to %s"), $old_room["Name"], $new_room["Name"]) . "\n";
|
$message .= sprintf(_("* Shift Location changed from %s to %s"), $old_room["Name"], $new_room["Name"]) . "\n";
|
||||||
$noticable_changes = true;
|
$noticable_changes = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $noticable_changes) {
|
if (!$noticable_changes) {
|
||||||
// There are no changes worth sending an E-Mail
|
// There are no changes worth sending an E-Mail
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$message .= "\n";
|
$message .= "\n";
|
||||||
$message .= _("The updated Shift:") . "\n";
|
$message .= _("The updated Shift:") . "\n";
|
||||||
|
|
||||||
$message .= $new_shift["name"] . "\n";
|
$message .= $new_shift["name"] . "\n";
|
||||||
$message .= $new_shift["title"] . "\n";
|
$message .= $new_shift["title"] . "\n";
|
||||||
$message .= date("Y-m-d H:i", $new_shift["start"]) . " - " . date("H:i", $new_shift["end"]) . "\n";
|
$message .= date("Y-m-d H:i", $new_shift["start"]) . " - " . date("H:i", $new_shift["end"]) . "\n";
|
||||||
$message .= $new_room["Name"] . "\n";
|
$message .= $new_room["Name"] . "\n";
|
||||||
|
|
||||||
foreach ($users as $user) {
|
foreach ($users as $user) {
|
||||||
if ($user["email_shiftinfo"]) {
|
if ($user["email_shiftinfo"]) {
|
||||||
engelsystem_email_to_user($user, '[engelsystem] ' . _("Your Shift has changed"), $message, true);
|
engelsystem_email_to_user($user, '[engelsystem] ' . _("Your Shift has changed"), $message, true);
|
||||||
|
@ -60,14 +68,14 @@ function mail_shift_delete($shift)
|
||||||
{
|
{
|
||||||
$users = ShiftEntries_by_shift($shift["SID"]);
|
$users = ShiftEntries_by_shift($shift["SID"]);
|
||||||
$room = Room($shift["RID"]);
|
$room = Room($shift["RID"]);
|
||||||
|
|
||||||
$message = _("A Shift you are registered on was deleted:") . "\n";
|
$message = _("A Shift you are registered on was deleted:") . "\n";
|
||||||
|
|
||||||
$message .= $shift["name"] . "\n";
|
$message .= $shift["name"] . "\n";
|
||||||
$message .= $shift["title"] . "\n";
|
$message .= $shift["title"] . "\n";
|
||||||
$message .= date("Y-m-d H:i", $shift["start"]) . " - " . date("H:i", $shift["end"]) . "\n";
|
$message .= date("Y-m-d H:i", $shift["start"]) . " - " . date("H:i", $shift["end"]) . "\n";
|
||||||
$message .= $room["Name"] . "\n";
|
$message .= $room["Name"] . "\n";
|
||||||
|
|
||||||
foreach ($users as $user) {
|
foreach ($users as $user) {
|
||||||
if ($user["email_shiftinfo"]) {
|
if ($user["email_shiftinfo"]) {
|
||||||
engelsystem_email_to_user($user, '[engelsystem] ' . _("Your Shift was deleted"), $message, true);
|
engelsystem_email_to_user($user, '[engelsystem] ' . _("Your Shift was deleted"), $message, true);
|
||||||
|
@ -79,13 +87,13 @@ function mail_shift_assign($user, $shift)
|
||||||
{
|
{
|
||||||
if ($user["email_shiftinfo"]) {
|
if ($user["email_shiftinfo"]) {
|
||||||
$room = Room($shift["RID"]);
|
$room = Room($shift["RID"]);
|
||||||
|
|
||||||
$message = _("You have been assigned to a Shift:") . "\n";
|
$message = _("You have been assigned to a Shift:") . "\n";
|
||||||
$message .= $shift["name"] . "\n";
|
$message .= $shift["name"] . "\n";
|
||||||
$message .= $shift["title"] . "\n";
|
$message .= $shift["title"] . "\n";
|
||||||
$message .= date("Y-m-d H:i", $shift["start"]) . " - " . date("H:i", $shift["end"]) . "\n";
|
$message .= date("Y-m-d H:i", $shift["start"]) . " - " . date("H:i", $shift["end"]) . "\n";
|
||||||
$message .= $room["Name"] . "\n";
|
$message .= $room["Name"] . "\n";
|
||||||
|
|
||||||
engelsystem_email_to_user($user, '[engelsystem] ' . _("Assigned to Shift"), $message, true);
|
engelsystem_email_to_user($user, '[engelsystem] ' . _("Assigned to Shift"), $message, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -94,13 +102,13 @@ function mail_shift_removed($user, $shift)
|
||||||
{
|
{
|
||||||
if ($user["email_shiftinfo"]) {
|
if ($user["email_shiftinfo"]) {
|
||||||
$room = Room($shift["RID"]);
|
$room = Room($shift["RID"]);
|
||||||
|
|
||||||
$message = _("You have been removed from a Shift:") . "\n";
|
$message = _("You have been removed from a Shift:") . "\n";
|
||||||
$message .= $shift["name"] . "\n";
|
$message .= $shift["name"] . "\n";
|
||||||
$message .= $shift["title"] . "\n";
|
$message .= $shift["title"] . "\n";
|
||||||
$message .= date("Y-m-d H:i", $shift["start"]) . " - " . date("H:i", $shift["end"]) . "\n";
|
$message .= date("Y-m-d H:i", $shift["start"]) . " - " . date("H:i", $shift["end"]) . "\n";
|
||||||
$message .= $room["Name"] . "\n";
|
$message .= $room["Name"] . "\n";
|
||||||
|
|
||||||
engelsystem_email_to_user($user, '[engelsystem] ' . _("Removed from Shift"), $message, true);
|
engelsystem_email_to_user($user, '[engelsystem] ' . _("Removed from Shift"), $message, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,5 +5,9 @@
|
||||||
*/
|
*/
|
||||||
function mail_user_delete($user)
|
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."));
|
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.")
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,17 +8,17 @@ use Engelsystem\ValidationResult;
|
||||||
function AngelType_new()
|
function AngelType_new()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'id' => null,
|
'id' => null,
|
||||||
'name' => "",
|
'name' => "",
|
||||||
'restricted' => false,
|
'restricted' => false,
|
||||||
'no_self_signup' => false,
|
'no_self_signup' => false,
|
||||||
'description' => '',
|
'description' => '',
|
||||||
'requires_driver_license' => false,
|
'requires_driver_license' => false,
|
||||||
'contact_user_id' => null,
|
'contact_user_id' => null,
|
||||||
'contact_name' => null,
|
'contact_name' => null,
|
||||||
'contact_dect' => null,
|
'contact_dect' => null,
|
||||||
'contact_email' => null
|
'contact_email' => null
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -30,7 +30,7 @@ function AngelType_new()
|
||||||
*/
|
*/
|
||||||
function AngelType_validate_contact_user_id($angeltype)
|
function AngelType_validate_contact_user_id($angeltype)
|
||||||
{
|
{
|
||||||
if (! isset($angeltype['contact_user_id'])) {
|
if (!isset($angeltype['contact_user_id'])) {
|
||||||
return new ValidationResult(true, null);
|
return new ValidationResult(true, null);
|
||||||
}
|
}
|
||||||
if (isset($angeltype['contact_name']) || isset($angeltype['contact_dect']) || isset($angeltype['contact_email'])) {
|
if (isset($angeltype['contact_name']) || isset($angeltype['contact_dect']) || isset($angeltype['contact_email'])) {
|
||||||
|
@ -53,9 +53,9 @@ function AngelType_contact_info($angeltype)
|
||||||
if (isset($angeltype['contact_user_id'])) {
|
if (isset($angeltype['contact_user_id'])) {
|
||||||
$contact_user = User($angeltype['contact_user_id']);
|
$contact_user = User($angeltype['contact_user_id']);
|
||||||
$contact_data = [
|
$contact_data = [
|
||||||
'contact_name' => $contact_user['Nick'],
|
'contact_name' => $contact_user['Nick'],
|
||||||
'contact_dect' => $contact_user['DECT']
|
'contact_dect' => $contact_user['DECT']
|
||||||
];
|
];
|
||||||
if ($contact_user['email_by_human_allowed']) {
|
if ($contact_user['email_by_human_allowed']) {
|
||||||
$contact_data['contact_email'] = $contact_user['email'];
|
$contact_data['contact_email'] = $contact_user['email'];
|
||||||
}
|
}
|
||||||
|
@ -63,10 +63,10 @@ function AngelType_contact_info($angeltype)
|
||||||
}
|
}
|
||||||
if (isset($angeltype['contact_name'])) {
|
if (isset($angeltype['contact_name'])) {
|
||||||
return [
|
return [
|
||||||
'contact_name' => $angeltype['contact_name'],
|
'contact_name' => $angeltype['contact_name'],
|
||||||
'contact_dect' => $angeltype['contact_dect'],
|
'contact_dect' => $angeltype['contact_dect'],
|
||||||
'contact_email' => $angeltype['contact_email']
|
'contact_email' => $angeltype['contact_email']
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -148,7 +148,7 @@ function AngelType_create($angeltype)
|
||||||
* Validates a name for angeltypes.
|
* Validates a name for angeltypes.
|
||||||
* Returns ValidationResult containing validation success and validated name.
|
* Returns ValidationResult containing validation success and validated name.
|
||||||
*
|
*
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* Wanted name for the angeltype
|
* Wanted name for the angeltype
|
||||||
* @param AngelType $angeltype
|
* @param AngelType $angeltype
|
||||||
* The angeltype the name is for
|
* The angeltype the name is for
|
||||||
|
@ -186,7 +186,7 @@ function AngelTypes_with_user($user)
|
||||||
{
|
{
|
||||||
$result = sql_select("
|
$result = sql_select("
|
||||||
SELECT `AngelTypes`.*,
|
SELECT `AngelTypes`.*,
|
||||||
`UserAngelTypes`.`id` as `user_angeltype_id`,
|
`UserAngelTypes`.`id` AS `user_angeltype_id`,
|
||||||
`UserAngelTypes`.`confirm_user_id`,
|
`UserAngelTypes`.`confirm_user_id`,
|
||||||
`UserAngelTypes`.`supporter`
|
`UserAngelTypes`.`supporter`
|
||||||
FROM `AngelTypes`
|
FROM `AngelTypes`
|
||||||
|
@ -230,7 +230,7 @@ function AngelType_ids()
|
||||||
* Returns angelType by id.
|
* Returns angelType by id.
|
||||||
*
|
*
|
||||||
* @param $angeltype_id angelType
|
* @param $angeltype_id angelType
|
||||||
* ID
|
* ID
|
||||||
*/
|
*/
|
||||||
function AngelType($angeltype_id)
|
function AngelType($angeltype_id)
|
||||||
{
|
{
|
||||||
|
|
|
@ -20,14 +20,20 @@ function EventConfig()
|
||||||
* Update event config.
|
* Update event config.
|
||||||
*
|
*
|
||||||
* @param string $event_name
|
* @param string $event_name
|
||||||
* @param int $buildup_start_date
|
* @param int $buildup_start_date
|
||||||
* @param int $event_start_date
|
* @param int $event_start_date
|
||||||
* @param int $event_end_date
|
* @param int $event_end_date
|
||||||
* @param int $teardown_end_date
|
* @param int $teardown_end_date
|
||||||
* @param string $event_welcome_msg
|
* @param string $event_welcome_msg
|
||||||
*/
|
*/
|
||||||
function EventConfig_update($event_name, $buildup_start_date, $event_start_date, $event_end_date, $teardown_end_date, $event_welcome_msg)
|
function EventConfig_update(
|
||||||
{
|
$event_name,
|
||||||
|
$buildup_start_date,
|
||||||
|
$event_start_date,
|
||||||
|
$event_end_date,
|
||||||
|
$teardown_end_date,
|
||||||
|
$event_welcome_msg
|
||||||
|
) {
|
||||||
if (EventConfig() == null) {
|
if (EventConfig() == null) {
|
||||||
return sql_query("INSERT INTO `EventConfig` SET
|
return sql_query("INSERT INTO `EventConfig` SET
|
||||||
`event_name`=" . sql_null($event_name) . ",
|
`event_name`=" . sql_null($event_name) . ",
|
||||||
|
|
|
@ -3,9 +3,9 @@
|
||||||
/**
|
/**
|
||||||
* Creates a log entry.
|
* Creates a log entry.
|
||||||
*
|
*
|
||||||
* @param $nick Username
|
* @param $nick Username
|
||||||
* @param $message Log
|
* @param $message Log
|
||||||
* Message
|
* Message
|
||||||
*/
|
*/
|
||||||
function LogEntry_create($nick, $message)
|
function LogEntry_create($nick, $message)
|
||||||
{
|
{
|
||||||
|
|
|
@ -12,7 +12,7 @@ function Message_ids()
|
||||||
* Returns message by id.
|
* Returns message by id.
|
||||||
*
|
*
|
||||||
* @param $message_id message
|
* @param $message_id message
|
||||||
* ID
|
* ID
|
||||||
*/
|
*/
|
||||||
function Message($message_id)
|
function Message($message_id)
|
||||||
{
|
{
|
||||||
|
@ -32,21 +32,36 @@ function Message($message_id)
|
||||||
* send message
|
* send message
|
||||||
*
|
*
|
||||||
* @param $receiver_user_id User
|
* @param $receiver_user_id User
|
||||||
* ID of Reciever
|
* ID of Reciever
|
||||||
* @param $text Text
|
* @param $text Text
|
||||||
* of Message
|
* of Message
|
||||||
*/
|
*/
|
||||||
function Message_send($receiver_user_id, $text)
|
function Message_send($receiver_user_id, $text)
|
||||||
{
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
$text = preg_replace("/([^\p{L}\p{P}\p{Z}\p{N}\n]{1,})/ui", '', strip_tags($text));
|
$text = preg_replace("/([^\p{L}\p{P}\p{Z}\p{N}\n]{1,})/ui", '', strip_tags($text));
|
||||||
$receiver_user_id = preg_replace("/([^0-9]{1,})/ui", '', strip_tags($receiver_user_id));
|
$receiver_user_id = preg_replace("/([^0-9]{1,})/ui", '', strip_tags($receiver_user_id));
|
||||||
|
|
||||||
if (($text != "" && is_numeric($receiver_user_id)) && (sql_num_query("SELECT * FROM `User` WHERE `UID`='" . sql_escape($receiver_user_id) . "' AND NOT `UID`='" . sql_escape($user['UID']) . "' LIMIT 1") > 0)) {
|
if (
|
||||||
sql_query("INSERT INTO `Messages` SET `Datum`='" . sql_escape(time()) . "', `SUID`='" . sql_escape($user['UID']) . "', `RUID`='" . sql_escape($receiver_user_id) . "', `Text`='" . sql_escape($text) . "'");
|
($text != "" && is_numeric($receiver_user_id))
|
||||||
|
&& (sql_num_query("
|
||||||
|
SELECT *
|
||||||
|
FROM `User`
|
||||||
|
WHERE `UID`='" . sql_escape($receiver_user_id) . "'
|
||||||
|
AND NOT `UID`='" . sql_escape($user['UID']) . "'
|
||||||
|
LIMIT 1
|
||||||
|
") > 0)
|
||||||
|
) {
|
||||||
|
sql_query("
|
||||||
|
INSERT INTO `Messages`
|
||||||
|
SET `Datum`='" . sql_escape(time()) . "',
|
||||||
|
`SUID`='" . sql_escape($user['UID']) . "',
|
||||||
|
`RUID`='" . sql_escape($receiver_user_id) . "',
|
||||||
|
`Text`='" . sql_escape($text) . "'
|
||||||
|
");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,10 +71,10 @@ function NeededAngelTypes_by_shift($shiftId)
|
||||||
if ($needed_angeltypes_source === false) {
|
if ($needed_angeltypes_source === false) {
|
||||||
engelsystem_error("Unable to load needed angeltypes.");
|
engelsystem_error("Unable to load needed angeltypes.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use settings from room
|
// Use settings from room
|
||||||
if (count($needed_angeltypes_source) == 0) {
|
if (count($needed_angeltypes_source) == 0) {
|
||||||
$needed_angeltypes_source = sql_select("
|
$needed_angeltypes_source = sql_select("
|
||||||
SELECT `NeededAngelTypes`.*, `AngelTypes`.`name`, `AngelTypes`.`restricted`
|
SELECT `NeededAngelTypes`.*, `AngelTypes`.`name`, `AngelTypes`.`restricted`
|
||||||
FROM `NeededAngelTypes`
|
FROM `NeededAngelTypes`
|
||||||
JOIN `AngelTypes` ON `AngelTypes`.`id` = `NeededAngelTypes`.`angel_type_id`
|
JOIN `AngelTypes` ON `AngelTypes`.`id` = `NeededAngelTypes`.`angel_type_id`
|
||||||
|
@ -83,11 +83,11 @@ function NeededAngelTypes_by_shift($shiftId)
|
||||||
AND `count` > 0
|
AND `count` > 0
|
||||||
ORDER BY `room_id` DESC
|
ORDER BY `room_id` DESC
|
||||||
");
|
");
|
||||||
if ($needed_angeltypes_source === false) {
|
if ($needed_angeltypes_source === false) {
|
||||||
engelsystem_error("Unable to load needed angeltypes.");
|
engelsystem_error("Unable to load needed angeltypes.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$shift_entries = ShiftEntries_by_shift($shiftId);
|
$shift_entries = ShiftEntries_by_shift($shiftId);
|
||||||
$needed_angeltypes = [];
|
$needed_angeltypes = [];
|
||||||
foreach ($needed_angeltypes_source as $angeltype) {
|
foreach ($needed_angeltypes_source as $angeltype) {
|
||||||
|
@ -95,13 +95,13 @@ function NeededAngelTypes_by_shift($shiftId)
|
||||||
$angeltype['taken'] = 0;
|
$angeltype['taken'] = 0;
|
||||||
foreach ($shift_entries as $shift_entry) {
|
foreach ($shift_entries as $shift_entry) {
|
||||||
if ($shift_entry['TID'] == $angeltype['angel_type_id'] && $shift_entry['freeloaded'] == 0) {
|
if ($shift_entry['TID'] == $angeltype['angel_type_id'] && $shift_entry['freeloaded'] == 0) {
|
||||||
$angeltype['taken'] ++;
|
$angeltype['taken']++;
|
||||||
$angeltype['shift_entries'][] = $shift_entry;
|
$angeltype['shift_entries'][] = $shift_entry;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$needed_angeltypes[] = $angeltype;
|
$needed_angeltypes[] = $angeltype;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $needed_angeltypes;
|
return $needed_angeltypes;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns a list of rooms.
|
* returns a list of rooms.
|
||||||
|
*
|
||||||
* @param boolean $show_all returns also hidden rooms when true
|
* @param boolean $show_all returns also hidden rooms when true
|
||||||
*/
|
*/
|
||||||
function Rooms($show_all = false)
|
function Rooms($show_all = false)
|
||||||
|
@ -22,7 +23,7 @@ function Room_delete($room_id)
|
||||||
/**
|
/**
|
||||||
* Create a new room
|
* Create a new room
|
||||||
*
|
*
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* Name of the room
|
* Name of the room
|
||||||
* @param boolean $from_frab
|
* @param boolean $from_frab
|
||||||
* Is this a frab imported room?
|
* Is this a frab imported room?
|
||||||
|
@ -51,7 +52,7 @@ function Room_create($name, $from_frab, $public)
|
||||||
function Room($room_id)
|
function Room($room_id)
|
||||||
{
|
{
|
||||||
$room_source = sql_select("SELECT * FROM `Room` WHERE `RID`='" . sql_escape($room_id) . "' AND `show` = 'Y'");
|
$room_source = sql_select("SELECT * FROM `Room` WHERE `RID`='" . sql_escape($room_id) . "' AND `show` = 'Y'");
|
||||||
|
|
||||||
if ($room_source === false) {
|
if ($room_source === false) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,14 +7,14 @@
|
||||||
function ShiftEntry_new()
|
function ShiftEntry_new()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'id' => null,
|
'id' => null,
|
||||||
'SID' => null,
|
'SID' => null,
|
||||||
'TID' => null,
|
'TID' => null,
|
||||||
'UID' => null,
|
'UID' => null,
|
||||||
'Comment' => null,
|
'Comment' => null,
|
||||||
'freeloaded_comment' => null,
|
'freeloaded_comment' => null,
|
||||||
'freeloaded' => false
|
'freeloaded' => false
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -31,7 +31,18 @@ function ShiftEntries_freeleaded_count()
|
||||||
function ShiftEntries_by_shift($shift_id)
|
function ShiftEntries_by_shift($shift_id)
|
||||||
{
|
{
|
||||||
return sql_select("
|
return sql_select("
|
||||||
SELECT `User`.`Nick`, `User`.`email`, `User`.`email_shiftinfo`, `User`.`Sprache`, `User`.`Gekommen`, `ShiftEntry`.`UID`, `ShiftEntry`.`TID`, `ShiftEntry`.`SID`, `AngelTypes`.`name` as `angel_type_name`, `ShiftEntry`.`Comment`, `ShiftEntry`.`freeloaded`
|
SELECT
|
||||||
|
`User`.`Nick`,
|
||||||
|
`User`.`email`,
|
||||||
|
`User`.`email_shiftinfo`,
|
||||||
|
`User`.`Sprache`,
|
||||||
|
`User`.`Gekommen`,
|
||||||
|
`ShiftEntry`.`UID`,
|
||||||
|
`ShiftEntry`.`TID`,
|
||||||
|
`ShiftEntry`.`SID`,
|
||||||
|
`AngelTypes`.`name` AS `angel_type_name`,
|
||||||
|
`ShiftEntry`.`Comment`,
|
||||||
|
`ShiftEntry`.`freeloaded`
|
||||||
FROM `ShiftEntry`
|
FROM `ShiftEntry`
|
||||||
JOIN `User` ON `ShiftEntry`.`UID`=`User`.`UID`
|
JOIN `User` ON `ShiftEntry`.`UID`=`User`.`UID`
|
||||||
JOIN `AngelTypes` ON `ShiftEntry`.`TID`=`AngelTypes`.`id`
|
JOIN `AngelTypes` ON `ShiftEntry`.`TID`=`AngelTypes`.`id`
|
||||||
|
|
|
@ -9,40 +9,40 @@ namespace Engelsystem;
|
||||||
class ShiftSignupState
|
class ShiftSignupState
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shift has free places
|
* Shift has free places
|
||||||
*/
|
*/
|
||||||
const FREE = 'FREE';
|
const FREE = 'FREE';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shift collides with users shifts
|
* Shift collides with users shifts
|
||||||
*/
|
*/
|
||||||
const COLLIDES = 'COLLIDES';
|
const COLLIDES = 'COLLIDES';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User cannot join because of a restricted angeltype or user is not in the angeltype
|
* User cannot join because of a restricted angeltype or user is not in the angeltype
|
||||||
*/
|
*/
|
||||||
const ANGELTYPE = 'ANGELTYPE';
|
const ANGELTYPE = 'ANGELTYPE';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shift is full
|
* Shift is full
|
||||||
*/
|
*/
|
||||||
const OCCUPIED = 'OCCUPIED';
|
const OCCUPIED = 'OCCUPIED';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User is admin and can do what he wants.
|
* User is admin and can do what he wants.
|
||||||
*/
|
*/
|
||||||
const ADMIN = 'ADMIN';
|
const ADMIN = 'ADMIN';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shift has already ended, no signup
|
* Shift has already ended, no signup
|
||||||
*/
|
*/
|
||||||
const SHIFT_ENDED = 'SHIFT_ENDED';
|
const SHIFT_ENDED = 'SHIFT_ENDED';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User is already signed up
|
* User is already signed up
|
||||||
*/
|
*/
|
||||||
const SIGNED_UP = 'SIGNED_UP';
|
const SIGNED_UP = 'SIGNED_UP';
|
||||||
|
|
||||||
private $state;
|
private $state;
|
||||||
|
|
||||||
|
@ -54,69 +54,69 @@ class ShiftSignupState
|
||||||
$this->freeEntries = $free_entries;
|
$this->freeEntries = $free_entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Combine this state with another state from the same shift.
|
* Combine this state with another state from the same shift.
|
||||||
*
|
*
|
||||||
* @param ShiftSignupState $shiftSignupState
|
* @param ShiftSignupState $shiftSignupState
|
||||||
* The other state to combine
|
* The other state to combine
|
||||||
*/
|
*/
|
||||||
public function combineWith(ShiftSignupState $shiftSignupState)
|
public function combineWith(ShiftSignupState $shiftSignupState)
|
||||||
{
|
{
|
||||||
$this->freeEntries += $shiftSignupState->getFreeEntries();
|
$this->freeEntries += $shiftSignupState->getFreeEntries();
|
||||||
|
|
||||||
if ($this->valueForState($shiftSignupState->state) > $this->valueForState($this->state)) {
|
if ($this->valueForState($shiftSignupState->state) > $this->valueForState($this->state)) {
|
||||||
$this->state = $shiftSignupState->state;
|
$this->state = $shiftSignupState->state;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function valueForState($state)
|
private function valueForState($state)
|
||||||
{
|
{
|
||||||
switch ($state) {
|
switch ($state) {
|
||||||
case ShiftSignupState::SHIFT_ENDED:
|
case ShiftSignupState::SHIFT_ENDED:
|
||||||
return 100;
|
return 100;
|
||||||
|
|
||||||
case ShiftSignupState::SIGNED_UP:
|
case ShiftSignupState::SIGNED_UP:
|
||||||
return 90;
|
return 90;
|
||||||
|
|
||||||
case ShiftSignupState::FREE:
|
case ShiftSignupState::FREE:
|
||||||
return 80;
|
return 80;
|
||||||
|
|
||||||
case ShiftSignupState::ANGELTYPE:
|
case ShiftSignupState::ANGELTYPE:
|
||||||
case ShiftSignupState::COLLIDES:
|
case ShiftSignupState::COLLIDES:
|
||||||
return 70;
|
return 70;
|
||||||
|
|
||||||
case ShiftSignupState::OCCUPIED:
|
case ShiftSignupState::OCCUPIED:
|
||||||
case ShiftSignupState::ADMIN:
|
case ShiftSignupState::ADMIN:
|
||||||
return 60;
|
return 60;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true, if signup is allowed
|
* Returns true, if signup is allowed
|
||||||
*/
|
*/
|
||||||
public function isSignupAllowed()
|
public function isSignupAllowed()
|
||||||
{
|
{
|
||||||
switch ($this->state) {
|
switch ($this->state) {
|
||||||
case ShiftSignupState::FREE:
|
case ShiftSignupState::FREE:
|
||||||
case ShiftSignupState::ADMIN:
|
case ShiftSignupState::ADMIN:
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the shift signup state
|
* Return the shift signup state
|
||||||
*/
|
*/
|
||||||
public function getState()
|
public function getState()
|
||||||
{
|
{
|
||||||
return $this->state;
|
return $this->state;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* How many places are free in this shift for the angeltype?
|
* How many places are free in this shift for the angeltype?
|
||||||
*/
|
*/
|
||||||
public function getFreeEntries()
|
public function getFreeEntries()
|
||||||
{
|
{
|
||||||
return $this->freeEntries;
|
return $this->freeEntries;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a shift type.
|
* Delete a shift type.
|
||||||
|
*
|
||||||
* @param int $shifttype_id
|
* @param int $shifttype_id
|
||||||
*/
|
*/
|
||||||
function ShiftType_delete($shifttype_id)
|
function ShiftType_delete($shifttype_id)
|
||||||
|
@ -12,34 +13,38 @@ function ShiftType_delete($shifttype_id)
|
||||||
/**
|
/**
|
||||||
* Update a shift type.
|
* Update a shift type.
|
||||||
*
|
*
|
||||||
* @param int $shifttype_id
|
* @param int $shifttype_id
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @param int $angeltype_id
|
* @param int $angeltype_id
|
||||||
* @param string $description
|
* @param string $description
|
||||||
*/
|
*/
|
||||||
function ShiftType_update($shifttype_id, $name, $angeltype_id, $description)
|
function ShiftType_update($shifttype_id, $name, $angeltype_id, $description)
|
||||||
{
|
{
|
||||||
return sql_query("UPDATE `ShiftTypes` SET
|
return sql_query("
|
||||||
|
UPDATE `ShiftTypes` SET
|
||||||
`name`='" . sql_escape($name) . "',
|
`name`='" . sql_escape($name) . "',
|
||||||
`angeltype_id`=" . sql_null($angeltype_id) . ",
|
`angeltype_id`=" . sql_null($angeltype_id) . ",
|
||||||
`description`='" . sql_escape($description) . "'
|
`description`='" . sql_escape($description) . "'
|
||||||
WHERE `id`='" . sql_escape($shifttype_id) . "'");
|
WHERE `id`='" . sql_escape($shifttype_id) . "'
|
||||||
|
");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a shift type.
|
* Create a shift type.
|
||||||
*
|
*
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @param int $angeltype_id
|
* @param int $angeltype_id
|
||||||
* @param string $description
|
* @param string $description
|
||||||
* @return new shifttype id
|
* @return new shifttype id
|
||||||
*/
|
*/
|
||||||
function ShiftType_create($name, $angeltype_id, $description)
|
function ShiftType_create($name, $angeltype_id, $description)
|
||||||
{
|
{
|
||||||
$result = sql_query("INSERT INTO `ShiftTypes` SET
|
$result = sql_query("
|
||||||
|
INSERT INTO `ShiftTypes` SET
|
||||||
`name`='" . sql_escape($name) . "',
|
`name`='" . sql_escape($name) . "',
|
||||||
`angeltype_id`=" . sql_null($angeltype_id) . ",
|
`angeltype_id`=" . sql_null($angeltype_id) . ",
|
||||||
`description`='" . sql_escape($description) . "'");
|
`description`='" . sql_escape($description) . "'
|
||||||
|
");
|
||||||
if ($result === false) {
|
if ($result === false) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,28 +10,28 @@ namespace Engelsystem;
|
||||||
class ShiftsFilter
|
class ShiftsFilter
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* How long can the time interval be?
|
* How long can the time interval be?
|
||||||
*/
|
*/
|
||||||
const MAX_DURATION = 86400;
|
const MAX_DURATION = 86400;
|
||||||
// one day
|
// one day
|
||||||
|
|
||||||
/**
|
|
||||||
* Shift is completely full.
|
|
||||||
*/
|
|
||||||
const FILLED_FILLED = 1;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shift has some free slots.
|
* Shift is completely full.
|
||||||
*/
|
*/
|
||||||
const FILLED_FREE = 0;
|
const FILLED_FILLED = 1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Has the user "user shifts admin" privilege?
|
* Shift has some free slots.
|
||||||
*
|
*/
|
||||||
* @var boolean
|
const FILLED_FREE = 0;
|
||||||
*/
|
|
||||||
private $userShiftsAdmin;
|
/**
|
||||||
|
* Has the user "user shifts admin" privilege?
|
||||||
|
*
|
||||||
|
* @var boolean
|
||||||
|
*/
|
||||||
|
private $userShiftsAdmin;
|
||||||
|
|
||||||
private $filled = [];
|
private $filled = [];
|
||||||
|
|
||||||
|
@ -48,11 +48,11 @@ class ShiftsFilter
|
||||||
$this->user_shifts_admin = $user_shifts_admin;
|
$this->user_shifts_admin = $user_shifts_admin;
|
||||||
$this->rooms = $rooms;
|
$this->rooms = $rooms;
|
||||||
$this->types = $types;
|
$this->types = $types;
|
||||||
|
|
||||||
$this->filled = [
|
$this->filled = [
|
||||||
ShiftsFilter::FILLED_FREE
|
ShiftsFilter::FILLED_FREE
|
||||||
];
|
];
|
||||||
|
|
||||||
if ($user_shifts_admin) {
|
if ($user_shifts_admin) {
|
||||||
$this->filled[] = ShiftsFilter::FILLED_FILLED;
|
$this->filled[] = ShiftsFilter::FILLED_FILLED;
|
||||||
}
|
}
|
||||||
|
@ -84,9 +84,7 @@ class ShiftsFilter
|
||||||
public function getTypes()
|
public function getTypes()
|
||||||
{
|
{
|
||||||
if (count($this->types) == 0) {
|
if (count($this->types) == 0) {
|
||||||
return [
|
return [0];
|
||||||
0
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
return $this->types;
|
return $this->types;
|
||||||
}
|
}
|
||||||
|
@ -99,9 +97,7 @@ class ShiftsFilter
|
||||||
public function getRooms()
|
public function getRooms()
|
||||||
{
|
{
|
||||||
if (count($this->rooms) == 0) {
|
if (count($this->rooms) == 0) {
|
||||||
return [
|
return [0];
|
||||||
0
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
return $this->rooms;
|
return $this->rooms;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ function Shifts_by_room($room)
|
||||||
function Shifts_by_ShiftsFilter(ShiftsFilter $shiftsFilter)
|
function Shifts_by_ShiftsFilter(ShiftsFilter $shiftsFilter)
|
||||||
{
|
{
|
||||||
$SQL = "SELECT * FROM (
|
$SQL = "SELECT * FROM (
|
||||||
SELECT DISTINCT `Shifts`.*, `ShiftTypes`.`name`, `Room`.`Name` as `room_name`
|
SELECT DISTINCT `Shifts`.*, `ShiftTypes`.`name`, `Room`.`Name` AS `room_name`
|
||||||
FROM `Shifts`
|
FROM `Shifts`
|
||||||
JOIN `Room` USING (`RID`)
|
JOIN `Room` USING (`RID`)
|
||||||
JOIN `ShiftTypes` ON `ShiftTypes`.`id` = `Shifts`.`shifttype_id`
|
JOIN `ShiftTypes` ON `ShiftTypes`.`id` = `Shifts`.`shifttype_id`
|
||||||
|
@ -27,7 +27,7 @@ function Shifts_by_ShiftsFilter(ShiftsFilter $shiftsFilter)
|
||||||
|
|
||||||
UNION
|
UNION
|
||||||
|
|
||||||
SELECT DISTINCT `Shifts`.*, `ShiftTypes`.`name`, `Room`.`Name` as `room_name`
|
SELECT DISTINCT `Shifts`.*, `ShiftTypes`.`name`, `Room`.`Name` AS `room_name`
|
||||||
FROM `Shifts`
|
FROM `Shifts`
|
||||||
JOIN `Room` USING (`RID`)
|
JOIN `Room` USING (`RID`)
|
||||||
JOIN `ShiftTypes` ON `ShiftTypes`.`id` = `Shifts`.`shifttype_id`
|
JOIN `ShiftTypes` ON `ShiftTypes`.`id` = `Shifts`.`shifttype_id`
|
||||||
|
@ -36,7 +36,7 @@ function Shifts_by_ShiftsFilter(ShiftsFilter $shiftsFilter)
|
||||||
AND `start` BETWEEN " . $shiftsFilter->getStartTime() . " AND " . $shiftsFilter->getEndTime() . "
|
AND `start` BETWEEN " . $shiftsFilter->getStartTime() . " AND " . $shiftsFilter->getEndTime() . "
|
||||||
AND `NeededAngelTypes`.`angel_type_id` IN (" . implode(',', $shiftsFilter->getTypes()) . ")
|
AND `NeededAngelTypes`.`angel_type_id` IN (" . implode(',', $shiftsFilter->getTypes()) . ")
|
||||||
AND `NeededAngelTypes`.`count` > 0
|
AND `NeededAngelTypes`.`count` > 0
|
||||||
AND NOT `Shifts`.`PSID` IS NULL) as tmp_shifts
|
AND NOT `Shifts`.`PSID` IS NULL) AS tmp_shifts
|
||||||
|
|
||||||
ORDER BY `start`";
|
ORDER BY `start`";
|
||||||
$result = sql_select($SQL);
|
$result = sql_select($SQL);
|
||||||
|
@ -48,7 +48,14 @@ function Shifts_by_ShiftsFilter(ShiftsFilter $shiftsFilter)
|
||||||
|
|
||||||
function NeededAngeltypes_by_ShiftsFilter(ShiftsFilter $shiftsFilter)
|
function NeededAngeltypes_by_ShiftsFilter(ShiftsFilter $shiftsFilter)
|
||||||
{
|
{
|
||||||
$SQL = "SELECT `NeededAngelTypes`.*, `Shifts`.`SID`, `AngelTypes`.`id`, `AngelTypes`.`name`, `AngelTypes`.`restricted`, `AngelTypes`.`no_self_signup`
|
$SQL = "
|
||||||
|
SELECT
|
||||||
|
`NeededAngelTypes`.*,
|
||||||
|
`Shifts`.`SID`,
|
||||||
|
`AngelTypes`.`id`,
|
||||||
|
`AngelTypes`.`name`,
|
||||||
|
`AngelTypes`.`restricted`,
|
||||||
|
`AngelTypes`.`no_self_signup`
|
||||||
FROM `Shifts`
|
FROM `Shifts`
|
||||||
JOIN `NeededAngelTypes` ON `NeededAngelTypes`.`shift_id`=`Shifts`.`SID`
|
JOIN `NeededAngelTypes` ON `NeededAngelTypes`.`shift_id`=`Shifts`.`SID`
|
||||||
JOIN `AngelTypes` ON `AngelTypes`.`id`= `NeededAngelTypes`.`angel_type_id`
|
JOIN `AngelTypes` ON `AngelTypes`.`id`= `NeededAngelTypes`.`angel_type_id`
|
||||||
|
@ -58,7 +65,13 @@ function NeededAngeltypes_by_ShiftsFilter(ShiftsFilter $shiftsFilter)
|
||||||
|
|
||||||
UNION
|
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`
|
FROM `Shifts`
|
||||||
JOIN `NeededAngelTypes` ON `NeededAngelTypes`.`room_id`=`Shifts`.`RID`
|
JOIN `NeededAngelTypes` ON `NeededAngelTypes`.`room_id`=`Shifts`.`RID`
|
||||||
JOIN `AngelTypes` ON `AngelTypes`.`id`= `NeededAngelTypes`.`angel_type_id`
|
JOIN `AngelTypes` ON `AngelTypes`.`id`= `NeededAngelTypes`.`angel_type_id`
|
||||||
|
@ -74,7 +87,14 @@ function NeededAngeltypes_by_ShiftsFilter(ShiftsFilter $shiftsFilter)
|
||||||
|
|
||||||
function NeededAngeltype_by_Shift_and_Angeltype($shift, $angeltype)
|
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`
|
$result = sql_select("
|
||||||
|
SELECT
|
||||||
|
`NeededAngelTypes`.*,
|
||||||
|
`Shifts`.`SID`,
|
||||||
|
`AngelTypes`.`id`,
|
||||||
|
`AngelTypes`.`name`,
|
||||||
|
`AngelTypes`.`restricted`,
|
||||||
|
`AngelTypes`.`no_self_signup`
|
||||||
FROM `Shifts`
|
FROM `Shifts`
|
||||||
JOIN `NeededAngelTypes` ON `NeededAngelTypes`.`shift_id`=`Shifts`.`SID`
|
JOIN `NeededAngelTypes` ON `NeededAngelTypes`.`shift_id`=`Shifts`.`SID`
|
||||||
JOIN `AngelTypes` ON `AngelTypes`.`id`= `NeededAngelTypes`.`angel_type_id`
|
JOIN `AngelTypes` ON `AngelTypes`.`id`= `NeededAngelTypes`.`angel_type_id`
|
||||||
|
@ -84,7 +104,13 @@ function NeededAngeltype_by_Shift_and_Angeltype($shift, $angeltype)
|
||||||
|
|
||||||
UNION
|
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`
|
FROM `Shifts`
|
||||||
JOIN `NeededAngelTypes` ON `NeededAngelTypes`.`room_id`=`Shifts`.`RID`
|
JOIN `NeededAngelTypes` ON `NeededAngelTypes`.`room_id`=`Shifts`.`RID`
|
||||||
JOIN `AngelTypes` ON `AngelTypes`.`id`= `NeededAngelTypes`.`angel_type_id`
|
JOIN `AngelTypes` ON `AngelTypes`.`id`= `NeededAngelTypes`.`angel_type_id`
|
||||||
|
@ -102,7 +128,18 @@ function NeededAngeltype_by_Shift_and_Angeltype($shift, $angeltype)
|
||||||
|
|
||||||
function ShiftEntries_by_ShiftsFilter(ShiftsFilter $shiftsFilter)
|
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`
|
$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`
|
FROM `Shifts`
|
||||||
JOIN `ShiftEntry` ON `ShiftEntry`.`SID`=`Shifts`.`SID`
|
JOIN `ShiftEntry` ON `ShiftEntry`.`SID`=`Shifts`.`SID`
|
||||||
JOIN `User` ON `ShiftEntry`.`UID`=`User`.`UID`
|
JOIN `User` ON `ShiftEntry`.`UID`=`User`.`UID`
|
||||||
|
@ -120,13 +157,13 @@ function ShiftEntries_by_ShiftsFilter(ShiftsFilter $shiftsFilter)
|
||||||
* Check if a shift collides with other shifts (in time).
|
* Check if a shift collides with other shifts (in time).
|
||||||
*
|
*
|
||||||
* @param Shift $shift
|
* @param Shift $shift
|
||||||
* @param array<Shift> $shifts
|
* @param array <Shift> $shifts
|
||||||
*/
|
*/
|
||||||
function Shift_collides($shift, $shifts)
|
function Shift_collides($shift, $shifts)
|
||||||
{
|
{
|
||||||
foreach ($shifts as $other_shift) {
|
foreach ($shifts as $other_shift) {
|
||||||
if ($shift['SID'] != $other_shift['SID']) {
|
if ($shift['SID'] != $other_shift['SID']) {
|
||||||
if (! ($shift['start'] >= $other_shift['end'] || $shift['end'] <= $other_shift['start'])) {
|
if (!($shift['start'] >= $other_shift['end'] || $shift['end'] <= $other_shift['start'])) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -142,7 +179,7 @@ function Shift_free_entries($needed_angeltype, $shift_entries)
|
||||||
$taken = 0;
|
$taken = 0;
|
||||||
foreach ($shift_entries as $shift_entry) {
|
foreach ($shift_entries as $shift_entry) {
|
||||||
if ($shift_entry['freeloaded'] == 0) {
|
if ($shift_entry['freeloaded'] == 0) {
|
||||||
$taken ++;
|
$taken++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return max(0, $needed_angeltype['count'] - $taken);
|
return max(0, $needed_angeltype['count'] - $taken);
|
||||||
|
@ -151,27 +188,35 @@ function Shift_free_entries($needed_angeltype, $shift_entries)
|
||||||
/**
|
/**
|
||||||
* Check if shift signup is allowed from the end users point of view (no admin like privileges)
|
* Check if shift signup is allowed from the end users point of view (no admin like privileges)
|
||||||
*
|
*
|
||||||
* @param Shift $shift
|
* @param Shift $shift
|
||||||
* The shift
|
* The shift
|
||||||
* @param AngelType $angeltype
|
* @param AngelType $angeltype
|
||||||
* The angeltype to which the user wants to sign up
|
* The angeltype to which the user wants to sign up
|
||||||
* @param array<Shift> $user_shifts
|
* @param array <Shift> $user_shifts
|
||||||
* List of the users shifts
|
* List of the users shifts
|
||||||
* @param boolean $angeltype_supporter
|
* @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.
|
* True, if the user has angeltype supporter rights for the angeltype, which enables him to sign
|
||||||
|
* somebody up for the shift.
|
||||||
*/
|
*/
|
||||||
function Shift_signup_allowed_angel($user, $shift, $angeltype, $user_angeltype, $user_shifts, $needed_angeltype, $shift_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);
|
$free_entries = Shift_free_entries($needed_angeltype, $shift_entries);
|
||||||
|
|
||||||
if ($user['Gekommen'] == 0) {
|
if ($user['Gekommen'] == 0) {
|
||||||
return new ShiftSignupState(ShiftSignupState::SHIFT_ENDED, $free_entries);
|
return new ShiftSignupState(ShiftSignupState::SHIFT_ENDED, $free_entries);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($user_shifts == null) {
|
if ($user_shifts == null) {
|
||||||
$user_shifts = Shifts_by_user($user);
|
$user_shifts = Shifts_by_user($user);
|
||||||
}
|
}
|
||||||
|
|
||||||
$signed_up = false;
|
$signed_up = false;
|
||||||
foreach ($user_shifts as $user_shift) {
|
foreach ($user_shifts as $user_shift) {
|
||||||
if ($user_shift['SID'] == $shift['SID']) {
|
if ($user_shift['SID'] == $shift['SID']) {
|
||||||
|
@ -179,40 +224,44 @@ function Shift_signup_allowed_angel($user, $shift, $angeltype, $user_angeltype,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($signed_up) {
|
if ($signed_up) {
|
||||||
// you cannot join if you already singed up for this shift
|
// you cannot join if you already singed up for this shift
|
||||||
return new ShiftSignupState(ShiftSignupState::SIGNED_UP, $free_entries);
|
return new ShiftSignupState(ShiftSignupState::SIGNED_UP, $free_entries);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (time() > $shift['start']) {
|
if (time() > $shift['start']) {
|
||||||
// you can only join if the shift is in future
|
// you can only join if the shift is in future
|
||||||
return new ShiftSignupState(ShiftSignupState::SHIFT_ENDED, $free_entries);
|
return new ShiftSignupState(ShiftSignupState::SHIFT_ENDED, $free_entries);
|
||||||
}
|
}
|
||||||
if ($free_entries == 0) {
|
if ($free_entries == 0) {
|
||||||
// you cannot join if shift is full
|
// you cannot join if shift is full
|
||||||
return new ShiftSignupState(ShiftSignupState::OCCUPIED, $free_entries);
|
return new ShiftSignupState(ShiftSignupState::OCCUPIED, $free_entries);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($user_angeltype == null) {
|
if ($user_angeltype == null) {
|
||||||
$user_angeltype = UserAngelType_by_User_and_AngelType($user, $angeltype);
|
$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']))) {
|
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 user is not of this angel type
|
||||||
// you cannot join if you are not confirmed
|
// you cannot join if you are not confirmed
|
||||||
// you cannot join if angeltype has no self signup
|
// you cannot join if angeltype has no self signup
|
||||||
|
|
||||||
return new ShiftSignupState(ShiftSignupState::ANGELTYPE, $free_entries);
|
return new ShiftSignupState(ShiftSignupState::ANGELTYPE, $free_entries);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Shift_collides($shift, $user_shifts)) {
|
if (Shift_collides($shift, $user_shifts)) {
|
||||||
// you cannot join if user alread joined a parallel or this shift
|
// you cannot join if user alread joined a parallel or this shift
|
||||||
return new ShiftSignupState(ShiftSignupState::COLLIDES, $free_entries);
|
return new ShiftSignupState(ShiftSignupState::COLLIDES, $free_entries);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hooray, shift is free for you!
|
// Hooray, shift is free for you!
|
||||||
return new ShiftSignupState(ShiftSignupState::FREE, $free_entries);
|
return new ShiftSignupState(ShiftSignupState::FREE, $free_entries);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -224,14 +273,14 @@ function Shift_signup_allowed_angeltype_supporter($angeltype, $needed_angeltype,
|
||||||
if ($free_entries == 0) {
|
if ($free_entries == 0) {
|
||||||
return new ShiftSignupState(ShiftSignupState::OCCUPIED, $free_entries);
|
return new ShiftSignupState(ShiftSignupState::OCCUPIED, $free_entries);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ShiftSignupState(ShiftSignupState::FREE, $free_entries);
|
return new ShiftSignupState(ShiftSignupState::FREE, $free_entries);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if an admin can sign up a user to a shift.
|
* Check if an admin can sign up a user to a shift.
|
||||||
*
|
*
|
||||||
* @param Shift $shift
|
* @param Shift $shift
|
||||||
* The shift
|
* The shift
|
||||||
* @param AngelType $angeltype
|
* @param AngelType $angeltype
|
||||||
* The angeltype to which the user wants to sign up
|
* The angeltype to which the user wants to sign up
|
||||||
|
@ -239,38 +288,56 @@ function Shift_signup_allowed_angeltype_supporter($angeltype, $needed_angeltype,
|
||||||
function Shift_signup_allowed_admin($angeltype, $needed_angeltype, $shift_entries)
|
function Shift_signup_allowed_admin($angeltype, $needed_angeltype, $shift_entries)
|
||||||
{
|
{
|
||||||
$free_entries = Shift_free_entries($needed_angeltype, $shift_entries);
|
$free_entries = Shift_free_entries($needed_angeltype, $shift_entries);
|
||||||
|
|
||||||
if ($free_entries == 0) {
|
if ($free_entries == 0) {
|
||||||
// User shift admins may join anybody in every shift
|
// User shift admins may join anybody in every shift
|
||||||
return new ShiftSignupState(ShiftSignupState::ADMIN, $free_entries);
|
return new ShiftSignupState(ShiftSignupState::ADMIN, $free_entries);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ShiftSignupState(ShiftSignupState::FREE, $free_entries);
|
return new ShiftSignupState(ShiftSignupState::FREE, $free_entries);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if an angel can sign up for given shift.
|
* Check if an angel can sign up for given shift.
|
||||||
*
|
*
|
||||||
* @param Shift $shift
|
* @param Shift $shift
|
||||||
* The shift
|
* The shift
|
||||||
* @param AngelType $angeltype
|
* @param AngelType $angeltype
|
||||||
* The angeltype to which the user wants to sign up
|
* The angeltype to which the user wants to sign up
|
||||||
* @param array<Shift> $user_shifts
|
* @param array <Shift> $user_shifts
|
||||||
* List of the users shifts
|
* List of the users shifts
|
||||||
*/
|
*/
|
||||||
function Shift_signup_allowed($signup_user, $shift, $angeltype, $user_angeltype = null, $user_shifts = null, $needed_angeltype, $shift_entries)
|
function Shift_signup_allowed(
|
||||||
{
|
$signup_user,
|
||||||
|
$shift,
|
||||||
|
$angeltype,
|
||||||
|
$user_angeltype = null,
|
||||||
|
$user_shifts = null,
|
||||||
|
$needed_angeltype,
|
||||||
|
$shift_entries
|
||||||
|
) {
|
||||||
global $user, $privileges;
|
global $user, $privileges;
|
||||||
|
|
||||||
if (in_array('user_shifts_admin', $privileges)) {
|
if (in_array('user_shifts_admin', $privileges)) {
|
||||||
return Shift_signup_allowed_admin($angeltype, $needed_angeltype, $shift_entries);
|
return Shift_signup_allowed_admin($angeltype, $needed_angeltype, $shift_entries);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (in_array('shiftentry_edit_angeltype_supporter', $privileges) && User_is_AngelType_supporter($user, $angeltype)) {
|
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_angeltype_supporter($angeltype, $needed_angeltype, $shift_entries);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Shift_signup_allowed_angel($signup_user, $shift, $angeltype, $user_angeltype, $user_shifts, $needed_angeltype, $shift_entries);
|
return Shift_signup_allowed_angel(
|
||||||
|
$signup_user,
|
||||||
|
$shift,
|
||||||
|
$angeltype,
|
||||||
|
$user_angeltype,
|
||||||
|
$user_shifts,
|
||||||
|
$needed_angeltype,
|
||||||
|
$shift_entries
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -287,7 +354,7 @@ function Shift_delete_by_psid($shift_psid)
|
||||||
function Shift_delete($shift_id)
|
function Shift_delete($shift_id)
|
||||||
{
|
{
|
||||||
mail_shift_delete(Shift($shift_id));
|
mail_shift_delete(Shift($shift_id));
|
||||||
|
|
||||||
$result = sql_query("DELETE FROM `Shifts` WHERE `SID`='" . sql_escape($shift_id) . "'");
|
$result = sql_query("DELETE FROM `Shifts` WHERE `SID`='" . sql_escape($shift_id) . "'");
|
||||||
if ($result === false) {
|
if ($result === false) {
|
||||||
engelsystem_error('Unable to delete shift.');
|
engelsystem_error('Unable to delete shift.');
|
||||||
|
@ -303,8 +370,9 @@ function Shift_update($shift)
|
||||||
global $user;
|
global $user;
|
||||||
$shift['name'] = ShiftType($shift['shifttype_id'])['name'];
|
$shift['name'] = ShiftType($shift['shifttype_id'])['name'];
|
||||||
mail_shift_change(Shift($shift['SID']), $shift);
|
mail_shift_change(Shift($shift['SID']), $shift);
|
||||||
|
|
||||||
return sql_query("UPDATE `Shifts` SET
|
return sql_query("
|
||||||
|
UPDATE `Shifts` SET
|
||||||
`shifttype_id`='" . sql_escape($shift['shifttype_id']) . "',
|
`shifttype_id`='" . sql_escape($shift['shifttype_id']) . "',
|
||||||
`start`='" . sql_escape($shift['start']) . "',
|
`start`='" . sql_escape($shift['start']) . "',
|
||||||
`end`='" . sql_escape($shift['end']) . "',
|
`end`='" . sql_escape($shift['end']) . "',
|
||||||
|
@ -314,7 +382,8 @@ function Shift_update($shift)
|
||||||
`PSID`=" . sql_null($shift['PSID']) . ",
|
`PSID`=" . sql_null($shift['PSID']) . ",
|
||||||
`edited_by_user_id`='" . sql_escape($user['UID']) . "',
|
`edited_by_user_id`='" . sql_escape($user['UID']) . "',
|
||||||
`edited_at_timestamp`=" . time() . "
|
`edited_at_timestamp`=" . time() . "
|
||||||
WHERE `SID`='" . sql_escape($shift['SID']) . "'");
|
WHERE `SID`='" . sql_escape($shift['SID']) . "'
|
||||||
|
");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -341,7 +410,8 @@ function Shift_update_by_psid($shift)
|
||||||
function Shift_create($shift)
|
function Shift_create($shift)
|
||||||
{
|
{
|
||||||
global $user;
|
global $user;
|
||||||
$result = sql_query("INSERT INTO `Shifts` SET
|
$result = sql_query("
|
||||||
|
INSERT INTO `Shifts` SET
|
||||||
`shifttype_id`='" . sql_escape($shift['shifttype_id']) . "',
|
`shifttype_id`='" . sql_escape($shift['shifttype_id']) . "',
|
||||||
`start`='" . sql_escape($shift['start']) . "',
|
`start`='" . sql_escape($shift['start']) . "',
|
||||||
`end`='" . sql_escape($shift['end']) . "',
|
`end`='" . sql_escape($shift['end']) . "',
|
||||||
|
@ -350,7 +420,8 @@ function Shift_create($shift)
|
||||||
`URL`=" . sql_null($shift['URL']) . ",
|
`URL`=" . sql_null($shift['URL']) . ",
|
||||||
`PSID`=" . sql_null($shift['PSID']) . ",
|
`PSID`=" . sql_null($shift['PSID']) . ",
|
||||||
`created_by_user_id`='" . sql_escape($user['UID']) . "',
|
`created_by_user_id`='" . sql_escape($user['UID']) . "',
|
||||||
`created_at_timestamp`=" . time());
|
`created_at_timestamp`=" . time()
|
||||||
|
);
|
||||||
if ($result === false) {
|
if ($result === false) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -384,7 +455,7 @@ function Shifts_by_user($user, $include_freeload_comments = false)
|
||||||
* Returns Shift by id.
|
* Returns Shift by id.
|
||||||
*
|
*
|
||||||
* @param $shift_id Shift
|
* @param $shift_id Shift
|
||||||
* ID
|
* ID
|
||||||
*/
|
*/
|
||||||
function Shift($shift_id)
|
function Shift($shift_id)
|
||||||
{
|
{
|
||||||
|
@ -394,30 +465,30 @@ function Shift($shift_id)
|
||||||
JOIN `ShiftTypes` ON (`ShiftTypes`.`id` = `Shifts`.`shifttype_id`)
|
JOIN `ShiftTypes` ON (`ShiftTypes`.`id` = `Shifts`.`shifttype_id`)
|
||||||
WHERE `SID`='" . sql_escape($shift_id) . "'");
|
WHERE `SID`='" . sql_escape($shift_id) . "'");
|
||||||
$shiftsEntry_source = sql_select("SELECT `id`, `TID` , `UID` , `freeloaded` FROM `ShiftEntry` 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) {
|
if ($shifts_source === false) {
|
||||||
engelsystem_error('Unable to load shift.');
|
engelsystem_error('Unable to load shift.');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($shifts_source)) {
|
if (empty($shifts_source)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $shifts_source[0];
|
$result = $shifts_source[0];
|
||||||
|
|
||||||
$result['ShiftEntry'] = $shiftsEntry_source;
|
$result['ShiftEntry'] = $shiftsEntry_source;
|
||||||
$result['NeedAngels'] = [];
|
$result['NeedAngels'] = [];
|
||||||
|
|
||||||
$temp = NeededAngelTypes_by_shift($shift_id);
|
$temp = NeededAngelTypes_by_shift($shift_id);
|
||||||
foreach ($temp as $e) {
|
foreach ($temp as $e) {
|
||||||
$result['NeedAngels'][] = [
|
$result['NeedAngels'][] = [
|
||||||
'TID' => $e['angel_type_id'],
|
'TID' => $e['angel_type_id'],
|
||||||
'count' => $e['count'],
|
'count' => $e['count'],
|
||||||
'restricted' => $e['restricted'],
|
'restricted' => $e['restricted'],
|
||||||
'taken' => $e['taken']
|
'taken' => $e['taken']
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -427,7 +498,7 @@ function Shift($shift_id)
|
||||||
function Shifts()
|
function Shifts()
|
||||||
{
|
{
|
||||||
$shifts_source = sql_select("
|
$shifts_source = sql_select("
|
||||||
SELECT `ShiftTypes`.`name`, `Shifts`.*, `Room`.`RID`, `Room`.`Name` as `room_name`
|
SELECT `ShiftTypes`.`name`, `Shifts`.*, `Room`.`RID`, `Room`.`Name` AS `room_name`
|
||||||
FROM `Shifts`
|
FROM `Shifts`
|
||||||
JOIN `ShiftTypes` ON (`ShiftTypes`.`id` = `Shifts`.`shifttype_id`)
|
JOIN `ShiftTypes` ON (`ShiftTypes`.`id` = `Shifts`.`shifttype_id`)
|
||||||
JOIN `Room` ON `Room`.`RID` = `Shifts`.`RID`
|
JOIN `Room` ON `Room`.`RID` = `Shifts`.`RID`
|
||||||
|
@ -435,15 +506,15 @@ function Shifts()
|
||||||
if ($shifts_source === false) {
|
if ($shifts_source === false) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($shifts_source as &$shift) {
|
foreach ($shifts_source as &$shift) {
|
||||||
$needed_angeltypes = NeededAngelTypes_by_shift($shift['SID']);
|
$needed_angeltypes = NeededAngelTypes_by_shift($shift['SID']);
|
||||||
if ($needed_angeltypes === false) {
|
if ($needed_angeltypes === false) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$shift['angeltypes'] = $needed_angeltypes;
|
$shift['angeltypes'] = $needed_angeltypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $shifts_source;
|
return $shifts_source;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
/**
|
/**
|
||||||
* Checks if a user joined an angeltype.
|
* Checks if a user joined an angeltype.
|
||||||
*
|
*
|
||||||
* @param User $user
|
* @param User $user
|
||||||
* The user to be checked
|
* The user to be checked
|
||||||
* @param Angeltype $angeltype
|
* @param Angeltype $angeltype
|
||||||
* The angeltype to be checked
|
* The angeltype to be checked
|
||||||
|
@ -51,19 +51,20 @@ function User_angeltypes($user)
|
||||||
function User_unconfirmed_AngelTypes($user)
|
function User_unconfirmed_AngelTypes($user)
|
||||||
{
|
{
|
||||||
$result = sql_select("
|
$result = sql_select("
|
||||||
SELECT
|
SELECT
|
||||||
`UserAngelTypes`.*,
|
`UserAngelTypes`.*,
|
||||||
`AngelTypes`.`name`,
|
`AngelTypes`.`name`,
|
||||||
count(`UnconfirmedMembers`.`user_id`) as `count`
|
count(`UnconfirmedMembers`.`user_id`) AS `count`
|
||||||
FROM `UserAngelTypes`
|
FROM `UserAngelTypes`
|
||||||
JOIN `AngelTypes` ON `UserAngelTypes`.`angeltype_id`=`AngelTypes`.`id`
|
JOIN `AngelTypes` ON `UserAngelTypes`.`angeltype_id`=`AngelTypes`.`id`
|
||||||
JOIN `UserAngelTypes` as `UnconfirmedMembers` ON `UserAngelTypes`.`angeltype_id`=`UnconfirmedMembers`.`angeltype_id`
|
JOIN `UserAngelTypes` AS `UnconfirmedMembers` ON `UserAngelTypes`.`angeltype_id`=`UnconfirmedMembers`.`angeltype_id`
|
||||||
WHERE `UserAngelTypes`.`user_id`='" . sql_escape($user['UID']) . "'
|
WHERE `UserAngelTypes`.`user_id`='" . sql_escape($user['UID']) . "'
|
||||||
AND `UserAngelTypes`.`supporter`=TRUE
|
AND `UserAngelTypes`.`supporter`=TRUE
|
||||||
AND `AngelTypes`.`restricted`=TRUE
|
AND `AngelTypes`.`restricted`=TRUE
|
||||||
AND `UnconfirmedMembers`.`confirm_user_id` IS NULL
|
AND `UnconfirmedMembers`.`confirm_user_id` IS NULL
|
||||||
GROUP BY `UserAngelTypes`.`angeltype_id`
|
GROUP BY `UserAngelTypes`.`angeltype_id`
|
||||||
ORDER BY `AngelTypes`.`name`");
|
ORDER BY `AngelTypes`.`name`
|
||||||
|
");
|
||||||
if ($result === false) {
|
if ($result === false) {
|
||||||
engelsystem_error("Unable to load user angeltypes.");
|
engelsystem_error("Unable to load user angeltypes.");
|
||||||
}
|
}
|
||||||
|
@ -73,7 +74,7 @@ function User_unconfirmed_AngelTypes($user)
|
||||||
/**
|
/**
|
||||||
* Returns true if user is angeltype supporter or has privilege admin_user_angeltypes.
|
* Returns true if user is angeltype supporter or has privilege admin_user_angeltypes.
|
||||||
*
|
*
|
||||||
* @param User $user
|
* @param User $user
|
||||||
* @param AngelType $angeltype
|
* @param AngelType $angeltype
|
||||||
*/
|
*/
|
||||||
function User_is_AngelType_supporter(&$user, $angeltype)
|
function User_is_AngelType_supporter(&$user, $angeltype)
|
||||||
|
@ -87,13 +88,14 @@ function User_is_AngelType_supporter(&$user, $angeltype)
|
||||||
WHERE `user_id`='" . sql_escape($user['UID']) . "'
|
WHERE `user_id`='" . sql_escape($user['UID']) . "'
|
||||||
AND `angeltype_id`='" . sql_escape($angeltype['id']) . "'
|
AND `angeltype_id`='" . sql_escape($angeltype['id']) . "'
|
||||||
AND `supporter`=TRUE
|
AND `supporter`=TRUE
|
||||||
LIMIT 1") > 0) || in_array('admin_user_angeltypes', $user['privileges']);
|
LIMIT 1
|
||||||
|
") > 0) || in_array('admin_user_angeltypes', $user['privileges']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add or remove supporter rights.
|
* Add or remove supporter rights.
|
||||||
*
|
*
|
||||||
* @param int $user_angeltype_id
|
* @param int $user_angeltype_id
|
||||||
* @param bool $supporter
|
* @param bool $supporter
|
||||||
*/
|
*/
|
||||||
function UserAngelType_update($user_angeltype_id, $supporter)
|
function UserAngelType_update($user_angeltype_id, $supporter)
|
||||||
|
@ -102,7 +104,8 @@ function UserAngelType_update($user_angeltype_id, $supporter)
|
||||||
UPDATE `UserAngelTypes`
|
UPDATE `UserAngelTypes`
|
||||||
SET `supporter`=" . sql_bool($supporter) . "
|
SET `supporter`=" . sql_bool($supporter) . "
|
||||||
WHERE `id`='" . sql_escape($user_angeltype_id) . "'
|
WHERE `id`='" . sql_escape($user_angeltype_id) . "'
|
||||||
LIMIT 1");
|
LIMIT 1
|
||||||
|
");
|
||||||
if ($result === false) {
|
if ($result === false) {
|
||||||
engelsystem_error("Unable to update supporter rights.");
|
engelsystem_error("Unable to update supporter rights.");
|
||||||
}
|
}
|
||||||
|
@ -119,7 +122,8 @@ function UserAngelTypes_delete_all($angeltype_id)
|
||||||
$result = sql_query("
|
$result = sql_query("
|
||||||
DELETE FROM `UserAngelTypes`
|
DELETE FROM `UserAngelTypes`
|
||||||
WHERE `angeltype_id`='" . sql_escape($angeltype_id) . "'
|
WHERE `angeltype_id`='" . sql_escape($angeltype_id) . "'
|
||||||
AND `confirm_user_id` IS NULL");
|
AND `confirm_user_id` IS NULL
|
||||||
|
");
|
||||||
if ($result === false) {
|
if ($result === false) {
|
||||||
engelsystem_error("Unable to delete all unconfirmed users.");
|
engelsystem_error("Unable to delete all unconfirmed users.");
|
||||||
}
|
}
|
||||||
|
@ -129,7 +133,7 @@ function UserAngelTypes_delete_all($angeltype_id)
|
||||||
/**
|
/**
|
||||||
* Confirm all unconfirmed UserAngelTypes for given Angeltype.
|
* Confirm all unconfirmed UserAngelTypes for given Angeltype.
|
||||||
*
|
*
|
||||||
* @param int $angeltype_id
|
* @param int $angeltype_id
|
||||||
* @param User $confirm_user
|
* @param User $confirm_user
|
||||||
*/
|
*/
|
||||||
function UserAngelTypes_confirm_all($angeltype_id, $confirm_user)
|
function UserAngelTypes_confirm_all($angeltype_id, $confirm_user)
|
||||||
|
@ -138,7 +142,8 @@ function UserAngelTypes_confirm_all($angeltype_id, $confirm_user)
|
||||||
UPDATE `UserAngelTypes`
|
UPDATE `UserAngelTypes`
|
||||||
SET `confirm_user_id`='" . sql_escape($confirm_user['UID']) . "'
|
SET `confirm_user_id`='" . sql_escape($confirm_user['UID']) . "'
|
||||||
WHERE `angeltype_id`='" . sql_escape($angeltype_id) . "'
|
WHERE `angeltype_id`='" . sql_escape($angeltype_id) . "'
|
||||||
AND `confirm_user_id` IS NULL");
|
AND `confirm_user_id` IS NULL
|
||||||
|
");
|
||||||
if ($result === false) {
|
if ($result === false) {
|
||||||
engelsystem_error("Unable to confirm all users.");
|
engelsystem_error("Unable to confirm all users.");
|
||||||
}
|
}
|
||||||
|
@ -148,7 +153,7 @@ function UserAngelTypes_confirm_all($angeltype_id, $confirm_user)
|
||||||
/**
|
/**
|
||||||
* Confirm an UserAngelType with confirming user.
|
* Confirm an UserAngelType with confirming user.
|
||||||
*
|
*
|
||||||
* @param int $user_angeltype_id
|
* @param int $user_angeltype_id
|
||||||
* @param User $confirm_user
|
* @param User $confirm_user
|
||||||
*/
|
*/
|
||||||
function UserAngelType_confirm($user_angeltype_id, $confirm_user)
|
function UserAngelType_confirm($user_angeltype_id, $confirm_user)
|
||||||
|
@ -180,7 +185,7 @@ function UserAngelType_delete($user_angeltype)
|
||||||
/**
|
/**
|
||||||
* Create an UserAngelType.
|
* Create an UserAngelType.
|
||||||
*
|
*
|
||||||
* @param User $user
|
* @param User $user
|
||||||
* @param Angeltype $angeltype
|
* @param Angeltype $angeltype
|
||||||
*/
|
*/
|
||||||
function UserAngelType_create($user, $angeltype)
|
function UserAngelType_create($user, $angeltype)
|
||||||
|
@ -219,7 +224,7 @@ function UserAngelType($user_angeltype_id)
|
||||||
/**
|
/**
|
||||||
* Get an UserAngelType by user and angeltype.
|
* Get an UserAngelType by user and angeltype.
|
||||||
*
|
*
|
||||||
* @param User $user
|
* @param User $user
|
||||||
* @param Angeltype $angeltype
|
* @param Angeltype $angeltype
|
||||||
*/
|
*/
|
||||||
function UserAngelType_by_User_and_AngelType($user, $angeltype)
|
function UserAngelType_by_User_and_AngelType($user, $angeltype)
|
||||||
|
|
|
@ -7,14 +7,14 @@
|
||||||
function UserDriverLicense_new()
|
function UserDriverLicense_new()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'user_id' => null,
|
'user_id' => null,
|
||||||
'has_car' => false,
|
'has_car' => false,
|
||||||
'has_license_car' => false,
|
'has_license_car' => false,
|
||||||
'has_license_3_5t_transporter' => false,
|
'has_license_3_5t_transporter' => false,
|
||||||
'has_license_7_5t_truck' => false,
|
'has_license_7_5t_truck' => false,
|
||||||
'has_license_12_5t_truck' => false,
|
'has_license_12_5t_truck' => false,
|
||||||
'has_license_forklift' => false
|
'has_license_forklift' => false
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -26,7 +26,12 @@ function UserDriverLicense_new()
|
||||||
*/
|
*/
|
||||||
function UserDriverLicense_valid($user_driver_license)
|
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'];
|
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'];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns users groups
|
* Returns users groups
|
||||||
|
*
|
||||||
* @param User $user
|
* @param User $user
|
||||||
*/
|
*/
|
||||||
function User_groups($user)
|
function User_groups($user)
|
||||||
|
|
|
@ -22,7 +22,8 @@ function User_delete($user_id)
|
||||||
*/
|
*/
|
||||||
function User_update($user)
|
function User_update($user)
|
||||||
{
|
{
|
||||||
return sql_query("UPDATE `User` SET
|
return sql_query("
|
||||||
|
UPDATE `User` SET
|
||||||
`Nick`='" . sql_escape($user['Nick']) . "',
|
`Nick`='" . sql_escape($user['Nick']) . "',
|
||||||
`Name`='" . sql_escape($user['Name']) . "',
|
`Name`='" . sql_escape($user['Name']) . "',
|
||||||
`Vorname`='" . sql_escape($user['Vorname']) . "',
|
`Vorname`='" . sql_escape($user['Vorname']) . "',
|
||||||
|
@ -46,7 +47,8 @@ function User_update($user)
|
||||||
`arrival_date`='" . sql_escape($user['arrival_date']) . "',
|
`arrival_date`='" . sql_escape($user['arrival_date']) . "',
|
||||||
`planned_arrival_date`='" . sql_escape($user['planned_arrival_date']) . "',
|
`planned_arrival_date`='" . sql_escape($user['planned_arrival_date']) . "',
|
||||||
`planned_departure_date`=" . sql_null($user['planned_departure_date']) . "
|
`planned_departure_date`=" . sql_null($user['planned_departure_date']) . "
|
||||||
WHERE `UID`='" . sql_escape($user['UID']) . "'");
|
WHERE `UID`='" . sql_escape($user['UID']) . "'
|
||||||
|
");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -83,19 +85,19 @@ function User_tshirts_count()
|
||||||
function User_sortable_columns()
|
function User_sortable_columns()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'Nick',
|
'Nick',
|
||||||
'Name',
|
'Name',
|
||||||
'Vorname',
|
'Vorname',
|
||||||
'Alter',
|
'Alter',
|
||||||
'DECT',
|
'DECT',
|
||||||
'email',
|
'email',
|
||||||
'Size',
|
'Size',
|
||||||
'Gekommen',
|
'Gekommen',
|
||||||
'Aktiv',
|
'Aktiv',
|
||||||
'force_active',
|
'force_active',
|
||||||
'Tshirt',
|
'Tshirt',
|
||||||
'lastLogIn'
|
'lastLogIn'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -116,7 +118,7 @@ function Users($order_by = 'Nick')
|
||||||
function User_is_freeloader($user)
|
function User_is_freeloader($user)
|
||||||
{
|
{
|
||||||
global $max_freeloadable_shifts, $user;
|
global $max_freeloadable_shifts, $user;
|
||||||
|
|
||||||
return count(ShiftEntries_freeloaded_by_user($user)) >= $max_freeloadable_shifts;
|
return count(ShiftEntries_freeloaded_by_user($user)) >= $max_freeloadable_shifts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,7 +132,8 @@ function Users_by_angeltype_inverted($angeltype)
|
||||||
$result = sql_select("
|
$result = sql_select("
|
||||||
SELECT `User`.*
|
SELECT `User`.*
|
||||||
FROM `User`
|
FROM `User`
|
||||||
LEFT JOIN `UserAngelTypes` ON (`User`.`UID`=`UserAngelTypes`.`user_id` AND `angeltype_id`='" . sql_escape($angeltype['id']) . "')
|
LEFT JOIN `UserAngelTypes`
|
||||||
|
ON (`User`.`UID`=`UserAngelTypes`.`user_id` AND `angeltype_id`='" . sql_escape($angeltype['id']) . "')
|
||||||
WHERE `UserAngelTypes`.`id` IS NULL
|
WHERE `UserAngelTypes`.`id` IS NULL
|
||||||
ORDER BY `Nick`");
|
ORDER BY `Nick`");
|
||||||
if ($result === false) {
|
if ($result === false) {
|
||||||
|
@ -149,7 +152,7 @@ function Users_by_angeltype($angeltype)
|
||||||
$result = sql_select("
|
$result = sql_select("
|
||||||
SELECT
|
SELECT
|
||||||
`User`.*,
|
`User`.*,
|
||||||
`UserAngelTypes`.`id` as `user_angeltype_id`,
|
`UserAngelTypes`.`id` AS `user_angeltype_id`,
|
||||||
`UserAngelTypes`.`confirm_user_id`,
|
`UserAngelTypes`.`confirm_user_id`,
|
||||||
`UserAngelTypes`.`supporter`,
|
`UserAngelTypes`.`supporter`,
|
||||||
`UserDriverLicenses`.*
|
`UserDriverLicenses`.*
|
||||||
|
@ -207,7 +210,7 @@ function User_validate_jabber($jabber)
|
||||||
$jabber = strip_item($jabber);
|
$jabber = strip_item($jabber);
|
||||||
if ($jabber == '') {
|
if ($jabber == '') {
|
||||||
// Empty is ok
|
// Empty is ok
|
||||||
return new ValidationResult(true, '');
|
return new ValidationResult(true, '');
|
||||||
}
|
}
|
||||||
return new ValidationResult(check_email($jabber), $jabber);
|
return new ValidationResult(check_email($jabber), $jabber);
|
||||||
}
|
}
|
||||||
|
@ -223,20 +226,20 @@ function User_validate_planned_arrival_date($planned_arrival_date)
|
||||||
{
|
{
|
||||||
if ($planned_arrival_date == null) {
|
if ($planned_arrival_date == null) {
|
||||||
// null is not okay
|
// null is not okay
|
||||||
return new ValidationResult(false, time());
|
return new ValidationResult(false, time());
|
||||||
}
|
}
|
||||||
$event_config = EventConfig();
|
$event_config = EventConfig();
|
||||||
if ($event_config == null) {
|
if ($event_config == null) {
|
||||||
// Nothing to validate against
|
// Nothing to validate against
|
||||||
return new ValidationResult(true, $planned_arrival_date);
|
return new ValidationResult(true, $planned_arrival_date);
|
||||||
}
|
}
|
||||||
if (isset($event_config['buildup_start_date']) && $planned_arrival_date < $event_config['buildup_start_date']) {
|
if (isset($event_config['buildup_start_date']) && $planned_arrival_date < $event_config['buildup_start_date']) {
|
||||||
// Planned arrival can not be before buildup start date
|
// Planned arrival can not be before buildup start date
|
||||||
return new ValidationResult(false, $event_config['buildup_start_date']);
|
return new ValidationResult(false, $event_config['buildup_start_date']);
|
||||||
}
|
}
|
||||||
if (isset($event_config['teardown_end_date']) && $planned_arrival_date > $event_config['teardown_end_date']) {
|
if (isset($event_config['teardown_end_date']) && $planned_arrival_date > $event_config['teardown_end_date']) {
|
||||||
// Planned arrival can not be after teardown end date
|
// Planned arrival can not be after teardown end date
|
||||||
return new ValidationResult(false, $event_config['teardown_end_date']);
|
return new ValidationResult(false, $event_config['teardown_end_date']);
|
||||||
}
|
}
|
||||||
return new ValidationResult(true, $planned_arrival_date);
|
return new ValidationResult(true, $planned_arrival_date);
|
||||||
}
|
}
|
||||||
|
@ -254,24 +257,24 @@ function User_validate_planned_departure_date($planned_arrival_date, $planned_de
|
||||||
{
|
{
|
||||||
if ($planned_departure_date == null) {
|
if ($planned_departure_date == null) {
|
||||||
// null is okay
|
// null is okay
|
||||||
return new ValidationResult(true, null);
|
return new ValidationResult(true, null);
|
||||||
}
|
}
|
||||||
if ($planned_arrival_date > $planned_departure_date) {
|
if ($planned_arrival_date > $planned_departure_date) {
|
||||||
// departure cannot be before arrival
|
// departure cannot be before arrival
|
||||||
return new ValidationResult(false, $planned_arrival_date);
|
return new ValidationResult(false, $planned_arrival_date);
|
||||||
}
|
}
|
||||||
$event_config = EventConfig();
|
$event_config = EventConfig();
|
||||||
if ($event_config == null) {
|
if ($event_config == null) {
|
||||||
// Nothing to validate against
|
// Nothing to validate against
|
||||||
return new ValidationResult(true, $planned_departure_date);
|
return new ValidationResult(true, $planned_departure_date);
|
||||||
}
|
}
|
||||||
if (isset($event_config['buildup_start_date']) && $planned_departure_date < $event_config['buildup_start_date']) {
|
if (isset($event_config['buildup_start_date']) && $planned_departure_date < $event_config['buildup_start_date']) {
|
||||||
// Planned arrival can not be before buildup start date
|
// Planned arrival can not be before buildup start date
|
||||||
return new ValidationResult(false, $event_config['buildup_start_date']);
|
return new ValidationResult(false, $event_config['buildup_start_date']);
|
||||||
}
|
}
|
||||||
if (isset($event_config['teardown_end_date']) && $planned_departure_date > $event_config['teardown_end_date']) {
|
if (isset($event_config['teardown_end_date']) && $planned_departure_date > $event_config['teardown_end_date']) {
|
||||||
// Planned arrival can not be after teardown end date
|
// Planned arrival can not be after teardown end date
|
||||||
return new ValidationResult(false, $event_config['teardown_end_date']);
|
return new ValidationResult(false, $event_config['teardown_end_date']);
|
||||||
}
|
}
|
||||||
return new ValidationResult(true, $planned_departure_date);
|
return new ValidationResult(true, $planned_departure_date);
|
||||||
}
|
}
|
||||||
|
@ -384,14 +387,14 @@ function User_generate_password_recovery_token(&$user)
|
||||||
function User_get_eligable_voucher_count(&$user)
|
function User_get_eligable_voucher_count(&$user)
|
||||||
{
|
{
|
||||||
global $voucher_settings;
|
global $voucher_settings;
|
||||||
|
|
||||||
$shifts_done = count(ShiftEntries_finished_by_user($user));
|
$shifts_done = count(ShiftEntries_finished_by_user($user));
|
||||||
|
|
||||||
$earned_vouchers = $user['got_voucher'] - $voucher_settings['initial_vouchers'];
|
$earned_vouchers = $user['got_voucher'] - $voucher_settings['initial_vouchers'];
|
||||||
$elegible_vouchers = $shifts_done / $voucher_settings['shifts_per_voucher'] - $earned_vouchers;
|
$elegible_vouchers = $shifts_done / $voucher_settings['shifts_per_voucher'] - $earned_vouchers;
|
||||||
if ($elegible_vouchers < 0) {
|
if ($elegible_vouchers < 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $elegible_vouchers;
|
return $elegible_vouchers;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,33 +12,33 @@ class ValidationResult
|
||||||
|
|
||||||
private $value;
|
private $value;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
* @param boolean $valid
|
* @param boolean $valid
|
||||||
* Is the value valid?
|
* Is the value valid?
|
||||||
* @param * $value
|
* @param * $value
|
||||||
* The validated value
|
* The validated value
|
||||||
*/
|
*/
|
||||||
public function __construct($valid, $value)
|
public function __construct($valid, $value)
|
||||||
{
|
{
|
||||||
$this->valid = $valid;
|
$this->valid = $valid;
|
||||||
$this->value = $value;
|
$this->value = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is the value valid?
|
* Is the value valid?
|
||||||
*/
|
*/
|
||||||
public function isValid()
|
public function isValid()
|
||||||
{
|
{
|
||||||
return $this->valid;
|
return $this->valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The parsed/validated value.
|
* The parsed/validated value.
|
||||||
*/
|
*/
|
||||||
public function getValue()
|
public function getValue()
|
||||||
{
|
{
|
||||||
return $this->value;
|
return $this->value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
function sql_close()
|
function sql_close()
|
||||||
{
|
{
|
||||||
global $sql_connection;
|
global $sql_connection;
|
||||||
|
|
||||||
return $sql_connection->close();
|
return $sql_connection->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,11 +24,11 @@ function sql_null($value = null)
|
||||||
function sql_transaction_start()
|
function sql_transaction_start()
|
||||||
{
|
{
|
||||||
global $sql_nested_transaction_level;
|
global $sql_nested_transaction_level;
|
||||||
|
|
||||||
if ($sql_nested_transaction_level ++ == 0) {
|
if ($sql_nested_transaction_level++ == 0) {
|
||||||
return sql_query("BEGIN");
|
return sql_query("BEGIN");
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,11 +38,11 @@ function sql_transaction_start()
|
||||||
function sql_transaction_commit()
|
function sql_transaction_commit()
|
||||||
{
|
{
|
||||||
global $sql_nested_transaction_level;
|
global $sql_nested_transaction_level;
|
||||||
|
|
||||||
if (-- $sql_nested_transaction_level == 0) {
|
if (--$sql_nested_transaction_level == 0) {
|
||||||
return sql_query("COMMIT");
|
return sql_query("COMMIT");
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,11 +52,11 @@ function sql_transaction_commit()
|
||||||
function sql_transaction_rollback()
|
function sql_transaction_rollback()
|
||||||
{
|
{
|
||||||
global $sql_nested_transaction_level;
|
global $sql_nested_transaction_level;
|
||||||
|
|
||||||
if (-- $sql_nested_transaction_level == 0) {
|
if (--$sql_nested_transaction_level == 0) {
|
||||||
return sql_query("ROLLBACK");
|
return sql_query("ROLLBACK");
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,12 +69,12 @@ function sql_transaction_rollback()
|
||||||
function sql_error($message)
|
function sql_error($message)
|
||||||
{
|
{
|
||||||
sql_close();
|
sql_close();
|
||||||
|
|
||||||
$message = trim($message) . "\n";
|
$message = trim($message) . "\n";
|
||||||
$message .= debug_string_backtrace() . "\n";
|
$message .= debug_string_backtrace() . "\n";
|
||||||
|
|
||||||
error_log('mysql_provider error: ' . $message);
|
error_log('mysql_provider error: ' . $message);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,23 +94,23 @@ function sql_error($message)
|
||||||
function sql_connect($host, $user, $pass, $db_name)
|
function sql_connect($host, $user, $pass, $db_name)
|
||||||
{
|
{
|
||||||
global $sql_connection;
|
global $sql_connection;
|
||||||
|
|
||||||
$sql_connection = new mysqli($host, $user, $pass, $db_name);
|
$sql_connection = new mysqli($host, $user, $pass, $db_name);
|
||||||
if ($sql_connection->connect_errno) {
|
if ($sql_connection->connect_errno) {
|
||||||
error("Unable to connect to MySQL: " . $sql_connection->connect_error);
|
error("Unable to connect to MySQL: " . $sql_connection->connect_error);
|
||||||
return sql_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;");
|
$result = $sql_connection->query("SET CHARACTER SET utf8;");
|
||||||
if (! $result) {
|
if (!$result) {
|
||||||
return sql_error("Unable to set utf8 character set (" . $sql_connection->errno . ") " . $sql_connection->error);
|
return sql_error("Unable to set utf8 character set (" . $sql_connection->errno . ") " . $sql_connection->error);
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $sql_connection->set_charset('utf8');
|
$result = $sql_connection->set_charset('utf8');
|
||||||
if (! $result) {
|
if (!$result) {
|
||||||
return sql_error("Unable to set utf8 names (" . $sql_connection->errno . ") " . $sql_connection->error);
|
return sql_error("Unable to set utf8 names (" . $sql_connection->errno . ") " . $sql_connection->error);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $sql_connection;
|
return $sql_connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ function sql_connect($host, $user, $pass, $db_name)
|
||||||
function sql_select_db($db_name)
|
function sql_select_db($db_name)
|
||||||
{
|
{
|
||||||
global $sql_connection;
|
global $sql_connection;
|
||||||
if (! $sql_connection->select_db($db_name)) {
|
if (!$sql_connection->select_db($db_name)) {
|
||||||
return sql_error("No database selected.");
|
return sql_error("No database selected.");
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -139,11 +139,11 @@ function sql_select_db($db_name)
|
||||||
function sql_select($query)
|
function sql_select($query)
|
||||||
{
|
{
|
||||||
global $sql_connection;
|
global $sql_connection;
|
||||||
|
|
||||||
// echo $query . ";\n";
|
// echo $query . ";\n";
|
||||||
// echo debug_string_backtrace() . "\n";
|
// echo debug_string_backtrace() . "\n";
|
||||||
|
|
||||||
$result = $sql_connection->query($query);
|
$result = $sql_connection->query($query);
|
||||||
if ($result) {
|
if ($result) {
|
||||||
$data = [];
|
$data = [];
|
||||||
while ($line = $result->fetch_assoc()) {
|
while ($line = $result->fetch_assoc()) {
|
||||||
|
@ -151,7 +151,7 @@ function sql_select($query)
|
||||||
}
|
}
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
return sql_error("MySQL-query error: " . $query . " (" . $sql_connection->errno . ") " . $sql_connection->error);
|
return sql_error("MySQL-query error: " . $query . " (" . $sql_connection->errno . ") " . $sql_connection->error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,12 +164,12 @@ function sql_select($query)
|
||||||
function sql_query($query)
|
function sql_query($query)
|
||||||
{
|
{
|
||||||
global $sql_connection;
|
global $sql_connection;
|
||||||
|
|
||||||
$result = $sql_connection->query($query);
|
$result = $sql_connection->query($query);
|
||||||
if ($result) {
|
if ($result) {
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
return sql_error("MySQL-query error: " . $query . " (" . $sql_connection->errno . ") " . $sql_connection->error);
|
return sql_error("MySQL-query error: " . $query . " (" . $sql_connection->errno . ") " . $sql_connection->error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,34 +8,37 @@ function admin_active_title()
|
||||||
function admin_active()
|
function admin_active()
|
||||||
{
|
{
|
||||||
global $tshirt_sizes, $shift_sum_formula;
|
global $tshirt_sizes, $shift_sum_formula;
|
||||||
|
|
||||||
$msg = "";
|
$msg = "";
|
||||||
$search = "";
|
$search = "";
|
||||||
$forced_count = sql_num_query("SELECT * FROM `User` WHERE `force_active`=1");
|
$forced_count = sql_num_query("SELECT * FROM `User` WHERE `force_active`=1");
|
||||||
$count = $forced_count;
|
$count = $forced_count;
|
||||||
$limit = "";
|
$limit = "";
|
||||||
$set_active = "";
|
$set_active = "";
|
||||||
|
|
||||||
if (isset($_REQUEST['search'])) {
|
if (isset($_REQUEST['search'])) {
|
||||||
$search = strip_request_item('search');
|
$search = strip_request_item('search');
|
||||||
}
|
}
|
||||||
|
|
||||||
$show_all_shifts = isset($_REQUEST['show_all_shifts']);
|
$show_all_shifts = isset($_REQUEST['show_all_shifts']);
|
||||||
|
|
||||||
if (isset($_REQUEST['set_active'])) {
|
if (isset($_REQUEST['set_active'])) {
|
||||||
$valid = true;
|
$valid = true;
|
||||||
|
|
||||||
if (isset($_REQUEST['count']) && preg_match("/^[0-9]+$/", $_REQUEST['count'])) {
|
if (isset($_REQUEST['count']) && preg_match("/^[0-9]+$/", $_REQUEST['count'])) {
|
||||||
$count = strip_request_item('count');
|
$count = strip_request_item('count');
|
||||||
if ($count < $forced_count) {
|
if ($count < $forced_count) {
|
||||||
error(sprintf(_("At least %s angels are forced to be active. The number has to be greater."), $forced_count));
|
error(sprintf(
|
||||||
|
_("At least %s angels are forced to be active. The number has to be greater."),
|
||||||
|
$forced_count
|
||||||
|
));
|
||||||
redirect(page_link_to('admin_active'));
|
redirect(page_link_to('admin_active'));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$valid = false;
|
$valid = false;
|
||||||
$msg .= error(_("Please enter a number of angels to be marked as active."), true);
|
$msg .= error(_("Please enter a number of angels to be marked as active."), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($valid) {
|
if ($valid) {
|
||||||
$limit = " LIMIT " . $count;
|
$limit = " LIMIT " . $count;
|
||||||
}
|
}
|
||||||
|
@ -56,14 +59,14 @@ function admin_active()
|
||||||
}
|
}
|
||||||
sql_query("UPDATE `User` SET `Aktiv`=1 WHERE `force_active`=TRUE");
|
sql_query("UPDATE `User` SET `Aktiv`=1 WHERE `force_active`=TRUE");
|
||||||
engelsystem_log("These angels are active now: " . join(", ", $user_nicks));
|
engelsystem_log("These angels are active now: " . join(", ", $user_nicks));
|
||||||
|
|
||||||
$limit = "";
|
$limit = "";
|
||||||
$msg = success(_("Marked angels."), true);
|
$msg = success(_("Marked angels."), true);
|
||||||
} else {
|
} else {
|
||||||
$set_active = '<a href="' . page_link_to('admin_active') . '&serach=' . $search . '">« ' . _("back") . '</a> | <a href="' . page_link_to('admin_active') . '&search=' . $search . '&count=' . $count . '&set_active&ack">' . _("apply") . '</a>';
|
$set_active = '<a href="' . page_link_to('admin_active') . '&serach=' . $search . '">« ' . _("back") . '</a> | <a href="' . page_link_to('admin_active') . '&search=' . $search . '&count=' . $count . '&set_active&ack">' . _("apply") . '</a>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_REQUEST['active']) && preg_match("/^[0-9]+$/", $_REQUEST['active'])) {
|
if (isset($_REQUEST['active']) && preg_match("/^[0-9]+$/", $_REQUEST['active'])) {
|
||||||
$user_id = $_REQUEST['active'];
|
$user_id = $_REQUEST['active'];
|
||||||
$user_source = User($user_id);
|
$user_source = User($user_id);
|
||||||
|
@ -105,14 +108,15 @@ function admin_active()
|
||||||
$msg = error(_("Angel not found."), true);
|
$msg = error(_("Angel not found."), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$users = sql_select("
|
$users = sql_select("
|
||||||
SELECT `User`.*, COUNT(`ShiftEntry`.`id`) as `shift_count`, ${shift_sum_formula} as `shift_length`
|
SELECT `User`.*, COUNT(`ShiftEntry`.`id`) as `shift_count`, ${shift_sum_formula} as `shift_length`
|
||||||
FROM `User` LEFT JOIN `ShiftEntry` ON `User`.`UID` = `ShiftEntry`.`UID`
|
FROM `User` LEFT JOIN `ShiftEntry` ON `User`.`UID` = `ShiftEntry`.`UID`
|
||||||
LEFT JOIN `Shifts` ON `ShiftEntry`.`SID` = `Shifts`.`SID` " . ($show_all_shifts ? "" : "AND (`Shifts`.`end` < " . time() . " OR `Shifts`.`end` IS NULL)") . "
|
LEFT JOIN `Shifts` ON `ShiftEntry`.`SID` = `Shifts`.`SID` " . ($show_all_shifts ? "" : "AND (`Shifts`.`end` < " . time() . " OR `Shifts`.`end` IS NULL)") . "
|
||||||
WHERE `User`.`Gekommen` = 1
|
WHERE `User`.`Gekommen` = 1
|
||||||
GROUP BY `User`.`UID`
|
GROUP BY `User`.`UID`
|
||||||
ORDER BY `force_active` DESC, `shift_length` DESC" . $limit);
|
ORDER BY `force_active` DESC, `shift_length` DESC" . $limit
|
||||||
|
);
|
||||||
$matched_users = [];
|
$matched_users = [];
|
||||||
if ($search == "") {
|
if ($search == "") {
|
||||||
$tokens = [];
|
$tokens = [];
|
||||||
|
@ -128,7 +132,7 @@ function admin_active()
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (! $match) {
|
if (!$match) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -138,7 +142,7 @@ function admin_active()
|
||||||
$usr['active'] = glyph_bool($usr['Aktiv'] == 1);
|
$usr['active'] = glyph_bool($usr['Aktiv'] == 1);
|
||||||
$usr['force_active'] = glyph_bool($usr['force_active'] == 1);
|
$usr['force_active'] = glyph_bool($usr['force_active'] == 1);
|
||||||
$usr['tshirt'] = glyph_bool($usr['Tshirt'] == 1);
|
$usr['tshirt'] = glyph_bool($usr['Tshirt'] == 1);
|
||||||
|
|
||||||
$actions = [];
|
$actions = [];
|
||||||
if ($usr['Aktiv'] == 0) {
|
if ($usr['Aktiv'] == 0) {
|
||||||
$actions[] = '<a href="' . page_link_to('admin_active') . '&active=' . $usr['UID'] . ($show_all_shifts ? '&show_all_shifts=' : '') . '&search=' . $search . '">' . _("set active") . '</a>';
|
$actions[] = '<a href="' . page_link_to('admin_active') . '&active=' . $usr['UID'] . ($show_all_shifts ? '&show_all_shifts=' : '') . '&search=' . $search . '">' . _("set active") . '</a>';
|
||||||
|
@ -150,54 +154,54 @@ function admin_active()
|
||||||
if ($usr['Tshirt'] == 1) {
|
if ($usr['Tshirt'] == 1) {
|
||||||
$actions[] = '<a href="' . page_link_to('admin_active') . '&not_tshirt=' . $usr['UID'] . ($show_all_shifts ? '&show_all_shifts=' : '') . '&search=' . $search . '">' . _("remove t-shirt") . '</a>';
|
$actions[] = '<a href="' . page_link_to('admin_active') . '&not_tshirt=' . $usr['UID'] . ($show_all_shifts ? '&show_all_shifts=' : '') . '&search=' . $search . '">' . _("remove t-shirt") . '</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
$usr['actions'] = join(' ', $actions);
|
$usr['actions'] = join(' ', $actions);
|
||||||
|
|
||||||
$matched_users[] = $usr;
|
$matched_users[] = $usr;
|
||||||
}
|
}
|
||||||
|
|
||||||
$shirt_statistics = [];
|
$shirt_statistics = [];
|
||||||
foreach (array_keys($tshirt_sizes) as $size) {
|
foreach (array_keys($tshirt_sizes) as $size) {
|
||||||
if ($size != '') {
|
if ($size != '') {
|
||||||
$shirt_statistics[] = [
|
$shirt_statistics[] = [
|
||||||
'size' => $size,
|
'size' => $size,
|
||||||
'needed' => sql_select_single_cell("SELECT count(*) FROM `User` WHERE `Size`='" . sql_escape($size) . "' AND `Gekommen`=1"),
|
'needed' => sql_select_single_cell("SELECT count(*) FROM `User` WHERE `Size`='" . sql_escape($size) . "' AND `Gekommen`=1"),
|
||||||
'given' => sql_select_single_cell("SELECT count(*) FROM `User` WHERE `Size`='" . sql_escape($size) . "' AND `Tshirt`=1")
|
'given' => sql_select_single_cell("SELECT count(*) FROM `User` WHERE `Size`='" . sql_escape($size) . "' AND `Tshirt`=1")
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$shirt_statistics[] = [
|
$shirt_statistics[] = [
|
||||||
'size' => '<b>' . _("Sum") . '</b>',
|
'size' => '<b>' . _("Sum") . '</b>',
|
||||||
'needed' => '<b>' . User_arrived_count() . '</b>',
|
'needed' => '<b>' . User_arrived_count() . '</b>',
|
||||||
'given' => '<b>' . sql_select_single_cell("SELECT count(*) FROM `User` WHERE `Tshirt`=1") . '</b>'
|
'given' => '<b>' . sql_select_single_cell("SELECT count(*) FROM `User` WHERE `Tshirt`=1") . '</b>'
|
||||||
];
|
];
|
||||||
|
|
||||||
return page_with_title(admin_active_title(), [
|
return page_with_title(admin_active_title(), [
|
||||||
form([
|
form([
|
||||||
form_text('search', _("Search angel:"), $search),
|
form_text('search', _("Search angel:"), $search),
|
||||||
form_checkbox('show_all_shifts', _("Show all shifts"), $show_all_shifts),
|
form_checkbox('show_all_shifts', _("Show all shifts"), $show_all_shifts),
|
||||||
form_submit('submit', _("Search"))
|
form_submit('submit', _("Search"))
|
||||||
], page_link_to('admin_active')),
|
], page_link_to('admin_active')),
|
||||||
$set_active == "" ? form([
|
$set_active == "" ? form([
|
||||||
form_text('count', _("How much angels should be active?"), $count),
|
form_text('count', _("How much angels should be active?"), $count),
|
||||||
form_submit('set_active', _("Preview"))
|
form_submit('set_active', _("Preview"))
|
||||||
]) : $set_active,
|
]) : $set_active,
|
||||||
msg(),
|
msg(),
|
||||||
table([
|
table([
|
||||||
'nick' => _("Nickname"),
|
'nick' => _("Nickname"),
|
||||||
'shirt_size' => _("Size"),
|
'shirt_size' => _("Size"),
|
||||||
'shift_count' => _("Shifts"),
|
'shift_count' => _("Shifts"),
|
||||||
'work_time' => _("Length"),
|
'work_time' => _("Length"),
|
||||||
'active' => _("Active?"),
|
'active' => _("Active?"),
|
||||||
'force_active' => _("Forced"),
|
'force_active' => _("Forced"),
|
||||||
'tshirt' => _("T-shirt?"),
|
'tshirt' => _("T-shirt?"),
|
||||||
'actions' => ""
|
'actions' => ""
|
||||||
], $matched_users),
|
], $matched_users),
|
||||||
'<h2>' . _("Shirt statistics") . '</h2>',
|
'<h2>' . _("Shirt statistics") . '</h2>',
|
||||||
table([
|
table([
|
||||||
'size' => _("Size"),
|
'size' => _("Size"),
|
||||||
'needed' => _("Needed shirts"),
|
'needed' => _("Needed shirts"),
|
||||||
'given' => _("Given shirts")
|
'given' => _("Given shirts")
|
||||||
], $shirt_statistics)
|
], $shirt_statistics)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ function admin_arrive()
|
||||||
if (isset($_REQUEST['search'])) {
|
if (isset($_REQUEST['search'])) {
|
||||||
$search = strip_request_item('search');
|
$search = strip_request_item('search');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_REQUEST['reset']) && preg_match("/^[0-9]*$/", $_REQUEST['reset'])) {
|
if (isset($_REQUEST['reset']) && preg_match("/^[0-9]*$/", $_REQUEST['reset'])) {
|
||||||
$user_id = $_REQUEST['reset'];
|
$user_id = $_REQUEST['reset'];
|
||||||
$user_source = User($user_id);
|
$user_source = User($user_id);
|
||||||
|
@ -36,7 +36,7 @@ function admin_arrive()
|
||||||
$msg = error(_("Angel not found."), true);
|
$msg = error(_("Angel not found."), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$users = sql_select("SELECT * FROM `User` ORDER BY `Nick`");
|
$users = sql_select("SELECT * FROM `User` ORDER BY `Nick`");
|
||||||
$arrival_count_at_day = [];
|
$arrival_count_at_day = [];
|
||||||
$planned_arrival_count_at_day = [];
|
$planned_arrival_count_at_day = [];
|
||||||
|
@ -57,11 +57,11 @@ function admin_arrive()
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (! $match) {
|
if (!$match) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$usr['nick'] = User_Nick_render($usr);
|
$usr['nick'] = User_Nick_render($usr);
|
||||||
if ($usr['planned_departure_date'] != null) {
|
if ($usr['planned_departure_date'] != null) {
|
||||||
$usr['rendered_planned_departure_date'] = date('Y-m-d', $usr['planned_departure_date']);
|
$usr['rendered_planned_departure_date'] = date('Y-m-d', $usr['planned_departure_date']);
|
||||||
|
@ -72,131 +72,131 @@ function admin_arrive()
|
||||||
$usr['rendered_arrival_date'] = $usr['arrival_date'] > 0 ? date('Y-m-d', $usr['arrival_date']) : "-";
|
$usr['rendered_arrival_date'] = $usr['arrival_date'] > 0 ? date('Y-m-d', $usr['arrival_date']) : "-";
|
||||||
$usr['arrived'] = $usr['Gekommen'] == 1 ? _("yes") : "";
|
$usr['arrived'] = $usr['Gekommen'] == 1 ? _("yes") : "";
|
||||||
$usr['actions'] = $usr['Gekommen'] == 1 ? '<a href="' . page_link_to('admin_arrive') . '&reset=' . $usr['UID'] . '&search=' . $search . '">' . _("reset") . '</a>' : '<a href="' . page_link_to('admin_arrive') . '&arrived=' . $usr['UID'] . '&search=' . $search . '">' . _("arrived") . '</a>';
|
$usr['actions'] = $usr['Gekommen'] == 1 ? '<a href="' . page_link_to('admin_arrive') . '&reset=' . $usr['UID'] . '&search=' . $search . '">' . _("reset") . '</a>' : '<a href="' . page_link_to('admin_arrive') . '&arrived=' . $usr['UID'] . '&search=' . $search . '">' . _("arrived") . '</a>';
|
||||||
|
|
||||||
if ($usr['arrival_date'] > 0) {
|
if ($usr['arrival_date'] > 0) {
|
||||||
$day = date('Y-m-d', $usr['arrival_date']);
|
$day = date('Y-m-d', $usr['arrival_date']);
|
||||||
if (! isset($arrival_count_at_day[$day])) {
|
if (!isset($arrival_count_at_day[$day])) {
|
||||||
$arrival_count_at_day[$day] = 0;
|
$arrival_count_at_day[$day] = 0;
|
||||||
}
|
}
|
||||||
$arrival_count_at_day[$day] ++;
|
$arrival_count_at_day[$day]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($usr['planned_arrival_date'] != null) {
|
if ($usr['planned_arrival_date'] != null) {
|
||||||
$day = date('Y-m-d', $usr['planned_arrival_date']);
|
$day = date('Y-m-d', $usr['planned_arrival_date']);
|
||||||
if (! isset($planned_arrival_count_at_day[$day])) {
|
if (!isset($planned_arrival_count_at_day[$day])) {
|
||||||
$planned_arrival_count_at_day[$day] = 0;
|
$planned_arrival_count_at_day[$day] = 0;
|
||||||
}
|
}
|
||||||
$planned_arrival_count_at_day[$day] ++;
|
$planned_arrival_count_at_day[$day]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($usr['planned_departure_date'] != null && $usr['Gekommen'] == 1) {
|
if ($usr['planned_departure_date'] != null && $usr['Gekommen'] == 1) {
|
||||||
$day = date('Y-m-d', $usr['planned_departure_date']);
|
$day = date('Y-m-d', $usr['planned_departure_date']);
|
||||||
if (! isset($planned_departure_count_at_day[$day])) {
|
if (!isset($planned_departure_count_at_day[$day])) {
|
||||||
$planned_departure_count_at_day[$day] = 0;
|
$planned_departure_count_at_day[$day] = 0;
|
||||||
}
|
}
|
||||||
$planned_departure_count_at_day[$day] ++;
|
$planned_departure_count_at_day[$day]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
$users_matched[] = $usr;
|
$users_matched[] = $usr;
|
||||||
}
|
}
|
||||||
|
|
||||||
ksort($arrival_count_at_day);
|
ksort($arrival_count_at_day);
|
||||||
ksort($planned_arrival_count_at_day);
|
ksort($planned_arrival_count_at_day);
|
||||||
ksort($planned_departure_count_at_day);
|
ksort($planned_departure_count_at_day);
|
||||||
|
|
||||||
$arrival_at_day = [];
|
$arrival_at_day = [];
|
||||||
$arrival_sum = 0;
|
$arrival_sum = 0;
|
||||||
foreach ($arrival_count_at_day as $day => $count) {
|
foreach ($arrival_count_at_day as $day => $count) {
|
||||||
$arrival_sum += $count;
|
$arrival_sum += $count;
|
||||||
$arrival_at_day[$day] = [
|
$arrival_at_day[$day] = [
|
||||||
'day' => $day,
|
'day' => $day,
|
||||||
'count' => $count,
|
'count' => $count,
|
||||||
'sum' => $arrival_sum
|
'sum' => $arrival_sum
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
$planned_arrival_at_day = [];
|
$planned_arrival_at_day = [];
|
||||||
$planned_arrival_sum = 0;
|
$planned_arrival_sum = 0;
|
||||||
foreach ($planned_arrival_count_at_day as $day => $count) {
|
foreach ($planned_arrival_count_at_day as $day => $count) {
|
||||||
$planned_arrival_sum += $count;
|
$planned_arrival_sum += $count;
|
||||||
$planned_arrival_at_day[$day] = [
|
$planned_arrival_at_day[$day] = [
|
||||||
'day' => $day,
|
'day' => $day,
|
||||||
'count' => $count,
|
'count' => $count,
|
||||||
'sum' => $planned_arrival_sum
|
'sum' => $planned_arrival_sum
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
$planned_departure_at_day = [];
|
$planned_departure_at_day = [];
|
||||||
$planned_departure_sum = 0;
|
$planned_departure_sum = 0;
|
||||||
foreach ($planned_departure_count_at_day as $day => $count) {
|
foreach ($planned_departure_count_at_day as $day => $count) {
|
||||||
$planned_departure_sum += $count;
|
$planned_departure_sum += $count;
|
||||||
$planned_departure_at_day[$day] = [
|
$planned_departure_at_day[$day] = [
|
||||||
'day' => $day,
|
'day' => $day,
|
||||||
'count' => $count,
|
'count' => $count,
|
||||||
'sum' => $planned_departure_sum
|
'sum' => $planned_departure_sum
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
return page_with_title(admin_arrive_title(), [
|
return page_with_title(admin_arrive_title(), [
|
||||||
msg(),
|
msg(),
|
||||||
form([
|
form([
|
||||||
form_text('search', _("Search"), $search),
|
form_text('search', _("Search"), $search),
|
||||||
form_submit('submit', _("Search"))
|
form_submit('submit', _("Search"))
|
||||||
]),
|
]),
|
||||||
table([
|
table([
|
||||||
'nick' => _("Nickname"),
|
'nick' => _("Nickname"),
|
||||||
'rendered_planned_arrival_date' => _("Planned arrival"),
|
'rendered_planned_arrival_date' => _("Planned arrival"),
|
||||||
'arrived' => _("Arrived?"),
|
'arrived' => _("Arrived?"),
|
||||||
'rendered_arrival_date' => _("Arrival date"),
|
'rendered_arrival_date' => _("Arrival date"),
|
||||||
'rendered_planned_departure_date' => _("Planned departure"),
|
'rendered_planned_departure_date' => _("Planned departure"),
|
||||||
'actions' => ""
|
'actions' => ""
|
||||||
], $users_matched),
|
], $users_matched),
|
||||||
div('row', [
|
div('row', [
|
||||||
div('col-md-4', [
|
div('col-md-4', [
|
||||||
heading(_("Planned arrival statistics"), 2),
|
heading(_("Planned arrival statistics"), 2),
|
||||||
bargraph('planned_arrives', 'day', [
|
bargraph('planned_arrives', 'day', [
|
||||||
'count' => _("arrived"),
|
'count' => _("arrived"),
|
||||||
'sum' => _("arrived sum")
|
'sum' => _("arrived sum")
|
||||||
], [
|
], [
|
||||||
'count' => '#090',
|
'count' => '#090',
|
||||||
'sum' => '#888'
|
'sum' => '#888'
|
||||||
], $planned_arrival_at_day),
|
], $planned_arrival_at_day),
|
||||||
table([
|
table([
|
||||||
'day' => _("Date"),
|
'day' => _("Date"),
|
||||||
'count' => _("Count"),
|
'count' => _("Count"),
|
||||||
'sum' => _("Sum")
|
'sum' => _("Sum")
|
||||||
], $planned_arrival_at_day)
|
], $planned_arrival_at_day)
|
||||||
]),
|
]),
|
||||||
div('col-md-4', [
|
div('col-md-4', [
|
||||||
heading(_("Arrival statistics"), 2),
|
heading(_("Arrival statistics"), 2),
|
||||||
bargraph('arrives', 'day', [
|
bargraph('arrives', 'day', [
|
||||||
'count' => _("arrived"),
|
'count' => _("arrived"),
|
||||||
'sum' => _("arrived sum")
|
'sum' => _("arrived sum")
|
||||||
], [
|
], [
|
||||||
'count' => '#090',
|
'count' => '#090',
|
||||||
'sum' => '#888'
|
'sum' => '#888'
|
||||||
], $arrival_at_day),
|
], $arrival_at_day),
|
||||||
table([
|
table([
|
||||||
'day' => _("Date"),
|
'day' => _("Date"),
|
||||||
'count' => _("Count"),
|
'count' => _("Count"),
|
||||||
'sum' => _("Sum")
|
'sum' => _("Sum")
|
||||||
], $arrival_at_day)
|
], $arrival_at_day)
|
||||||
]),
|
]),
|
||||||
div('col-md-4', [
|
div('col-md-4', [
|
||||||
heading(_("Planned departure statistics"), 2),
|
heading(_("Planned departure statistics"), 2),
|
||||||
bargraph('planned_departures', 'day', [
|
bargraph('planned_departures', 'day', [
|
||||||
'count' => _("arrived"),
|
'count' => _("arrived"),
|
||||||
'sum' => _("arrived sum")
|
'sum' => _("arrived sum")
|
||||||
], [
|
], [
|
||||||
'count' => '#090',
|
'count' => '#090',
|
||||||
'sum' => '#888'
|
'sum' => '#888'
|
||||||
], $planned_departure_at_day),
|
], $planned_departure_at_day),
|
||||||
table([
|
table([
|
||||||
'day' => _("Date"),
|
'day' => _("Date"),
|
||||||
'count' => _("Count"),
|
'count' => _("Count"),
|
||||||
'sum' => _("Sum")
|
'sum' => _("Sum")
|
||||||
], $planned_departure_at_day)
|
], $planned_departure_at_day)
|
||||||
])
|
])
|
||||||
])
|
])
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,12 +8,12 @@ function admin_free_title()
|
||||||
function admin_free()
|
function admin_free()
|
||||||
{
|
{
|
||||||
global $privileges;
|
global $privileges;
|
||||||
|
|
||||||
$search = "";
|
$search = "";
|
||||||
if (isset($_REQUEST['search'])) {
|
if (isset($_REQUEST['search'])) {
|
||||||
$search = strip_request_item('search');
|
$search = strip_request_item('search');
|
||||||
}
|
}
|
||||||
|
|
||||||
$angeltypesearch = "";
|
$angeltypesearch = "";
|
||||||
if (empty($_REQUEST['angeltype'])) {
|
if (empty($_REQUEST['angeltype'])) {
|
||||||
$_REQUEST['angeltype'] = '';
|
$_REQUEST['angeltype'] = '';
|
||||||
|
@ -24,15 +24,15 @@ function admin_free()
|
||||||
}
|
}
|
||||||
$angeltypesearch .= ") ";
|
$angeltypesearch .= ") ";
|
||||||
}
|
}
|
||||||
|
|
||||||
$angel_types_source = sql_select("SELECT `id`, `name` FROM `AngelTypes` ORDER BY `name`");
|
$angel_types_source = sql_select("SELECT `id`, `name` FROM `AngelTypes` ORDER BY `name`");
|
||||||
$angel_types = [
|
$angel_types = [
|
||||||
'' => 'alle Typen'
|
'' => 'alle Typen'
|
||||||
];
|
];
|
||||||
foreach ($angel_types_source as $angel_type) {
|
foreach ($angel_types_source as $angel_type) {
|
||||||
$angel_types[$angel_type['id']] = $angel_type['name'];
|
$angel_types[$angel_type['id']] = $angel_type['name'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$users = sql_select("
|
$users = sql_select("
|
||||||
SELECT `User`.*
|
SELECT `User`.*
|
||||||
FROM `User`
|
FROM `User`
|
||||||
|
@ -42,7 +42,7 @@ function admin_free()
|
||||||
WHERE `User`.`Gekommen` = 1 AND `Shifts`.`SID` IS NULL
|
WHERE `User`.`Gekommen` = 1 AND `Shifts`.`SID` IS NULL
|
||||||
GROUP BY `User`.`UID`
|
GROUP BY `User`.`UID`
|
||||||
ORDER BY `Nick`");
|
ORDER BY `Nick`");
|
||||||
|
|
||||||
$free_users_table = [];
|
$free_users_table = [];
|
||||||
if ($search == "") {
|
if ($search == "") {
|
||||||
$tokens = [];
|
$tokens = [];
|
||||||
|
@ -59,44 +59,47 @@ function admin_free()
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (! $match) {
|
if (!$match) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$free_users_table[] = [
|
$free_users_table[] = [
|
||||||
'name' => User_Nick_render($usr),
|
'name' => User_Nick_render($usr),
|
||||||
'shift_state' => User_shift_state_render($usr),
|
'shift_state' => User_shift_state_render($usr),
|
||||||
'dect' => $usr['DECT'],
|
'dect' => $usr['DECT'],
|
||||||
'jabber' => $usr['jabber'],
|
'jabber' => $usr['jabber'],
|
||||||
'email' => $usr['email_by_human_allowed'] ? $usr['email'] : glyph('eye-close'),
|
'email' => $usr['email_by_human_allowed'] ? $usr['email'] : glyph('eye-close'),
|
||||||
'actions' => in_array('admin_user', $privileges) ? button(page_link_to('admin_user') . '&id=' . $usr['UID'], _("edit"), 'btn-xs') : ''
|
'actions' =>
|
||||||
];
|
in_array('admin_user', $privileges)
|
||||||
|
? button(page_link_to('admin_user') . '&id=' . $usr['UID'], _("edit"), 'btn-xs')
|
||||||
|
: ''
|
||||||
|
];
|
||||||
}
|
}
|
||||||
return page_with_title(admin_free_title(), [
|
return page_with_title(admin_free_title(), [
|
||||||
form([
|
form([
|
||||||
div('row', [
|
div('row', [
|
||||||
div('col-md-4', [
|
div('col-md-4', [
|
||||||
form_text('search', _("Search"), $search)
|
form_text('search', _("Search"), $search)
|
||||||
]),
|
]),
|
||||||
div('col-md-4', [
|
div('col-md-4', [
|
||||||
form_select('angeltype', _("Angeltype"), $angel_types, $_REQUEST['angeltype'])
|
form_select('angeltype', _("Angeltype"), $angel_types, $_REQUEST['angeltype'])
|
||||||
]),
|
]),
|
||||||
div('col-md-2', [
|
div('col-md-2', [
|
||||||
form_checkbox('confirmed_only', _("Only confirmed"), isset($_REQUEST['confirmed_only']))
|
form_checkbox('confirmed_only', _("Only confirmed"), isset($_REQUEST['confirmed_only']))
|
||||||
]),
|
]),
|
||||||
div('col-md-2', [
|
div('col-md-2', [
|
||||||
form_submit('submit', _("Search"))
|
form_submit('submit', _("Search"))
|
||||||
])
|
])
|
||||||
])
|
])
|
||||||
]),
|
]),
|
||||||
table([
|
table([
|
||||||
'name' => _("Nick"),
|
'name' => _("Nick"),
|
||||||
'shift_state' => '',
|
'shift_state' => '',
|
||||||
'dect' => _("DECT"),
|
'dect' => _("DECT"),
|
||||||
'jabber' => _("Jabber"),
|
'jabber' => _("Jabber"),
|
||||||
'email' => _("E-Mail"),
|
'email' => _("E-Mail"),
|
||||||
'actions' => ''
|
'actions' => ''
|
||||||
], $free_users_table)
|
], $free_users_table)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,90 +9,122 @@ function admin_groups()
|
||||||
{
|
{
|
||||||
$html = "";
|
$html = "";
|
||||||
$groups = sql_select("SELECT * FROM `Groups` ORDER BY `Name`");
|
$groups = sql_select("SELECT * FROM `Groups` ORDER BY `Name`");
|
||||||
if (! isset($_REQUEST["action"])) {
|
if (!isset($_REQUEST["action"])) {
|
||||||
$groups_table = [];
|
$groups_table = [];
|
||||||
foreach ($groups as $group) {
|
foreach ($groups as $group) {
|
||||||
$privileges = sql_select("SELECT * FROM `GroupPrivileges` JOIN `Privileges` ON (`GroupPrivileges`.`privilege_id` = `Privileges`.`id`) WHERE `group_id`='" . sql_escape($group['UID']) . "'");
|
$privileges = sql_select("
|
||||||
|
SELECT *
|
||||||
|
FROM `GroupPrivileges`
|
||||||
|
JOIN `Privileges` ON (`GroupPrivileges`.`privilege_id` = `Privileges`.`id`)
|
||||||
|
WHERE `group_id`='" . sql_escape($group['UID']) . "'
|
||||||
|
");
|
||||||
$privileges_html = [];
|
$privileges_html = [];
|
||||||
|
|
||||||
foreach ($privileges as $priv) {
|
foreach ($privileges as $priv) {
|
||||||
$privileges_html[] = $priv['name'];
|
$privileges_html[] = $priv['name'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$groups_table[] = [
|
$groups_table[] = [
|
||||||
'name' => $group['Name'],
|
'name' => $group['Name'],
|
||||||
'privileges' => join(', ', $privileges_html),
|
'privileges' => join(', ', $privileges_html),
|
||||||
'actions' => button(page_link_to('admin_groups') . '&action=edit&id=' . $group['UID'], _("edit"), 'btn-xs')
|
'actions' => button(
|
||||||
];
|
page_link_to('admin_groups') . '&action=edit&id=' . $group['UID'],
|
||||||
|
_("edit"),
|
||||||
|
'btn-xs'
|
||||||
|
)
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
return page_with_title(admin_groups_title(), [
|
return page_with_title(admin_groups_title(), [
|
||||||
table([
|
table([
|
||||||
'name' => _("Name"),
|
'name' => _("Name"),
|
||||||
'privileges' => _("Privileges"),
|
'privileges' => _("Privileges"),
|
||||||
'actions' => ''
|
'actions' => ''
|
||||||
], $groups_table)
|
], $groups_table)
|
||||||
]);
|
]);
|
||||||
} else {
|
} else {
|
||||||
switch ($_REQUEST["action"]) {
|
switch ($_REQUEST["action"]) {
|
||||||
case 'edit':
|
case 'edit':
|
||||||
if (isset($_REQUEST['id']) && preg_match("/^-[0-9]{1,11}$/", $_REQUEST['id'])) {
|
if (isset($_REQUEST['id']) && preg_match("/^-[0-9]{1,11}$/", $_REQUEST['id'])) {
|
||||||
$group_id = $_REQUEST['id'];
|
$group_id = $_REQUEST['id'];
|
||||||
} else {
|
} else {
|
||||||
return error("Incomplete call, missing Groups ID.", true);
|
return error("Incomplete call, missing Groups ID.", true);
|
||||||
}
|
|
||||||
|
|
||||||
$group = sql_select("SELECT * FROM `Groups` WHERE `UID`='" . sql_escape($group_id) . "' LIMIT 1");
|
|
||||||
if (count($group) > 0) {
|
|
||||||
list($group) = $group;
|
|
||||||
$privileges = sql_select("SELECT `Privileges`.*, `GroupPrivileges`.`group_id` FROM `Privileges` LEFT OUTER JOIN `GroupPrivileges` ON (`Privileges`.`id` = `GroupPrivileges`.`privilege_id` AND `GroupPrivileges`.`group_id`='" . sql_escape($group_id) . "') ORDER BY `Privileges`.`name`");
|
|
||||||
$privileges_html = "";
|
|
||||||
$privileges_form = [];
|
|
||||||
foreach ($privileges as $priv) {
|
|
||||||
$privileges_form[] = form_checkbox('privileges[]', $priv['desc'] . ' (' . $priv['name'] . ')', $priv['group_id'] != "", $priv['id']);
|
|
||||||
$privileges_html .= sprintf('<tr><td><input type="checkbox" ' . 'name="privileges[]" value="%s" %s />' . '</td> <td>%s</td> <td>%s</td></tr>', $priv['id'], ($priv['group_id'] != "" ? 'checked="checked"' : ''), $priv['name'], $priv['desc']);
|
|
||||||
}
|
|
||||||
|
|
||||||
$privileges_form[] = form_submit('submit', _("Save"));
|
|
||||||
$html .= page_with_title(_("Edit group"), [
|
|
||||||
form($privileges_form, page_link_to('admin_groups') . '&action=save&id=' . $group_id)
|
|
||||||
]);
|
|
||||||
} else {
|
|
||||||
return error("No Group found.", true);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'save':
|
|
||||||
if (isset($_REQUEST['id']) && preg_match("/^-[0-9]{1,11}$/", $_REQUEST['id'])) {
|
|
||||||
$group_id = $_REQUEST['id'];
|
|
||||||
} else {
|
|
||||||
return error("Incomplete call, missing Groups ID.", true);
|
|
||||||
}
|
|
||||||
|
|
||||||
$group = sql_select("SELECT * FROM `Groups` WHERE `UID`='" . sql_escape($group_id) . "' LIMIT 1");
|
|
||||||
if (! is_array($_REQUEST['privileges'])) {
|
|
||||||
$_REQUEST['privileges'] = [];
|
|
||||||
}
|
|
||||||
if (count($group) > 0) {
|
|
||||||
list($group) = $group;
|
|
||||||
sql_query("DELETE FROM `GroupPrivileges` WHERE `group_id`='" . sql_escape($group_id) . "'");
|
|
||||||
$privilege_names = [];
|
|
||||||
foreach ($_REQUEST['privileges'] as $priv) {
|
|
||||||
if (preg_match("/^[0-9]{1,}$/", $priv)) {
|
|
||||||
$group_privileges_source = sql_select("SELECT * FROM `Privileges` WHERE `id`='" . sql_escape($priv) . "' LIMIT 1");
|
|
||||||
if (count($group_privileges_source) > 0) {
|
|
||||||
sql_query("INSERT INTO `GroupPrivileges` SET `group_id`='" . sql_escape($group_id) . "', `privilege_id`='" . sql_escape($priv) . "'");
|
|
||||||
$privilege_names[] = $group_privileges_source[0]['name'];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
engelsystem_log("Group privileges of group " . $group['Name'] . " edited: " . join(", ", $privilege_names));
|
$group = sql_select("SELECT * FROM `Groups` WHERE `UID`='" . sql_escape($group_id) . "' LIMIT 1");
|
||||||
redirect(page_link_to("admin_groups"));
|
if (count($group) > 0) {
|
||||||
} else {
|
list($group) = $group;
|
||||||
return error("No Group found.", true);
|
$privileges = sql_select("
|
||||||
|
SELECT `Privileges`.*, `GroupPrivileges`.`group_id`
|
||||||
|
FROM `Privileges`
|
||||||
|
LEFT OUTER JOIN `GroupPrivileges`
|
||||||
|
ON (
|
||||||
|
`Privileges`.`id` = `GroupPrivileges`.`privilege_id`
|
||||||
|
AND `GroupPrivileges`.`group_id`='" . sql_escape($group_id) . "'
|
||||||
|
)
|
||||||
|
ORDER BY `Privileges`.`name`
|
||||||
|
");
|
||||||
|
$privileges_html = "";
|
||||||
|
$privileges_form = [];
|
||||||
|
foreach ($privileges as $priv) {
|
||||||
|
$privileges_form[] = form_checkbox(
|
||||||
|
'privileges[]',
|
||||||
|
$priv['desc'] . ' (' . $priv['name'] . ')',
|
||||||
|
$priv['group_id'] != "",
|
||||||
|
$priv['id']
|
||||||
|
);
|
||||||
|
$privileges_html .= sprintf(
|
||||||
|
'<tr><td><input type="checkbox" name="privileges[]" value="%s" %s /></td> <td>%s</td> <td>%s</td></tr>',
|
||||||
|
$priv['id'],
|
||||||
|
($priv['group_id'] != "" ? 'checked="checked"' : ''),
|
||||||
|
$priv['name'],
|
||||||
|
$priv['desc']
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$privileges_form[] = form_submit('submit', _("Save"));
|
||||||
|
$html .= page_with_title(_("Edit group"), [
|
||||||
|
form($privileges_form, page_link_to('admin_groups') . '&action=save&id=' . $group_id)
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
return error("No Group found.", true);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'save':
|
||||||
|
if (isset($_REQUEST['id']) && preg_match("/^-[0-9]{1,11}$/", $_REQUEST['id'])) {
|
||||||
|
$group_id = $_REQUEST['id'];
|
||||||
|
} else {
|
||||||
|
return error("Incomplete call, missing Groups ID.", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
$group = sql_select("SELECT * FROM `Groups` WHERE `UID`='" . sql_escape($group_id) . "' LIMIT 1");
|
||||||
|
if (!is_array($_REQUEST['privileges'])) {
|
||||||
|
$_REQUEST['privileges'] = [];
|
||||||
|
}
|
||||||
|
if (count($group) > 0) {
|
||||||
|
list($group) = $group;
|
||||||
|
sql_query("DELETE FROM `GroupPrivileges` WHERE `group_id`='" . sql_escape($group_id) . "'");
|
||||||
|
$privilege_names = [];
|
||||||
|
foreach ($_REQUEST['privileges'] as $priv) {
|
||||||
|
if (preg_match("/^[0-9]{1,}$/", $priv)) {
|
||||||
|
$group_privileges_source = sql_select("SELECT * FROM `Privileges` WHERE `id`='" . sql_escape($priv) . "' LIMIT 1");
|
||||||
|
if (count($group_privileges_source) > 0) {
|
||||||
|
sql_query("INSERT INTO `GroupPrivileges` SET `group_id`='" . sql_escape($group_id) . "', `privilege_id`='" . sql_escape($priv) . "'");
|
||||||
|
$privilege_names[] = $group_privileges_source[0]['name'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
engelsystem_log(
|
||||||
|
"Group privileges of group " . $group['Name']
|
||||||
|
. " edited: " . join(", ", $privilege_names)
|
||||||
|
);
|
||||||
|
redirect(page_link_to("admin_groups"));
|
||||||
|
} else {
|
||||||
|
return error("No Group found.", true);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return $html;
|
return $html;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,28 +11,31 @@ function admin_import()
|
||||||
global $user;
|
global $user;
|
||||||
$html = "";
|
$html = "";
|
||||||
$import_dir = __DIR__ . '/../../import';
|
$import_dir = __DIR__ . '/../../import';
|
||||||
|
|
||||||
$step = "input";
|
$step = "input";
|
||||||
if (isset($_REQUEST['step']) && in_array($step, [
|
if (
|
||||||
'input',
|
isset($_REQUEST['step'])
|
||||||
'check',
|
&& in_array($step, [
|
||||||
'import'
|
'input',
|
||||||
])) {
|
'check',
|
||||||
|
'import'
|
||||||
|
])
|
||||||
|
) {
|
||||||
$step = $_REQUEST['step'];
|
$step = $_REQUEST['step'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($test_handle = @fopen($import_dir . '/tmp', 'w')) {
|
if ($test_handle = @fopen($import_dir . '/tmp', 'w')) {
|
||||||
fclose($test_handle);
|
fclose($test_handle);
|
||||||
@unlink($import_dir . '/tmp');
|
@unlink($import_dir . '/tmp');
|
||||||
} else {
|
} else {
|
||||||
error(_('Webserver has no write-permission on import directory.'));
|
error(_('Webserver has no write-permission on import directory.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$import_file = $import_dir . '/import_' . $user['UID'] . '.xml';
|
$import_file = $import_dir . '/import_' . $user['UID'] . '.xml';
|
||||||
$shifttype_id = null;
|
$shifttype_id = null;
|
||||||
$add_minutes_start = 15;
|
$add_minutes_start = 15;
|
||||||
$add_minutes_end = 15;
|
$add_minutes_end = 15;
|
||||||
|
|
||||||
$shifttypes_source = ShiftTypes();
|
$shifttypes_source = ShiftTypes();
|
||||||
if ($shifttypes_source === false) {
|
if ($shifttypes_source === false) {
|
||||||
engelsystem_error('Unable to load shifttypes.');
|
engelsystem_error('Unable to load shifttypes.');
|
||||||
|
@ -41,301 +44,323 @@ function admin_import()
|
||||||
foreach ($shifttypes_source as $shifttype) {
|
foreach ($shifttypes_source as $shifttype) {
|
||||||
$shifttypes[$shifttype['id']] = $shifttype['name'];
|
$shifttypes[$shifttype['id']] = $shifttype['name'];
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ($step) {
|
switch ($step) {
|
||||||
case 'input':
|
case 'input':
|
||||||
$valid = false;
|
$valid = false;
|
||||||
|
|
||||||
if (isset($_REQUEST['submit'])) {
|
if (isset($_REQUEST['submit'])) {
|
||||||
$valid = true;
|
$valid = true;
|
||||||
|
|
||||||
if (isset($_REQUEST['shifttype_id']) && isset($shifttypes[$_REQUEST['shifttype_id']])) {
|
if (isset($_REQUEST['shifttype_id']) && isset($shifttypes[$_REQUEST['shifttype_id']])) {
|
||||||
$shifttype_id = $_REQUEST['shifttype_id'];
|
$shifttype_id = $_REQUEST['shifttype_id'];
|
||||||
} else {
|
} else {
|
||||||
$valid = false;
|
$valid = false;
|
||||||
error(_('Please select a shift type.'));
|
error(_('Please select a shift type.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_REQUEST['add_minutes_start']) && is_numeric(trim($_REQUEST['add_minutes_start']))) {
|
if (isset($_REQUEST['add_minutes_start']) && is_numeric(trim($_REQUEST['add_minutes_start']))) {
|
||||||
$add_minutes_start = trim($_REQUEST['add_minutes_start']);
|
$add_minutes_start = trim($_REQUEST['add_minutes_start']);
|
||||||
} else {
|
} else {
|
||||||
$valid = false;
|
$valid = false;
|
||||||
error(_("Please enter an amount of minutes to add to a talk's begin."));
|
error(_("Please enter an amount of minutes to add to a talk's begin."));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_REQUEST['add_minutes_end']) && is_numeric(trim($_REQUEST['add_minutes_end']))) {
|
if (isset($_REQUEST['add_minutes_end']) && is_numeric(trim($_REQUEST['add_minutes_end']))) {
|
||||||
$add_minutes_end = trim($_REQUEST['add_minutes_end']);
|
$add_minutes_end = trim($_REQUEST['add_minutes_end']);
|
||||||
} else {
|
} else {
|
||||||
$valid = false;
|
$valid = false;
|
||||||
error(_("Please enter an amount of minutes to add to a talk's end."));
|
error(_("Please enter an amount of minutes to add to a talk's end."));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_FILES['xcal_file']) && ($_FILES['xcal_file']['error'] == 0)) {
|
if (isset($_FILES['xcal_file']) && ($_FILES['xcal_file']['error'] == 0)) {
|
||||||
if (move_uploaded_file($_FILES['xcal_file']['tmp_name'], $import_file)) {
|
if (move_uploaded_file($_FILES['xcal_file']['tmp_name'], $import_file)) {
|
||||||
libxml_use_internal_errors(true);
|
libxml_use_internal_errors(true);
|
||||||
if (simplexml_load_file($import_file) === false) {
|
if (simplexml_load_file($import_file) === false) {
|
||||||
$valid = false;
|
$valid = false;
|
||||||
error(_('No valid xml/xcal file provided.'));
|
error(_('No valid xml/xcal file provided.'));
|
||||||
unlink($import_file);
|
unlink($import_file);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$valid = false;
|
$valid = false;
|
||||||
error(_('File upload went wrong.'));
|
error(_('File upload went wrong.'));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$valid = false;
|
$valid = false;
|
||||||
error(_('Please provide some data.'));
|
error(_('Please provide some data.'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($valid) {
|
if ($valid) {
|
||||||
redirect(page_link_to('admin_import') . "&step=check&shifttype_id=" . $shifttype_id . "&add_minutes_end=" . $add_minutes_end . "&add_minutes_start=" . $add_minutes_start);
|
redirect(page_link_to('admin_import') . "&step=check&shifttype_id=" . $shifttype_id . "&add_minutes_end=" . $add_minutes_end . "&add_minutes_start=" . $add_minutes_start);
|
||||||
} else {
|
} else {
|
||||||
$html .= div('well well-sm text-center', [
|
$html .= div('well well-sm text-center', [
|
||||||
_('File Upload') . mute(glyph('arrow-right')) . mute(_('Validation')) . mute(glyph('arrow-right')) . mute(_('Import'))
|
_('File Upload') . mute(glyph('arrow-right')) . mute(_('Validation')) . mute(glyph('arrow-right')) . mute(_('Import'))
|
||||||
]) . div('row', [
|
]) . div('row', [
|
||||||
div('col-md-offset-3 col-md-6', [
|
div('col-md-offset-3 col-md-6', [
|
||||||
form([
|
form([
|
||||||
form_info('', _("This import will create/update/delete rooms and shifts by given FRAB-export file. The needed file format is xcal.")),
|
form_info(
|
||||||
form_select('shifttype_id', _('Shifttype'), $shifttypes, $shifttype_id),
|
'',
|
||||||
form_spinner('add_minutes_start', _("Add minutes to start"), $add_minutes_start),
|
_("This import will create/update/delete rooms and shifts by given FRAB-export file. The needed file format is xcal.")
|
||||||
form_spinner('add_minutes_end', _("Add minutes to end"), $add_minutes_end),
|
),
|
||||||
form_file('xcal_file', _("xcal-File (.xcal)")),
|
form_select('shifttype_id', _('Shifttype'), $shifttypes, $shifttype_id),
|
||||||
form_submit('submit', _("Import"))
|
form_spinner('add_minutes_start', _("Add minutes to start"), $add_minutes_start),
|
||||||
])
|
form_spinner('add_minutes_end', _("Add minutes to end"), $add_minutes_end),
|
||||||
])
|
form_file('xcal_file', _("xcal-File (.xcal)")),
|
||||||
]);
|
form_submit('submit', _("Import"))
|
||||||
}
|
])
|
||||||
break;
|
])
|
||||||
|
]);
|
||||||
case 'check':
|
}
|
||||||
if (! file_exists($import_file)) {
|
break;
|
||||||
error(_('Missing import file.'));
|
|
||||||
redirect(page_link_to('admin_import'));
|
case 'check':
|
||||||
}
|
if (!file_exists($import_file)) {
|
||||||
|
error(_('Missing import file.'));
|
||||||
if (isset($_REQUEST['shifttype_id']) && isset($shifttypes[$_REQUEST['shifttype_id']])) {
|
redirect(page_link_to('admin_import'));
|
||||||
$shifttype_id = $_REQUEST['shifttype_id'];
|
}
|
||||||
} else {
|
|
||||||
error(_('Please select a shift type.'));
|
if (isset($_REQUEST['shifttype_id']) && isset($shifttypes[$_REQUEST['shifttype_id']])) {
|
||||||
redirect(page_link_to('admin_import'));
|
$shifttype_id = $_REQUEST['shifttype_id'];
|
||||||
}
|
} else {
|
||||||
|
error(_('Please select a shift type.'));
|
||||||
if (isset($_REQUEST['add_minutes_start']) && is_numeric(trim($_REQUEST['add_minutes_start']))) {
|
redirect(page_link_to('admin_import'));
|
||||||
$add_minutes_start = trim($_REQUEST['add_minutes_start']);
|
}
|
||||||
} else {
|
|
||||||
error(_("Please enter an amount of minutes to add to a talk's begin."));
|
if (isset($_REQUEST['add_minutes_start']) && is_numeric(trim($_REQUEST['add_minutes_start']))) {
|
||||||
redirect(page_link_to('admin_import'));
|
$add_minutes_start = trim($_REQUEST['add_minutes_start']);
|
||||||
}
|
} else {
|
||||||
|
error(_("Please enter an amount of minutes to add to a talk's begin."));
|
||||||
if (isset($_REQUEST['add_minutes_end']) && is_numeric(trim($_REQUEST['add_minutes_end']))) {
|
redirect(page_link_to('admin_import'));
|
||||||
$add_minutes_end = trim($_REQUEST['add_minutes_end']);
|
}
|
||||||
} else {
|
|
||||||
error(_("Please enter an amount of minutes to add to a talk's end."));
|
if (isset($_REQUEST['add_minutes_end']) && is_numeric(trim($_REQUEST['add_minutes_end']))) {
|
||||||
redirect(page_link_to('admin_import'));
|
$add_minutes_end = trim($_REQUEST['add_minutes_end']);
|
||||||
}
|
} else {
|
||||||
|
error(_("Please enter an amount of minutes to add to a talk's end."));
|
||||||
list($rooms_new, $rooms_deleted) = prepare_rooms($import_file);
|
redirect(page_link_to('admin_import'));
|
||||||
list($events_new, $events_updated, $events_deleted) = prepare_events($import_file, $shifttype_id, $add_minutes_start, $add_minutes_end);
|
}
|
||||||
|
|
||||||
$html .= div('well well-sm text-center', [
|
list($rooms_new, $rooms_deleted) = prepare_rooms($import_file);
|
||||||
'<span class="text-success">' . _('File Upload') . glyph('ok-circle') . '</span>' . mute(glyph('arrow-right')) . _('Validation') . mute(glyph('arrow-right')) . mute(_('Import'))
|
list($events_new, $events_updated, $events_deleted) = prepare_events(
|
||||||
]) . form([
|
$import_file,
|
||||||
div('row', [
|
$shifttype_id,
|
||||||
div('col-sm-6', [
|
$add_minutes_start,
|
||||||
'<h3>' . _("Rooms to create") . '</h3>',
|
$add_minutes_end
|
||||||
table(_("Name"), $rooms_new)
|
);
|
||||||
]),
|
|
||||||
div('col-sm-6', [
|
$html .= div(
|
||||||
'<h3>' . _("Rooms to delete") . '</h3>',
|
'well well-sm text-center',
|
||||||
table(_("Name"), $rooms_deleted)
|
[
|
||||||
])
|
'<span class="text-success">' . _('File Upload') . glyph('ok-circle') . '</span>' . mute(glyph('arrow-right')) . _('Validation') . mute(glyph('arrow-right')) . mute(_('Import'))
|
||||||
]),
|
])
|
||||||
'<h3>' . _("Shifts to create") . '</h3>',
|
. form(
|
||||||
table([
|
[
|
||||||
'day' => _("Day"),
|
div('row', [
|
||||||
'start' => _("Start"),
|
div('col-sm-6', [
|
||||||
'end' => _("End"),
|
'<h3>' . _("Rooms to create") . '</h3>',
|
||||||
'shifttype' => _('Shift type'),
|
table(_("Name"), $rooms_new)
|
||||||
'title' => _("Title"),
|
]),
|
||||||
'room' => _("Room")
|
div('col-sm-6', [
|
||||||
], shifts_printable($events_new, $shifttypes)),
|
'<h3>' . _("Rooms to delete") . '</h3>',
|
||||||
'<h3>' . _("Shifts to update") . '</h3>',
|
table(_("Name"), $rooms_deleted)
|
||||||
table([
|
])
|
||||||
'day' => _("Day"),
|
]),
|
||||||
'start' => _("Start"),
|
'<h3>' . _("Shifts to create") . '</h3>',
|
||||||
'end' => _("End"),
|
table([
|
||||||
'shifttype' => _('Shift type'),
|
'day' => _("Day"),
|
||||||
'title' => _("Title"),
|
'start' => _("Start"),
|
||||||
'room' => _("Room")
|
'end' => _("End"),
|
||||||
], shifts_printable($events_updated, $shifttypes)),
|
'shifttype' => _('Shift type'),
|
||||||
'<h3>' . _("Shifts to delete") . '</h3>',
|
'title' => _("Title"),
|
||||||
table([
|
'room' => _("Room")
|
||||||
'day' => _("Day"),
|
], shifts_printable($events_new, $shifttypes)),
|
||||||
'start' => _("Start"),
|
'<h3>' . _("Shifts to update") . '</h3>',
|
||||||
'end' => _("End"),
|
table([
|
||||||
'shifttype' => _('Shift type'),
|
'day' => _("Day"),
|
||||||
'title' => _("Title"),
|
'start' => _("Start"),
|
||||||
'room' => _("Room")
|
'end' => _("End"),
|
||||||
], shifts_printable($events_deleted, $shifttypes)),
|
'shifttype' => _('Shift type'),
|
||||||
form_submit('submit', _("Import"))
|
'title' => _("Title"),
|
||||||
], page_link_to('admin_import') . '&step=import&shifttype_id=' . $shifttype_id . "&add_minutes_end=" . $add_minutes_end . "&add_minutes_start=" . $add_minutes_start);
|
'room' => _("Room")
|
||||||
break;
|
], shifts_printable($events_updated, $shifttypes)),
|
||||||
|
'<h3>' . _("Shifts to delete") . '</h3>',
|
||||||
case 'import':
|
table([
|
||||||
if (! file_exists($import_file)) {
|
'day' => _("Day"),
|
||||||
error(_('Missing import file.'));
|
'start' => _("Start"),
|
||||||
redirect(page_link_to('admin_import'));
|
'end' => _("End"),
|
||||||
}
|
'shifttype' => _('Shift type'),
|
||||||
|
'title' => _("Title"),
|
||||||
if (! file_exists($import_file)) {
|
'room' => _("Room")
|
||||||
redirect(page_link_to('admin_import'));
|
], shifts_printable($events_deleted, $shifttypes)),
|
||||||
}
|
form_submit('submit', _("Import"))
|
||||||
|
],
|
||||||
if (isset($_REQUEST['shifttype_id']) && isset($shifttypes[$_REQUEST['shifttype_id']])) {
|
page_link_to('admin_import')
|
||||||
$shifttype_id = $_REQUEST['shifttype_id'];
|
. '&step=import&shifttype_id=' . $shifttype_id
|
||||||
} else {
|
. "&add_minutes_end=" . $add_minutes_end
|
||||||
error(_('Please select a shift type.'));
|
. "&add_minutes_start=" . $add_minutes_start
|
||||||
redirect(page_link_to('admin_import'));
|
);
|
||||||
}
|
break;
|
||||||
|
|
||||||
if (isset($_REQUEST['add_minutes_start']) && is_numeric(trim($_REQUEST['add_minutes_start']))) {
|
case 'import':
|
||||||
$add_minutes_start = trim($_REQUEST['add_minutes_start']);
|
if (!file_exists($import_file)) {
|
||||||
} else {
|
error(_('Missing import file.'));
|
||||||
error(_("Please enter an amount of minutes to add to a talk's begin."));
|
redirect(page_link_to('admin_import'));
|
||||||
redirect(page_link_to('admin_import'));
|
}
|
||||||
}
|
|
||||||
|
if (!file_exists($import_file)) {
|
||||||
if (isset($_REQUEST['add_minutes_end']) && is_numeric(trim($_REQUEST['add_minutes_end']))) {
|
redirect(page_link_to('admin_import'));
|
||||||
$add_minutes_end = trim($_REQUEST['add_minutes_end']);
|
}
|
||||||
} else {
|
|
||||||
error(_("Please enter an amount of minutes to add to a talk's end."));
|
if (isset($_REQUEST['shifttype_id']) && isset($shifttypes[$_REQUEST['shifttype_id']])) {
|
||||||
redirect(page_link_to('admin_import'));
|
$shifttype_id = $_REQUEST['shifttype_id'];
|
||||||
}
|
} else {
|
||||||
|
error(_('Please select a shift type.'));
|
||||||
list($rooms_new, $rooms_deleted) = prepare_rooms($import_file);
|
redirect(page_link_to('admin_import'));
|
||||||
foreach ($rooms_new as $room) {
|
}
|
||||||
$result = Room_create($room, true, true);
|
|
||||||
if ($result === false) {
|
if (isset($_REQUEST['add_minutes_start']) && is_numeric(trim($_REQUEST['add_minutes_start']))) {
|
||||||
engelsystem_error('Unable to create room.');
|
$add_minutes_start = trim($_REQUEST['add_minutes_start']);
|
||||||
}
|
} else {
|
||||||
$rooms_import[trim($room)] = sql_id();
|
error(_("Please enter an amount of minutes to add to a talk's begin."));
|
||||||
}
|
redirect(page_link_to('admin_import'));
|
||||||
foreach ($rooms_deleted as $room) {
|
}
|
||||||
sql_query("DELETE FROM `Room` WHERE `Name`='" . sql_escape($room) . "' LIMIT 1");
|
|
||||||
}
|
if (isset($_REQUEST['add_minutes_end']) && is_numeric(trim($_REQUEST['add_minutes_end']))) {
|
||||||
|
$add_minutes_end = trim($_REQUEST['add_minutes_end']);
|
||||||
list($events_new, $events_updated, $events_deleted) = prepare_events($import_file, $shifttype_id, $add_minutes_start, $add_minutes_end);
|
} else {
|
||||||
foreach ($events_new as $event) {
|
error(_("Please enter an amount of minutes to add to a talk's end."));
|
||||||
$result = Shift_create($event);
|
redirect(page_link_to('admin_import'));
|
||||||
if ($result === false) {
|
}
|
||||||
engelsystem_error('Unable to create shift.');
|
|
||||||
}
|
list($rooms_new, $rooms_deleted) = prepare_rooms($import_file);
|
||||||
}
|
foreach ($rooms_new as $room) {
|
||||||
|
$result = Room_create($room, true, true);
|
||||||
foreach ($events_updated as $event) {
|
if ($result === false) {
|
||||||
$result = Shift_update_by_psid($event);
|
engelsystem_error('Unable to create room.');
|
||||||
if ($result === false) {
|
}
|
||||||
engelsystem_error('Unable to update shift.');
|
$rooms_import[trim($room)] = sql_id();
|
||||||
}
|
}
|
||||||
}
|
foreach ($rooms_deleted as $room) {
|
||||||
|
sql_query("DELETE FROM `Room` WHERE `Name`='" . sql_escape($room) . "' LIMIT 1");
|
||||||
foreach ($events_deleted as $event) {
|
}
|
||||||
$result = Shift_delete_by_psid($event['PSID']);
|
|
||||||
if ($result === false) {
|
list($events_new, $events_updated, $events_deleted) = prepare_events(
|
||||||
engelsystem_error('Unable to delete shift.');
|
$import_file,
|
||||||
}
|
$shifttype_id,
|
||||||
}
|
$add_minutes_start,
|
||||||
|
$add_minutes_end
|
||||||
engelsystem_log("Frab import done");
|
);
|
||||||
|
foreach ($events_new as $event) {
|
||||||
unlink($import_file);
|
$result = Shift_create($event);
|
||||||
|
if ($result === false) {
|
||||||
$html .= div('well well-sm text-center', [
|
engelsystem_error('Unable to create shift.');
|
||||||
'<span class="text-success">' . _('File Upload') . glyph('ok-circle') . '</span>' . mute(glyph('arrow-right')) . '<span class="text-success">' . _('Validation') . glyph('ok-circle') . '</span>' . mute(glyph('arrow-right')) . '<span class="text-success">' . _('Import') . glyph('ok-circle') . '</span>'
|
}
|
||||||
]) . success(_("It's done!"), true);
|
}
|
||||||
break;
|
|
||||||
default:
|
foreach ($events_updated as $event) {
|
||||||
redirect(page_link_to('admin_import'));
|
$result = Shift_update_by_psid($event);
|
||||||
}
|
if ($result === false) {
|
||||||
|
engelsystem_error('Unable to update shift.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($events_deleted as $event) {
|
||||||
|
$result = Shift_delete_by_psid($event['PSID']);
|
||||||
|
if ($result === false) {
|
||||||
|
engelsystem_error('Unable to delete shift.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
engelsystem_log("Frab import done");
|
||||||
|
|
||||||
|
unlink($import_file);
|
||||||
|
|
||||||
|
$html .= div('well well-sm text-center', [
|
||||||
|
'<span class="text-success">' . _('File Upload') . glyph('ok-circle') . '</span>' . mute(glyph('arrow-right')) . '<span class="text-success">' . _('Validation') . glyph('ok-circle') . '</span>' . mute(glyph('arrow-right')) . '<span class="text-success">' . _('Import') . glyph('ok-circle') . '</span>'
|
||||||
|
]) . success(_("It's done!"), true);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
redirect(page_link_to('admin_import'));
|
||||||
|
}
|
||||||
|
|
||||||
return page_with_title(admin_import_title(), [
|
return page_with_title(admin_import_title(), [
|
||||||
msg(),
|
msg(),
|
||||||
$html
|
$html
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function prepare_rooms($file)
|
function prepare_rooms($file)
|
||||||
{
|
{
|
||||||
global $rooms_import;
|
global $rooms_import;
|
||||||
$data = read_xml($file);
|
$data = read_xml($file);
|
||||||
|
|
||||||
// Load rooms from db for compare with input
|
// Load rooms from db for compare with input
|
||||||
$rooms = sql_select("SELECT * FROM `Room` WHERE `FromPentabarf`='Y'");
|
$rooms = sql_select("SELECT * FROM `Room` WHERE `FromPentabarf`='Y'");
|
||||||
$rooms_db = [];
|
$rooms_db = [];
|
||||||
$rooms_import = [];
|
$rooms_import = [];
|
||||||
foreach ($rooms as $room) {
|
foreach ($rooms as $room) {
|
||||||
$rooms_db[] = (string) $room['Name'];
|
$rooms_db[] = (string)$room['Name'];
|
||||||
$rooms_import[$room['Name']] = $room['RID'];
|
$rooms_import[$room['Name']] = $room['RID'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$events = $data->vcalendar->vevent;
|
$events = $data->vcalendar->vevent;
|
||||||
$rooms_pb = [];
|
$rooms_pb = [];
|
||||||
foreach ($events as $event) {
|
foreach ($events as $event) {
|
||||||
$rooms_pb[] = (string) $event->location;
|
$rooms_pb[] = (string)$event->location;
|
||||||
if (! isset($rooms_import[trim($event->location)])) {
|
if (!isset($rooms_import[trim($event->location)])) {
|
||||||
$rooms_import[trim($event->location)] = trim($event->location);
|
$rooms_import[trim($event->location)] = trim($event->location);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$rooms_pb = array_unique($rooms_pb);
|
$rooms_pb = array_unique($rooms_pb);
|
||||||
|
|
||||||
$rooms_new = array_diff($rooms_pb, $rooms_db);
|
$rooms_new = array_diff($rooms_pb, $rooms_db);
|
||||||
$rooms_deleted = array_diff($rooms_db, $rooms_pb);
|
$rooms_deleted = array_diff($rooms_db, $rooms_pb);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
$rooms_new,
|
$rooms_new,
|
||||||
$rooms_deleted
|
$rooms_deleted
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
function prepare_events($file, $shifttype_id, $add_minutes_start, $add_minutes_end)
|
function prepare_events($file, $shifttype_id, $add_minutes_start, $add_minutes_end)
|
||||||
{
|
{
|
||||||
global $rooms_import;
|
global $rooms_import;
|
||||||
$data = read_xml($file);
|
$data = read_xml($file);
|
||||||
|
|
||||||
$rooms = sql_select("SELECT * FROM `Room`");
|
$rooms = sql_select("SELECT * FROM `Room`");
|
||||||
$rooms_db = [];
|
$rooms_db = [];
|
||||||
foreach ($rooms as $room) {
|
foreach ($rooms as $room) {
|
||||||
$rooms_db[$room['Name']] = $room['RID'];
|
$rooms_db[$room['Name']] = $room['RID'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$events = $data->vcalendar->vevent;
|
$events = $data->vcalendar->vevent;
|
||||||
$shifts_pb = [];
|
$shifts_pb = [];
|
||||||
foreach ($events as $event) {
|
foreach ($events as $event) {
|
||||||
$event_pb = $event->children("http://pentabarf.org");
|
$event_pb = $event->children("http://pentabarf.org");
|
||||||
$event_id = trim($event_pb->{
|
$event_id = trim($event_pb->{
|
||||||
'event-id' });
|
'event-id'});
|
||||||
$shifts_pb[$event_id] = [
|
$shifts_pb[$event_id] = [
|
||||||
'shifttype_id' => $shifttype_id,
|
'shifttype_id' => $shifttype_id,
|
||||||
'start' => parse_date("Ymd\THis", $event->dtstart) - $add_minutes_start * 60,
|
'start' => parse_date("Ymd\THis", $event->dtstart) - $add_minutes_start * 60,
|
||||||
'end' => parse_date("Ymd\THis", $event->dtend) + $add_minutes_end * 60,
|
'end' => parse_date("Ymd\THis", $event->dtend) + $add_minutes_end * 60,
|
||||||
'RID' => $rooms_import[trim($event->location)],
|
'RID' => $rooms_import[trim($event->location)],
|
||||||
'title' => trim($event->summary),
|
'title' => trim($event->summary),
|
||||||
'URL' => trim($event->url),
|
'URL' => trim($event->url),
|
||||||
'PSID' => $event_id
|
'PSID' => $event_id
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
$shifts = sql_select("SELECT * FROM `Shifts` WHERE `PSID` IS NOT NULL ORDER BY `start`");
|
$shifts = sql_select("SELECT * FROM `Shifts` WHERE `PSID` IS NOT NULL ORDER BY `start`");
|
||||||
$shifts_db = [];
|
$shifts_db = [];
|
||||||
foreach ($shifts as $shift) {
|
foreach ($shifts as $shift) {
|
||||||
$shifts_db[$shift['PSID']] = $shift;
|
$shifts_db[$shift['PSID']] = $shift;
|
||||||
}
|
}
|
||||||
|
|
||||||
$shifts_new = [];
|
$shifts_new = [];
|
||||||
$shifts_updated = [];
|
$shifts_updated = [];
|
||||||
foreach ($shifts_pb as $shift) {
|
foreach ($shifts_pb as $shift) {
|
||||||
if (! isset($shifts_db[$shift['PSID']])) {
|
if (!isset($shifts_db[$shift['PSID']])) {
|
||||||
$shifts_new[] = $shift;
|
$shifts_new[] = $shift;
|
||||||
} else {
|
} else {
|
||||||
$tmp = $shifts_db[$shift['PSID']];
|
$tmp = $shifts_db[$shift['PSID']];
|
||||||
|
@ -344,25 +369,25 @@ function prepare_events($file, $shifttype_id, $add_minutes_start, $add_minutes_e
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$shifts_deleted = [];
|
$shifts_deleted = [];
|
||||||
foreach ($shifts_db as $shift) {
|
foreach ($shifts_db as $shift) {
|
||||||
if (! isset($shifts_pb[$shift['PSID']])) {
|
if (!isset($shifts_pb[$shift['PSID']])) {
|
||||||
$shifts_deleted[] = $shift;
|
$shifts_deleted[] = $shift;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
$shifts_new,
|
$shifts_new,
|
||||||
$shifts_updated,
|
$shifts_updated,
|
||||||
$shifts_deleted
|
$shifts_deleted
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
function read_xml($file)
|
function read_xml($file)
|
||||||
{
|
{
|
||||||
global $xml_import;
|
global $xml_import;
|
||||||
if (! isset($xml_import)) {
|
if (!isset($xml_import)) {
|
||||||
$xml_import = simplexml_load_file($file);
|
$xml_import = simplexml_load_file($file);
|
||||||
}
|
}
|
||||||
return $xml_import;
|
return $xml_import;
|
||||||
|
@ -372,27 +397,27 @@ function shifts_printable($shifts, $shifttypes)
|
||||||
{
|
{
|
||||||
global $rooms_import;
|
global $rooms_import;
|
||||||
$rooms = array_flip($rooms_import);
|
$rooms = array_flip($rooms_import);
|
||||||
|
|
||||||
uasort($shifts, 'shift_sort');
|
uasort($shifts, 'shift_sort');
|
||||||
|
|
||||||
$shifts_printable = [];
|
$shifts_printable = [];
|
||||||
foreach ($shifts as $shift) {
|
foreach ($shifts as $shift) {
|
||||||
$shifts_printable[] = [
|
$shifts_printable[] = [
|
||||||
'day' => date("l, Y-m-d", $shift['start']),
|
'day' => date("l, Y-m-d", $shift['start']),
|
||||||
'start' => date("H:i", $shift['start']),
|
'start' => date("H:i", $shift['start']),
|
||||||
'shifttype' => ShiftType_name_render([
|
'shifttype' => ShiftType_name_render([
|
||||||
'id' => $shift['shifttype_id'],
|
'id' => $shift['shifttype_id'],
|
||||||
'name' => $shifttypes[$shift['shifttype_id']]
|
'name' => $shifttypes[$shift['shifttype_id']]
|
||||||
]),
|
]),
|
||||||
'title' => shorten($shift['title']),
|
'title' => shorten($shift['title']),
|
||||||
'end' => date("H:i", $shift['end']),
|
'end' => date("H:i", $shift['end']),
|
||||||
'room' => $rooms[$shift['RID']]
|
'room' => $rooms[$shift['RID']]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
return $shifts_printable;
|
return $shifts_printable;
|
||||||
}
|
}
|
||||||
|
|
||||||
function shift_sort($shift_a, $shift_b)
|
function shift_sort($shift_a, $shift_b)
|
||||||
{
|
{
|
||||||
return ($shift_a['start'] < $shift_b['start']) ? - 1 : 1;
|
return ($shift_a['start'] < $shift_b['start']) ? -1 : 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,23 +12,23 @@ function admin_log()
|
||||||
$filter = strip_request_item('keyword');
|
$filter = strip_request_item('keyword');
|
||||||
}
|
}
|
||||||
$log_entries_source = LogEntries_filter($filter);
|
$log_entries_source = LogEntries_filter($filter);
|
||||||
|
|
||||||
$log_entries = [];
|
$log_entries = [];
|
||||||
foreach ($log_entries_source as $log_entry) {
|
foreach ($log_entries_source as $log_entry) {
|
||||||
$log_entry['date'] = date("d.m.Y H:i", $log_entry['timestamp']);
|
$log_entry['date'] = date("d.m.Y H:i", $log_entry['timestamp']);
|
||||||
$log_entries[] = $log_entry;
|
$log_entries[] = $log_entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
return page_with_title(admin_log_title(), [
|
return page_with_title(admin_log_title(), [
|
||||||
msg(),
|
msg(),
|
||||||
form([
|
form([
|
||||||
form_text('keyword', _("Search"), $filter),
|
form_text('keyword', _("Search"), $filter),
|
||||||
form_submit(_("Search"), "Go")
|
form_submit(_("Search"), "Go")
|
||||||
]),
|
]),
|
||||||
table([
|
table([
|
||||||
'date' => "Time",
|
'date' => "Time",
|
||||||
'nick' => "Angel",
|
'nick' => "Angel",
|
||||||
'message' => "Log Entry"
|
'message' => "Log Entry"
|
||||||
], $log_entries)
|
], $log_entries)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,65 +3,67 @@
|
||||||
function admin_news()
|
function admin_news()
|
||||||
{
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
if (! isset($_GET["action"])) {
|
if (!isset($_GET["action"])) {
|
||||||
redirect(page_link_to("news"));
|
redirect(page_link_to("news"));
|
||||||
}
|
}
|
||||||
|
|
||||||
$html = '<div class="col-md-12"><h1>' . _("Edit news entry") . '</h1>' . msg();
|
$html = '<div class="col-md-12"><h1>' . _("Edit news entry") . '</h1>' . msg();
|
||||||
if (isset($_REQUEST['id']) && preg_match("/^[0-9]{1,11}$/", $_REQUEST['id'])) {
|
if (isset($_REQUEST['id']) && preg_match("/^[0-9]{1,11}$/", $_REQUEST['id'])) {
|
||||||
$news_id = $_REQUEST['id'];
|
$news_id = $_REQUEST['id'];
|
||||||
} else {
|
} else {
|
||||||
return error("Incomplete call, missing News ID.", true);
|
return error("Incomplete call, missing News ID.", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
$news = sql_select("SELECT * FROM `News` WHERE `ID`='" . sql_escape($news_id) . "' LIMIT 1");
|
$news = sql_select("SELECT * FROM `News` WHERE `ID`='" . sql_escape($news_id) . "' LIMIT 1");
|
||||||
if (empty($news)) {
|
if (empty($news)) {
|
||||||
return error("No News found.", true);
|
return error("No News found.", true);
|
||||||
}
|
}
|
||||||
switch ($_REQUEST["action"]) {
|
switch ($_REQUEST["action"]) {
|
||||||
default:
|
default:
|
||||||
redirect(page_link_to('news'));
|
redirect(page_link_to('news'));
|
||||||
case 'edit':
|
case 'edit':
|
||||||
list($news) = $news;
|
list($news) = $news;
|
||||||
|
|
||||||
$user_source = User($news['UID']);
|
$user_source = User($news['UID']);
|
||||||
|
|
||||||
$html .= form([
|
$html .= form([
|
||||||
form_info(_("Date"), date("Y-m-d H:i", $news['Datum'])),
|
form_info(_("Date"), date("Y-m-d H:i", $news['Datum'])),
|
||||||
form_info(_("Author"), User_Nick_render($user_source)),
|
form_info(_("Author"), User_Nick_render($user_source)),
|
||||||
form_text('eBetreff', _("Subject"), $news['Betreff']),
|
form_text('eBetreff', _("Subject"), $news['Betreff']),
|
||||||
form_textarea('eText', _("Message"), $news['Text']),
|
form_textarea('eText', _("Message"), $news['Text']),
|
||||||
form_checkbox('eTreffen', _("Meeting"), $news['Treffen'] == 1, 1),
|
form_checkbox('eTreffen', _("Meeting"), $news['Treffen'] == 1, 1),
|
||||||
form_submit('submit', _("Save"))
|
form_submit('submit', _("Save"))
|
||||||
], page_link_to('admin_news&action=save&id=' . $news_id));
|
], 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>';
|
$html .= '<a class="btn btn-danger" href="' . page_link_to('admin_news&action=delete&id=' . $news_id) . '">'
|
||||||
break;
|
. '<span class="glyphicon glyphicon-trash"></span> ' . _("Delete")
|
||||||
|
. '</a>';
|
||||||
case 'save':
|
break;
|
||||||
list($news) = $news;
|
|
||||||
|
case 'save':
|
||||||
sql_query("UPDATE `News` SET
|
list($news) = $news;
|
||||||
|
|
||||||
|
sql_query("UPDATE `News` SET
|
||||||
`Datum`='" . sql_escape(time()) . "',
|
`Datum`='" . sql_escape(time()) . "',
|
||||||
`Betreff`='" . sql_escape($_POST["eBetreff"]) . "',
|
`Betreff`='" . sql_escape($_POST["eBetreff"]) . "',
|
||||||
`Text`='" . sql_escape($_POST["eText"]) . "',
|
`Text`='" . sql_escape($_POST["eText"]) . "',
|
||||||
`UID`='" . sql_escape($user['UID']) . "',
|
`UID`='" . sql_escape($user['UID']) . "',
|
||||||
`Treffen`='" . sql_escape($_POST["eTreffen"]) . "'
|
`Treffen`='" . sql_escape($_POST["eTreffen"]) . "'
|
||||||
WHERE `ID`='" . sql_escape($news_id) . "'");
|
WHERE `ID`='" . sql_escape($news_id) . "'");
|
||||||
engelsystem_log("News updated: " . $_POST["eBetreff"]);
|
engelsystem_log("News updated: " . $_POST["eBetreff"]);
|
||||||
success(_("News entry updated."));
|
success(_("News entry updated."));
|
||||||
redirect(page_link_to("news"));
|
redirect(page_link_to("news"));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'delete':
|
case 'delete':
|
||||||
list($news) = $news;
|
list($news) = $news;
|
||||||
|
|
||||||
sql_query("DELETE FROM `News` WHERE `ID`='" . sql_escape($news_id) . "' LIMIT 1");
|
sql_query("DELETE FROM `News` WHERE `ID`='" . sql_escape($news_id) . "' LIMIT 1");
|
||||||
engelsystem_log("News deleted: " . $news['Betreff']);
|
engelsystem_log("News deleted: " . $news['Betreff']);
|
||||||
success(_("News entry deleted."));
|
success(_("News entry deleted."));
|
||||||
redirect(page_link_to("news"));
|
redirect(page_link_to("news"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return $html . '</div>';
|
return $html . '</div>';
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,112 +11,129 @@ function admin_questions_title()
|
||||||
function admin_new_questions()
|
function admin_new_questions()
|
||||||
{
|
{
|
||||||
global $privileges, $page;
|
global $privileges, $page;
|
||||||
|
|
||||||
if ($page != "admin_questions") {
|
if ($page != "admin_questions") {
|
||||||
if (in_array("admin_questions", $privileges)) {
|
if (in_array("admin_questions", $privileges)) {
|
||||||
$new_messages = sql_num_query("SELECT * FROM `Questions` WHERE `AID` IS NULL");
|
$new_messages = sql_num_query("SELECT * FROM `Questions` WHERE `AID` IS NULL");
|
||||||
|
|
||||||
if ($new_messages > 0) {
|
if ($new_messages > 0) {
|
||||||
return '<a href="' . page_link_to("admin_questions") . '">' . _('There are unanswered questions!') . '</a>';
|
return '<a href="' . page_link_to("admin_questions") . '">' . _('There are unanswered questions!') . '</a>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function admin_questions()
|
function admin_questions()
|
||||||
{
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
if (! isset($_REQUEST['action'])) {
|
if (!isset($_REQUEST['action'])) {
|
||||||
$unanswered_questions_table = [];
|
$unanswered_questions_table = [];
|
||||||
$questions = sql_select("SELECT * FROM `Questions` WHERE `AID` IS NULL");
|
$questions = sql_select("SELECT * FROM `Questions` WHERE `AID` IS NULL");
|
||||||
foreach ($questions as $question) {
|
foreach ($questions as $question) {
|
||||||
$user_source = User($question['UID']);
|
$user_source = User($question['UID']);
|
||||||
|
|
||||||
$unanswered_questions_table[] = [
|
$unanswered_questions_table[] = [
|
||||||
'from' => User_Nick_render($user_source),
|
'from' => User_Nick_render($user_source),
|
||||||
'question' => str_replace("\n", "<br />", $question['Question']),
|
'question' => str_replace("\n", "<br />", $question['Question']),
|
||||||
'answer' => form([
|
'answer' => form([
|
||||||
form_textarea('answer', '', ''),
|
form_textarea('answer', '', ''),
|
||||||
form_submit('submit', _("Save"))
|
form_submit('submit', _("Save"))
|
||||||
], page_link_to('admin_questions') . '&action=answer&id=' . $question['QID']),
|
], page_link_to('admin_questions') . '&action=answer&id=' . $question['QID']),
|
||||||
'actions' => button(page_link_to("admin_questions") . '&action=delete&id=' . $question['QID'], _("delete"), 'btn-xs')
|
'actions' => button(
|
||||||
];
|
page_link_to("admin_questions") . '&action=delete&id=' . $question['QID'],
|
||||||
|
_("delete"),
|
||||||
|
'btn-xs'
|
||||||
|
)
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
$answered_questions_table = [];
|
$answered_questions_table = [];
|
||||||
$questions = sql_select("SELECT * FROM `Questions` WHERE NOT `AID` IS NULL");
|
$questions = sql_select("SELECT * FROM `Questions` WHERE NOT `AID` IS NULL");
|
||||||
foreach ($questions as $question) {
|
foreach ($questions as $question) {
|
||||||
$user_source = User($question['UID']);
|
$user_source = User($question['UID']);
|
||||||
$answer_user_source = User($question['AID']);
|
$answer_user_source = User($question['AID']);
|
||||||
$answered_questions_table[] = [
|
$answered_questions_table[] = [
|
||||||
'from' => User_Nick_render($user_source),
|
'from' => User_Nick_render($user_source),
|
||||||
'question' => str_replace("\n", "<br />", $question['Question']),
|
'question' => str_replace("\n", "<br />", $question['Question']),
|
||||||
'answered_by' => User_Nick_render($answer_user_source),
|
'answered_by' => User_Nick_render($answer_user_source),
|
||||||
'answer' => str_replace("\n", "<br />", $question['Answer']),
|
'answer' => str_replace("\n", "<br />", $question['Answer']),
|
||||||
'actions' => button(page_link_to("admin_questions") . '&action=delete&id=' . $question['QID'], _("delete"), 'btn-xs')
|
'actions' => button(
|
||||||
];
|
page_link_to("admin_questions") . '&action=delete&id=' . $question['QID'],
|
||||||
|
_("delete"),
|
||||||
|
'btn-xs'
|
||||||
|
)
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
return page_with_title(admin_questions_title(), [
|
return page_with_title(admin_questions_title(), [
|
||||||
'<h2>' . _("Unanswered questions") . '</h2>',
|
'<h2>' . _("Unanswered questions") . '</h2>',
|
||||||
table([
|
table([
|
||||||
'from' => _("From"),
|
'from' => _("From"),
|
||||||
'question' => _("Question"),
|
'question' => _("Question"),
|
||||||
'answer' => _("Answer"),
|
'answer' => _("Answer"),
|
||||||
'actions' => ''
|
'actions' => ''
|
||||||
], $unanswered_questions_table),
|
], $unanswered_questions_table),
|
||||||
'<h2>' . _("Answered questions") . '</h2>',
|
'<h2>' . _("Answered questions") . '</h2>',
|
||||||
table([
|
table([
|
||||||
'from' => _("From"),
|
'from' => _("From"),
|
||||||
'question' => _("Question"),
|
'question' => _("Question"),
|
||||||
'answered_by' => _("Answered by"),
|
'answered_by' => _("Answered by"),
|
||||||
'answer' => _("Answer"),
|
'answer' => _("Answer"),
|
||||||
'actions' => ''
|
'actions' => ''
|
||||||
], $answered_questions_table)
|
], $answered_questions_table)
|
||||||
]);
|
]);
|
||||||
} else {
|
} else {
|
||||||
switch ($_REQUEST['action']) {
|
switch ($_REQUEST['action']) {
|
||||||
case 'answer':
|
case 'answer':
|
||||||
if (isset($_REQUEST['id']) && preg_match("/^[0-9]{1,11}$/", $_REQUEST['id'])) {
|
if (isset($_REQUEST['id']) && preg_match("/^[0-9]{1,11}$/", $_REQUEST['id'])) {
|
||||||
$question_id = $_REQUEST['id'];
|
$question_id = $_REQUEST['id'];
|
||||||
} else {
|
} else {
|
||||||
return error("Incomplete call, missing Question ID.", true);
|
return error("Incomplete call, missing Question ID.", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
$question = sql_select("SELECT * FROM `Questions` WHERE `QID`='" . sql_escape($question_id) . "' LIMIT 1");
|
||||||
|
if (count($question) > 0 && $question[0]['AID'] == null) {
|
||||||
|
$answer = trim(
|
||||||
|
preg_replace("/([^\p{L}\p{P}\p{Z}\p{N}\n]{1,})/ui",
|
||||||
|
'',
|
||||||
|
strip_tags($_REQUEST['answer'])
|
||||||
|
));
|
||||||
|
|
||||||
|
if ($answer != "") {
|
||||||
|
sql_query("
|
||||||
|
UPDATE `Questions`
|
||||||
|
SET `AID`='" . sql_escape($user['UID']) . "', `Answer`='" . sql_escape($answer) . "'
|
||||||
|
WHERE `QID`='" . sql_escape($question_id) . "'
|
||||||
|
LIMIT 1
|
||||||
|
");
|
||||||
|
engelsystem_log("Question " . $question[0]['Question'] . " answered: " . $answer);
|
||||||
|
redirect(page_link_to("admin_questions"));
|
||||||
|
} else {
|
||||||
|
return error("Enter an answer!", true);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return error("No question found.", 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
$question = sql_select("SELECT * FROM `Questions` WHERE `QID`='" . sql_escape($question_id) . "' LIMIT 1");
|
||||||
|
if (count($question) > 0) {
|
||||||
|
sql_query("DELETE FROM `Questions` WHERE `QID`='" . sql_escape($question_id) . "' LIMIT 1");
|
||||||
|
engelsystem_log("Question deleted: " . $question[0]['Question']);
|
||||||
|
redirect(page_link_to("admin_questions"));
|
||||||
|
} else {
|
||||||
|
return error("No question found.", true);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$question = sql_select("SELECT * FROM `Questions` WHERE `QID`='" . sql_escape($question_id) . "' LIMIT 1");
|
|
||||||
if (count($question) > 0 && $question[0]['AID'] == null) {
|
|
||||||
$answer = trim(preg_replace("/([^\p{L}\p{P}\p{Z}\p{N}\n]{1,})/ui", '', strip_tags($_REQUEST['answer'])));
|
|
||||||
|
|
||||||
if ($answer != "") {
|
|
||||||
sql_query("UPDATE `Questions` SET `AID`='" . sql_escape($user['UID']) . "', `Answer`='" . sql_escape($answer) . "' WHERE `QID`='" . sql_escape($question_id) . "' LIMIT 1");
|
|
||||||
engelsystem_log("Question " . $question[0]['Question'] . " answered: " . $answer);
|
|
||||||
redirect(page_link_to("admin_questions"));
|
|
||||||
} else {
|
|
||||||
return error("Enter an answer!", true);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return error("No question found.", 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
$question = sql_select("SELECT * FROM `Questions` WHERE `QID`='" . sql_escape($question_id) . "' LIMIT 1");
|
|
||||||
if (count($question) > 0) {
|
|
||||||
sql_query("DELETE FROM `Questions` WHERE `QID`='" . sql_escape($question_id) . "' LIMIT 1");
|
|
||||||
engelsystem_log("Question deleted: " . $question[0]['Question']);
|
|
||||||
redirect(page_link_to("admin_questions"));
|
|
||||||
} else {
|
|
||||||
return error("No question found.", true);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,24 +11,24 @@ function admin_rooms()
|
||||||
$rooms = [];
|
$rooms = [];
|
||||||
foreach ($rooms_source as $room) {
|
foreach ($rooms_source as $room) {
|
||||||
$rooms[] = [
|
$rooms[] = [
|
||||||
'name' => Room_name_render($room),
|
'name' => Room_name_render($room),
|
||||||
'from_pentabarf' => $room['FromPentabarf'] == 'Y' ? '✓' : '',
|
'from_pentabarf' => $room['FromPentabarf'] == 'Y' ? '✓' : '',
|
||||||
'public' => $room['show'] == 'Y' ? '✓' : '',
|
'public' => $room['show'] == 'Y' ? '✓' : '',
|
||||||
'actions' => table_buttons([
|
'actions' => table_buttons([
|
||||||
button(page_link_to('admin_rooms') . '&show=edit&id=' . $room['RID'], _("edit"), 'btn-xs'),
|
button(page_link_to('admin_rooms') . '&show=edit&id=' . $room['RID'], _("edit"), 'btn-xs'),
|
||||||
button(page_link_to('admin_rooms') . '&show=delete&id=' . $room['RID'], _("delete"), 'btn-xs')
|
button(page_link_to('admin_rooms') . '&show=delete&id=' . $room['RID'], _("delete"), 'btn-xs')
|
||||||
])
|
])
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
$room = null;
|
$room = null;
|
||||||
|
|
||||||
if (isset($_REQUEST['show'])) {
|
if (isset($_REQUEST['show'])) {
|
||||||
$msg = "";
|
$msg = "";
|
||||||
$name = "";
|
$name = "";
|
||||||
$from_pentabarf = "";
|
$from_pentabarf = "";
|
||||||
$public = 'Y';
|
$public = 'Y';
|
||||||
$number = "";
|
$number = "";
|
||||||
|
|
||||||
$angeltypes_source = sql_select("SELECT * FROM `AngelTypes` ORDER BY `name`");
|
$angeltypes_source = sql_select("SELECT * FROM `AngelTypes` ORDER BY `name`");
|
||||||
$angeltypes = [];
|
$angeltypes = [];
|
||||||
$angeltypes_count = [];
|
$angeltypes_count = [];
|
||||||
|
@ -36,7 +36,7 @@ function admin_rooms()
|
||||||
$angeltypes[$angeltype['id']] = $angeltype['name'];
|
$angeltypes[$angeltype['id']] = $angeltype['name'];
|
||||||
$angeltypes_count[$angeltype['id']] = 0;
|
$angeltypes_count[$angeltype['id']] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (test_request_int('id')) {
|
if (test_request_int('id')) {
|
||||||
$room = Room($_REQUEST['id']);
|
$room = Room($_REQUEST['id']);
|
||||||
if ($room === false) {
|
if ($room === false) {
|
||||||
|
@ -45,23 +45,23 @@ function admin_rooms()
|
||||||
if ($room == null) {
|
if ($room == null) {
|
||||||
redirect(page_link_to('admin_rooms'));
|
redirect(page_link_to('admin_rooms'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$room_id = $_REQUEST['id'];
|
$room_id = $_REQUEST['id'];
|
||||||
$name = $room['Name'];
|
$name = $room['Name'];
|
||||||
$from_pentabarf = $room['FromPentabarf'];
|
$from_pentabarf = $room['FromPentabarf'];
|
||||||
$public = $room['show'];
|
$public = $room['show'];
|
||||||
$number = $room['Number'];
|
$number = $room['Number'];
|
||||||
|
|
||||||
$needed_angeltypes = sql_select("SELECT * FROM `NeededAngelTypes` WHERE `room_id`='" . sql_escape($room_id) . "'");
|
$needed_angeltypes = sql_select("SELECT * FROM `NeededAngelTypes` WHERE `room_id`='" . sql_escape($room_id) . "'");
|
||||||
foreach ($needed_angeltypes as $needed_angeltype) {
|
foreach ($needed_angeltypes as $needed_angeltype) {
|
||||||
$angeltypes_count[$needed_angeltype['angel_type_id']] = $needed_angeltype['count'];
|
$angeltypes_count[$needed_angeltype['angel_type_id']] = $needed_angeltype['count'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($_REQUEST['show'] == 'edit') {
|
if ($_REQUEST['show'] == 'edit') {
|
||||||
if (isset($_REQUEST['submit'])) {
|
if (isset($_REQUEST['submit'])) {
|
||||||
$valid = true;
|
$valid = true;
|
||||||
|
|
||||||
if (isset($_REQUEST['name']) && strlen(strip_request_item('name')) > 0) {
|
if (isset($_REQUEST['name']) && strlen(strip_request_item('name')) > 0) {
|
||||||
$name = strip_request_item('name');
|
$name = strip_request_item('name');
|
||||||
if (isset($room) && sql_num_query("SELECT * FROM `Room` WHERE `Name`='" . sql_escape($name) . "' AND NOT `RID`=" . sql_escape($room_id)) > 0) {
|
if (isset($room) && sql_num_query("SELECT * FROM `Room` WHERE `Name`='" . sql_escape($name) . "' AND NOT `RID`=" . sql_escape($room_id)) > 0) {
|
||||||
|
@ -72,34 +72,37 @@ function admin_rooms()
|
||||||
$valid = false;
|
$valid = false;
|
||||||
$msg .= error(_("Please enter a name."), true);
|
$msg .= error(_("Please enter a name."), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_REQUEST['from_pentabarf'])) {
|
if (isset($_REQUEST['from_pentabarf'])) {
|
||||||
$from_pentabarf = 'Y';
|
$from_pentabarf = 'Y';
|
||||||
} else {
|
} else {
|
||||||
$from_pentabarf = '';
|
$from_pentabarf = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_REQUEST['public'])) {
|
if (isset($_REQUEST['public'])) {
|
||||||
$public = 'Y';
|
$public = 'Y';
|
||||||
} else {
|
} else {
|
||||||
$public = '';
|
$public = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_REQUEST['number'])) {
|
if (isset($_REQUEST['number'])) {
|
||||||
$number = strip_request_item('number');
|
$number = strip_request_item('number');
|
||||||
} else {
|
} else {
|
||||||
$valid = false;
|
$valid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($angeltypes as $angeltype_id => $angeltype) {
|
foreach ($angeltypes as $angeltype_id => $angeltype) {
|
||||||
if (isset($_REQUEST['angeltype_count_' . $angeltype_id]) && preg_match("/^[0-9]{1,4}$/", $_REQUEST['angeltype_count_' . $angeltype_id])) {
|
if (
|
||||||
|
isset($_REQUEST['angeltype_count_' . $angeltype_id])
|
||||||
|
&& preg_match("/^[0-9]{1,4}$/", $_REQUEST['angeltype_count_' . $angeltype_id])
|
||||||
|
) {
|
||||||
$angeltypes_count[$angeltype_id] = $_REQUEST['angeltype_count_' . $angeltype_id];
|
$angeltypes_count[$angeltype_id] = $_REQUEST['angeltype_count_' . $angeltype_id];
|
||||||
} else {
|
} else {
|
||||||
$valid = false;
|
$valid = false;
|
||||||
$msg .= error(sprintf(_("Please enter needed angels for type %s.", $angeltype)), true);
|
$msg .= error(sprintf(_("Please enter needed angels for type %s.", $angeltype)), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($valid) {
|
if ($valid) {
|
||||||
if (isset($room_id)) {
|
if (isset($room_id)) {
|
||||||
sql_query("UPDATE `Room` SET `Name`='" . sql_escape($name) . "', `FromPentabarf`='" . sql_escape($from_pentabarf) . "', `show`='" . sql_escape($public) . "', `Number`='" . sql_escape($number) . "' WHERE `RID`='" . sql_escape($room_id) . "' LIMIT 1");
|
sql_query("UPDATE `Room` SET `Name`='" . sql_escape($name) . "', `FromPentabarf`='" . sql_escape($from_pentabarf) . "', `show`='" . sql_escape($public) . "', `Number`='" . sql_escape($number) . "' WHERE `RID`='" . sql_escape($room_id) . "' LIMIT 1");
|
||||||
|
@ -111,7 +114,7 @@ function admin_rooms()
|
||||||
}
|
}
|
||||||
engelsystem_log("Room created: " . $name . ", pentabarf import: " . $from_pentabarf . ", public: " . $public . ", number: " . $number);
|
engelsystem_log("Room created: " . $name . ", pentabarf import: " . $from_pentabarf . ", public: " . $public . ", number: " . $number);
|
||||||
}
|
}
|
||||||
|
|
||||||
NeededAngelTypes_delete_by_room($room_id);
|
NeededAngelTypes_delete_by_room($room_id);
|
||||||
$needed_angeltype_info = [];
|
$needed_angeltype_info = [];
|
||||||
foreach ($angeltypes_count as $angeltype_id => $angeltype_count) {
|
foreach ($angeltypes_count as $angeltype_id => $angeltype_count) {
|
||||||
|
@ -121,8 +124,11 @@ function admin_rooms()
|
||||||
$needed_angeltype_info[] = $angeltype['name'] . ": " . $angeltype_count;
|
$needed_angeltype_info[] = $angeltype['name'] . ": " . $angeltype_count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
engelsystem_log("Set needed angeltypes of room " . $name . " to: " . join(", ", $needed_angeltype_info));
|
engelsystem_log(
|
||||||
|
"Set needed angeltypes of room " . $name
|
||||||
|
. " to: " . join(", ", $needed_angeltype_info)
|
||||||
|
);
|
||||||
success(_("Room saved."));
|
success(_("Room saved."));
|
||||||
redirect(page_link_to("admin_rooms"));
|
redirect(page_link_to("admin_rooms"));
|
||||||
}
|
}
|
||||||
|
@ -130,68 +136,68 @@ function admin_rooms()
|
||||||
$angeltypes_count_form = [];
|
$angeltypes_count_form = [];
|
||||||
foreach ($angeltypes as $angeltype_id => $angeltype) {
|
foreach ($angeltypes as $angeltype_id => $angeltype) {
|
||||||
$angeltypes_count_form[] = div('col-lg-4 col-md-6 col-xs-6', [
|
$angeltypes_count_form[] = div('col-lg-4 col-md-6 col-xs-6', [
|
||||||
form_spinner('angeltype_count_' . $angeltype_id, $angeltype, $angeltypes_count[$angeltype_id])
|
form_spinner('angeltype_count_' . $angeltype_id, $angeltype, $angeltypes_count[$angeltype_id])
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return page_with_title(admin_rooms_title(), [
|
return page_with_title(admin_rooms_title(), [
|
||||||
buttons([
|
buttons([
|
||||||
button(page_link_to('admin_rooms'), _("back"), 'back')
|
button(page_link_to('admin_rooms'), _("back"), 'back')
|
||||||
]),
|
]),
|
||||||
$msg,
|
$msg,
|
||||||
form([
|
form([
|
||||||
div('row', [
|
div('row', [
|
||||||
div('col-md-6', [
|
div('col-md-6', [
|
||||||
form_text('name', _("Name"), $name),
|
form_text('name', _("Name"), $name),
|
||||||
form_checkbox('from_pentabarf', _("Frab import"), $from_pentabarf),
|
form_checkbox('from_pentabarf', _("Frab import"), $from_pentabarf),
|
||||||
form_checkbox('public', _("Public"), $public),
|
form_checkbox('public', _("Public"), $public),
|
||||||
form_text('number', _("Room number"), $number)
|
form_text('number', _("Room number"), $number)
|
||||||
]),
|
]),
|
||||||
div('col-md-6', [
|
div('col-md-6', [
|
||||||
div('row', [
|
div('row', [
|
||||||
div('col-md-12', [
|
div('col-md-12', [
|
||||||
form_info(_("Needed angels:"))
|
form_info(_("Needed angels:"))
|
||||||
]),
|
]),
|
||||||
join($angeltypes_count_form)
|
join($angeltypes_count_form)
|
||||||
])
|
])
|
||||||
])
|
])
|
||||||
]),
|
]),
|
||||||
form_submit('submit', _("Save"))
|
form_submit('submit', _("Save"))
|
||||||
])
|
])
|
||||||
]);
|
]);
|
||||||
} elseif ($_REQUEST['show'] == 'delete') {
|
} elseif ($_REQUEST['show'] == 'delete') {
|
||||||
if (isset($_REQUEST['ack'])) {
|
if (isset($_REQUEST['ack'])) {
|
||||||
if (! Room_delete($room_id)) {
|
if (!Room_delete($room_id)) {
|
||||||
engelsystem_error("Unable to delete room.");
|
engelsystem_error("Unable to delete room.");
|
||||||
}
|
}
|
||||||
|
|
||||||
engelsystem_log("Room deleted: " . $name);
|
engelsystem_log("Room deleted: " . $name);
|
||||||
success(sprintf(_("Room %s deleted."), $name));
|
success(sprintf(_("Room %s deleted."), $name));
|
||||||
redirect(page_link_to('admin_rooms'));
|
redirect(page_link_to('admin_rooms'));
|
||||||
}
|
}
|
||||||
|
|
||||||
return page_with_title(admin_rooms_title(), [
|
return page_with_title(admin_rooms_title(), [
|
||||||
buttons([
|
buttons([
|
||||||
button(page_link_to('admin_rooms'), _("back"), 'back')
|
button(page_link_to('admin_rooms'), _("back"), 'back')
|
||||||
]),
|
]),
|
||||||
sprintf(_("Do you want to delete room %s?"), $name),
|
sprintf(_("Do you want to delete room %s?"), $name),
|
||||||
buttons([
|
buttons([
|
||||||
button(page_link_to('admin_rooms') . '&show=delete&id=' . $room_id . '&ack', _("Delete"), 'delete')
|
button(page_link_to('admin_rooms') . '&show=delete&id=' . $room_id . '&ack', _("Delete"), 'delete')
|
||||||
])
|
])
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return page_with_title(admin_rooms_title(), [
|
return page_with_title(admin_rooms_title(), [
|
||||||
buttons([
|
buttons([
|
||||||
button(page_link_to('admin_rooms') . '&show=edit', _("add"))
|
button(page_link_to('admin_rooms') . '&show=edit', _("add"))
|
||||||
]),
|
]),
|
||||||
msg(),
|
msg(),
|
||||||
table([
|
table([
|
||||||
'name' => _("Name"),
|
'name' => _("Name"),
|
||||||
'from_pentabarf' => _("Frab import"),
|
'from_pentabarf' => _("Frab import"),
|
||||||
'public' => _("Public"),
|
'public' => _("Public"),
|
||||||
'actions' => ""
|
'actions' => ""
|
||||||
], $rooms)
|
], $rooms)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ function admin_shifts_title()
|
||||||
function admin_shifts()
|
function admin_shifts()
|
||||||
{
|
{
|
||||||
$valid = true;
|
$valid = true;
|
||||||
|
|
||||||
$rid = 0;
|
$rid = 0;
|
||||||
$start = parse_date("Y-m-d H:i", date("Y-m-d") . " 00:00");
|
$start = parse_date("Y-m-d H:i", date("Y-m-d") . " 00:00");
|
||||||
$end = $start;
|
$end = $start;
|
||||||
|
@ -19,23 +19,23 @@ function admin_shifts()
|
||||||
$change_hours = [];
|
$change_hours = [];
|
||||||
$title = "";
|
$title = "";
|
||||||
$shifttype_id = null;
|
$shifttype_id = null;
|
||||||
|
|
||||||
// Locations laden (auch unsichtbare - fuer Erzengel ist das ok)
|
// Locations laden (auch unsichtbare - fuer Erzengel ist das ok)
|
||||||
$rooms = sql_select("SELECT * FROM `Room` ORDER BY `Name`");
|
$rooms = sql_select("SELECT * FROM `Room` ORDER BY `Name`");
|
||||||
$room_array = [];
|
$room_array = [];
|
||||||
foreach ($rooms as $room) {
|
foreach ($rooms as $room) {
|
||||||
$room_array[$room['RID']] = $room['Name'];
|
$room_array[$room['RID']] = $room['Name'];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Engeltypen laden
|
// Engeltypen laden
|
||||||
$types = sql_select("SELECT * FROM `AngelTypes` ORDER BY `name`");
|
$types = sql_select("SELECT * FROM `AngelTypes` ORDER BY `name`");
|
||||||
$needed_angel_types = [];
|
$needed_angel_types = [];
|
||||||
foreach ($types as $type) {
|
foreach ($types as $type) {
|
||||||
$needed_angel_types[$type['id']] = 0;
|
$needed_angel_types[$type['id']] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load shift types
|
// Load shift types
|
||||||
$shifttypes_source = ShiftTypes();
|
$shifttypes_source = ShiftTypes();
|
||||||
if ($shifttypes_source === false) {
|
if ($shifttypes_source === false) {
|
||||||
engelsystem_error('Unable to load shift types.');
|
engelsystem_error('Unable to load shift types.');
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ function admin_shifts()
|
||||||
foreach ($shifttypes_source as $shifttype) {
|
foreach ($shifttypes_source as $shifttype) {
|
||||||
$shifttypes[$shifttype['id']] = $shifttype['name'];
|
$shifttypes[$shifttype['id']] = $shifttype['name'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_REQUEST['preview']) || isset($_REQUEST['back'])) {
|
if (isset($_REQUEST['preview']) || isset($_REQUEST['back'])) {
|
||||||
if (isset($_REQUEST['shifttype_id'])) {
|
if (isset($_REQUEST['shifttype_id'])) {
|
||||||
$shifttype = ShiftType($_REQUEST['shifttype_id']);
|
$shifttype = ShiftType($_REQUEST['shifttype_id']);
|
||||||
|
@ -60,38 +60,42 @@ function admin_shifts()
|
||||||
$valid = false;
|
$valid = false;
|
||||||
error(_('Please select a shift type.'));
|
error(_('Please select a shift type.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Name/Bezeichnung der Schicht, darf leer sein
|
// Name/Bezeichnung der Schicht, darf leer sein
|
||||||
$title = strip_request_item('title');
|
$title = strip_request_item('title');
|
||||||
|
|
||||||
// Auswahl der sichtbaren Locations für die Schichten
|
// Auswahl der sichtbaren Locations für die Schichten
|
||||||
if (isset($_REQUEST['rid']) && preg_match("/^[0-9]+$/", $_REQUEST['rid']) && isset($room_array[$_REQUEST['rid']])) {
|
if (
|
||||||
$rid = $_REQUEST['rid'];
|
isset($_REQUEST['rid'])
|
||||||
} else {
|
&& preg_match("/^[0-9]+$/", $_REQUEST['rid'])
|
||||||
$valid = false;
|
&& isset($room_array[$_REQUEST['rid']])
|
||||||
$rid = $rooms[0]['RID'];
|
) {
|
||||||
error(_('Please select a location.'));
|
$rid = $_REQUEST['rid'];
|
||||||
}
|
} else {
|
||||||
|
$valid = false;
|
||||||
|
$rid = $rooms[0]['RID'];
|
||||||
|
error(_('Please select a location.'));
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($_REQUEST['start']) && $tmp = parse_date("Y-m-d H:i", $_REQUEST['start'])) {
|
if (isset($_REQUEST['start']) && $tmp = parse_date("Y-m-d H:i", $_REQUEST['start'])) {
|
||||||
$start = $tmp;
|
$start = $tmp;
|
||||||
} else {
|
} else {
|
||||||
$valid = false;
|
$valid = false;
|
||||||
error(_('Please select a start time.'));
|
error(_('Please select a start time.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_REQUEST['end']) && $tmp = parse_date("Y-m-d H:i", $_REQUEST['end'])) {
|
if (isset($_REQUEST['end']) && $tmp = parse_date("Y-m-d H:i", $_REQUEST['end'])) {
|
||||||
$end = $tmp;
|
$end = $tmp;
|
||||||
} else {
|
} else {
|
||||||
$valid = false;
|
$valid = false;
|
||||||
error(_('Please select an end time.'));
|
error(_('Please select an end time.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($start >= $end) {
|
if ($start >= $end) {
|
||||||
$valid = false;
|
$valid = false;
|
||||||
error(_('The shifts end has to be after its start.'));
|
error(_('The shifts end has to be after its start.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_REQUEST['mode'])) {
|
if (isset($_REQUEST['mode'])) {
|
||||||
if ($_REQUEST['mode'] == 'single') {
|
if ($_REQUEST['mode'] == 'single') {
|
||||||
$mode = 'single';
|
$mode = 'single';
|
||||||
|
@ -104,7 +108,10 @@ function admin_shifts()
|
||||||
error(_('Please enter a shift duration in minutes.'));
|
error(_('Please enter a shift duration in minutes.'));
|
||||||
}
|
}
|
||||||
} elseif ($_REQUEST['mode'] == 'variable') {
|
} elseif ($_REQUEST['mode'] == 'variable') {
|
||||||
if (isset($_REQUEST['change_hours']) && preg_match("/^([0-9]{2}(,|$))/", trim(str_replace(" ", "", $_REQUEST['change_hours'])))) {
|
if (
|
||||||
|
isset($_REQUEST['change_hours'])
|
||||||
|
&& preg_match("/^([0-9]{2}(,|$))/", trim(str_replace(" ", "", $_REQUEST['change_hours'])))
|
||||||
|
) {
|
||||||
$mode = 'variable';
|
$mode = 'variable';
|
||||||
$change_hours = array_map('trim', explode(",", $_REQUEST['change_hours']));
|
$change_hours = array_map('trim', explode(",", $_REQUEST['change_hours']));
|
||||||
} else {
|
} else {
|
||||||
|
@ -116,14 +123,17 @@ function admin_shifts()
|
||||||
$valid = false;
|
$valid = false;
|
||||||
error(_('Please select a mode.'));
|
error(_('Please select a mode.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_REQUEST['angelmode'])) {
|
if (isset($_REQUEST['angelmode'])) {
|
||||||
if ($_REQUEST['angelmode'] == 'location') {
|
if ($_REQUEST['angelmode'] == 'location') {
|
||||||
$angelmode = 'location';
|
$angelmode = 'location';
|
||||||
} elseif ($_REQUEST['angelmode'] == 'manually') {
|
} elseif ($_REQUEST['angelmode'] == 'manually') {
|
||||||
$angelmode = 'manually';
|
$angelmode = 'manually';
|
||||||
foreach ($types as $type) {
|
foreach ($types as $type) {
|
||||||
if (isset($_REQUEST['type_' . $type['id']]) && preg_match("/^[0-9]+$/", trim($_REQUEST['type_' . $type['id']]))) {
|
if (
|
||||||
|
isset($_REQUEST['type_' . $type['id']])
|
||||||
|
&& preg_match("/^[0-9]+$/", trim($_REQUEST['type_' . $type['id']]))
|
||||||
|
) {
|
||||||
$needed_angel_types[$type['id']] = trim($_REQUEST['type_' . $type['id']]);
|
$needed_angel_types[$type['id']] = trim($_REQUEST['type_' . $type['id']]);
|
||||||
} else {
|
} else {
|
||||||
$valid = false;
|
$valid = false;
|
||||||
|
@ -142,144 +152,152 @@ function admin_shifts()
|
||||||
$valid = false;
|
$valid = false;
|
||||||
error(_('Please select needed angels.'));
|
error(_('Please select needed angels.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Beim Zurück-Knopf das Formular zeigen
|
// Beim Zurück-Knopf das Formular zeigen
|
||||||
if (isset($_REQUEST['back'])) {
|
if (isset($_REQUEST['back'])) {
|
||||||
$valid = false;
|
$valid = false;
|
||||||
}
|
|
||||||
|
|
||||||
// Alle Eingaben in Ordnung
|
|
||||||
if ($valid) {
|
|
||||||
if ($angelmode == 'location') {
|
|
||||||
$needed_angel_types = [];
|
|
||||||
$needed_angel_types_location = sql_select("SELECT * FROM `NeededAngelTypes` WHERE `room_id`='" . sql_escape($rid) . "'");
|
|
||||||
foreach ($needed_angel_types_location as $type) {
|
|
||||||
$needed_angel_types[$type['angel_type_id']] = $type['count'];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
$shifts = [];
|
|
||||||
if ($mode == 'single') {
|
// Alle Eingaben in Ordnung
|
||||||
$shifts[] = [
|
if ($valid) {
|
||||||
'start' => $start,
|
if ($angelmode == 'location') {
|
||||||
'end' => $end,
|
$needed_angel_types = [];
|
||||||
'RID' => $rid,
|
$needed_angel_types_location = sql_select("SELECT * FROM `NeededAngelTypes` WHERE `room_id`='" . sql_escape($rid) . "'");
|
||||||
'title' => $title,
|
foreach ($needed_angel_types_location as $type) {
|
||||||
'shifttype_id' => $shifttype_id
|
$needed_angel_types[$type['angel_type_id']] = $type['count'];
|
||||||
];
|
|
||||||
} elseif ($mode == 'multi') {
|
|
||||||
$shift_start = $start;
|
|
||||||
do {
|
|
||||||
$shift_end = $shift_start + $length * 60;
|
|
||||||
|
|
||||||
if ($shift_end > $end) {
|
|
||||||
$shift_end = $end;
|
|
||||||
}
|
}
|
||||||
if ($shift_start >= $shift_end) {
|
}
|
||||||
break;
|
$shifts = [];
|
||||||
}
|
if ($mode == 'single') {
|
||||||
|
|
||||||
$shifts[] = [
|
$shifts[] = [
|
||||||
'start' => $shift_start,
|
'start' => $start,
|
||||||
'end' => $shift_end,
|
'end' => $end,
|
||||||
'RID' => $rid,
|
'RID' => $rid,
|
||||||
'title' => $title,
|
'title' => $title,
|
||||||
'shifttype_id' => $shifttype_id
|
'shifttype_id' => $shifttype_id
|
||||||
];
|
];
|
||||||
|
} elseif ($mode == 'multi') {
|
||||||
$shift_start = $shift_end;
|
$shift_start = $start;
|
||||||
} while ($shift_end < $end);
|
do {
|
||||||
} elseif ($mode == 'variable') {
|
$shift_end = $shift_start + $length * 60;
|
||||||
rsort($change_hours);
|
|
||||||
$day = parse_date("Y-m-d H:i", date("Y-m-d", $start) . " 00:00");
|
if ($shift_end > $end) {
|
||||||
$change_index = 0;
|
$shift_end = $end;
|
||||||
// Ersten/nächsten passenden Schichtwechsel suchen
|
}
|
||||||
foreach ($change_hours as $i => $change_hour) {
|
if ($shift_start >= $shift_end) {
|
||||||
if ($start < $day + $change_hour * 60 * 60) {
|
break;
|
||||||
$change_index = $i;
|
}
|
||||||
} elseif ($start == $day + $change_hour * 60 * 60) {
|
|
||||||
// Start trifft Schichtwechsel
|
$shifts[] = [
|
||||||
$change_index = ($i + count($change_hours) - 1) % count($change_hours);
|
'start' => $shift_start,
|
||||||
break;
|
'end' => $shift_end,
|
||||||
} else {
|
'RID' => $rid,
|
||||||
break;
|
'title' => $title,
|
||||||
|
'shifttype_id' => $shifttype_id
|
||||||
|
];
|
||||||
|
|
||||||
|
$shift_start = $shift_end;
|
||||||
|
} while ($shift_end < $end);
|
||||||
|
} elseif ($mode == 'variable') {
|
||||||
|
rsort($change_hours);
|
||||||
|
$day = parse_date("Y-m-d H:i", date("Y-m-d", $start) . " 00:00");
|
||||||
|
$change_index = 0;
|
||||||
|
// Ersten/nächsten passenden Schichtwechsel suchen
|
||||||
|
foreach ($change_hours as $i => $change_hour) {
|
||||||
|
if ($start < $day + $change_hour * 60 * 60) {
|
||||||
|
$change_index = $i;
|
||||||
|
} elseif ($start == $day + $change_hour * 60 * 60) {
|
||||||
|
// Start trifft Schichtwechsel
|
||||||
|
$change_index = ($i + count($change_hours) - 1) % count($change_hours);
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$shift_start = $start;
|
||||||
|
do {
|
||||||
|
$day = parse_date("Y-m-d H:i", date("Y-m-d", $shift_start) . " 00:00");
|
||||||
|
$shift_end = $day + $change_hours[$change_index] * 60 * 60;
|
||||||
|
|
||||||
|
if ($shift_end > $end) {
|
||||||
|
$shift_end = $end;
|
||||||
|
}
|
||||||
|
if ($shift_start >= $shift_end) {
|
||||||
|
$shift_end += 24 * 60 * 60;
|
||||||
|
}
|
||||||
|
|
||||||
|
$shifts[] = [
|
||||||
|
'start' => $shift_start,
|
||||||
|
'end' => $shift_end,
|
||||||
|
'RID' => $rid,
|
||||||
|
'title' => $title,
|
||||||
|
'shifttype_id' => $shifttype_id
|
||||||
|
];
|
||||||
|
|
||||||
|
$shift_start = $shift_end;
|
||||||
|
$change_index = ($change_index + count($change_hours) - 1) % count($change_hours);
|
||||||
|
} while ($shift_end < $end);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
$shifts_table = [];
|
||||||
$shift_start = $start;
|
foreach ($shifts as $shift) {
|
||||||
do {
|
$shifts_table_entry = [
|
||||||
$day = parse_date("Y-m-d H:i", date("Y-m-d", $shift_start) . " 00:00");
|
'timeslot' =>
|
||||||
$shift_end = $day + $change_hours[$change_index] * 60 * 60;
|
'<span class="glyphicon glyphicon-time"></span> '
|
||||||
|
. date("Y-m-d H:i", $shift['start'])
|
||||||
if ($shift_end > $end) {
|
. ' - '
|
||||||
$shift_end = $end;
|
. date("H:i", $shift['end'])
|
||||||
}
|
. '<br />'
|
||||||
if ($shift_start >= $shift_end) {
|
. Room_name_render(Room($shift['RID'])),
|
||||||
$shift_end += 24 * 60 * 60;
|
'title' =>
|
||||||
}
|
ShiftType_name_render(ShiftType($shifttype_id))
|
||||||
|
. ($shift['title'] ? '<br />' . $shift['title'] : ''),
|
||||||
$shifts[] = [
|
'needed_angels' => ''
|
||||||
'start' => $shift_start,
|
];
|
||||||
'end' => $shift_end,
|
foreach ($types as $type) {
|
||||||
'RID' => $rid,
|
if (isset($needed_angel_types[$type['id']]) && $needed_angel_types[$type['id']] > 0) {
|
||||||
'title' => $title,
|
$shifts_table_entry['needed_angels'] .= '<b>' . AngelType_name_render($type) . ':</b> ' . $needed_angel_types[$type['id']] . '<br />';
|
||||||
'shifttype_id' => $shifttype_id
|
}
|
||||||
];
|
|
||||||
|
|
||||||
$shift_start = $shift_end;
|
|
||||||
$change_index = ($change_index + count($change_hours) - 1) % count($change_hours);
|
|
||||||
} while ($shift_end < $end);
|
|
||||||
}
|
|
||||||
|
|
||||||
$shifts_table = [];
|
|
||||||
foreach ($shifts as $shift) {
|
|
||||||
$shifts_table_entry = [
|
|
||||||
'timeslot' => '<span class="glyphicon glyphicon-time"></span> ' . date("Y-m-d H:i", $shift['start']) . ' - ' . date("H:i", $shift['end']) . '<br />' . Room_name_render(Room($shift['RID'])),
|
|
||||||
'title' => ShiftType_name_render(ShiftType($shifttype_id)) . ($shift['title'] ? '<br />' . $shift['title'] : ''),
|
|
||||||
'needed_angels' => ''
|
|
||||||
];
|
|
||||||
foreach ($types as $type) {
|
|
||||||
if (isset($needed_angel_types[$type['id']]) && $needed_angel_types[$type['id']] > 0) {
|
|
||||||
$shifts_table_entry['needed_angels'] .= '<b>' . AngelType_name_render($type) . ':</b> ' . $needed_angel_types[$type['id']] . '<br />';
|
|
||||||
}
|
}
|
||||||
|
$shifts_table[] = $shifts_table_entry;
|
||||||
}
|
}
|
||||||
$shifts_table[] = $shifts_table_entry;
|
|
||||||
|
// Fürs Anlegen zwischenspeichern:
|
||||||
|
$_SESSION['admin_shifts_shifts'] = $shifts;
|
||||||
|
$_SESSION['admin_shifts_types'] = $needed_angel_types;
|
||||||
|
|
||||||
|
$hidden_types = "";
|
||||||
|
foreach ($needed_angel_types as $type_id => $count) {
|
||||||
|
$hidden_types .= form_hidden('type_' . $type_id, $count);
|
||||||
|
}
|
||||||
|
return page_with_title(_("Preview"), [
|
||||||
|
form([
|
||||||
|
$hidden_types,
|
||||||
|
form_hidden('shifttype_id', $shifttype_id),
|
||||||
|
form_hidden('title', $title),
|
||||||
|
form_hidden('rid', $rid),
|
||||||
|
form_hidden('start', date("Y-m-d H:i", $start)),
|
||||||
|
form_hidden('end', date("Y-m-d H:i", $end)),
|
||||||
|
form_hidden('mode', $mode),
|
||||||
|
form_hidden('length', $length),
|
||||||
|
form_hidden('change_hours', implode(', ', $change_hours)),
|
||||||
|
form_hidden('angelmode', $angelmode),
|
||||||
|
form_submit('back', _("back")),
|
||||||
|
table([
|
||||||
|
'timeslot' => _('Time and location'),
|
||||||
|
'title' => _('Type and title'),
|
||||||
|
'needed_angels' => _('Needed angels')
|
||||||
|
], $shifts_table),
|
||||||
|
form_submit('submit', _("Save"))
|
||||||
|
])
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fürs Anlegen zwischenspeichern:
|
|
||||||
$_SESSION['admin_shifts_shifts'] = $shifts;
|
|
||||||
$_SESSION['admin_shifts_types'] = $needed_angel_types;
|
|
||||||
|
|
||||||
$hidden_types = "";
|
|
||||||
foreach ($needed_angel_types as $type_id => $count) {
|
|
||||||
$hidden_types .= form_hidden('type_' . $type_id, $count);
|
|
||||||
}
|
|
||||||
return page_with_title(_("Preview"), [
|
|
||||||
form([
|
|
||||||
$hidden_types,
|
|
||||||
form_hidden('shifttype_id', $shifttype_id),
|
|
||||||
form_hidden('title', $title),
|
|
||||||
form_hidden('rid', $rid),
|
|
||||||
form_hidden('start', date("Y-m-d H:i", $start)),
|
|
||||||
form_hidden('end', date("Y-m-d H:i", $end)),
|
|
||||||
form_hidden('mode', $mode),
|
|
||||||
form_hidden('length', $length),
|
|
||||||
form_hidden('change_hours', implode(', ', $change_hours)),
|
|
||||||
form_hidden('angelmode', $angelmode),
|
|
||||||
form_submit('back', _("back")),
|
|
||||||
table([
|
|
||||||
'timeslot' => _('Time and location'),
|
|
||||||
'title' => _('Type and title'),
|
|
||||||
'needed_angels' => _('Needed angels')
|
|
||||||
], $shifts_table),
|
|
||||||
form_submit('submit', _("Save"))
|
|
||||||
])
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
} elseif (isset($_REQUEST['submit'])) {
|
} elseif (isset($_REQUEST['submit'])) {
|
||||||
if (! is_array($_SESSION['admin_shifts_shifts']) || ! is_array($_SESSION['admin_shifts_types'])) {
|
if (!is_array($_SESSION['admin_shifts_shifts']) || !is_array($_SESSION['admin_shifts_types'])) {
|
||||||
redirect(page_link_to('admin_shifts'));
|
redirect(page_link_to('admin_shifts'));
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($_SESSION['admin_shifts_shifts'] as $shift) {
|
foreach ($_SESSION['admin_shifts_shifts'] as $shift) {
|
||||||
$shift['URL'] = null;
|
$shift['URL'] = null;
|
||||||
$shift['PSID'] = null;
|
$shift['PSID'] = null;
|
||||||
|
@ -287,8 +305,13 @@ function admin_shifts()
|
||||||
if ($shift_id === false) {
|
if ($shift_id === false) {
|
||||||
engelsystem_error('Unable to create shift.');
|
engelsystem_error('Unable to create shift.');
|
||||||
}
|
}
|
||||||
|
|
||||||
engelsystem_log("Shift created: " . $shifttypes[$shift['shifttype_id']] . " with title " . $shift['title'] . " from " . date("Y-m-d H:i", $shift['start']) . " to " . date("Y-m-d H:i", $shift['end']));
|
engelsystem_log(
|
||||||
|
"Shift created: " . $shifttypes[$shift['shifttype_id']]
|
||||||
|
. " with title " . $shift['title']
|
||||||
|
. " from " . date("Y-m-d H:i", $shift['start'])
|
||||||
|
. " to " . date("Y-m-d H:i", $shift['end'])
|
||||||
|
);
|
||||||
$needed_angel_types_info = [];
|
$needed_angel_types_info = [];
|
||||||
foreach ($_SESSION['admin_shifts_types'] as $type_id => $count) {
|
foreach ($_SESSION['admin_shifts_types'] as $type_id => $count) {
|
||||||
$angel_type_source = sql_select("SELECT * FROM `AngelTypes` WHERE `id`='" . sql_escape($type_id) . "' LIMIT 1");
|
$angel_type_source = sql_select("SELECT * FROM `AngelTypes` WHERE `id`='" . sql_escape($type_id) . "' LIMIT 1");
|
||||||
|
@ -298,7 +321,7 @@ function admin_shifts()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
engelsystem_log("Shift needs following angel types: " . join(", ", $needed_angel_types_info));
|
engelsystem_log("Shift needs following angel types: " . join(", ", $needed_angel_types_info));
|
||||||
success("Schichten angelegt.");
|
success("Schichten angelegt.");
|
||||||
redirect(page_link_to('admin_shifts'));
|
redirect(page_link_to('admin_shifts'));
|
||||||
|
@ -306,42 +329,61 @@ function admin_shifts()
|
||||||
unset($_SESSION['admin_shifts_shifts']);
|
unset($_SESSION['admin_shifts_shifts']);
|
||||||
unset($_SESSION['admin_shifts_types']);
|
unset($_SESSION['admin_shifts_types']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! isset($_REQUEST['rid'])) {
|
if (!isset($_REQUEST['rid'])) {
|
||||||
$_REQUEST['rid'] = null;
|
$_REQUEST['rid'] = null;
|
||||||
}
|
}
|
||||||
$angel_types = "";
|
$angel_types = "";
|
||||||
foreach ($types as $type) {
|
foreach ($types as $type) {
|
||||||
$angel_types .= '<div class="col-md-4">' . form_spinner('type_' . $type['id'], $type['name'], $needed_angel_types[$type['id']]) . '</div>';
|
$angel_types .= '<div class="col-md-4">' . form_spinner(
|
||||||
|
'type_' . $type['id'],
|
||||||
|
$type['name'],
|
||||||
|
$needed_angel_types[$type['id']]
|
||||||
|
)
|
||||||
|
. '</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
return page_with_title(admin_shifts_title(), [
|
return page_with_title(admin_shifts_title(), [
|
||||||
msg(),
|
msg(),
|
||||||
form([
|
form([
|
||||||
form_select('shifttype_id', _('Shifttype'), $shifttypes, $shifttype_id),
|
form_select('shifttype_id', _('Shifttype'), $shifttypes, $shifttype_id),
|
||||||
form_text('title', _("Title"), $title),
|
form_text('title', _("Title"), $title),
|
||||||
form_select('rid', _("Room"), $room_array, $_REQUEST['rid']),
|
form_select('rid', _("Room"), $room_array, $_REQUEST['rid']),
|
||||||
div('row', [
|
div('row', [
|
||||||
div('col-md-6', [
|
div('col-md-6', [
|
||||||
form_text('start', _("Start"), date("Y-m-d H:i", $start)),
|
form_text('start', _("Start"), date("Y-m-d H:i", $start)),
|
||||||
form_text('end', _("End"), date("Y-m-d H:i", $end)),
|
form_text('end', _("End"), date("Y-m-d H:i", $end)),
|
||||||
form_info(_("Mode"), ''),
|
form_info(_("Mode"), ''),
|
||||||
form_radio('mode', _("Create one shift"), $mode == 'single', 'single'),
|
form_radio('mode', _("Create one shift"), $mode == 'single', 'single'),
|
||||||
form_radio('mode', _("Create multiple shifts"), $mode == 'multi', 'multi'),
|
form_radio('mode', _("Create multiple shifts"), $mode == 'multi', 'multi'),
|
||||||
form_text('length', _("Length"), ! empty($_REQUEST['length']) ? $_REQUEST['length'] : '120'),
|
form_text('length', _("Length"), !empty($_REQUEST['length']) ? $_REQUEST['length'] : '120'),
|
||||||
form_radio('mode', _("Create multiple shifts with variable length"), $mode == 'variable', 'variable'),
|
form_radio(
|
||||||
form_text('change_hours', _("Shift change hours"), ! empty($_REQUEST['change_hours']) ? $_REQUEST['change_hours'] : '00, 04, 08, 10, 12, 14, 16, 18, 20, 22')
|
'mode',
|
||||||
]),
|
_("Create multiple shifts with variable length"),
|
||||||
div('col-md-6', [
|
$mode == 'variable',
|
||||||
form_info(_("Needed angels"), ''),
|
'variable'
|
||||||
form_radio('angelmode', _("Take needed angels from room settings"), $angelmode == 'location', 'location'),
|
),
|
||||||
form_radio('angelmode', _("The following angels are needed"), $angelmode == 'manually', 'manually'),
|
form_text(
|
||||||
div('row', [
|
'change_hours',
|
||||||
$angel_types
|
_("Shift change hours"),
|
||||||
])
|
!empty($_REQUEST['change_hours']) ? $_REQUEST['change_hours'] : '00, 04, 08, 10, 12, 14, 16, 18, 20, 22'
|
||||||
])
|
)
|
||||||
]),
|
]),
|
||||||
form_submit('preview', _("Preview"))
|
div('col-md-6', [
|
||||||
])
|
form_info(_("Needed angels"), ''),
|
||||||
]);
|
form_radio(
|
||||||
|
'angelmode',
|
||||||
|
_("Take needed angels from room settings"),
|
||||||
|
$angelmode == 'location',
|
||||||
|
'location'
|
||||||
|
),
|
||||||
|
form_radio('angelmode', _("The following angels are needed"), $angelmode == 'manually', 'manually'),
|
||||||
|
div('row', [
|
||||||
|
$angel_types
|
||||||
|
])
|
||||||
|
])
|
||||||
|
]),
|
||||||
|
form_submit('preview', _("Preview"))
|
||||||
|
])
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,23 +8,23 @@ function admin_user_title()
|
||||||
function admin_user()
|
function admin_user()
|
||||||
{
|
{
|
||||||
global $user, $privileges, $tshirt_sizes, $privileges;
|
global $user, $privileges, $tshirt_sizes, $privileges;
|
||||||
|
|
||||||
$html = '';
|
$html = '';
|
||||||
|
|
||||||
if (! isset($_REQUEST['id'])) {
|
if (!isset($_REQUEST['id'])) {
|
||||||
redirect(users_link());
|
redirect(users_link());
|
||||||
}
|
}
|
||||||
|
|
||||||
$user_id = $_REQUEST['id'];
|
$user_id = $_REQUEST['id'];
|
||||||
if (! isset($_REQUEST['action'])) {
|
if (!isset($_REQUEST['action'])) {
|
||||||
$user_source = User($user_id);
|
$user_source = User($user_id);
|
||||||
if ($user_source == null) {
|
if ($user_source == null) {
|
||||||
error(_('This user does not exist.'));
|
error(_('This user does not exist.'));
|
||||||
redirect(users_link());
|
redirect(users_link());
|
||||||
}
|
}
|
||||||
|
|
||||||
$html .= "Hallo,<br />" . "hier kannst du den Eintrag ändern. Unter dem Punkt 'Gekommen' " . "wird der Engel als anwesend markiert, ein Ja bei Aktiv bedeutet, " . "dass der Engel aktiv war und damit ein Anspruch auf ein T-Shirt hat. " . "Wenn T-Shirt ein 'Ja' enthält, bedeutet dies, dass der Engel " . "bereits sein T-Shirt erhalten hat.<br /><br />\n";
|
$html .= "Hallo,<br />" . "hier kannst du den Eintrag ändern. Unter dem Punkt 'Gekommen' " . "wird der Engel als anwesend markiert, ein Ja bei Aktiv bedeutet, " . "dass der Engel aktiv war und damit ein Anspruch auf ein T-Shirt hat. " . "Wenn T-Shirt ein 'Ja' enthält, bedeutet dies, dass der Engel " . "bereits sein T-Shirt erhalten hat.<br /><br />\n";
|
||||||
|
|
||||||
$html .= "<form action=\"" . page_link_to("admin_user") . "&action=save&id=$user_id\" method=\"post\">\n";
|
$html .= "<form action=\"" . page_link_to("admin_user") . "&action=save&id=$user_id\" method=\"post\">\n";
|
||||||
$html .= "<table border=\"0\">\n";
|
$html .= "<table border=\"0\">\n";
|
||||||
$html .= "<input type=\"hidden\" name=\"Type\" value=\"Normal\">\n";
|
$html .= "<input type=\"hidden\" name=\"Type\" value=\"Normal\">\n";
|
||||||
|
@ -42,132 +42,135 @@ function admin_user()
|
||||||
$html .= " <tr><td>email</td><td>" . "<input type=\"text\" size=\"40\" name=\"eemail\" value=\"" . $user_source['email'] . "\"></td></tr>\n";
|
$html .= " <tr><td>email</td><td>" . "<input type=\"text\" size=\"40\" name=\"eemail\" value=\"" . $user_source['email'] . "\"></td></tr>\n";
|
||||||
}
|
}
|
||||||
$html .= " <tr><td>jabber</td><td>" . "<input type=\"text\" size=\"40\" name=\"ejabber\" value=\"" . $user_source['jabber'] . "\"></td></tr>\n";
|
$html .= " <tr><td>jabber</td><td>" . "<input type=\"text\" size=\"40\" name=\"ejabber\" value=\"" . $user_source['jabber'] . "\"></td></tr>\n";
|
||||||
$html .= " <tr><td>Size</td><td>" . html_select_key('size', 'eSize', $tshirt_sizes, $user_source['Size']) . "</td></tr>\n";
|
$html .= " <tr><td>Size</td><td>"
|
||||||
|
. html_select_key('size', 'eSize', $tshirt_sizes, $user_source['Size'])
|
||||||
|
. "</td></tr>\n";
|
||||||
|
|
||||||
$options = [
|
$options = [
|
||||||
'1' => _("Yes"),
|
'1' => _("Yes"),
|
||||||
'0' => _("No")
|
'0' => _("No")
|
||||||
];
|
];
|
||||||
|
|
||||||
// Gekommen?
|
// Gekommen?
|
||||||
$html .= " <tr><td>Gekommen</td><td>\n";
|
$html .= " <tr><td>Gekommen</td><td>\n";
|
||||||
$html .= html_options('eGekommen', $options, $user_source['Gekommen']) . "</td></tr>\n";
|
$html .= html_options('eGekommen', $options, $user_source['Gekommen']) . "</td></tr>\n";
|
||||||
|
|
||||||
// Aktiv?
|
// Aktiv?
|
||||||
$html .= " <tr><td>Aktiv</td><td>\n";
|
$html .= " <tr><td>Aktiv</td><td>\n";
|
||||||
$html .= html_options('eAktiv', $options, $user_source['Aktiv']) . "</td></tr>\n";
|
$html .= html_options('eAktiv', $options, $user_source['Aktiv']) . "</td></tr>\n";
|
||||||
|
|
||||||
// Aktiv erzwingen
|
// Aktiv erzwingen
|
||||||
if (in_array('admin_active', $privileges)) {
|
if (in_array('admin_active', $privileges)) {
|
||||||
$html .= " <tr><td>" . _("Force active") . "</td><td>\n";
|
$html .= " <tr><td>" . _("Force active") . "</td><td>\n";
|
||||||
$html .= html_options('force_active', $options, $user_source['force_active']) . "</td></tr>\n";
|
$html .= html_options('force_active', $options, $user_source['force_active']) . "</td></tr>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
// T-Shirt bekommen?
|
// T-Shirt bekommen?
|
||||||
$html .= " <tr><td>T-Shirt</td><td>\n";
|
$html .= " <tr><td>T-Shirt</td><td>\n";
|
||||||
$html .= html_options('eTshirt', $options, $user_source['Tshirt']) . "</td></tr>\n";
|
$html .= html_options('eTshirt', $options, $user_source['Tshirt']) . "</td></tr>\n";
|
||||||
|
|
||||||
$html .= " <tr><td>Hometown</td><td>" . "<input type=\"text\" size=\"40\" name=\"Hometown\" value=\"" . $user_source['Hometown'] . "\"></td></tr>\n";
|
$html .= " <tr><td>Hometown</td><td>" . "<input type=\"text\" size=\"40\" name=\"Hometown\" value=\"" . $user_source['Hometown'] . "\"></td></tr>\n";
|
||||||
|
|
||||||
$html .= "</table>\n</td><td valign=\"top\"></td></tr>";
|
$html .= "</table>\n</td><td valign=\"top\"></td></tr>";
|
||||||
|
|
||||||
$html .= "</td></tr>\n";
|
$html .= "</td></tr>\n";
|
||||||
$html .= "</table>\n<br />\n";
|
$html .= "</table>\n<br />\n";
|
||||||
$html .= "<input type=\"submit\" value=\"Speichern\">\n";
|
$html .= "<input type=\"submit\" value=\"Speichern\">\n";
|
||||||
$html .= "</form>";
|
$html .= "</form>";
|
||||||
|
|
||||||
$html .= "<hr />";
|
$html .= "<hr />";
|
||||||
|
|
||||||
$html .= form_info('', _('Please visit the angeltypes page or the users profile to manage users angeltypes.'));
|
$html .= form_info('', _('Please visit the angeltypes page or the users profile to manage users angeltypes.'));
|
||||||
|
|
||||||
$html .= "Hier kannst Du das Passwort dieses Engels neu setzen:<form action=\"" . page_link_to("admin_user") . "&action=change_pw&id=$user_id\" method=\"post\">\n";
|
$html .= "Hier kannst Du das Passwort dieses Engels neu setzen:<form action=\"" . page_link_to("admin_user") . "&action=change_pw&id=$user_id\" method=\"post\">\n";
|
||||||
$html .= "<table>\n";
|
$html .= "<table>\n";
|
||||||
$html .= " <tr><td>Passwort</td><td>" . "<input type=\"password\" size=\"40\" name=\"new_pw\" value=\"\"></td></tr>\n";
|
$html .= " <tr><td>Passwort</td><td>" . "<input type=\"password\" size=\"40\" name=\"new_pw\" value=\"\"></td></tr>\n";
|
||||||
$html .= " <tr><td>Wiederholung</td><td>" . "<input type=\"password\" size=\"40\" name=\"new_pw2\" value=\"\"></td></tr>\n";
|
$html .= " <tr><td>Wiederholung</td><td>" . "<input type=\"password\" size=\"40\" name=\"new_pw2\" value=\"\"></td></tr>\n";
|
||||||
|
|
||||||
$html .= "</table>";
|
$html .= "</table>";
|
||||||
$html .= "<input type=\"submit\" value=\"Speichern\">\n";
|
$html .= "<input type=\"submit\" value=\"Speichern\">\n";
|
||||||
$html .= "</form>";
|
$html .= "</form>";
|
||||||
|
|
||||||
$html .= "<hr />";
|
$html .= "<hr />";
|
||||||
|
|
||||||
$my_highest_group = sql_select("SELECT * FROM `UserGroups` WHERE `uid`='" . sql_escape($user['UID']) . "' ORDER BY `group_id` LIMIT 1");
|
$my_highest_group = sql_select("SELECT * FROM `UserGroups` WHERE `uid`='" . sql_escape($user['UID']) . "' ORDER BY `group_id` LIMIT 1");
|
||||||
if (count($my_highest_group) > 0) {
|
if (count($my_highest_group) > 0) {
|
||||||
$my_highest_group = $my_highest_group[0]['group_id'];
|
$my_highest_group = $my_highest_group[0]['group_id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$his_highest_group = sql_select("SELECT * FROM `UserGroups` WHERE `uid`='" . sql_escape($user_id) . "' ORDER BY `group_id` LIMIT 1");
|
$his_highest_group = sql_select("SELECT * FROM `UserGroups` WHERE `uid`='" . sql_escape($user_id) . "' ORDER BY `group_id` LIMIT 1");
|
||||||
if (count($his_highest_group) > 0) {
|
if (count($his_highest_group) > 0) {
|
||||||
$his_highest_group = $his_highest_group[0]['group_id'];
|
$his_highest_group = $his_highest_group[0]['group_id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($user_id != $user['UID'] && $my_highest_group <= $his_highest_group) {
|
if ($user_id != $user['UID'] && $my_highest_group <= $his_highest_group) {
|
||||||
$html .= "Hier kannst Du die Benutzergruppen des Engels festlegen:<form action=\"" . page_link_to("admin_user") . "&action=save_groups&id=" . $user_id . "\" method=\"post\">\n";
|
$html .= "Hier kannst Du die Benutzergruppen des Engels festlegen:<form action=\"" . page_link_to("admin_user") . "&action=save_groups&id=" . $user_id . "\" method=\"post\">\n";
|
||||||
$html .= '<table>';
|
$html .= '<table>';
|
||||||
|
|
||||||
$groups = sql_select("SELECT * FROM `Groups` LEFT OUTER JOIN `UserGroups` ON (`UserGroups`.`group_id` = `Groups`.`UID` AND `UserGroups`.`uid` = '" . sql_escape($user_id) . "') WHERE `Groups`.`UID` >= '" . sql_escape($my_highest_group) . "' ORDER BY `Groups`.`Name`");
|
$groups = sql_select("SELECT * FROM `Groups` LEFT OUTER JOIN `UserGroups` ON (`UserGroups`.`group_id` = `Groups`.`UID` AND `UserGroups`.`uid` = '" . sql_escape($user_id) . "') WHERE `Groups`.`UID` >= '" . sql_escape($my_highest_group) . "' ORDER BY `Groups`.`Name`");
|
||||||
foreach ($groups as $group) {
|
foreach ($groups as $group) {
|
||||||
$html .= '<tr><td><input type="checkbox" name="groups[]" value="' . $group['UID'] . '"' . ($group['group_id'] != "" ? ' checked="checked"' : '') . ' /></td><td>' . $group['Name'] . '</td></tr>';
|
$html .= '<tr><td><input type="checkbox" name="groups[]" value="' . $group['UID'] . '"' . ($group['group_id'] != "" ? ' checked="checked"' : '') . ' /></td><td>' . $group['Name'] . '</td></tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
$html .= '</table>';
|
$html .= '</table>';
|
||||||
|
|
||||||
$html .= "<input type=\"submit\" value=\"Speichern\">\n";
|
$html .= "<input type=\"submit\" value=\"Speichern\">\n";
|
||||||
$html .= "</form>";
|
$html .= "</form>";
|
||||||
|
|
||||||
$html .= "<hr />";
|
$html .= "<hr />";
|
||||||
}
|
}
|
||||||
|
|
||||||
$html .= buttons([
|
$html .= buttons([
|
||||||
button(user_delete_link($user_source), glyph('lock') . _("delete"), 'btn-danger')
|
button(user_delete_link($user_source), glyph('lock') . _("delete"), 'btn-danger')
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$html .= "<hr />";
|
$html .= "<hr />";
|
||||||
} else {
|
} else {
|
||||||
switch ($_REQUEST['action']) {
|
switch ($_REQUEST['action']) {
|
||||||
case 'save_groups':
|
case 'save_groups':
|
||||||
if ($user_id != $user['UID']) {
|
if ($user_id != $user['UID']) {
|
||||||
$my_highest_group = sql_select("SELECT * FROM `UserGroups` WHERE `uid`='" . sql_escape($user['UID']) . "' ORDER BY `group_id`");
|
$my_highest_group = sql_select("SELECT * FROM `UserGroups` WHERE `uid`='" . sql_escape($user['UID']) . "' ORDER BY `group_id`");
|
||||||
$his_highest_group = sql_select("SELECT * FROM `UserGroups` WHERE `uid`='" . sql_escape($user_id) . "' ORDER BY `group_id`");
|
$his_highest_group = sql_select("SELECT * FROM `UserGroups` WHERE `uid`='" . sql_escape($user_id) . "' ORDER BY `group_id`");
|
||||||
|
|
||||||
if (count($my_highest_group) > 0 && (count($his_highest_group) == 0 || ($my_highest_group[0]['group_id'] <= $his_highest_group[0]['group_id']))) {
|
if (count($my_highest_group) > 0 && (count($his_highest_group) == 0 || ($my_highest_group[0]['group_id'] <= $his_highest_group[0]['group_id']))) {
|
||||||
$groups_source = sql_select("SELECT * FROM `Groups` LEFT OUTER JOIN `UserGroups` ON (`UserGroups`.`group_id` = `Groups`.`UID` AND `UserGroups`.`uid` = '" . sql_escape($user_id) . "') WHERE `Groups`.`UID` >= '" . sql_escape($my_highest_group[0]['group_id']) . "' ORDER BY `Groups`.`Name`");
|
$groups_source = sql_select("SELECT * FROM `Groups` LEFT OUTER JOIN `UserGroups` ON (`UserGroups`.`group_id` = `Groups`.`UID` AND `UserGroups`.`uid` = '" . sql_escape($user_id) . "') WHERE `Groups`.`UID` >= '" . sql_escape($my_highest_group[0]['group_id']) . "' ORDER BY `Groups`.`Name`");
|
||||||
$groups = [];
|
$groups = [];
|
||||||
$grouplist = [];
|
$grouplist = [];
|
||||||
foreach ($groups_source as $group) {
|
foreach ($groups_source as $group) {
|
||||||
$groups[$group['UID']] = $group;
|
$groups[$group['UID']] = $group;
|
||||||
$grouplist[] = $group['UID'];
|
$grouplist[] = $group['UID'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! is_array($_REQUEST['groups'])) {
|
if (!is_array($_REQUEST['groups'])) {
|
||||||
$_REQUEST['groups'] = [];
|
$_REQUEST['groups'] = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
sql_query("DELETE FROM `UserGroups` WHERE `uid`='" . sql_escape($user_id) . "'");
|
sql_query("DELETE FROM `UserGroups` WHERE `uid`='" . sql_escape($user_id) . "'");
|
||||||
$user_groups_info = [];
|
$user_groups_info = [];
|
||||||
foreach ($_REQUEST['groups'] as $group) {
|
foreach ($_REQUEST['groups'] as $group) {
|
||||||
if (in_array($group, $grouplist)) {
|
if (in_array($group, $grouplist)) {
|
||||||
sql_query("INSERT INTO `UserGroups` SET `uid`='" . sql_escape($user_id) . "', `group_id`='" . sql_escape($group) . "'");
|
sql_query("INSERT INTO `UserGroups` SET `uid`='" . sql_escape($user_id) . "', `group_id`='" . sql_escape($group) . "'");
|
||||||
$user_groups_info[] = $groups[$group]['Name'];
|
$user_groups_info[] = $groups[$group]['Name'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$user_source = User($user_id);
|
||||||
|
engelsystem_log("Set groups of " . User_Nick_render($user_source) . " to: " . join(", ",
|
||||||
|
$user_groups_info));
|
||||||
|
$html .= success("Benutzergruppen gespeichert.", true);
|
||||||
|
} else {
|
||||||
|
$html .= error("Du kannst keine Engel mit mehr Rechten bearbeiten.", true);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
$html .= error("Du kannst Deine eigenen Rechte nicht bearbeiten.", true);
|
||||||
}
|
}
|
||||||
$user_source = User($user_id);
|
break;
|
||||||
engelsystem_log("Set groups of " . User_Nick_render($user_source) . " to: " . join(", ", $user_groups_info));
|
|
||||||
$html .= success("Benutzergruppen gespeichert.", true);
|
case 'save':
|
||||||
} else {
|
$force_active = $user['force_active'];
|
||||||
$html .= error("Du kannst keine Engel mit mehr Rechten bearbeiten.", true);
|
if (in_array('admin_active', $privileges)) {
|
||||||
}
|
$force_active = $_REQUEST['force_active'];
|
||||||
} else {
|
}
|
||||||
$html .= error("Du kannst Deine eigenen Rechte nicht bearbeiten.", true);
|
$SQL = "UPDATE `User` SET
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'save':
|
|
||||||
$force_active = $user['force_active'];
|
|
||||||
if (in_array('admin_active', $privileges)) {
|
|
||||||
$force_active = $_REQUEST['force_active'];
|
|
||||||
}
|
|
||||||
$SQL = "UPDATE `User` SET
|
|
||||||
`Nick` = '" . sql_escape($_POST["eNick"]) . "',
|
`Nick` = '" . sql_escape($_POST["eNick"]) . "',
|
||||||
`Name` = '" . sql_escape($_POST["eName"]) . "',
|
`Name` = '" . sql_escape($_POST["eName"]) . "',
|
||||||
`Vorname` = '" . sql_escape($_POST["eVorname"]) . "',
|
`Vorname` = '" . sql_escape($_POST["eVorname"]) . "',
|
||||||
|
@ -185,25 +188,25 @@ function admin_user()
|
||||||
`Hometown` = '" . sql_escape($_POST["Hometown"]) . "'
|
`Hometown` = '" . sql_escape($_POST["Hometown"]) . "'
|
||||||
WHERE `UID` = '" . sql_escape($user_id) . "'
|
WHERE `UID` = '" . sql_escape($user_id) . "'
|
||||||
LIMIT 1";
|
LIMIT 1";
|
||||||
sql_query($SQL);
|
sql_query($SQL);
|
||||||
engelsystem_log("Updated user: " . $_POST["eNick"] . ", " . $_POST["eSize"] . ", arrived: " . $_POST["eGekommen"] . ", active: " . $_POST["eAktiv"] . ", tshirt: " . $_POST["eTshirt"]);
|
engelsystem_log("Updated user: " . $_POST["eNick"] . ", " . $_POST["eSize"] . ", arrived: " . $_POST["eGekommen"] . ", active: " . $_POST["eAktiv"] . ", tshirt: " . $_POST["eTshirt"]);
|
||||||
$html .= success("Änderung wurde gespeichert...\n", true);
|
$html .= success("Änderung wurde gespeichert...\n", true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'change_pw':
|
case 'change_pw':
|
||||||
if ($_REQUEST['new_pw'] != "" && $_REQUEST['new_pw'] == $_REQUEST['new_pw2']) {
|
if ($_REQUEST['new_pw'] != "" && $_REQUEST['new_pw'] == $_REQUEST['new_pw2']) {
|
||||||
set_password($user_id, $_REQUEST['new_pw']);
|
set_password($user_id, $_REQUEST['new_pw']);
|
||||||
$user_source = User($user_id);
|
$user_source = User($user_id);
|
||||||
engelsystem_log("Set new password for " . User_Nick_render($user_source));
|
engelsystem_log("Set new password for " . User_Nick_render($user_source));
|
||||||
$html .= success("Passwort neu gesetzt.", true);
|
$html .= success("Passwort neu gesetzt.", true);
|
||||||
} else {
|
} else {
|
||||||
$html .= error("Die Eingaben müssen übereinstimmen und dürfen nicht leer sein!", true);
|
$html .= error("Die Eingaben müssen übereinstimmen und dürfen nicht leer sein!", true);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return page_with_title(_("Edit user"), [
|
return page_with_title(_("Edit user"), [
|
||||||
$html
|
$html
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,9 +19,9 @@ function logout_title()
|
||||||
function guest_register()
|
function guest_register()
|
||||||
{
|
{
|
||||||
global $tshirt_sizes, $enable_tshirt_size, $default_theme, $user, $min_password_length;
|
global $tshirt_sizes, $enable_tshirt_size, $default_theme, $user, $min_password_length;
|
||||||
|
|
||||||
$event_config = EventConfig();
|
$event_config = EventConfig();
|
||||||
|
|
||||||
$msg = "";
|
$msg = "";
|
||||||
$nick = "";
|
$nick = "";
|
||||||
$lastname = "";
|
$lastname = "";
|
||||||
|
@ -40,19 +40,19 @@ function guest_register()
|
||||||
$password_hash = "";
|
$password_hash = "";
|
||||||
$selected_angel_types = [];
|
$selected_angel_types = [];
|
||||||
$planned_arrival_date = null;
|
$planned_arrival_date = null;
|
||||||
|
|
||||||
$angel_types_source = AngelTypes();
|
$angel_types_source = AngelTypes();
|
||||||
$angel_types = [];
|
$angel_types = [];
|
||||||
foreach ($angel_types_source as $angel_type) {
|
foreach ($angel_types_source as $angel_type) {
|
||||||
$angel_types[$angel_type['id']] = $angel_type['name'] . ($angel_type['restricted'] ? " (restricted)" : "");
|
$angel_types[$angel_type['id']] = $angel_type['name'] . ($angel_type['restricted'] ? " (restricted)" : "");
|
||||||
if (! $angel_type['restricted']) {
|
if (!$angel_type['restricted']) {
|
||||||
$selected_angel_types[] = $angel_type['id'];
|
$selected_angel_types[] = $angel_type['id'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_REQUEST['submit'])) {
|
if (isset($_REQUEST['submit'])) {
|
||||||
$valid = true;
|
$valid = true;
|
||||||
|
|
||||||
if (isset($_REQUEST['nick']) && strlen(User_validate_Nick($_REQUEST['nick'])) > 1) {
|
if (isset($_REQUEST['nick']) && strlen(User_validate_Nick($_REQUEST['nick'])) > 1) {
|
||||||
$nick = User_validate_Nick($_REQUEST['nick']);
|
$nick = User_validate_Nick($_REQUEST['nick']);
|
||||||
if (sql_num_query("SELECT * FROM `User` WHERE `Nick`='" . sql_escape($nick) . "' LIMIT 1") > 0) {
|
if (sql_num_query("SELECT * FROM `User` WHERE `Nick`='" . sql_escape($nick) . "' LIMIT 1") > 0) {
|
||||||
|
@ -61,12 +61,15 @@ function guest_register()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$valid = false;
|
$valid = false;
|
||||||
$msg .= error(sprintf(_("Your nick "%s" is too short (min. 2 characters)."), User_validate_Nick($_REQUEST['nick'])), true);
|
$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) {
|
if (isset($_REQUEST['mail']) && strlen(strip_request_item('mail')) > 0) {
|
||||||
$mail = strip_request_item('mail');
|
$mail = strip_request_item('mail');
|
||||||
if (! check_email($mail)) {
|
if (!check_email($mail)) {
|
||||||
$valid = false;
|
$valid = false;
|
||||||
$msg .= error(_("E-mail address is not correct."), true);
|
$msg .= error(_("E-mail address is not correct."), true);
|
||||||
}
|
}
|
||||||
|
@ -74,23 +77,23 @@ function guest_register()
|
||||||
$valid = false;
|
$valid = false;
|
||||||
$msg .= error(_("Please enter your e-mail."), true);
|
$msg .= error(_("Please enter your e-mail."), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_REQUEST['email_shiftinfo'])) {
|
if (isset($_REQUEST['email_shiftinfo'])) {
|
||||||
$email_shiftinfo = true;
|
$email_shiftinfo = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_REQUEST['email_by_human_allowed'])) {
|
if (isset($_REQUEST['email_by_human_allowed'])) {
|
||||||
$email_by_human_allowed = true;
|
$email_by_human_allowed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_REQUEST['jabber']) && strlen(strip_request_item('jabber')) > 0) {
|
if (isset($_REQUEST['jabber']) && strlen(strip_request_item('jabber')) > 0) {
|
||||||
$jabber = strip_request_item('jabber');
|
$jabber = strip_request_item('jabber');
|
||||||
if (! check_email($jabber)) {
|
if (!check_email($jabber)) {
|
||||||
$valid = false;
|
$valid = false;
|
||||||
$msg .= error(_("Please check your jabber account information."), true);
|
$msg .= error(_("Please check your jabber account information."), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($enable_tshirt_size) {
|
if ($enable_tshirt_size) {
|
||||||
if (isset($_REQUEST['tshirt_size']) && isset($tshirt_sizes[$_REQUEST['tshirt_size']]) && $_REQUEST['tshirt_size'] != '') {
|
if (isset($_REQUEST['tshirt_size']) && isset($tshirt_sizes[$_REQUEST['tshirt_size']]) && $_REQUEST['tshirt_size'] != '') {
|
||||||
$tshirt_size = $_REQUEST['tshirt_size'];
|
$tshirt_size = $_REQUEST['tshirt_size'];
|
||||||
|
@ -99,7 +102,7 @@ function guest_register()
|
||||||
$msg .= error(_("Please select your shirt size."), true);
|
$msg .= error(_("Please select your shirt size."), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_REQUEST['password']) && strlen($_REQUEST['password']) >= $min_password_length) {
|
if (isset($_REQUEST['password']) && strlen($_REQUEST['password']) >= $min_password_length) {
|
||||||
if ($_REQUEST['password'] != $_REQUEST['password2']) {
|
if ($_REQUEST['password'] != $_REQUEST['password2']) {
|
||||||
$valid = false;
|
$valid = false;
|
||||||
|
@ -107,30 +110,33 @@ function guest_register()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$valid = false;
|
$valid = false;
|
||||||
$msg .= error(sprintf(_("Your password is too short (please use at least %s characters)."), $min_password_length), true);
|
$msg .= error(sprintf(
|
||||||
|
_("Your password is too short (please use at least %s characters)."),
|
||||||
|
$min_password_length
|
||||||
|
), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_REQUEST['planned_arrival_date'])) {
|
if (isset($_REQUEST['planned_arrival_date'])) {
|
||||||
$tmp = parse_date("Y-m-d H:i", $_REQUEST['planned_arrival_date'] . " 00:00");
|
$tmp = parse_date("Y-m-d H:i", $_REQUEST['planned_arrival_date'] . " 00:00");
|
||||||
$result = User_validate_planned_arrival_date($tmp);
|
$result = User_validate_planned_arrival_date($tmp);
|
||||||
$planned_arrival_date = $result->getValue();
|
$planned_arrival_date = $result->getValue();
|
||||||
if (! $result->isValid()) {
|
if (!$result->isValid()) {
|
||||||
$valid = false;
|
$valid = false;
|
||||||
error(_("Please enter your planned date of arrival. It should be after the buildup start date and before teardown end date."));
|
error(_("Please enter your planned date of arrival. It should be after the buildup start date and before teardown end date."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$selected_angel_types = [];
|
$selected_angel_types = [];
|
||||||
foreach (array_keys($angel_types) as $angel_type_id) {
|
foreach (array_keys($angel_types) as $angel_type_id) {
|
||||||
if (isset($_REQUEST['angel_types_' . $angel_type_id])) {
|
if (isset($_REQUEST['angel_types_' . $angel_type_id])) {
|
||||||
$selected_angel_types[] = $angel_type_id;
|
$selected_angel_types[] = $angel_type_id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Trivia
|
// Trivia
|
||||||
if (isset($_REQUEST['lastname'])) {
|
if (isset($_REQUEST['lastname'])) {
|
||||||
$lastname = strip_request_item('lastname');
|
$lastname = strip_request_item('lastname');
|
||||||
}
|
}
|
||||||
if (isset($_REQUEST['prename'])) {
|
if (isset($_REQUEST['prename'])) {
|
||||||
$prename = strip_request_item('prename');
|
$prename = strip_request_item('prename');
|
||||||
}
|
}
|
||||||
|
@ -152,7 +158,7 @@ function guest_register()
|
||||||
if (isset($_REQUEST['comment'])) {
|
if (isset($_REQUEST['comment'])) {
|
||||||
$comment = strip_request_item_nl('comment');
|
$comment = strip_request_item_nl('comment');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($valid) {
|
if ($valid) {
|
||||||
sql_query("
|
sql_query("
|
||||||
INSERT INTO `User` SET
|
INSERT INTO `User` SET
|
||||||
|
@ -176,36 +182,39 @@ function guest_register()
|
||||||
`Sprache`='" . sql_escape($_SESSION["locale"]) . "',
|
`Sprache`='" . sql_escape($_SESSION["locale"]) . "',
|
||||||
`arrival_date`=NULL,
|
`arrival_date`=NULL,
|
||||||
`planned_arrival_date`='" . sql_escape($planned_arrival_date) . "'");
|
`planned_arrival_date`='" . sql_escape($planned_arrival_date) . "'");
|
||||||
|
|
||||||
// Assign user-group and set password
|
// Assign user-group and set password
|
||||||
$user_id = sql_id();
|
$user_id = sql_id();
|
||||||
sql_query("INSERT INTO `UserGroups` SET `uid`='" . sql_escape($user_id) . "', `group_id`=-2");
|
sql_query("INSERT INTO `UserGroups` SET `uid`='" . sql_escape($user_id) . "', `group_id`=-2");
|
||||||
set_password($user_id, $_REQUEST['password']);
|
set_password($user_id, $_REQUEST['password']);
|
||||||
|
|
||||||
// Assign angel-types
|
// Assign angel-types
|
||||||
$user_angel_types_info = [];
|
$user_angel_types_info = [];
|
||||||
foreach ($selected_angel_types as $selected_angel_type_id) {
|
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) . "'");
|
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];
|
$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));
|
engelsystem_log(
|
||||||
|
"User " . User_Nick_render(User($user_id))
|
||||||
|
. " signed up as: " . join(", ", $user_angel_types_info)
|
||||||
|
);
|
||||||
success(_("Angel registration successful!"));
|
success(_("Angel registration successful!"));
|
||||||
|
|
||||||
// User is already logged in - that means a supporter has registered an angel. Return to register page.
|
// User is already logged in - that means a supporter has registered an angel. Return to register page.
|
||||||
if (isset($user)) {
|
if (isset($user)) {
|
||||||
redirect(page_link_to('register'));
|
redirect(page_link_to('register'));
|
||||||
}
|
}
|
||||||
|
|
||||||
// If a welcome message is present, display registration success page.
|
// If a welcome message is present, display registration success page.
|
||||||
if ($event_config != null && $event_config['event_welcome_msg'] != null) {
|
if ($event_config != null && $event_config['event_welcome_msg'] != null) {
|
||||||
return User_registration_success_view($event_config['event_welcome_msg']);
|
return User_registration_success_view($event_config['event_welcome_msg']);
|
||||||
}
|
}
|
||||||
|
|
||||||
redirect('?');
|
redirect('?');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$buildup_start_date = time();
|
$buildup_start_date = time();
|
||||||
$teardown_end_date = null;
|
$teardown_end_date = null;
|
||||||
if ($event_config != null) {
|
if ($event_config != null) {
|
||||||
|
@ -216,79 +225,105 @@ function guest_register()
|
||||||
$teardown_end_date = $event_config['teardown_end_date'];
|
$teardown_end_date = $event_config['teardown_end_date'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return page_with_title(register_title(), [
|
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."),
|
_("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,
|
||||||
msg(),
|
msg(),
|
||||||
form([
|
form([
|
||||||
div('row', [
|
div('row', [
|
||||||
div('col-md-6', [
|
div('col-md-6', [
|
||||||
div('row', [
|
div('row', [
|
||||||
div('col-sm-4', [
|
div('col-sm-4', [
|
||||||
form_text('nick', _("Nick") . ' ' . entry_required(), $nick)
|
form_text('nick', _("Nick") . ' ' . entry_required(), $nick)
|
||||||
]),
|
]),
|
||||||
div('col-sm-8', [
|
div('col-sm-8', [
|
||||||
form_email('mail', _("E-Mail") . ' ' . entry_required(), $mail),
|
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(
|
||||||
form_checkbox('email_by_human_allowed', _("Humans are allowed to send me an email (e.g. for ticket vouchers)"), $email_by_human_allowed)
|
'email_shiftinfo',
|
||||||
])
|
_("The engelsystem is allowed to send me an email (e.g. when my shifts change)"),
|
||||||
]),
|
$email_shiftinfo
|
||||||
div('row', [
|
),
|
||||||
div('col-sm-6', [
|
form_checkbox(
|
||||||
form_date('planned_arrival_date', _("Planned date of arrival") . ' ' . entry_required(), $planned_arrival_date, $buildup_start_date, $teardown_end_date)
|
'email_by_human_allowed',
|
||||||
]),
|
_("Humans are allowed to send me an email (e.g. for ticket vouchers)"),
|
||||||
div('col-sm-6', [
|
$email_by_human_allowed
|
||||||
$enable_tshirt_size ? form_select('tshirt_size', _("Shirt size") . ' ' . entry_required(), $tshirt_sizes, $tshirt_size) : ''
|
)
|
||||||
])
|
])
|
||||||
]),
|
]),
|
||||||
div('row', [
|
div('row', [
|
||||||
div('col-sm-6', [
|
div('col-sm-6', [
|
||||||
form_password('password', _("Password") . ' ' . entry_required())
|
form_date(
|
||||||
]),
|
'planned_arrival_date',
|
||||||
div('col-sm-6', [
|
_("Planned date of arrival") . ' ' . entry_required(),
|
||||||
form_password('password2', _("Confirm password") . ' ' . entry_required())
|
$planned_arrival_date, $buildup_start_date, $teardown_end_date
|
||||||
])
|
)
|
||||||
]),
|
]),
|
||||||
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),
|
div('col-sm-6', [
|
||||||
form_info("", _("Restricted angel types need will be confirmed later by a supporter. You can change your selection in the options section."))
|
$enable_tshirt_size ? form_select('tshirt_size',
|
||||||
]),
|
_("Shirt size") . ' ' . entry_required(),
|
||||||
div('col-md-6', [
|
$tshirt_sizes, $tshirt_size) : ''
|
||||||
div('row', [
|
])
|
||||||
div('col-sm-4', [
|
]),
|
||||||
form_text('dect', _("DECT"), $dect)
|
div('row', [
|
||||||
]),
|
div('col-sm-6', [
|
||||||
div('col-sm-4', [
|
form_password('password', _("Password") . ' ' . entry_required())
|
||||||
form_text('mobile', _("Mobile"), $mobile)
|
]),
|
||||||
]),
|
div('col-sm-6', [
|
||||||
div('col-sm-4', [
|
form_password('password2', _("Confirm password") . ' ' . entry_required())
|
||||||
form_text('tel', _("Phone"), $tel)
|
])
|
||||||
])
|
]),
|
||||||
]),
|
form_checkboxes(
|
||||||
form_text('jabber', _("Jabber"), $jabber),
|
'angel_types',
|
||||||
div('row', [
|
_("What do you want to do?") . sprintf(
|
||||||
div('col-sm-6', [
|
" (<a href=\"%s\">%s</a>)",
|
||||||
form_text('prename', _("First name"), $prename)
|
page_link_to('angeltypes') . '&action=about',
|
||||||
]),
|
_("Description of job types")
|
||||||
div('col-sm-6', [
|
),
|
||||||
form_text('lastname', _("Last name"), $lastname)
|
$angel_types,
|
||||||
])
|
$selected_angel_types
|
||||||
]),
|
),
|
||||||
div('row', [
|
form_info(
|
||||||
div('col-sm-3', [
|
"",
|
||||||
form_text('age', _("Age"), $age)
|
_("Restricted angel types need will be confirmed later by a supporter. You can change your selection in the options section.")
|
||||||
]),
|
)
|
||||||
div('col-sm-9', [
|
]),
|
||||||
form_text('hometown', _("Hometown"), $hometown)
|
div('col-md-6', [
|
||||||
])
|
div('row', [
|
||||||
]),
|
div('col-sm-4', [
|
||||||
form_info(entry_required() . ' = ' . _("Entry required!"))
|
form_text('dect', _("DECT"), $dect)
|
||||||
])
|
]),
|
||||||
]),
|
div('col-sm-4', [
|
||||||
// form_textarea('comment', _("Did you help at former CCC events and which tasks have you performed then?"), $comment),
|
form_text('mobile', _("Mobile"), $mobile)
|
||||||
form_submit('submit', _("Register"))
|
]),
|
||||||
])
|
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()
|
function entry_required()
|
||||||
|
@ -305,10 +340,10 @@ function guest_logout()
|
||||||
function guest_login()
|
function guest_login()
|
||||||
{
|
{
|
||||||
$nick = "";
|
$nick = "";
|
||||||
|
|
||||||
unset($_SESSION['uid']);
|
unset($_SESSION['uid']);
|
||||||
$valid = true;
|
$valid = true;
|
||||||
|
|
||||||
if (isset($_REQUEST['submit'])) {
|
if (isset($_REQUEST['submit'])) {
|
||||||
if (isset($_REQUEST['nick']) && strlen(User_validate_Nick($_REQUEST['nick'])) > 0) {
|
if (isset($_REQUEST['nick']) && strlen(User_validate_Nick($_REQUEST['nick'])) > 0) {
|
||||||
$nick = User_validate_Nick($_REQUEST['nick']);
|
$nick = User_validate_Nick($_REQUEST['nick']);
|
||||||
|
@ -316,7 +351,7 @@ function guest_login()
|
||||||
if (count($login_user) > 0) {
|
if (count($login_user) > 0) {
|
||||||
$login_user = $login_user[0];
|
$login_user = $login_user[0];
|
||||||
if (isset($_REQUEST['password'])) {
|
if (isset($_REQUEST['password'])) {
|
||||||
if (! verify_password($_REQUEST['password'], $login_user['Passwort'], $login_user['UID'])) {
|
if (!verify_password($_REQUEST['password'], $login_user['Passwort'], $login_user['UID'])) {
|
||||||
$valid = false;
|
$valid = false;
|
||||||
error(_("Your password is incorrect. Please try it again."));
|
error(_("Your password is incorrect. Please try it again."));
|
||||||
}
|
}
|
||||||
|
@ -332,75 +367,75 @@ function guest_login()
|
||||||
$valid = false;
|
$valid = false;
|
||||||
error(_("Please enter a nickname."));
|
error(_("Please enter a nickname."));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($valid) {
|
if ($valid) {
|
||||||
$_SESSION['uid'] = $login_user['UID'];
|
$_SESSION['uid'] = $login_user['UID'];
|
||||||
$_SESSION['locale'] = $login_user['Sprache'];
|
$_SESSION['locale'] = $login_user['Sprache'];
|
||||||
|
|
||||||
redirect(page_link_to('news'));
|
redirect(page_link_to('news'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$event_config = EventConfig();
|
$event_config = EventConfig();
|
||||||
|
|
||||||
return page([
|
return page([
|
||||||
div('col-md-12', [
|
div('col-md-12', [
|
||||||
div('row', [
|
div('row', [
|
||||||
EventConfig_countdown_page($event_config)
|
EventConfig_countdown_page($event_config)
|
||||||
]),
|
]),
|
||||||
div('row', [
|
div('row', [
|
||||||
div('col-sm-6 col-sm-offset-3 col-md-4 col-md-offset-4', [
|
div('col-sm-6 col-sm-offset-3 col-md-4 col-md-offset-4', [
|
||||||
div('panel panel-primary first', [
|
div('panel panel-primary first', [
|
||||||
div('panel-heading', [
|
div('panel-heading', [
|
||||||
'<span class="icon-icon_angel"></span> ' . _("Login")
|
'<span class="icon-icon_angel"></span> ' . _("Login")
|
||||||
]),
|
]),
|
||||||
div('panel-body', [
|
div('panel-body', [
|
||||||
msg(),
|
msg(),
|
||||||
form([
|
form([
|
||||||
form_text_placeholder('nick', _("Nick"), $nick),
|
form_text_placeholder('nick', _("Nick"), $nick),
|
||||||
form_password_placeholder('password', _("Password")),
|
form_password_placeholder('password', _("Password")),
|
||||||
form_submit('submit', _("Login")),
|
form_submit('submit', _("Login")),
|
||||||
! $valid ? buttons([
|
!$valid ? buttons([
|
||||||
button(page_link_to('user_password_recovery'), _("I forgot my password"))
|
button(page_link_to('user_password_recovery'), _("I forgot my password"))
|
||||||
]) : ''
|
]) : ''
|
||||||
])
|
])
|
||||||
]),
|
]),
|
||||||
div('panel-footer', [
|
div('panel-footer', [
|
||||||
glyph('info-sign') . _("Please note: You have to activate cookies!")
|
glyph('info-sign') . _("Please note: You have to activate cookies!")
|
||||||
])
|
])
|
||||||
])
|
])
|
||||||
])
|
])
|
||||||
]),
|
]),
|
||||||
div('row', [
|
div('row', [
|
||||||
div('col-sm-6 text-center', [
|
div('col-sm-6 text-center', [
|
||||||
heading(register_title(), 2),
|
heading(register_title(), 2),
|
||||||
get_register_hint()
|
get_register_hint()
|
||||||
]),
|
]),
|
||||||
div('col-sm-6 text-center', [
|
div('col-sm-6 text-center', [
|
||||||
heading(_("What can I do?"), 2),
|
heading(_("What can I do?"), 2),
|
||||||
'<p>' . _("Please read about the jobs you can do to help us.") . '</p>',
|
'<p>' . _("Please read about the jobs you can do to help us.") . '</p>',
|
||||||
buttons([
|
buttons([
|
||||||
button(page_link_to('angeltypes') . '&action=about', _("Teams/Job description") . ' »')
|
button(page_link_to('angeltypes') . '&action=about', _("Teams/Job description") . ' »')
|
||||||
])
|
])
|
||||||
])
|
])
|
||||||
])
|
])
|
||||||
])
|
])
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_register_hint()
|
function get_register_hint()
|
||||||
{
|
{
|
||||||
global $privileges;
|
global $privileges;
|
||||||
|
|
||||||
if (in_array('register', $privileges)) {
|
if (in_array('register', $privileges)) {
|
||||||
return join('', [
|
return join('', [
|
||||||
'<p>' . _("Please sign up, if you want to help us!") . '</p>',
|
'<p>' . _("Please sign up, if you want to help us!") . '</p>',
|
||||||
buttons([
|
buttons([
|
||||||
button(page_link_to('register'), register_title() . ' »')
|
button(page_link_to('register'), register_title() . ' »')
|
||||||
])
|
])
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
//FIXME: return error(_("Registration is disabled."), true);
|
//FIXME: return error(_("Registration is disabled."), true);
|
||||||
return error("Registration is <a href='https://engelsystem.de/33c3/overwhelmed.html'>disabled</a>.", true);
|
return error("Registration is <a href='https://engelsystem.de/33c3/overwhelmed.html'>disabled</a>.", true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,32 +3,32 @@
|
||||||
function guest_stats()
|
function guest_stats()
|
||||||
{
|
{
|
||||||
global $api_key;
|
global $api_key;
|
||||||
|
|
||||||
if (isset($_REQUEST['api_key'])) {
|
if (isset($_REQUEST['api_key'])) {
|
||||||
if ($_REQUEST['api_key'] == $api_key) {
|
if ($_REQUEST['api_key'] == $api_key) {
|
||||||
$stats = [];
|
$stats = [];
|
||||||
|
|
||||||
list($user_count) = sql_select("SELECT count(*) as `user_count` FROM `User`");
|
list($user_count) = sql_select("SELECT count(*) AS `user_count` FROM `User`");
|
||||||
$stats['user_count'] = $user_count['user_count'];
|
$stats['user_count'] = $user_count['user_count'];
|
||||||
|
|
||||||
list($arrived_user_count) = sql_select("SELECT count(*) as `user_count` FROM `User` WHERE `Gekommen`=1");
|
list($arrived_user_count) = sql_select("SELECT count(*) AS `user_count` FROM `User` WHERE `Gekommen`=1");
|
||||||
$stats['arrived_user_count'] = $arrived_user_count['user_count'];
|
$stats['arrived_user_count'] = $arrived_user_count['user_count'];
|
||||||
|
|
||||||
$done_shifts_seconds = sql_select_single_cell("SELECT SUM(`Shifts`.`end` - `Shifts`.`start`) FROM `ShiftEntry` JOIN `Shifts` USING (`SID`) WHERE `Shifts`.`end` < UNIX_TIMESTAMP()");
|
$done_shifts_seconds = sql_select_single_cell("SELECT SUM(`Shifts`.`end` - `Shifts`.`start`) FROM `ShiftEntry` JOIN `Shifts` USING (`SID`) WHERE `Shifts`.`end` < UNIX_TIMESTAMP()");
|
||||||
$stats['done_work_hours'] = round($done_shifts_seconds / (60 * 60), 0);
|
$stats['done_work_hours'] = round($done_shifts_seconds / (60 * 60), 0);
|
||||||
|
|
||||||
$users_in_action = sql_select("SELECT `Shifts`.`start`, `Shifts`.`end` FROM `ShiftEntry` JOIN `Shifts` ON `Shifts`.`SID`=`ShiftEntry`.`SID` WHERE UNIX_TIMESTAMP() BETWEEN `Shifts`.`start` AND `Shifts`.`end`");
|
$users_in_action = sql_select("SELECT `Shifts`.`start`, `Shifts`.`end` FROM `ShiftEntry` JOIN `Shifts` ON `Shifts`.`SID`=`ShiftEntry`.`SID` WHERE UNIX_TIMESTAMP() BETWEEN `Shifts`.`start` AND `Shifts`.`end`");
|
||||||
$stats['users_in_action'] = count($users_in_action);
|
$stats['users_in_action'] = count($users_in_action);
|
||||||
|
|
||||||
header("Content-Type: application/json");
|
header("Content-Type: application/json");
|
||||||
raw_output(json_encode($stats));
|
raw_output(json_encode($stats));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
raw_output(json_encode([
|
raw_output(json_encode([
|
||||||
'error' => "Wrong api_key."
|
'error' => "Wrong api_key."
|
||||||
]));
|
]));
|
||||||
}
|
}
|
||||||
raw_output(json_encode([
|
raw_output(json_encode([
|
||||||
'error' => "Missing parameter api_key."
|
'error' => "Missing parameter api_key."
|
||||||
]));
|
]));
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,24 +4,24 @@
|
||||||
function user_atom()
|
function user_atom()
|
||||||
{
|
{
|
||||||
global $user, $DISPLAY_NEWS;
|
global $user, $DISPLAY_NEWS;
|
||||||
|
|
||||||
if (! isset($_REQUEST['key']) || ! preg_match("/^[0-9a-f]{32}$/", $_REQUEST['key'])) {
|
if (!isset($_REQUEST['key']) || !preg_match("/^[0-9a-f]{32}$/", $_REQUEST['key'])) {
|
||||||
engelsystem_error("Missing key.");
|
engelsystem_error("Missing key.");
|
||||||
}
|
}
|
||||||
$key = $_REQUEST['key'];
|
$key = $_REQUEST['key'];
|
||||||
|
|
||||||
$user = User_by_api_key($key);
|
$user = User_by_api_key($key);
|
||||||
if ($user == null) {
|
if ($user == null) {
|
||||||
engelsystem_error("Key invalid.");
|
engelsystem_error("Key invalid.");
|
||||||
}
|
}
|
||||||
if (! in_array('atom', privileges_for_user($user['UID']))) {
|
if (!in_array('atom', privileges_for_user($user['UID']))) {
|
||||||
engelsystem_error("No privilege for atom.");
|
engelsystem_error("No privilege for atom.");
|
||||||
}
|
}
|
||||||
|
|
||||||
$news = sql_select("SELECT * FROM `News` " . (empty($_REQUEST['meetings']) ? '' : 'WHERE `Treffen` = 1 ') . "ORDER BY `ID` DESC LIMIT " . sql_escape($DISPLAY_NEWS));
|
$news = sql_select("SELECT * FROM `News` " . (empty($_REQUEST['meetings']) ? '' : 'WHERE `Treffen` = 1 ') . "ORDER BY `ID` DESC LIMIT " . sql_escape($DISPLAY_NEWS));
|
||||||
|
|
||||||
$output = make_atom_entries_from_news($news);
|
$output = make_atom_entries_from_news($news);
|
||||||
|
|
||||||
header('Content-Type: application/atom+xml; charset=utf-8');
|
header('Content-Type: application/atom+xml; charset=utf-8');
|
||||||
header("Content-Length: " . strlen($output));
|
header("Content-Length: " . strlen($output));
|
||||||
raw_output($output);
|
raw_output($output);
|
||||||
|
@ -32,7 +32,13 @@ function make_atom_entries_from_news($news_entries)
|
||||||
$html = '<?xml version="1.0" encoding="utf-8"?>
|
$html = '<?xml version="1.0" encoding="utf-8"?>
|
||||||
<feed xmlns="http://www.w3.org/2005/Atom">
|
<feed xmlns="http://www.w3.org/2005/Atom">
|
||||||
<title>Engelsystem</title>
|
<title>Engelsystem</title>
|
||||||
<id>' . $_SERVER['HTTP_HOST'] . htmlspecialchars(preg_replace('#[&?]key=[a-f0-9]{32}#', '', $_SERVER['REQUEST_URI'])) . '</id>
|
<id>' . $_SERVER['HTTP_HOST']
|
||||||
|
. htmlspecialchars(preg_replace(
|
||||||
|
'#[&?]key=[a-f0-9]{32}#',
|
||||||
|
'',
|
||||||
|
$_SERVER['REQUEST_URI']
|
||||||
|
))
|
||||||
|
. '</id>
|
||||||
<updated>' . date('Y-m-d\TH:i:sP', $news_entries[0]['Datum']) . "</updated>\n";
|
<updated>' . date('Y-m-d\TH:i:sP', $news_entries[0]['Datum']) . "</updated>\n";
|
||||||
foreach ($news_entries as $news_entry) {
|
foreach ($news_entries as $news_entry) {
|
||||||
$html .= make_atom_entry_from_news($news_entry);
|
$html .= make_atom_entry_from_news($news_entry);
|
||||||
|
|
|
@ -6,30 +6,30 @@
|
||||||
function user_ical()
|
function user_ical()
|
||||||
{
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
if (! isset($_REQUEST['key']) || ! preg_match("/^[0-9a-f]{32}$/", $_REQUEST['key'])) {
|
if (!isset($_REQUEST['key']) || !preg_match("/^[0-9a-f]{32}$/", $_REQUEST['key'])) {
|
||||||
engelsystem_error("Missing key.");
|
engelsystem_error("Missing key.");
|
||||||
}
|
}
|
||||||
$key = $_REQUEST['key'];
|
$key = $_REQUEST['key'];
|
||||||
|
|
||||||
$user = User_by_api_key($key);
|
$user = User_by_api_key($key);
|
||||||
if ($user == null) {
|
if ($user == null) {
|
||||||
engelsystem_error("Key invalid.");
|
engelsystem_error("Key invalid.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! in_array('ical', privileges_for_user($user['UID']))) {
|
if (!in_array('ical', privileges_for_user($user['UID']))) {
|
||||||
engelsystem_error("No privilege for ical.");
|
engelsystem_error("No privilege for ical.");
|
||||||
}
|
}
|
||||||
|
|
||||||
$ical_shifts = load_ical_shifts();
|
$ical_shifts = load_ical_shifts();
|
||||||
|
|
||||||
send_ical_from_shifts($ical_shifts);
|
send_ical_from_shifts($ical_shifts);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renders an ical calender from given shifts array.
|
* Renders an ical calender from given shifts array.
|
||||||
*
|
*
|
||||||
* @param array<Shift> $shifts
|
* @param array <Shift> $shifts
|
||||||
*/
|
*/
|
||||||
function send_ical_from_shifts($shifts)
|
function send_ical_from_shifts($shifts)
|
||||||
{
|
{
|
||||||
|
@ -53,7 +53,8 @@ function make_ical_entry_from_shift($shift)
|
||||||
{
|
{
|
||||||
$output = "BEGIN:VEVENT\r\n";
|
$output = "BEGIN:VEVENT\r\n";
|
||||||
$output .= "UID:" . md5($shift['start'] . $shift['end'] . $shift['name']) . "\r\n";
|
$output .= "UID:" . md5($shift['start'] . $shift['end'] . $shift['name']) . "\r\n";
|
||||||
$output .= "SUMMARY:" . str_replace("\n", "\\n", $shift['name']) . " (" . str_replace("\n", "\\n", $shift['title']) . ")\r\n";
|
$output .= "SUMMARY:" . str_replace("\n", "\\n", $shift['name'])
|
||||||
|
. " (" . str_replace("\n", "\\n", $shift['title']) . ")\r\n";
|
||||||
if (isset($shift['Comment'])) {
|
if (isset($shift['Comment'])) {
|
||||||
$output .= "DESCRIPTION:" . str_replace("\n", "\\n", $shift['Comment']) . "\r\n";
|
$output .= "DESCRIPTION:" . str_replace("\n", "\\n", $shift['Comment']) . "\r\n";
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ function messages_title()
|
||||||
function user_unread_messages()
|
function user_unread_messages()
|
||||||
{
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
if (isset($user)) {
|
if (isset($user)) {
|
||||||
$new_messages = sql_num_query("SELECT * FROM `Messages` WHERE isRead='N' AND `RUID`='" . sql_escape($user['UID']) . "'");
|
$new_messages = sql_num_query("SELECT * FROM `Messages` WHERE isRead='N' AND `RUID`='" . sql_escape($user['UID']) . "'");
|
||||||
if ($new_messages > 0) {
|
if ($new_messages > 0) {
|
||||||
|
@ -21,113 +21,121 @@ function user_unread_messages()
|
||||||
function user_messages()
|
function user_messages()
|
||||||
{
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
if (! isset($_REQUEST['action'])) {
|
if (!isset($_REQUEST['action'])) {
|
||||||
$users = sql_select("SELECT * FROM `User` WHERE NOT `UID`='" . sql_escape($user['UID']) . "' ORDER BY `Nick`");
|
$users = sql_select("SELECT * FROM `User` WHERE NOT `UID`='" . sql_escape($user['UID']) . "' ORDER BY `Nick`");
|
||||||
|
|
||||||
$to_select_data = [
|
$to_select_data = [
|
||||||
"" => _("Select recipient...")
|
"" => _("Select recipient...")
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach ($users as $u) {
|
foreach ($users as $u) {
|
||||||
$to_select_data[$u['UID']] = $u['Nick'];
|
$to_select_data[$u['UID']] = $u['Nick'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$to_select = html_select_key('to', 'to', $to_select_data, '');
|
$to_select = html_select_key('to', 'to', $to_select_data, '');
|
||||||
|
|
||||||
$messages = sql_select("SELECT * FROM `Messages` WHERE `SUID`='" . sql_escape($user['UID']) . "' OR `RUID`='" . sql_escape($user['UID']) . "' ORDER BY `isRead`,`Datum` DESC");
|
$messages = sql_select("SELECT * FROM `Messages` WHERE `SUID`='" . sql_escape($user['UID']) . "' OR `RUID`='" . sql_escape($user['UID']) . "' ORDER BY `isRead`,`Datum` DESC");
|
||||||
|
|
||||||
$messages_table = [
|
$messages_table = [
|
||||||
[
|
[
|
||||||
'news' => '',
|
'news' => '',
|
||||||
'timestamp' => date("Y-m-d H:i"),
|
'timestamp' => date("Y-m-d H:i"),
|
||||||
'from' => User_Nick_render($user),
|
'from' => User_Nick_render($user),
|
||||||
'to' => $to_select,
|
'to' => $to_select,
|
||||||
'text' => form_textarea('text', '', ''),
|
'text' => form_textarea('text', '', ''),
|
||||||
'actions' => form_submit('submit', _("Save"))
|
'actions' => form_submit('submit', _("Save"))
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach ($messages as $message) {
|
foreach ($messages as $message) {
|
||||||
$sender_user_source = User($message['SUID']);
|
$sender_user_source = User($message['SUID']);
|
||||||
$receiver_user_source = User($message['RUID']);
|
$receiver_user_source = User($message['RUID']);
|
||||||
|
|
||||||
$messages_table_entry = [
|
$messages_table_entry = [
|
||||||
'new' => $message['isRead'] == 'N' ? '<span class="glyphicon glyphicon-envelope"></span>' : '',
|
'new' => $message['isRead'] == 'N' ? '<span class="glyphicon glyphicon-envelope"></span>' : '',
|
||||||
'timestamp' => date("Y-m-d H:i", $message['Datum']),
|
'timestamp' => date("Y-m-d H:i", $message['Datum']),
|
||||||
'from' => User_Nick_render($sender_user_source),
|
'from' => User_Nick_render($sender_user_source),
|
||||||
'to' => User_Nick_render($receiver_user_source),
|
'to' => User_Nick_render($receiver_user_source),
|
||||||
'text' => str_replace("\n", '<br />', $message['Text'])
|
'text' => str_replace("\n", '<br />', $message['Text'])
|
||||||
];
|
];
|
||||||
|
|
||||||
if ($message['RUID'] == $user['UID']) {
|
if ($message['RUID'] == $user['UID']) {
|
||||||
if ($message['isRead'] == 'N') {
|
if ($message['isRead'] == 'N') {
|
||||||
$messages_table_entry['actions'] = button(page_link_to("user_messages") . '&action=read&id=' . $message['id'], _("mark as read"), 'btn-xs');
|
$messages_table_entry['actions'] = button(
|
||||||
|
page_link_to("user_messages") . '&action=read&id=' . $message['id'],
|
||||||
|
_("mark as read"),
|
||||||
|
'btn-xs'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$messages_table_entry['actions'] = button(page_link_to("user_messages") . '&action=delete&id=' . $message['id'], _("delete message"), 'btn-xs');
|
$messages_table_entry['actions'] = button(
|
||||||
|
page_link_to("user_messages") . '&action=delete&id=' . $message['id'],
|
||||||
|
_("delete message"),
|
||||||
|
'btn-xs'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
$messages_table[] = $messages_table_entry;
|
$messages_table[] = $messages_table_entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
return page_with_title(messages_title(), [
|
return page_with_title(messages_title(), [
|
||||||
msg(),
|
msg(),
|
||||||
sprintf(_("Hello %s, here can you leave messages for other angels"), User_Nick_render($user)),
|
sprintf(_("Hello %s, here can you leave messages for other angels"), User_Nick_render($user)),
|
||||||
form([
|
form([
|
||||||
table([
|
table([
|
||||||
'new' => _("New"),
|
'new' => _("New"),
|
||||||
'timestamp' => _("Date"),
|
'timestamp' => _("Date"),
|
||||||
'from' => _("Transmitted"),
|
'from' => _("Transmitted"),
|
||||||
'to' => _("Recipient"),
|
'to' => _("Recipient"),
|
||||||
'text' => _("Message"),
|
'text' => _("Message"),
|
||||||
'actions' => ''
|
'actions' => ''
|
||||||
], $messages_table)
|
], $messages_table)
|
||||||
], page_link_to('user_messages') . '&action=send')
|
], page_link_to('user_messages') . '&action=send')
|
||||||
]);
|
]);
|
||||||
} else {
|
} else {
|
||||||
switch ($_REQUEST['action']) {
|
switch ($_REQUEST['action']) {
|
||||||
case "read":
|
case "read":
|
||||||
if (isset($_REQUEST['id']) && preg_match("/^[0-9]{1,11}$/", $_REQUEST['id'])) {
|
if (isset($_REQUEST['id']) && preg_match("/^[0-9]{1,11}$/", $_REQUEST['id'])) {
|
||||||
$message_id = $_REQUEST['id'];
|
$message_id = $_REQUEST['id'];
|
||||||
} else {
|
} else {
|
||||||
return error(_("Incomplete call, missing Message ID."), true);
|
return error(_("Incomplete call, missing Message ID."), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
$message = sql_select("SELECT * FROM `Messages` WHERE `id`='" . sql_escape($message_id) . "' LIMIT 1");
|
||||||
|
if (count($message) > 0 && $message[0]['RUID'] == $user['UID']) {
|
||||||
|
sql_query("UPDATE `Messages` SET `isRead`='Y' WHERE `id`='" . sql_escape($message_id) . "' LIMIT 1");
|
||||||
|
redirect(page_link_to("user_messages"));
|
||||||
|
} else {
|
||||||
|
return error(_("No Message found."), true);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "delete":
|
||||||
|
if (isset($_REQUEST['id']) && preg_match("/^[0-9]{1,11}$/", $_REQUEST['id'])) {
|
||||||
|
$message_id = $_REQUEST['id'];
|
||||||
|
} else {
|
||||||
|
return error(_("Incomplete call, missing Message ID."), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
$message = sql_select("SELECT * FROM `Messages` WHERE `id`='" . sql_escape($message_id) . "' LIMIT 1");
|
||||||
|
if (count($message) > 0 && $message[0]['SUID'] == $user['UID']) {
|
||||||
|
sql_query("DELETE FROM `Messages` WHERE `id`='" . sql_escape($message_id) . "' LIMIT 1");
|
||||||
|
redirect(page_link_to("user_messages"));
|
||||||
|
} else {
|
||||||
|
return error(_("No Message found."), true);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "send":
|
||||||
|
if (Message_send($_REQUEST['to'], $_REQUEST['text']) === true) {
|
||||||
|
redirect(page_link_to("user_messages"));
|
||||||
|
} else {
|
||||||
|
return error(_("Transmitting was terminated with an Error."), true);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return error(_("Wrong action."), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
$message = sql_select("SELECT * FROM `Messages` WHERE `id`='" . sql_escape($message_id) . "' LIMIT 1");
|
|
||||||
if (count($message) > 0 && $message[0]['RUID'] == $user['UID']) {
|
|
||||||
sql_query("UPDATE `Messages` SET `isRead`='Y' WHERE `id`='" . sql_escape($message_id) . "' LIMIT 1");
|
|
||||||
redirect(page_link_to("user_messages"));
|
|
||||||
} else {
|
|
||||||
return error(_("No Message found."), true);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "delete":
|
|
||||||
if (isset($_REQUEST['id']) && preg_match("/^[0-9]{1,11}$/", $_REQUEST['id'])) {
|
|
||||||
$message_id = $_REQUEST['id'];
|
|
||||||
} else {
|
|
||||||
return error(_("Incomplete call, missing Message ID."), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
$message = sql_select("SELECT * FROM `Messages` WHERE `id`='" . sql_escape($message_id) . "' LIMIT 1");
|
|
||||||
if (count($message) > 0 && $message[0]['SUID'] == $user['UID']) {
|
|
||||||
sql_query("DELETE FROM `Messages` WHERE `id`='" . sql_escape($message_id) . "' LIMIT 1");
|
|
||||||
redirect(page_link_to("user_messages"));
|
|
||||||
} else {
|
|
||||||
return error(_("No Message found."), true);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "send":
|
|
||||||
if (Message_send($_REQUEST['to'], $_REQUEST['text']) === true) {
|
|
||||||
redirect(page_link_to("user_messages"));
|
|
||||||
} else {
|
|
||||||
return error(_("Transmitting was terminated with an Error."), true);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return error(_("Wrong action."), true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,15 +10,20 @@ function user_myshifts()
|
||||||
{
|
{
|
||||||
global $LETZTES_AUSTRAGEN;
|
global $LETZTES_AUSTRAGEN;
|
||||||
global $user, $privileges;
|
global $user, $privileges;
|
||||||
|
|
||||||
if (isset($_REQUEST['id']) && in_array("user_shifts_admin", $privileges) && preg_match("/^[0-9]{1,}$/", $_REQUEST['id']) && sql_num_query("SELECT * FROM `User` WHERE `UID`='" . sql_escape($_REQUEST['id']) . "'") > 0) {
|
if (
|
||||||
|
isset($_REQUEST['id'])
|
||||||
|
&& in_array("user_shifts_admin", $privileges)
|
||||||
|
&& preg_match("/^[0-9]{1,}$/", $_REQUEST['id'])
|
||||||
|
&& sql_num_query("SELECT * FROM `User` WHERE `UID`='" . sql_escape($_REQUEST['id']) . "'") > 0
|
||||||
|
) {
|
||||||
$user_id = $_REQUEST['id'];
|
$user_id = $_REQUEST['id'];
|
||||||
} else {
|
} else {
|
||||||
$user_id = $user['UID'];
|
$user_id = $user['UID'];
|
||||||
}
|
}
|
||||||
|
|
||||||
list($shifts_user) = sql_select("SELECT * FROM `User` WHERE `UID`='" . sql_escape($user_id) . "' LIMIT 1");
|
list($shifts_user) = sql_select("SELECT * FROM `User` WHERE `UID`='" . sql_escape($user_id) . "' LIMIT 1");
|
||||||
|
|
||||||
if (isset($_REQUEST['reset'])) {
|
if (isset($_REQUEST['reset'])) {
|
||||||
if ($_REQUEST['reset'] == "ack") {
|
if ($_REQUEST['reset'] == "ack") {
|
||||||
User_reset_api_key($user);
|
User_reset_api_key($user);
|
||||||
|
@ -26,9 +31,12 @@ function user_myshifts()
|
||||||
redirect(page_link_to('users') . '&action=view&user_id=' . $shifts_user['UID']);
|
redirect(page_link_to('users') . '&action=view&user_id=' . $shifts_user['UID']);
|
||||||
}
|
}
|
||||||
return page_with_title(_("Reset API key"), [
|
return page_with_title(_("Reset API key"), [
|
||||||
error(_("If you reset the key, the url to your iCal- and JSON-export and your atom feed changes! You have to update it in every application using one of these exports."), true),
|
error(
|
||||||
button(page_link_to('user_myshifts') . '&reset=ack', _("Continue"), 'btn-danger')
|
_("If you reset the key, the url to your iCal- and JSON-export and your atom feed changes! You have to update it in every application using one of these exports."),
|
||||||
]);
|
true
|
||||||
|
),
|
||||||
|
button(page_link_to('user_myshifts') . '&reset=ack', _("Continue"), 'btn-danger')
|
||||||
|
]);
|
||||||
} elseif (isset($_REQUEST['edit']) && preg_match("/^[0-9]*$/", $_REQUEST['edit'])) {
|
} elseif (isset($_REQUEST['edit']) && preg_match("/^[0-9]*$/", $_REQUEST['edit'])) {
|
||||||
$user_id = $_REQUEST['edit'];
|
$user_id = $_REQUEST['edit'];
|
||||||
$shift = sql_select("SELECT
|
$shift = sql_select("SELECT
|
||||||
|
@ -39,7 +47,7 @@ function user_myshifts()
|
||||||
`ShiftTypes`.`name`,
|
`ShiftTypes`.`name`,
|
||||||
`Shifts`.*,
|
`Shifts`.*,
|
||||||
`Room`.`Name`,
|
`Room`.`Name`,
|
||||||
`AngelTypes`.`name` as `angel_type`
|
`AngelTypes`.`name` AS `angel_type`
|
||||||
FROM `ShiftEntry`
|
FROM `ShiftEntry`
|
||||||
JOIN `AngelTypes` ON (`ShiftEntry`.`TID` = `AngelTypes`.`id`)
|
JOIN `AngelTypes` ON (`ShiftEntry`.`TID` = `AngelTypes`.`id`)
|
||||||
JOIN `Shifts` ON (`ShiftEntry`.`SID` = `Shifts`.`SID`)
|
JOIN `Shifts` ON (`ShiftEntry`.`SID` = `Shifts`.`SID`)
|
||||||
|
@ -51,7 +59,7 @@ function user_myshifts()
|
||||||
$shift = $shift[0];
|
$shift = $shift[0];
|
||||||
$freeloaded = $shift['freeloaded'];
|
$freeloaded = $shift['freeloaded'];
|
||||||
$freeload_comment = $shift['freeload_comment'];
|
$freeload_comment = $shift['freeload_comment'];
|
||||||
|
|
||||||
if (isset($_REQUEST['submit'])) {
|
if (isset($_REQUEST['submit'])) {
|
||||||
$valid = true;
|
$valid = true;
|
||||||
if (in_array("user_shifts_admin", $privileges)) {
|
if (in_array("user_shifts_admin", $privileges)) {
|
||||||
|
@ -62,28 +70,44 @@ function user_myshifts()
|
||||||
error(_("Please enter a freeload comment!"));
|
error(_("Please enter a freeload comment!"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$comment = strip_request_item_nl('comment');
|
$comment = strip_request_item_nl('comment');
|
||||||
$user_source = User($shift['UID']);
|
$user_source = User($shift['UID']);
|
||||||
|
|
||||||
if ($valid) {
|
if ($valid) {
|
||||||
$result = ShiftEntry_update([
|
$result = ShiftEntry_update([
|
||||||
'id' => $user_id,
|
'id' => $user_id,
|
||||||
'Comment' => $comment,
|
'Comment' => $comment,
|
||||||
'freeloaded' => $freeloaded,
|
'freeloaded' => $freeloaded,
|
||||||
'freeload_comment' => $freeload_comment
|
'freeload_comment' => $freeload_comment
|
||||||
]);
|
]);
|
||||||
if ($result === false) {
|
if ($result === false) {
|
||||||
engelsystem_error('Unable to update shift entry.');
|
engelsystem_error('Unable to update shift entry.');
|
||||||
}
|
}
|
||||||
|
|
||||||
engelsystem_log("Updated " . User_Nick_render($user_source) . "'s shift " . $shift['name'] . " from " . date("Y-m-d H:i", $shift['start']) . " to " . date("Y-m-d H:i", $shift['end']) . " with comment " . $comment . ". Freeloaded: " . ($freeloaded ? "YES Comment: " . $freeload_comment : "NO"));
|
engelsystem_log(
|
||||||
|
"Updated " . User_Nick_render($user_source) . "'s shift " . $shift['name']
|
||||||
|
. " from " . date("Y-m-d H:i", $shift['start'])
|
||||||
|
. " to " . date("Y-m-d H:i", $shift['end'])
|
||||||
|
. " with comment " . $comment
|
||||||
|
. ". Freeloaded: " . ($freeloaded ? "YES Comment: " . $freeload_comment : "NO")
|
||||||
|
);
|
||||||
success(_("Shift saved."));
|
success(_("Shift saved."));
|
||||||
redirect(page_link_to('users') . '&action=view&user_id=' . $shifts_user['UID']);
|
redirect(page_link_to('users') . '&action=view&user_id=' . $shifts_user['UID']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ShiftEntry_edit_view(User_Nick_render($shifts_user), date("Y-m-d H:i", $shift['start']) . ', ' . shift_length($shift), $shift['Name'], $shift['name'], $shift['angel_type'], $shift['Comment'], $shift['freeloaded'], $shift['freeload_comment'], in_array("user_shifts_admin", $privileges));
|
return ShiftEntry_edit_view(
|
||||||
|
User_Nick_render($shifts_user),
|
||||||
|
date("Y-m-d H:i", $shift['start']) . ', ' . shift_length($shift),
|
||||||
|
$shift['Name'],
|
||||||
|
$shift['name'],
|
||||||
|
$shift['angel_type'],
|
||||||
|
$shift['Comment'],
|
||||||
|
$shift['freeloaded'],
|
||||||
|
$shift['freeload_comment'],
|
||||||
|
in_array("user_shifts_admin", $privileges)
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
redirect(page_link_to('user_myshifts'));
|
redirect(page_link_to('user_myshifts'));
|
||||||
}
|
}
|
||||||
|
@ -104,8 +128,14 @@ function user_myshifts()
|
||||||
$room = Room($shift['RID']);
|
$room = Room($shift['RID']);
|
||||||
$angeltype = AngelType($shift['TID']);
|
$angeltype = AngelType($shift['TID']);
|
||||||
$shifttype = ShiftType($shift['shifttype_id']);
|
$shifttype = ShiftType($shift['shifttype_id']);
|
||||||
|
|
||||||
engelsystem_log("Deleted own shift: " . $shifttype['name'] . " at " . $room['Name'] . " from " . date("Y-m-d H:i", $shift['start']) . " to " . date("Y-m-d H:i", $shift['end']) . " as " . $angeltype['name']);
|
engelsystem_log(
|
||||||
|
"Deleted own shift: " . $shifttype['name']
|
||||||
|
. " at " . $room['Name']
|
||||||
|
. " from " . date("Y-m-d H:i", $shift['start'])
|
||||||
|
. " to " . date("Y-m-d H:i", $shift['end'])
|
||||||
|
. " as " . $angeltype['name']
|
||||||
|
);
|
||||||
success(_("Shift canceled."));
|
success(_("Shift canceled."));
|
||||||
} else {
|
} else {
|
||||||
error(_("It's too late to sign yourself off the shift. If neccessary, ask the dispatcher to do so."));
|
error(_("It's too late to sign yourself off the shift. If neccessary, ask the dispatcher to do so."));
|
||||||
|
@ -114,6 +144,6 @@ function user_myshifts()
|
||||||
redirect(user_link($shifts_user));
|
redirect(user_link($shifts_user));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
redirect(page_link_to('users') . '&action=view&user_id=' . $shifts_user['UID']);
|
redirect(page_link_to('users') . '&action=view&user_id=' . $shifts_user['UID']);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,26 +18,26 @@ function meetings_title()
|
||||||
function user_meetings()
|
function user_meetings()
|
||||||
{
|
{
|
||||||
global $DISPLAY_NEWS;
|
global $DISPLAY_NEWS;
|
||||||
|
|
||||||
$html = '<div class="col-md-12"><h1>' . meetings_title() . '</h1>' . msg();
|
$html = '<div class="col-md-12"><h1>' . meetings_title() . '</h1>' . msg();
|
||||||
|
|
||||||
if (isset($_REQUEST['page']) && preg_match("/^[0-9]{1,}$/", $_REQUEST['page'])) {
|
if (isset($_REQUEST['page']) && preg_match("/^[0-9]{1,}$/", $_REQUEST['page'])) {
|
||||||
$page = $_REQUEST['page'];
|
$page = $_REQUEST['page'];
|
||||||
} else {
|
} else {
|
||||||
$page = 0;
|
$page = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
$news = sql_select("SELECT * FROM `News` WHERE `Treffen`=1 ORDER BY `Datum` DESC LIMIT " . sql_escape($page * $DISPLAY_NEWS) . ", " . sql_escape($DISPLAY_NEWS));
|
$news = sql_select("SELECT * FROM `News` WHERE `Treffen`=1 ORDER BY `Datum` DESC LIMIT " . sql_escape($page * $DISPLAY_NEWS) . ", " . sql_escape($DISPLAY_NEWS));
|
||||||
foreach ($news as $entry) {
|
foreach ($news as $entry) {
|
||||||
$html .= display_news($entry);
|
$html .= display_news($entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
$dis_rows = ceil(sql_num_query("SELECT * FROM `News`") / $DISPLAY_NEWS);
|
$dis_rows = ceil(sql_num_query("SELECT * FROM `News`") / $DISPLAY_NEWS);
|
||||||
$html .= '<div class="text-center">' . '<ul class="pagination">';
|
$html .= '<div class="text-center">' . '<ul class="pagination">';
|
||||||
for ($i = 0; $i < $dis_rows; $i ++) {
|
for ($i = 0; $i < $dis_rows; $i++) {
|
||||||
if (isset($_REQUEST['page']) && $i == $_REQUEST['page']) {
|
if (isset($_REQUEST['page']) && $i == $_REQUEST['page']) {
|
||||||
$html .= '<li class="active">';
|
$html .= '<li class="active">';
|
||||||
} elseif (! isset($_REQUEST['page']) && $i == 0) {
|
} elseif (!isset($_REQUEST['page']) && $i == 0) {
|
||||||
$html .= '<li class="active">';
|
$html .= '<li class="active">';
|
||||||
} else {
|
} else {
|
||||||
$html .= '<li>';
|
$html .= '<li>';
|
||||||
|
@ -45,29 +45,31 @@ function user_meetings()
|
||||||
$html .= '<a href="' . page_link_to("user_meetings") . '&page=' . $i . '">' . ($i + 1) . '</a></li>';
|
$html .= '<a href="' . page_link_to("user_meetings") . '&page=' . $i . '">' . ($i + 1) . '</a></li>';
|
||||||
}
|
}
|
||||||
$html .= '</ul></div></div>';
|
$html .= '</ul></div></div>';
|
||||||
|
|
||||||
return $html;
|
return $html;
|
||||||
}
|
}
|
||||||
|
|
||||||
function display_news($news)
|
function display_news($news)
|
||||||
{
|
{
|
||||||
global $privileges, $page;
|
global $privileges, $page;
|
||||||
|
|
||||||
$html = '';
|
$html = '';
|
||||||
$html .= '<div class="panel' . ($news['Treffen'] == 1 ? ' panel-info' : ' panel-default') . '">';
|
$html .= '<div class="panel' . ($news['Treffen'] == 1 ? ' panel-info' : ' panel-default') . '">';
|
||||||
$html .= '<div class="panel-heading">';
|
$html .= '<div class="panel-heading">';
|
||||||
$html .= '<h3 class="panel-title">' . ($news['Treffen'] == 1 ? '[Meeting] ' : '') . ReplaceSmilies($news['Betreff']) . '</h3>';
|
$html .= '<h3 class="panel-title">' . ($news['Treffen'] == 1 ? '[Meeting] ' : '') . ReplaceSmilies($news['Betreff']) . '</h3>';
|
||||||
$html .= '</div>';
|
$html .= '</div>';
|
||||||
$html .= '<div class="panel-body">' . ReplaceSmilies(nl2br($news['Text'])) . '</div>';
|
$html .= '<div class="panel-body">' . ReplaceSmilies(nl2br($news['Text'])) . '</div>';
|
||||||
|
|
||||||
$html .= '<div class="panel-footer text-muted">';
|
$html .= '<div class="panel-footer text-muted">';
|
||||||
if (in_array("admin_news", $privileges)) {
|
if (in_array("admin_news", $privileges)) {
|
||||||
$html .= '<div class="pull-right">' . button_glyph(page_link_to("admin_news") . '&action=edit&id=' . $news['ID'], 'edit', 'btn-xs') . '</div>';
|
$html .= '<div class="pull-right">'
|
||||||
|
. button_glyph(page_link_to("admin_news") . '&action=edit&id=' . $news['ID'], 'edit', 'btn-xs')
|
||||||
|
. '</div>';
|
||||||
}
|
}
|
||||||
$html .= '<span class="glyphicon glyphicon-time"></span> ' . date("Y-m-d H:i", $news['Datum']) . ' ';
|
$html .= '<span class="glyphicon glyphicon-time"></span> ' . date("Y-m-d H:i", $news['Datum']) . ' ';
|
||||||
|
|
||||||
$user_source = User($news['UID']);
|
$user_source = User($news['UID']);
|
||||||
|
|
||||||
$html .= User_Nick_render($user_source);
|
$html .= User_Nick_render($user_source);
|
||||||
if ($page != "news_comments") {
|
if ($page != "news_comments") {
|
||||||
$html .= ' <a href="' . page_link_to("news_comments") . '&nid=' . $news['ID'] . '"><span class="glyphicon glyphicon-comment"></span> ' . _("Comments") . ' »</a> <span class="badge">' . sql_num_query("SELECT * FROM `NewsComments` WHERE `Refid`='" . sql_escape($news['ID']) . "'") . '</span>';
|
$html .= ' <a href="' . page_link_to("news_comments") . '&nid=' . $news['ID'] . '"><span class="glyphicon glyphicon-comment"></span> ' . _("Comments") . ' »</a> <span class="badge">' . sql_num_query("SELECT * FROM `NewsComments` WHERE `Refid`='" . sql_escape($news['ID']) . "'") . '</span>';
|
||||||
|
@ -80,9 +82,13 @@ function display_news($news)
|
||||||
function user_news_comments()
|
function user_news_comments()
|
||||||
{
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
$html = '<div class="col-md-12"><h1>' . user_news_comments_title() . '</h1>';
|
$html = '<div class="col-md-12"><h1>' . user_news_comments_title() . '</h1>';
|
||||||
if (isset($_REQUEST["nid"]) && preg_match("/^[0-9]{1,}$/", $_REQUEST['nid']) && sql_num_query("SELECT * FROM `News` WHERE `ID`='" . sql_escape($_REQUEST['nid']) . "' LIMIT 1") > 0) {
|
if (
|
||||||
|
isset($_REQUEST["nid"])
|
||||||
|
&& preg_match("/^[0-9]{1,}$/", $_REQUEST['nid'])
|
||||||
|
&& sql_num_query("SELECT * FROM `News` WHERE `ID`='" . sql_escape($_REQUEST['nid']) . "' LIMIT 1") > 0
|
||||||
|
) {
|
||||||
$nid = $_REQUEST["nid"];
|
$nid = $_REQUEST["nid"];
|
||||||
list($news) = sql_select("SELECT * FROM `News` WHERE `ID`='" . sql_escape($nid) . "' LIMIT 1");
|
list($news) = sql_select("SELECT * FROM `News` WHERE `ID`='" . sql_escape($nid) . "' LIMIT 1");
|
||||||
if (isset($_REQUEST["text"])) {
|
if (isset($_REQUEST["text"])) {
|
||||||
|
@ -91,13 +97,13 @@ function user_news_comments()
|
||||||
engelsystem_log("Created news_comment: " . $text);
|
engelsystem_log("Created news_comment: " . $text);
|
||||||
$html .= success(_("Entry saved."), true);
|
$html .= success(_("Entry saved."), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
$html .= display_news($news);
|
$html .= display_news($news);
|
||||||
|
|
||||||
$comments = sql_select("SELECT * FROM `NewsComments` WHERE `Refid`='" . sql_escape($nid) . "' ORDER BY 'ID'");
|
$comments = sql_select("SELECT * FROM `NewsComments` WHERE `Refid`='" . sql_escape($nid) . "' ORDER BY 'ID'");
|
||||||
foreach ($comments as $comment) {
|
foreach ($comments as $comment) {
|
||||||
$user_source = User($comment['UID']);
|
$user_source = User($comment['UID']);
|
||||||
|
|
||||||
$html .= '<div class="panel panel-default">';
|
$html .= '<div class="panel panel-default">';
|
||||||
$html .= '<div class="panel-body">' . nl2br($comment['Text']) . '</div>';
|
$html .= '<div class="panel-body">' . nl2br($comment['Text']) . '</div>';
|
||||||
$html .= '<div class="panel-footer text-muted">';
|
$html .= '<div class="panel-footer text-muted">';
|
||||||
|
@ -106,27 +112,27 @@ function user_news_comments()
|
||||||
$html .= '</div>';
|
$html .= '</div>';
|
||||||
$html .= '</div>';
|
$html .= '</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
$html .= '<hr /><h2>' . _("New Comment:") . '</h2>';
|
$html .= '<hr /><h2>' . _("New Comment:") . '</h2>';
|
||||||
$html .= form([
|
$html .= form([
|
||||||
form_textarea('text', _("Message"), ''),
|
form_textarea('text', _("Message"), ''),
|
||||||
form_submit('submit', _("Save"))
|
form_submit('submit', _("Save"))
|
||||||
], page_link_to('news_comments') . '&nid=' . $news['ID']);
|
], page_link_to('news_comments') . '&nid=' . $news['ID']);
|
||||||
} else {
|
} else {
|
||||||
$html .= _("Invalid request.");
|
$html .= _("Invalid request.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return $html . '</div>';
|
return $html . '</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
function user_news()
|
function user_news()
|
||||||
{
|
{
|
||||||
global $DISPLAY_NEWS, $privileges, $user;
|
global $DISPLAY_NEWS, $privileges, $user;
|
||||||
|
|
||||||
$html = '<div class="col-md-12"><h1>' . news_title() . '</h1>' . msg();
|
$html = '<div class="col-md-12"><h1>' . news_title() . '</h1>' . msg();
|
||||||
|
|
||||||
if (isset($_POST["text"]) && isset($_POST["betreff"]) && in_array("admin_news", $privileges)) {
|
if (isset($_POST["text"]) && isset($_POST["betreff"]) && in_array("admin_news", $privileges)) {
|
||||||
if (! isset($_POST["treffen"]) || ! in_array("admin_news", $privileges)) {
|
if (!isset($_POST["treffen"]) || !in_array("admin_news", $privileges)) {
|
||||||
$_POST["treffen"] = 0;
|
$_POST["treffen"] = 0;
|
||||||
}
|
}
|
||||||
sql_query("INSERT INTO `News` (`Datum`, `Betreff`, `Text`, `UID`, `Treffen`) " . "VALUES ('" . sql_escape(time()) . "', '" . sql_escape($_POST["betreff"]) . "', '" . sql_escape($_POST["text"]) . "', '" . sql_escape($user['UID']) . "', '" . sql_escape($_POST["treffen"]) . "');");
|
sql_query("INSERT INTO `News` (`Datum`, `Betreff`, `Text`, `UID`, `Treffen`) " . "VALUES ('" . sql_escape(time()) . "', '" . sql_escape($_POST["betreff"]) . "', '" . sql_escape($_POST["text"]) . "', '" . sql_escape($user['UID']) . "', '" . sql_escape($_POST["treffen"]) . "');");
|
||||||
|
@ -134,24 +140,24 @@ function user_news()
|
||||||
success(_("Entry saved."));
|
success(_("Entry saved."));
|
||||||
redirect(page_link_to('news'));
|
redirect(page_link_to('news'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_REQUEST['page']) && preg_match("/^[0-9]{1,}$/", $_REQUEST['page'])) {
|
if (isset($_REQUEST['page']) && preg_match("/^[0-9]{1,}$/", $_REQUEST['page'])) {
|
||||||
$page = $_REQUEST['page'];
|
$page = $_REQUEST['page'];
|
||||||
} else {
|
} else {
|
||||||
$page = 0;
|
$page = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
$news = sql_select("SELECT * FROM `News` ORDER BY `Datum` DESC LIMIT " . sql_escape($page * $DISPLAY_NEWS) . ", " . sql_escape($DISPLAY_NEWS));
|
$news = sql_select("SELECT * FROM `News` ORDER BY `Datum` DESC LIMIT " . sql_escape($page * $DISPLAY_NEWS) . ", " . sql_escape($DISPLAY_NEWS));
|
||||||
foreach ($news as $entry) {
|
foreach ($news as $entry) {
|
||||||
$html .= display_news($entry);
|
$html .= display_news($entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
$dis_rows = ceil(sql_num_query("SELECT * FROM `News`") / $DISPLAY_NEWS);
|
$dis_rows = ceil(sql_num_query("SELECT * FROM `News`") / $DISPLAY_NEWS);
|
||||||
$html .= '<div class="text-center">' . '<ul class="pagination">';
|
$html .= '<div class="text-center">' . '<ul class="pagination">';
|
||||||
for ($i = 0; $i < $dis_rows; $i ++) {
|
for ($i = 0; $i < $dis_rows; $i++) {
|
||||||
if (isset($_REQUEST['page']) && $i == $_REQUEST['page']) {
|
if (isset($_REQUEST['page']) && $i == $_REQUEST['page']) {
|
||||||
$html .= '<li class="active">';
|
$html .= '<li class="active">';
|
||||||
} elseif (! isset($_REQUEST['page']) && $i == 0) {
|
} elseif (!isset($_REQUEST['page']) && $i == 0) {
|
||||||
$html .= '<li class="active">';
|
$html .= '<li class="active">';
|
||||||
} else {
|
} else {
|
||||||
$html .= '<li>';
|
$html .= '<li>';
|
||||||
|
@ -159,17 +165,17 @@ function user_news()
|
||||||
$html .= '<a href="' . page_link_to("news") . '&page=' . $i . '">' . ($i + 1) . '</a></li>';
|
$html .= '<a href="' . page_link_to("news") . '&page=' . $i . '">' . ($i + 1) . '</a></li>';
|
||||||
}
|
}
|
||||||
$html .= '</ul></div>';
|
$html .= '</ul></div>';
|
||||||
|
|
||||||
if (in_array("admin_news", $privileges)) {
|
if (in_array("admin_news", $privileges)) {
|
||||||
$html .= '<hr />';
|
$html .= '<hr />';
|
||||||
$html .= '<h2>' . _("Create news:") . '</h2>';
|
$html .= '<h2>' . _("Create news:") . '</h2>';
|
||||||
|
|
||||||
$html .= form([
|
$html .= form([
|
||||||
form_text('betreff', _("Subject"), ''),
|
form_text('betreff', _("Subject"), ''),
|
||||||
form_textarea('text', _("Message"), ''),
|
form_textarea('text', _("Message"), ''),
|
||||||
form_checkbox('treffen', _("Meeting"), false, 1),
|
form_checkbox('treffen', _("Meeting"), false, 1),
|
||||||
form_submit('submit', _("Save"))
|
form_submit('submit', _("Save"))
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
return $html . '</div>';
|
return $html . '</div>';
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,51 +8,58 @@ function questions_title()
|
||||||
function user_questions()
|
function user_questions()
|
||||||
{
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
if (! isset($_REQUEST['action'])) {
|
if (!isset($_REQUEST['action'])) {
|
||||||
$open_questions = sql_select("SELECT * FROM `Questions` WHERE `AID` IS NULL AND `UID`='" . sql_escape($user['UID']) . "'");
|
$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']) . "'");
|
);
|
||||||
|
|
||||||
|
$answered_questions = sql_select(
|
||||||
|
"SELECT * FROM `Questions` WHERE NOT `AID` IS NULL AND `UID`='" . sql_escape($user['UID']) . "'"
|
||||||
|
);
|
||||||
foreach ($answered_questions as &$question) {
|
foreach ($answered_questions as &$question) {
|
||||||
$answer_user_source = User($question['AID']);
|
$answer_user_source = User($question['AID']);
|
||||||
$question['answer_user'] = User_Nick_render($answer_user_source);
|
$question['answer_user'] = User_Nick_render($answer_user_source);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Questions_view($open_questions, $answered_questions, page_link_to("user_questions") . '&action=ask');
|
return Questions_view($open_questions, $answered_questions, page_link_to("user_questions") . '&action=ask');
|
||||||
} else {
|
} else {
|
||||||
switch ($_REQUEST['action']) {
|
switch ($_REQUEST['action']) {
|
||||||
case 'ask':
|
case 'ask':
|
||||||
$question = strip_request_item_nl('question');
|
$question = strip_request_item_nl('question');
|
||||||
if ($question != "") {
|
if ($question != "") {
|
||||||
$result = sql_query("INSERT INTO `Questions` SET `UID`='" . sql_escape($user['UID']) . "', `Question`='" . sql_escape($question) . "'");
|
$result = sql_query("
|
||||||
if ($result === false) {
|
INSERT INTO `Questions`
|
||||||
engelsystem_error(_("Unable to save question."));
|
SET `UID`='" . sql_escape($user['UID']) . "', `Question`='" . sql_escape($question) . "'
|
||||||
}
|
");
|
||||||
success(_("You question was saved."));
|
if ($result === false) {
|
||||||
redirect(page_link_to("user_questions"));
|
engelsystem_error(_("Unable to save question."));
|
||||||
} else {
|
}
|
||||||
return page_with_title(questions_title(), [
|
success(_("You question was saved."));
|
||||||
error(_("Please enter a question!"), true)
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
$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)
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
$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)
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,11 +14,11 @@ function settings_title()
|
||||||
function user_settings_main($user_source, $enable_tshirt_size, $tshirt_sizes)
|
function user_settings_main($user_source, $enable_tshirt_size, $tshirt_sizes)
|
||||||
{
|
{
|
||||||
$valid = true;
|
$valid = true;
|
||||||
|
|
||||||
if (isset($_REQUEST['mail'])) {
|
if (isset($_REQUEST['mail'])) {
|
||||||
$result = User_validate_mail($_REQUEST['mail']);
|
$result = User_validate_mail($_REQUEST['mail']);
|
||||||
$user_source['email'] = $result->getValue();
|
$user_source['email'] = $result->getValue();
|
||||||
if (! $result->isValid()) {
|
if (!$result->isValid()) {
|
||||||
$valid = false;
|
$valid = false;
|
||||||
error(_("E-mail address is not correct."));
|
error(_("E-mail address is not correct."));
|
||||||
}
|
}
|
||||||
|
@ -26,60 +26,60 @@ function user_settings_main($user_source, $enable_tshirt_size, $tshirt_sizes)
|
||||||
$valid = false;
|
$valid = false;
|
||||||
error(_("Please enter your e-mail."));
|
error(_("Please enter your e-mail."));
|
||||||
}
|
}
|
||||||
|
|
||||||
$user_source['email_shiftinfo'] = isset($_REQUEST['email_shiftinfo']);
|
$user_source['email_shiftinfo'] = isset($_REQUEST['email_shiftinfo']);
|
||||||
$user_source['email_by_human_allowed'] = isset($_REQUEST['email_by_human_allowed']);
|
$user_source['email_by_human_allowed'] = isset($_REQUEST['email_by_human_allowed']);
|
||||||
|
|
||||||
if (isset($_REQUEST['jabber'])) {
|
if (isset($_REQUEST['jabber'])) {
|
||||||
$result = User_validate_jabber($_REQUEST['jabber']);
|
$result = User_validate_jabber($_REQUEST['jabber']);
|
||||||
$user_source['jabber'] = $result->getValue();
|
$user_source['jabber'] = $result->getValue();
|
||||||
if (! $result->isValid()) {
|
if (!$result->isValid()) {
|
||||||
$valid = false;
|
$valid = false;
|
||||||
error(_("Please check your jabber account information."));
|
error(_("Please check your jabber account information."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_REQUEST['tshirt_size']) && isset($tshirt_sizes[$_REQUEST['tshirt_size']])) {
|
if (isset($_REQUEST['tshirt_size']) && isset($tshirt_sizes[$_REQUEST['tshirt_size']])) {
|
||||||
$user_source['Size'] = $_REQUEST['tshirt_size'];
|
$user_source['Size'] = $_REQUEST['tshirt_size'];
|
||||||
} elseif ($enable_tshirt_size) {
|
} elseif ($enable_tshirt_size) {
|
||||||
$valid = false;
|
$valid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_REQUEST['planned_arrival_date'])) {
|
if (isset($_REQUEST['planned_arrival_date'])) {
|
||||||
$tmp = parse_date("Y-m-d H:i", $_REQUEST['planned_arrival_date'] . " 00:00");
|
$tmp = parse_date("Y-m-d H:i", $_REQUEST['planned_arrival_date'] . " 00:00");
|
||||||
$result = User_validate_planned_arrival_date($tmp);
|
$result = User_validate_planned_arrival_date($tmp);
|
||||||
$user_source['planned_arrival_date'] = $result->getValue();
|
$user_source['planned_arrival_date'] = $result->getValue();
|
||||||
if (! $result->isValid()) {
|
if (!$result->isValid()) {
|
||||||
$valid = false;
|
$valid = false;
|
||||||
error(_("Please enter your planned date of arrival. It should be after the buildup start date and before teardown end date."));
|
error(_("Please enter your planned date of arrival. It should be after the buildup start date and before teardown end date."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_REQUEST['planned_departure_date'])) {
|
if (isset($_REQUEST['planned_departure_date'])) {
|
||||||
$tmp = parse_date("Y-m-d H:i", $_REQUEST['planned_departure_date'] . " 00:00");
|
$tmp = parse_date("Y-m-d H:i", $_REQUEST['planned_departure_date'] . " 00:00");
|
||||||
$result = User_validate_planned_departure_date($user_source['planned_arrival_date'], $tmp);
|
$result = User_validate_planned_departure_date($user_source['planned_arrival_date'], $tmp);
|
||||||
$user_source['planned_departure_date'] = $result->getValue();
|
$user_source['planned_departure_date'] = $result->getValue();
|
||||||
if (! $result->isValid()) {
|
if (!$result->isValid()) {
|
||||||
$valid = false;
|
$valid = false;
|
||||||
error(_("Please enter your planned date of departure. It should be after your planned arrival date and after buildup start date and before teardown end date."));
|
error(_("Please enter your planned date of departure. It should be after your planned arrival date and after buildup start date and before teardown end date."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Trivia
|
// Trivia
|
||||||
$user_source['Name'] = strip_request_item('lastname', $user_source['Name']);
|
$user_source['Name'] = strip_request_item('lastname', $user_source['Name']);
|
||||||
$user_source['Vorname'] = strip_request_item('prename', $user_source['Vorname']);
|
$user_source['Vorname'] = strip_request_item('prename', $user_source['Vorname']);
|
||||||
$user_source['Alter'] = strip_request_item('age', $user_source['Alter']);
|
$user_source['Alter'] = strip_request_item('age', $user_source['Alter']);
|
||||||
$user_source['Telefon'] = strip_request_item('tel', $user_source['Telefon']);
|
$user_source['Telefon'] = strip_request_item('tel', $user_source['Telefon']);
|
||||||
$user_source['DECT'] = strip_request_item('dect', $user_source['DECT']);
|
$user_source['DECT'] = strip_request_item('dect', $user_source['DECT']);
|
||||||
$user_source['Handy'] = strip_request_item('mobile', $user_source['Handy']);
|
$user_source['Handy'] = strip_request_item('mobile', $user_source['Handy']);
|
||||||
$user_source['Hometown'] = strip_request_item('hometown', $user_source['Hometown']);
|
$user_source['Hometown'] = strip_request_item('hometown', $user_source['Hometown']);
|
||||||
|
|
||||||
if ($valid) {
|
if ($valid) {
|
||||||
User_update($user_source);
|
User_update($user_source);
|
||||||
success(_("Settings saved."));
|
success(_("Settings saved."));
|
||||||
redirect(page_link_to('user_settings'));
|
redirect(page_link_to('user_settings'));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $user_source;
|
return $user_source;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,7 +92,10 @@ function user_settings_main($user_source, $enable_tshirt_size, $tshirt_sizes)
|
||||||
function user_settings_password($user_source)
|
function user_settings_password($user_source)
|
||||||
{
|
{
|
||||||
global $min_password_length;
|
global $min_password_length;
|
||||||
if (! isset($_REQUEST['password']) || ! verify_password($_REQUEST['password'], $user_source['Passwort'], $user_source['UID'])) {
|
if (
|
||||||
|
!isset($_REQUEST['password'])
|
||||||
|
|| !verify_password($_REQUEST['password'], $user_source['Passwort'], $user_source['UID'])
|
||||||
|
) {
|
||||||
error(_("-> not OK. Please try again."));
|
error(_("-> not OK. Please try again."));
|
||||||
} elseif (strlen($_REQUEST['new_password']) < $min_password_length) {
|
} elseif (strlen($_REQUEST['new_password']) < $min_password_length) {
|
||||||
error(_("Your password is to short (please use at least 6 characters)."));
|
error(_("Your password is to short (please use at least 6 characters)."));
|
||||||
|
@ -110,27 +113,27 @@ function user_settings_password($user_source)
|
||||||
* Change user theme
|
* Change user theme
|
||||||
*
|
*
|
||||||
* @param User $user_sources
|
* @param User $user_sources
|
||||||
* The user
|
* The user
|
||||||
* @param array<String> $themes
|
* @param array <String> $themes
|
||||||
* List of available themes
|
* List of available themes
|
||||||
*/
|
*/
|
||||||
function user_settings_theme($user_source, $themes)
|
function user_settings_theme($user_source, $themes)
|
||||||
{
|
{
|
||||||
$valid = true;
|
$valid = true;
|
||||||
|
|
||||||
if (isset($_REQUEST['theme']) && isset($themes[$_REQUEST['theme']])) {
|
if (isset($_REQUEST['theme']) && isset($themes[$_REQUEST['theme']])) {
|
||||||
$user_source['color'] = $_REQUEST['theme'];
|
$user_source['color'] = $_REQUEST['theme'];
|
||||||
} else {
|
} else {
|
||||||
$valid = false;
|
$valid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($valid) {
|
if ($valid) {
|
||||||
sql_query("UPDATE `User` SET `color`='" . sql_escape($user_source['color']) . "' WHERE `UID`='" . sql_escape($user_source['UID']) . "'");
|
sql_query("UPDATE `User` SET `color`='" . sql_escape($user_source['color']) . "' WHERE `UID`='" . sql_escape($user_source['UID']) . "'");
|
||||||
|
|
||||||
success(_("Theme changed."));
|
success(_("Theme changed."));
|
||||||
redirect(page_link_to('user_settings'));
|
redirect(page_link_to('user_settings'));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $user_source;
|
return $user_source;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,28 +141,28 @@ function user_settings_theme($user_source, $themes)
|
||||||
* Change use locale
|
* Change use locale
|
||||||
*
|
*
|
||||||
* @param User $user_source
|
* @param User $user_source
|
||||||
* The user
|
* The user
|
||||||
* @param array<String> $locales
|
* @param array <String> $locales
|
||||||
* List of available locales
|
* List of available locales
|
||||||
*/
|
*/
|
||||||
function user_settings_locale($user_source, $locales)
|
function user_settings_locale($user_source, $locales)
|
||||||
{
|
{
|
||||||
$valid = true;
|
$valid = true;
|
||||||
|
|
||||||
if (isset($_REQUEST['language']) && isset($locales[$_REQUEST['language']])) {
|
if (isset($_REQUEST['language']) && isset($locales[$_REQUEST['language']])) {
|
||||||
$user_source['Sprache'] = $_REQUEST['language'];
|
$user_source['Sprache'] = $_REQUEST['language'];
|
||||||
} else {
|
} else {
|
||||||
$valid = false;
|
$valid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($valid) {
|
if ($valid) {
|
||||||
sql_query("UPDATE `User` SET `Sprache`='" . sql_escape($user_source['Sprache']) . "' WHERE `UID`='" . sql_escape($user_source['UID']) . "'");
|
sql_query("UPDATE `User` SET `Sprache`='" . sql_escape($user_source['Sprache']) . "' WHERE `UID`='" . sql_escape($user_source['UID']) . "'");
|
||||||
$_SESSION['locale'] = $user_source['Sprache'];
|
$_SESSION['locale'] = $user_source['Sprache'];
|
||||||
|
|
||||||
success("Language changed.");
|
success("Language changed.");
|
||||||
redirect(page_link_to('user_settings'));
|
redirect(page_link_to('user_settings'));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $user_source;
|
return $user_source;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,7 +173,7 @@ function user_settings()
|
||||||
{
|
{
|
||||||
global $enable_tshirt_size, $tshirt_sizes, $themes, $locales;
|
global $enable_tshirt_size, $tshirt_sizes, $themes, $locales;
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
$buildup_start_date = null;
|
$buildup_start_date = null;
|
||||||
$teardown_end_date = null;
|
$teardown_end_date = null;
|
||||||
$event_config = EventConfig();
|
$event_config = EventConfig();
|
||||||
|
@ -182,9 +185,9 @@ function user_settings()
|
||||||
$teardown_end_date = $event_config['teardown_end_date'];
|
$teardown_end_date = $event_config['teardown_end_date'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$user_source = $user;
|
$user_source = $user;
|
||||||
|
|
||||||
if (isset($_REQUEST['submit'])) {
|
if (isset($_REQUEST['submit'])) {
|
||||||
$user_source = user_settings_main($user_source, $enable_tshirt_size, $tshirt_sizes);
|
$user_source = user_settings_main($user_source, $enable_tshirt_size, $tshirt_sizes);
|
||||||
} elseif (isset($_REQUEST['submit_password'])) {
|
} elseif (isset($_REQUEST['submit_password'])) {
|
||||||
|
@ -194,6 +197,7 @@ function user_settings()
|
||||||
} elseif (isset($_REQUEST['submit_language'])) {
|
} elseif (isset($_REQUEST['submit_language'])) {
|
||||||
$user_source = user_settings_locale($user_source, $locales);
|
$user_source = user_settings_locale($user_source, $locales);
|
||||||
}
|
}
|
||||||
|
|
||||||
return User_settings_view($user_source, $locales, $themes, $buildup_start_date, $teardown_end_date, $enable_tshirt_size, $tshirt_sizes);
|
return User_settings_view($user_source, $locales, $themes, $buildup_start_date, $teardown_end_date,
|
||||||
|
$enable_tshirt_size, $tshirt_sizes);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,21 +16,21 @@ function shifts_title()
|
||||||
function user_shifts()
|
function user_shifts()
|
||||||
{
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
if (User_is_freeloader($user)) {
|
if (User_is_freeloader($user)) {
|
||||||
redirect(page_link_to('user_myshifts'));
|
redirect(page_link_to('user_myshifts'));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Löschen einzelner Schicht-Einträge (Also Belegung einer Schicht von Engeln) durch Admins
|
// Löschen einzelner Schicht-Einträge (Also Belegung einer Schicht von Engeln) durch Admins
|
||||||
if (isset($_REQUEST['entry_id'])) {
|
if (isset($_REQUEST['entry_id'])) {
|
||||||
return shift_entry_delete_controller();
|
return shift_entry_delete_controller();
|
||||||
} elseif (isset($_REQUEST['edit_shift'])) {
|
} elseif (isset($_REQUEST['edit_shift'])) {
|
||||||
return shift_edit_controller();
|
return shift_edit_controller();
|
||||||
} elseif (isset($_REQUEST['delete_shift'])) {
|
} elseif (isset($_REQUEST['delete_shift'])) {
|
||||||
return shift_delete_controller();
|
return shift_delete_controller();
|
||||||
} elseif (isset($_REQUEST['shift_id'])) {
|
} elseif (isset($_REQUEST['shift_id'])) {
|
||||||
return shift_entry_add_controller();
|
return shift_entry_add_controller();
|
||||||
}
|
}
|
||||||
return view_user_shifts();
|
return view_user_shifts();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,15 +47,15 @@ function update_ShiftsFilter_timerange(ShiftsFilter $shiftsFilter, $days)
|
||||||
if ($start_time == null) {
|
if ($start_time == null) {
|
||||||
$start_time = time();
|
$start_time = time();
|
||||||
}
|
}
|
||||||
|
|
||||||
$end_time = $shiftsFilter->getEndTime();
|
$end_time = $shiftsFilter->getEndTime();
|
||||||
if ($end_time == null) {
|
if ($end_time == null) {
|
||||||
$end_time = $start_time + 24 * 60 * 60;
|
$end_time = $start_time + 24 * 60 * 60;
|
||||||
}
|
}
|
||||||
|
|
||||||
$shiftsFilter->setStartTime(check_request_datetime('start_day', 'start_time', $days, $start_time));
|
$shiftsFilter->setStartTime(check_request_datetime('start_day', 'start_time', $days, $start_time));
|
||||||
$shiftsFilter->setEndTime(check_request_datetime('end_day', 'end_time', $days, $end_time));
|
$shiftsFilter->setEndTime(check_request_datetime('end_day', 'end_time', $days, $end_time));
|
||||||
|
|
||||||
if ($shiftsFilter->getStartTime() > $shiftsFilter->getEndTime()) {
|
if ($shiftsFilter->getStartTime() > $shiftsFilter->getEndTime()) {
|
||||||
$shiftsFilter->setEndTime($shiftsFilter->getStartTime() + 24 * 60 * 60);
|
$shiftsFilter->setEndTime($shiftsFilter->getStartTime() + 24 * 60 * 60);
|
||||||
}
|
}
|
||||||
|
@ -66,9 +66,9 @@ function update_ShiftsFilter_timerange(ShiftsFilter $shiftsFilter, $days)
|
||||||
*
|
*
|
||||||
* @param ShiftsFilter $shiftsFilter
|
* @param ShiftsFilter $shiftsFilter
|
||||||
* The shifts filter to update from request data
|
* The shifts filter to update from request data
|
||||||
* @param boolean $user_shifts_admin
|
* @param boolean $user_shifts_admin
|
||||||
* Has the user user_shift_admin privilege?
|
* Has the user user_shift_admin privilege?
|
||||||
* @param string[] $days
|
* @param string[] $days
|
||||||
* An array of available filter days
|
* An array of available filter days
|
||||||
*/
|
*/
|
||||||
function update_ShiftsFilter(ShiftsFilter $shiftsFilter, $user_shifts_admin, $days)
|
function update_ShiftsFilter(ShiftsFilter $shiftsFilter, $user_shifts_admin, $days)
|
||||||
|
@ -106,12 +106,30 @@ function load_days()
|
||||||
function load_types()
|
function load_types()
|
||||||
{
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
if (sql_num_query("SELECT `id`, `name` FROM `AngelTypes` WHERE `restricted` = 0") == 0) {
|
if (sql_num_query("SELECT `id`, `name` FROM `AngelTypes` WHERE `restricted` = 0") == 0) {
|
||||||
error(_("The administration has not configured any angeltypes yet - or you are not subscribed to any angeltype."));
|
error(_("The administration has not configured any angeltypes yet - or you are not subscribed to any angeltype."));
|
||||||
redirect('?');
|
redirect('?');
|
||||||
}
|
}
|
||||||
$types = sql_select("SELECT `AngelTypes`.`id`, `AngelTypes`.`name`, (`AngelTypes`.`restricted`=0 OR (NOT `UserAngelTypes`.`confirm_user_id` IS NULL OR `UserAngelTypes`.`id` IS NULL)) as `enabled` FROM `AngelTypes` LEFT JOIN `UserAngelTypes` ON (`UserAngelTypes`.`angeltype_id`=`AngelTypes`.`id` AND `UserAngelTypes`.`user_id`='" . sql_escape($user['UID']) . "') ORDER BY `AngelTypes`.`name`");
|
$types = sql_select("
|
||||||
|
SELECT
|
||||||
|
`AngelTypes`.`id`,
|
||||||
|
`AngelTypes`.`name`,
|
||||||
|
(
|
||||||
|
`AngelTypes`.`restricted`=0
|
||||||
|
OR (
|
||||||
|
NOT `UserAngelTypes`.`confirm_user_id` IS NULL
|
||||||
|
OR `UserAngelTypes`.`id` IS NULL
|
||||||
|
)
|
||||||
|
) AS `enabled`
|
||||||
|
FROM `AngelTypes`
|
||||||
|
LEFT JOIN `UserAngelTypes`
|
||||||
|
ON (
|
||||||
|
`UserAngelTypes`.`angeltype_id`=`AngelTypes`.`id`
|
||||||
|
AND `UserAngelTypes`.`user_id`='" . sql_escape($user['UID']) . "'
|
||||||
|
)
|
||||||
|
ORDER BY `AngelTypes`.`name`
|
||||||
|
");
|
||||||
if (empty($types)) {
|
if (empty($types)) {
|
||||||
return sql_select("SELECT `id`, `name` FROM `AngelTypes` WHERE `restricted` = 0");
|
return sql_select("SELECT `id`, `name` FROM `AngelTypes` WHERE `restricted` = 0");
|
||||||
}
|
}
|
||||||
|
@ -122,62 +140,77 @@ function view_user_shifts()
|
||||||
{
|
{
|
||||||
global $user, $privileges;
|
global $user, $privileges;
|
||||||
global $ical_shifts;
|
global $ical_shifts;
|
||||||
|
|
||||||
$ical_shifts = [];
|
$ical_shifts = [];
|
||||||
$days = load_days();
|
$days = load_days();
|
||||||
$rooms = load_rooms();
|
$rooms = load_rooms();
|
||||||
$types = load_types();
|
$types = load_types();
|
||||||
|
|
||||||
if (! isset($_SESSION['ShiftsFilter'])) {
|
if (!isset($_SESSION['ShiftsFilter'])) {
|
||||||
$room_ids = [
|
$room_ids = [
|
||||||
$rooms[0]['id']
|
$rooms[0]['id']
|
||||||
];
|
];
|
||||||
$type_ids = array_map('get_ids_from_array', $types);
|
$type_ids = array_map('get_ids_from_array', $types);
|
||||||
$_SESSION['ShiftsFilter'] = new ShiftsFilter(in_array('user_shifts_admin', $privileges), $room_ids, $type_ids);
|
$_SESSION['ShiftsFilter'] = new ShiftsFilter(in_array('user_shifts_admin', $privileges), $room_ids, $type_ids);
|
||||||
}
|
}
|
||||||
update_ShiftsFilter($_SESSION['ShiftsFilter'], in_array('user_shifts_admin', $privileges), $days);
|
update_ShiftsFilter($_SESSION['ShiftsFilter'], in_array('user_shifts_admin', $privileges), $days);
|
||||||
$shiftsFilter = $_SESSION['ShiftsFilter'];
|
$shiftsFilter = $_SESSION['ShiftsFilter'];
|
||||||
|
|
||||||
$shiftCalendarRenderer = shiftCalendarRendererByShiftFilter($shiftsFilter);
|
$shiftCalendarRenderer = shiftCalendarRendererByShiftFilter($shiftsFilter);
|
||||||
|
|
||||||
if ($user['api_key'] == "") {
|
if ($user['api_key'] == "") {
|
||||||
User_reset_api_key($user, false);
|
User_reset_api_key($user, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
$filled = [
|
$filled = [
|
||||||
[
|
[
|
||||||
'id' => '1',
|
'id' => '1',
|
||||||
'name' => _("occupied")
|
'name' => _("occupied")
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'id' => '0',
|
'id' => '0',
|
||||||
'name' => _("free")
|
'name' => _("free")
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
$start_day = date("Y-m-d", $shiftsFilter->getStartTime());
|
$start_day = date("Y-m-d", $shiftsFilter->getStartTime());
|
||||||
$start_time = date("H:i", $shiftsFilter->getStartTime());
|
$start_time = date("H:i", $shiftsFilter->getStartTime());
|
||||||
$end_day = date("Y-m-d", $shiftsFilter->getEndTime());
|
$end_day = date("Y-m-d", $shiftsFilter->getEndTime());
|
||||||
$end_time = date("H:i", $shiftsFilter->getEndTime());
|
$end_time = date("H:i", $shiftsFilter->getEndTime());
|
||||||
|
|
||||||
return page([
|
return page([
|
||||||
div('col-md-12', [
|
div('col-md-12', [
|
||||||
msg(),
|
msg(),
|
||||||
template_render(__DIR__ . '/../../templates/user_shifts.html', [
|
template_render(__DIR__ . '/../../templates/user_shifts.html', [
|
||||||
'title' => shifts_title(),
|
'title' => shifts_title(),
|
||||||
'room_select' => make_select($rooms, $shiftsFilter->getRooms(), "rooms", _("Rooms")),
|
'room_select' => make_select($rooms, $shiftsFilter->getRooms(), "rooms", _("Rooms")),
|
||||||
'start_select' => html_select_key("start_day", "start_day", array_combine($days, $days), $start_day),
|
'start_select' => html_select_key("start_day", "start_day", array_combine($days, $days), $start_day),
|
||||||
'start_time' => $start_time,
|
'start_time' => $start_time,
|
||||||
'end_select' => html_select_key("end_day", "end_day", array_combine($days, $days), $end_day),
|
'end_select' => html_select_key("end_day", "end_day", array_combine($days, $days), $end_day),
|
||||||
'end_time' => $end_time,
|
'end_time' => $end_time,
|
||||||
'type_select' => make_select($types, $shiftsFilter->getTypes(), "types", _("Angeltypes") . '<sup>1</sup>'),
|
'type_select' => make_select(
|
||||||
'filled_select' => make_select($filled, $shiftsFilter->getFilled(), "filled", _("Occupancy")),
|
$types,
|
||||||
'task_notice' => '<sup>1</sup>' . _("The tasks shown here are influenced by the angeltypes you joined already!") . " <a href=\"" . page_link_to('angeltypes') . '&action=about' . "\">" . _("Description of the jobs.") . "</a>",
|
$shiftsFilter->getTypes(),
|
||||||
'shifts_table' => msg() . $shiftCalendarRenderer->render(),
|
"types",
|
||||||
'ical_text' => '<h2>' . _("iCal export") . '</h2><p>' . sprintf(_("Export of shown shifts. <a href=\"%s\">iCal format</a> or <a href=\"%s\">JSON format</a> available (please keep secret, otherwise <a href=\"%s\">reset the api key</a>)."), page_link_to_absolute('ical') . '&key=' . $user['api_key'], page_link_to_absolute('shifts_json_export') . '&key=' . $user['api_key'], page_link_to('user_myshifts') . '&reset') . '</p>',
|
_("Angeltypes") . '<sup>1</sup>'
|
||||||
'filter' => _("Filter")
|
),
|
||||||
])
|
'filled_select' => make_select($filled, $shiftsFilter->getFilled(), "filled", _("Occupancy")),
|
||||||
])
|
'task_notice' =>
|
||||||
]);
|
'<sup>1</sup>'
|
||||||
|
. _("The tasks shown here are influenced by the angeltypes you joined already!")
|
||||||
|
. " <a href=\"" . page_link_to('angeltypes') . '&action=about' . "\">"
|
||||||
|
. _("Description of the jobs.")
|
||||||
|
. "</a>",
|
||||||
|
'shifts_table' => msg() . $shiftCalendarRenderer->render(),
|
||||||
|
'ical_text' => '<h2>' . _("iCal export") . '</h2><p>' . sprintf(
|
||||||
|
_("Export of shown shifts. <a href=\"%s\">iCal format</a> or <a href=\"%s\">JSON format</a> available (please keep secret, otherwise <a href=\"%s\">reset the api key</a>)."),
|
||||||
|
page_link_to_absolute('ical') . '&key=' . $user['api_key'],
|
||||||
|
page_link_to_absolute('shifts_json_export') . '&key=' . $user['api_key'],
|
||||||
|
page_link_to('user_myshifts') . '&reset'
|
||||||
|
) . '</p>',
|
||||||
|
'filter' => _("Filter")
|
||||||
|
])
|
||||||
|
])
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_ids_from_array($array)
|
function get_ids_from_array($array)
|
||||||
|
@ -191,16 +224,21 @@ function make_select($items, $selected, $name, $title = null)
|
||||||
if (isset($title)) {
|
if (isset($title)) {
|
||||||
$html_items[] = '<h4>' . $title . '</h4>' . "\n";
|
$html_items[] = '<h4>' . $title . '</h4>' . "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($items as $i) {
|
foreach ($items as $i) {
|
||||||
$html_items[] = '<div class="checkbox"><label><input type="checkbox" name="' . $name . '[]" value="' . $i['id'] . '"' . (in_array($i['id'], $selected) ? ' checked="checked"' : '') . '> ' . $i['name'] . '</label>' . (! isset($i['enabled']) || $i['enabled'] ? '' : glyph("lock")) . '</div><br />';
|
$html_items[] = '<div class="checkbox">'
|
||||||
|
. '<label><input type="checkbox" name="' . $name . '[]" value="' . $i['id'] . '"'
|
||||||
|
. (in_array($i['id'], $selected) ? ' checked="checked"' : '')
|
||||||
|
. '> ' . $i['name'] . '</label>'
|
||||||
|
. (!isset($i['enabled']) || $i['enabled'] ? '' : glyph("lock"))
|
||||||
|
. '</div><br />';
|
||||||
}
|
}
|
||||||
$html = '<div id="selection_' . $name . '" class="selection ' . $name . '">' . "\n";
|
$html = '<div id="selection_' . $name . '" class="selection ' . $name . '">' . "\n";
|
||||||
$html .= implode("\n", $html_items);
|
$html .= implode("\n", $html_items);
|
||||||
$html .= buttons([
|
$html .= buttons([
|
||||||
button("javascript: checkAll('selection_" . $name . "', true)", _("All"), ""),
|
button("javascript: checkAll('selection_" . $name . "', true)", _("All"), ""),
|
||||||
button("javascript: checkAll('selection_" . $name . "', false)", _("None"), "")
|
button("javascript: checkAll('selection_" . $name . "', false)", _("None"), "")
|
||||||
]);
|
]);
|
||||||
$html .= '</div>' . "\n";
|
$html .= '</div>' . "\n";
|
||||||
return $html;
|
return $html;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,22 +6,27 @@
|
||||||
function load_auth()
|
function load_auth()
|
||||||
{
|
{
|
||||||
global $user, $privileges;
|
global $user, $privileges;
|
||||||
|
|
||||||
$user = null;
|
$user = null;
|
||||||
if (isset($_SESSION['uid'])) {
|
if (isset($_SESSION['uid'])) {
|
||||||
$user = sql_select("SELECT * FROM `User` WHERE `UID`='" . sql_escape($_SESSION['uid']) . "' LIMIT 1");
|
$user = sql_select("SELECT * FROM `User` WHERE `UID`='" . sql_escape($_SESSION['uid']) . "' LIMIT 1");
|
||||||
if (count($user) > 0) {
|
if (count($user) > 0) {
|
||||||
// User ist eingeloggt, Datensatz zur Verfügung stellen und Timestamp updaten
|
// User ist eingeloggt, Datensatz zur Verfügung stellen und Timestamp updaten
|
||||||
list($user) = $user;
|
list($user) = $user;
|
||||||
sql_query("UPDATE `User` SET " . "`lastLogIn` = '" . time() . "'" . " WHERE `UID` = '" . sql_escape($_SESSION['uid']) . "' LIMIT 1;");
|
sql_query("
|
||||||
|
UPDATE `User`
|
||||||
|
SET " . "`lastLogIn` = '" . time() . "'" . "
|
||||||
|
WHERE `UID` = '" . sql_escape($_SESSION['uid']) . "'
|
||||||
|
LIMIT 1
|
||||||
|
");
|
||||||
$privileges = privileges_for_user($user['UID']);
|
$privileges = privileges_for_user($user['UID']);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
unset($_SESSION['uid']);
|
unset($_SESSION['uid']);
|
||||||
}
|
}
|
||||||
|
|
||||||
// guest privileges
|
// guest privileges
|
||||||
$privileges = privileges_for_group(- 1);
|
$privileges = privileges_for_group(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -31,7 +36,7 @@ function generate_salt($length = 16)
|
||||||
{
|
{
|
||||||
$alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
$alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||||
$salt = "";
|
$salt = "";
|
||||||
for ($i = 0; $i < $length; $i ++) {
|
for ($i = 0; $i < $length; $i++) {
|
||||||
$salt .= $alphabet[rand(0, strlen($alphabet) - 1)];
|
$salt .= $alphabet[rand(0, strlen($alphabet) - 1)];
|
||||||
}
|
}
|
||||||
return $salt;
|
return $salt;
|
||||||
|
@ -43,7 +48,13 @@ function generate_salt($length = 16)
|
||||||
function set_password($uid, $password)
|
function set_password($uid, $password)
|
||||||
{
|
{
|
||||||
global $crypt_alg;
|
global $crypt_alg;
|
||||||
$result = sql_query("UPDATE `User` SET `Passwort` = '" . sql_escape(crypt($password, $crypt_alg . '$' . generate_salt(16) . '$')) . "', `password_recovery_token`=NULL WHERE `UID` = " . intval($uid) . " LIMIT 1");
|
$result = sql_query("
|
||||||
|
UPDATE `User`
|
||||||
|
SET `Passwort` = '" . sql_escape(crypt($password, $crypt_alg . '$' . generate_salt(16) . '$')) . "',
|
||||||
|
`password_recovery_token`=NULL
|
||||||
|
WHERE `UID` = " . intval($uid) . "
|
||||||
|
LIMIT 1
|
||||||
|
");
|
||||||
if ($result === false) {
|
if ($result === false) {
|
||||||
engelsystem_error('Unable to update password.');
|
engelsystem_error('Unable to update password.');
|
||||||
}
|
}
|
||||||
|
@ -59,18 +70,24 @@ function verify_password($password, $salt, $uid = false)
|
||||||
global $crypt_alg;
|
global $crypt_alg;
|
||||||
$correct = false;
|
$correct = false;
|
||||||
if (substr($salt, 0, 1) == '$') { // new-style crypt()
|
if (substr($salt, 0, 1) == '$') { // new-style crypt()
|
||||||
$correct = crypt($password, $salt) == $salt;
|
$correct = crypt($password, $salt) == $salt;
|
||||||
} elseif (substr($salt, 0, 7) == '{crypt}') { // old-style crypt() with DES and static salt - not used anymore
|
} elseif (substr($salt, 0, 7) == '{crypt}') { // old-style crypt() with DES and static salt - not used anymore
|
||||||
$correct = crypt($password, '77') == $salt;
|
$correct = crypt($password, '77') == $salt;
|
||||||
} elseif (strlen($salt) == 32) { // old-style md5 without salt - not used anymore
|
} elseif (strlen($salt) == 32) { // old-style md5 without salt - not used anymore
|
||||||
$correct = md5($password) == $salt;
|
$correct = md5($password) == $salt;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($correct && substr($salt, 0, strlen($crypt_alg)) != $crypt_alg && $uid) {
|
if ($correct && substr($salt, 0, strlen($crypt_alg)) != $crypt_alg && $uid) {
|
||||||
// this password is stored in another format than we want it to be.
|
// this password is stored in another format than we want it to be.
|
||||||
// let's update it!
|
// let's update it!
|
||||||
// we duplicate the query from the above set_password() function to have the extra safety of checking the old hash
|
// we duplicate the query from the above set_password() function to have the extra safety of checking the old hash
|
||||||
sql_query("UPDATE `User` SET `Passwort` = '" . sql_escape(crypt($password, $crypt_alg . '$' . generate_salt() . '$')) . "' WHERE `UID` = " . intval($uid) . " AND `Passwort` = '" . sql_escape($salt) . "' LIMIT 1");
|
sql_query("
|
||||||
|
UPDATE `User`
|
||||||
|
SET `Passwort` = '" . sql_escape(crypt($password, $crypt_alg . '$' . generate_salt() . '$')) . "'
|
||||||
|
WHERE `UID` = " . intval($uid) . "
|
||||||
|
AND `Passwort` = '" . sql_escape($salt) . "'
|
||||||
|
LIMIT 1
|
||||||
|
");
|
||||||
}
|
}
|
||||||
return $correct;
|
return $correct;
|
||||||
}
|
}
|
||||||
|
@ -78,7 +95,14 @@ function verify_password($password, $salt, $uid = false)
|
||||||
function privileges_for_user($user_id)
|
function privileges_for_user($user_id)
|
||||||
{
|
{
|
||||||
$privileges = [];
|
$privileges = [];
|
||||||
$user_privs = sql_select("SELECT `Privileges`.`name` FROM `User` JOIN `UserGroups` ON (`User`.`UID` = `UserGroups`.`uid`) JOIN `GroupPrivileges` ON (`UserGroups`.`group_id` = `GroupPrivileges`.`group_id`) JOIN `Privileges` ON (`GroupPrivileges`.`privilege_id` = `Privileges`.`id`) WHERE `User`.`UID`='" . sql_escape($user_id) . "'");
|
$user_privs = sql_select("
|
||||||
|
SELECT `Privileges`.`name`
|
||||||
|
FROM `User`
|
||||||
|
JOIN `UserGroups` ON (`User`.`UID` = `UserGroups`.`uid`)
|
||||||
|
JOIN `GroupPrivileges` ON (`UserGroups`.`group_id` = `GroupPrivileges`.`group_id`)
|
||||||
|
JOIN `Privileges` ON (`GroupPrivileges`.`privilege_id` = `Privileges`.`id`)
|
||||||
|
WHERE `User`.`UID`='" . sql_escape($user_id) . "'
|
||||||
|
");
|
||||||
foreach ($user_privs as $user_priv) {
|
foreach ($user_privs as $user_priv) {
|
||||||
$privileges[] = $user_priv['name'];
|
$privileges[] = $user_priv['name'];
|
||||||
}
|
}
|
||||||
|
@ -88,7 +112,12 @@ function privileges_for_user($user_id)
|
||||||
function privileges_for_group($group_id)
|
function privileges_for_group($group_id)
|
||||||
{
|
{
|
||||||
$privileges = [];
|
$privileges = [];
|
||||||
$groups_privs = sql_select("SELECT * FROM `GroupPrivileges` JOIN `Privileges` ON (`GroupPrivileges`.`privilege_id` = `Privileges`.`id`) WHERE `group_id`='" . sql_escape($group_id) . "'");
|
$groups_privs = sql_select("
|
||||||
|
SELECT *
|
||||||
|
FROM `GroupPrivileges`
|
||||||
|
JOIN `Privileges` ON (`GroupPrivileges`.`privilege_id` = `Privileges`.`id`)
|
||||||
|
WHERE `group_id`='" . sql_escape($group_id) . "'
|
||||||
|
");
|
||||||
foreach ($groups_privs as $guest_priv) {
|
foreach ($groups_privs as $guest_priv) {
|
||||||
$privileges[] = $guest_priv['name'];
|
$privileges[] = $guest_priv['name'];
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,9 +50,9 @@ function form_spinner($name, $label, $value)
|
||||||
* Name of the parameter
|
* Name of the parameter
|
||||||
* @param string $label
|
* @param string $label
|
||||||
* Label
|
* Label
|
||||||
* @param int $value
|
* @param int $value
|
||||||
* Unix Timestamp
|
* Unix Timestamp
|
||||||
* @param int $min_date
|
* @param int $min_date
|
||||||
* Earliest possible date
|
* Earliest possible date
|
||||||
* @return HTML
|
* @return HTML
|
||||||
*/
|
*/
|
||||||
|
@ -111,7 +111,8 @@ function form_checkboxes($name, $label, $items, $selected)
|
||||||
* @param
|
* @param
|
||||||
* items Array mit den Beschriftungen der Zeilen
|
* items Array mit den Beschriftungen der Zeilen
|
||||||
* @param
|
* @param
|
||||||
* selected Mehrdimensionales Array, wobei $selected[foo] ein Array der in der Datenreihe foo markierten Checkboxen ist
|
* selected Mehrdimensionales Array, wobei $selected[foo] ein Array der in der Datenreihe foo markierten
|
||||||
|
* Checkboxen ist
|
||||||
* @param
|
* @param
|
||||||
* disabled Wie selected, nur dass die entsprechenden Checkboxen deaktiviert statt markiert sind
|
* disabled Wie selected, nur dass die entsprechenden Checkboxen deaktiviert statt markiert sind
|
||||||
*/
|
*/
|
||||||
|
@ -127,7 +128,7 @@ function form_multi_checkboxes($names, $label, $items, $selected, $disabled = []
|
||||||
foreach ($names as $name => $title) {
|
foreach ($names as $name => $title) {
|
||||||
$dom_id = $name . '_' . $key;
|
$dom_id = $name . '_' . $key;
|
||||||
$sel = array_search($key, $selected[$name]) !== false ? ' checked="checked"' : "";
|
$sel = array_search($key, $selected[$name]) !== false ? ' checked="checked"' : "";
|
||||||
if (! empty($disabled) && ! empty($disabled[$name]) && array_search($key, $disabled[$name]) !== false) {
|
if (!empty($disabled) && !empty($disabled[$name]) && array_search($key, $disabled[$name]) !== false) {
|
||||||
$sel .= ' disabled="disabled"';
|
$sel .= ' disabled="disabled"';
|
||||||
}
|
}
|
||||||
$html .= '<td style="text-align: center;"><input type="checkbox" id="' . $dom_id . '" name="' . $name . '[]" value="' . $key . '"' . $sel . ' /></td>';
|
$html .= '<td style="text-align: center;"><input type="checkbox" id="' . $dom_id . '" name="' . $name . '[]" value="' . $key . '"' . $sel . ' /></td>';
|
||||||
|
@ -173,7 +174,10 @@ function form_info($label, $text = "")
|
||||||
*/
|
*/
|
||||||
function form_submit($name, $label)
|
function form_submit($name, $label)
|
||||||
{
|
{
|
||||||
return form_element('<input class="btn btn-primary" type="submit" name="' . $name . '" value="' . $label . '" />', "");
|
return form_element(
|
||||||
|
'<input class="btn btn-primary" type="submit" name="' . $name . '" value="' . $label . '" />',
|
||||||
|
""
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -182,17 +186,21 @@ function form_submit($name, $label)
|
||||||
function form_text($name, $label, $value, $disabled = false)
|
function form_text($name, $label, $value, $disabled = false)
|
||||||
{
|
{
|
||||||
$disabled = $disabled ? ' disabled="disabled"' : '';
|
$disabled = $disabled ? ' disabled="disabled"' : '';
|
||||||
return form_element($label, '<input class="form-control" id="form_' . $name . '" type="text" name="' . $name . '" value="' . htmlspecialchars($value) . '" ' . $disabled . '/>', 'form_' . $name);
|
return form_element(
|
||||||
|
$label,
|
||||||
|
'<input class="form-control" id="form_' . $name . '" type="text" name="' . $name . '" value="' . htmlspecialchars($value) . '" ' . $disabled . '/>',
|
||||||
|
'form_' . $name
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renders a text input with placeholder instead of label.
|
* Renders a text input with placeholder instead of label.
|
||||||
*
|
*
|
||||||
* @param String $name
|
* @param String $name
|
||||||
* Input name
|
* Input name
|
||||||
* @param String $placeholder
|
* @param String $placeholder
|
||||||
* Placeholder
|
* Placeholder
|
||||||
* @param String $value
|
* @param String $value
|
||||||
* The value
|
* The value
|
||||||
* @param Boolean $disabled
|
* @param Boolean $disabled
|
||||||
* Is the field enabled?
|
* Is the field enabled?
|
||||||
|
@ -200,7 +208,8 @@ function form_text($name, $label, $value, $disabled = false)
|
||||||
function form_text_placeholder($name, $placeholder, $value, $disabled = false)
|
function form_text_placeholder($name, $placeholder, $value, $disabled = false)
|
||||||
{
|
{
|
||||||
$disabled = $disabled ? ' disabled="disabled"' : '';
|
$disabled = $disabled ? ' disabled="disabled"' : '';
|
||||||
return form_element('', '<input class="form-control" id="form_' . $name . '" type="text" name="' . $name . '" value="' . htmlspecialchars($value) . '" placeholder="' . $placeholder . '" ' . $disabled . '/>');
|
return form_element('',
|
||||||
|
'<input class="form-control" id="form_' . $name . '" type="text" name="' . $name . '" value="' . htmlspecialchars($value) . '" placeholder="' . $placeholder . '" ' . $disabled . '/>');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -209,7 +218,11 @@ function form_text_placeholder($name, $placeholder, $value, $disabled = false)
|
||||||
function form_email($name, $label, $value, $disabled = false)
|
function form_email($name, $label, $value, $disabled = false)
|
||||||
{
|
{
|
||||||
$disabled = $disabled ? ' disabled="disabled"' : '';
|
$disabled = $disabled ? ' disabled="disabled"' : '';
|
||||||
return form_element($label, '<input class="form-control" id="form_' . $name . '" type="email" name="' . $name . '" value="' . htmlspecialchars($value) . '" ' . $disabled . '/>', 'form_' . $name);
|
return form_element(
|
||||||
|
$label,
|
||||||
|
'<input class="form-control" id="form_' . $name . '" type="email" name="' . $name . '" value="' . htmlspecialchars($value) . '" ' . $disabled . '/>',
|
||||||
|
'form_' . $name
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -226,7 +239,11 @@ function form_file($name, $label)
|
||||||
function form_password($name, $label, $disabled = false)
|
function form_password($name, $label, $disabled = false)
|
||||||
{
|
{
|
||||||
$disabled = $disabled ? ' disabled="disabled"' : '';
|
$disabled = $disabled ? ' disabled="disabled"' : '';
|
||||||
return form_element($label, '<input class="form-control" id="form_' . $name . '" type="password" name="' . $name . '" value="" ' . $disabled . '/>', 'form_' . $name);
|
return form_element(
|
||||||
|
$label,
|
||||||
|
'<input class="form-control" id="form_' . $name . '" type="password" name="' . $name . '" value="" ' . $disabled . '/>',
|
||||||
|
'form_' . $name
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -235,7 +252,11 @@ function form_password($name, $label, $disabled = false)
|
||||||
function form_password_placeholder($name, $placeholder, $disabled = false)
|
function form_password_placeholder($name, $placeholder, $disabled = false)
|
||||||
{
|
{
|
||||||
$disabled = $disabled ? ' disabled="disabled"' : '';
|
$disabled = $disabled ? ' disabled="disabled"' : '';
|
||||||
return form_element('', '<input class="form-control" id="form_' . $name . '" type="password" name="' . $name . '" value="" placeholder="' . $placeholder . '" ' . $disabled . '/>', 'form_' . $name);
|
return form_element(
|
||||||
|
'',
|
||||||
|
'<input class="form-control" id="form_' . $name . '" type="password" name="' . $name . '" value="" placeholder="' . $placeholder . '" ' . $disabled . '/>',
|
||||||
|
'form_' . $name
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -244,7 +265,11 @@ function form_password_placeholder($name, $placeholder, $disabled = false)
|
||||||
function form_textarea($name, $label, $value, $disabled = false)
|
function form_textarea($name, $label, $value, $disabled = false)
|
||||||
{
|
{
|
||||||
$disabled = $disabled ? ' disabled="disabled"' : '';
|
$disabled = $disabled ? ' disabled="disabled"' : '';
|
||||||
return form_element($label, '<textarea rows="5" class="form-control" id="form_' . $name . '" type="text" name="' . $name . '" ' . $disabled . '>' . $value . '</textarea>', 'form_' . $name);
|
return form_element(
|
||||||
|
$label,
|
||||||
|
'<textarea rows="5" class="form-control" id="form_' . $name . '" type="text" name="' . $name . '" ' . $disabled . '>' . $value . '</textarea>',
|
||||||
|
'form_' . $name
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -263,7 +288,7 @@ function form_element($label, $input, $for = "")
|
||||||
if ($label == '') {
|
if ($label == '') {
|
||||||
return '<div class="form-group">' . $input . '</div>';
|
return '<div class="form-group">' . $input . '</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
return '<div class="form-group">' . '<label for="' . $for . '">' . $label . '</label>' . $input . '</div>';
|
return '<div class="form-group">' . '<label for="' . $for . '">' . $label . '</label>' . $input . '</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -281,7 +306,7 @@ function html_options($name, $options, $selected = "")
|
||||||
foreach ($options as $value => $label) {
|
foreach ($options as $value => $label) {
|
||||||
$html .= '<input type="radio"' . ($value == $selected ? ' checked="checked"' : '') . ' name="' . $name . '" value="' . $value . '"> ' . $label;
|
$html .= '<input type="radio"' . ($value == $selected ? ' checked="checked"' : '') . ' name="' . $name . '" value="' . $value . '"> ' . $label;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $html;
|
return $html;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
function engelsystem_log($message)
|
function engelsystem_log($message)
|
||||||
{
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
$nick = "Guest";
|
$nick = "Guest";
|
||||||
if (isset($user)) {
|
if (isset($user)) {
|
||||||
$nick = User_Nick_render($user);
|
$nick = User_Nick_render($user);
|
||||||
|
@ -27,13 +27,13 @@ function debug_string_backtrace()
|
||||||
debug_print_backtrace();
|
debug_print_backtrace();
|
||||||
$trace = ob_get_contents();
|
$trace = ob_get_contents();
|
||||||
ob_end_clean();
|
ob_end_clean();
|
||||||
|
|
||||||
// Remove first item from backtrace as it's this function which
|
// Remove first item from backtrace as it's this function which
|
||||||
// is redundant.
|
// is redundant.
|
||||||
$trace = preg_replace('/^#0\s+' . __FUNCTION__ . "[^\n]*\n/", '', $trace, 1);
|
$trace = preg_replace('/^#0\s+' . __FUNCTION__ . "[^\n]*\n/", '', $trace, 1);
|
||||||
|
|
||||||
// Renumber backtrace items.
|
// Renumber backtrace items.
|
||||||
// $trace = preg_replace('/^#(\d+)/me', '\'#\' . ($1 - 1)', $trace);
|
// $trace = preg_replace('/^#(\d+)/me', '\'#\' . ($1 - 1)', $trace);
|
||||||
|
|
||||||
return $trace;
|
return $trace;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,10 @@ function page_link_to($page = "")
|
||||||
|
|
||||||
function page_link_to_absolute($page)
|
function page_link_to_absolute($page)
|
||||||
{
|
{
|
||||||
return (isset($_SERVER['HTTPS']) ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . preg_replace("/\?.*$/", '', $_SERVER['REQUEST_URI']) . page_link_to($page);
|
return (isset($_SERVER['HTTPS']) ? 'https' : 'http') . '://'
|
||||||
|
. $_SERVER['HTTP_HOST']
|
||||||
|
. preg_replace("/\?.*$/", '', $_SERVER['REQUEST_URI'])
|
||||||
|
. page_link_to($page);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -20,22 +23,22 @@ function page_link_to_absolute($page)
|
||||||
function header_render_hints()
|
function header_render_hints()
|
||||||
{
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
$hints_renderer = new UserHintsRenderer();
|
$hints_renderer = new UserHintsRenderer();
|
||||||
|
|
||||||
if (isset($user)) {
|
if (isset($user)) {
|
||||||
$hints_renderer->addHint(admin_new_questions());
|
$hints_renderer->addHint(admin_new_questions());
|
||||||
$hints_renderer->addHint(user_angeltypes_unconfirmed_hint());
|
$hints_renderer->addHint(user_angeltypes_unconfirmed_hint());
|
||||||
$hints_renderer->addHint(render_user_departure_date_hint());
|
$hints_renderer->addHint(render_user_departure_date_hint());
|
||||||
$hints_renderer->addHint(user_driver_license_required_hint());
|
$hints_renderer->addHint(user_driver_license_required_hint());
|
||||||
|
|
||||||
// Important hints:
|
// Important hints:
|
||||||
$hints_renderer->addHint(render_user_freeloader_hint(), true);
|
$hints_renderer->addHint(render_user_freeloader_hint(), true);
|
||||||
$hints_renderer->addHint(render_user_arrived_hint(), true);
|
$hints_renderer->addHint(render_user_arrived_hint(), true);
|
||||||
$hints_renderer->addHint(render_user_tshirt_hint(), true);
|
$hints_renderer->addHint(render_user_tshirt_hint(), true);
|
||||||
$hints_renderer->addHint(render_user_dect_hint(), true);
|
$hints_renderer->addHint(render_user_dect_hint(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $hints_renderer->render();
|
return $hints_renderer->render();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,106 +48,120 @@ function header_render_hints()
|
||||||
function header_toolbar()
|
function header_toolbar()
|
||||||
{
|
{
|
||||||
global $page, $privileges, $user;
|
global $page, $privileges, $user;
|
||||||
|
|
||||||
$toolbar_items = [];
|
$toolbar_items = [];
|
||||||
|
|
||||||
if (isset($user)) {
|
if (isset($user)) {
|
||||||
$toolbar_items[] = toolbar_item_link(page_link_to('shifts') . '&action=next', 'time', User_shift_state_render($user));
|
$toolbar_items[] = toolbar_item_link(
|
||||||
|
page_link_to('shifts') . '&action=next',
|
||||||
|
'time',
|
||||||
|
User_shift_state_render($user)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! isset($user) && in_array('register', $privileges)) {
|
if (!isset($user) && in_array('register', $privileges)) {
|
||||||
$toolbar_items[] = toolbar_item_link(page_link_to('register'), 'plus', register_title(), $page == 'register');
|
$toolbar_items[] = toolbar_item_link(page_link_to('register'), 'plus', register_title(), $page == 'register');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (in_array('login', $privileges)) {
|
if (in_array('login', $privileges)) {
|
||||||
$toolbar_items[] = toolbar_item_link(page_link_to('login'), 'log-in', login_title(), $page == 'login');
|
$toolbar_items[] = toolbar_item_link(page_link_to('login'), 'log-in', login_title(), $page == 'login');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($user) && in_array('user_messages', $privileges)) {
|
if (isset($user) && in_array('user_messages', $privileges)) {
|
||||||
$toolbar_items[] = toolbar_item_link(page_link_to('user_messages'), 'envelope', user_unread_messages());
|
$toolbar_items[] = toolbar_item_link(page_link_to('user_messages'), 'envelope', user_unread_messages());
|
||||||
}
|
}
|
||||||
|
|
||||||
$toolbar_items[] = header_render_hints();
|
$toolbar_items[] = header_render_hints();
|
||||||
if (in_array('user_myshifts', $privileges)) {
|
if (in_array('user_myshifts', $privileges)) {
|
||||||
$toolbar_items[] = toolbar_item_link(page_link_to('users') . '&action=view', ' icon-icon_angel', $user['Nick'], $page == 'users');
|
$toolbar_items[] = toolbar_item_link(
|
||||||
|
page_link_to('users') . '&action=view',
|
||||||
|
' icon-icon_angel',
|
||||||
|
$user['Nick'],
|
||||||
|
$page == 'users'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$user_submenu = make_user_submenu();
|
$user_submenu = make_user_submenu();
|
||||||
if (count($user_submenu) > 0) {
|
if (count($user_submenu) > 0) {
|
||||||
$toolbar_items[] = toolbar_dropdown('', '', $user_submenu);
|
$toolbar_items[] = toolbar_dropdown('', '', $user_submenu);
|
||||||
}
|
}
|
||||||
|
|
||||||
return toolbar($toolbar_items, true);
|
return toolbar($toolbar_items, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
function make_user_submenu()
|
function make_user_submenu()
|
||||||
{
|
{
|
||||||
global $privileges, $page;
|
global $privileges, $page;
|
||||||
|
|
||||||
$user_submenu = make_langselect();
|
$user_submenu = make_langselect();
|
||||||
|
|
||||||
if (in_array('user_settings', $privileges) || in_array('logout', $privileges)) {
|
if (in_array('user_settings', $privileges) || in_array('logout', $privileges)) {
|
||||||
$user_submenu[] = toolbar_item_divider();
|
$user_submenu[] = toolbar_item_divider();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (in_array('user_settings', $privileges)) {
|
if (in_array('user_settings', $privileges)) {
|
||||||
$user_submenu[] = toolbar_item_link(page_link_to('user_settings'), 'list-alt', settings_title(), $page == 'user_settings');
|
$user_submenu[] = toolbar_item_link(
|
||||||
|
page_link_to('user_settings'),
|
||||||
|
'list-alt',
|
||||||
|
settings_title(),
|
||||||
|
$page == 'user_settings'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (in_array('logout', $privileges)) {
|
if (in_array('logout', $privileges)) {
|
||||||
$user_submenu[] = toolbar_item_link(page_link_to('logout'), 'log-out', logout_title(), $page == 'logout');
|
$user_submenu[] = toolbar_item_link(page_link_to('logout'), 'log-out', logout_title(), $page == 'logout');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $user_submenu;
|
return $user_submenu;
|
||||||
}
|
}
|
||||||
|
|
||||||
function make_navigation()
|
function make_navigation()
|
||||||
{
|
{
|
||||||
global $page, $privileges;
|
global $page, $privileges;
|
||||||
|
|
||||||
$menu = [];
|
$menu = [];
|
||||||
$pages = [
|
$pages = [
|
||||||
"news" => news_title(),
|
"news" => news_title(),
|
||||||
"user_meetings" => meetings_title(),
|
"user_meetings" => meetings_title(),
|
||||||
"user_shifts" => shifts_title(),
|
"user_shifts" => shifts_title(),
|
||||||
"angeltypes" => angeltypes_title(),
|
"angeltypes" => angeltypes_title(),
|
||||||
"user_questions" => questions_title()
|
"user_questions" => questions_title()
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach ($pages as $menu_page => $title) {
|
foreach ($pages as $menu_page => $title) {
|
||||||
if (in_array($menu_page, $privileges)) {
|
if (in_array($menu_page, $privileges)) {
|
||||||
$menu[] = toolbar_item_link(page_link_to($menu_page), '', $title, $menu_page == $page);
|
$menu[] = toolbar_item_link(page_link_to($menu_page), '', $title, $menu_page == $page);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$menu = make_room_navigation($menu);
|
$menu = make_room_navigation($menu);
|
||||||
|
|
||||||
$admin_menu = [];
|
$admin_menu = [];
|
||||||
$admin_pages = [
|
$admin_pages = [
|
||||||
"admin_arrive" => admin_arrive_title(),
|
"admin_arrive" => admin_arrive_title(),
|
||||||
"admin_active" => admin_active_title(),
|
"admin_active" => admin_active_title(),
|
||||||
"admin_user" => admin_user_title(),
|
"admin_user" => admin_user_title(),
|
||||||
"admin_free" => admin_free_title(),
|
"admin_free" => admin_free_title(),
|
||||||
"admin_questions" => admin_questions_title(),
|
"admin_questions" => admin_questions_title(),
|
||||||
"shifttypes" => shifttypes_title(),
|
"shifttypes" => shifttypes_title(),
|
||||||
"admin_shifts" => admin_shifts_title(),
|
"admin_shifts" => admin_shifts_title(),
|
||||||
"admin_rooms" => admin_rooms_title(),
|
"admin_rooms" => admin_rooms_title(),
|
||||||
"admin_groups" => admin_groups_title(),
|
"admin_groups" => admin_groups_title(),
|
||||||
"admin_import" => admin_import_title(),
|
"admin_import" => admin_import_title(),
|
||||||
"admin_log" => admin_log_title(),
|
"admin_log" => admin_log_title(),
|
||||||
"admin_event_config" => event_config_title()
|
"admin_event_config" => event_config_title()
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach ($admin_pages as $menu_page => $title) {
|
foreach ($admin_pages as $menu_page => $title) {
|
||||||
if (in_array($menu_page, $privileges)) {
|
if (in_array($menu_page, $privileges)) {
|
||||||
$admin_menu[] = toolbar_item_link(page_link_to($menu_page), '', $title, $menu_page == $page);
|
$admin_menu[] = toolbar_item_link(page_link_to($menu_page), '', $title, $menu_page == $page);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($admin_menu) > 0) {
|
if (count($admin_menu) > 0) {
|
||||||
$menu[] = toolbar_dropdown('', _("Admin"), $admin_menu);
|
$menu[] = toolbar_dropdown('', _("Admin"), $admin_menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
return toolbar($menu);
|
return toolbar($menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,11 +174,11 @@ function make_navigation()
|
||||||
function make_room_navigation($menu)
|
function make_room_navigation($menu)
|
||||||
{
|
{
|
||||||
global $privileges;
|
global $privileges;
|
||||||
|
|
||||||
if (! in_array('view_rooms', $privileges)) {
|
if (!in_array('view_rooms', $privileges)) {
|
||||||
return $menu;
|
return $menu;
|
||||||
}
|
}
|
||||||
|
|
||||||
$rooms = Rooms();
|
$rooms = Rooms();
|
||||||
$room_menu = [];
|
$room_menu = [];
|
||||||
if (in_array('admin_rooms', $privileges)) {
|
if (in_array('admin_rooms', $privileges)) {
|
||||||
|
|
|
@ -8,27 +8,27 @@ use Engelsystem\ValidationResult;
|
||||||
/**
|
/**
|
||||||
* Parse a date from da day and a time textfield.
|
* Parse a date from da day and a time textfield.
|
||||||
*
|
*
|
||||||
* @param string $date_name
|
* @param string $date_name
|
||||||
* Name of the textfield containing the day (format Y-m-d)
|
* Name of the textfield containing the day (format Y-m-d)
|
||||||
* @param string $time_name
|
* @param string $time_name
|
||||||
* Name of the textfield containing the time (format H:i)
|
* Name of the textfield containing the time (format H:i)
|
||||||
* @param string[] $allowed_days
|
* @param string[] $allowed_days
|
||||||
* List of allowed days in format Y-m-d
|
* List of allowed days in format Y-m-d
|
||||||
* @param int $default_value
|
* @param int $default_value
|
||||||
* Default value unix timestamp
|
* Default value unix timestamp
|
||||||
*/
|
*/
|
||||||
function check_request_datetime($date_name, $time_name, $allowed_days, $default_value)
|
function check_request_datetime($date_name, $time_name, $allowed_days, $default_value)
|
||||||
{
|
{
|
||||||
$time = date("H:i", $default_value);
|
$time = date("H:i", $default_value);
|
||||||
$day = date("Y-m-d", $default_value);
|
$day = date("Y-m-d", $default_value);
|
||||||
|
|
||||||
if (isset($_REQUEST[$time_name]) && preg_match('#^\d{1,2}:\d\d$#', trim($_REQUEST[$time_name]))) {
|
if (isset($_REQUEST[$time_name]) && preg_match('#^\d{1,2}:\d\d$#', trim($_REQUEST[$time_name]))) {
|
||||||
$time = trim($_REQUEST[$time_name]);
|
$time = trim($_REQUEST[$time_name]);
|
||||||
}
|
}
|
||||||
if (isset($_REQUEST[$date_name]) && in_array($_REQUEST[$date_name], $allowed_days)) {
|
if (isset($_REQUEST[$date_name]) && in_array($_REQUEST[$date_name], $allowed_days)) {
|
||||||
$day = $_REQUEST[$date_name];
|
$day = $_REQUEST[$date_name];
|
||||||
}
|
}
|
||||||
|
|
||||||
return parse_date("Y-m-d H:i", $day . " " . $time);
|
return parse_date("Y-m-d H:i", $day . " " . $time);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ function raw_output($output)
|
||||||
/**
|
/**
|
||||||
* Helper function for transforming list of entities into array for select boxes.
|
* Helper function for transforming list of entities into array for select boxes.
|
||||||
*
|
*
|
||||||
* @param array $data
|
* @param array $data
|
||||||
* The data array
|
* The data array
|
||||||
* @param string $key_name
|
* @param string $key_name
|
||||||
* name of the column to use as id/key
|
* name of the column to use as id/key
|
||||||
|
@ -94,9 +94,9 @@ function select_array($data, $key_name, $value_name)
|
||||||
* Returns an int[] from given request param name.
|
* Returns an int[] from given request param name.
|
||||||
*
|
*
|
||||||
* @param String $name
|
* @param String $name
|
||||||
* Name of the request param
|
* Name of the request param
|
||||||
* @param array<int> $default
|
* @param array <int> $default
|
||||||
* Default return value, if param is not set
|
* Default return value, if param is not set
|
||||||
*/
|
*/
|
||||||
function check_request_int_array($name, $default = [])
|
function check_request_int_array($name, $default = [])
|
||||||
{
|
{
|
||||||
|
@ -110,9 +110,9 @@ function check_request_int_array($name, $default = [])
|
||||||
* Checks if given request item (name) can be parsed to a date.
|
* Checks if given request item (name) can be parsed to a date.
|
||||||
* If not parsable, given error message is put into msg() and null is returned.
|
* If not parsable, given error message is put into msg() and null is returned.
|
||||||
*
|
*
|
||||||
* @param string $input
|
* @param string $input
|
||||||
* String to be parsed into a date.
|
* String to be parsed into a date.
|
||||||
* @param string $error_message
|
* @param string $error_message
|
||||||
* the error message displayed if $input is not parsable
|
* the error message displayed if $input is not parsable
|
||||||
* @param boolean $null_allowed
|
* @param boolean $null_allowed
|
||||||
* is a null value allowed?
|
* is a null value allowed?
|
||||||
|
@ -120,7 +120,7 @@ function check_request_int_array($name, $default = [])
|
||||||
*/
|
*/
|
||||||
function check_request_date($name, $error_message = null, $null_allowed = false)
|
function check_request_date($name, $error_message = null, $null_allowed = false)
|
||||||
{
|
{
|
||||||
if (! isset($_REQUEST[$name])) {
|
if (!isset($_REQUEST[$name])) {
|
||||||
return new ValidationResult($null_allowed, null);
|
return new ValidationResult($null_allowed, null);
|
||||||
}
|
}
|
||||||
return check_date($_REQUEST[$name], $error_message, $null_allowed);
|
return check_date($_REQUEST[$name], $error_message, $null_allowed);
|
||||||
|
@ -130,9 +130,9 @@ function check_request_date($name, $error_message = null, $null_allowed = false)
|
||||||
* Checks if given string can be parsed to a date.
|
* Checks if given string can be parsed to a date.
|
||||||
* If not parsable, given error message is put into msg() and null is returned.
|
* If not parsable, given error message is put into msg() and null is returned.
|
||||||
*
|
*
|
||||||
* @param string $input
|
* @param string $input
|
||||||
* String to be parsed into a date.
|
* String to be parsed into a date.
|
||||||
* @param string $error_message
|
* @param string $error_message
|
||||||
* the error message displayed if $input is not parsable
|
* the error message displayed if $input is not parsable
|
||||||
* @param boolean $null_allowed
|
* @param boolean $null_allowed
|
||||||
* is a null value allowed?
|
* is a null value allowed?
|
||||||
|
@ -146,7 +146,7 @@ function check_date($input, $error_message = null, $null_allowed = false)
|
||||||
if ($null_allowed) {
|
if ($null_allowed) {
|
||||||
return new ValidationResult(true, null);
|
return new ValidationResult(true, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
error($error_message);
|
error($error_message);
|
||||||
return new ValidationResult(false, null);
|
return new ValidationResult(false, null);
|
||||||
}
|
}
|
||||||
|
@ -198,5 +198,5 @@ function strip_item($item)
|
||||||
*/
|
*/
|
||||||
function check_email($email)
|
function check_email($email)
|
||||||
{
|
{
|
||||||
return (bool) filter_var($email, FILTER_VALIDATE_EMAIL);
|
return (bool)filter_var($email, FILTER_VALIDATE_EMAIL);
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,7 +95,7 @@ function toolbar_pills($items)
|
||||||
* @param string $href
|
* @param string $href
|
||||||
* @param string $glyphicon
|
* @param string $glyphicon
|
||||||
* @param string $label
|
* @param string $label
|
||||||
* @param bool $selected
|
* @param bool $selected
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function toolbar_item_link($href, $glyphicon, $label, $selected = false)
|
function toolbar_item_link($href, $glyphicon, $label, $selected = false)
|
||||||
|
@ -158,18 +158,18 @@ function page_with_title($title, $elements)
|
||||||
function table($columns, $rows_raw, $data = true)
|
function table($columns, $rows_raw, $data = true)
|
||||||
{
|
{
|
||||||
// If only one column is given
|
// If only one column is given
|
||||||
if (! is_array($columns)) {
|
if (!is_array($columns)) {
|
||||||
$rows = [];
|
$rows = [];
|
||||||
foreach ($rows_raw as $row) {
|
foreach ($rows_raw as $row) {
|
||||||
$rows[] = [
|
$rows[] = [
|
||||||
'col' => $row
|
'col' => $row
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
return render_table([
|
return render_table([
|
||||||
'col' => $columns
|
'col' => $columns
|
||||||
], $rows, $data);
|
], $rows, $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
return render_table($columns, $rows_raw, $data);
|
return render_table($columns, $rows_raw, $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,7 +182,7 @@ function render_table($columns, $rows, $data = true)
|
||||||
if (count($rows) == 0) {
|
if (count($rows) == 0) {
|
||||||
return info(_("No data found."), true);
|
return info(_("No data found."), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
$html = '<table class="table table-striped' . ($data ? ' data' : '') . '">';
|
$html = '<table class="table table-striped' . ($data ? ' data' : '') . '">';
|
||||||
$html .= '<thead><tr>';
|
$html .= '<thead><tr>';
|
||||||
foreach ($columns as $key => $column) {
|
foreach ($columns as $key => $column) {
|
||||||
|
@ -255,7 +255,9 @@ function shorten($str, $length = 50)
|
||||||
if (strlen($str) < $length) {
|
if (strlen($str) < $length) {
|
||||||
return $str;
|
return $str;
|
||||||
}
|
}
|
||||||
return '<span title="' . htmlentities($str, ENT_COMPAT, 'UTF-8') . '">' . substr($str, 0, $length - 3) . '...</span>';
|
return '<span title="' . htmlentities($str, ENT_COMPAT, 'UTF-8') . '">'
|
||||||
|
. substr($str, 0, $length - 3)
|
||||||
|
. '...</span>';
|
||||||
}
|
}
|
||||||
|
|
||||||
function table_body($array)
|
function table_body($array)
|
||||||
|
@ -297,6 +299,6 @@ function ReplaceSmilies($neueckig)
|
||||||
$neueckig = str_replace(";P", "<img src=\"pic/smiles/icon_mad.gif\">", $neueckig);
|
$neueckig = str_replace(";P", "<img src=\"pic/smiles/icon_mad.gif\">", $neueckig);
|
||||||
$neueckig = str_replace(";oP", "<img src=\"pic/smiles/icon_mad.gif\">", $neueckig);
|
$neueckig = str_replace(";oP", "<img src=\"pic/smiles/icon_mad.gif\">", $neueckig);
|
||||||
$neueckig = str_replace("?)", "<img src=\"pic/smiles/icon_question.gif\">", $neueckig);
|
$neueckig = str_replace("?)", "<img src=\"pic/smiles/icon_question.gif\">", $neueckig);
|
||||||
|
|
||||||
return $neueckig;
|
return $neueckig;
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,12 +42,16 @@ function AngelType_render_membership($user_angeltype)
|
||||||
function AngelType_delete_view($angeltype)
|
function AngelType_delete_view($angeltype)
|
||||||
{
|
{
|
||||||
return page_with_title(sprintf(_("Delete angeltype %s"), $angeltype['name']), [
|
return page_with_title(sprintf(_("Delete angeltype %s"), $angeltype['name']), [
|
||||||
info(sprintf(_("Do you want to delete angeltype %s?"), $angeltype['name']), true),
|
info(sprintf(_("Do you want to delete angeltype %s?"), $angeltype['name']), true),
|
||||||
buttons([
|
buttons([
|
||||||
button(page_link_to('angeltypes'), _("cancel"), 'cancel'),
|
button(page_link_to('angeltypes'), _("cancel"), 'cancel'),
|
||||||
button(page_link_to('angeltypes') . '&action=delete&angeltype_id=' . $angeltype['id'] . '&confirmed', _("delete"), 'ok')
|
button(
|
||||||
])
|
page_link_to('angeltypes') . '&action=delete&angeltype_id=' . $angeltype['id'] . '&confirmed',
|
||||||
]);
|
_("delete"),
|
||||||
|
'ok'
|
||||||
|
)
|
||||||
|
])
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -55,31 +59,46 @@ function AngelType_delete_view($angeltype)
|
||||||
*
|
*
|
||||||
* @param Angeltype $angeltype
|
* @param Angeltype $angeltype
|
||||||
* The angeltype to edit
|
* The angeltype to edit
|
||||||
* @param boolean $supporter_mode
|
* @param boolean $supporter_mode
|
||||||
* Is the user a supporter of this angeltype?
|
* Is the user a supporter of this angeltype?
|
||||||
*/
|
*/
|
||||||
function AngelType_edit_view($angeltype, $supporter_mode)
|
function AngelType_edit_view($angeltype, $supporter_mode)
|
||||||
{
|
{
|
||||||
$contact_info = AngelType_contact_info($angeltype);
|
$contact_info = AngelType_contact_info($angeltype);
|
||||||
return page_with_title(sprintf(_("Edit %s"), $angeltype['name']), [
|
return page_with_title(sprintf(_("Edit %s"), $angeltype['name']), [
|
||||||
buttons([
|
buttons([
|
||||||
button(page_link_to('angeltypes'), _("Angeltypes"), 'back')
|
button(page_link_to('angeltypes'), _("Angeltypes"), 'back')
|
||||||
]),
|
]),
|
||||||
msg(),
|
msg(),
|
||||||
form([
|
form([
|
||||||
$supporter_mode ? form_info(_("Name"), $angeltype['name']) : form_text('name', _("Name"), $angeltype['name']),
|
$supporter_mode
|
||||||
$supporter_mode ? form_info(_("Restricted"), $angeltype['restricted'] ? _("Yes") : _("No")) : form_checkbox('restricted', _("Restricted"), $angeltype['restricted']),
|
? form_info(_("Name"), $angeltype['name'])
|
||||||
$supporter_mode ? form_info(_("No Self Sign Up"), $angeltype['no_self_signup'] ? _("Yes") : _("No")) : form_checkbox('no_self_signup', _("No Self Sign Up"), $angeltype['no_self_signup']),
|
: form_text('name', _("Name"), $angeltype['name']),
|
||||||
$supporter_mode ? form_info(_("Requires driver license"), $angeltype['requires_driver_license'] ? _("Yes") : _("No")) : form_checkbox('requires_driver_license', _("Requires driver license"), $angeltype['requires_driver_license']),
|
$supporter_mode
|
||||||
//form_text('contact_name', _("Name"), $angeltype['contact_name']),
|
? form_info(_("Restricted"), $angeltype['restricted'] ? _("Yes") : _("No"))
|
||||||
//form_text('contact_dect', _("DECT"), $angeltype['contact_dect']),
|
: form_checkbox('restricted', _("Restricted"), $angeltype['restricted']),
|
||||||
//form_text('contact_email', _("E-Mail"), $angeltype['contact_email']),
|
$supporter_mode
|
||||||
form_info("", _("Restricted angel types can only be used by an angel if enabled by a supporter (double opt-in).")),
|
? form_info(_("No Self Sign Up"), $angeltype['no_self_signup'] ? _("Yes") : _("No"))
|
||||||
form_textarea('description', _("Description"), $angeltype['description']),
|
: form_checkbox('no_self_signup', _("No Self Sign Up"), $angeltype['no_self_signup']),
|
||||||
form_info("", _("Please use markdown for the description.")),
|
$supporter_mode
|
||||||
form_submit('submit', _("Save"))
|
? form_info(_("Requires driver license"), $angeltype['requires_driver_license'] ? _("Yes") : _("No"))
|
||||||
])
|
: form_checkbox(
|
||||||
]);
|
'requires_driver_license',
|
||||||
|
_("Requires driver license"),
|
||||||
|
$angeltype['requires_driver_license']
|
||||||
|
),
|
||||||
|
//form_text('contact_name', _("Name"), $angeltype['contact_name']),
|
||||||
|
//form_text('contact_dect', _("DECT"), $angeltype['contact_dect']),
|
||||||
|
//form_text('contact_email', _("E-Mail"), $angeltype['contact_email']),
|
||||||
|
form_info(
|
||||||
|
"",
|
||||||
|
_("Restricted angel types can only be used by an angel if enabled by a supporter (double opt-in).")
|
||||||
|
),
|
||||||
|
form_textarea('description', _("Description"), $angeltype['description']),
|
||||||
|
form_info("", _("Please use markdown for the description.")),
|
||||||
|
form_submit('submit', _("Save"))
|
||||||
|
])
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -88,33 +107,49 @@ function AngelType_edit_view($angeltype, $supporter_mode)
|
||||||
function AngelType_view_buttons($angeltype, $user_angeltype, $admin_angeltypes, $supporter, $user_driver_license, $user)
|
function AngelType_view_buttons($angeltype, $user_angeltype, $admin_angeltypes, $supporter, $user_driver_license, $user)
|
||||||
{
|
{
|
||||||
$buttons = [
|
$buttons = [
|
||||||
button(page_link_to('angeltypes'), _("Angeltypes"), 'back')
|
button(page_link_to('angeltypes'), _("Angeltypes"), 'back')
|
||||||
];
|
];
|
||||||
|
|
||||||
if ($angeltype['requires_driver_license']) {
|
if ($angeltype['requires_driver_license']) {
|
||||||
$buttons[] = button(user_driver_license_edit_link($user), glyph("road") . _("my driving license"));
|
$buttons[] = button(user_driver_license_edit_link($user), glyph("road") . _("my driving license"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($user_angeltype == null) {
|
if ($user_angeltype == null) {
|
||||||
$buttons[] = button(page_link_to('user_angeltypes') . '&action=add&angeltype_id=' . $angeltype['id'], _("join"), 'add');
|
$buttons[] = button(
|
||||||
|
page_link_to('user_angeltypes') . '&action=add&angeltype_id=' . $angeltype['id'],
|
||||||
|
_("join"),
|
||||||
|
'add'
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
if ($angeltype['requires_driver_license'] && $user_driver_license == null) {
|
if ($angeltype['requires_driver_license'] && $user_driver_license == null) {
|
||||||
error(_("This angeltype requires a driver license. Please enter your driver license information!"));
|
error(_("This angeltype requires a driver license. Please enter your driver license information!"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($angeltype['restricted'] && $user_angeltype['confirm_user_id'] == null) {
|
if ($angeltype['restricted'] && $user_angeltype['confirm_user_id'] == null) {
|
||||||
error(sprintf(_("You are unconfirmed for this angeltype. Please go to the introduction for %s to get confirmed."), $angeltype['name']));
|
error(sprintf(
|
||||||
|
_("You are unconfirmed for this angeltype. Please go to the introduction for %s to get confirmed."),
|
||||||
|
$angeltype['name']
|
||||||
|
));
|
||||||
}
|
}
|
||||||
$buttons[] = button(page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $user_angeltype['id'], _("leave"), 'cancel');
|
$buttons[] = button(page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $user_angeltype['id'],
|
||||||
|
_("leave"), 'cancel');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($admin_angeltypes || $supporter) {
|
if ($admin_angeltypes || $supporter) {
|
||||||
$buttons[] = button(page_link_to('angeltypes') . '&action=edit&angeltype_id=' . $angeltype['id'], _("edit"), 'edit');
|
$buttons[] = button(
|
||||||
|
page_link_to('angeltypes') . '&action=edit&angeltype_id=' . $angeltype['id'],
|
||||||
|
_("edit"),
|
||||||
|
'edit'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if ($admin_angeltypes) {
|
if ($admin_angeltypes) {
|
||||||
$buttons[] = button(page_link_to('angeltypes') . '&action=delete&angeltype_id=' . $angeltype['id'], _("delete"), 'delete');
|
$buttons[] = button(
|
||||||
|
page_link_to('angeltypes') . '&action=delete&angeltype_id=' . $angeltype['id'],
|
||||||
|
_("delete"),
|
||||||
|
'delete'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return buttons($buttons);
|
return buttons($buttons);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,7 +165,7 @@ function AngelType_view_members($angeltype, $members, $admin_user_angeltypes, $a
|
||||||
$members_unconfirmed = [];
|
$members_unconfirmed = [];
|
||||||
foreach ($members as $member) {
|
foreach ($members as $member) {
|
||||||
$member['Nick'] = User_Nick_render($member);
|
$member['Nick'] = User_Nick_render($member);
|
||||||
|
|
||||||
if ($angeltype['requires_driver_license']) {
|
if ($angeltype['requires_driver_license']) {
|
||||||
$member['wants_to_drive'] = glyph_bool($member['user_id']);
|
$member['wants_to_drive'] = glyph_bool($member['user_id']);
|
||||||
$member['has_car'] = glyph_bool($member['has_car']);
|
$member['has_car'] = glyph_bool($member['has_car']);
|
||||||
|
@ -140,18 +175,30 @@ function AngelType_view_members($angeltype, $members, $admin_user_angeltypes, $a
|
||||||
$member['has_license_12_5t_truck'] = glyph_bool($member['has_license_12_5t_truck']);
|
$member['has_license_12_5t_truck'] = glyph_bool($member['has_license_12_5t_truck']);
|
||||||
$member['has_license_forklift'] = glyph_bool($member['has_license_forklift']);
|
$member['has_license_forklift'] = glyph_bool($member['has_license_forklift']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($angeltype['restricted'] && $member['confirm_user_id'] == null) {
|
if ($angeltype['restricted'] && $member['confirm_user_id'] == null) {
|
||||||
$member['actions'] = table_buttons([
|
$member['actions'] = table_buttons([
|
||||||
button(page_link_to('user_angeltypes') . '&action=confirm&user_angeltype_id=' . $member['user_angeltype_id'], _("confirm"), 'btn-xs'),
|
button(
|
||||||
button(page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $member['user_angeltype_id'], _("deny"), 'btn-xs')
|
page_link_to('user_angeltypes') . '&action=confirm&user_angeltype_id=' . $member['user_angeltype_id'],
|
||||||
]);
|
_("confirm"),
|
||||||
|
'btn-xs'
|
||||||
|
),
|
||||||
|
button(
|
||||||
|
page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $member['user_angeltype_id'],
|
||||||
|
_("deny"),
|
||||||
|
'btn-xs'
|
||||||
|
)
|
||||||
|
]);
|
||||||
$members_unconfirmed[] = $member;
|
$members_unconfirmed[] = $member;
|
||||||
} elseif ($member['supporter']) {
|
} elseif ($member['supporter']) {
|
||||||
if ($admin_angeltypes) {
|
if ($admin_angeltypes) {
|
||||||
$member['actions'] = table_buttons([
|
$member['actions'] = table_buttons([
|
||||||
button(page_link_to('user_angeltypes') . '&action=update&user_angeltype_id=' . $member['user_angeltype_id'] . '&supporter=0', _("Remove supporter rights"), 'btn-xs')
|
button(
|
||||||
]);
|
page_link_to('user_angeltypes') . '&action=update&user_angeltype_id=' . $member['user_angeltype_id'] . '&supporter=0',
|
||||||
|
_("Remove supporter rights"),
|
||||||
|
'btn-xs'
|
||||||
|
)
|
||||||
|
]);
|
||||||
} else {
|
} else {
|
||||||
$member['actions'] = '';
|
$member['actions'] = '';
|
||||||
}
|
}
|
||||||
|
@ -159,19 +206,26 @@ function AngelType_view_members($angeltype, $members, $admin_user_angeltypes, $a
|
||||||
} else {
|
} else {
|
||||||
if ($admin_user_angeltypes) {
|
if ($admin_user_angeltypes) {
|
||||||
$member['actions'] = table_buttons([
|
$member['actions'] = table_buttons([
|
||||||
$admin_angeltypes ? button(page_link_to('user_angeltypes') . '&action=update&user_angeltype_id=' . $member['user_angeltype_id'] . '&supporter=1', _("Add supporter rights"), 'btn-xs') : '',
|
$admin_angeltypes
|
||||||
button(page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $member['user_angeltype_id'], _("remove"), 'btn-xs')
|
? button(page_link_to('user_angeltypes') . '&action=update&user_angeltype_id=' . $member['user_angeltype_id'] . '&supporter=1',
|
||||||
]);
|
_("Add supporter rights"), 'btn-xs')
|
||||||
|
: '',
|
||||||
|
button(
|
||||||
|
page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $member['user_angeltype_id'],
|
||||||
|
_("remove"),
|
||||||
|
'btn-xs'
|
||||||
|
)
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
$members_confirmed[] = $member;
|
$members_confirmed[] = $member;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
$supporters,
|
$supporters,
|
||||||
$members_confirmed,
|
$members_confirmed,
|
||||||
$members_unconfirmed
|
$members_unconfirmed
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -181,82 +235,103 @@ function AngelType_view_table_headers($angeltype, $supporter, $admin_angeltypes)
|
||||||
{
|
{
|
||||||
if ($angeltype['requires_driver_license'] && ($supporter || $admin_angeltypes)) {
|
if ($angeltype['requires_driver_license'] && ($supporter || $admin_angeltypes)) {
|
||||||
return [
|
return [
|
||||||
'Nick' => _("Nick"),
|
'Nick' => _("Nick"),
|
||||||
'DECT' => _("DECT"),
|
'DECT' => _("DECT"),
|
||||||
'wants_to_drive' => _("Driver"),
|
'wants_to_drive' => _("Driver"),
|
||||||
'has_car' => _("Has car"),
|
'has_car' => _("Has car"),
|
||||||
'has_license_car' => _("Car"),
|
'has_license_car' => _("Car"),
|
||||||
'has_license_3_5t_transporter' => _("3,5t Transporter"),
|
'has_license_3_5t_transporter' => _("3,5t Transporter"),
|
||||||
'has_license_7_5t_truck' => _("7,5t Truck"),
|
'has_license_7_5t_truck' => _("7,5t Truck"),
|
||||||
'has_license_12_5t_truck' => _("12,5t Truck"),
|
'has_license_12_5t_truck' => _("12,5t Truck"),
|
||||||
'has_license_forklift' => _("Forklift"),
|
'has_license_forklift' => _("Forklift"),
|
||||||
'actions' => ''
|
'actions' => ''
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
return [
|
return [
|
||||||
'Nick' => _("Nick"),
|
'Nick' => _("Nick"),
|
||||||
'DECT' => _("DECT"),
|
'DECT' => _("DECT"),
|
||||||
'actions' => ''
|
'actions' => ''
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render an angeltype page containing the member lists.
|
* Render an angeltype page containing the member lists.
|
||||||
*/
|
*/
|
||||||
function AngelType_view($angeltype, $members, $user_angeltype, $admin_user_angeltypes, $admin_angeltypes, $supporter, $user_driver_license, $user)
|
function AngelType_view(
|
||||||
{
|
$angeltype,
|
||||||
|
$members,
|
||||||
|
$user_angeltype,
|
||||||
|
$admin_user_angeltypes,
|
||||||
|
$admin_angeltypes,
|
||||||
|
$supporter,
|
||||||
|
$user_driver_license,
|
||||||
|
$user
|
||||||
|
) {
|
||||||
$page = [
|
$page = [
|
||||||
AngelType_view_buttons($angeltype, $user_angeltype, $admin_angeltypes, $supporter, $user_driver_license, $user),
|
AngelType_view_buttons($angeltype, $user_angeltype, $admin_angeltypes, $supporter, $user_driver_license, $user),
|
||||||
msg()
|
msg()
|
||||||
];
|
];
|
||||||
|
|
||||||
$page[] = '<h3>' . _("Description") . '</h3>';
|
$page[] = '<h3>' . _("Description") . '</h3>';
|
||||||
$parsedown = new Parsedown();
|
$parsedown = new Parsedown();
|
||||||
if ($angeltype['description'] != "") {
|
if ($angeltype['description'] != "") {
|
||||||
$page[] = '<div class="well">' . $parsedown->parse($angeltype['description']) . '</div>';
|
$page[] = '<div class="well">' . $parsedown->parse($angeltype['description']) . '</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
list($supporters, $members_confirmed, $members_unconfirmed) = AngelType_view_members($angeltype, $members, $admin_user_angeltypes, $admin_angeltypes);
|
list($supporters, $members_confirmed, $members_unconfirmed) = AngelType_view_members(
|
||||||
|
$angeltype,
|
||||||
|
$members,
|
||||||
|
$admin_user_angeltypes,
|
||||||
|
$admin_angeltypes
|
||||||
|
);
|
||||||
$table_headers = AngelType_view_table_headers($angeltype, $supporter, $admin_angeltypes);
|
$table_headers = AngelType_view_table_headers($angeltype, $supporter, $admin_angeltypes);
|
||||||
|
|
||||||
if (count($supporters) > 0) {
|
if (count($supporters) > 0) {
|
||||||
$page[] = '<h3>' . _("supporters") . '</h3>';
|
$page[] = '<h3>' . _("supporters") . '</h3>';
|
||||||
$page[] = table($table_headers, $supporters);
|
$page[] = table($table_headers, $supporters);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($members_confirmed) > 0) {
|
if (count($members_confirmed) > 0) {
|
||||||
$members_confirmed[] = [
|
$members_confirmed[] = [
|
||||||
'Nick' => _('Sum'),
|
'Nick' => _('Sum'),
|
||||||
'DECT' => count($members_confirmed),
|
'DECT' => count($members_confirmed),
|
||||||
'actions' => ''
|
'actions' => ''
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($members_unconfirmed) > 0) {
|
if (count($members_unconfirmed) > 0) {
|
||||||
$members_unconfirmed[] = [
|
$members_unconfirmed[] = [
|
||||||
'Nick' => _('Sum'),
|
'Nick' => _('Sum'),
|
||||||
'DECT' => count($members_unconfirmed),
|
'DECT' => count($members_unconfirmed),
|
||||||
'actions' => ''
|
'actions' => ''
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
$page[] = '<h3>' . _("Members") . '</h3>';
|
$page[] = '<h3>' . _("Members") . '</h3>';
|
||||||
if ($admin_user_angeltypes) {
|
if ($admin_user_angeltypes) {
|
||||||
$page[] = buttons([
|
$page[] = buttons([
|
||||||
button(page_link_to('user_angeltypes') . '&action=add&angeltype_id=' . $angeltype['id'], _("Add"), 'add')
|
button(page_link_to('user_angeltypes') . '&action=add&angeltype_id=' . $angeltype['id'], _("Add"), 'add')
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
$page[] = table($table_headers, $members_confirmed);
|
$page[] = table($table_headers, $members_confirmed);
|
||||||
|
|
||||||
if ($admin_user_angeltypes && $angeltype['restricted'] && count($members_unconfirmed) > 0) {
|
if ($admin_user_angeltypes && $angeltype['restricted'] && count($members_unconfirmed) > 0) {
|
||||||
$page[] = '<h3>' . _("Unconfirmed") . '</h3>';
|
$page[] = '<h3>' . _("Unconfirmed") . '</h3>';
|
||||||
$page[] = buttons([
|
$page[] = buttons([
|
||||||
button(page_link_to('user_angeltypes') . '&action=confirm_all&angeltype_id=' . $angeltype['id'], _("confirm all"), 'ok'),
|
button(
|
||||||
button(page_link_to('user_angeltypes') . '&action=delete_all&angeltype_id=' . $angeltype['id'], _("deny all"), 'cancel')
|
page_link_to('user_angeltypes') . '&action=confirm_all&angeltype_id=' . $angeltype['id'],
|
||||||
]);
|
_("confirm all"),
|
||||||
|
'ok'
|
||||||
|
),
|
||||||
|
button(
|
||||||
|
page_link_to('user_angeltypes') . '&action=delete_all&angeltype_id=' . $angeltype['id'],
|
||||||
|
_("deny all"),
|
||||||
|
'cancel'
|
||||||
|
)
|
||||||
|
]);
|
||||||
$page[] = table($table_headers, $members_unconfirmed);
|
$page[] = table($table_headers, $members_unconfirmed);
|
||||||
}
|
}
|
||||||
|
|
||||||
return page_with_title(sprintf(_("Team %s"), $angeltype['name']), $page);
|
return page_with_title(sprintf(_("Team %s"), $angeltype['name']), $page);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -268,19 +343,19 @@ function AngelType_view($angeltype, $members, $user_angeltype, $admin_user_angel
|
||||||
function AngelTypes_list_view($angeltypes, $admin_angeltypes)
|
function AngelTypes_list_view($angeltypes, $admin_angeltypes)
|
||||||
{
|
{
|
||||||
return page_with_title(angeltypes_title(), [
|
return page_with_title(angeltypes_title(), [
|
||||||
msg(),
|
msg(),
|
||||||
buttons([
|
buttons([
|
||||||
$admin_angeltypes ? button(page_link_to('angeltypes') . '&action=edit', _("New angeltype"), 'add') : '',
|
$admin_angeltypes ? button(page_link_to('angeltypes') . '&action=edit', _("New angeltype"), 'add') : '',
|
||||||
button(page_link_to('angeltypes') . '&action=about', _("Teams/Job description"))
|
button(page_link_to('angeltypes') . '&action=about', _("Teams/Job description"))
|
||||||
]),
|
]),
|
||||||
table([
|
table([
|
||||||
'name' => _("Name"),
|
'name' => _("Name"),
|
||||||
'restricted' => glyph('lock') . _("Restricted"),
|
'restricted' => glyph('lock') . _("Restricted"),
|
||||||
'no_self_signup' => glyph('share') . _("Self Sign Up Allowed"),
|
'no_self_signup' => glyph('share') . _("Self Sign Up Allowed"),
|
||||||
'membership' => _("Membership"),
|
'membership' => _("Membership"),
|
||||||
'actions' => ""
|
'actions' => ""
|
||||||
], $angeltypes)
|
], $angeltypes)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -289,27 +364,38 @@ function AngelTypes_list_view($angeltypes, $admin_angeltypes)
|
||||||
function AngelTypes_about_view_angeltype($angeltype)
|
function AngelTypes_about_view_angeltype($angeltype)
|
||||||
{
|
{
|
||||||
$parsedown = new Parsedown();
|
$parsedown = new Parsedown();
|
||||||
|
|
||||||
$html = '<h2>' . $angeltype['name'] . '</h2>';
|
$html = '<h2>' . $angeltype['name'] . '</h2>';
|
||||||
|
|
||||||
if (isset($angeltype['user_angeltype_id'])) {
|
if (isset($angeltype['user_angeltype_id'])) {
|
||||||
$buttons = [];
|
$buttons = [];
|
||||||
if ($angeltype['user_angeltype_id'] != null) {
|
if ($angeltype['user_angeltype_id'] != null) {
|
||||||
$buttons[] = button(page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $angeltype['user_angeltype_id'], _("leave"), 'cancel');
|
$buttons[] = button(
|
||||||
|
page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $angeltype['user_angeltype_id'],
|
||||||
|
_("leave"),
|
||||||
|
'cancel'
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
$buttons[] = button(page_link_to('user_angeltypes') . '&action=add&angeltype_id=' . $angeltype['id'], _("join"), 'add');
|
$buttons[] = button(
|
||||||
|
page_link_to('user_angeltypes') . '&action=add&angeltype_id=' . $angeltype['id'],
|
||||||
|
_("join"),
|
||||||
|
'add'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
$html .= buttons($buttons);
|
$html .= buttons($buttons);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($angeltype['restricted']) {
|
if ($angeltype['restricted']) {
|
||||||
$html .= info(_("This angeltype is restricted by double-opt-in by a team supporter. Please show up at the according introduction meetings."), true);
|
$html .= info(
|
||||||
|
_("This angeltype is restricted by double-opt-in by a team supporter. Please show up at the according introduction meetings."),
|
||||||
|
true
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if ($angeltype['description'] != "") {
|
if ($angeltype['description'] != "") {
|
||||||
$html .= '<div class="well">' . $parsedown->parse($angeltype['description']) . '</div>';
|
$html .= '<div class="well">' . $parsedown->parse($angeltype['description']) . '</div>';
|
||||||
}
|
}
|
||||||
$html .= '<hr />';
|
$html .= '<hr />';
|
||||||
|
|
||||||
return $html;
|
return $html;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -319,20 +405,20 @@ function AngelTypes_about_view_angeltype($angeltype)
|
||||||
function AngelTypes_about_view($angeltypes, $user_logged_in)
|
function AngelTypes_about_view($angeltypes, $user_logged_in)
|
||||||
{
|
{
|
||||||
global $faq_url;
|
global $faq_url;
|
||||||
|
|
||||||
$content = [
|
$content = [
|
||||||
buttons([
|
buttons([
|
||||||
! $user_logged_in ? button(page_link_to('register'), register_title()) : '',
|
!$user_logged_in ? button(page_link_to('register'), register_title()) : '',
|
||||||
! $user_logged_in ? button(page_link_to('login'), login_title()) : '',
|
!$user_logged_in ? button(page_link_to('login'), login_title()) : '',
|
||||||
$user_logged_in ? button(page_link_to('angeltypes'), angeltypes_title(), 'back') : '',
|
$user_logged_in ? button(page_link_to('angeltypes'), angeltypes_title(), 'back') : '',
|
||||||
button($faq_url, _("FAQ"), "btn-primary")
|
button($faq_url, _("FAQ"), "btn-primary")
|
||||||
]),
|
]),
|
||||||
'<p>' . _("Here is the list of teams and their tasks. If you have questions, read the FAQ.") . '</p>',
|
'<p>' . _("Here is the list of teams and their tasks. If you have questions, read the FAQ.") . '</p>',
|
||||||
'<hr />'
|
'<hr />'
|
||||||
];
|
];
|
||||||
foreach ($angeltypes as $angeltype) {
|
foreach ($angeltypes as $angeltype) {
|
||||||
$content[] = AngelTypes_about_view_angeltype($angeltype);
|
$content[] = AngelTypes_about_view_angeltype($angeltype);
|
||||||
}
|
}
|
||||||
|
|
||||||
return page_with_title(_("Teams/Job description"), $content);
|
return page_with_title(_("Teams/Job description"), $content);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,56 +2,60 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shows basic event infos and countdowns.
|
* Shows basic event infos and countdowns.
|
||||||
|
*
|
||||||
* @param EventConfig $event_config The event configuration
|
* @param EventConfig $event_config The event configuration
|
||||||
*/
|
*/
|
||||||
function EventConfig_countdown_page($event_config)
|
function EventConfig_countdown_page($event_config)
|
||||||
{
|
{
|
||||||
if ($event_config == null) {
|
if ($event_config == null) {
|
||||||
return div('col-md-12 text-center', [
|
return div('col-md-12 text-center', [
|
||||||
heading(sprintf(_("Welcome to the %s!"), '<span class="icon-icon_angel"></span> ENGELSYSTEM'), 2)
|
heading(sprintf(_("Welcome to the %s!"), '<span class="icon-icon_angel"></span> ENGELSYSTEM'), 2)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$elements = [];
|
$elements = [];
|
||||||
|
|
||||||
if ($event_config['event_name'] != null) {
|
if ($event_config['event_name'] != null) {
|
||||||
$elements[] = div('col-sm-12 text-center', [
|
$elements[] = div('col-sm-12 text-center', [
|
||||||
heading(sprintf(_("Welcome to the %s!"), $event_config['event_name'] . ' <span class="icon-icon_angel"></span> ENGELSYSTEM'), 2)
|
heading(sprintf(
|
||||||
]);
|
_("Welcome to the %s!"),
|
||||||
|
$event_config['event_name'] . ' <span class="icon-icon_angel"></span> ENGELSYSTEM'
|
||||||
|
), 2)
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($event_config['buildup_start_date'] != null && time() < $event_config['buildup_start_date']) {
|
if ($event_config['buildup_start_date'] != null && time() < $event_config['buildup_start_date']) {
|
||||||
$elements[] = div('col-sm-3 text-center hidden-xs', [
|
$elements[] = div('col-sm-3 text-center hidden-xs', [
|
||||||
heading(_("Buildup starts"), 4),
|
heading(_("Buildup starts"), 4),
|
||||||
'<span class="moment-countdown text-big" data-timestamp="' . $event_config['buildup_start_date'] . '">%c</span>',
|
'<span class="moment-countdown text-big" data-timestamp="' . $event_config['buildup_start_date'] . '">%c</span>',
|
||||||
'<small>' . date(_("Y-m-d"), $event_config['buildup_start_date']) . '</small>'
|
'<small>' . date(_("Y-m-d"), $event_config['buildup_start_date']) . '</small>'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($event_config['event_start_date'] != null && time() < $event_config['event_start_date']) {
|
if ($event_config['event_start_date'] != null && time() < $event_config['event_start_date']) {
|
||||||
$elements[] = div('col-sm-3 text-center hidden-xs', [
|
$elements[] = div('col-sm-3 text-center hidden-xs', [
|
||||||
heading(_("Event starts"), 4),
|
heading(_("Event starts"), 4),
|
||||||
'<span class="moment-countdown text-big" data-timestamp="' . $event_config['event_start_date'] . '">%c</span>',
|
'<span class="moment-countdown text-big" data-timestamp="' . $event_config['event_start_date'] . '">%c</span>',
|
||||||
'<small>' . date(_("Y-m-d"), $event_config['event_start_date']) . '</small>'
|
'<small>' . date(_("Y-m-d"), $event_config['event_start_date']) . '</small>'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($event_config['event_end_date'] != null && time() < $event_config['event_end_date']) {
|
if ($event_config['event_end_date'] != null && time() < $event_config['event_end_date']) {
|
||||||
$elements[] = div('col-sm-3 text-center hidden-xs', [
|
$elements[] = div('col-sm-3 text-center hidden-xs', [
|
||||||
heading(_("Event ends"), 4),
|
heading(_("Event ends"), 4),
|
||||||
'<span class="moment-countdown text-big" data-timestamp="' . $event_config['event_end_date'] . '">%c</span>',
|
'<span class="moment-countdown text-big" data-timestamp="' . $event_config['event_end_date'] . '">%c</span>',
|
||||||
'<small>' . date(_("Y-m-d"), $event_config['event_end_date']) . '</small>'
|
'<small>' . date(_("Y-m-d"), $event_config['event_end_date']) . '</small>'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($event_config['teardown_end_date'] != null && time() < $event_config['teardown_end_date']) {
|
if ($event_config['teardown_end_date'] != null && time() < $event_config['teardown_end_date']) {
|
||||||
$elements[] = div('col-sm-3 text-center hidden-xs', [
|
$elements[] = div('col-sm-3 text-center hidden-xs', [
|
||||||
heading(_("Teardown ends"), 4),
|
heading(_("Teardown ends"), 4),
|
||||||
'<span class="moment-countdown text-big" data-timestamp="' . $event_config['teardown_end_date'] . '">%c</span>',
|
'<span class="moment-countdown text-big" data-timestamp="' . $event_config['teardown_end_date'] . '">%c</span>',
|
||||||
'<small>' . date(_("Y-m-d"), $event_config['teardown_end_date']) . '</small>'
|
'<small>' . date(_("Y-m-d"), $event_config['teardown_end_date']) . '</small>'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return join("", $elements);
|
return join("", $elements);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,27 +67,39 @@ function EventConfig_info($event_config)
|
||||||
if ($event_config == null) {
|
if ($event_config == null) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Event name, start+end date are set
|
// Event name, start+end date are set
|
||||||
if ($event_config['event_name'] != null && $event_config['event_start_date'] != null && $event_config['event_end_date'] != null) {
|
if ($event_config['event_name'] != null && $event_config['event_start_date'] != null && $event_config['event_end_date'] != null) {
|
||||||
return sprintf(_("%s, from %s to %s"), $event_config['event_name'], date(_("Y-m-d"), $event_config['event_start_date']), date(_("Y-m-d"), $event_config['event_end_date']));
|
return sprintf(
|
||||||
}
|
_("%s, from %s to %s"),
|
||||||
|
$event_config['event_name'],
|
||||||
// Event name, start date are set
|
date(_("Y-m-d"), $event_config['event_start_date']),
|
||||||
if ($event_config['event_name'] != null && $event_config['event_start_date'] != null) {
|
date(_("Y-m-d"), $event_config['event_end_date'])
|
||||||
return sprintf(_("%s, starting %s"), $event_config['event_name'], date(_("Y-m-d"), $event_config['event_start_date']));
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Event start+end date are set
|
// Event name, start date are set
|
||||||
if ($event_config['event_start_date'] != null && $event_config['event_end_date'] != null) {
|
if ($event_config['event_name'] != null && $event_config['event_start_date'] != null) {
|
||||||
return sprintf(_("Event from %s to %s"), date(_("Y-m-d"), $event_config['event_start_date']), date(_("Y-m-d"), $event_config['event_end_date']));
|
return sprintf(
|
||||||
}
|
_("%s, starting %s"), $event_config['event_name'],
|
||||||
|
date(_("Y-m-d"), $event_config['event_start_date'])
|
||||||
// Only event name is set
|
);
|
||||||
if ($event_config['event_name'] != null) {
|
}
|
||||||
return sprintf($event_config['event_name']);
|
|
||||||
}
|
// Event start+end date are set
|
||||||
|
if ($event_config['event_start_date'] != null && $event_config['event_end_date'] != null) {
|
||||||
|
return sprintf(
|
||||||
|
_("Event from %s to %s"),
|
||||||
|
date(_("Y-m-d"), $event_config['event_start_date']),
|
||||||
|
date(_("Y-m-d"), $event_config['event_end_date'])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only event name is set
|
||||||
|
if ($event_config['event_name'] != null) {
|
||||||
|
return sprintf($event_config['event_name']);
|
||||||
|
}
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,37 +110,43 @@ function EventConfig_info($event_config)
|
||||||
* The event name
|
* The event name
|
||||||
* @param string $event_welcome_msg
|
* @param string $event_welcome_msg
|
||||||
* The welcome message
|
* The welcome message
|
||||||
* @param date $buildup_start_date
|
* @param date $buildup_start_date
|
||||||
* @param date $event_start_date
|
* @param date $event_start_date
|
||||||
* @param date $event_end_date
|
* @param date $event_end_date
|
||||||
* @param date $teardown_end_date
|
* @param date $teardown_end_date
|
||||||
*/
|
*/
|
||||||
function EventConfig_edit_view($event_name, $event_welcome_msg, $buildup_start_date, $event_start_date, $event_end_date, $teardown_end_date)
|
function EventConfig_edit_view(
|
||||||
{
|
$event_name,
|
||||||
|
$event_welcome_msg,
|
||||||
|
$buildup_start_date,
|
||||||
|
$event_start_date,
|
||||||
|
$event_end_date,
|
||||||
|
$teardown_end_date
|
||||||
|
) {
|
||||||
return page_with_title(event_config_title(), [
|
return page_with_title(event_config_title(), [
|
||||||
msg(),
|
msg(),
|
||||||
form([
|
form([
|
||||||
div('row', [
|
div('row', [
|
||||||
div('col-md-6', [
|
div('col-md-6', [
|
||||||
form_text('event_name', _("Event Name"), $event_name),
|
form_text('event_name', _("Event Name"), $event_name),
|
||||||
form_info('', _("Event Name is shown on the start page.")),
|
form_info('', _("Event Name is shown on the start page.")),
|
||||||
form_textarea('event_welcome_msg', _("Event Welcome Message"), $event_welcome_msg),
|
form_textarea('event_welcome_msg', _("Event Welcome Message"), $event_welcome_msg),
|
||||||
form_info('', _("Welcome message is shown after successful registration. You can use markdown."))
|
form_info('', _("Welcome message is shown after successful registration. You can use markdown."))
|
||||||
]),
|
]),
|
||||||
div('col-md-3 col-xs-6', [
|
div('col-md-3 col-xs-6', [
|
||||||
form_date('buildup_start_date', _("Buildup date"), $buildup_start_date),
|
form_date('buildup_start_date', _("Buildup date"), $buildup_start_date),
|
||||||
form_date('event_start_date', _("Event start date"), $event_start_date)
|
form_date('event_start_date', _("Event start date"), $event_start_date)
|
||||||
]),
|
]),
|
||||||
div('col-md-3 col-xs-6', [
|
div('col-md-3 col-xs-6', [
|
||||||
form_date('teardown_end_date', _("Teardown end date"), $teardown_end_date),
|
form_date('teardown_end_date', _("Teardown end date"), $teardown_end_date),
|
||||||
form_date('event_end_date', _("Event end date"), $event_end_date)
|
form_date('event_end_date', _("Event end date"), $event_end_date)
|
||||||
])
|
])
|
||||||
]),
|
]),
|
||||||
div('row', [
|
div('row', [
|
||||||
div('col-md-6', [
|
div('col-md-6', [
|
||||||
form_submit('submit', _("Save"))
|
form_submit('submit', _("Save"))
|
||||||
])
|
])
|
||||||
])
|
])
|
||||||
])
|
])
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,31 +6,31 @@ function Questions_view($open_questions, $answered_questions, $ask_action)
|
||||||
$question['actions'] = '<a href="' . page_link_to("user_questions") . '&action=delete&id=' . $question['QID'] . '">' . _("delete") . '</a>';
|
$question['actions'] = '<a href="' . page_link_to("user_questions") . '&action=delete&id=' . $question['QID'] . '">' . _("delete") . '</a>';
|
||||||
$question['Question'] = str_replace("\n", '<br />', $question['Question']);
|
$question['Question'] = str_replace("\n", '<br />', $question['Question']);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($answered_questions as &$question) {
|
foreach ($answered_questions as &$question) {
|
||||||
$question['Question'] = str_replace("\n", '<br />', $question['Question']);
|
$question['Question'] = str_replace("\n", '<br />', $question['Question']);
|
||||||
$question['Answer'] = str_replace("\n", '<br />', $question['Answer']);
|
$question['Answer'] = str_replace("\n", '<br />', $question['Answer']);
|
||||||
$question['actions'] = '<a href="' . page_link_to("user_questions") . '&action=delete&id=' . $question['QID'] . '">' . _("delete") . '</a>';
|
$question['actions'] = '<a href="' . page_link_to("user_questions") . '&action=delete&id=' . $question['QID'] . '">' . _("delete") . '</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
return page_with_title(questions_title(), [
|
return page_with_title(questions_title(), [
|
||||||
msg(),
|
msg(),
|
||||||
heading(_("Open questions"), 2),
|
heading(_("Open questions"), 2),
|
||||||
table([
|
table([
|
||||||
'Question' => _("Question"),
|
'Question' => _("Question"),
|
||||||
'actions' => ""
|
'actions' => ""
|
||||||
], $open_questions),
|
], $open_questions),
|
||||||
heading(_("Answered questions"), 2),
|
heading(_("Answered questions"), 2),
|
||||||
table([
|
table([
|
||||||
'Question' => _("Question"),
|
'Question' => _("Question"),
|
||||||
'answer_user' => _("Answered by"),
|
'answer_user' => _("Answered by"),
|
||||||
'Answer' => _("Answer"),
|
'Answer' => _("Answer"),
|
||||||
'actions' => ""
|
'actions' => ""
|
||||||
], $answered_questions),
|
], $answered_questions),
|
||||||
heading(_("Ask the Heaven"), 2),
|
heading(_("Ask the Heaven"), 2),
|
||||||
form([
|
form([
|
||||||
form_textarea('question', _("Your Question:"), ""),
|
form_textarea('question', _("Your Question:"), ""),
|
||||||
form_submit('submit', _("Save"))
|
form_submit('submit', _("Save"))
|
||||||
], $ask_action)
|
], $ask_action)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
<?php
|
<?php
|
||||||
use Engelsystem\ShiftsFilterRenderer;
|
|
||||||
use Engelsystem\ShiftCalendarRenderer;
|
use Engelsystem\ShiftCalendarRenderer;
|
||||||
|
use Engelsystem\ShiftsFilterRenderer;
|
||||||
|
|
||||||
function Room_view($room, ShiftsFilterRenderer $shiftsFilterRenderer, ShiftCalendarRenderer $shiftCalendarRenderer)
|
function Room_view($room, ShiftsFilterRenderer $shiftsFilterRenderer, ShiftCalendarRenderer $shiftCalendarRenderer)
|
||||||
{
|
{
|
||||||
return page_with_title(glyph('map-marker') . $room['Name'], [
|
return page_with_title(glyph('map-marker') . $room['Name'], [
|
||||||
$shiftsFilterRenderer->render(room_link($room)) ,
|
$shiftsFilterRenderer->render(room_link($room)),
|
||||||
$shiftCalendarRenderer->render()
|
$shiftCalendarRenderer->render()
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function Room_name_render($room)
|
function Room_name_render($room)
|
||||||
|
|
|
@ -22,38 +22,38 @@ class ShiftCalendarLane
|
||||||
$this->blockCount = $blockCount;
|
$this->blockCount = $blockCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a shift to the lane, but only if it fits.
|
* Adds a shift to the lane, but only if it fits.
|
||||||
* Returns true on success.
|
* Returns true on success.
|
||||||
*
|
*
|
||||||
* @param Shift $shift
|
* @param Shift $shift
|
||||||
* The shift to add
|
* The shift to add
|
||||||
* @return boolean true on success
|
* @return boolean true on success
|
||||||
*/
|
*/
|
||||||
public function addShift($shift)
|
public function addShift($shift)
|
||||||
{
|
{
|
||||||
if ($this->shiftFits($shift)) {
|
if ($this->shiftFits($shift)) {
|
||||||
$this->shifts[] = $shift;
|
$this->shifts[] = $shift;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if given shift fits into this lane.
|
* Returns true if given shift fits into this lane.
|
||||||
*
|
*
|
||||||
* @param Shift $shift
|
* @param Shift $shift
|
||||||
* The shift to fit into this lane
|
* The shift to fit into this lane
|
||||||
*/
|
*/
|
||||||
public function shiftFits($newShift)
|
public function shiftFits($newShift)
|
||||||
{
|
{
|
||||||
foreach ($this->shifts as $laneShift) {
|
foreach ($this->shifts as $laneShift) {
|
||||||
if (! ($newShift['start'] >= $laneShift['end'] || $newShift['end'] <= $laneShift['start'])) {
|
if (!($newShift['start'] >= $laneShift['end'] || $newShift['end'] <= $laneShift['start'])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getHeader()
|
public function getHeader()
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,26 +5,26 @@ namespace Engelsystem;
|
||||||
class ShiftCalendarRenderer
|
class ShiftCalendarRenderer
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 15m * 60s/m = 900s
|
* 15m * 60s/m = 900s
|
||||||
*/
|
*/
|
||||||
const SECONDS_PER_ROW = 900;
|
const SECONDS_PER_ROW = 900;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Height of a block in pixel.
|
* Height of a block in pixel.
|
||||||
* Do not change - corresponds with theme/css
|
* Do not change - corresponds with theme/css
|
||||||
*/
|
*/
|
||||||
const BLOCK_HEIGHT = 30;
|
const BLOCK_HEIGHT = 30;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Distance between two shifts in pixels
|
* Distance between two shifts in pixels
|
||||||
*/
|
*/
|
||||||
const MARGIN = 5;
|
const MARGIN = 5;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Seconds added to the start and end time
|
* Seconds added to the start and end time
|
||||||
*/
|
*/
|
||||||
const TIME_MARGIN = 1800;
|
const TIME_MARGIN = 1800;
|
||||||
|
|
||||||
private $lanes;
|
private $lanes;
|
||||||
|
|
||||||
|
@ -50,51 +50,51 @@ class ShiftCalendarRenderer
|
||||||
$this->shift_entries = $shift_entries;
|
$this->shift_entries = $shift_entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Assigns the shifts to different lanes per room if they collide
|
* Assigns the shifts to different lanes per room if they collide
|
||||||
*
|
*
|
||||||
* @param Shift[] $shifts
|
* @param Shift[] $shifts
|
||||||
* The shifts to assign
|
* The shifts to assign
|
||||||
*
|
*
|
||||||
* @return Returns an array that assigns a room_id to an array of ShiftCalendarLane containing the shifts
|
* @return Returns an array that assigns a room_id to an array of ShiftCalendarLane containing the shifts
|
||||||
*/
|
*/
|
||||||
private function assignShiftsToLanes($shifts)
|
private function assignShiftsToLanes($shifts)
|
||||||
{
|
{
|
||||||
// array that assigns a room id to a list of lanes (per room)
|
// array that assigns a room id to a list of lanes (per room)
|
||||||
$lanes = [];
|
$lanes = [];
|
||||||
|
|
||||||
foreach ($shifts as $shift) {
|
foreach ($shifts as $shift) {
|
||||||
$room_id = $shift['RID'];
|
$room_id = $shift['RID'];
|
||||||
$header = Room_name_render([
|
$header = Room_name_render([
|
||||||
'RID' => $room_id,
|
'RID' => $room_id,
|
||||||
'Name' => $shift['room_name']
|
'Name' => $shift['room_name']
|
||||||
]);
|
]);
|
||||||
if (! isset($lanes[$room_id])) {
|
if (!isset($lanes[$room_id])) {
|
||||||
// initialize room with one lane
|
// initialize room with one lane
|
||||||
$lanes[$room_id] = [
|
$lanes[$room_id] = [
|
||||||
new ShiftCalendarLane($header, $this->getFirstBlockStartTime(), $this->getBlocksPerSlot())
|
new ShiftCalendarLane($header, $this->getFirstBlockStartTime(), $this->getBlocksPerSlot())
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
// Try to add the shift to the existing lanes for this room
|
// Try to add the shift to the existing lanes for this room
|
||||||
$shift_added = false;
|
$shift_added = false;
|
||||||
foreach ($lanes[$room_id] as $lane) {
|
foreach ($lanes[$room_id] as $lane) {
|
||||||
$shift_added = $lane->addShift($shift);
|
$shift_added = $lane->addShift($shift);
|
||||||
if ($shift_added == true) {
|
if ($shift_added == true) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// If all lanes for this room are busy, create a new lane and add shift to it
|
// If all lanes for this room are busy, create a new lane and add shift to it
|
||||||
if ($shift_added == false) {
|
if ($shift_added == false) {
|
||||||
$newLane = new ShiftCalendarLane($header, $this->getFirstBlockStartTime(), $this->getBlocksPerSlot());
|
$newLane = new ShiftCalendarLane($header, $this->getFirstBlockStartTime(), $this->getBlocksPerSlot());
|
||||||
if (! $newLane->addShift($shift)) {
|
if (!$newLane->addShift($shift)) {
|
||||||
engelsystem_error("Unable to add shift to new lane.");
|
engelsystem_error("Unable to add shift to new lane.");
|
||||||
}
|
}
|
||||||
$lanes[$room_id][] = $newLane;
|
$lanes[$room_id][] = $newLane;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $lanes;
|
return $lanes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFirstBlockStartTime()
|
public function getFirstBlockStartTime()
|
||||||
{
|
{
|
||||||
|
@ -114,118 +114,119 @@ class ShiftCalendarRenderer
|
||||||
return $this->blocksPerSlot;
|
return $this->blocksPerSlot;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renders the whole calendar
|
* Renders the whole calendar
|
||||||
*
|
*
|
||||||
* @return the generated html
|
* @return the generated html
|
||||||
*/
|
*/
|
||||||
public function render()
|
public function render()
|
||||||
{
|
{
|
||||||
if (count($this->lanes) == 0) {
|
if (count($this->lanes) == 0) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
return div('shift-calendar', [
|
return div('shift-calendar', [
|
||||||
$this->renderTimeLane(),
|
$this->renderTimeLane(),
|
||||||
$this->renderShiftLanes()
|
$this->renderShiftLanes()
|
||||||
]) . $this->renderLegend();
|
]) . $this->renderLegend();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renders the lanes containing the shifts
|
* Renders the lanes containing the shifts
|
||||||
*/
|
*/
|
||||||
private function renderShiftLanes()
|
private function renderShiftLanes()
|
||||||
{
|
{
|
||||||
$html = "";
|
$html = "";
|
||||||
foreach ($this->lanes as $room_lanes) {
|
foreach ($this->lanes as $room_lanes) {
|
||||||
foreach ($room_lanes as $lane) {
|
foreach ($room_lanes as $lane) {
|
||||||
$html .= $this->renderLane($lane);
|
$html .= $this->renderLane($lane);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $html;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
return $html;
|
||||||
* Renders a single lane
|
}
|
||||||
*
|
|
||||||
* @param ShiftCalendarLane $lane
|
|
||||||
* The lane to render
|
|
||||||
*/
|
|
||||||
private function renderLane(ShiftCalendarLane $lane)
|
|
||||||
{
|
|
||||||
global $user;
|
|
||||||
|
|
||||||
$shift_renderer = new ShiftCalendarShiftRenderer();
|
|
||||||
$html = "";
|
|
||||||
$rendered_until = $this->getFirstBlockStartTime();
|
|
||||||
|
|
||||||
foreach ($lane->getShifts() as $shift) {
|
|
||||||
while ($rendered_until + ShiftCalendarRenderer::SECONDS_PER_ROW <= $shift['start']) {
|
|
||||||
$html .= $this->renderTick($rendered_until);
|
|
||||||
$rendered_until += ShiftCalendarRenderer::SECONDS_PER_ROW;
|
|
||||||
}
|
|
||||||
|
|
||||||
list($shift_height, $shift_html) = $shift_renderer->render($shift, $this->needed_angeltypes[$shift['SID']], $this->shift_entries[$shift['SID']], $user);
|
|
||||||
$html .= $shift_html;
|
|
||||||
$rendered_until += $shift_height * ShiftCalendarRenderer::SECONDS_PER_ROW;
|
|
||||||
}
|
|
||||||
|
|
||||||
while ($rendered_until < $this->getLastBlockEndTime()) {
|
|
||||||
$html .= $this->renderTick($rendered_until);
|
|
||||||
$rendered_until += ShiftCalendarRenderer::SECONDS_PER_ROW;
|
|
||||||
}
|
|
||||||
|
|
||||||
return div('lane', [
|
|
||||||
div('header', $lane->getHeader()),
|
|
||||||
$html
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renders a tick/block for given time
|
* Renders a single lane
|
||||||
*
|
*
|
||||||
* @param int $time
|
* @param ShiftCalendarLane $lane
|
||||||
* unix timestamp
|
* The lane to render
|
||||||
* @param boolean $label
|
*/
|
||||||
* Should time labels be generated?
|
private function renderLane(ShiftCalendarLane $lane)
|
||||||
* @return rendered tick html
|
{
|
||||||
*/
|
global $user;
|
||||||
private function renderTick($time, $label = false)
|
|
||||||
{
|
|
||||||
if ($time % (24 * 60 * 60) == 23 * 60 * 60) {
|
|
||||||
if (! $label) {
|
|
||||||
return div('tick day');
|
|
||||||
}
|
|
||||||
return div('tick day', [
|
|
||||||
date('m-d<b\r />H:i', $time)
|
|
||||||
]);
|
|
||||||
} elseif ($time % (60 * 60) == 0) {
|
|
||||||
if (! $label) {
|
|
||||||
return div('tick hour');
|
|
||||||
}
|
|
||||||
return div('tick hour', [
|
|
||||||
date('m-d<b\r />H:i', $time)
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
return div('tick');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
$shift_renderer = new ShiftCalendarShiftRenderer();
|
||||||
* Renders the left time lane including hour/day ticks
|
$html = "";
|
||||||
*/
|
$rendered_until = $this->getFirstBlockStartTime();
|
||||||
private function renderTimeLane()
|
|
||||||
{
|
foreach ($lane->getShifts() as $shift) {
|
||||||
$time_slot = [
|
while ($rendered_until + ShiftCalendarRenderer::SECONDS_PER_ROW <= $shift['start']) {
|
||||||
div('header', [
|
$html .= $this->renderTick($rendered_until);
|
||||||
_("Time")
|
$rendered_until += ShiftCalendarRenderer::SECONDS_PER_ROW;
|
||||||
])
|
}
|
||||||
];
|
|
||||||
for ($block = 0; $block < $this->getBlocksPerSlot(); $block ++) {
|
list($shift_height, $shift_html) = $shift_renderer->render($shift, $this->needed_angeltypes[$shift['SID']],
|
||||||
$thistime = $this->getFirstBlockStartTime() + ($block * ShiftCalendarRenderer::SECONDS_PER_ROW);
|
$this->shift_entries[$shift['SID']], $user);
|
||||||
$time_slot[] = $this->renderTick($thistime, true);
|
$html .= $shift_html;
|
||||||
}
|
$rendered_until += $shift_height * ShiftCalendarRenderer::SECONDS_PER_ROW;
|
||||||
return div('lane time', $time_slot);
|
}
|
||||||
}
|
|
||||||
|
while ($rendered_until < $this->getLastBlockEndTime()) {
|
||||||
|
$html .= $this->renderTick($rendered_until);
|
||||||
|
$rendered_until += ShiftCalendarRenderer::SECONDS_PER_ROW;
|
||||||
|
}
|
||||||
|
|
||||||
|
return div('lane', [
|
||||||
|
div('header', $lane->getHeader()),
|
||||||
|
$html
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Renders a tick/block for given time
|
||||||
|
*
|
||||||
|
* @param int $time
|
||||||
|
* unix timestamp
|
||||||
|
* @param boolean $label
|
||||||
|
* Should time labels be generated?
|
||||||
|
* @return rendered tick html
|
||||||
|
*/
|
||||||
|
private function renderTick($time, $label = false)
|
||||||
|
{
|
||||||
|
if ($time % (24 * 60 * 60) == 23 * 60 * 60) {
|
||||||
|
if (!$label) {
|
||||||
|
return div('tick day');
|
||||||
|
}
|
||||||
|
return div('tick day', [
|
||||||
|
date('m-d<b\r />H:i', $time)
|
||||||
|
]);
|
||||||
|
} elseif ($time % (60 * 60) == 0) {
|
||||||
|
if (!$label) {
|
||||||
|
return div('tick hour');
|
||||||
|
}
|
||||||
|
return div('tick hour', [
|
||||||
|
date('m-d<b\r />H:i', $time)
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
return div('tick');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Renders the left time lane including hour/day ticks
|
||||||
|
*/
|
||||||
|
private function renderTimeLane()
|
||||||
|
{
|
||||||
|
$time_slot = [
|
||||||
|
div('header', [
|
||||||
|
_("Time")
|
||||||
|
])
|
||||||
|
];
|
||||||
|
for ($block = 0; $block < $this->getBlocksPerSlot(); $block++) {
|
||||||
|
$thistime = $this->getFirstBlockStartTime() + ($block * ShiftCalendarRenderer::SECONDS_PER_ROW);
|
||||||
|
$time_slot[] = $this->renderTick($thistime, true);
|
||||||
|
}
|
||||||
|
return div('lane time', $time_slot);
|
||||||
|
}
|
||||||
|
|
||||||
private function calcFirstBlockStartTime($shifts)
|
private function calcFirstBlockStartTime($shifts)
|
||||||
{
|
{
|
||||||
|
@ -254,17 +255,17 @@ class ShiftCalendarRenderer
|
||||||
return ceil(($this->getLastBlockEndTime() - $this->getFirstBlockStartTime()) / ShiftCalendarRenderer::SECONDS_PER_ROW);
|
return ceil(($this->getLastBlockEndTime() - $this->getFirstBlockStartTime()) / ShiftCalendarRenderer::SECONDS_PER_ROW);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renders a legend explaining the shift coloring
|
* Renders a legend explaining the shift coloring
|
||||||
*/
|
*/
|
||||||
private function renderLegend()
|
private function renderLegend()
|
||||||
{
|
{
|
||||||
return div('legend', [
|
return div('legend', [
|
||||||
label(_('Your shift'), 'primary'),
|
label(_('Your shift'), 'primary'),
|
||||||
label(_('Help needed'), 'danger'),
|
label(_('Help needed'), 'danger'),
|
||||||
label(_('Other angeltype needed / collides with my shifts'), 'warning'),
|
label(_('Other angeltype needed / collides with my shifts'), 'warning'),
|
||||||
label(_('Shift is full'), 'success'),
|
label(_('Shift is full'), 'success'),
|
||||||
label(_('Shift running/ended'), 'default')
|
label(_('Shift running/ended'), 'default')
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,69 +8,77 @@ namespace Engelsystem;
|
||||||
class ShiftCalendarShiftRenderer
|
class ShiftCalendarShiftRenderer
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renders a shift
|
* Renders a shift
|
||||||
*
|
*
|
||||||
* @param Shift $shift
|
* @param Shift $shift
|
||||||
* The shift to render
|
* The shift to render
|
||||||
* @param User $user
|
* @param User $user
|
||||||
* The user who is viewing the shift calendar
|
* The user who is viewing the shift calendar
|
||||||
*/
|
*/
|
||||||
public function render($shift, $needed_angeltypes, $shift_entries, $user)
|
public function render($shift, $needed_angeltypes, $shift_entries, $user)
|
||||||
{
|
{
|
||||||
$info_text = "";
|
$info_text = "";
|
||||||
if ($shift['title'] != '') {
|
if ($shift['title'] != '') {
|
||||||
$info_text = glyph('info-sign') . $shift['title'] . '<br>';
|
$info_text = glyph('info-sign') . $shift['title'] . '<br>';
|
||||||
}
|
}
|
||||||
list($shift_signup_state, $shifts_row) = $this->renderShiftNeededAngeltypes($shift, $needed_angeltypes, $shift_entries, $user);
|
list($shift_signup_state, $shifts_row) = $this->renderShiftNeededAngeltypes(
|
||||||
|
$shift,
|
||||||
$class = $this->classForSignupState($shift_signup_state);
|
$needed_angeltypes,
|
||||||
|
$shift_entries,
|
||||||
$blocks = ceil(($shift["end"] - $shift["start"]) / ShiftCalendarRenderer::SECONDS_PER_ROW);
|
$user
|
||||||
$blocks = max(1, $blocks);
|
);
|
||||||
return [
|
|
||||||
$blocks,
|
$class = $this->classForSignupState($shift_signup_state);
|
||||||
div('shift panel panel-' . $class . '" style="height: ' . ($blocks * ShiftCalendarRenderer::BLOCK_HEIGHT - ShiftCalendarRenderer::MARGIN) . 'px"', [
|
|
||||||
$this->renderShiftHead($shift),
|
$blocks = ceil(($shift["end"] - $shift["start"]) / ShiftCalendarRenderer::SECONDS_PER_ROW);
|
||||||
div('panel-body', [
|
$blocks = max(1, $blocks);
|
||||||
$info_text,
|
return [
|
||||||
Room_name_render([
|
$blocks,
|
||||||
'RID' => $shift['RID'],
|
div(
|
||||||
'Name' => $shift['room_name']
|
'shift panel panel-' . $class . '" style="height: ' . ($blocks * ShiftCalendarRenderer::BLOCK_HEIGHT - ShiftCalendarRenderer::MARGIN) . 'px"',
|
||||||
])
|
[
|
||||||
]),
|
$this->renderShiftHead($shift),
|
||||||
$shifts_row,
|
div('panel-body', [
|
||||||
div('shift-spacer')
|
$info_text,
|
||||||
])
|
Room_name_render([
|
||||||
];
|
'RID' => $shift['RID'],
|
||||||
}
|
'Name' => $shift['room_name']
|
||||||
|
])
|
||||||
|
]),
|
||||||
|
$shifts_row,
|
||||||
|
div('shift-spacer')
|
||||||
|
]
|
||||||
|
)
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
private function classForSignupState(ShiftSignupState $shiftSignupState)
|
private function classForSignupState(ShiftSignupState $shiftSignupState)
|
||||||
{
|
{
|
||||||
switch ($shiftSignupState->getState()) {
|
switch ($shiftSignupState->getState()) {
|
||||||
case ShiftSignupState::ADMIN:
|
case ShiftSignupState::ADMIN:
|
||||||
case ShiftSignupState::OCCUPIED:
|
case ShiftSignupState::OCCUPIED:
|
||||||
return 'success';
|
return 'success';
|
||||||
|
|
||||||
case ShiftSignupState::SIGNED_UP:
|
case ShiftSignupState::SIGNED_UP:
|
||||||
return 'primary';
|
return 'primary';
|
||||||
|
|
||||||
case ShiftSignupState::SHIFT_ENDED:
|
case ShiftSignupState::SHIFT_ENDED:
|
||||||
return 'default';
|
return 'default';
|
||||||
|
|
||||||
case ShiftSignupState::ANGELTYPE:
|
case ShiftSignupState::ANGELTYPE:
|
||||||
case ShiftSignupState::COLLIDES:
|
case ShiftSignupState::COLLIDES:
|
||||||
return 'warning';
|
return 'warning';
|
||||||
|
|
||||||
case ShiftSignupState::FREE:
|
case ShiftSignupState::FREE:
|
||||||
return 'danger';
|
return 'danger';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function renderShiftNeededAngeltypes($shift, $needed_angeltypes, $shift_entries, $user)
|
private function renderShiftNeededAngeltypes($shift, $needed_angeltypes, $shift_entries, $user)
|
||||||
{
|
{
|
||||||
global $privileges;
|
global $privileges;
|
||||||
|
|
||||||
$shift_entries_filtered = [];
|
$shift_entries_filtered = [];
|
||||||
foreach ($needed_angeltypes as $needed_angeltype) {
|
foreach ($needed_angeltypes as $needed_angeltype) {
|
||||||
$shift_entries_filtered[$needed_angeltype['id']] = [];
|
$shift_entries_filtered[$needed_angeltype['id']] = [];
|
||||||
|
@ -78,12 +86,17 @@ class ShiftCalendarShiftRenderer
|
||||||
foreach ($shift_entries as $shift_entry) {
|
foreach ($shift_entries as $shift_entry) {
|
||||||
$shift_entries_filtered[$shift_entry['TID']][] = $shift_entry;
|
$shift_entries_filtered[$shift_entry['TID']][] = $shift_entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
$html = "";
|
$html = "";
|
||||||
$shift_signup_state = null;
|
$shift_signup_state = null;
|
||||||
foreach ($needed_angeltypes as $angeltype) {
|
foreach ($needed_angeltypes as $angeltype) {
|
||||||
if ($angeltype['count'] > 0 || count($shift_entries_filtered[$angeltype['id']]) > 0) {
|
if ($angeltype['count'] > 0 || count($shift_entries_filtered[$angeltype['id']]) > 0) {
|
||||||
list($angeltype_signup_state, $angeltype_html) = $this->renderShiftNeededAngeltype($shift, $shift_entries_filtered[$angeltype['id']], $angeltype, $user);
|
list($angeltype_signup_state, $angeltype_html) = $this->renderShiftNeededAngeltype(
|
||||||
|
$shift,
|
||||||
|
$shift_entries_filtered[$angeltype['id']],
|
||||||
|
$angeltype,
|
||||||
|
$user
|
||||||
|
);
|
||||||
if ($shift_signup_state == null) {
|
if ($shift_signup_state == null) {
|
||||||
$shift_signup_state = $angeltype_signup_state;
|
$shift_signup_state = $angeltype_signup_state;
|
||||||
} else {
|
} else {
|
||||||
|
@ -95,105 +108,125 @@ class ShiftCalendarShiftRenderer
|
||||||
if ($shift_signup_state == null) {
|
if ($shift_signup_state == null) {
|
||||||
$shift_signup_state = new ShiftSignupState(ShiftSignupState::SHIFT_ENDED, 0);
|
$shift_signup_state = new ShiftSignupState(ShiftSignupState::SHIFT_ENDED, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (in_array('user_shifts_admin', $privileges)) {
|
if (in_array('user_shifts_admin', $privileges)) {
|
||||||
$html .= '<li class="list-group-item">' . button(page_link_to('user_shifts') . '&shift_id=' . $shift['SID'], _("Add more angels"), 'btn-xs') . '</li>';
|
$html .= '<li class="list-group-item">' . button(
|
||||||
|
page_link_to('user_shifts') . '&shift_id=' . $shift['SID'],
|
||||||
|
_("Add more angels"),
|
||||||
|
'btn-xs'
|
||||||
|
) . '</li>';
|
||||||
}
|
}
|
||||||
if ($html != '') {
|
if ($html != '') {
|
||||||
return [
|
return [
|
||||||
$shift_signup_state,
|
$shift_signup_state,
|
||||||
'<ul class="list-group">' . $html . '</ul>'
|
'<ul class="list-group">' . $html . '</ul>'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
return [
|
return [
|
||||||
$shift_signup_state,
|
$shift_signup_state,
|
||||||
""
|
""
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renders a list entry containing the needed angels for an angeltype
|
* Renders a list entry containing the needed angels for an angeltype
|
||||||
*
|
*
|
||||||
* @param Shift $shift
|
* @param Shift $shift
|
||||||
* The shift which is rendered
|
* The shift which is rendered
|
||||||
* @param Angeltype $angeltype
|
* @param Angeltype $angeltype
|
||||||
* The angeltype, containing informations about needed angeltypes and already signed up angels
|
* The angeltype, containing informations about needed angeltypes and already signed up angels
|
||||||
* @param User $user
|
* @param User $user
|
||||||
* The user who is viewing the shift calendar
|
* The user who is viewing the shift calendar
|
||||||
*/
|
*/
|
||||||
private function renderShiftNeededAngeltype($shift, $shift_entries, $angeltype, $user)
|
private function renderShiftNeededAngeltype($shift, $shift_entries, $angeltype, $user)
|
||||||
{
|
{
|
||||||
$entry_list = [];
|
$entry_list = [];
|
||||||
foreach ($shift_entries as $entry) {
|
foreach ($shift_entries as $entry) {
|
||||||
$style = $entry['freeloaded'] ? " text-decoration: line-through;" : '';
|
$style = $entry['freeloaded'] ? " text-decoration: line-through;" : '';
|
||||||
$entry_list[] = "<span style=\"$style\">" . User_Nick_render($entry) . "</span>";
|
$entry_list[] = "<span style=\"$style\">" . User_Nick_render($entry) . "</span>";
|
||||||
}
|
|
||||||
$shift_signup_state = Shift_signup_allowed($user, $shift, $angeltype, null, null, $angeltype, $shift_entries);
|
|
||||||
$inner_text = sprintf(ngettext("%d helper needed", "%d helpers needed", $shift_signup_state->getFreeEntries()), $shift_signup_state->getFreeEntries());
|
|
||||||
switch ($shift_signup_state->getState()) {
|
|
||||||
case ShiftSignupState::ADMIN:
|
|
||||||
case ShiftSignupState::FREE:
|
|
||||||
// When admin or free display a link + button for sign up
|
|
||||||
$entry_list[] = '<a href="' . page_link_to('user_shifts') . '&shift_id=' . $shift['SID'] . '&type_id=' . $angeltype['id'] . '">' . $inner_text . '</a> ' . button(page_link_to('user_shifts') . '&shift_id=' . $shift['SID'] . '&type_id=' . $angeltype['id'], _('Sign up'), 'btn-xs btn-primary');
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ShiftSignupState::SHIFT_ENDED:
|
|
||||||
// No link and add a text hint, when the shift ended
|
|
||||||
$entry_list[] = $inner_text . ' (' . _('ended') . ')';
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ShiftSignupState::ANGELTYPE:
|
|
||||||
if ($angeltype['restricted'] == 1) {
|
|
||||||
// User has to be confirmed on the angeltype first
|
|
||||||
$entry_list[] = $inner_text . glyph('lock');
|
|
||||||
} else {
|
|
||||||
// Add link to join the angeltype first
|
|
||||||
$entry_list[] = $inner_text . '<br />' . button(page_link_to('user_angeltypes') . '&action=add&angeltype_id=' . $angeltype['id'], sprintf(_('Become %s'), $angeltype['name']), 'btn-xs');
|
|
||||||
}
|
}
|
||||||
break;
|
$shift_signup_state = Shift_signup_allowed($user, $shift, $angeltype, null, null, $angeltype, $shift_entries);
|
||||||
|
$inner_text = sprintf(
|
||||||
case ShiftSignupState::COLLIDES:
|
ngettext("%d helper needed", "%d helpers needed", $shift_signup_state->getFreeEntries()),
|
||||||
case ShiftSignupState::SIGNED_UP:
|
$shift_signup_state->getFreeEntries()
|
||||||
// Shift collides or user is already signed up: No signup allowed
|
);
|
||||||
$entry_list[] = $inner_text;
|
switch ($shift_signup_state->getState()) {
|
||||||
break;
|
case ShiftSignupState::ADMIN:
|
||||||
|
case ShiftSignupState::FREE:
|
||||||
case ShiftSignupState::OCCUPIED:
|
// When admin or free display a link + button for sign up
|
||||||
// Shift is full
|
$entry_list[] = '<a href="' . page_link_to('user_shifts') . '&shift_id=' . $shift['SID'] . '&type_id=' . $angeltype['id'] . '">'
|
||||||
break;
|
. $inner_text
|
||||||
}
|
. '</a> '
|
||||||
|
. button(
|
||||||
$shifts_row = '<li class="list-group-item">';
|
page_link_to('user_shifts') . '&shift_id=' . $shift['SID'] . '&type_id=' . $angeltype['id'],
|
||||||
$shifts_row .= '<strong>' . AngelType_name_render($angeltype) . ':</strong> ';
|
_('Sign up'), 'btn-xs btn-primary'
|
||||||
$shifts_row .= join(", ", $entry_list);
|
);
|
||||||
$shifts_row .= '</li>';
|
break;
|
||||||
return [
|
|
||||||
$shift_signup_state,
|
|
||||||
$shifts_row
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
case ShiftSignupState::SHIFT_ENDED:
|
||||||
* Renders the shift header
|
// No link and add a text hint, when the shift ended
|
||||||
*
|
$entry_list[] = $inner_text . ' (' . _('ended') . ')';
|
||||||
* @param Shift $shift
|
break;
|
||||||
* The shift
|
|
||||||
*/
|
case ShiftSignupState::ANGELTYPE:
|
||||||
private function renderShiftHead($shift)
|
if ($angeltype['restricted'] == 1) {
|
||||||
{
|
// User has to be confirmed on the angeltype first
|
||||||
global $privileges;
|
$entry_list[] = $inner_text . glyph('lock');
|
||||||
|
} else {
|
||||||
$header_buttons = "";
|
// Add link to join the angeltype first
|
||||||
if (in_array('admin_shifts', $privileges)) {
|
$entry_list[] = $inner_text . '<br />'
|
||||||
$header_buttons = '<div class="pull-right">' . table_buttons([
|
. button(
|
||||||
button(page_link_to('user_shifts') . '&edit_shift=' . $shift['SID'], glyph('edit'), 'btn-xs'),
|
page_link_to('user_angeltypes') . '&action=add&angeltype_id=' . $angeltype['id'],
|
||||||
button(page_link_to('user_shifts') . '&delete_shift=' . $shift['SID'], glyph('trash'), 'btn-xs')
|
sprintf(_('Become %s'), $angeltype['name']),
|
||||||
]) . '</div>';
|
'btn-xs'
|
||||||
}
|
);
|
||||||
$shift_heading = date('H:i', $shift['start']) . ' ‐ ' . date('H:i', $shift['end']) . ' — ' . $shift['name'];
|
}
|
||||||
return div('panel-heading', [
|
break;
|
||||||
'<a href="' . shift_link($shift) . '">' . $shift_heading . '</a>',
|
|
||||||
$header_buttons
|
case ShiftSignupState::COLLIDES:
|
||||||
]);
|
case ShiftSignupState::SIGNED_UP:
|
||||||
}
|
// Shift collides or user is already signed up: No signup allowed
|
||||||
|
$entry_list[] = $inner_text;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ShiftSignupState::OCCUPIED:
|
||||||
|
// Shift is full
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$shifts_row = '<li class="list-group-item">';
|
||||||
|
$shifts_row .= '<strong>' . AngelType_name_render($angeltype) . ':</strong> ';
|
||||||
|
$shifts_row .= join(", ", $entry_list);
|
||||||
|
$shifts_row .= '</li>';
|
||||||
|
return [
|
||||||
|
$shift_signup_state,
|
||||||
|
$shifts_row
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Renders the shift header
|
||||||
|
*
|
||||||
|
* @param Shift $shift
|
||||||
|
* The shift
|
||||||
|
*/
|
||||||
|
private function renderShiftHead($shift)
|
||||||
|
{
|
||||||
|
global $privileges;
|
||||||
|
|
||||||
|
$header_buttons = "";
|
||||||
|
if (in_array('admin_shifts', $privileges)) {
|
||||||
|
$header_buttons = '<div class="pull-right">' . table_buttons([
|
||||||
|
button(page_link_to('user_shifts') . '&edit_shift=' . $shift['SID'], glyph('edit'), 'btn-xs'),
|
||||||
|
button(page_link_to('user_shifts') . '&delete_shift=' . $shift['SID'], glyph('trash'), 'btn-xs')
|
||||||
|
]) . '</div>';
|
||||||
|
}
|
||||||
|
$shift_heading = date('H:i', $shift['start']) . ' ‐ '
|
||||||
|
. date('H:i', $shift['end']) . ' — '
|
||||||
|
. $shift['name'];
|
||||||
|
return div('panel-heading', [
|
||||||
|
'<a href="' . shift_link($shift) . '">' . $shift_heading . '</a>',
|
||||||
|
$header_buttons
|
||||||
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display form for adding/editing a shift entry.
|
* Display form for adding/editing a shift entry.
|
||||||
|
*
|
||||||
* @param string $angel
|
* @param string $angel
|
||||||
* @param string $date
|
* @param string $date
|
||||||
* @param string $location
|
* @param string $location
|
||||||
|
@ -11,26 +12,35 @@
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function ShiftEntry_edit_view($angel, $date, $location, $title, $type, $comment, $freeloaded, $freeload_comment, $user_admin_shifts = false)
|
function ShiftEntry_edit_view(
|
||||||
{
|
$angel,
|
||||||
|
$date,
|
||||||
|
$location,
|
||||||
|
$title,
|
||||||
|
$type,
|
||||||
|
$comment,
|
||||||
|
$freeloaded,
|
||||||
|
$freeload_comment,
|
||||||
|
$user_admin_shifts = false
|
||||||
|
) {
|
||||||
$freeload_form = [];
|
$freeload_form = [];
|
||||||
if ($user_admin_shifts) {
|
if ($user_admin_shifts) {
|
||||||
$freeload_form = [
|
$freeload_form = [
|
||||||
form_checkbox('freeloaded', _("Freeloaded"), $freeloaded),
|
form_checkbox('freeloaded', _("Freeloaded"), $freeloaded),
|
||||||
form_textarea('freeload_comment', _("Freeload comment (Only for shift coordination):"), $freeload_comment)
|
form_textarea('freeload_comment', _("Freeload comment (Only for shift coordination):"), $freeload_comment)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
return page_with_title(_("Edit shift entry"), [
|
return page_with_title(_("Edit shift entry"), [
|
||||||
msg(),
|
msg(),
|
||||||
form([
|
form([
|
||||||
form_info(_("Angel:"), $angel),
|
form_info(_("Angel:"), $angel),
|
||||||
form_info(_("Date, Duration:"), $date),
|
form_info(_("Date, Duration:"), $date),
|
||||||
form_info(_("Location:"), $location),
|
form_info(_("Location:"), $location),
|
||||||
form_info(_("Title:"), $title),
|
form_info(_("Title:"), $title),
|
||||||
form_info(_("Type:"), $type),
|
form_info(_("Type:"), $type),
|
||||||
form_textarea('comment', _("Comment (for your eyes only):"), $comment),
|
form_textarea('comment', _("Comment (for your eyes only):"), $comment),
|
||||||
join("", $freeload_form),
|
join("", $freeload_form),
|
||||||
form_submit('submit', _("Save"))
|
form_submit('submit', _("Save"))
|
||||||
])
|
])
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,36 +12,40 @@ function ShiftType_name_render($shifttype)
|
||||||
function ShiftType_delete_view($shifttype)
|
function ShiftType_delete_view($shifttype)
|
||||||
{
|
{
|
||||||
return page_with_title(sprintf(_("Delete shifttype %s"), $shifttype['name']), [
|
return page_with_title(sprintf(_("Delete shifttype %s"), $shifttype['name']), [
|
||||||
info(sprintf(_("Do you want to delete shifttype %s?"), $shifttype['name']), true),
|
info(sprintf(_("Do you want to delete shifttype %s?"), $shifttype['name']), true),
|
||||||
buttons([
|
buttons([
|
||||||
button(page_link_to('shifttypes'), _("cancel"), 'cancel'),
|
button(page_link_to('shifttypes'), _("cancel"), 'cancel'),
|
||||||
button(page_link_to('shifttypes') . '&action=delete&shifttype_id=' . $shifttype['id'] . '&confirmed', _("delete"), 'ok')
|
button(
|
||||||
])
|
page_link_to('shifttypes') . '&action=delete&shifttype_id=' . $shifttype['id'] . '&confirmed',
|
||||||
]);
|
_("delete"),
|
||||||
|
'ok'
|
||||||
|
)
|
||||||
|
])
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function ShiftType_edit_view($name, $angeltype_id, $angeltypes, $description, $shifttype_id)
|
function ShiftType_edit_view($name, $angeltype_id, $angeltypes, $description, $shifttype_id)
|
||||||
{
|
{
|
||||||
$angeltypes_select = [
|
$angeltypes_select = [
|
||||||
'' => _('All')
|
'' => _('All')
|
||||||
];
|
];
|
||||||
foreach ($angeltypes as $angeltype) {
|
foreach ($angeltypes as $angeltype) {
|
||||||
$angeltypes_select[$angeltype['id']] = $angeltype['name'];
|
$angeltypes_select[$angeltype['id']] = $angeltype['name'];
|
||||||
}
|
}
|
||||||
|
|
||||||
return page_with_title($shifttype_id ? _('Edit shifttype') : _('Create shifttype'), [
|
return page_with_title($shifttype_id ? _('Edit shifttype') : _('Create shifttype'), [
|
||||||
msg(),
|
msg(),
|
||||||
buttons([
|
buttons([
|
||||||
button(page_link_to('shifttypes'), shifttypes_title(), 'back')
|
button(page_link_to('shifttypes'), shifttypes_title(), 'back')
|
||||||
]),
|
]),
|
||||||
form([
|
form([
|
||||||
form_text('name', _('Name'), $name),
|
form_text('name', _('Name'), $name),
|
||||||
form_select('angeltype_id', _('Angeltype'), $angeltypes_select, $angeltype_id),
|
form_select('angeltype_id', _('Angeltype'), $angeltypes_select, $angeltype_id),
|
||||||
form_textarea('description', _('Description'), $description),
|
form_textarea('description', _('Description'), $description),
|
||||||
form_info('', _('Please use markdown for the description.')),
|
form_info('', _('Please use markdown for the description.')),
|
||||||
form_submit('submit', _('Save'))
|
form_submit('submit', _('Save'))
|
||||||
])
|
])
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function ShiftType_view($shifttype, $angeltype)
|
function ShiftType_view($shifttype, $angeltype)
|
||||||
|
@ -52,16 +56,23 @@ function ShiftType_view($shifttype, $angeltype)
|
||||||
$title .= ' <small>' . sprintf(_('for team %s'), $angeltype['name']) . '</small>';
|
$title .= ' <small>' . sprintf(_('for team %s'), $angeltype['name']) . '</small>';
|
||||||
}
|
}
|
||||||
return page_with_title($title, [
|
return page_with_title($title, [
|
||||||
msg(),
|
msg(),
|
||||||
buttons([
|
buttons([
|
||||||
button(page_link_to('shifttypes'), shifttypes_title(), 'back'),
|
button(page_link_to('shifttypes'), shifttypes_title(), 'back'),
|
||||||
$angeltype ? button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], $angeltype['name']) : '',
|
$angeltype ? button(
|
||||||
button(page_link_to('shifttypes') . '&action=edit&shifttype_id=' . $shifttype['id'], _('edit'), 'edit'),
|
page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'],
|
||||||
button(page_link_to('shifttypes') . '&action=delete&shifttype_id=' . $shifttype['id'], _('delete'), 'delete')
|
$angeltype['name']
|
||||||
]),
|
) : '',
|
||||||
heading(_("Description"), 2),
|
button(page_link_to('shifttypes') . '&action=edit&shifttype_id=' . $shifttype['id'], _('edit'), 'edit'),
|
||||||
$parsedown->parse($shifttype['description'])
|
button(
|
||||||
]);
|
page_link_to('shifttypes') . '&action=delete&shifttype_id=' . $shifttype['id'],
|
||||||
|
_('delete'),
|
||||||
|
'delete'
|
||||||
|
)
|
||||||
|
]),
|
||||||
|
heading(_("Description"), 2),
|
||||||
|
$parsedown->parse($shifttype['description'])
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function ShiftTypes_list_view($shifttypes)
|
function ShiftTypes_list_view($shifttypes)
|
||||||
|
@ -69,19 +80,23 @@ function ShiftTypes_list_view($shifttypes)
|
||||||
foreach ($shifttypes as &$shifttype) {
|
foreach ($shifttypes as &$shifttype) {
|
||||||
$shifttype['name'] = '<a href="' . page_link_to('shifttypes') . '&action=view&shifttype_id=' . $shifttype['id'] . '">' . $shifttype['name'] . '</a>';
|
$shifttype['name'] = '<a href="' . page_link_to('shifttypes') . '&action=view&shifttype_id=' . $shifttype['id'] . '">' . $shifttype['name'] . '</a>';
|
||||||
$shifttype['actions'] = table_buttons([
|
$shifttype['actions'] = table_buttons([
|
||||||
button(page_link_to('shifttypes') . '&action=edit&shifttype_id=' . $shifttype['id'], _('edit'), 'btn-xs'),
|
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')
|
button(
|
||||||
]);
|
page_link_to('shifttypes') . '&action=delete&shifttype_id=' . $shifttype['id'],
|
||||||
|
_('delete'),
|
||||||
|
'btn-xs'
|
||||||
|
)
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return page_with_title(shifttypes_title(), [
|
return page_with_title(shifttypes_title(), [
|
||||||
msg(),
|
msg(),
|
||||||
buttons([
|
buttons([
|
||||||
button(page_link_to('shifttypes') . '&action=edit', _('New shifttype'), 'add')
|
button(page_link_to('shifttypes') . '&action=edit', _('New shifttype'), 'add')
|
||||||
]),
|
]),
|
||||||
table([
|
table([
|
||||||
'name' => _('Name'),
|
'name' => _('Name'),
|
||||||
'actions' => ''
|
'actions' => ''
|
||||||
], $shifttypes)
|
], $shifttypes)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,68 +5,68 @@ namespace Engelsystem;
|
||||||
class ShiftsFilterRenderer
|
class ShiftsFilterRenderer
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The shiftFilter to render.
|
* The shiftFilter to render.
|
||||||
*
|
*
|
||||||
* @var ShiftsFilter
|
* @var ShiftsFilter
|
||||||
*/
|
*/
|
||||||
private $shiftsFilter;
|
private $shiftsFilter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Should the filter display a day selection.
|
* Should the filter display a day selection.
|
||||||
*
|
*
|
||||||
* @var boolean
|
* @var boolean
|
||||||
*/
|
*/
|
||||||
private $daySelectionEnabled = false;
|
private $daySelectionEnabled = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Days that can be selected.
|
* Days that can be selected.
|
||||||
* Format Y-m-d
|
* Format Y-m-d
|
||||||
*
|
*
|
||||||
* @var string[]
|
* @var string[]
|
||||||
*/
|
*/
|
||||||
private $days = [];
|
private $days = [];
|
||||||
|
|
||||||
public function __construct(ShiftsFilter $shiftsFilter)
|
public function __construct(ShiftsFilter $shiftsFilter)
|
||||||
{
|
{
|
||||||
$this->shiftsFilter = $shiftsFilter;
|
$this->shiftsFilter = $shiftsFilter;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renders the filter.
|
* Renders the filter.
|
||||||
*
|
*
|
||||||
* @return Generated HTML
|
* @return Generated HTML
|
||||||
*/
|
*/
|
||||||
public function render($link_base)
|
public function render($link_base)
|
||||||
{
|
{
|
||||||
$toolbar = [];
|
$toolbar = [];
|
||||||
if ($this->daySelectionEnabled && ! empty($this->days)) {
|
if ($this->daySelectionEnabled && !empty($this->days)) {
|
||||||
$selected_day = date("Y-m-d", $this->shiftsFilter->getStartTime());
|
$selected_day = date("Y-m-d", $this->shiftsFilter->getStartTime());
|
||||||
$day_dropdown_items = [];
|
$day_dropdown_items = [];
|
||||||
foreach ($this->days as $day) {
|
foreach ($this->days as $day) {
|
||||||
$day_dropdown_items[] = toolbar_item_link($link_base . '&shifts_filter_day=' . $day, '', $day);
|
$day_dropdown_items[] = toolbar_item_link($link_base . '&shifts_filter_day=' . $day, '', $day);
|
||||||
}
|
}
|
||||||
$toolbar[] = toolbar_dropdown('', $selected_day, $day_dropdown_items, 'active');
|
$toolbar[] = toolbar_dropdown('', $selected_day, $day_dropdown_items, 'active');
|
||||||
}
|
}
|
||||||
return div('form-group', [
|
return div('form-group', [
|
||||||
toolbar_pills($toolbar)
|
toolbar_pills($toolbar)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Should the filter display a day selection.
|
* Should the filter display a day selection.
|
||||||
*/
|
*/
|
||||||
public function enableDaySelection($days)
|
public function enableDaySelection($days)
|
||||||
{
|
{
|
||||||
$this->daySelectionEnabled = true;
|
$this->daySelectionEnabled = true;
|
||||||
$this->days = $days;
|
$this->days = $days;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Should the filter display a day selection.
|
* Should the filter display a day selection.
|
||||||
*/
|
*/
|
||||||
public function isDaySelectionEnabled()
|
public function isDaySelectionEnabled()
|
||||||
{
|
{
|
||||||
return $this->daySelectionEnabled;
|
return $this->daySelectionEnabled;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,10 +5,18 @@ function Shift_editor_info_render($shift)
|
||||||
{
|
{
|
||||||
$info = [];
|
$info = [];
|
||||||
if ($shift['created_by_user_id'] != null) {
|
if ($shift['created_by_user_id'] != null) {
|
||||||
$info[] = sprintf(glyph('plus') . _("created at %s by %s"), date('Y-m-d H:i', $shift['created_at_timestamp']), User_Nick_render(User($shift['created_by_user_id'])));
|
$info[] = sprintf(
|
||||||
|
glyph('plus') . _("created at %s by %s"),
|
||||||
|
date('Y-m-d H:i', $shift['created_at_timestamp']),
|
||||||
|
User_Nick_render(User($shift['created_by_user_id']))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if ($shift['edited_by_user_id'] != null) {
|
if ($shift['edited_by_user_id'] != null) {
|
||||||
$info[] = sprintf(glyph('pencil') . _("edited at %s by %s"), date('Y-m-d H:i', $shift['edited_at_timestamp']), User_Nick_render(User($shift['edited_by_user_id'])));
|
$info[] = sprintf(
|
||||||
|
glyph('pencil') . _("edited at %s by %s"),
|
||||||
|
date('Y-m-d H:i', $shift['edited_at_timestamp']),
|
||||||
|
User_Nick_render(User($shift['edited_by_user_id']))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return join('<br />', $info);
|
return join('<br />', $info);
|
||||||
}
|
}
|
||||||
|
@ -16,15 +24,22 @@ function Shift_editor_info_render($shift)
|
||||||
function Shift_signup_button_render($shift, $angeltype, $user_angeltype = null)
|
function Shift_signup_button_render($shift, $angeltype, $user_angeltype = null)
|
||||||
{
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
if ($user_angeltype == null) {
|
if ($user_angeltype == null) {
|
||||||
$user_angeltype = UserAngelType_by_User_and_AngelType($user, $angeltype);
|
$user_angeltype = UserAngelType_by_User_and_AngelType($user, $angeltype);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($angeltype['shift_signup_state']->isSignupAllowed()) {
|
if ($angeltype['shift_signup_state']->isSignupAllowed()) {
|
||||||
return button(page_link_to('user_shifts') . '&shift_id=' . $shift['SID'] . '&type_id=' . $angeltype['id'], _('Sign up'));
|
return button(
|
||||||
|
page_link_to('user_shifts') . '&shift_id=' . $shift['SID'] . '&type_id=' . $angeltype['id'],
|
||||||
|
_('Sign up')
|
||||||
|
);
|
||||||
} elseif ($user_angeltype == null) {
|
} elseif ($user_angeltype == null) {
|
||||||
return button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], sprintf(_('Become %s'), $angeltype['name']));
|
return button(
|
||||||
|
page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'],
|
||||||
|
sprintf(_('Become %s'),
|
||||||
|
$angeltype['name'])
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
@ -32,83 +47,90 @@ function Shift_signup_button_render($shift, $angeltype, $user_angeltype = null)
|
||||||
function Shift_view($shift, $shifttype, $room, $angeltypes_source, ShiftSignupState $shift_signup_state)
|
function Shift_view($shift, $shifttype, $room, $angeltypes_source, ShiftSignupState $shift_signup_state)
|
||||||
{
|
{
|
||||||
global $privileges;
|
global $privileges;
|
||||||
|
|
||||||
$shift_admin = in_array('admin_shifts', $privileges);
|
$shift_admin = in_array('admin_shifts', $privileges);
|
||||||
$user_shift_admin = in_array('user_shifts_admin', $privileges);
|
$user_shift_admin = in_array('user_shifts_admin', $privileges);
|
||||||
$admin_rooms = in_array('admin_rooms', $privileges);
|
$admin_rooms = in_array('admin_rooms', $privileges);
|
||||||
$admin_shifttypes = in_array('shifttypes', $privileges);
|
$admin_shifttypes = in_array('shifttypes', $privileges);
|
||||||
|
|
||||||
$parsedown = new Parsedown();
|
$parsedown = new Parsedown();
|
||||||
|
|
||||||
$angeltypes = [];
|
$angeltypes = [];
|
||||||
foreach ($angeltypes_source as $angeltype) {
|
foreach ($angeltypes_source as $angeltype) {
|
||||||
$angeltypes[$angeltype['id']] = $angeltype;
|
$angeltypes[$angeltype['id']] = $angeltype;
|
||||||
}
|
}
|
||||||
|
|
||||||
$needed_angels = '';
|
$needed_angels = '';
|
||||||
foreach ($shift['NeedAngels'] as $needed_angeltype) {
|
foreach ($shift['NeedAngels'] as $needed_angeltype) {
|
||||||
$needed_angels .= Shift_view_render_needed_angeltype($needed_angeltype, $angeltypes, $shift, $user_shift_admin);
|
$needed_angels .= Shift_view_render_needed_angeltype($needed_angeltype, $angeltypes, $shift, $user_shift_admin);
|
||||||
}
|
}
|
||||||
|
|
||||||
return page_with_title($shift['name'] . ' <small class="moment-countdown" data-timestamp="' . $shift['start'] . '">%c</small>', [
|
return page_with_title(
|
||||||
msg(),
|
$shift['name'] . ' <small class="moment-countdown" data-timestamp="' . $shift['start'] . '">%c</small>',
|
||||||
$shift_signup_state->getState() == ShiftSignupState::COLLIDES ? info(_('This shift collides with one of your shifts.'), true) : '',
|
[
|
||||||
$shift_signup_state->getState() == ShiftSignupState::SIGNED_UP ? info(_('You are signed up for this shift.'), true) : '',
|
msg(),
|
||||||
($shift_admin || $admin_shifttypes || $admin_rooms) ? buttons([
|
$shift_signup_state->getState() == ShiftSignupState::COLLIDES
|
||||||
$shift_admin ? button(shift_edit_link($shift), glyph('pencil') . _('edit')) : '',
|
? info(_('This shift collides with one of your shifts.'), true)
|
||||||
$shift_admin ? button(shift_delete_link($shift), glyph('trash') . _('delete')) : '',
|
: '',
|
||||||
$admin_shifttypes ? button(shifttype_link($shifttype), $shifttype['name']) : '',
|
$shift_signup_state->getState() == ShiftSignupState::SIGNED_UP
|
||||||
$admin_rooms ? button(room_link($room), glyph('map-marker') . $room['Name']) : ''
|
? info(_('You are signed up for this shift.'), true)
|
||||||
]) : '',
|
: '',
|
||||||
div('row', [
|
($shift_admin || $admin_shifttypes || $admin_rooms) ? buttons([
|
||||||
div('col-sm-3 col-xs-6', [
|
$shift_admin ? button(shift_edit_link($shift), glyph('pencil') . _('edit')) : '',
|
||||||
'<h4>' . _('Title') . '</h4>',
|
$shift_admin ? button(shift_delete_link($shift), glyph('trash') . _('delete')) : '',
|
||||||
'<p class="lead">' . ($shift['URL'] != '' ? '<a href="' . $shift['URL'] . '">' . $shift['title'] . '</a>' : $shift['title']) . '</p>'
|
$admin_shifttypes ? button(shifttype_link($shifttype), $shifttype['name']) : '',
|
||||||
]),
|
$admin_rooms ? button(room_link($room), glyph('map-marker') . $room['Name']) : ''
|
||||||
div('col-sm-3 col-xs-6', [
|
]) : '',
|
||||||
'<h4>' . _('Start') . '</h4>',
|
div('row', [
|
||||||
'<p class="lead' . (time() >= $shift['start'] ? ' text-success' : '') . '">',
|
div('col-sm-3 col-xs-6', [
|
||||||
glyph('calendar') . date(_('Y-m-d'), $shift['start']),
|
'<h4>' . _('Title') . '</h4>',
|
||||||
'<br />',
|
'<p class="lead">' . ($shift['URL'] != '' ? '<a href="' . $shift['URL'] . '">' . $shift['title'] . '</a>' : $shift['title']) . '</p>'
|
||||||
glyph('time') . date('H:i', $shift['start']),
|
]),
|
||||||
'</p>'
|
div('col-sm-3 col-xs-6', [
|
||||||
]),
|
'<h4>' . _('Start') . '</h4>',
|
||||||
div('col-sm-3 col-xs-6', [
|
'<p class="lead' . (time() >= $shift['start'] ? ' text-success' : '') . '">',
|
||||||
'<h4>' . _('End') . '</h4>',
|
glyph('calendar') . date(_('Y-m-d'), $shift['start']),
|
||||||
'<p class="lead' . (time() >= $shift['end'] ? ' text-success' : '') . '">',
|
'<br />',
|
||||||
glyph('calendar') . date(_('Y-m-d'), $shift['end']),
|
glyph('time') . date('H:i', $shift['start']),
|
||||||
'<br />',
|
'</p>'
|
||||||
glyph('time') . date('H:i', $shift['end']),
|
]),
|
||||||
'</p>'
|
div('col-sm-3 col-xs-6', [
|
||||||
]),
|
'<h4>' . _('End') . '</h4>',
|
||||||
div('col-sm-3 col-xs-6', [
|
'<p class="lead' . (time() >= $shift['end'] ? ' text-success' : '') . '">',
|
||||||
'<h4>' . _('Location') . '</h4>',
|
glyph('calendar') . date(_('Y-m-d'), $shift['end']),
|
||||||
'<p class="lead">' . Room_name_render($room) . '</p>'
|
'<br />',
|
||||||
])
|
glyph('time') . date('H:i', $shift['end']),
|
||||||
]),
|
'</p>'
|
||||||
div('row', [
|
]),
|
||||||
div('col-sm-6', [
|
div('col-sm-3 col-xs-6', [
|
||||||
'<h2>' . _('Needed angels') . '</h2>',
|
'<h4>' . _('Location') . '</h4>',
|
||||||
'<div class="list-group">' . $needed_angels . '</div>'
|
'<p class="lead">' . Room_name_render($room) . '</p>'
|
||||||
]),
|
])
|
||||||
div('col-sm-6', [
|
]),
|
||||||
'<h2>' . _('Description') . '</h2>',
|
div('row', [
|
||||||
$parsedown->parse($shifttype['description'])
|
div('col-sm-6', [
|
||||||
])
|
'<h2>' . _('Needed angels') . '</h2>',
|
||||||
]),
|
'<div class="list-group">' . $needed_angels . '</div>'
|
||||||
$shift_admin ? Shift_editor_info_render($shift) : ''
|
]),
|
||||||
]);
|
div('col-sm-6', [
|
||||||
|
'<h2>' . _('Description') . '</h2>',
|
||||||
|
$parsedown->parse($shifttype['description'])
|
||||||
|
])
|
||||||
|
]),
|
||||||
|
$shift_admin ? Shift_editor_info_render($shift) : ''
|
||||||
|
]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function Shift_view_render_needed_angeltype($needed_angeltype, $angeltypes, $shift, $user_shift_admin)
|
function Shift_view_render_needed_angeltype($needed_angeltype, $angeltypes, $shift, $user_shift_admin)
|
||||||
{
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
$angeltype = $angeltypes[$needed_angeltype['TID']];
|
$angeltype = $angeltypes[$needed_angeltype['TID']];
|
||||||
$angeltype_supporter = User_is_AngelType_supporter($user, $angeltype);
|
$angeltype_supporter = User_is_AngelType_supporter($user, $angeltype);
|
||||||
|
|
||||||
$needed_angels = '';
|
$needed_angels = '';
|
||||||
|
|
||||||
$class = 'progress-bar-warning';
|
$class = 'progress-bar-warning';
|
||||||
if ($needed_angeltype['taken'] == 0) {
|
if ($needed_angeltype['taken'] == 0) {
|
||||||
$class = 'progress-bar-danger';
|
$class = 'progress-bar-danger';
|
||||||
|
@ -117,24 +139,30 @@ function Shift_view_render_needed_angeltype($needed_angeltype, $angeltypes, $shi
|
||||||
$class = 'progress-bar-success';
|
$class = 'progress-bar-success';
|
||||||
}
|
}
|
||||||
$needed_angels .= '<div class="list-group-item">';
|
$needed_angels .= '<div class="list-group-item">';
|
||||||
|
|
||||||
$needed_angels .= '<div class="pull-right">' . Shift_signup_button_render($shift, $angeltype) . '</div>';
|
$needed_angels .= '<div class="pull-right">' . Shift_signup_button_render($shift, $angeltype) . '</div>';
|
||||||
|
|
||||||
$needed_angels .= '<h3>' . AngelType_name_render($angeltype) . '</h3>';
|
$needed_angels .= '<h3>' . AngelType_name_render($angeltype) . '</h3>';
|
||||||
$bar_max = max($needed_angeltype['count'] * 10, $needed_angeltype['taken'] * 10, 10);
|
$bar_max = max($needed_angeltype['count'] * 10, $needed_angeltype['taken'] * 10, 10);
|
||||||
$bar_value = max(1, $needed_angeltype['taken'] * 10);
|
$bar_value = max(1, $needed_angeltype['taken'] * 10);
|
||||||
$needed_angels .= progress_bar(0, $bar_max, $bar_value, $class, $needed_angeltype['taken'] . ' / ' . $needed_angeltype['count']);
|
$needed_angels .= progress_bar(
|
||||||
|
0,
|
||||||
|
$bar_max,
|
||||||
|
$bar_value,
|
||||||
|
$class,
|
||||||
|
$needed_angeltype['taken'] . ' / ' . $needed_angeltype['count']
|
||||||
|
);
|
||||||
|
|
||||||
$angels = [];
|
$angels = [];
|
||||||
foreach ($shift['ShiftEntry'] as $shift_entry) {
|
foreach ($shift['ShiftEntry'] as $shift_entry) {
|
||||||
if ($shift_entry['TID'] == $needed_angeltype['TID']) {
|
if ($shift_entry['TID'] == $needed_angeltype['TID']) {
|
||||||
$angels[] = Shift_view_render_shift_entry($shift_entry, $user_shift_admin, $angeltype_supporter);
|
$angels[] = Shift_view_render_shift_entry($shift_entry, $user_shift_admin, $angeltype_supporter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$needed_angels .= join(', ', $angels);
|
$needed_angels .= join(', ', $angels);
|
||||||
$needed_angels .= '</div>';
|
$needed_angels .= '</div>';
|
||||||
|
|
||||||
return $needed_angels;
|
return $needed_angels;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,7 +175,11 @@ function Shift_view_render_shift_entry($shift_entry, $user_shift_admin, $angelty
|
||||||
if ($user_shift_admin || $angeltype_supporter) {
|
if ($user_shift_admin || $angeltype_supporter) {
|
||||||
$entry .= ' <div class="btn-group">';
|
$entry .= ' <div class="btn-group">';
|
||||||
if ($user_shift_admin) {
|
if ($user_shift_admin) {
|
||||||
$entry .= button_glyph(page_link_to('user_myshifts') . '&edit=' . $shift_entry['id'] . '&id=' . $shift_entry['UID'], 'pencil', 'btn-xs');
|
$entry .= button_glyph(
|
||||||
|
page_link_to('user_myshifts') . '&edit=' . $shift_entry['id'] . '&id=' . $shift_entry['UID'],
|
||||||
|
'pencil',
|
||||||
|
'btn-xs'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
$entry .= button_glyph(page_link_to('user_shifts') . '&entry_id=' . $shift_entry['id'], 'trash', 'btn-xs');
|
$entry .= button_glyph(page_link_to('user_shifts') . '&entry_id=' . $shift_entry['id'], 'trash', 'btn-xs');
|
||||||
$entry .= '</div>';
|
$entry .= '</div>';
|
||||||
|
|
|
@ -3,61 +3,90 @@
|
||||||
function UserAngelType_update_view($user_angeltype, $user, $angeltype, $supporter)
|
function UserAngelType_update_view($user_angeltype, $user, $angeltype, $supporter)
|
||||||
{
|
{
|
||||||
return page_with_title($supporter ? _("Add supporter rights") : _("Remove supporter rights"), [
|
return page_with_title($supporter ? _("Add supporter rights") : _("Remove supporter rights"), [
|
||||||
msg(),
|
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),
|
info(sprintf(
|
||||||
buttons([
|
$supporter
|
||||||
button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _("cancel"), 'cancel'),
|
? _("Do you really want to add supporter rights for %s to %s?")
|
||||||
button(page_link_to('user_angeltypes') . '&action=update&user_angeltype_id=' . $user_angeltype['id'] . '&supporter=' . ($supporter ? '1' : '0') . '&confirmed', _("yes"), 'ok')
|
: _("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)
|
function UserAngelTypes_delete_all_view($angeltype)
|
||||||
{
|
{
|
||||||
return page_with_title(_("Deny all users"), [
|
return page_with_title(_("Deny all users"), [
|
||||||
msg(),
|
msg(),
|
||||||
info(sprintf(_("Do you really want to deny all users for %s?"), $angeltype['name']), true),
|
info(sprintf(_("Do you really want to deny all users for %s?"), $angeltype['name']), true),
|
||||||
buttons([
|
buttons([
|
||||||
button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _("cancel"), 'cancel'),
|
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')
|
button(
|
||||||
])
|
page_link_to('user_angeltypes') . '&action=delete_all&angeltype_id=' . $angeltype['id'] . '&confirmed',
|
||||||
]);
|
_("yes"),
|
||||||
|
'ok'
|
||||||
|
)
|
||||||
|
])
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function UserAngelTypes_confirm_all_view($angeltype)
|
function UserAngelTypes_confirm_all_view($angeltype)
|
||||||
{
|
{
|
||||||
return page_with_title(_("Confirm all users"), [
|
return page_with_title(_("Confirm all users"), [
|
||||||
msg(),
|
msg(),
|
||||||
info(sprintf(_("Do you really want to confirm all users for %s?"), $angeltype['name']), true),
|
info(sprintf(_("Do you really want to confirm all users for %s?"), $angeltype['name']), true),
|
||||||
buttons([
|
buttons([
|
||||||
button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _("cancel"), 'cancel'),
|
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')
|
button(
|
||||||
])
|
page_link_to('user_angeltypes') . '&action=confirm_all&angeltype_id=' . $angeltype['id'] . '&confirmed',
|
||||||
]);
|
_("yes"),
|
||||||
|
'ok'
|
||||||
|
)
|
||||||
|
])
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function UserAngelType_confirm_view($user_angeltype, $user, $angeltype)
|
function UserAngelType_confirm_view($user_angeltype, $user, $angeltype)
|
||||||
{
|
{
|
||||||
return page_with_title(_("Confirm angeltype for user"), [
|
return page_with_title(_("Confirm angeltype for user"), [
|
||||||
msg(),
|
msg(),
|
||||||
info(sprintf(_("Do you really want to confirm %s for %s?"), User_Nick_render($user), $angeltype['name']), true),
|
info(sprintf(_("Do you really want to confirm %s for %s?"), User_Nick_render($user), $angeltype['name']), true),
|
||||||
buttons([
|
buttons([
|
||||||
button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _("cancel"), 'cancel'),
|
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')
|
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)
|
function UserAngelType_delete_view($user_angeltype, $user, $angeltype)
|
||||||
{
|
{
|
||||||
return page_with_title(_("Remove angeltype"), [
|
return page_with_title(_("Remove angeltype"), [
|
||||||
msg(),
|
msg(),
|
||||||
info(sprintf(_("Do you really want to delete %s from %s?"), User_Nick_render($user), $angeltype['name']), true),
|
info(sprintf(_("Do you really want to delete %s from %s?"), User_Nick_render($user), $angeltype['name']), true),
|
||||||
buttons([
|
buttons([
|
||||||
button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _("cancel"), 'cancel'),
|
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')
|
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)
|
function UserAngelType_add_view($angeltype, $users_source, $user_id)
|
||||||
|
@ -66,28 +95,32 @@ function UserAngelType_add_view($angeltype, $users_source, $user_id)
|
||||||
foreach ($users_source as $user_source) {
|
foreach ($users_source as $user_source) {
|
||||||
$users[$user_source['UID']] = User_Nick_render($user_source);
|
$users[$user_source['UID']] = User_Nick_render($user_source);
|
||||||
}
|
}
|
||||||
|
|
||||||
return page_with_title(_("Add user to angeltype"), [
|
return page_with_title(_("Add user to angeltype"), [
|
||||||
msg(),
|
msg(),
|
||||||
buttons([
|
buttons([
|
||||||
button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _("back"), 'back')
|
button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _("back"), 'back')
|
||||||
]),
|
]),
|
||||||
form([
|
form([
|
||||||
form_info(_("Angeltype"), $angeltype['name']),
|
form_info(_("Angeltype"), $angeltype['name']),
|
||||||
form_select('user_id', _("User"), $users, $user_id),
|
form_select('user_id', _("User"), $users, $user_id),
|
||||||
form_submit('submit', _("Add"))
|
form_submit('submit', _("Add"))
|
||||||
])
|
])
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function UserAngelType_join_view($user, $angeltype)
|
function UserAngelType_join_view($user, $angeltype)
|
||||||
{
|
{
|
||||||
return page_with_title(sprintf(_("Become a %s"), $angeltype['name']), [
|
return page_with_title(sprintf(_("Become a %s"), $angeltype['name']), [
|
||||||
msg(),
|
msg(),
|
||||||
info(sprintf(_("Do you really want to add %s to %s?"), User_Nick_render($user), $angeltype['name']), true),
|
info(sprintf(_("Do you really want to add %s to %s?"), User_Nick_render($user), $angeltype['name']), true),
|
||||||
buttons([
|
buttons([
|
||||||
button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _("cancel"), 'cancel'),
|
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')
|
button(
|
||||||
])
|
page_link_to('user_angeltypes') . '&action=add&angeltype_id=' . $angeltype['id'] . '&user_id=' . $user['UID'] . '&confirmed',
|
||||||
]);
|
_("save"),
|
||||||
|
'ok'
|
||||||
|
)
|
||||||
|
])
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@
|
||||||
/**
|
/**
|
||||||
* Edit a user's driving license information.
|
* Edit a user's driving license information.
|
||||||
*
|
*
|
||||||
* @param User $user_source
|
* @param User $user_source
|
||||||
* The user
|
* The user
|
||||||
* @param bool $wants_to_drive
|
* @param bool $wants_to_drive
|
||||||
* true, if the user wants to drive
|
* true, if the user wants to drive
|
||||||
* @param UserDriverLicense $user_driver_license
|
* @param UserDriverLicense $user_driver_license
|
||||||
* The user driver license
|
* The user driver license
|
||||||
|
@ -14,27 +14,43 @@
|
||||||
function UserDriverLicense_edit_view($user_source, $wants_to_drive, $user_driver_license)
|
function UserDriverLicense_edit_view($user_source, $wants_to_drive, $user_driver_license)
|
||||||
{
|
{
|
||||||
return page_with_title(sprintf(_("Edit %s driving license information"), User_Nick_render($user_source)), [
|
return page_with_title(sprintf(_("Edit %s driving license information"), User_Nick_render($user_source)), [
|
||||||
buttons([
|
buttons([
|
||||||
button(user_link($user_source), _("Back to profile"), 'back')
|
button(user_link($user_source), _("Back to profile"), 'back')
|
||||||
]),
|
]),
|
||||||
msg(),
|
msg(),
|
||||||
form([
|
form([
|
||||||
form_info(_("Privacy"), _("Your driving license information is only visible for supporters and admins.")),
|
form_info(_("Privacy"), _("Your driving license information is only visible for supporters and admins.")),
|
||||||
form_checkbox('wants_to_drive', _("I am willing to operate cars for the PL"), $wants_to_drive),
|
form_checkbox('wants_to_drive', _("I am willing to operate cars for the PL"), $wants_to_drive),
|
||||||
div('panel panel-default', [
|
div('panel panel-default', [
|
||||||
div('panel-body', [
|
div('panel-body', [
|
||||||
form_checkbox('has_car', _("I have my own car with me and am willing to use it for the PL (You'll get reimbursed for fuel)"), $user_driver_license['has_car']),
|
form_checkbox(
|
||||||
heading(_("Driver license"), 3),
|
'has_car',
|
||||||
form_checkbox('has_license_car', _("Car"), $user_driver_license['has_license_car']),
|
_("I have my own car with me and am willing to use it for the PL (You'll get reimbursed for fuel)"),
|
||||||
form_checkbox('has_license_3_5t_transporter', _("Transporter 3,5t"), $user_driver_license['has_license_3_5t_transporter']),
|
$user_driver_license['has_car']
|
||||||
form_checkbox('has_license_7_5t_truck', _("Truck 7,5t"), $user_driver_license['has_license_7_5t_truck']),
|
),
|
||||||
form_checkbox('has_license_12_5t_truck', _("Truck 12,5t"), $user_driver_license['has_license_12_5t_truck']),
|
heading(_("Driver license"), 3),
|
||||||
form_checkbox('has_license_forklift', _("Forklift"), $user_driver_license['has_license_forklift'])
|
form_checkbox('has_license_car', _("Car"), $user_driver_license['has_license_car']),
|
||||||
])
|
form_checkbox(
|
||||||
], 'driving_license'),
|
'has_license_3_5t_transporter',
|
||||||
form_submit('submit', _("Save"))
|
_("Transporter 3,5t"),
|
||||||
]),
|
$user_driver_license['has_license_3_5t_transporter']
|
||||||
'<script type="text/javascript">
|
),
|
||||||
|
form_checkbox(
|
||||||
|
'has_license_7_5t_truck',
|
||||||
|
_("Truck 7,5t"),
|
||||||
|
$user_driver_license['has_license_7_5t_truck']
|
||||||
|
),
|
||||||
|
form_checkbox(
|
||||||
|
'has_license_12_5t_truck',
|
||||||
|
_("Truck 12,5t"),
|
||||||
|
$user_driver_license['has_license_12_5t_truck']
|
||||||
|
),
|
||||||
|
form_checkbox('has_license_forklift', _("Forklift"), $user_driver_license['has_license_forklift'])
|
||||||
|
])
|
||||||
|
], 'driving_license'),
|
||||||
|
form_submit('submit', _("Save"))
|
||||||
|
]),
|
||||||
|
'<script type="text/javascript">
|
||||||
$(function() {
|
$(function() {
|
||||||
if($("#wants_to_drive").is(":checked"))
|
if($("#wants_to_drive").is(":checked"))
|
||||||
$("#driving_license").show();
|
$("#driving_license").show();
|
||||||
|
@ -51,5 +67,5 @@ function UserDriverLicense_edit_view($user_source, $wants_to_drive, $user_driver
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
</script>'
|
</script>'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,54 +8,54 @@ class UserHintsRenderer
|
||||||
|
|
||||||
private $important = false;
|
private $important = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render the added hints to a popover for the toolbar.
|
* Render the added hints to a popover for the toolbar.
|
||||||
*/
|
*/
|
||||||
public function render()
|
public function render()
|
||||||
{
|
{
|
||||||
if (count($this->hints) > 0) {
|
if (count($this->hints) > 0) {
|
||||||
$hint_class = $this->important ? 'danger' : 'info';
|
$hint_class = $this->important ? 'danger' : 'info';
|
||||||
$glyphicon = $this->important ? 'warning-sign' : 'info-sign';
|
$glyphicon = $this->important ? 'warning-sign' : 'info-sign';
|
||||||
|
|
||||||
return toolbar_popover($glyphicon . ' text-' . $hint_class, '', $this->hints, 'bg-' . $hint_class);
|
|
||||||
}
|
|
||||||
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
return toolbar_popover($glyphicon . ' text-' . $hint_class, '', $this->hints, 'bg-' . $hint_class);
|
||||||
* Add a hint to the list, if its not null and a not empty string.
|
}
|
||||||
*
|
|
||||||
* @param string $hint
|
|
||||||
* The hint
|
|
||||||
* @param boolean $important
|
|
||||||
* Is the hint important?
|
|
||||||
*/
|
|
||||||
public function addHint($hint, $important = false)
|
|
||||||
{
|
|
||||||
if ($hint != null && $hint != '') {
|
|
||||||
if ($important) {
|
|
||||||
$this->important = true;
|
|
||||||
$this->hints[] = error($hint, true);
|
|
||||||
} else {
|
|
||||||
$this->hints[] = info($hint, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
return '';
|
||||||
* Get all hints.
|
}
|
||||||
*/
|
|
||||||
public function getHints()
|
|
||||||
{
|
|
||||||
return $this->hints;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Are there important hints? This leads to a more intensive icon.
|
* Add a hint to the list, if its not null and a not empty string.
|
||||||
*/
|
*
|
||||||
public function isImportant()
|
* @param string $hint
|
||||||
{
|
* The hint
|
||||||
return $this->important;
|
* @param boolean $important
|
||||||
}
|
* Is the hint important?
|
||||||
|
*/
|
||||||
|
public function addHint($hint, $important = false)
|
||||||
|
{
|
||||||
|
if ($hint != null && $hint != '') {
|
||||||
|
if ($important) {
|
||||||
|
$this->important = true;
|
||||||
|
$this->hints[] = error($hint, true);
|
||||||
|
} else {
|
||||||
|
$this->hints[] = info($hint, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all hints.
|
||||||
|
*/
|
||||||
|
public function getHints()
|
||||||
|
{
|
||||||
|
return $this->hints;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Are there important hints? This leads to a more intensive icon.
|
||||||
|
*/
|
||||||
|
public function isImportant()
|
||||||
|
{
|
||||||
|
return $this->important;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,18 +4,18 @@
|
||||||
* Available T-Shirt sizes
|
* Available T-Shirt sizes
|
||||||
*/
|
*/
|
||||||
$tshirt_sizes = [
|
$tshirt_sizes = [
|
||||||
'' => _("Please select..."),
|
'' => _("Please select..."),
|
||||||
'S' => "S",
|
'S' => "S",
|
||||||
'M' => "M",
|
'M' => "M",
|
||||||
'L' => "L",
|
'L' => "L",
|
||||||
'XL' => "XL",
|
'XL' => "XL",
|
||||||
'2XL' => "2XL",
|
'2XL' => "2XL",
|
||||||
'3XL' => "3XL",
|
'3XL' => "3XL",
|
||||||
'4XL' => "4XL",
|
'4XL' => "4XL",
|
||||||
'5XL' => "5XL",
|
'5XL' => "5XL",
|
||||||
'S-G' => "S Girl",
|
'S-G' => "S Girl",
|
||||||
'M-G' => "M Girl",
|
'M-G' => "M Girl",
|
||||||
'L-G' => "L Girl",
|
'L-G' => "L Girl",
|
||||||
'XL-G' => "XL Girl"
|
'XL-G' => "XL Girl"
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -23,61 +23,92 @@ $tshirt_sizes = [
|
||||||
* Renders user settings page
|
* Renders user settings page
|
||||||
*
|
*
|
||||||
* @param User $user_source
|
* @param User $user_source
|
||||||
* The user
|
* The user
|
||||||
* @param array<String> $locales
|
* @param array <String> $locales
|
||||||
* Available languages
|
* Available languages
|
||||||
* @param array<String> $themes
|
* @param array <String> $themes
|
||||||
* Available themes
|
* Available themes
|
||||||
*/
|
*/
|
||||||
function User_settings_view($user_source, $locales, $themes, $buildup_start_date, $teardown_end_date, $enable_tshirt_size, $tshirt_sizes)
|
function User_settings_view(
|
||||||
{
|
$user_source,
|
||||||
|
$locales,
|
||||||
|
$themes,
|
||||||
|
$buildup_start_date,
|
||||||
|
$teardown_end_date,
|
||||||
|
$enable_tshirt_size,
|
||||||
|
$tshirt_sizes
|
||||||
|
) {
|
||||||
return page_with_title(settings_title(), [
|
return page_with_title(settings_title(), [
|
||||||
msg(),
|
msg(),
|
||||||
div('row', [
|
div('row', [
|
||||||
div('col-md-6', [
|
div('col-md-6', [
|
||||||
form([
|
form([
|
||||||
form_info('', _("Here you can change your user details.")),
|
form_info('', _("Here you can change your user details.")),
|
||||||
form_info(entry_required() . ' = ' . _("Entry required!")),
|
form_info(entry_required() . ' = ' . _("Entry required!")),
|
||||||
form_text('nick', _("Nick"), $user_source['Nick'], true),
|
form_text('nick', _("Nick"), $user_source['Nick'], true),
|
||||||
form_text('lastname', _("Last name"), $user_source['Name']),
|
form_text('lastname', _("Last name"), $user_source['Name']),
|
||||||
form_text('prename', _("First name"), $user_source['Vorname']),
|
form_text('prename', _("First name"), $user_source['Vorname']),
|
||||||
form_date('planned_arrival_date', _("Planned date of arrival") . ' ' . entry_required(), $user_source['planned_arrival_date'], $buildup_start_date, $teardown_end_date),
|
form_date(
|
||||||
form_date('planned_departure_date', _("Planned date of departure"), $user_source['planned_departure_date'], $buildup_start_date, $teardown_end_date),
|
'planned_arrival_date',
|
||||||
form_text('age', _("Age"), $user_source['Alter']),
|
_("Planned date of arrival") . ' ' . entry_required(),
|
||||||
form_text('tel', _("Phone"), $user_source['Telefon']),
|
$user_source['planned_arrival_date'],
|
||||||
form_text('dect', _("DECT"), $user_source['DECT']),
|
$buildup_start_date, $teardown_end_date
|
||||||
form_text('mobile', _("Mobile"), $user_source['Handy']),
|
),
|
||||||
form_text('mail', _("E-Mail") . ' ' . entry_required(), $user_source['email']),
|
form_date(
|
||||||
form_checkbox('email_shiftinfo', _("The engelsystem is allowed to send me an email (e.g. when my shifts change)"), $user_source['email_shiftinfo']),
|
'planned_departure_date',
|
||||||
form_checkbox('email_by_human_allowed', _("Humans are allowed to send me an email (e.g. for ticket vouchers)"), $user_source['email_by_human_allowed']),
|
_("Planned date of departure"),
|
||||||
form_text('jabber', _("Jabber"), $user_source['jabber']),
|
$user_source['planned_departure_date'],
|
||||||
form_text('hometown', _("Hometown"), $user_source['Hometown']),
|
$buildup_start_date,
|
||||||
$enable_tshirt_size ? form_select('tshirt_size', _("Shirt size"), $tshirt_sizes, $user_source['Size']) : '',
|
$teardown_end_date
|
||||||
form_info('', _('Please visit the angeltypes page to manage your angeltypes.')),
|
),
|
||||||
form_submit('submit', _("Save"))
|
form_text('age', _("Age"), $user_source['Alter']),
|
||||||
])
|
form_text('tel', _("Phone"), $user_source['Telefon']),
|
||||||
]),
|
form_text('dect', _("DECT"), $user_source['DECT']),
|
||||||
div('col-md-6', [
|
form_text('mobile', _("Mobile"), $user_source['Handy']),
|
||||||
form([
|
form_text('mail', _("E-Mail") . ' ' . entry_required(), $user_source['email']),
|
||||||
form_info(_("Here you can change your password.")),
|
form_checkbox(
|
||||||
form_password('password', _("Old password:")),
|
'email_shiftinfo',
|
||||||
form_password('new_password', _("New password:")),
|
_("The engelsystem is allowed to send me an email (e.g. when my shifts change)"),
|
||||||
form_password('new_password2', _("Password confirmation:")),
|
$user_source['email_shiftinfo']
|
||||||
form_submit('submit_password', _("Save"))
|
),
|
||||||
]),
|
form_checkbox(
|
||||||
form([
|
'email_by_human_allowed',
|
||||||
form_info(_("Here you can choose your color settings:")),
|
_("Humans are allowed to send me an email (e.g. for ticket vouchers)"),
|
||||||
form_select('theme', _("Color settings:"), $themes, $user_source['color']),
|
$user_source['email_by_human_allowed']
|
||||||
form_submit('submit_theme', _("Save"))
|
),
|
||||||
]),
|
form_text('jabber', _("Jabber"), $user_source['jabber']),
|
||||||
form([
|
form_text('hometown', _("Hometown"), $user_source['Hometown']),
|
||||||
form_info(_("Here you can choose your language:")),
|
$enable_tshirt_size ? form_select(
|
||||||
form_select('language', _("Language:"), $locales, $user_source['Sprache']),
|
'tshirt_size',
|
||||||
form_submit('submit_language', _("Save"))
|
_("Shirt size"),
|
||||||
])
|
$tshirt_sizes,
|
||||||
])
|
$user_source['Size']
|
||||||
])
|
) : '',
|
||||||
]);
|
form_info('', _('Please visit the angeltypes page to manage your angeltypes.')),
|
||||||
|
form_submit('submit', _("Save"))
|
||||||
|
])
|
||||||
|
]),
|
||||||
|
div('col-md-6', [
|
||||||
|
form([
|
||||||
|
form_info(_("Here you can change your password.")),
|
||||||
|
form_password('password', _("Old password:")),
|
||||||
|
form_password('new_password', _("New password:")),
|
||||||
|
form_password('new_password2', _("Password confirmation:")),
|
||||||
|
form_submit('submit_password', _("Save"))
|
||||||
|
]),
|
||||||
|
form([
|
||||||
|
form_info(_("Here you can choose your color settings:")),
|
||||||
|
form_select('theme', _("Color settings:"), $themes, $user_source['color']),
|
||||||
|
form_submit('submit_theme', _("Save"))
|
||||||
|
]),
|
||||||
|
form([
|
||||||
|
form_info(_("Here you can choose your language:")),
|
||||||
|
form_select('language', _("Language:"), $locales, $user_source['Sprache']),
|
||||||
|
form_submit('submit_language', _("Save"))
|
||||||
|
])
|
||||||
|
])
|
||||||
|
])
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -88,32 +119,32 @@ function User_registration_success_view($event_welcome_message)
|
||||||
$parsedown = new Parsedown();
|
$parsedown = new Parsedown();
|
||||||
$event_welcome_message = $parsedown->text($event_welcome_message);
|
$event_welcome_message = $parsedown->text($event_welcome_message);
|
||||||
return page_with_title(_("Registration successful"), [
|
return page_with_title(_("Registration successful"), [
|
||||||
msg(),
|
msg(),
|
||||||
div('row', [
|
div('row', [
|
||||||
div('col-md-4', [
|
div('col-md-4', [
|
||||||
$event_welcome_message
|
$event_welcome_message
|
||||||
]),
|
]),
|
||||||
div('col-md-4', [
|
div('col-md-4', [
|
||||||
'<h2>' . _("Login") . '</h2>',
|
'<h2>' . _("Login") . '</h2>',
|
||||||
form([
|
form([
|
||||||
form_text('nick', _("Nick"), ""),
|
form_text('nick', _("Nick"), ""),
|
||||||
form_password('password', _("Password")),
|
form_password('password', _("Password")),
|
||||||
form_submit('submit', _("Login")),
|
form_submit('submit', _("Login")),
|
||||||
buttons([
|
buttons([
|
||||||
button(page_link_to('user_password_recovery'), _("I forgot my password"))
|
button(page_link_to('user_password_recovery'), _("I forgot my password"))
|
||||||
]),
|
]),
|
||||||
info(_("Please note: You have to activate cookies!"), true)
|
info(_("Please note: You have to activate cookies!"), true)
|
||||||
], page_link_to('login'))
|
], page_link_to('login'))
|
||||||
]),
|
]),
|
||||||
div('col-md-4', [
|
div('col-md-4', [
|
||||||
'<h2>' . _("What can I do?") . '</h2>',
|
'<h2>' . _("What can I do?") . '</h2>',
|
||||||
'<p>' . _("Please read about the jobs you can do to help us.") . '</p>',
|
'<p>' . _("Please read about the jobs you can do to help us.") . '</p>',
|
||||||
buttons([
|
buttons([
|
||||||
button(page_link_to('angeltypes') . '&action=about', _("Teams/Job description") . ' »')
|
button(page_link_to('angeltypes') . '&action=about', _("Teams/Job description") . ' »')
|
||||||
])
|
])
|
||||||
])
|
])
|
||||||
])
|
])
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -122,16 +153,19 @@ function User_registration_success_view($event_welcome_message)
|
||||||
function User_delete_view($user)
|
function User_delete_view($user)
|
||||||
{
|
{
|
||||||
return page_with_title(sprintf(_("Delete %s"), User_Nick_render($user)), [
|
return page_with_title(sprintf(_("Delete %s"), User_Nick_render($user)), [
|
||||||
msg(),
|
msg(),
|
||||||
buttons([
|
buttons([
|
||||||
button(user_edit_link($user), glyph('chevron-left') . _("back"))
|
button(user_edit_link($user), glyph('chevron-left') . _("back"))
|
||||||
]),
|
]),
|
||||||
error(_("Do you really want to delete the user including all his shifts and every other piece of his data?"), true),
|
error(
|
||||||
form([
|
_("Do you really want to delete the user including all his shifts and every other piece of his data?"),
|
||||||
form_password('password', _("Your password")),
|
true
|
||||||
form_submit('submit', _("Delete"))
|
),
|
||||||
])
|
form([
|
||||||
]);
|
form_password('password', _("Your password")),
|
||||||
|
form_submit('submit', _("Delete"))
|
||||||
|
])
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -140,20 +174,28 @@ function User_delete_view($user)
|
||||||
function User_edit_vouchers_view($user)
|
function User_edit_vouchers_view($user)
|
||||||
{
|
{
|
||||||
return page_with_title(sprintf(_("%s's vouchers"), User_Nick_render($user)), [
|
return page_with_title(sprintf(_("%s's vouchers"), User_Nick_render($user)), [
|
||||||
msg(),
|
msg(),
|
||||||
buttons([
|
buttons([
|
||||||
button(user_link($user), glyph('chevron-left') . _("back"))
|
button(user_link($user), glyph('chevron-left') . _("back"))
|
||||||
]),
|
]),
|
||||||
info(sprintf(_("Angel should receive at least %d vouchers."), User_get_eligable_voucher_count($user)), true),
|
info(sprintf(_("Angel should receive at least %d vouchers."), User_get_eligable_voucher_count($user)), true),
|
||||||
form([
|
form([
|
||||||
form_spinner('vouchers', _("Number of vouchers given out"), $user['got_voucher']),
|
form_spinner('vouchers', _("Number of vouchers given out"), $user['got_voucher']),
|
||||||
form_submit('submit', _("Save"))
|
form_submit('submit', _("Save"))
|
||||||
], page_link_to('users') . '&action=edit_vouchers&user_id=' . $user['UID'])
|
], page_link_to('users') . '&action=edit_vouchers&user_id=' . $user['UID'])
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function Users_view($users, $order_by, $arrived_count, $active_count, $force_active_count, $freeloads_count, $tshirts_count, $voucher_count)
|
function Users_view(
|
||||||
{
|
$users,
|
||||||
|
$order_by,
|
||||||
|
$arrived_count,
|
||||||
|
$active_count,
|
||||||
|
$force_active_count,
|
||||||
|
$freeloads_count,
|
||||||
|
$tshirts_count,
|
||||||
|
$voucher_count
|
||||||
|
) {
|
||||||
foreach ($users as &$user) {
|
foreach ($users as &$user) {
|
||||||
$user['Nick'] = User_Nick_render($user);
|
$user['Nick'] = User_Nick_render($user);
|
||||||
$user['Gekommen'] = glyph_bool($user['Gekommen']);
|
$user['Gekommen'] = glyph_bool($user['Gekommen']);
|
||||||
|
@ -163,41 +205,41 @@ function Users_view($users, $order_by, $arrived_count, $active_count, $force_act
|
||||||
$user['Tshirt'] = glyph_bool($user['Tshirt']);
|
$user['Tshirt'] = glyph_bool($user['Tshirt']);
|
||||||
$user['lastLogIn'] = date(_('m/d/Y h:i a'), $user['lastLogIn']);
|
$user['lastLogIn'] = date(_('m/d/Y h:i a'), $user['lastLogIn']);
|
||||||
$user['actions'] = table_buttons([
|
$user['actions'] = table_buttons([
|
||||||
button_glyph(page_link_to('admin_user') . '&id=' . $user['UID'], 'edit', 'btn-xs')
|
button_glyph(page_link_to('admin_user') . '&id=' . $user['UID'], 'edit', 'btn-xs')
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
$users[] = [
|
$users[] = [
|
||||||
'Nick' => '<strong>' . _('Sum') . '</strong>',
|
'Nick' => '<strong>' . _('Sum') . '</strong>',
|
||||||
'Gekommen' => $arrived_count,
|
'Gekommen' => $arrived_count,
|
||||||
'got_voucher' => $voucher_count,
|
'got_voucher' => $voucher_count,
|
||||||
'Aktiv' => $active_count,
|
'Aktiv' => $active_count,
|
||||||
'force_active' => $force_active_count,
|
'force_active' => $force_active_count,
|
||||||
'freeloads' => $freeloads_count,
|
'freeloads' => $freeloads_count,
|
||||||
'Tshirt' => $tshirts_count,
|
'Tshirt' => $tshirts_count,
|
||||||
'actions' => '<strong>' . count($users) . '</strong>'
|
'actions' => '<strong>' . count($users) . '</strong>'
|
||||||
];
|
];
|
||||||
|
|
||||||
return page_with_title(_("All users"), [
|
return page_with_title(_("All users"), [
|
||||||
msg(),
|
msg(),
|
||||||
buttons([
|
buttons([
|
||||||
button(page_link_to('register'), glyph('plus') . _("New user"))
|
button(page_link_to('register'), glyph('plus') . _("New user"))
|
||||||
]),
|
]),
|
||||||
table([
|
table([
|
||||||
'Nick' => Users_table_header_link('Nick', _("Nick"), $order_by),
|
'Nick' => Users_table_header_link('Nick', _("Nick"), $order_by),
|
||||||
'Vorname' => Users_table_header_link('Vorname', _("Prename"), $order_by),
|
'Vorname' => Users_table_header_link('Vorname', _("Prename"), $order_by),
|
||||||
'Name' => Users_table_header_link('Name', _("Name"), $order_by),
|
'Name' => Users_table_header_link('Name', _("Name"), $order_by),
|
||||||
'DECT' => Users_table_header_link('DECT', _("DECT"), $order_by),
|
'DECT' => Users_table_header_link('DECT', _("DECT"), $order_by),
|
||||||
'Gekommen' => Users_table_header_link('Gekommen', _("Arrived"), $order_by),
|
'Gekommen' => Users_table_header_link('Gekommen', _("Arrived"), $order_by),
|
||||||
'got_voucher' => Users_table_header_link('got_voucher', _("Voucher"), $order_by),
|
'got_voucher' => Users_table_header_link('got_voucher', _("Voucher"), $order_by),
|
||||||
'freeloads' => _('Freeloads'),
|
'freeloads' => _('Freeloads'),
|
||||||
'Aktiv' => Users_table_header_link('Aktiv', _("Active"), $order_by),
|
'Aktiv' => Users_table_header_link('Aktiv', _("Active"), $order_by),
|
||||||
'force_active' => Users_table_header_link('force_active', _("Forced"), $order_by),
|
'force_active' => Users_table_header_link('force_active', _("Forced"), $order_by),
|
||||||
'Tshirt' => Users_table_header_link('Tshirt', _("T-Shirt"), $order_by),
|
'Tshirt' => Users_table_header_link('Tshirt', _("T-Shirt"), $order_by),
|
||||||
'Size' => Users_table_header_link('Size', _("Size"), $order_by),
|
'Size' => Users_table_header_link('Size', _("Size"), $order_by),
|
||||||
'lastLogIn' => Users_table_header_link('lastLogIn', _("Last login"), $order_by),
|
'lastLogIn' => Users_table_header_link('lastLogIn', _("Last login"), $order_by),
|
||||||
'actions' => ''
|
'actions' => ''
|
||||||
], $users)
|
], $users)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function Users_table_header_link($column, $label, $order_by)
|
function Users_table_header_link($column, $label, $order_by)
|
||||||
|
@ -211,11 +253,11 @@ function User_shift_state_render($user)
|
||||||
if ($upcoming_shifts === false) {
|
if ($upcoming_shifts === false) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($upcoming_shifts) == 0) {
|
if (count($upcoming_shifts) == 0) {
|
||||||
return '<span class="text-success">' . _("Free") . '</span>';
|
return '<span class="text-success">' . _("Free") . '</span>';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($upcoming_shifts[0]['start'] > time()) {
|
if ($upcoming_shifts[0]['start'] > time()) {
|
||||||
if ($upcoming_shifts[0]['start'] - time() > 3600) {
|
if ($upcoming_shifts[0]['start'] - time() > 3600) {
|
||||||
return '<span class="text-success moment-countdown" data-timestamp="' . $upcoming_shifts[0]['start'] . '">' . _("Next shift %c") . '</span>';
|
return '<span class="text-success moment-countdown" data-timestamp="' . $upcoming_shifts[0]['start'] . '">' . _("Next shift %c") . '</span>';
|
||||||
|
@ -223,7 +265,7 @@ function User_shift_state_render($user)
|
||||||
return '<span class="text-warning moment-countdown" data-timestamp="' . $upcoming_shifts[0]['start'] . '">' . _("Next shift %c") . '</span>';
|
return '<span class="text-warning moment-countdown" data-timestamp="' . $upcoming_shifts[0]['start'] . '">' . _("Next shift %c") . '</span>';
|
||||||
}
|
}
|
||||||
$halfway = ($upcoming_shifts[0]['start'] + $upcoming_shifts[0]['end']) / 2;
|
$halfway = ($upcoming_shifts[0]['start'] + $upcoming_shifts[0]['end']) / 2;
|
||||||
|
|
||||||
if (time() < $halfway) {
|
if (time() < $halfway) {
|
||||||
return '<span class="text-danger moment-countdown" data-timestamp="' . $upcoming_shifts[0]['start'] . '">' . _("Shift starts %c") . '</span>';
|
return '<span class="text-danger moment-countdown" data-timestamp="' . $upcoming_shifts[0]['start'] . '">' . _("Shift starts %c") . '</span>';
|
||||||
}
|
}
|
||||||
|
@ -233,18 +275,18 @@ function User_shift_state_render($user)
|
||||||
function User_view_shiftentries($needed_angel_type)
|
function User_view_shiftentries($needed_angel_type)
|
||||||
{
|
{
|
||||||
$shift_info = '<br><b>' . $needed_angel_type['name'] . ':</b> ';
|
$shift_info = '<br><b>' . $needed_angel_type['name'] . ':</b> ';
|
||||||
|
|
||||||
$shift_entries = [];
|
$shift_entries = [];
|
||||||
foreach ($needed_angel_type['users'] as $user_shift) {
|
foreach ($needed_angel_type['users'] as $user_shift) {
|
||||||
$member = User_Nick_render($user_shift);
|
$member = User_Nick_render($user_shift);
|
||||||
if ($user_shift['freeloaded']) {
|
if ($user_shift['freeloaded']) {
|
||||||
$member = '<strike>' . $member . '</strike>';
|
$member = '<strike>' . $member . '</strike>';
|
||||||
}
|
}
|
||||||
|
|
||||||
$shift_entries[] = $member;
|
$shift_entries[] = $member;
|
||||||
}
|
}
|
||||||
$shift_info .= join(", ", $shift_entries);
|
$shift_info .= join(", ", $shift_entries);
|
||||||
|
|
||||||
return $shift_info;
|
return $shift_info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -254,7 +296,7 @@ function User_view_shiftentries($needed_angel_type)
|
||||||
function User_view_myshift($shift, $user_source, $its_me)
|
function User_view_myshift($shift, $user_source, $its_me)
|
||||||
{
|
{
|
||||||
global $LETZTES_AUSTRAGEN, $privileges;
|
global $LETZTES_AUSTRAGEN, $privileges;
|
||||||
|
|
||||||
$shift_info = '<a href="' . shift_link($shift) . '">' . $shift['name'] . '</a>';
|
$shift_info = '<a href="' . shift_link($shift) . '">' . $shift['name'] . '</a>';
|
||||||
if ($shift['title']) {
|
if ($shift['title']) {
|
||||||
$shift_info .= '<br /><a href="' . shift_link($shift) . '">' . $shift['title'] . '</a>';
|
$shift_info .= '<br /><a href="' . shift_link($shift) . '">' . $shift['title'] . '</a>';
|
||||||
|
@ -262,15 +304,15 @@ function User_view_myshift($shift, $user_source, $its_me)
|
||||||
foreach ($shift['needed_angeltypes'] as $needed_angel_type) {
|
foreach ($shift['needed_angeltypes'] as $needed_angel_type) {
|
||||||
$shift_info .= User_view_shiftentries($needed_angel_type);
|
$shift_info .= User_view_shiftentries($needed_angel_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
$myshift = [
|
$myshift = [
|
||||||
'date' => date("Y-m-d", $shift['start']),
|
'date' => date("Y-m-d", $shift['start']),
|
||||||
'time' => date("H:i", $shift['start']) . ' - ' . date("H:i", $shift['end']),
|
'time' => date("H:i", $shift['start']) . ' - ' . date("H:i", $shift['end']),
|
||||||
'room' => $shift['Name'],
|
'room' => $shift['Name'],
|
||||||
'shift_info' => $shift_info,
|
'shift_info' => $shift_info,
|
||||||
'comment' => $shift['Comment']
|
'comment' => $shift['Comment']
|
||||||
];
|
];
|
||||||
|
|
||||||
if ($shift['freeloaded']) {
|
if ($shift['freeloaded']) {
|
||||||
if (in_array("user_shifts_admin", $privileges)) {
|
if (in_array("user_shifts_admin", $privileges)) {
|
||||||
$myshift['comment'] .= '<br /><p class="error">' . _("Freeloaded") . ': ' . $shift['freeload_comment'] . '</p>';
|
$myshift['comment'] .= '<br /><p class="error">' . _("Freeloaded") . ': ' . $shift['freeload_comment'] . '</p>';
|
||||||
|
@ -278,18 +320,26 @@ function User_view_myshift($shift, $user_source, $its_me)
|
||||||
$myshift['comment'] .= '<br /><p class="error">' . _("Freeloaded") . '</p>';
|
$myshift['comment'] .= '<br /><p class="error">' . _("Freeloaded") . '</p>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$myshift['actions'] = [
|
$myshift['actions'] = [
|
||||||
button(shift_link($shift), glyph('eye-open') . _('view'), 'btn-xs')
|
button(shift_link($shift), glyph('eye-open') . _('view'), 'btn-xs')
|
||||||
];
|
];
|
||||||
if ($its_me || in_array('user_shifts_admin', $privileges)) {
|
if ($its_me || in_array('user_shifts_admin', $privileges)) {
|
||||||
$myshift['actions'][] = button(page_link_to('user_myshifts') . '&edit=' . $shift['id'] . '&id=' . $user_source['UID'], glyph('edit') . _('edit'), 'btn-xs');
|
$myshift['actions'][] = button(
|
||||||
|
page_link_to('user_myshifts') . '&edit=' . $shift['id'] . '&id=' . $user_source['UID'],
|
||||||
|
glyph('edit') . _('edit'),
|
||||||
|
'btn-xs'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (($shift['start'] > time() + $LETZTES_AUSTRAGEN * 3600) || in_array('user_shifts_admin', $privileges)) {
|
if (($shift['start'] > time() + $LETZTES_AUSTRAGEN * 3600) || in_array('user_shifts_admin', $privileges)) {
|
||||||
$myshift['actions'][] = button(page_link_to('user_myshifts') . ((! $its_me) ? '&id=' . $user_source['UID'] : '') . '&cancel=' . $shift['id'], glyph('trash') . _('sign off'), 'btn-xs');
|
$myshift['actions'][] = button(
|
||||||
|
page_link_to('user_myshifts') . ((!$its_me) ? '&id=' . $user_source['UID'] : '') . '&cancel=' . $shift['id'],
|
||||||
|
glyph('trash') . _('sign off'),
|
||||||
|
'btn-xs'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
$myshift['actions'] = table_buttons($myshift['actions']);
|
$myshift['actions'] = table_buttons($myshift['actions']);
|
||||||
|
|
||||||
return $myshift;
|
return $myshift;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -302,23 +352,23 @@ function User_view_myshifts($shifts, $user_source, $its_me)
|
||||||
$timesum = 0;
|
$timesum = 0;
|
||||||
foreach ($shifts as $shift) {
|
foreach ($shifts as $shift) {
|
||||||
$myshifts_table[] = User_view_myshift($shift, $user_source, $its_me);
|
$myshifts_table[] = User_view_myshift($shift, $user_source, $its_me);
|
||||||
|
|
||||||
if ($shift['freeloaded']) {
|
if ($shift['freeloaded']) {
|
||||||
$timesum += (- 2 * ($shift['end'] - $shift['start']));
|
$timesum += (-2 * ($shift['end'] - $shift['start']));
|
||||||
} else {
|
} else {
|
||||||
$timesum += ($shift['end'] - $shift['start']);
|
$timesum += ($shift['end'] - $shift['start']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($myshifts_table) > 0) {
|
if (count($myshifts_table) > 0) {
|
||||||
$myshifts_table[] = [
|
$myshifts_table[] = [
|
||||||
'date' => '<b>' . _("Sum:") . '</b>',
|
'date' => '<b>' . _("Sum:") . '</b>',
|
||||||
'time' => "<b>" . round($timesum / 3600, 1) . " h</b>",
|
'time' => "<b>" . round($timesum / 3600, 1) . " h</b>",
|
||||||
'room' => "",
|
'room' => "",
|
||||||
'shift_info' => "",
|
'shift_info' => "",
|
||||||
'comment' => "",
|
'comment' => "",
|
||||||
'actions' => ""
|
'actions' => ""
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
return $myshifts_table;
|
return $myshifts_table;
|
||||||
}
|
}
|
||||||
|
@ -330,60 +380,116 @@ function User_view($user_source, $admin_user_privilege, $freeloader, $user_angel
|
||||||
{
|
{
|
||||||
$user_name = htmlspecialchars($user_source['Vorname']) . " " . htmlspecialchars($user_source['Name']);
|
$user_name = htmlspecialchars($user_source['Vorname']) . " " . htmlspecialchars($user_source['Name']);
|
||||||
$myshifts_table = User_view_myshifts($shifts, $user_source, $its_me);
|
$myshifts_table = User_view_myshifts($shifts, $user_source, $its_me);
|
||||||
|
|
||||||
return page_with_title('<span class="icon-icon_angel"></span> ' . htmlspecialchars($user_source['Nick']) . ' <small>' . $user_name . '</small>', [
|
return page_with_title(
|
||||||
msg(),
|
'<span class="icon-icon_angel"></span> ' . htmlspecialchars($user_source['Nick']) . ' <small>' . $user_name . '</small>',
|
||||||
div('row space-top', [
|
[
|
||||||
div('col-md-12', [
|
msg(),
|
||||||
buttons([
|
div('row space-top', [
|
||||||
$admin_user_privilege ? button(page_link_to('admin_user') . '&id=' . $user_source['UID'], glyph("edit") . _("edit")) : '',
|
div('col-md-12', [
|
||||||
$admin_user_privilege ? button(user_driver_license_edit_link($user_source), glyph("road") . _("driving license")) : '',
|
buttons([
|
||||||
($admin_user_privilege && ! $user_source['Gekommen']) ? button(page_link_to('admin_arrive') . '&arrived=' . $user_source['UID'], _("arrived")) : '',
|
$admin_user_privilege ? button(
|
||||||
$admin_user_privilege ? button(page_link_to('users') . '&action=edit_vouchers&user_id=' . $user_source['UID'], glyph('cutlery') . _('Edit vouchers')) : '',
|
page_link_to('admin_user') . '&id=' . $user_source['UID'],
|
||||||
$its_me ? button(page_link_to('user_settings'), glyph('list-alt') . _("Settings")) : '',
|
glyph("edit") . _("edit")
|
||||||
$its_me ? button(page_link_to('ical') . '&key=' . $user_source['api_key'], glyph('calendar') . _("iCal Export")) : '',
|
) : '',
|
||||||
$its_me ? button(page_link_to('shifts_json_export') . '&key=' . $user_source['api_key'], glyph('export') . _("JSON Export")) : '',
|
$admin_user_privilege ? button(
|
||||||
$its_me ? button(page_link_to('user_myshifts') . '&reset', glyph('repeat') . _('Reset API key')) : ''
|
user_driver_license_edit_link($user_source),
|
||||||
])
|
glyph("road") . _("driving license")
|
||||||
])
|
) : '',
|
||||||
]),
|
($admin_user_privilege && !$user_source['Gekommen']) ? button(
|
||||||
div('row', [
|
page_link_to('admin_arrive') . '&arrived=' . $user_source['UID'],
|
||||||
div('col-md-3', [
|
_("arrived")
|
||||||
'<h1>',
|
) : '',
|
||||||
'<span class="glyphicon glyphicon-phone"></span>',
|
$admin_user_privilege ? button(
|
||||||
$user_source['DECT'],
|
page_link_to('users') . '&action=edit_vouchers&user_id=' . $user_source['UID'],
|
||||||
'</h1>'
|
glyph('cutlery') . _('Edit vouchers')
|
||||||
]),
|
) : '',
|
||||||
div('col-md-3', [
|
$its_me ? button(page_link_to('user_settings'), glyph('list-alt') . _("Settings")) : '',
|
||||||
'<h4>' . _("User state") . '</h4>',
|
$its_me ? button(
|
||||||
($admin_user_privilege && $freeloader) ? '<span class="text-danger"><span class="glyphicon glyphicon-exclamation-sign"></span> ' . _("Freeloader") . '</span><br />' : '',
|
page_link_to('ical') . '&key=' . $user_source['api_key'],
|
||||||
$user_source['Gekommen'] ? User_shift_state_render($user_source) . '<br />' : '',
|
glyph('calendar') . _("iCal Export")
|
||||||
$admin_user_privilege || $its_me ? ($user_source['Gekommen'] ? '<span class="text-success"><span class="glyphicon glyphicon-home"></span> ' . sprintf(_("Arrived at %s"), date('Y-m-d', $user_source['arrival_date'])) . '</span>' : '<span class="text-danger">' . sprintf(_("Not arrived (Planned: %s)"), date('Y-m-d', $user_source['planned_arrival_date'])) . '</span>') : ($user_source['Gekommen'] ? '<span class="text-success"><span class="glyphicon glyphicon-home"></span> ' . _("Arrived") . '</span>' : '<span class="text-danger">' . _("Not arrived") . '</span>'),
|
) : '',
|
||||||
$admin_user_privilege ? ($user_source['got_voucher'] > 0 ? '<br /><span class="text-success">' . glyph('cutlery') . sprintf(ngettext("Got %s voucher", "Got %s vouchers", $user_source['got_voucher']), $user_source['got_voucher']) . '</span><br />' : '<br /><span class="text-danger">' . _("Got no vouchers") . '</span><br />') : '',
|
$its_me ? button(
|
||||||
($user_source['Gekommen'] && $admin_user_privilege && $user_source['Aktiv']) ? ' <span class="text-success">' . _("Active") . '</span>' : '',
|
page_link_to('shifts_json_export') . '&key=' . $user_source['api_key'],
|
||||||
($user_source['Gekommen'] && $admin_user_privilege && $user_source['Tshirt']) ? ' <span class="text-success">' . _("T-Shirt") . '</span>' : ''
|
glyph('export') . _("JSON Export")
|
||||||
]),
|
) : '',
|
||||||
div('col-md-3', [
|
$its_me ? button(
|
||||||
'<h4>' . _("Angeltypes") . '</h4>',
|
page_link_to('user_myshifts') . '&reset',
|
||||||
User_angeltypes_render($user_angeltypes)
|
glyph('repeat') . _('Reset API key')
|
||||||
]),
|
) : ''
|
||||||
div('col-md-3', [
|
])
|
||||||
'<h4>' . _("Rights") . '</h4>',
|
])
|
||||||
User_groups_render($user_groups)
|
]),
|
||||||
])
|
div('row', [
|
||||||
]),
|
div('col-md-3', [
|
||||||
($its_me || $admin_user_privilege) ? '<h2>' . _("Shifts") . '</h2>' : '',
|
'<h1>',
|
||||||
($its_me || $admin_user_privilege) ? table([
|
'<span class="glyphicon glyphicon-phone"></span>',
|
||||||
'date' => _("Day"),
|
$user_source['DECT'],
|
||||||
'time' => _("Time"),
|
'</h1>'
|
||||||
'room' => _("Location"),
|
]),
|
||||||
'shift_info' => _("Name & workmates"),
|
div('col-md-3', [
|
||||||
'comment' => _("Comment"),
|
'<h4>' . _("User state") . '</h4>',
|
||||||
'actions' => _("Action")
|
($admin_user_privilege && $freeloader)
|
||||||
], $myshifts_table) : '',
|
? '<span class="text-danger"><span class="glyphicon glyphicon-exclamation-sign"></span> ' . _("Freeloader") . '</span><br />'
|
||||||
$its_me ? info(glyph('info-sign') . _("Your night shifts between 2 and 8 am count twice."), true) : '',
|
: '',
|
||||||
$its_me && count($shifts) == 0 ? error(sprintf(_("Go to the <a href=\"%s\">shifts table</a> to sign yourself up for some shifts."), page_link_to('user_shifts')), true) : ''
|
$user_source['Gekommen']
|
||||||
]);
|
? User_shift_state_render($user_source) . '<br />'
|
||||||
|
: '',
|
||||||
|
$admin_user_privilege || $its_me
|
||||||
|
? (
|
||||||
|
$user_source['Gekommen']
|
||||||
|
? '<span class="text-success"><span class="glyphicon glyphicon-home"></span> '
|
||||||
|
. sprintf(_("Arrived at %s"), date('Y-m-d', $user_source['arrival_date']))
|
||||||
|
. '</span>'
|
||||||
|
: '<span class="text-danger">'
|
||||||
|
. sprintf(_("Not arrived (Planned: %s)"), date('Y-m-d', $user_source['planned_arrival_date']))
|
||||||
|
. '</span>'
|
||||||
|
)
|
||||||
|
: (
|
||||||
|
$user_source['Gekommen']
|
||||||
|
? '<span class="text-success"><span class="glyphicon glyphicon-home"></span> ' . _("Arrived") . '</span>'
|
||||||
|
: '<span class="text-danger">' . _("Not arrived") . '</span>'),
|
||||||
|
$admin_user_privilege
|
||||||
|
? (
|
||||||
|
$user_source['got_voucher'] > 0
|
||||||
|
? '<br /><span class="text-success">'
|
||||||
|
. glyph('cutlery')
|
||||||
|
. sprintf(
|
||||||
|
ngettext("Got %s voucher", "Got %s vouchers", $user_source['got_voucher']),
|
||||||
|
$user_source['got_voucher']
|
||||||
|
)
|
||||||
|
. '</span><br />'
|
||||||
|
: '<br /><span class="text-danger">' . _("Got no vouchers") . '</span><br />')
|
||||||
|
: '',
|
||||||
|
($user_source['Gekommen'] && $admin_user_privilege && $user_source['Aktiv']) ? ' <span class="text-success">' . _("Active") . '</span>' : '',
|
||||||
|
($user_source['Gekommen'] && $admin_user_privilege && $user_source['Tshirt']) ? ' <span class="text-success">' . _("T-Shirt") . '</span>' : ''
|
||||||
|
]),
|
||||||
|
div('col-md-3', [
|
||||||
|
'<h4>' . _("Angeltypes") . '</h4>',
|
||||||
|
User_angeltypes_render($user_angeltypes)
|
||||||
|
]),
|
||||||
|
div('col-md-3', [
|
||||||
|
'<h4>' . _("Rights") . '</h4>',
|
||||||
|
User_groups_render($user_groups)
|
||||||
|
])
|
||||||
|
]),
|
||||||
|
($its_me || $admin_user_privilege) ? '<h2>' . _("Shifts") . '</h2>' : '',
|
||||||
|
($its_me || $admin_user_privilege) ? table([
|
||||||
|
'date' => _("Day"),
|
||||||
|
'time' => _("Time"),
|
||||||
|
'room' => _("Location"),
|
||||||
|
'shift_info' => _("Name & workmates"),
|
||||||
|
'comment' => _("Comment"),
|
||||||
|
'actions' => _("Action")
|
||||||
|
], $myshifts_table) : '',
|
||||||
|
$its_me ? info(glyph('info-sign') . _("Your night shifts between 2 and 8 am count twice."), true) : '',
|
||||||
|
$its_me && count($shifts) == 0
|
||||||
|
? error(sprintf(
|
||||||
|
_("Go to the <a href=\"%s\">shifts table</a> to sign yourself up for some shifts."),
|
||||||
|
page_link_to('user_shifts')
|
||||||
|
), true)
|
||||||
|
: ''
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -392,13 +498,13 @@ function User_view($user_source, $admin_user_privilege, $freeloader, $user_angel
|
||||||
function User_password_recovery_view()
|
function User_password_recovery_view()
|
||||||
{
|
{
|
||||||
return page_with_title(user_password_recovery_title(), [
|
return page_with_title(user_password_recovery_title(), [
|
||||||
msg(),
|
msg(),
|
||||||
_("We will send you an e-mail with a password recovery link. Please use the email address you used for registration."),
|
_("We will send you an e-mail with a password recovery link. Please use the email address you used for registration."),
|
||||||
form([
|
form([
|
||||||
form_text('email', _("E-Mail"), ""),
|
form_text('email', _("E-Mail"), ""),
|
||||||
form_submit('submit', _("Recover"))
|
form_submit('submit', _("Recover"))
|
||||||
])
|
])
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -407,14 +513,14 @@ function User_password_recovery_view()
|
||||||
function User_password_set_view()
|
function User_password_set_view()
|
||||||
{
|
{
|
||||||
return page_with_title(user_password_recovery_title(), [
|
return page_with_title(user_password_recovery_title(), [
|
||||||
msg(),
|
msg(),
|
||||||
_("Please enter a new password."),
|
_("Please enter a new password."),
|
||||||
form([
|
form([
|
||||||
form_password('password', _("Password")),
|
form_password('password', _("Password")),
|
||||||
form_password('password2', _("Confirm password")),
|
form_password('password2', _("Confirm password")),
|
||||||
form_submit('submit', _("Save"))
|
form_submit('submit', _("Save"))
|
||||||
])
|
])
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function User_angeltypes_render($user_angeltypes)
|
function User_angeltypes_render($user_angeltypes)
|
||||||
|
@ -459,22 +565,25 @@ function User_Nick_render($user_source)
|
||||||
function render_user_departure_date_hint()
|
function render_user_departure_date_hint()
|
||||||
{
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
if (! isset($user['planned_departure_date']) || $user['planned_departure_date'] == null) {
|
if (!isset($user['planned_departure_date']) || $user['planned_departure_date'] == null) {
|
||||||
return _("Please enter your planned date of departure on your settings page to give us a feeling for teardown capacities.");
|
return _("Please enter your planned date of departure on your settings page to give us a feeling for teardown capacities.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function render_user_freeloader_hint()
|
function render_user_freeloader_hint()
|
||||||
{
|
{
|
||||||
global $user, $max_freeloadable_shifts;
|
global $user, $max_freeloadable_shifts;
|
||||||
|
|
||||||
if (User_is_freeloader($user)) {
|
if (User_is_freeloader($user)) {
|
||||||
return sprintf(_("You freeloaded at least %s shifts. Shift signup is locked. Please go to heavens desk to be unlocked again."), $max_freeloadable_shifts);
|
return sprintf(
|
||||||
|
_("You freeloaded at least %s shifts. Shift signup is locked. Please go to heavens desk to be unlocked again."),
|
||||||
|
$max_freeloadable_shifts
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -482,32 +591,32 @@ function render_user_freeloader_hint()
|
||||||
function render_user_arrived_hint()
|
function render_user_arrived_hint()
|
||||||
{
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
if ($user['Gekommen'] == 0) {
|
if ($user['Gekommen'] == 0) {
|
||||||
return _("You are not marked as arrived. Please go to heaven's desk, get your angel badge and/or tell them that you arrived already.");
|
return _("You are not marked as arrived. Please go to heaven's desk, get your angel badge and/or tell them that you arrived already.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function render_user_tshirt_hint()
|
function render_user_tshirt_hint()
|
||||||
{
|
{
|
||||||
global $enable_tshirt_size, $user;
|
global $enable_tshirt_size, $user;
|
||||||
|
|
||||||
if ($enable_tshirt_size && $user['Size'] == "") {
|
if ($enable_tshirt_size && $user['Size'] == "") {
|
||||||
return _("You need to specify a tshirt size in your settings!");
|
return _("You need to specify a tshirt size in your settings!");
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function render_user_dect_hint()
|
function render_user_dect_hint()
|
||||||
{
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
if ($user['DECT'] == "") {
|
if ($user['DECT'] == "") {
|
||||||
return _("You need to specify a DECT phone number in your settings! If you don't have a DECT phone, just enter \"-\".");
|
return _("You need to specify a DECT phone number in your settings! If you don't have a DECT phone, just enter \"-\".");
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
44
phpunit.xml
44
phpunit.xml
|
@ -1,24 +1,24 @@
|
||||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.5/phpunit.xsd"
|
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.5/phpunit.xsd"
|
||||||
backupGlobals="false"
|
backupGlobals="false"
|
||||||
bootstrap="./includes/engelsystem_provider.php"
|
bootstrap="./includes/engelsystem_provider.php"
|
||||||
colors="true"
|
colors="true"
|
||||||
convertErrorsToExceptions="true"
|
convertErrorsToExceptions="true"
|
||||||
convertNoticesToExceptions="true"
|
convertNoticesToExceptions="true"
|
||||||
convertWarningsToExceptions="true"
|
convertWarningsToExceptions="true"
|
||||||
processIsolation="false">
|
processIsolation="false">
|
||||||
<testsuites>
|
<testsuites>
|
||||||
<testsuite name="Models">
|
<testsuite name="Models">
|
||||||
<directory>./test/model/</directory>
|
<directory>./test/model/</directory>
|
||||||
</testsuite>
|
</testsuite>
|
||||||
</testsuites>
|
</testsuites>
|
||||||
<filter>
|
<filter>
|
||||||
<whitelist>
|
<whitelist>
|
||||||
<directory>./include/</directory>
|
<directory>./include/</directory>
|
||||||
<directory>./public/</directory>
|
<directory>./public/</directory>
|
||||||
</whitelist>
|
</whitelist>
|
||||||
</filter>
|
</filter>
|
||||||
<php>
|
<php>
|
||||||
<const name="PHPUNIT_TESTSUITE" value="true" />
|
<const name="PHPUNIT_TESTSUITE" value="true"/>
|
||||||
</php>
|
</php>
|
||||||
</phpunit>
|
</phpunit>
|
||||||
|
|
|
@ -21,16 +21,23 @@ $free_pages = [
|
||||||
|
|
||||||
// Gewünschte Seite/Funktion
|
// Gewünschte Seite/Funktion
|
||||||
$page = "";
|
$page = "";
|
||||||
if (! isset($_REQUEST['p'])) {
|
if (!isset($_REQUEST['p'])) {
|
||||||
$_REQUEST['p'] = isset($user) ? "news" : "login";
|
$_REQUEST['p'] = isset($user) ? "news" : "login";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_REQUEST['p']) && preg_match("/^[a-z0-9_]*$/i", $_REQUEST['p']) && (in_array($_REQUEST['p'], $free_pages) || in_array($_REQUEST['p'], $privileges))) {
|
if (
|
||||||
|
isset($_REQUEST['p'])
|
||||||
|
&& preg_match("/^[a-z0-9_]*$/i", $_REQUEST['p'])
|
||||||
|
&& (
|
||||||
|
in_array($_REQUEST['p'], $free_pages)
|
||||||
|
|| in_array($_REQUEST['p'], $privileges)
|
||||||
|
)
|
||||||
|
) {
|
||||||
$page = $_REQUEST['p'];
|
$page = $_REQUEST['p'];
|
||||||
|
|
||||||
$title = $page;
|
$title = $page;
|
||||||
$content = "";
|
$content = "";
|
||||||
|
|
||||||
if ($page == "api") {
|
if ($page == "api") {
|
||||||
require_once realpath(__DIR__ . '/../includes/controller/api.php');
|
require_once realpath(__DIR__ . '/../includes/controller/api.php');
|
||||||
error("Api disabled temporily.");
|
error("Api disabled temporily.");
|
||||||
|
@ -151,26 +158,26 @@ if (isset($_REQUEST['p']) && preg_match("/^[a-z0-9_]*$/i", $_REQUEST['p']) && (i
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Wenn schon eingeloggt, keine-Berechtigung-Seite anzeigen
|
// Wenn schon eingeloggt, keine-Berechtigung-Seite anzeigen
|
||||||
if (isset($user)) {
|
if (isset($user)) {
|
||||||
$title = _("No Access");
|
$title = _("No Access");
|
||||||
$content = _("You don't have permission to view this page. You probably have to sign in or register in order to gain access!");
|
$content = _("You don't have permission to view this page. You probably have to sign in or register in order to gain access!");
|
||||||
} else {
|
} else {
|
||||||
// Sonst zur Loginseite leiten
|
// Sonst zur Loginseite leiten
|
||||||
redirect(page_link_to("login"));
|
redirect(page_link_to("login"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$event_config = EventConfig();
|
$event_config = EventConfig();
|
||||||
|
|
||||||
echo template_render(__DIR__ . '/../templates/layout.html', [
|
echo template_render(__DIR__ . '/../templates/layout.html', [
|
||||||
'theme' => isset($user) ? $user['color'] : $default_theme,
|
'theme' => isset($user) ? $user['color'] : $default_theme,
|
||||||
'title' => $title,
|
'title' => $title,
|
||||||
'atom_link' => ($page == 'news' || $page == 'user_meetings') ? '<link href="' . page_link_to('atom') . (($page == 'user_meetings') ? '&meetings=1' : '') . '&key=' . $user['api_key'] . '" type="application/atom+xml" rel="alternate" title="Atom Feed">' : '',
|
'atom_link' => ($page == 'news' || $page == 'user_meetings') ? '<link href="' . page_link_to('atom') . (($page == 'user_meetings') ? '&meetings=1' : '') . '&key=' . $user['api_key'] . '" type="application/atom+xml" rel="alternate" title="Atom Feed">' : '',
|
||||||
'menu' => make_menu(),
|
'menu' => make_menu(),
|
||||||
'content' => msg() . $content,
|
'content' => msg() . $content,
|
||||||
'header_toolbar' => header_toolbar(),
|
'header_toolbar' => header_toolbar(),
|
||||||
'faq_url' => $faq_url,
|
'faq_url' => $faq_url,
|
||||||
'contact_email' => $contact_email,
|
'contact_email' => $contact_email,
|
||||||
'locale' => locale(),
|
'locale' => locale(),
|
||||||
'event_info' => EventConfig_info($event_config) . '<br />'
|
'event_info' => EventConfig_info($event_config) . '<br />'
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -1,28 +1,28 @@
|
||||||
/**
|
/**
|
||||||
* Runs through the DOM under the element with the given id, finds all
|
* Runs through the DOM under the element with the given id, finds all
|
||||||
* checkboxes and sets them to the wanted state.
|
* checkboxes and sets them to the wanted state.
|
||||||
*
|
*
|
||||||
* @param String
|
* @param String
|
||||||
* id Id of the element containing all the checkboxes
|
* id Id of the element containing all the checkboxes
|
||||||
* @param Boolean
|
* @param Boolean
|
||||||
* checked True if the checkboxes should be checked
|
* checked True if the checkboxes should be checked
|
||||||
*/
|
*/
|
||||||
function checkAll(id, checked) {
|
function checkAll(id, checked) {
|
||||||
var obj = document.getElementById(id);
|
var obj = document.getElementById(id);
|
||||||
var boxes = obj.getElementsByTagName("input");
|
var boxes = obj.getElementsByTagName("input");
|
||||||
for (var i = 0; i < boxes.length; i++) {
|
for (var i = 0; i < boxes.length; i++) {
|
||||||
if (boxes[i].type === "checkbox" && !boxes[i].disabled) {
|
if (boxes[i].type === "checkbox" && !boxes[i].disabled) {
|
||||||
boxes[i].checked = checked;
|
boxes[i].checked = checked;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$(function() {
|
$(function () {
|
||||||
/**
|
/**
|
||||||
* Disable every submit button after clicking (to prevent double-clicking)
|
* Disable every submit button after clicking (to prevent double-clicking)
|
||||||
*/
|
*/
|
||||||
$("form").submit(function(ev) {
|
$("form").submit(function (ev) {
|
||||||
$("input[type='submit']").prop("readonly", true).addClass("disabled");
|
$("input[type='submit']").prop("readonly", true).addClass("disabled");
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -3,17 +3,17 @@
|
||||||
* class "moment-countdown" and the attribute "data-timestamp" which defines the
|
* class "moment-countdown" and the attribute "data-timestamp" which defines the
|
||||||
* countdown's time goal.
|
* countdown's time goal.
|
||||||
*/
|
*/
|
||||||
$(document).ready(function() {
|
$(document).ready(function () {
|
||||||
if (typeof moment !== "undefined") {
|
if (typeof moment !== "undefined") {
|
||||||
$.each($(".moment-countdown"), function(i, e) {
|
$.each($(".moment-countdown"), function (i, e) {
|
||||||
var span = $(e);
|
var span = $(e);
|
||||||
var text = span.html();
|
var text = span.html();
|
||||||
/* global moment */
|
/* global moment */
|
||||||
var timestamp = moment(parseInt(span.attr("data-timestamp") * 1000));
|
var timestamp = moment(parseInt(span.attr("data-timestamp") * 1000));
|
||||||
span.html(text.replace("%c", timestamp.fromNow()));
|
span.html(text.replace("%c", timestamp.fromNow()));
|
||||||
setInterval(function() {
|
setInterval(function () {
|
||||||
span.html(text.replace("%c", timestamp.fromNow()));
|
span.html(text.replace("%c", timestamp.fromNow()));
|
||||||
}, 1000);
|
}, 1000);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,32 +1,31 @@
|
||||||
/**
|
/**
|
||||||
* Enables the fixed headers and time lane for the shift-calendar and datatables
|
* Enables the fixed headers and time lane for the shift-calendar and datatables
|
||||||
*/
|
*/
|
||||||
$(document).ready(
|
$(document).ready(function () {
|
||||||
function() {
|
if ($(".shift-calendar").length) {
|
||||||
if ($(".shift-calendar").length) {
|
|
||||||
var timeLanes = $(".shift-calendar .time");
|
var timeLanes = $(".shift-calendar .time");
|
||||||
var headers = $(".shift-calendar .header");
|
var headers = $(".shift-calendar .header");
|
||||||
var topReference = $(".container-fluid .row");
|
var topReference = $(".container-fluid .row");
|
||||||
var top = headers.offset().top;
|
var top = headers.offset().top;
|
||||||
var left = 15;
|
var left = 15;
|
||||||
timeLanes.css({
|
timeLanes.css({
|
||||||
"position" : "relative",
|
"position": "relative",
|
||||||
"z-index" : 999
|
"z-index": 999
|
||||||
});
|
});
|
||||||
headers.css({
|
headers.css({
|
||||||
"position" : "relative",
|
"position": "relative",
|
||||||
"z-index" : 900
|
"z-index": 900
|
||||||
});
|
});
|
||||||
$(window).scroll(
|
$(window).scroll(
|
||||||
function() {
|
function () {
|
||||||
timeLanes.css({
|
timeLanes.css({
|
||||||
"left" : Math.max(0, $(window).scrollLeft() - left) + "px"
|
"left": Math.max(0, $(window).scrollLeft() - left) + "px"
|
||||||
});
|
});
|
||||||
headers.css({
|
headers.css({
|
||||||
"top" : Math.max(0, $(window).scrollTop() - top
|
"top": Math.max(0, $(window).scrollTop() - top
|
||||||
+ topReference.offset().top)
|
+ topReference.offset().top)
|
||||||
+ "px"
|
+ "px"
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,72 +1,86 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Maintenance - Engelsystem</title>
|
<title>Maintenance - Engelsystem</title>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8"/>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<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="css/theme0.css"/>
|
||||||
<link rel="stylesheet" type="text/css" href="vendor/icomoon/style.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" />
|
<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-2.1.1.min.js"></script>
|
||||||
<script type="text/javascript" src="vendor/jquery-ui.min.js"></script>
|
<script type="text/javascript" src="vendor/jquery-ui.min.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="navbar navbar-default navbar-fixed-top">
|
<div class="navbar navbar-default navbar-fixed-top">
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<div class="navbar-header">
|
<div class="navbar-header">
|
||||||
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar-collapse-1">
|
<button type="button" class="navbar-toggle collapsed"
|
||||||
<span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span>
|
data-toggle="collapse" data-target="#navbar-collapse-1">
|
||||||
</button>
|
<span class="sr-only">Toggle navigation</span>
|
||||||
<a class="navbar-brand" href="?"><span class="icon-icon_angel"></span> <strong class="visible-lg-inline">ENGELSYSTEM</strong></a>
|
<span class="icon-bar"></span>
|
||||||
</div>
|
<span class="icon-bar"></span>
|
||||||
<div class="collapse navbar-collapse" id="navbar-collapse-1">
|
<span class="icon-bar"></span>
|
||||||
<ul class="nav navbar-nav"></ul>
|
</button>
|
||||||
<ul class="nav navbar-nav navbar-right">
|
<a class="navbar-brand" href="?">
|
||||||
</ul>
|
<span class="icon-icon_angel"></span> <strong class="visible-lg-inline">ENGELSYSTEM</strong>
|
||||||
</div>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div class="collapse navbar-collapse" id="navbar-collapse-1">
|
||||||
<div class="container-fluid">
|
<ul class="nav navbar-nav"></ul>
|
||||||
<div class="row">
|
<ul class="nav navbar-nav navbar-right">
|
||||||
<div class="jumbotron">
|
</ul>
|
||||||
<div class="container text-center">
|
</div>
|
||||||
<h1>
|
</div>
|
||||||
<span class="glyphicon glyphicon-scissors"></span> <span class="glyphicon glyphicon-wrench"></span> <span class="glyphicon glyphicon-fire"></span>
|
</div>
|
||||||
</h1>
|
<div class="container-fluid">
|
||||||
<div class="col-md-6">
|
<div class="row">
|
||||||
<h2>
|
<div class="jumbotron">
|
||||||
The <span class="icon-icon_angel"></span> <strong>ENGELSYSTEM</strong> is in maintenance mode.
|
<div class="container text-center">
|
||||||
</h2>
|
<h1>
|
||||||
<p>This may be due to...</p>
|
<span class="glyphicon glyphicon-scissors"></span>
|
||||||
<p>
|
<span class="glyphicon glyphicon-wrench"></span>
|
||||||
...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.
|
<span class="glyphicon glyphicon-fire"></span>
|
||||||
</p>
|
</h1>
|
||||||
</div>
|
<div class="col-md-6">
|
||||||
<div class="col-md-6">
|
<h2>
|
||||||
<iframe width="560" height="315" src="https://www.youtube.com/embed/0aV_vHcunSQ?rel=0" frameborder="0" allowfullscreen></iframe>
|
The <span class="icon-icon_angel"></span> <strong>ENGELSYSTEM</strong> is in maintenance mode.
|
||||||
</div>
|
</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>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
<div class="text-center footer">
|
<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>
|
<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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script type="text/javascript" src="vendor/bootstrap/js/bootstrap.min.js"></script>
|
<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/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/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="vendor/Chart.min.js"></script>
|
||||||
<script type="text/javascript" src="js/forms.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" src="vendor/moment-with-locales.min.js"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(function() {
|
$(function () {
|
||||||
moment.locale("en_US.UTF-8");
|
moment.locale("en_US.UTF-8");
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<script type="text/javascript" src="js/moment-countdown.js"></script>
|
<script type="text/javascript" src="js/moment-countdown.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -1,57 +1,77 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Engelsystem</title>
|
<title>Engelsystem</title>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8"/>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<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="css/theme0.css"/>
|
||||||
<link rel="stylesheet" type="text/css" href="vendor/icomoon/style.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" />
|
<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-2.1.1.min.js"></script>
|
||||||
<script type="text/javascript" src="vendor/jquery-ui.min.js"></script>
|
<script type="text/javascript" src="vendor/jquery-ui.min.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="navbar navbar-default navbar-fixed-top">
|
<div class="navbar navbar-default navbar-fixed-top">
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<div class="navbar-header">
|
<div class="navbar-header">
|
||||||
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar-collapse-1">
|
<button type="button" class="navbar-toggle collapsed"
|
||||||
<span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span>
|
data-toggle="collapse" data-target="#navbar-collapse-1">
|
||||||
</button>
|
<span class="sr-only">Toggle navigation</span>
|
||||||
<a class="navbar-brand" href="https://engelsystem.de"><span class="icon-icon_angel"></span> <strong class="visible-lg-inline">ENGELSYSTEM</strong></a>
|
<span class="icon-bar"></span>
|
||||||
</div>
|
<span class="icon-bar"></span>
|
||||||
<div class="collapse navbar-collapse" id="navbar-collapse-1">
|
<span class="icon-bar"></span>
|
||||||
<ul class="nav navbar-nav"></ul>
|
</button>
|
||||||
<ul class="nav navbar-nav navbar-right">
|
<a class="navbar-brand" href="https://engelsystem.de"><span class="icon-icon_angel"></span> <strong
|
||||||
</ul>
|
class="visible-lg-inline">ENGELSYSTEM</strong></a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div class="collapse navbar-collapse" id="navbar-collapse-1">
|
||||||
</div>
|
<ul class="nav navbar-nav"></ul>
|
||||||
<div class="container-fluid">
|
<ul class="nav navbar-nav navbar-right"></ul>
|
||||||
<div class="row">
|
</div>
|
||||||
<div class="jumbotron">
|
</div>
|
||||||
<div class="container text-center">
|
</div>
|
||||||
<div class="col-md-6 col-md-offset-3">
|
<div class="container-fluid">
|
||||||
<h2>Dear Angels,</h2>
|
<div class="row">
|
||||||
<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>
|
<div class="jumbotron">
|
||||||
<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
|
<div class="container text-center">
|
||||||
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>
|
<div class="col-md-6 col-md-offset-3">
|
||||||
<p>We closed the registration in the Engelsystem and at Heaven Desk at 19:00 27. Dec. 2016.</p>
|
<h2>Dear Angels,</h2>
|
||||||
<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>
|
||||||
<p>
|
The great interest in becoming an angel and participating at 33C3 is is something we are
|
||||||
For the Heaven Team<br /> Agnes, Jen, LLF and Knuth
|
grateful for every time. There is a record number of angels and helping volunteers this year.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
<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>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
<div class="text-center footer">
|
<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>
|
<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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script type="text/javascript" src="vendor/bootstrap/js/bootstrap.min.js"></script>
|
<script type="text/javascript" src="vendor/bootstrap/js/bootstrap.min.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -1,86 +1,105 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8"/>
|
||||||
<link rel="stylesheet" type="text/css" href="public/css/theme3.css" />
|
<link rel="stylesheet" type="text/css" href="public/css/theme3.css"/>
|
||||||
<style>
|
<style>
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="shift-calendar">
|
<div class="shift-calendar">
|
||||||
<div class="lane time">
|
<div class="lane time">
|
||||||
<div class="header">Time</div>
|
<div class="header">Time</div>
|
||||||
<div class="tick day">2016-12-27 00:00</div>
|
<div class="tick day">2016-12-27 00:00</div>
|
||||||
<div class="tick"></div>
|
<div class="tick"></div>
|
||||||
<div class="tick"></div>
|
<div class="tick"></div>
|
||||||
<div class="tick"></div>
|
<div class="tick"></div>
|
||||||
<div class="tick hour">11:00</div>
|
<div class="tick hour">11:00</div>
|
||||||
<div class="tick"></div>
|
<div class="tick"></div>
|
||||||
<div class="tick"></div>
|
<div class="tick"></div>
|
||||||
<div class="tick"></div>
|
<div class="tick"></div>
|
||||||
<div class="tick hour">12:00</div>
|
<div class="tick hour">12:00</div>
|
||||||
<div class="tick"></div>
|
<div class="tick"></div>
|
||||||
<div class="tick"></div>
|
<div class="tick"></div>
|
||||||
<div class="tick"></div>
|
<div class="tick"></div>
|
||||||
<div class="tick hour">13:00</div>
|
<div class="tick hour">13:00</div>
|
||||||
<div class="tick"></div>
|
<div class="tick"></div>
|
||||||
<div class="tick"></div>
|
<div class="tick"></div>
|
||||||
<div class="tick"></div>
|
<div class="tick"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="lane">
|
<div class="lane">
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<span class="glyphicon glyphicon-map-marker"></span> Bottle Sorting (Hall H)
|
<span class="glyphicon glyphicon-map-marker"></span> Bottle Sorting (Hall H)
|
||||||
</div>
|
</div>
|
||||||
<div class="tick day"></div>
|
<div class="tick day"></div>
|
||||||
<div class="tick"></div>
|
<div class="tick"></div>
|
||||||
<div class="tick"></div>
|
<div class="tick"></div>
|
||||||
<div class="tick"></div>
|
<div class="tick"></div>
|
||||||
<div class="shift panel panel-success" style="height: 160px;">
|
<div class="shift panel panel-success" style="height: 160px;">
|
||||||
<div class="panel-heading">
|
<div class="panel-heading">
|
||||||
<a href="?p=shifts&action=view&shift_id=2696">00:00 ‐ 02:00 — Bottle Collection</a>
|
<a href="?p=shifts&action=view&shift_id=2696">00:00 ‐ 02:00 — Bottle Collection</a>
|
||||||
<div class="pull-right">
|
<div class="pull-right">
|
||||||
<div class="btn-group">
|
<div class="btn-group">
|
||||||
<a href="?p=user_shifts&edit_shift=2696" class="btn btn-default btn-xs"> <span class="glyphicon glyphicon-edit"></span>
|
<a href="?p=user_shifts&edit_shift=2696" class="btn btn-default btn-xs">
|
||||||
</a> <a href="?p=user_shifts&delete_shift=2696" class="btn btn-default btn-xs"> <span class="glyphicon glyphicon-trash"></span>
|
<span class="glyphicon glyphicon-edit"></span>
|
||||||
</a>
|
</a>
|
||||||
|
<a href="?p=user_shifts&delete_shift=2696" class="btn btn-default btn-xs">
|
||||||
|
<span class="glyphicon glyphicon-trash"></span>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div class="panel-body">
|
||||||
|
<span class="glyphicon glyphicon-info-sign"></span> Bottle Collection Quick Response Team<br>
|
||||||
|
<a href="?p=rooms&action=view&room_id=42">
|
||||||
|
<span class="glyphicon glyphicon-map-marker"></span> Bottle Sorting (Hall H)
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<ul class="list-group">
|
||||||
|
<li class="list-group-item"><strong><a href="?p=angeltypes&action=view&angeltype_id=104575">Angel</a>:</strong>
|
||||||
|
<span style="">
|
||||||
|
<a class="" href="?p=users&action=view&user_id=1755">
|
||||||
|
<span class="icon-icon_angel"></span> Pantomime
|
||||||
|
</a>
|
||||||
|
</span>,
|
||||||
|
<span style="">
|
||||||
|
<a class="" href="?p=users&action=view&user_id=50">
|
||||||
|
<span class="icon-icon_angel"></span> sandzwerg
|
||||||
|
</a>
|
||||||
|
</span>
|
||||||
|
</li>
|
||||||
|
<li class="list-group-item">
|
||||||
|
<a href="?p=user_shifts&shift_id=2696&type_id=104575" class="btn btn-default btn-xs">
|
||||||
|
Neue Engel hinzufügen
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<div class="shift-spacer"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-body">
|
<div class="tick hour"></div>
|
||||||
<span class="glyphicon glyphicon-info-sign"></span> Bottle Collection Quick Response Team<br> <a href="?p=rooms&action=view&room_id=42"> <span class="glyphicon glyphicon-map-marker"></span> Bottle Sorting (Hall H)
|
<div class="tick"></div>
|
||||||
</a>
|
<div class="tick"></div>
|
||||||
</div>
|
<div class="tick"></div>
|
||||||
<ul class="list-group">
|
|
||||||
<li class="list-group-item"><strong><a href="?p=angeltypes&action=view&angeltype_id=104575">Angel</a>:</strong> <span style=""><a class="" href="?p=users&action=view&user_id=1755"><span class="icon-icon_angel"></span> Pantomime</a></span>, <span style=""><a
|
|
||||||
class="" href="?p=users&action=view&user_id=50"><span class="icon-icon_angel"></span> sandzwerg</a></span></li>
|
|
||||||
<li class="list-group-item"><a href="?p=user_shifts&shift_id=2696&type_id=104575" class="btn btn-default btn-xs">Neue Engel hinzufügen</a></li>
|
|
||||||
</ul>
|
|
||||||
<div class="shift-spacer"></div>
|
|
||||||
</div>
|
|
||||||
<div class="tick hour"></div>
|
|
||||||
<div class="tick"></div>
|
|
||||||
<div class="tick"></div>
|
|
||||||
<div class="tick"></div>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="lane">
|
<div class="lane">
|
||||||
<div class="header"></div>
|
<div class="header"></div>
|
||||||
<div class="tick day"></div>
|
<div class="tick day"></div>
|
||||||
<div class="tick"></div>
|
<div class="tick"></div>
|
||||||
<div class="tick"></div>
|
<div class="tick"></div>
|
||||||
<div class="tick"></div>
|
<div class="tick"></div>
|
||||||
<div class="tick hour"></div>
|
<div class="tick hour"></div>
|
||||||
<div class="tick"></div>
|
<div class="tick"></div>
|
||||||
<div class="tick"></div>
|
<div class="tick"></div>
|
||||||
<div class="tick"></div>
|
<div class="tick"></div>
|
||||||
<div class="tick hour"></div>
|
<div class="tick hour"></div>
|
||||||
<div class="tick"></div>
|
<div class="tick"></div>
|
||||||
<div class="tick"></div>
|
<div class="tick"></div>
|
||||||
<div class="tick"></div>
|
<div class="tick"></div>
|
||||||
<div class="tick hour"></div>
|
<div class="tick hour"></div>
|
||||||
<div class="tick"></div>
|
<div class="tick"></div>
|
||||||
<div class="tick"></div>
|
<div class="tick"></div>
|
||||||
<div class="tick"></div>
|
<div class="tick"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
|
@ -1,27 +1,35 @@
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<h1>Credits</h1>
|
<h1>Credits</h1>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-4">
|
<div class="col-md-4">
|
||||||
<h2>Source code</h2>
|
<h2>Source code</h2>
|
||||||
<p>
|
<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
|
The original system was written by <a href="https://github.com/cookieBerlin/engelsystem">cookie</a>.
|
||||||
cyborg</a>, <a href="http://jplitza.de/">jplitza</a> and gnomus.
|
It was then completely rewritten and greatly enhanced by <a href="http://notrademark.de/">msquare</a>
|
||||||
</p>
|
and <a href="http://myigel.name/">MyIgel</a>,
|
||||||
<p>
|
<a href="http://mortzu.de/">mortzu</a> of <a href="http://planetcyborg.de">planet cyborg</a>,
|
||||||
Please look at the <a href="https://github.com/engelsystem/engelsystem/graphs/contributors">contributor list on github</a> for a more complete version.
|
<a href="http://jplitza.de/">jplitza</a> and gnomus.
|
||||||
</p>
|
</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>
|
||||||
<div class="col-md-4">
|
</div>
|
||||||
<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>
|
|
||||||
|
|
|
@ -1,53 +1,60 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>%title% - Engelsystem</title>
|
<title>%title% - Engelsystem</title>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8"/>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<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="css/theme%theme%.css"/>
|
||||||
<link rel="stylesheet" type="text/css" href="vendor/icomoon/style.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" />
|
<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-2.1.1.min.js"></script>
|
||||||
<script type="text/javascript" src="vendor/jquery-ui.min.js"></script>
|
<script type="text/javascript" src="vendor/jquery-ui.min.js"></script>
|
||||||
%atom_link%
|
%atom_link%
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="navbar navbar-default navbar-fixed-top">
|
<div class="navbar navbar-default navbar-fixed-top">
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<div class="navbar-header">
|
<div class="navbar-header">
|
||||||
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar-collapse-1">
|
<button type="button" class="navbar-toggle collapsed"
|
||||||
<span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span>
|
data-toggle="collapse" data-target="#navbar-collapse-1">
|
||||||
</button>
|
<span class="sr-only">Toggle navigation</span>
|
||||||
<a class="navbar-brand" href="?"><span class="icon-icon_angel"></span> <strong class="visible-lg-inline">ENGELSYSTEM</strong></a>
|
<span class="icon-bar"></span>
|
||||||
</div>
|
<span class="icon-bar"></span>
|
||||||
<div class="collapse navbar-collapse" id="navbar-collapse-1">%menu% %header_toolbar%</div>
|
<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>
|
</div>
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<div class="row">%content%</div>
|
<div class="row">%content%</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
<hr />
|
<hr/>
|
||||||
<div class="text-center footer" style="margin-bottom: 10px;">
|
<div class="text-center footer" style="margin-bottom: 10px;">
|
||||||
%event_info%
|
%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
|
<a href="%faq_url%">FAQ</a>
|
||||||
Platform</a> · <a href="?p=credits">Credits</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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script type="text/javascript" src="vendor/bootstrap/js/bootstrap.min.js"></script>
|
<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/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/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="vendor/Chart.min.js"></script>
|
||||||
<script type="text/javascript" src="js/forms.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" src="vendor/moment-with-locales.min.js"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(function() {
|
$(function () {
|
||||||
moment.locale("%locale%");
|
moment.locale("%locale%");
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<script type="text/javascript" src="js/moment-countdown.js"></script>
|
<script type="text/javascript" src="js/moment-countdown.js"></script>
|
||||||
<script type="text/javascript" src="js/sticky-headers.js"></script>
|
<script type="text/javascript" src="js/sticky-headers.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -1,52 +1,54 @@
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
function set_to_now(id) {
|
function set_to_now(id) {
|
||||||
document.getElementById(id + '_time').value = moment().format('HH:mm');
|
document.getElementById(id + '_time').value = moment().format('HH:mm');
|
||||||
var days = document.getElementById(id + '_day').getElementsByTagName(
|
var days = document.getElementById(id + '_day').getElementsByTagName(
|
||||||
'option');
|
'option');
|
||||||
for ( var i = 0; i < days.length; i++) {
|
for (var i = 0; i < days.length; i++) {
|
||||||
if (days[i].value == moment().format('YYYY-MM-DD'))
|
if (days[i].value == moment().format('YYYY-MM-DD'))
|
||||||
days[i].selected = true;
|
days[i].selected = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<form class="form-inline" action="" method="get">
|
<form class="form-inline" action="" method="get">
|
||||||
<input type="hidden" name="p" value="user_shifts">
|
<input type="hidden" name="p" value="user_shifts">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<h1>%title%</h1>
|
<h1>%title%</h1>
|
||||||
<div class="form-group">%start_select%</div>
|
<div class="form-group">%start_select%</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="input-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%">
|
<input class="form-control" type="text" id="start_time" name="start_time" size="5"
|
||||||
<div class="input-group-btn">
|
pattern="^\d{1,2}:\d{2}$" placeholder="HH:MM" maxlength="5" value="%start_time%">
|
||||||
<button class="btn btn-default" title="Now" type="button" onclick="set_to_now('start');">
|
<div class="input-group-btn">
|
||||||
<span class="glyphicon glyphicon-time"></span>
|
<button class="btn btn-default" title="Now" type="button" onclick="set_to_now('start');">
|
||||||
</button>
|
<span class="glyphicon glyphicon-time"></span>
|
||||||
</div>
|
</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 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="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="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>
|
</form>
|
||||||
%shifts_table% %ical_text%
|
%shifts_table% %ical_text%
|
||||||
|
|
|
@ -13,9 +13,9 @@ class LogEntriesModelTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
$count = count(LogEntries());
|
$count = count(LogEntries());
|
||||||
$this->assertNotFalse(LogEntry_create('test', 'test_LogEntry_create'));
|
$this->assertNotFalse(LogEntry_create('test', 'test_LogEntry_create'));
|
||||||
|
|
||||||
// There should be one more log entry now
|
// There should be one more log entry now
|
||||||
$this->assertEquals(count(LogEntries()), $count + 1);
|
$this->assertEquals(count(LogEntries()), $count + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_LogEntries_clear_all()
|
public function test_LogEntries_clear_all()
|
||||||
|
@ -26,11 +26,11 @@ class LogEntriesModelTest extends \PHPUnit_Framework_TestCase
|
||||||
$this->assertEquals(count(LogEntries()), 0);
|
$this->assertEquals(count(LogEntries()), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @after
|
* @after
|
||||||
*/
|
*/
|
||||||
public function teardown()
|
public function teardown()
|
||||||
{
|
{
|
||||||
LogEntries_clear_all();
|
LogEntries_clear_all();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,23 +14,23 @@ class RoomModelTest extends \PHPUnit_Framework_TestCase
|
||||||
public function test_Room()
|
public function test_Room()
|
||||||
{
|
{
|
||||||
$this->create_Room();
|
$this->create_Room();
|
||||||
|
|
||||||
$room = Room($this->room_id);
|
$room = Room($this->room_id);
|
||||||
|
|
||||||
$this->assertNotFalse($room);
|
$this->assertNotFalse($room);
|
||||||
$this->assertNotNull($room);
|
$this->assertNotNull($room);
|
||||||
$this->assertEquals($room['Name'], 'test');
|
$this->assertEquals($room['Name'], 'test');
|
||||||
|
|
||||||
$this->assertNull(Room(- 1));
|
$this->assertNull(Room(-1));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @after
|
* @after
|
||||||
*/
|
*/
|
||||||
public function teardown()
|
public function teardown()
|
||||||
{
|
{
|
||||||
if ($this->room_id != null) {
|
if ($this->room_id != null) {
|
||||||
Room_delete($this->room_id);
|
Room_delete($this->room_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
134
themes/base.less
134
themes/base.less
|
@ -11,14 +11,14 @@ body {
|
||||||
}
|
}
|
||||||
|
|
||||||
.first {
|
.first {
|
||||||
margin-top: 30px;
|
margin-top: 30px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.text-big {
|
.text-big {
|
||||||
display: block;
|
display: block;
|
||||||
font-size: 30px;
|
font-size: 30px;
|
||||||
line-height: 30px;
|
line-height: 30px;
|
||||||
margin: 0px;
|
margin: 0px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.panel-primary .panel-heading a {
|
.panel-primary .panel-heading a {
|
||||||
|
@ -51,51 +51,51 @@ body {
|
||||||
flex-wrap: nowrap;
|
flex-wrap: nowrap;
|
||||||
align-itmes: stretch;
|
align-itmes: stretch;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
||||||
.lane {
|
.lane {
|
||||||
background: @table-bg-accent;
|
background: @table-bg-accent;
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
min-width: 280px;
|
min-width: 280px;
|
||||||
width: 280px;
|
width: 280px;
|
||||||
flex-shrink: 1;
|
flex-shrink: 1;
|
||||||
|
|
||||||
.header {
|
.header {
|
||||||
background: @panel-bg;
|
background: @panel-bg;
|
||||||
border-bottom: 1px solid @table-border-color;
|
border-bottom: 1px solid @table-border-color;
|
||||||
height: 30px;
|
height: 30px;
|
||||||
padding: 5px 5px 5px 16px;
|
padding: 5px 5px 5px 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tick {
|
.tick {
|
||||||
height: 30px;
|
height: 30px;
|
||||||
border-top: 1px solid darken(@table-bg-accent, 2%);
|
border-top: 1px solid darken(@table-bg-accent, 2%);
|
||||||
}
|
}
|
||||||
|
|
||||||
.tick.hour {
|
.tick.hour {
|
||||||
border-top: 2px solid @table-border-color;
|
border-top: 2px solid @table-border-color;
|
||||||
font-size: 0.9em;
|
font-size: 0.9em;
|
||||||
padding-left: 5px;
|
padding-left: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tick.day {
|
.tick.day {
|
||||||
border-top: 2px solid @brand-primary;
|
border-top: 2px solid @brand-primary;
|
||||||
font-size: 0.9em;
|
font-size: 0.9em;
|
||||||
padding-left: 5px;
|
padding-left: 5px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.lane.time {
|
.lane.time {
|
||||||
border-right: 1px solid @table-border-color;
|
border-right: 1px solid @table-border-color;
|
||||||
flex-grow: 0;
|
flex-grow: 0;
|
||||||
min-width: 50px;
|
min-width: 50px;
|
||||||
width: 50px;
|
width: 50px;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.shift {
|
.shift {
|
||||||
margin: 0 5px 5px 0;
|
margin: 0 5px 5px 0;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.space-top {
|
.space-top {
|
||||||
|
@ -119,22 +119,22 @@ body {
|
||||||
|
|
||||||
@keyframes pulse {
|
@keyframes pulse {
|
||||||
0% {
|
0% {
|
||||||
transform: rotate(0deg);
|
transform: rotate(0deg);
|
||||||
}
|
}
|
||||||
10% {
|
10% {
|
||||||
transform: rotate(5deg) translateY(-2px);
|
transform: rotate(5deg) translateY(-2px);
|
||||||
}
|
}
|
||||||
20% {
|
20% {
|
||||||
transform: rotate(-5deg);
|
transform: rotate(-5deg);
|
||||||
}
|
}
|
||||||
30% {
|
30% {
|
||||||
transform: rotate(5deg) translateY(-2px);;
|
transform: rotate(5deg) translateY(-2px);;
|
||||||
}
|
}
|
||||||
40% {
|
40% {
|
||||||
transform: rotate(-5deg);
|
transform: rotate(-5deg);
|
||||||
}
|
}
|
||||||
50% {
|
50% {
|
||||||
transform: rotate(0deg) translateY(-2px);
|
transform: rotate(0deg) translateY(-2px);
|
||||||
}
|
}
|
||||||
75% {
|
75% {
|
||||||
transform: rotate(0deg) translateY(0px);
|
transform: rotate(0deg) translateY(0px);
|
||||||
|
@ -143,22 +143,22 @@ body {
|
||||||
|
|
||||||
@-webkit-keyframes pulse {
|
@-webkit-keyframes pulse {
|
||||||
0% {
|
0% {
|
||||||
transform: rotate(0deg);
|
transform: rotate(0deg);
|
||||||
}
|
}
|
||||||
10% {
|
10% {
|
||||||
transform: rotate(5deg) translateY(-2px);
|
transform: rotate(5deg) translateY(-2px);
|
||||||
}
|
}
|
||||||
20% {
|
20% {
|
||||||
transform: rotate(-5deg);
|
transform: rotate(-5deg);
|
||||||
}
|
}
|
||||||
30% {
|
30% {
|
||||||
transform: rotate(5deg) translateY(-2px);
|
transform: rotate(5deg) translateY(-2px);
|
||||||
}
|
}
|
||||||
40% {
|
40% {
|
||||||
transform: rotate(-5deg);
|
transform: rotate(-5deg);
|
||||||
}
|
}
|
||||||
50% {
|
50% {
|
||||||
transform: rotate(0deg) translateY(-2px);
|
transform: rotate(0deg) translateY(-2px);
|
||||||
}
|
}
|
||||||
75% {
|
75% {
|
||||||
transform: rotate(0deg) translateY(0px);
|
transform: rotate(0deg) translateY(0px);
|
||||||
|
@ -167,22 +167,22 @@ body {
|
||||||
|
|
||||||
@-moz-keyframes pulse {
|
@-moz-keyframes pulse {
|
||||||
0% {
|
0% {
|
||||||
transform: rotate(0deg);
|
transform: rotate(0deg);
|
||||||
}
|
}
|
||||||
10% {
|
10% {
|
||||||
transform: rotate(5deg) translateY(-2px);
|
transform: rotate(5deg) translateY(-2px);
|
||||||
}
|
}
|
||||||
20% {
|
20% {
|
||||||
transform: rotate(-5deg);
|
transform: rotate(-5deg);
|
||||||
}
|
}
|
||||||
30% {
|
30% {
|
||||||
transform: rotate(5deg) translateY(-2px);
|
transform: rotate(5deg) translateY(-2px);
|
||||||
}
|
}
|
||||||
40% {
|
40% {
|
||||||
transform: rotate(-5deg);
|
transform: rotate(-5deg);
|
||||||
}
|
}
|
||||||
50% {
|
50% {
|
||||||
transform: rotate(0deg) translateY(-2px);
|
transform: rotate(0deg) translateY(-2px);
|
||||||
}
|
}
|
||||||
75% {
|
75% {
|
||||||
transform: rotate(0deg) translateY(0px);
|
transform: rotate(0deg) translateY(0px);
|
||||||
|
|
Loading…
Reference in New Issue