prohibit inline control structures on controllers
This commit is contained in:
parent
6685beb397
commit
bd9003f5d5
|
@ -11,8 +11,9 @@ function angeltypes_title() {
|
||||||
* Route angeltype actions.
|
* Route angeltype actions.
|
||||||
*/
|
*/
|
||||||
function angeltypes_controller() {
|
function angeltypes_controller() {
|
||||||
if (! isset($_REQUEST['action']))
|
if (! isset($_REQUEST['action'])) {
|
||||||
$_REQUEST['action'] = 'list';
|
$_REQUEST['action'] = 'list';
|
||||||
|
}
|
||||||
|
|
||||||
switch ($_REQUEST['action']) {
|
switch ($_REQUEST['action']) {
|
||||||
default:
|
default:
|
||||||
|
@ -44,17 +45,19 @@ 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();
|
||||||
if ($angeltypes === false)
|
}
|
||||||
|
if ($angeltypes === false) {
|
||||||
engelsystem_error("Unable to load angeltypes.");
|
engelsystem_error("Unable to load angeltypes.");
|
||||||
|
}
|
||||||
|
|
||||||
return array(
|
return [
|
||||||
_("Teams/Job description"),
|
_("Teams/Job description"),
|
||||||
AngelTypes_about_view($angeltypes, isset($user))
|
AngelTypes_about_view($angeltypes, isset($user))
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -63,29 +66,33 @@ 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 = AngelType($_REQUEST['angeltype_id']);
|
$angeltype = AngelType($_REQUEST['angeltype_id']);
|
||||||
if ($angeltype === false)
|
if ($angeltype === false) {
|
||||||
engelsystem_error("Unable to load angeltype.");
|
engelsystem_error("Unable to load angeltype.");
|
||||||
if ($angeltype == null)
|
}
|
||||||
|
if ($angeltype == null) {
|
||||||
redirect(page_link_to('angeltypes'));
|
redirect(page_link_to('angeltypes'));
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($_REQUEST['confirmed'])) {
|
if (isset($_REQUEST['confirmed'])) {
|
||||||
$result = AngelType_delete($angeltype);
|
$result = AngelType_delete($angeltype);
|
||||||
if ($result === false)
|
if ($result === false) {
|
||||||
engelsystem_error("Unable to delete angeltype.");
|
engelsystem_error("Unable to delete angeltype.");
|
||||||
|
}
|
||||||
|
|
||||||
engelsystem_log("Deleted angeltype: " . AngelType_name_render($angeltype));
|
engelsystem_log("Deleted angeltype: " . AngelType_name_render($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 array(
|
return [
|
||||||
sprintf(_("Delete angeltype %s"), $angeltype['name']),
|
sprintf(_("Delete angeltype %s"), $angeltype['name']),
|
||||||
AngelType_delete_view($angeltype)
|
AngelType_delete_view($angeltype)
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -101,22 +108,26 @@ function angeltype_edit_controller() {
|
||||||
|
|
||||||
if (isset($_REQUEST['angeltype_id'])) {
|
if (isset($_REQUEST['angeltype_id'])) {
|
||||||
$angeltype = AngelType($_REQUEST['angeltype_id']);
|
$angeltype = AngelType($_REQUEST['angeltype_id']);
|
||||||
if ($angeltype === false)
|
if ($angeltype === false) {
|
||||||
engelsystem_error("Unable to load angeltype.");
|
engelsystem_error("Unable to load angeltype.");
|
||||||
if ($angeltype == null)
|
}
|
||||||
|
if ($angeltype == null) {
|
||||||
redirect(page_link_to('angeltypes'));
|
redirect(page_link_to('angeltypes'));
|
||||||
|
}
|
||||||
|
|
||||||
$name = $angeltype['name'];
|
$name = $angeltype['name'];
|
||||||
$restricted = $angeltype['restricted'];
|
$restricted = $angeltype['restricted'];
|
||||||
$description = $angeltype['description'];
|
$description = $angeltype['description'];
|
||||||
$requires_driver_license = $angeltype['requires_driver_license'];
|
$requires_driver_license = $angeltype['requires_driver_license'];
|
||||||
|
|
||||||
if (! User_is_AngelType_coordinator($user, $angeltype))
|
if (! User_is_AngelType_coordinator($user, $angeltype)) {
|
||||||
redirect(page_link_to('angeltypes'));
|
redirect(page_link_to('angeltypes'));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (! in_array('admin_angel_types', $privileges))
|
if (! in_array('admin_angel_types', $privileges)) {
|
||||||
redirect(page_link_to('angeltypes'));
|
redirect(page_link_to('angeltypes'));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// In coordinator mode only allow to modify description
|
// In coordinator mode only allow to modify description
|
||||||
$coordinator_mode = ! in_array('admin_angel_types', $privileges);
|
$coordinator_mode = ! in_array('admin_angel_types', $privileges);
|
||||||
|
@ -137,20 +148,23 @@ function angeltype_edit_controller() {
|
||||||
$requires_driver_license = isset($_REQUEST['requires_driver_license']);
|
$requires_driver_license = isset($_REQUEST['requires_driver_license']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_REQUEST['description']))
|
if (isset($_REQUEST['description'])) {
|
||||||
$description = strip_request_item_nl('description');
|
$description = strip_request_item_nl('description');
|
||||||
|
}
|
||||||
|
|
||||||
if ($ok) {
|
if ($ok) {
|
||||||
if (isset($angeltype)) {
|
if (isset($angeltype)) {
|
||||||
$result = AngelType_update($angeltype['id'], $name, $restricted, $description, $requires_driver_license);
|
$result = AngelType_update($angeltype['id'], $name, $restricted, $description, $requires_driver_license);
|
||||||
if ($result === false)
|
if ($result === false) {
|
||||||
engelsystem_error("Unable to update angeltype.");
|
engelsystem_error("Unable to update angeltype.");
|
||||||
|
}
|
||||||
engelsystem_log("Updated angeltype: " . $name . ($restricted ? ", restricted" : "") . ($requires_driver_license ? ", requires driver license" : ""));
|
engelsystem_log("Updated angeltype: " . $name . ($restricted ? ", restricted" : "") . ($requires_driver_license ? ", requires driver license" : ""));
|
||||||
$angeltype_id = $angeltype['id'];
|
$angeltype_id = $angeltype['id'];
|
||||||
} else {
|
} else {
|
||||||
$angeltype_id = AngelType_create($name, $restricted, $description, $requires_driver_license);
|
$angeltype_id = AngelType_create($name, $restricted, $description, $requires_driver_license);
|
||||||
if ($angeltype_id === false)
|
if ($angeltype_id === false) {
|
||||||
engelsystem_error("Unable to create angeltype.");
|
engelsystem_error("Unable to create angeltype.");
|
||||||
|
}
|
||||||
engelsystem_log("Created angeltype: " . $name . ($restricted ? ", restricted" : "") . ($requires_driver_license ? ", requires driver license" : ""));
|
engelsystem_log("Created angeltype: " . $name . ($restricted ? ", restricted" : "") . ($requires_driver_license ? ", requires driver license" : ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,10 +173,10 @@ function angeltype_edit_controller() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return array(
|
return [
|
||||||
sprintf(_("Edit %s"), $name),
|
sprintf(_("Edit %s"), $name),
|
||||||
AngelType_edit_view($name, $restricted, $description, $coordinator_mode, $requires_driver_license)
|
AngelType_edit_view($name, $restricted, $description, $coordinator_mode, $requires_driver_license)
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -171,34 +185,41 @@ 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('?');
|
||||||
|
}
|
||||||
|
|
||||||
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 === false)
|
if ($angeltype === false) {
|
||||||
engelsystem_error("Unable to load angeltype.");
|
engelsystem_error("Unable to load angeltype.");
|
||||||
if ($angeltype == null)
|
}
|
||||||
|
if ($angeltype == null) {
|
||||||
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 === false)
|
if ($user_angeltype === false) {
|
||||||
engelsystem_error("Unable to load user angeltype.");
|
engelsystem_error("Unable to load user angeltype.");
|
||||||
|
}
|
||||||
|
|
||||||
$user_driver_license = UserDriverLicense($user['UID']);
|
$user_driver_license = UserDriverLicense($user['UID']);
|
||||||
if ($user_driver_license === false)
|
if ($user_driver_license === false) {
|
||||||
engelsystem_error("Unable to load user driver license.");
|
engelsystem_error("Unable to load user driver license.");
|
||||||
|
}
|
||||||
|
|
||||||
$members = Users_by_angeltype($angeltype);
|
$members = Users_by_angeltype($angeltype);
|
||||||
if ($members === false)
|
if ($members === false) {
|
||||||
engelsystem_error("Unable to load members.");
|
engelsystem_error("Unable to load members.");
|
||||||
|
}
|
||||||
|
|
||||||
return array(
|
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['coordinator'], in_array('admin_angel_types', $privileges), $user_angeltype['coordinator'], $user_driver_license, $user)
|
AngelType_view($angeltype, $members, $user_angeltype, in_array('admin_user_angeltypes', $privileges) || $user_angeltype['coordinator'], in_array('admin_angel_types', $privileges), $user_angeltype['coordinator'], $user_driver_license, $user)
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -207,17 +228,19 @@ 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);
|
||||||
if ($angeltypes === false)
|
if ($angeltypes === false) {
|
||||||
engelsystem_error("Unable to load angeltypes.");
|
engelsystem_error("Unable to load angeltypes.");
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($angeltypes as &$angeltype) {
|
foreach ($angeltypes as &$angeltype) {
|
||||||
$actions = array(
|
$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(page_link_to('angeltypes') . '&action=edit&angeltype_id=' . $angeltype['id'], _("edit"), "btn-xs");
|
||||||
|
@ -237,9 +260,9 @@ function angeltypes_list_controller() {
|
||||||
$angeltype['actions'] = table_buttons($actions);
|
$angeltype['actions'] = table_buttons($actions);
|
||||||
}
|
}
|
||||||
|
|
||||||
return array(
|
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))
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -7,8 +7,9 @@ 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;
|
||||||
|
@ -18,8 +19,9 @@ function event_config_edit_controller() {
|
||||||
$teardown_end_date = null;
|
$teardown_end_date = null;
|
||||||
|
|
||||||
$event_config = EventConfig();
|
$event_config = EventConfig();
|
||||||
if ($event_config === false)
|
if ($event_config === false) {
|
||||||
engelsystem_error('Unable to load event config.');
|
engelsystem_error('Unable to load event config.');
|
||||||
|
}
|
||||||
if ($event_config != null) {
|
if ($event_config != null) {
|
||||||
$event_name = $event_config['event_name'];
|
$event_name = $event_config['event_name'];
|
||||||
$buildup_start_date = $event_config['buildup_start_date'];
|
$buildup_start_date = $event_config['buildup_start_date'];
|
||||||
|
@ -32,15 +34,19 @@ function event_config_edit_controller() {
|
||||||
if (isset($_REQUEST['submit'])) {
|
if (isset($_REQUEST['submit'])) {
|
||||||
$ok = true;
|
$ok = 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();
|
||||||
|
@ -81,8 +87,9 @@ function event_config_edit_controller() {
|
||||||
if ($ok) {
|
if ($ok) {
|
||||||
$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."));
|
||||||
|
|
|
@ -8,28 +8,34 @@ function shifttype_link($shifttype) {
|
||||||
* Delete a shifttype.
|
* Delete a 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 array(
|
return [
|
||||||
sprintf(_("Delete shifttype %s"), $shifttype['name']),
|
sprintf(_("Delete shifttype %s"), $shifttype['name']),
|
||||||
ShiftType_delete_view($shifttype)
|
ShiftType_delete_view($shifttype)
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -42,13 +48,15 @@ function shifttype_edit_controller() {
|
||||||
$description = "";
|
$description = "";
|
||||||
|
|
||||||
$angeltypes = AngelTypes();
|
$angeltypes = AngelTypes();
|
||||||
if ($angeltypes === false)
|
if ($angeltypes === false) {
|
||||||
engelsystem_error("Unable to load angel types.");
|
engelsystem_error("Unable to load angel types.");
|
||||||
|
}
|
||||||
|
|
||||||
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) {
|
||||||
engelsystem_error('Unable to load shifttype.');
|
engelsystem_error('Unable to load shifttype.');
|
||||||
|
}
|
||||||
if ($shifttype == null) {
|
if ($shifttype == null) {
|
||||||
error(_('Shifttype not found.'));
|
error(_('Shifttype not found.'));
|
||||||
redirect(page_link_to('shifttypes'));
|
redirect(page_link_to('shifttypes'));
|
||||||
|
@ -62,32 +70,36 @@ function shifttype_edit_controller() {
|
||||||
if (isset($_REQUEST['submit'])) {
|
if (isset($_REQUEST['submit'])) {
|
||||||
$ok = true;
|
$ok = 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 {
|
||||||
$ok = false;
|
$ok = 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 ($ok) {
|
if ($ok) {
|
||||||
if ($shifttype_id) {
|
if ($shifttype_id) {
|
||||||
$result = ShiftType_update($shifttype_id, $name, $angeltype_id, $description);
|
$result = ShiftType_update($shifttype_id, $name, $angeltype_id, $description);
|
||||||
if ($result === false)
|
if ($result === false) {
|
||||||
engelsystem_error('Unable to update shifttype.');
|
engelsystem_error('Unable to update shifttype.');
|
||||||
|
}
|
||||||
engelsystem_log('Updated shifttype ' . $name);
|
engelsystem_log('Updated shifttype ' . $name);
|
||||||
success(_('Updated shifttype.'));
|
success(_('Updated shifttype.'));
|
||||||
} else {
|
} else {
|
||||||
$shifttype_id = ShiftType_create($name, $angeltype_id, $description);
|
$shifttype_id = ShiftType_create($name, $angeltype_id, $description);
|
||||||
if ($shifttype_id === false)
|
if ($shifttype_id === false) {
|
||||||
engelsystem_error('Unable to create shifttype.');
|
engelsystem_error('Unable to create shifttype.');
|
||||||
|
}
|
||||||
engelsystem_log('Created shifttype ' . $name);
|
engelsystem_log('Created shifttype ' . $name);
|
||||||
success(_('Created shifttype.'));
|
success(_('Created shifttype.'));
|
||||||
}
|
}
|
||||||
|
@ -102,20 +114,24 @@ function shifttype_edit_controller() {
|
||||||
}
|
}
|
||||||
|
|
||||||
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']);
|
||||||
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'));
|
||||||
|
}
|
||||||
|
|
||||||
$angeltype = null;
|
$angeltype = null;
|
||||||
if ($shifttype['angeltype_id'] != null) {
|
if ($shifttype['angeltype_id'] != null) {
|
||||||
$angeltype = AngelType($shifttype['angeltype_id']);
|
$angeltype = AngelType($shifttype['angeltype_id']);
|
||||||
if ($angeltype === false)
|
if ($angeltype === false) {
|
||||||
engelsystem_error('Unable to load angeltype.');
|
engelsystem_error('Unable to load angeltype.');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
$shifttype['name'],
|
$shifttype['name'],
|
||||||
|
@ -128,8 +144,9 @@ function shifttype_controller() {
|
||||||
*/
|
*/
|
||||||
function shifttypes_list_controller() {
|
function shifttypes_list_controller() {
|
||||||
$shifttypes = ShiftTypes();
|
$shifttypes = ShiftTypes();
|
||||||
if ($shifttypes === false)
|
if ($shifttypes === false) {
|
||||||
engelsystem_error("Unable to load shifttypes.");
|
engelsystem_error("Unable to load shifttypes.");
|
||||||
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
shifttypes_title(),
|
shifttypes_title(),
|
||||||
|
@ -148,8 +165,9 @@ function shifttypes_title() {
|
||||||
* Route shift type actions
|
* Route shift type actions
|
||||||
*/
|
*/
|
||||||
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:
|
||||||
|
|
|
@ -7,14 +7,17 @@ function user_angeltypes_unconfirmed_hint() {
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
$unconfirmed_user_angeltypes = User_unconfirmed_AngelTypes($user);
|
$unconfirmed_user_angeltypes = User_unconfirmed_AngelTypes($user);
|
||||||
if ($unconfirmed_user_angeltypes === false)
|
if ($unconfirmed_user_angeltypes === false) {
|
||||||
engelsystem_error("Unable to load user angeltypes.");
|
engelsystem_error("Unable to load user angeltypes.");
|
||||||
if (count($unconfirmed_user_angeltypes) == 0)
|
}
|
||||||
|
if (count($unconfirmed_user_angeltypes) == 0) {
|
||||||
return '';
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
$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 info(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), true);
|
return info(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), true);
|
||||||
}
|
}
|
||||||
|
@ -31,8 +34,9 @@ function user_angeltypes_delete_all_controller() {
|
||||||
}
|
}
|
||||||
|
|
||||||
$angeltype = AngelType($_REQUEST['angeltype_id']);
|
$angeltype = AngelType($_REQUEST['angeltype_id']);
|
||||||
if ($angeltype === false)
|
if ($angeltype === false) {
|
||||||
engelsystem_error("Unable to load angeltype.");
|
engelsystem_error("Unable to load angeltype.");
|
||||||
|
}
|
||||||
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'));
|
||||||
|
@ -45,18 +49,19 @@ function user_angeltypes_delete_all_controller() {
|
||||||
|
|
||||||
if (isset($_REQUEST['confirmed'])) {
|
if (isset($_REQUEST['confirmed'])) {
|
||||||
$result = UserAngelTypes_delete_all($angeltype['id']);
|
$result = UserAngelTypes_delete_all($angeltype['id']);
|
||||||
if ($result === false)
|
if ($result === false) {
|
||||||
engelsystem_error("Unable to confirm all users.");
|
engelsystem_error("Unable to confirm all users.");
|
||||||
|
}
|
||||||
|
|
||||||
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 array(
|
return [
|
||||||
_("Deny all users"),
|
_("Deny all users"),
|
||||||
UserAngelTypes_delete_all_view($angeltype)
|
UserAngelTypes_delete_all_view($angeltype)
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -71,16 +76,18 @@ function user_angeltypes_confirm_all_controller() {
|
||||||
}
|
}
|
||||||
|
|
||||||
$angeltype = AngelType($_REQUEST['angeltype_id']);
|
$angeltype = AngelType($_REQUEST['angeltype_id']);
|
||||||
if ($angeltype === false)
|
if ($angeltype === false) {
|
||||||
engelsystem_error("Unable to load angeltype.");
|
engelsystem_error("Unable to load angeltype.");
|
||||||
|
}
|
||||||
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 === false)
|
if ($user_angeltype === false) {
|
||||||
engelsystem_error("Unable to load user angeltype.");
|
engelsystem_error("Unable to load 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'));
|
||||||
|
@ -93,18 +100,19 @@ function user_angeltypes_confirm_all_controller() {
|
||||||
|
|
||||||
if (isset($_REQUEST['confirmed'])) {
|
if (isset($_REQUEST['confirmed'])) {
|
||||||
$result = UserAngelTypes_confirm_all($angeltype['id'], $user);
|
$result = UserAngelTypes_confirm_all($angeltype['id'], $user);
|
||||||
if ($result === false)
|
if ($result === false) {
|
||||||
engelsystem_error("Unable to confirm all users.");
|
engelsystem_error("Unable to confirm all users.");
|
||||||
|
}
|
||||||
|
|
||||||
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 array(
|
return [
|
||||||
_("Confirm all users"),
|
_("Confirm all users"),
|
||||||
UserAngelTypes_confirm_all_view($angeltype)
|
UserAngelTypes_confirm_all_view($angeltype)
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -119,16 +127,18 @@ function user_angeltype_confirm_controller() {
|
||||||
}
|
}
|
||||||
|
|
||||||
$user_angeltype = UserAngelType($_REQUEST['user_angeltype_id']);
|
$user_angeltype = UserAngelType($_REQUEST['user_angeltype_id']);
|
||||||
if ($user_angeltype === false)
|
if ($user_angeltype === false) {
|
||||||
engelsystem_error("Unable to load user angeltype.");
|
engelsystem_error("Unable to load 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'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$angeltype = AngelType($user_angeltype['angeltype_id']);
|
$angeltype = AngelType($user_angeltype['angeltype_id']);
|
||||||
if ($angeltype === false)
|
if ($angeltype === false) {
|
||||||
engelsystem_error("Unable to load angeltype.");
|
engelsystem_error("Unable to load angeltype.");
|
||||||
|
}
|
||||||
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'));
|
||||||
|
@ -140,8 +150,9 @@ function user_angeltype_confirm_controller() {
|
||||||
}
|
}
|
||||||
|
|
||||||
$user_source = User($user_angeltype['user_id']);
|
$user_source = User($user_angeltype['user_id']);
|
||||||
if ($user_source === false)
|
if ($user_source === false) {
|
||||||
engelsystem_error("Unable to load user.");
|
engelsystem_error("Unable to load user.");
|
||||||
|
}
|
||||||
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'));
|
||||||
|
@ -149,18 +160,19 @@ function user_angeltype_confirm_controller() {
|
||||||
|
|
||||||
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("%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)));
|
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 array(
|
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)
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -175,24 +187,27 @@ function user_angeltype_delete_controller() {
|
||||||
}
|
}
|
||||||
|
|
||||||
$user_angeltype = UserAngelType($_REQUEST['user_angeltype_id']);
|
$user_angeltype = UserAngelType($_REQUEST['user_angeltype_id']);
|
||||||
if ($user_angeltype === false)
|
if ($user_angeltype === false) {
|
||||||
engelsystem_error("Unable to load user angeltype.");
|
engelsystem_error("Unable to load 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'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$angeltype = AngelType($user_angeltype['angeltype_id']);
|
$angeltype = AngelType($user_angeltype['angeltype_id']);
|
||||||
if ($angeltype === false)
|
if ($angeltype === false) {
|
||||||
engelsystem_error("Unable to load angeltype.");
|
engelsystem_error("Unable to load angeltype.");
|
||||||
|
}
|
||||||
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 === false)
|
if ($user_source === false) {
|
||||||
engelsystem_error("Unable to load user.");
|
engelsystem_error("Unable to load user.");
|
||||||
|
}
|
||||||
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'));
|
||||||
|
@ -205,8 +220,9 @@ function user_angeltype_delete_controller() {
|
||||||
|
|
||||||
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);
|
||||||
|
@ -215,10 +231,10 @@ function user_angeltype_delete_controller() {
|
||||||
redirect(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id']);
|
redirect(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
return array(
|
return [
|
||||||
_("Remove angeltype"),
|
_("Remove angeltype"),
|
||||||
UserAngelType_delete_view($user_angeltype, $user_source, $angeltype)
|
UserAngelType_delete_view($user_angeltype, $user_source, $angeltype)
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -237,32 +253,35 @@ function user_angeltype_update_controller() {
|
||||||
redirect(page_link_to('angeltypes'));
|
redirect(page_link_to('angeltypes'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_REQUEST['coordinator']) && preg_match("/^[01]$/", $_REQUEST['coordinator']))
|
if (isset($_REQUEST['coordinator']) && preg_match("/^[01]$/", $_REQUEST['coordinator'])) {
|
||||||
$coordinator = $_REQUEST['coordinator'] == "1";
|
$coordinator = $_REQUEST['coordinator'] == "1";
|
||||||
else {
|
} else {
|
||||||
error(_("No coordinator update given."));
|
error(_("No coordinator 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 === false)
|
if ($user_angeltype === false) {
|
||||||
engelsystem_error("Unable to load user angeltype.");
|
engelsystem_error("Unable to load 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'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$angeltype = AngelType($user_angeltype['angeltype_id']);
|
$angeltype = AngelType($user_angeltype['angeltype_id']);
|
||||||
if ($angeltype === false)
|
if ($angeltype === false) {
|
||||||
engelsystem_error("Unable to load angeltype.");
|
engelsystem_error("Unable to load angeltype.");
|
||||||
|
}
|
||||||
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 === false)
|
if ($user_source === false) {
|
||||||
engelsystem_error("Unable to load user.");
|
engelsystem_error("Unable to load user.");
|
||||||
|
}
|
||||||
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'));
|
||||||
|
@ -270,8 +289,9 @@ function user_angeltype_update_controller() {
|
||||||
|
|
||||||
if (isset($_REQUEST['confirmed'])) {
|
if (isset($_REQUEST['confirmed'])) {
|
||||||
$result = UserAngelType_update($user_angeltype['id'], $coordinator);
|
$result = UserAngelType_update($user_angeltype['id'], $coordinator);
|
||||||
if ($result === false)
|
if ($result === false) {
|
||||||
engelsystem_error("Unable to update coordinator rights.");
|
engelsystem_error("Unable to update coordinator rights.");
|
||||||
|
}
|
||||||
|
|
||||||
$success_message = sprintf($coordinator ? _("Added coordinator rights for %s to %s.") : _("Removed coordinator rights for %s from %s."), AngelType_name_render($angeltype), User_Nick_render($user_source));
|
$success_message = sprintf($coordinator ? _("Added coordinator rights for %s to %s.") : _("Removed coordinator rights for %s from %s."), AngelType_name_render($angeltype), User_Nick_render($user_source));
|
||||||
engelsystem_log($success_message);
|
engelsystem_log($success_message);
|
||||||
|
@ -280,10 +300,10 @@ function user_angeltype_update_controller() {
|
||||||
redirect(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id']);
|
redirect(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
return array(
|
return [
|
||||||
$coordinator ? _("Add coordinator rights") : _("Remove coordinator rights"),
|
$coordinator ? _("Add coordinator rights") : _("Remove coordinator rights"),
|
||||||
UserAngelType_update_view($user_angeltype, $user_source, $angeltype, $coordinator)
|
UserAngelType_update_view($user_angeltype, $user_source, $angeltype, $coordinator)
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -298,8 +318,9 @@ function user_angeltype_add_controller() {
|
||||||
}
|
}
|
||||||
|
|
||||||
$angeltype = AngelType($_REQUEST['angeltype_id']);
|
$angeltype = AngelType($_REQUEST['angeltype_id']);
|
||||||
if ($angeltype === false)
|
if ($angeltype === false) {
|
||||||
engelsystem_error("Unable to load angeltype.");
|
engelsystem_error("Unable to load angeltype.");
|
||||||
|
}
|
||||||
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'));
|
||||||
|
@ -310,50 +331,55 @@ function user_angeltype_add_controller() {
|
||||||
$user_id = $user['UID'];
|
$user_id = $user['UID'];
|
||||||
|
|
||||||
$users_source = Users_by_angeltype_inverted($angeltype);
|
$users_source = Users_by_angeltype_inverted($angeltype);
|
||||||
if ($users_source === false)
|
if ($users_source === false) {
|
||||||
engelsystem_error("Unable to load users.");
|
engelsystem_error("Unable to load users.");
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($_REQUEST['submit'])) {
|
if (isset($_REQUEST['submit'])) {
|
||||||
$ok = true;
|
$ok = true;
|
||||||
|
|
||||||
if (isset($_REQUEST['user_id']) && in_array($_REQUEST['user_id'], array_map(function ($user) {
|
if (isset($_REQUEST['user_id']) && in_array($_REQUEST['user_id'], array_map(function ($user) {
|
||||||
return $user['UID'];
|
return $user['UID'];
|
||||||
}, $users_source)))
|
}, $users_source))) {
|
||||||
$user_id = $_REQUEST['user_id'];
|
$user_id = $_REQUEST['user_id'];
|
||||||
else {
|
} else {
|
||||||
$ok = false;
|
$ok = false;
|
||||||
error(_("Please select a user."));
|
error(_("Please select a user."));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($ok) {
|
if ($ok) {
|
||||||
foreach ($users_source as $user_source)
|
foreach ($users_source as $user_source) {
|
||||||
if ($user_source['UID'] == $user_id) {
|
if ($user_source['UID'] == $user_id) {
|
||||||
$user_angeltype_id = UserAngelType_create($user_source, $angeltype);
|
$user_angeltype_id = UserAngelType_create($user_source, $angeltype);
|
||||||
if ($user_angeltype_id === false)
|
if ($user_angeltype_id === false) {
|
||||||
engelsystem_error("Unable to create user angeltype.");
|
engelsystem_error("Unable to create user angeltype.");
|
||||||
|
}
|
||||||
|
|
||||||
engelsystem_log(sprintf("User %s added to %s.", User_Nick_render($user_source), AngelType_name_render($angeltype)));
|
engelsystem_log(sprintf("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)));
|
success(sprintf(_("User %s added to %s."), User_Nick_render($user_source), AngelType_name_render($angeltype)));
|
||||||
|
|
||||||
$result = UserAngelType_confirm($user_angeltype_id, $user_source);
|
$result = UserAngelType_confirm($user_angeltype_id, $user_source);
|
||||||
if ($result === false)
|
if ($result === false) {
|
||||||
engelsystem_error("Unable to confirm user angeltype.");
|
engelsystem_error("Unable to confirm user angeltype.");
|
||||||
|
}
|
||||||
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 array(
|
return [
|
||||||
_("Add user to angeltype"),
|
_("Add user to angeltype"),
|
||||||
UserAngelType_add_view($angeltype, $users_source, $user_id)
|
UserAngelType_add_view($angeltype, $users_source, $user_id)
|
||||||
);
|
];
|
||||||
} else {
|
} else {
|
||||||
// Allow only me
|
// Allow only me
|
||||||
$user_angeltype = UserAngelType_by_User_and_AngelType($user, $angeltype);
|
$user_angeltype = UserAngelType_by_User_and_AngelType($user, $angeltype);
|
||||||
if ($user_angeltype === false)
|
if ($user_angeltype === false) {
|
||||||
engelsystem_error("Unable to load user angeltype.");
|
engelsystem_error("Unable to load 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'));
|
||||||
|
@ -361,8 +387,9 @@ function user_angeltype_add_controller() {
|
||||||
|
|
||||||
if (isset($_REQUEST['confirmed'])) {
|
if (isset($_REQUEST['confirmed'])) {
|
||||||
$user_angeltype_id = UserAngelType_create($user, $angeltype);
|
$user_angeltype_id = UserAngelType_create($user, $angeltype);
|
||||||
if ($user_angeltype_id === false)
|
if ($user_angeltype_id === false) {
|
||||||
engelsystem_error("Unable to create user angeltype.");
|
engelsystem_error("Unable to 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)));
|
||||||
|
@ -370,18 +397,19 @@ function user_angeltype_add_controller() {
|
||||||
|
|
||||||
if (in_array('admin_user_angeltypes', $privileges)) {
|
if (in_array('admin_user_angeltypes', $privileges)) {
|
||||||
$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("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 array(
|
return [
|
||||||
sprintf(_("Become a %s"), $angeltype['name']),
|
sprintf(_("Become a %s"), $angeltype['name']),
|
||||||
UserAngelType_join_view($user, $angeltype)
|
UserAngelType_join_view($user, $angeltype)
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -389,8 +417,9 @@ function user_angeltype_add_controller() {
|
||||||
* Route UserAngelType actions.
|
* Route UserAngelType actions.
|
||||||
*/
|
*/
|
||||||
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':
|
||||||
|
|
|
@ -7,21 +7,25 @@ function user_driver_license_required_hint() {
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
$angeltypes = User_angeltypes($user);
|
$angeltypes = User_angeltypes($user);
|
||||||
if ($angeltypes === false)
|
if ($angeltypes === false) {
|
||||||
engelsystem_error("Unable to load user angeltypes.");
|
engelsystem_error("Unable to load user angeltypes.");
|
||||||
|
}
|
||||||
$user_driver_license = UserDriverLicense($user['UID']);
|
$user_driver_license = UserDriverLicense($user['UID']);
|
||||||
if ($user_driver_license === false)
|
if ($user_driver_license === false) {
|
||||||
engelsystem_error("Unable to load user driver license.");
|
engelsystem_error("Unable to load user driver license.");
|
||||||
|
}
|
||||||
|
|
||||||
$driving_license_information_required = false;
|
$driving_license_information_required = false;
|
||||||
foreach ($angeltypes as $angeltype)
|
foreach ($angeltypes as $angeltype) {
|
||||||
if ($angeltype['requires_driver_license']) {
|
if ($angeltype['requires_driver_license']) {
|
||||||
$driving_license_information_required = true;
|
$driving_license_information_required = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($driving_license_information_required && $user_driver_license == null)
|
if ($driving_license_information_required && $user_driver_license == null) {
|
||||||
return info(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>'), true);
|
return info(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>'), true);
|
||||||
|
}
|
||||||
|
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
@ -32,11 +36,13 @@ 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(''));
|
||||||
|
}
|
||||||
|
|
||||||
if (! isset($_REQUEST['action']))
|
if (! isset($_REQUEST['action'])) {
|
||||||
$_REQUEST['action'] = 'edit';
|
$_REQUEST['action'] = 'edit';
|
||||||
|
}
|
||||||
|
|
||||||
switch ($_REQUEST['action']) {
|
switch ($_REQUEST['action']) {
|
||||||
default:
|
default:
|
||||||
|
@ -51,8 +57,9 @@ function user_driver_licenses_controller() {
|
||||||
* @param User $user
|
* @param User $user
|
||||||
*/
|
*/
|
||||||
function user_driver_license_edit_link($user = null) {
|
function user_driver_license_edit_link($user = null) {
|
||||||
if ($user == null)
|
if ($user == null) {
|
||||||
return page_link_to('user_driver_licenses');
|
return page_link_to('user_driver_licenses');
|
||||||
|
}
|
||||||
return page_link_to('user_driver_licenses') . '&user_id=' . $user['UID'];
|
return page_link_to('user_driver_licenses') . '&user_id=' . $user['UID'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,14 +71,17 @@ function user_driver_license_edit_controller() {
|
||||||
|
|
||||||
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 === false)
|
if ($user_source === false) {
|
||||||
engelsystem_error('Unable to load angeltype.');
|
engelsystem_error('Unable to load angeltype.');
|
||||||
if ($user_source == null)
|
}
|
||||||
|
if ($user_source == null) {
|
||||||
redirect(user_driver_license_edit_link());
|
redirect(user_driver_license_edit_link());
|
||||||
|
}
|
||||||
|
|
||||||
// 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());
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$user_source = $user;
|
$user_source = $user;
|
||||||
}
|
}
|
||||||
|
@ -85,8 +95,9 @@ function user_driver_license_edit_controller() {
|
||||||
$has_license_forklift = false;
|
$has_license_forklift = false;
|
||||||
|
|
||||||
$user_driver_license = UserDriverLicense($user_source['UID']);
|
$user_driver_license = UserDriverLicense($user_source['UID']);
|
||||||
if ($user_driver_license === false)
|
if ($user_driver_license === false) {
|
||||||
engelsystem_error('Unable to load user driver license.');
|
engelsystem_error('Unable to load user driver license.');
|
||||||
|
}
|
||||||
if ($user_driver_license != null) {
|
if ($user_driver_license != null) {
|
||||||
$wants_to_drive = true;
|
$wants_to_drive = true;
|
||||||
$has_car = $user_driver_license['has_car'];
|
$has_car = $user_driver_license['has_car'];
|
||||||
|
@ -115,19 +126,22 @@ function user_driver_license_edit_controller() {
|
||||||
if ($ok) {
|
if ($ok) {
|
||||||
if (! $wants_to_drive && $user_driver_license != null) {
|
if (! $wants_to_drive && $user_driver_license != null) {
|
||||||
$result = UserDriverLicenses_delete($user_source['UID']);
|
$result = UserDriverLicenses_delete($user_source['UID']);
|
||||||
if ($result === false)
|
if ($result === false) {
|
||||||
engelsystem_error("Unable to remove user driver license information");
|
engelsystem_error("Unable to remove user driver license information");
|
||||||
|
}
|
||||||
engelsystem_log("Driver license information removed.");
|
engelsystem_log("Driver license information removed.");
|
||||||
success(_("Your driver license information has been removed."));
|
success(_("Your driver license information has been removed."));
|
||||||
} else {
|
} else {
|
||||||
if ($wants_to_drive) {
|
if ($wants_to_drive) {
|
||||||
if ($user_driver_license == null)
|
if ($user_driver_license == null) {
|
||||||
$result = UserDriverLicenses_create($user_source['UID'], $has_car, $has_license_car, $has_license_3_5t_transporter, $has_license_7_5t_truck, $has_license_12_5t_truck, $has_license_forklift);
|
$result = UserDriverLicenses_create($user_source['UID'], $has_car, $has_license_car, $has_license_3_5t_transporter, $has_license_7_5t_truck, $has_license_12_5t_truck, $has_license_forklift);
|
||||||
else
|
} else {
|
||||||
$result = UserDriverLicenses_update($user_source['UID'], $has_car, $has_license_car, $has_license_3_5t_transporter, $has_license_7_5t_truck, $has_license_12_5t_truck, $has_license_forklift);
|
$result = UserDriverLicenses_update($user_source['UID'], $has_car, $has_license_car, $has_license_3_5t_transporter, $has_license_7_5t_truck, $has_license_12_5t_truck, $has_license_forklift);
|
||||||
|
}
|
||||||
|
|
||||||
if ($result === false)
|
if ($result === false) {
|
||||||
engelsystem_error("Unable to save user driver license information.");
|
engelsystem_error("Unable to save user driver license information.");
|
||||||
|
}
|
||||||
engelsystem_log("Driver license information updated.");
|
engelsystem_log("Driver license information updated.");
|
||||||
}
|
}
|
||||||
success(_("Your driver license information has been saved."));
|
success(_("Your driver license information has been saved."));
|
||||||
|
|
|
@ -6,11 +6,13 @@
|
||||||
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:
|
||||||
|
@ -35,11 +37,13 @@ function user_delete_controller() {
|
||||||
|
|
||||||
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']) {
|
||||||
|
@ -57,8 +61,9 @@ function user_delete_controller() {
|
||||||
|
|
||||||
if ($ok) {
|
if ($ok) {
|
||||||
$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."));
|
||||||
|
@ -68,10 +73,10 @@ function user_delete_controller() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return array(
|
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() {
|
||||||
|
@ -95,18 +100,20 @@ function user_edit_vouchers_controller() {
|
||||||
|
|
||||||
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'])) {
|
||||||
$ok = true;
|
$ok = 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 {
|
||||||
$ok = false;
|
$ok = false;
|
||||||
error(_("Please enter a valid number of vouchers."));
|
error(_("Please enter a valid number of vouchers."));
|
||||||
}
|
}
|
||||||
|
@ -115,8 +122,9 @@ function user_edit_vouchers_controller() {
|
||||||
$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']));
|
||||||
|
@ -125,10 +133,10 @@ function user_edit_vouchers_controller() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return array(
|
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() {
|
||||||
|
@ -136,14 +144,16 @@ function user_controller() {
|
||||||
|
|
||||||
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 === false)
|
if ($user_source === false) {
|
||||||
engelsystem_error("Unable to load user.");
|
engelsystem_error("Unable to load user.");
|
||||||
|
}
|
||||||
if ($user_source == null) {
|
if ($user_source == null) {
|
||||||
error(_("User not found."));
|
error(_("User not found."));
|
||||||
redirect('?');
|
redirect('?');
|
||||||
}
|
}
|
||||||
} else
|
} else {
|
||||||
$user_source = $user;
|
$user_source = $user;
|
||||||
|
}
|
||||||
|
|
||||||
$shifts = Shifts_by_user($user_source);
|
$shifts = Shifts_by_user($user_source);
|
||||||
foreach ($shifts as &$shift) {
|
foreach ($shifts as &$shift) {
|
||||||
|
@ -159,13 +169,14 @@ function user_controller() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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 array(
|
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'])
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -174,24 +185,28 @@ 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 array(
|
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())
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -201,8 +216,9 @@ function users_list_controller() {
|
||||||
function user_password_recovery_controller() {
|
function user_password_recovery_controller() {
|
||||||
if (isset($_REQUEST['token'])) {
|
if (isset($_REQUEST['token'])) {
|
||||||
$user_source = User_by_password_recovery_token($_REQUEST['token']);
|
$user_source = User_by_password_recovery_token($_REQUEST['token']);
|
||||||
if ($user_source === false)
|
if ($user_source === false) {
|
||||||
engelsystem_error("Unable to load user.");
|
engelsystem_error("Unable to load user.");
|
||||||
|
}
|
||||||
if ($user_source == null) {
|
if ($user_source == null) {
|
||||||
error(_("Token is not correct."));
|
error(_("Token is not correct."));
|
||||||
redirect(page_link_to('login'));
|
redirect(page_link_to('login'));
|
||||||
|
@ -223,8 +239,9 @@ function user_password_recovery_controller() {
|
||||||
|
|
||||||
if ($ok) {
|
if ($ok) {
|
||||||
$result = set_password($user_source['UID'], $_REQUEST['password']);
|
$result = set_password($user_source['UID'], $_REQUEST['password']);
|
||||||
if ($result === false)
|
if ($result === false) {
|
||||||
engelsystem_error(_("Password could not be updated."));
|
engelsystem_error(_("Password could not be updated."));
|
||||||
|
}
|
||||||
|
|
||||||
success(_("Password saved."));
|
success(_("Password saved."));
|
||||||
redirect(page_link_to('login'));
|
redirect(page_link_to('login'));
|
||||||
|
@ -240,8 +257,9 @@ function user_password_recovery_controller() {
|
||||||
$email = strip_request_item('email');
|
$email = strip_request_item('email');
|
||||||
if (check_email($email)) {
|
if (check_email($email)) {
|
||||||
$user_source = User_by_email($email);
|
$user_source = User_by_email($email);
|
||||||
if ($user_source === false)
|
if ($user_source === false) {
|
||||||
engelsystem_error("Unable to load user.");
|
engelsystem_error("Unable to load user.");
|
||||||
|
}
|
||||||
if ($user_source == null) {
|
if ($user_source == null) {
|
||||||
$ok = false;
|
$ok = false;
|
||||||
error(_("E-mail address is not correct."));
|
error(_("E-mail address is not correct."));
|
||||||
|
@ -257,11 +275,13 @@ function user_password_recovery_controller() {
|
||||||
|
|
||||||
if ($ok) {
|
if ($ok) {
|
||||||
$token = User_generate_password_recovery_token($user_source);
|
$token = User_generate_password_recovery_token($user_source);
|
||||||
if ($token === false)
|
if ($token === false) {
|
||||||
engelsystem_error("Unable to generate password recovery token.");
|
engelsystem_error("Unable to generate password recovery token.");
|
||||||
|
}
|
||||||
$result = 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));
|
$result = 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));
|
||||||
if ($result === false)
|
if ($result === false) {
|
||||||
engelsystem_error("Unable to send password recovery email.");
|
engelsystem_error("Unable to send password recovery email.");
|
||||||
|
}
|
||||||
|
|
||||||
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'));
|
||||||
|
|
Loading…
Reference in New Issue