database: updated checks for selectOne
This commit is contained in:
parent
0e8cc2f0a7
commit
fe58e4f422
|
@ -154,7 +154,7 @@ function angeltype_edit_controller()
|
||||||
$angeltype['contact_email'] = strip_request_item('contact_email', $angeltype['contact_email']);
|
$angeltype['contact_email'] = strip_request_item('contact_email', $angeltype['contact_email']);
|
||||||
|
|
||||||
if ($valid) {
|
if ($valid) {
|
||||||
if ($angeltype['id'] != null) {
|
if (!empty($angeltype['id'])) {
|
||||||
AngelType_update($angeltype);
|
AngelType_update($angeltype);
|
||||||
} else {
|
} else {
|
||||||
$angeltype = AngelType_create($angeltype);
|
$angeltype = AngelType_create($angeltype);
|
||||||
|
@ -308,7 +308,7 @@ function angeltypes_list_controller()
|
||||||
}
|
}
|
||||||
|
|
||||||
$angeltype['membership'] = AngelType_render_membership($angeltype);
|
$angeltype['membership'] = AngelType_render_membership($angeltype);
|
||||||
if ($angeltype['user_angeltype_id'] != null) {
|
if (!empty($angeltype['user_angeltype_id'])) {
|
||||||
$actions[] = button(
|
$actions[] = button(
|
||||||
page_link_to('user_angeltypes',
|
page_link_to('user_angeltypes',
|
||||||
['action' => 'delete', 'user_angeltype_id' => $angeltype['user_angeltype_id']]
|
['action' => 'delete', 'user_angeltype_id' => $angeltype['user_angeltype_id']]
|
||||||
|
@ -355,7 +355,7 @@ function load_angeltype()
|
||||||
}
|
}
|
||||||
|
|
||||||
$angeltype = AngelType($request->input('angeltype_id'));
|
$angeltype = AngelType($request->input('angeltype_id'));
|
||||||
if ($angeltype == null) {
|
if (empty($angeltype)) {
|
||||||
error(_('Angeltype doesn\'t exist . '));
|
error(_('Angeltype doesn\'t exist . '));
|
||||||
redirect(page_link_to('angeltypes'));
|
redirect(page_link_to('angeltypes'));
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ function event_config_edit_controller()
|
||||||
$teardown_end_date = null;
|
$teardown_end_date = null;
|
||||||
|
|
||||||
$event_config = EventConfig();
|
$event_config = EventConfig();
|
||||||
if ($event_config != null) {
|
if (empty($event_config)) {
|
||||||
$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'];
|
||||||
$event_start_date = $event_config['event_start_date'];
|
$event_start_date = $event_config['event_start_date'];
|
||||||
|
@ -70,22 +70,22 @@ function event_config_edit_controller()
|
||||||
$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 (!is_null($buildup_start_date) && !is_null($event_start_date) && $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 (!is_null($event_start_date) && !is_null($event_end_date) && $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 (!is_null($event_end_date) && !is_null($teardown_end_date) && $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 (!is_null($buildup_start_date) && !is_null($teardown_end_date) && $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.'));
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,7 +110,7 @@ function load_room()
|
||||||
}
|
}
|
||||||
|
|
||||||
$room = Room(request()->input('room_id'));
|
$room = Room(request()->input('room_id'));
|
||||||
if ($room == null) {
|
if (empty($room)) {
|
||||||
redirect(page_link_to());
|
redirect(page_link_to());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ function shift_entries_controller()
|
||||||
}
|
}
|
||||||
|
|
||||||
$action = strip_request_item('action');
|
$action = strip_request_item('action');
|
||||||
if ($action == null) {
|
if (empty($action)) {
|
||||||
redirect(user_link($user));
|
redirect(user_link($user));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ function shift_entry_create_controller()
|
||||||
}
|
}
|
||||||
|
|
||||||
$shift = Shift($request->input('shift_id'));
|
$shift = Shift($request->input('shift_id'));
|
||||||
if ($shift == null) {
|
if (empty($shift)) {
|
||||||
redirect(user_link($user));
|
redirect(user_link($user));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ function shift_entry_create_controller()
|
||||||
return shift_entry_create_controller_admin($shift, $angeltype);
|
return shift_entry_create_controller_admin($shift, $angeltype);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($angeltype == null) {
|
if (empty($angeltype)) {
|
||||||
redirect(user_link($user));
|
redirect(user_link($user));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ function shift_entry_create_controller_admin($shift, $angeltype)
|
||||||
if ($request->has('user_id')) {
|
if ($request->has('user_id')) {
|
||||||
$signup_user = User($request->input('user_id'));
|
$signup_user = User($request->input('user_id'));
|
||||||
}
|
}
|
||||||
if ($signup_user == null) {
|
if (empty($signup_user)) {
|
||||||
redirect(shift_link($shift));
|
redirect(shift_link($shift));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ function shift_entry_create_controller_admin($shift, $angeltype)
|
||||||
if ($request->has('angeltype_id')) {
|
if ($request->has('angeltype_id')) {
|
||||||
$angeltype = AngelType($request->input('angeltype_id'));
|
$angeltype = AngelType($request->input('angeltype_id'));
|
||||||
}
|
}
|
||||||
if ($angeltype == null) {
|
if (empty($angeltype)) {
|
||||||
if (count($angeltypes) == 0) {
|
if (count($angeltypes) == 0) {
|
||||||
redirect(shift_link($shift));
|
redirect(shift_link($shift));
|
||||||
}
|
}
|
||||||
|
@ -321,7 +321,7 @@ function shift_entry_load()
|
||||||
redirect(page_link_to('user_shifts'));
|
redirect(page_link_to('user_shifts'));
|
||||||
}
|
}
|
||||||
$shiftEntry = ShiftEntry($request->input('shift_entry_id'));
|
$shiftEntry = ShiftEntry($request->input('shift_entry_id'));
|
||||||
if ($shiftEntry == null) {
|
if (empty($shiftEntry)) {
|
||||||
error(_('Shift entry not found.'));
|
error(_('Shift entry not found.'));
|
||||||
redirect(page_link_to('user_shifts'));
|
redirect(page_link_to('user_shifts'));
|
||||||
}
|
}
|
||||||
|
|
|
@ -217,7 +217,7 @@ function shift_delete_controller()
|
||||||
$shift_id = $request->input('delete_shift');
|
$shift_id = $request->input('delete_shift');
|
||||||
|
|
||||||
$shift = Shift($shift_id);
|
$shift = Shift($shift_id);
|
||||||
if ($shift == null) {
|
if (empty($shift)) {
|
||||||
redirect(page_link_to('user_shifts'));
|
redirect(page_link_to('user_shifts'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -264,7 +264,7 @@ function shift_controller()
|
||||||
}
|
}
|
||||||
|
|
||||||
$shift = Shift($request->input('shift_id'));
|
$shift = Shift($request->input('shift_id'));
|
||||||
if ($shift == null) {
|
if (empty($shift)) {
|
||||||
error(_('Shift could not be found.'));
|
error(_('Shift could not be found.'));
|
||||||
redirect(page_link_to('user_shifts'));
|
redirect(page_link_to('user_shifts'));
|
||||||
}
|
}
|
||||||
|
@ -288,7 +288,7 @@ function shift_controller()
|
||||||
$needed_angeltype,
|
$needed_angeltype,
|
||||||
$shift_entries
|
$shift_entries
|
||||||
);
|
);
|
||||||
if ($shift_signup_state == null) {
|
if (empty($shift_signup_state)) {
|
||||||
$shift_signup_state = $angeltype_signup_state;
|
$shift_signup_state = $angeltype_signup_state;
|
||||||
} else {
|
} else {
|
||||||
$shift_signup_state->combineWith($angeltype_signup_state);
|
$shift_signup_state->combineWith($angeltype_signup_state);
|
||||||
|
@ -387,7 +387,7 @@ function shifts_json_export_controller()
|
||||||
$key = $request->input('key');
|
$key = $request->input('key');
|
||||||
|
|
||||||
$user = User_by_api_key($key);
|
$user = User_by_api_key($key);
|
||||||
if ($user == null) {
|
if (empty($user)) {
|
||||||
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']))) {
|
||||||
|
|
|
@ -22,8 +22,7 @@ function shifttype_delete_controller()
|
||||||
}
|
}
|
||||||
|
|
||||||
$shifttype = ShiftType($request->input('shifttype_id'));
|
$shifttype = ShiftType($request->input('shifttype_id'));
|
||||||
|
if (empty($shifttype)) {
|
||||||
if ($shifttype == null) {
|
|
||||||
redirect(page_link_to('shifttypes'));
|
redirect(page_link_to('shifttypes'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,7 +57,7 @@ function shifttype_edit_controller()
|
||||||
|
|
||||||
if ($request->has('shifttype_id')) {
|
if ($request->has('shifttype_id')) {
|
||||||
$shifttype = ShiftType($request->input('shifttype_id'));
|
$shifttype = ShiftType($request->input('shifttype_id'));
|
||||||
if ($shifttype == null) {
|
if (empty($shifttype)) {
|
||||||
error(_('Shifttype not found.'));
|
error(_('Shifttype not found.'));
|
||||||
redirect(page_link_to('shifttypes'));
|
redirect(page_link_to('shifttypes'));
|
||||||
}
|
}
|
||||||
|
@ -120,12 +119,12 @@ function shifttype_controller()
|
||||||
redirect(page_link_to('shifttypes'));
|
redirect(page_link_to('shifttypes'));
|
||||||
}
|
}
|
||||||
$shifttype = ShiftType($request->input('shifttype_id'));
|
$shifttype = ShiftType($request->input('shifttype_id'));
|
||||||
if ($shifttype == null) {
|
if (empty($shifttype)) {
|
||||||
redirect(page_link_to('shifttypes'));
|
redirect(page_link_to('shifttypes'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$angeltype = null;
|
$angeltype = [];
|
||||||
if ($shifttype['angeltype_id'] != null) {
|
if (!empty($shifttype['angeltype_id'])) {
|
||||||
$angeltype = AngelType($shifttype['angeltype_id']);
|
$angeltype = AngelType($shifttype['angeltype_id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ function user_angeltypes_delete_all_controller()
|
||||||
}
|
}
|
||||||
|
|
||||||
$angeltype = AngelType($request->input('angeltype_id'));
|
$angeltype = AngelType($request->input('angeltype_id'));
|
||||||
if ($angeltype == null) {
|
if (empty($angeltype)) {
|
||||||
error(_('Angeltype doesn\'t exist.'));
|
error(_('Angeltype doesn\'t exist.'));
|
||||||
redirect(page_link_to('angeltypes'));
|
redirect(page_link_to('angeltypes'));
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,7 @@ function user_angeltypes_confirm_all_controller()
|
||||||
}
|
}
|
||||||
|
|
||||||
$angeltype = AngelType($request->input('angeltype_id'));
|
$angeltype = AngelType($request->input('angeltype_id'));
|
||||||
if ($angeltype == null) {
|
if (empty($angeltype)) {
|
||||||
error(_('Angeltype doesn\'t exist.'));
|
error(_('Angeltype doesn\'t exist.'));
|
||||||
redirect(page_link_to('angeltypes'));
|
redirect(page_link_to('angeltypes'));
|
||||||
}
|
}
|
||||||
|
@ -125,13 +125,13 @@ function user_angeltype_confirm_controller()
|
||||||
}
|
}
|
||||||
|
|
||||||
$user_angeltype = UserAngelType($request->input('user_angeltype_id'));
|
$user_angeltype = UserAngelType($request->input('user_angeltype_id'));
|
||||||
if ($user_angeltype == null) {
|
if (empty($user_angeltype)) {
|
||||||
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 (empty($angeltype)) {
|
||||||
error(_('Angeltype doesn\'t exist.'));
|
error(_('Angeltype doesn\'t exist.'));
|
||||||
redirect(page_link_to('angeltypes'));
|
redirect(page_link_to('angeltypes'));
|
||||||
}
|
}
|
||||||
|
@ -142,7 +142,7 @@ function user_angeltype_confirm_controller()
|
||||||
}
|
}
|
||||||
|
|
||||||
$user_source = User($user_angeltype['user_id']);
|
$user_source = User($user_angeltype['user_id']);
|
||||||
if ($user_source == null) {
|
if (empty($user_source)) {
|
||||||
error(_('User doesn\'t exist.'));
|
error(_('User doesn\'t exist.'));
|
||||||
redirect(page_link_to('angeltypes'));
|
redirect(page_link_to('angeltypes'));
|
||||||
}
|
}
|
||||||
|
@ -185,19 +185,19 @@ function user_angeltype_delete_controller()
|
||||||
}
|
}
|
||||||
|
|
||||||
$user_angeltype = UserAngelType($request->input('user_angeltype_id'));
|
$user_angeltype = UserAngelType($request->input('user_angeltype_id'));
|
||||||
if ($user_angeltype == null) {
|
if (empty($user_angeltype)) {
|
||||||
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 (empty($angeltype)) {
|
||||||
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 (empty($user_source)) {
|
||||||
error(_('User doesn\'t exist.'));
|
error(_('User doesn\'t exist.'));
|
||||||
redirect(page_link_to('angeltypes'));
|
redirect(page_link_to('angeltypes'));
|
||||||
}
|
}
|
||||||
|
@ -252,19 +252,19 @@ function user_angeltype_update_controller()
|
||||||
}
|
}
|
||||||
|
|
||||||
$user_angeltype = UserAngelType($request->input('user_angeltype_id'));
|
$user_angeltype = UserAngelType($request->input('user_angeltype_id'));
|
||||||
if ($user_angeltype == null) {
|
if (empty($user_angeltype)) {
|
||||||
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 (empty($angeltype)) {
|
||||||
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 (empty($user_source)) {
|
||||||
error(_('User doesn\'t exist.'));
|
error(_('User doesn\'t exist.'));
|
||||||
redirect(page_link_to('angeltypes'));
|
redirect(page_link_to('angeltypes'));
|
||||||
}
|
}
|
||||||
|
@ -359,7 +359,7 @@ 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 (!empty($user_angeltype)) {
|
||||||
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'));
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ function user_driver_license_required_hint()
|
||||||
$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 (!empty($user_driver_license)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ function user_driver_licenses_controller()
|
||||||
*/
|
*/
|
||||||
function user_driver_license_edit_link($user = null)
|
function user_driver_license_edit_link($user = null)
|
||||||
{
|
{
|
||||||
if ($user == null) {
|
if (empty($user)) {
|
||||||
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']]);
|
||||||
|
@ -79,7 +79,7 @@ function user_driver_license_load_user()
|
||||||
|
|
||||||
if ($request->has('user_id')) {
|
if ($request->has('user_id')) {
|
||||||
$user_source = User($request->input('user_id'));
|
$user_source = User($request->input('user_id'));
|
||||||
if ($user_source == null) {
|
if (empty($user_source)) {
|
||||||
redirect(user_driver_license_edit_link());
|
redirect(user_driver_license_edit_link());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,7 @@ function user_driver_license_edit_controller()
|
||||||
}
|
}
|
||||||
|
|
||||||
$user_driver_license = UserDriverLicense($user_source['UID']);
|
$user_driver_license = UserDriverLicense($user_source['UID']);
|
||||||
if ($user_driver_license == null) {
|
if (empty($user_driver_license)) {
|
||||||
$wants_to_drive = false;
|
$wants_to_drive = false;
|
||||||
$user_driver_license = UserDriverLicense_new();
|
$user_driver_license = UserDriverLicense_new();
|
||||||
} else {
|
} else {
|
||||||
|
@ -122,7 +122,7 @@ function user_driver_license_edit_controller()
|
||||||
$user_driver_license['has_license_forklift'] = $request->has('has_license_forklift');
|
$user_driver_license['has_license_forklift'] = $request->has('has_license_forklift');
|
||||||
|
|
||||||
if (UserDriverLicense_valid($user_driver_license)) {
|
if (UserDriverLicense_valid($user_driver_license)) {
|
||||||
if ($user_driver_license['user_id'] == null) {
|
if (empty($user_driver_license['user_id'])) {
|
||||||
$user_driver_license = UserDriverLicenses_create($user_driver_license, $user_source);
|
$user_driver_license = UserDriverLicenses_create($user_driver_license, $user_source);
|
||||||
} else {
|
} else {
|
||||||
UserDriverLicenses_update($user_driver_license);
|
UserDriverLicenses_update($user_driver_license);
|
||||||
|
@ -133,7 +133,7 @@ function user_driver_license_edit_controller()
|
||||||
} else {
|
} else {
|
||||||
error(_('Please select at least one driving license.'));
|
error(_('Please select at least one driving license.'));
|
||||||
}
|
}
|
||||||
} elseif ($user_driver_license['user_id'] != null) {
|
} elseif (!empty($user_driver_license['user_id'])) {
|
||||||
UserDriverLicenses_delete($user_source['UID']);
|
UserDriverLicenses_delete($user_source['UID']);
|
||||||
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.'));
|
||||||
|
|
|
@ -6,21 +6,21 @@
|
||||||
function user_worklog_delete_controller()
|
function user_worklog_delete_controller()
|
||||||
{
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
$request = request();
|
$request = request();
|
||||||
$userWorkLog = UserWorkLog($request->input('user_worklog_id'));
|
$userWorkLog = UserWorkLog($request->input('user_worklog_id'));
|
||||||
if (empty($userWorkLog)) {
|
if (empty($userWorkLog)) {
|
||||||
redirect(user_link($user));
|
redirect(user_link($user));
|
||||||
}
|
}
|
||||||
$user_source = User($userWorkLog['user_id']);
|
$user_source = User($userWorkLog['user_id']);
|
||||||
|
|
||||||
if ($request->has('confirmed')) {
|
if ($request->has('confirmed')) {
|
||||||
UserWorkLog_delete($userWorkLog);
|
UserWorkLog_delete($userWorkLog);
|
||||||
|
|
||||||
success(_('Work log entry deleted.'));
|
success(_('Work log entry deleted.'));
|
||||||
redirect(user_link($user_source));
|
redirect(user_link($user_source));
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
UserWorkLog_delete_title(),
|
UserWorkLog_delete_title(),
|
||||||
UserWorkLog_delete_view($user_source, $userWorkLog)
|
UserWorkLog_delete_view($user_source, $userWorkLog)
|
||||||
|
@ -33,25 +33,25 @@ function user_worklog_delete_controller()
|
||||||
function user_worklog_edit_controller()
|
function user_worklog_edit_controller()
|
||||||
{
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
$request = request();
|
$request = request();
|
||||||
$userWorkLog = UserWorkLog($request->input('user_worklog_id'));
|
$userWorkLog = UserWorkLog($request->input('user_worklog_id'));
|
||||||
if (empty($userWorkLog)) {
|
if (empty($userWorkLog)) {
|
||||||
redirect(user_link($user));
|
redirect(user_link($user));
|
||||||
}
|
}
|
||||||
$user_source = User($userWorkLog['user_id']);
|
$user_source = User($userWorkLog['user_id']);
|
||||||
|
|
||||||
if ($request->has('submit')) {
|
if ($request->has('submit')) {
|
||||||
list ($valid, $userWorkLog) = user_worklog_from_request($userWorkLog);
|
list ($valid, $userWorkLog) = user_worklog_from_request($userWorkLog);
|
||||||
|
|
||||||
if ($valid) {
|
if ($valid) {
|
||||||
UserWorkLog_update($userWorkLog);
|
UserWorkLog_update($userWorkLog);
|
||||||
|
|
||||||
success(_('Work log entry updated.'));
|
success(_('Work log entry updated.'));
|
||||||
redirect(user_link($user_source));
|
redirect(user_link($user_source));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
UserWorkLog_edit_title(),
|
UserWorkLog_edit_title(),
|
||||||
UserWorkLog_edit_view($user_source, $userWorkLog)
|
UserWorkLog_edit_view($user_source, $userWorkLog)
|
||||||
|
@ -60,33 +60,33 @@ function user_worklog_edit_controller()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param UserWorkLog $userWorkLog
|
* @param UserWorkLog $userWorkLog
|
||||||
* @return [bool $valid, UserWorkLog $userWorkLog]
|
* @return [bool $valid, UserWorkLog $userWorkLog]
|
||||||
*/
|
*/
|
||||||
function user_worklog_from_request($userWorkLog)
|
function user_worklog_from_request($userWorkLog)
|
||||||
{
|
{
|
||||||
$request = request();
|
$request = request();
|
||||||
|
|
||||||
$valid = true;
|
$valid = true;
|
||||||
|
|
||||||
$userWorkLog['work_timestamp'] = parse_date('Y-m-d H:i', $request->input('work_timestamp') . ' 00:00');
|
$userWorkLog['work_timestamp'] = parse_date('Y-m-d H:i', $request->input('work_timestamp') . ' 00:00');
|
||||||
if ($userWorkLog['work_timestamp'] == null) {
|
if (is_null($userWorkLog['work_timestamp'])) {
|
||||||
$valid = false;
|
$valid = false;
|
||||||
error(_('Please enter work date.'));
|
error(_('Please enter work date.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$userWorkLog['work_hours'] = $request->input('work_hours');
|
$userWorkLog['work_hours'] = $request->input('work_hours');
|
||||||
if (! preg_match("/[0-9]+(\.[0-9]+)?/", $userWorkLog['work_hours'])) {
|
if (! preg_match("/[0-9]+(\.[0-9]+)?/", $userWorkLog['work_hours'])) {
|
||||||
$valid = false;
|
$valid = false;
|
||||||
error(_('Please enter work hours in format ##[.##].'));
|
error(_('Please enter work hours in format ##[.##].'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$userWorkLog['comment'] = $request->input('comment');
|
$userWorkLog['comment'] = $request->input('comment');
|
||||||
if (empty($userWorkLog['comment'])) {
|
if (empty($userWorkLog['comment'])) {
|
||||||
$valid = false;
|
$valid = false;
|
||||||
error(_('Please enter a comment.'));
|
error(_('Please enter a comment.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
$valid,
|
$valid,
|
||||||
$userWorkLog
|
$userWorkLog
|
||||||
|
@ -99,26 +99,26 @@ function user_worklog_from_request($userWorkLog)
|
||||||
function user_worklog_add_controller()
|
function user_worklog_add_controller()
|
||||||
{
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
$request = request();
|
$request = request();
|
||||||
$user_source = User($request->input('user_id'));
|
$user_source = User($request->input('user_id'));
|
||||||
if (empty($user_source)) {
|
if (empty($user_source)) {
|
||||||
redirect(user_link($user));
|
redirect(user_link($user));
|
||||||
}
|
}
|
||||||
|
|
||||||
$userWorkLog = UserWorkLog_new($user_source);
|
$userWorkLog = UserWorkLog_new($user_source);
|
||||||
|
|
||||||
if ($request->has('submit')) {
|
if ($request->has('submit')) {
|
||||||
list ($valid, $userWorkLog) = user_worklog_from_request($userWorkLog);
|
list ($valid, $userWorkLog) = user_worklog_from_request($userWorkLog);
|
||||||
|
|
||||||
if ($valid) {
|
if ($valid) {
|
||||||
UserWorkLog_create($userWorkLog);
|
UserWorkLog_create($userWorkLog);
|
||||||
|
|
||||||
success(_('Work log entry created.'));
|
success(_('Work log entry created.'));
|
||||||
redirect(user_link($user_source));
|
redirect(user_link($user_source));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
UserWorkLog_add_title(),
|
UserWorkLog_add_title(),
|
||||||
UserWorkLog_add_view($user_source, $userWorkLog)
|
UserWorkLog_add_view($user_source, $userWorkLog)
|
||||||
|
@ -128,7 +128,7 @@ function user_worklog_add_controller()
|
||||||
/**
|
/**
|
||||||
* Link to work log entry add for given user.
|
* Link to work log entry add for given user.
|
||||||
*
|
*
|
||||||
* @param User $user
|
* @param User $user
|
||||||
*/
|
*/
|
||||||
function user_worklog_add_link($user)
|
function user_worklog_add_link($user)
|
||||||
{
|
{
|
||||||
|
@ -141,7 +141,7 @@ function user_worklog_add_link($user)
|
||||||
/**
|
/**
|
||||||
* Link to work log entry edit.
|
* Link to work log entry edit.
|
||||||
*
|
*
|
||||||
* @param UserWorkLog $userWorkLog
|
* @param UserWorkLog $userWorkLog
|
||||||
*/
|
*/
|
||||||
function user_worklog_edit_link($userWorkLog)
|
function user_worklog_edit_link($userWorkLog)
|
||||||
{
|
{
|
||||||
|
@ -154,8 +154,8 @@ function user_worklog_edit_link($userWorkLog)
|
||||||
/**
|
/**
|
||||||
* Link to work log entry delete.
|
* Link to work log entry delete.
|
||||||
*
|
*
|
||||||
* @param UserWorkLog $userWorkLog
|
* @param UserWorkLog $userWorkLog
|
||||||
* @param array[] $parameters
|
* @param array[] $parameters
|
||||||
*/
|
*/
|
||||||
function user_worklog_delete_link($userWorkLog, $parameters = [])
|
function user_worklog_delete_link($userWorkLog, $parameters = [])
|
||||||
{
|
{
|
||||||
|
@ -171,17 +171,17 @@ function user_worklog_delete_link($userWorkLog, $parameters = [])
|
||||||
function user_worklogs_controller()
|
function user_worklogs_controller()
|
||||||
{
|
{
|
||||||
global $user, $privileges;
|
global $user, $privileges;
|
||||||
|
|
||||||
if (! in_array('admin_user_worklog', $privileges)) {
|
if (! in_array('admin_user_worklog', $privileges)) {
|
||||||
redirect(user_link($user));
|
redirect(user_link($user));
|
||||||
}
|
}
|
||||||
|
|
||||||
$request = request();
|
$request = request();
|
||||||
$action = $request->input('action');
|
$action = $request->input('action');
|
||||||
if (! $request->has('action')) {
|
if (! $request->has('action')) {
|
||||||
redirect(user_link($user));
|
redirect(user_link($user));
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ($action) {
|
switch ($action) {
|
||||||
case 'add':
|
case 'add':
|
||||||
return user_worklog_add_controller();
|
return user_worklog_add_controller();
|
||||||
|
@ -191,5 +191,3 @@ function user_worklogs_controller()
|
||||||
return user_worklog_delete_controller();
|
return user_worklog_delete_controller();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
|
@ -190,7 +190,7 @@ function user_controller()
|
||||||
$user_source = $user;
|
$user_source = $user;
|
||||||
if ($request->has('user_id')) {
|
if ($request->has('user_id')) {
|
||||||
$user_source = User($request->input('user_id'));
|
$user_source = User($request->input('user_id'));
|
||||||
if ($user_source == null) {
|
if (empty($user_source)) {
|
||||||
error(_('User not found.'));
|
error(_('User not found.'));
|
||||||
redirect(page_link_to('/'));
|
redirect(page_link_to('/'));
|
||||||
}
|
}
|
||||||
|
@ -220,12 +220,12 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($user_source['force_active']) {
|
if ($user_source['force_active']) {
|
||||||
$tshirt_score = _('Enough');
|
$tshirt_score = _('Enough');
|
||||||
} else {
|
} else {
|
||||||
$tshirt_score = sprintf('%.2f', User_tshirt_score($user_source)) . ' h';
|
$tshirt_score = sprintf('%.2f', User_tshirt_score($user_source)) . ' h';
|
||||||
|
@ -297,7 +297,7 @@ function user_password_recovery_set_new_controller()
|
||||||
{
|
{
|
||||||
$request = request();
|
$request = request();
|
||||||
$user_source = User_by_password_recovery_token($request->input('token'));
|
$user_source = User_by_password_recovery_token($request->input('token'));
|
||||||
if ($user_source == null) {
|
if (empty($user_source)) {
|
||||||
error(_('Token is not correct.'));
|
error(_('Token is not correct.'));
|
||||||
redirect(page_link_to('login'));
|
redirect(page_link_to('login'));
|
||||||
}
|
}
|
||||||
|
@ -343,7 +343,7 @@ function user_password_recovery_start_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 == null) {
|
if (empty($user_source)) {
|
||||||
$valid = false;
|
$valid = false;
|
||||||
error(_('E-mail address is not correct.'));
|
error(_('E-mail address is not correct.'));
|
||||||
}
|
}
|
||||||
|
@ -412,8 +412,7 @@ function load_user()
|
||||||
}
|
}
|
||||||
|
|
||||||
$user = User($request->input('user_id'));
|
$user = User($request->input('user_id'));
|
||||||
|
if (empty($user)) {
|
||||||
if ($user == null) {
|
|
||||||
error(_('User doesn\'t exist.'));
|
error(_('User doesn\'t exist.'));
|
||||||
redirect(page_link_to());
|
redirect(page_link_to());
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ function gettext_init()
|
||||||
*/
|
*/
|
||||||
function gettext_locale($locale = null)
|
function gettext_locale($locale = null)
|
||||||
{
|
{
|
||||||
if ($locale == null) {
|
if (empty($locale)) {
|
||||||
$locale = session()->get('locale');
|
$locale = session()->get('locale');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -159,7 +159,7 @@ function AngelType_validate_name($name, $angeltype)
|
||||||
if ($name == '') {
|
if ($name == '') {
|
||||||
return new ValidationResult(false, '');
|
return new ValidationResult(false, '');
|
||||||
}
|
}
|
||||||
if ($angeltype != null && isset($angeltype['id'])) {
|
if (!empty($angeltype) && isset($angeltype['id'])) {
|
||||||
$valid = (count(DB::select('
|
$valid = (count(DB::select('
|
||||||
SELECT `id`
|
SELECT `id`
|
||||||
FROM `AngelTypes`
|
FROM `AngelTypes`
|
||||||
|
@ -225,7 +225,7 @@ function AngelType_ids()
|
||||||
* Returns angelType by id.
|
* Returns angelType by id.
|
||||||
*
|
*
|
||||||
* @param int $angeltype_id angelType ID
|
* @param int $angeltype_id angelType ID
|
||||||
* @return array|null
|
* @return array
|
||||||
*/
|
*/
|
||||||
function AngelType($angeltype_id)
|
function AngelType($angeltype_id)
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,7 +5,7 @@ use Engelsystem\Database\DB;
|
||||||
/**
|
/**
|
||||||
* Get event config.
|
* Get event config.
|
||||||
*
|
*
|
||||||
* @return array|null
|
* @return array
|
||||||
*/
|
*/
|
||||||
function EventConfig()
|
function EventConfig()
|
||||||
{
|
{
|
||||||
|
@ -31,7 +31,8 @@ function EventConfig_update(
|
||||||
$teardown_end_date,
|
$teardown_end_date,
|
||||||
$event_welcome_msg
|
$event_welcome_msg
|
||||||
) {
|
) {
|
||||||
if (EventConfig() == null) {
|
$eventConfig = EventConfig();
|
||||||
|
if (empty($eventConfig)) {
|
||||||
return DB::insert('
|
return DB::insert('
|
||||||
INSERT INTO `EventConfig` (
|
INSERT INTO `EventConfig` (
|
||||||
`event_name`,
|
`event_name`,
|
||||||
|
|
|
@ -16,7 +16,7 @@ function Message_ids()
|
||||||
* Returns message by id.
|
* Returns message by id.
|
||||||
*
|
*
|
||||||
* @param int $message_id message ID
|
* @param int $message_id message ID
|
||||||
* @return array|null
|
* @return array
|
||||||
*/
|
*/
|
||||||
function Message($message_id)
|
function Message($message_id)
|
||||||
{
|
{
|
||||||
|
|
|
@ -148,7 +148,7 @@ function Room_update($room_id, $name, $from_frab, $map_url, $description)
|
||||||
* Returns room by id.
|
* Returns room by id.
|
||||||
*
|
*
|
||||||
* @param int $room_id RID
|
* @param int $room_id RID
|
||||||
* @return array|false
|
* @return array
|
||||||
*/
|
*/
|
||||||
function Room($room_id)
|
function Room($room_id)
|
||||||
{
|
{
|
||||||
|
|
|
@ -134,7 +134,7 @@ function ShiftEntry_update($shift_entry)
|
||||||
* Get a shift entry.
|
* Get a shift entry.
|
||||||
*
|
*
|
||||||
* @param int $shift_entry_id
|
* @param int $shift_entry_id
|
||||||
* @return array|null
|
* @return array
|
||||||
*/
|
*/
|
||||||
function ShiftEntry($shift_entry_id)
|
function ShiftEntry($shift_entry_id)
|
||||||
{
|
{
|
||||||
|
|
|
@ -66,7 +66,7 @@ function ShiftType_create($name, $angeltype_id, $description)
|
||||||
* Get a shift type by id.
|
* Get a shift type by id.
|
||||||
*
|
*
|
||||||
* @param int $shifttype_id
|
* @param int $shifttype_id
|
||||||
* @return array|null
|
* @return array
|
||||||
*/
|
*/
|
||||||
function ShiftType($shifttype_id)
|
function ShiftType($shifttype_id)
|
||||||
{
|
{
|
||||||
|
|
|
@ -182,7 +182,7 @@ function NeededAngeltypes_by_ShiftsFilter(ShiftsFilter $shiftsFilter)
|
||||||
/**
|
/**
|
||||||
* @param array $shift
|
* @param array $shift
|
||||||
* @param array $angeltype
|
* @param array $angeltype
|
||||||
* @return array|null
|
* @return array
|
||||||
*/
|
*/
|
||||||
function NeededAngeltype_by_Shift_and_Angeltype($shift, $angeltype)
|
function NeededAngeltype_by_Shift_and_Angeltype($shift, $angeltype)
|
||||||
{
|
{
|
||||||
|
@ -323,7 +323,7 @@ function Shift_signup_allowed_angel(
|
||||||
return new ShiftSignupState(ShiftSignupState::NOT_ARRIVED, $free_entries);
|
return new ShiftSignupState(ShiftSignupState::NOT_ARRIVED, $free_entries);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($user_shifts == null) {
|
if (empty($user_shifts)) {
|
||||||
$user_shifts = Shifts_by_user($user);
|
$user_shifts = Shifts_by_user($user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -349,14 +349,14 @@ function Shift_signup_allowed_angel(
|
||||||
return new ShiftSignupState(ShiftSignupState::OCCUPIED, $free_entries);
|
return new ShiftSignupState(ShiftSignupState::OCCUPIED, $free_entries);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($user_angeltype == null) {
|
if (empty($user_angeltype)) {
|
||||||
$user_angeltype = UserAngelType_by_User_and_AngelType($user, $angeltype);
|
$user_angeltype = UserAngelType_by_User_and_AngelType($user, $angeltype);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
$user_angeltype == null
|
empty($user_angeltype)
|
||||||
|| ($angeltype['no_self_signup'] == 1 && $user_angeltype != null)
|
|| ($angeltype['no_self_signup'] == 1 && !empty($user_angeltype))
|
||||||
|| ($angeltype['restricted'] == 1 && $user_angeltype != null && !isset($user_angeltype['confirm_user_id']))
|
|| ($angeltype['restricted'] == 1 && !empty($user_angeltype) && !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
|
||||||
|
|
|
@ -193,7 +193,7 @@ function UserAngelType_create($user, $angeltype)
|
||||||
* Get an UserAngelType by its id.
|
* Get an UserAngelType by its id.
|
||||||
*
|
*
|
||||||
* @param int $user_angeltype_id
|
* @param int $user_angeltype_id
|
||||||
* @return array|null
|
* @return array
|
||||||
*/
|
*/
|
||||||
function UserAngelType($user_angeltype_id)
|
function UserAngelType($user_angeltype_id)
|
||||||
{
|
{
|
||||||
|
@ -209,7 +209,7 @@ function UserAngelType($user_angeltype_id)
|
||||||
*
|
*
|
||||||
* @param array $user
|
* @param array $user
|
||||||
* @param array $angeltype
|
* @param array $angeltype
|
||||||
* @return array|null
|
* @return array
|
||||||
*/
|
*/
|
||||||
function UserAngelType_by_User_and_AngelType($user, $angeltype)
|
function UserAngelType_by_User_and_AngelType($user, $angeltype)
|
||||||
{
|
{
|
||||||
|
|
|
@ -41,7 +41,7 @@ function UserDriverLicense_valid($user_driver_license)
|
||||||
* Get a users driver license information
|
* Get a users driver license information
|
||||||
*
|
*
|
||||||
* @param int $user_id The users id
|
* @param int $user_id The users id
|
||||||
* @return array|null
|
* @return array
|
||||||
*/
|
*/
|
||||||
function UserDriverLicense($user_id)
|
function UserDriverLicense($user_id)
|
||||||
{
|
{
|
||||||
|
|
|
@ -347,12 +347,12 @@ function User_validate_jabber($jabber)
|
||||||
*/
|
*/
|
||||||
function User_validate_planned_arrival_date($planned_arrival_date)
|
function User_validate_planned_arrival_date($planned_arrival_date)
|
||||||
{
|
{
|
||||||
if ($planned_arrival_date == null) {
|
if (is_null($planned_arrival_date)) {
|
||||||
// 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 (empty($event_config)) {
|
||||||
// Nothing to validate against
|
// Nothing to validate against
|
||||||
return new ValidationResult(true, $planned_arrival_date);
|
return new ValidationResult(true, $planned_arrival_date);
|
||||||
}
|
}
|
||||||
|
@ -376,7 +376,7 @@ function User_validate_planned_arrival_date($planned_arrival_date)
|
||||||
*/
|
*/
|
||||||
function User_validate_planned_departure_date($planned_arrival_date, $planned_departure_date)
|
function User_validate_planned_departure_date($planned_arrival_date, $planned_departure_date)
|
||||||
{
|
{
|
||||||
if ($planned_departure_date == null) {
|
if (is_null($planned_departure_date)) {
|
||||||
// null is okay
|
// null is okay
|
||||||
return new ValidationResult(true, null);
|
return new ValidationResult(true, null);
|
||||||
}
|
}
|
||||||
|
@ -385,7 +385,7 @@ function User_validate_planned_departure_date($planned_arrival_date, $planned_de
|
||||||
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 (empty($event_config )) {
|
||||||
// Nothing to validate against
|
// Nothing to validate against
|
||||||
return new ValidationResult(true, $planned_departure_date);
|
return new ValidationResult(true, $planned_departure_date);
|
||||||
}
|
}
|
||||||
|
@ -404,7 +404,7 @@ function User_validate_planned_departure_date($planned_arrival_date, $planned_de
|
||||||
* Returns user by id.
|
* Returns user by id.
|
||||||
*
|
*
|
||||||
* @param int $user_id UID
|
* @param int $user_id UID
|
||||||
* @return array|null
|
* @return array
|
||||||
*/
|
*/
|
||||||
function User($user_id)
|
function User($user_id)
|
||||||
{
|
{
|
||||||
|
@ -415,7 +415,7 @@ function User($user_id)
|
||||||
* Returns User by api_key.
|
* Returns User by api_key.
|
||||||
*
|
*
|
||||||
* @param string $api_key User api key
|
* @param string $api_key User api key
|
||||||
* @return array|null Matching user, null if not found
|
* @return array Matching user, empty if not found
|
||||||
*/
|
*/
|
||||||
function User_by_api_key($api_key)
|
function User_by_api_key($api_key)
|
||||||
{
|
{
|
||||||
|
@ -426,7 +426,7 @@ function User_by_api_key($api_key)
|
||||||
* Returns User by email.
|
* Returns User by email.
|
||||||
*
|
*
|
||||||
* @param string $email
|
* @param string $email
|
||||||
* @return array|null Matching user, null on error
|
* @return array Matching user, empty on error
|
||||||
*/
|
*/
|
||||||
function User_by_email($email)
|
function User_by_email($email)
|
||||||
{
|
{
|
||||||
|
@ -437,7 +437,7 @@ function User_by_email($email)
|
||||||
* Returns User by password token.
|
* Returns User by password token.
|
||||||
*
|
*
|
||||||
* @param string $token
|
* @param string $token
|
||||||
* @return array|null Matching user, null when not found
|
* @return array Matching user, empty when not found
|
||||||
*/
|
*/
|
||||||
function User_by_password_recovery_token($token)
|
function User_by_password_recovery_token($token)
|
||||||
{
|
{
|
||||||
|
|
|
@ -101,7 +101,7 @@ function admin_active()
|
||||||
if ($request->has('active') && preg_match('/^\d+$/', $request->input('active'))) {
|
if ($request->has('active') && preg_match('/^\d+$/', $request->input('active'))) {
|
||||||
$user_id = $request->input('active');
|
$user_id = $request->input('active');
|
||||||
$user_source = User($user_id);
|
$user_source = User($user_id);
|
||||||
if ($user_source != null) {
|
if (!empty($user_source)) {
|
||||||
DB::update('UPDATE `User` SET `Aktiv`=1 WHERE `UID`=? LIMIT 1', [$user_id]);
|
DB::update('UPDATE `User` SET `Aktiv`=1 WHERE `UID`=? LIMIT 1', [$user_id]);
|
||||||
engelsystem_log('User ' . User_Nick_render($user_source) . ' is active now.');
|
engelsystem_log('User ' . User_Nick_render($user_source) . ' is active now.');
|
||||||
$msg = success(_('Angel has been marked as active.'), true);
|
$msg = success(_('Angel has been marked as active.'), true);
|
||||||
|
@ -111,7 +111,7 @@ function admin_active()
|
||||||
} elseif ($request->has('not_active') && preg_match('/^\d+$/', $request->input('not_active'))) {
|
} elseif ($request->has('not_active') && preg_match('/^\d+$/', $request->input('not_active'))) {
|
||||||
$user_id = $request->input('not_active');
|
$user_id = $request->input('not_active');
|
||||||
$user_source = User($user_id);
|
$user_source = User($user_id);
|
||||||
if ($user_source != null) {
|
if (!empty($user_source)) {
|
||||||
DB::update('UPDATE `User` SET `Aktiv`=0 WHERE `UID`=? LIMIT 1', [$user_id]);
|
DB::update('UPDATE `User` SET `Aktiv`=0 WHERE `UID`=? LIMIT 1', [$user_id]);
|
||||||
engelsystem_log('User ' . User_Nick_render($user_source) . ' is NOT active now.');
|
engelsystem_log('User ' . User_Nick_render($user_source) . ' is NOT active now.');
|
||||||
$msg = success(_('Angel has been marked as not active.'), true);
|
$msg = success(_('Angel has been marked as not active.'), true);
|
||||||
|
@ -121,7 +121,7 @@ function admin_active()
|
||||||
} elseif ($request->has('tshirt') && preg_match('/^\d+$/', $request->input('tshirt'))) {
|
} elseif ($request->has('tshirt') && preg_match('/^\d+$/', $request->input('tshirt'))) {
|
||||||
$user_id = $request->input('tshirt');
|
$user_id = $request->input('tshirt');
|
||||||
$user_source = User($user_id);
|
$user_source = User($user_id);
|
||||||
if ($user_source != null) {
|
if (!empty($user_source)) {
|
||||||
DB::update('UPDATE `User` SET `Tshirt`=1 WHERE `UID`=? LIMIT 1', [$user_id]);
|
DB::update('UPDATE `User` SET `Tshirt`=1 WHERE `UID`=? LIMIT 1', [$user_id]);
|
||||||
engelsystem_log('User ' . User_Nick_render($user_source) . ' has tshirt now.');
|
engelsystem_log('User ' . User_Nick_render($user_source) . ' has tshirt now.');
|
||||||
$msg = success(_('Angel has got a t-shirt.'), true);
|
$msg = success(_('Angel has got a t-shirt.'), true);
|
||||||
|
@ -131,7 +131,7 @@ function admin_active()
|
||||||
} elseif ($request->has('not_tshirt') && preg_match('/^\d+$/', $request->input('not_tshirt'))) {
|
} elseif ($request->has('not_tshirt') && preg_match('/^\d+$/', $request->input('not_tshirt'))) {
|
||||||
$user_id = $request->input('not_tshirt');
|
$user_id = $request->input('not_tshirt');
|
||||||
$user_source = User($user_id);
|
$user_source = User($user_id);
|
||||||
if ($user_source != null) {
|
if (!empty($user_source)) {
|
||||||
DB::update('UPDATE `User` SET `Tshirt`=0 WHERE `UID`=? LIMIT 1', [$user_id]);
|
DB::update('UPDATE `User` SET `Tshirt`=0 WHERE `UID`=? LIMIT 1', [$user_id]);
|
||||||
engelsystem_log('User ' . User_Nick_render($user_source) . ' has NO tshirt.');
|
engelsystem_log('User ' . User_Nick_render($user_source) . ' has NO tshirt.');
|
||||||
$msg = success(_('Angel has got no t-shirt.'), true);
|
$msg = success(_('Angel has got no t-shirt.'), true);
|
||||||
|
@ -252,8 +252,8 @@ function admin_active()
|
||||||
$gc = array_shift($gc);
|
$gc = array_shift($gc);
|
||||||
|
|
||||||
$shirt_statistics[] = [
|
$shirt_statistics[] = [
|
||||||
'size' => $size,
|
'size' => $size,
|
||||||
'given' => (int)$gc
|
'given' => (int)$gc
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -261,8 +261,8 @@ function admin_active()
|
||||||
$shirtCount = User_tshirts_count();
|
$shirtCount = User_tshirts_count();
|
||||||
|
|
||||||
$shirt_statistics[] = [
|
$shirt_statistics[] = [
|
||||||
'size' => '<b>' . _('Sum') . '</b>',
|
'size' => '<b>' . _('Sum') . '</b>',
|
||||||
'given' => '<b>' . $shirtCount . '</b>'
|
'given' => '<b>' . $shirtCount . '</b>'
|
||||||
];
|
];
|
||||||
|
|
||||||
return page_with_title(admin_active_title(), [
|
return page_with_title(admin_active_title(), [
|
||||||
|
@ -288,8 +288,8 @@ function admin_active()
|
||||||
], $matched_users),
|
], $matched_users),
|
||||||
'<h2>' . _('Shirt statistics') . '</h2>',
|
'<h2>' . _('Shirt statistics') . '</h2>',
|
||||||
table([
|
table([
|
||||||
'size' => _('Size'),
|
'size' => _('Size'),
|
||||||
'given' => _('Given shirts')
|
'given' => _('Given shirts')
|
||||||
], $shirt_statistics)
|
], $shirt_statistics)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ function admin_arrive()
|
||||||
if ($request->has('reset') && preg_match('/^\d+$/', $request->input('reset'))) {
|
if ($request->has('reset') && preg_match('/^\d+$/', $request->input('reset'))) {
|
||||||
$user_id = $request->input('reset');
|
$user_id = $request->input('reset');
|
||||||
$user_source = User($user_id);
|
$user_source = User($user_id);
|
||||||
if ($user_source != null) {
|
if (!empty($user_source)) {
|
||||||
DB::update('
|
DB::update('
|
||||||
UPDATE `User`
|
UPDATE `User`
|
||||||
SET `Gekommen`=0, `arrival_date` = NULL
|
SET `Gekommen`=0, `arrival_date` = NULL
|
||||||
|
@ -42,7 +42,7 @@ function admin_arrive()
|
||||||
} elseif ($request->has('arrived') && preg_match('/^\d+$/', $request->input('arrived'))) {
|
} elseif ($request->has('arrived') && preg_match('/^\d+$/', $request->input('arrived'))) {
|
||||||
$user_id = $request->input('arrived');
|
$user_id = $request->input('arrived');
|
||||||
$user_source = User($user_id);
|
$user_source = User($user_id);
|
||||||
if ($user_source != null) {
|
if (!empty($user_source)) {
|
||||||
DB::update('
|
DB::update('
|
||||||
UPDATE `User`
|
UPDATE `User`
|
||||||
SET `Gekommen`=1, `arrival_date`=?
|
SET `Gekommen`=1, `arrival_date`=?
|
||||||
|
@ -83,7 +83,7 @@ function admin_arrive()
|
||||||
}
|
}
|
||||||
|
|
||||||
$usr['nick'] = User_Nick_render($usr);
|
$usr['nick'] = User_Nick_render($usr);
|
||||||
if ($usr['planned_departure_date'] != null) {
|
if (!is_null($usr['planned_departure_date'])) {
|
||||||
$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']);
|
||||||
} else {
|
} else {
|
||||||
$usr['rendered_planned_departure_date'] = '-';
|
$usr['rendered_planned_departure_date'] = '-';
|
||||||
|
@ -109,7 +109,7 @@ function admin_arrive()
|
||||||
$arrival_count_at_day[$day]++;
|
$arrival_count_at_day[$day]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($usr['planned_arrival_date'] != null) {
|
if (!is_null($usr['planned_arrival_date'])) {
|
||||||
$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;
|
||||||
|
@ -117,7 +117,7 @@ function admin_arrive()
|
||||||
$planned_arrival_count_at_day[$day]++;
|
$planned_arrival_count_at_day[$day]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($usr['planned_departure_date'] != null && $usr['Gekommen'] == 1) {
|
if (!is_null($usr['planned_departure_date']) && $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;
|
||||||
|
|
|
@ -111,7 +111,7 @@ function admin_questions()
|
||||||
'SELECT * FROM `Questions` WHERE `QID`=? LIMIT 1',
|
'SELECT * FROM `Questions` WHERE `QID`=? LIMIT 1',
|
||||||
[$question_id]
|
[$question_id]
|
||||||
);
|
);
|
||||||
if (!empty($question) && $question['AID'] == null) {
|
if (!empty($question) && empty($question['AID'])) {
|
||||||
$answer = trim(
|
$answer = trim(
|
||||||
preg_replace("/([^\p{L}\p{P}\p{Z}\p{N}\n]{1,})/ui",
|
preg_replace("/([^\p{L}\p{P}\p{Z}\p{N}\n]{1,})/ui",
|
||||||
'',
|
'',
|
||||||
|
|
|
@ -55,7 +55,7 @@ function admin_rooms()
|
||||||
|
|
||||||
if (test_request_int('id')) {
|
if (test_request_int('id')) {
|
||||||
$room = Room($request->input('id'));
|
$room = Room($request->input('id'));
|
||||||
if ($room == null) {
|
if (empty($room)) {
|
||||||
redirect(page_link_to('admin_rooms'));
|
redirect(page_link_to('admin_rooms'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ function admin_rooms()
|
||||||
$needed_angeltype_info = [];
|
$needed_angeltype_info = [];
|
||||||
foreach ($angeltypes_count as $angeltype_id => $angeltype_count) {
|
foreach ($angeltypes_count as $angeltype_id => $angeltype_count) {
|
||||||
$angeltype = AngelType($angeltype_id);
|
$angeltype = AngelType($angeltype_id);
|
||||||
if ($angeltype != null) {
|
if (!empty($angeltype)) {
|
||||||
NeededAngelType_add(null, $angeltype_id, $room_id, $angeltype_count);
|
NeededAngelType_add(null, $angeltype_id, $room_id, $angeltype_count);
|
||||||
if ($angeltype_count > 0) {
|
if ($angeltype_count > 0) {
|
||||||
$needed_angeltype_info[] = $angeltype['name'] . ': ' . $angeltype_count;
|
$needed_angeltype_info[] = $angeltype['name'] . ': ' . $angeltype_count;
|
||||||
|
|
|
@ -53,7 +53,7 @@ function admin_shifts()
|
||||||
if ($request->has('preview') || $request->has('back')) {
|
if ($request->has('preview') || $request->has('back')) {
|
||||||
if ($request->has('shifttype_id')) {
|
if ($request->has('shifttype_id')) {
|
||||||
$shifttype = ShiftType($request->input('shifttype_id'));
|
$shifttype = ShiftType($request->input('shifttype_id'));
|
||||||
if ($shifttype == null) {
|
if (empty($shifttype)) {
|
||||||
$valid = false;
|
$valid = false;
|
||||||
error(_('Please select a shift type.'));
|
error(_('Please select a shift type.'));
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -34,7 +34,7 @@ function admin_user()
|
||||||
$user_id = $request->input('id');
|
$user_id = $request->input('id');
|
||||||
if (!$request->has('action')) {
|
if (!$request->has('action')) {
|
||||||
$user_source = User($user_id);
|
$user_source = User($user_id);
|
||||||
if ($user_source == null) {
|
if (empty($user_source)) {
|
||||||
error(_('This user does not exist.'));
|
error(_('This user does not exist.'));
|
||||||
redirect(users_link());
|
redirect(users_link());
|
||||||
}
|
}
|
||||||
|
|
|
@ -279,7 +279,7 @@ function guest_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 (!empty($event_config) && !empty($event_config['event_welcome_msg'])) {
|
||||||
return User_registration_success_view($event_config['event_welcome_msg']);
|
return User_registration_success_view($event_config['event_welcome_msg']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -289,7 +289,7 @@ function guest_register()
|
||||||
|
|
||||||
$buildup_start_date = time();
|
$buildup_start_date = time();
|
||||||
$teardown_end_date = null;
|
$teardown_end_date = null;
|
||||||
if ($event_config != null) {
|
if (!empty($event_config)) {
|
||||||
if (isset($event_config['buildup_start_date'])) {
|
if (isset($event_config['buildup_start_date'])) {
|
||||||
$buildup_start_date = $event_config['buildup_start_date'];
|
$buildup_start_date = $event_config['buildup_start_date'];
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ function user_atom()
|
||||||
$key = $request->input('key');
|
$key = $request->input('key');
|
||||||
|
|
||||||
$user = User_by_api_key($key);
|
$user = User_by_api_key($key);
|
||||||
if ($user == null) {
|
if (empty($user)) {
|
||||||
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']))) {
|
||||||
|
|
|
@ -14,7 +14,7 @@ function user_ical()
|
||||||
$key = $request->input('key');
|
$key = $request->input('key');
|
||||||
|
|
||||||
$user = User_by_api_key($key);
|
$user = User_by_api_key($key);
|
||||||
if ($user == null) {
|
if (empty($user)) {
|
||||||
engelsystem_error('Key invalid.');
|
engelsystem_error('Key invalid.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,6 @@ function user_myshifts()
|
||||||
}
|
}
|
||||||
|
|
||||||
$shifts_user = DB::selectOne('SELECT * FROM `User` WHERE `UID`=? LIMIT 1', [$shift_entry_id]);
|
$shifts_user = DB::selectOne('SELECT * FROM `User` WHERE `UID`=? LIMIT 1', [$shift_entry_id]);
|
||||||
|
|
||||||
if ($request->has('reset')) {
|
if ($request->has('reset')) {
|
||||||
if ($request->input('reset') == 'ack') {
|
if ($request->input('reset') == 'ack') {
|
||||||
User_reset_api_key($user);
|
User_reset_api_key($user);
|
||||||
|
|
|
@ -215,7 +215,7 @@ function user_settings()
|
||||||
$buildup_start_date = null;
|
$buildup_start_date = null;
|
||||||
$teardown_end_date = null;
|
$teardown_end_date = null;
|
||||||
$event_config = EventConfig();
|
$event_config = EventConfig();
|
||||||
if ($event_config != null) {
|
if (!empty($event_config)) {
|
||||||
if (isset($event_config['buildup_start_date'])) {
|
if (isset($event_config['buildup_start_date'])) {
|
||||||
$buildup_start_date = $event_config['buildup_start_date'];
|
$buildup_start_date = $event_config['buildup_start_date'];
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@ function user_shifts()
|
||||||
function update_ShiftsFilter_timerange(ShiftsFilter $shiftsFilter, $days)
|
function update_ShiftsFilter_timerange(ShiftsFilter $shiftsFilter, $days)
|
||||||
{
|
{
|
||||||
$start_time = $shiftsFilter->getStartTime();
|
$start_time = $shiftsFilter->getStartTime();
|
||||||
if ($start_time == null) {
|
if (is_null($start_time)) {
|
||||||
$start_time = time();
|
$start_time = time();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ function check_request_datetime($date_name, $time_name, $allowed_days, $default_
|
||||||
function parse_date($pattern, $value)
|
function parse_date($pattern, $value)
|
||||||
{
|
{
|
||||||
$datetime = DateTime::createFromFormat($pattern, trim($value));
|
$datetime = DateTime::createFromFormat($pattern, trim($value));
|
||||||
if ($datetime == null) {
|
if (is_null($datetime)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return $datetime->getTimestamp();
|
return $datetime->getTimestamp();
|
||||||
|
|
|
@ -28,9 +28,9 @@ function AngelType_name_render($angeltype)
|
||||||
*/
|
*/
|
||||||
function AngelType_render_membership($user_angeltype)
|
function AngelType_render_membership($user_angeltype)
|
||||||
{
|
{
|
||||||
if ($user_angeltype['user_angeltype_id'] != null) {
|
if (!empty($user_angeltype['user_angeltype_id'])) {
|
||||||
if ($user_angeltype['restricted']) {
|
if ($user_angeltype['restricted']) {
|
||||||
if ($user_angeltype['confirm_user_id'] == null) {
|
if (empty($user_angeltype['confirm_user_id'])) {
|
||||||
return glyph('lock') . _('Unconfirmed');
|
return glyph('lock') . _('Unconfirmed');
|
||||||
} elseif ($user_angeltype['supporter']) {
|
} elseif ($user_angeltype['supporter']) {
|
||||||
return glyph_bool(true) . _('Supporter');
|
return glyph_bool(true) . _('Supporter');
|
||||||
|
@ -145,18 +145,18 @@ function AngelType_view_buttons($angeltype, $user_angeltype, $admin_angeltypes,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($user_angeltype == null) {
|
if (is_null($user_angeltype)) {
|
||||||
$buttons[] = button(
|
$buttons[] = button(
|
||||||
page_link_to('user_angeltypes', ['action' => 'add', 'angeltype_id' => $angeltype['id']]),
|
page_link_to('user_angeltypes', ['action' => 'add', 'angeltype_id' => $angeltype['id']]),
|
||||||
_('join'),
|
_('join'),
|
||||||
'add'
|
'add'
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
if ($angeltype['requires_driver_license'] && $user_driver_license == null) {
|
if ($angeltype['requires_driver_license'] && empty($user_driver_license)) {
|
||||||
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'] && empty($user_angeltype['confirm_user_id'])) {
|
||||||
error(sprintf(
|
error(sprintf(
|
||||||
_('You are unconfirmed for this angeltype. Please go to the introduction for %s to get confirmed.'),
|
_('You are unconfirmed for this angeltype. Please go to the introduction for %s to get confirmed.'),
|
||||||
$angeltype['name']
|
$angeltype['name']
|
||||||
|
@ -212,7 +212,7 @@ function AngelType_view_members($angeltype, $members, $admin_user_angeltypes, $a
|
||||||
$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'] && empty($member['confirm_user_id'])) {
|
||||||
$member['actions'] = table_buttons([
|
$member['actions'] = table_buttons([
|
||||||
button(
|
button(
|
||||||
page_link_to(
|
page_link_to(
|
||||||
|
@ -526,7 +526,7 @@ function AngelTypes_about_view_angeltype($angeltype)
|
||||||
|
|
||||||
if (isset($angeltype['user_angeltype_id'])) {
|
if (isset($angeltype['user_angeltype_id'])) {
|
||||||
$buttons = [];
|
$buttons = [];
|
||||||
if ($angeltype['user_angeltype_id'] != null) {
|
if (!empty($angeltype['user_angeltype_id'])) {
|
||||||
$buttons[] = button(
|
$buttons[] = button(
|
||||||
page_link_to(
|
page_link_to(
|
||||||
'user_angeltypes',
|
'user_angeltypes',
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
*/
|
*/
|
||||||
function EventConfig_countdown_page($event_config)
|
function EventConfig_countdown_page($event_config)
|
||||||
{
|
{
|
||||||
if ($event_config == null) {
|
if (empty($event_config)) {
|
||||||
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)
|
||||||
]);
|
]);
|
||||||
|
@ -16,7 +16,7 @@ function EventConfig_countdown_page($event_config)
|
||||||
|
|
||||||
$elements = [];
|
$elements = [];
|
||||||
|
|
||||||
if ($event_config['event_name'] != null) {
|
if (!is_null($event_config['event_name'])) {
|
||||||
$elements[] = div('col-sm-12 text-center', [
|
$elements[] = div('col-sm-12 text-center', [
|
||||||
heading(sprintf(
|
heading(sprintf(
|
||||||
_('Welcome to the %s!'),
|
_('Welcome to the %s!'),
|
||||||
|
@ -25,7 +25,7 @@ function EventConfig_countdown_page($event_config)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($event_config['buildup_start_date'] != null && time() < $event_config['buildup_start_date']) {
|
if (!is_null($event_config['buildup_start_date']) && 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>',
|
||||||
|
@ -33,7 +33,7 @@ function EventConfig_countdown_page($event_config)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($event_config['event_start_date'] != null && time() < $event_config['event_start_date']) {
|
if (!is_null($event_config['event_start_date']) && 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>',
|
||||||
|
@ -41,7 +41,7 @@ function EventConfig_countdown_page($event_config)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($event_config['event_end_date'] != null && time() < $event_config['event_end_date']) {
|
if (!is_null($event_config['event_end_date']) && 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>',
|
||||||
|
@ -49,7 +49,7 @@ function EventConfig_countdown_page($event_config)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($event_config['teardown_end_date'] != null && time() < $event_config['teardown_end_date']) {
|
if (!is_null($event_config['teardown_end_date']) && 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>',
|
||||||
|
@ -68,15 +68,15 @@ function EventConfig_countdown_page($event_config)
|
||||||
*/
|
*/
|
||||||
function EventConfig_info($event_config)
|
function EventConfig_info($event_config)
|
||||||
{
|
{
|
||||||
if ($event_config == null) {
|
if (empty($event_config)) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Event name, start+end date are set
|
// Event name, start+end date are set
|
||||||
if (
|
if (
|
||||||
$event_config['event_name'] != null
|
!is_null($event_config['event_name'])
|
||||||
&& $event_config['event_start_date'] != null
|
&& !is_null($event_config['event_start_date'])
|
||||||
&& $event_config['event_end_date'] != null
|
&& !is_null($event_config['event_end_date'])
|
||||||
) {
|
) {
|
||||||
return sprintf(
|
return sprintf(
|
||||||
_('%s, from %s to %s'),
|
_('%s, from %s to %s'),
|
||||||
|
@ -87,7 +87,7 @@ function EventConfig_info($event_config)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Event name, start date are set
|
// Event name, start date are set
|
||||||
if ($event_config['event_name'] != null && $event_config['event_start_date'] != null) {
|
if (!is_null($event_config['event_name']) && !is_null($event_config['event_start_date'])) {
|
||||||
return sprintf(
|
return sprintf(
|
||||||
_('%s, starting %s'), $event_config['event_name'],
|
_('%s, starting %s'), $event_config['event_name'],
|
||||||
date(_('Y-m-d'), $event_config['event_start_date'])
|
date(_('Y-m-d'), $event_config['event_start_date'])
|
||||||
|
@ -95,7 +95,7 @@ function EventConfig_info($event_config)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Event start+end date are set
|
// Event start+end date are set
|
||||||
if ($event_config['event_start_date'] != null && $event_config['event_end_date'] != null) {
|
if (!is_null($event_config['event_start_date']) && !is_null($event_config['event_end_date'])) {
|
||||||
return sprintf(
|
return sprintf(
|
||||||
_('Event from %s to %s'),
|
_('Event from %s to %s'),
|
||||||
date(_('Y-m-d'), $event_config['event_start_date']),
|
date(_('Y-m-d'), $event_config['event_start_date']),
|
||||||
|
@ -104,7 +104,7 @@ function EventConfig_info($event_config)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only event name is set
|
// Only event name is set
|
||||||
if ($event_config['event_name'] != null) {
|
if (!is_null($event_config['event_name'])) {
|
||||||
return sprintf($event_config['event_name']);
|
return sprintf($event_config['event_name']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -129,7 +129,7 @@ class ShiftCalendarRenderer
|
||||||
*/
|
*/
|
||||||
public function getBlocksPerSlot()
|
public function getBlocksPerSlot()
|
||||||
{
|
{
|
||||||
if ($this->blocksPerSlot == null) {
|
if (is_null($this->blocksPerSlot)) {
|
||||||
$this->blocksPerSlot = $this->calcBlocksPerSlot();
|
$this->blocksPerSlot = $this->calcBlocksPerSlot();
|
||||||
}
|
}
|
||||||
return $this->blocksPerSlot;
|
return $this->blocksPerSlot;
|
||||||
|
|
|
@ -116,7 +116,7 @@ class ShiftCalendarShiftRenderer
|
||||||
$angeltype,
|
$angeltype,
|
||||||
$user
|
$user
|
||||||
);
|
);
|
||||||
if ($shift_signup_state == null) {
|
if (is_null($shift_signup_state)) {
|
||||||
$shift_signup_state = $angeltype_signup_state;
|
$shift_signup_state = $angeltype_signup_state;
|
||||||
} else {
|
} else {
|
||||||
$shift_signup_state->combineWith($angeltype_signup_state);
|
$shift_signup_state->combineWith($angeltype_signup_state);
|
||||||
|
@ -124,7 +124,7 @@ class ShiftCalendarShiftRenderer
|
||||||
$html .= $angeltype_html;
|
$html .= $angeltype_html;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($shift_signup_state == null) {
|
if (is_null($shift_signup_state)) {
|
||||||
$shift_signup_state = new ShiftSignupState(ShiftSignupState::SHIFT_ENDED, 0);
|
$shift_signup_state = new ShiftSignupState(ShiftSignupState::SHIFT_ENDED, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,14 +50,14 @@ function Shift_view_header($shift, $room)
|
||||||
function Shift_editor_info_render($shift)
|
function Shift_editor_info_render($shift)
|
||||||
{
|
{
|
||||||
$info = [];
|
$info = [];
|
||||||
if ($shift['created_by_user_id'] != null) {
|
if (!empty($shift['created_by_user_id'])) {
|
||||||
$info[] = sprintf(
|
$info[] = sprintf(
|
||||||
glyph('plus') . _('created at %s by %s'),
|
glyph('plus') . _('created at %s by %s'),
|
||||||
date('Y-m-d H:i', $shift['created_at_timestamp']),
|
date('Y-m-d H:i', $shift['created_at_timestamp']),
|
||||||
User_Nick_render(User($shift['created_by_user_id']))
|
User_Nick_render(User($shift['created_by_user_id']))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if ($shift['edited_by_user_id'] != null) {
|
if (!empty($shift['edited_by_user_id'])) {
|
||||||
$info[] = sprintf(
|
$info[] = sprintf(
|
||||||
glyph('pencil') . _('edited at %s by %s'),
|
glyph('pencil') . _('edited at %s by %s'),
|
||||||
date('Y-m-d H:i', $shift['edited_at_timestamp']),
|
date('Y-m-d H:i', $shift['edited_at_timestamp']),
|
||||||
|
@ -77,13 +77,13 @@ function Shift_signup_button_render($shift, $angeltype, $user_angeltype = null)
|
||||||
{
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
if ($user_angeltype == null) {
|
if (empty($user_angeltype)) {
|
||||||
$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(shift_entry_create_link($shift, $angeltype), _('Sign up'));
|
return button(shift_entry_create_link($shift, $angeltype), _('Sign up'));
|
||||||
} elseif ($user_angeltype == null) {
|
} elseif (empty($user_angeltype)) {
|
||||||
return button(
|
return button(
|
||||||
page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']]),
|
page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']]),
|
||||||
sprintf(_('Become %s'),
|
sprintf(_('Become %s'),
|
||||||
|
|
|
@ -36,7 +36,7 @@ class UserHintsRenderer
|
||||||
*/
|
*/
|
||||||
public function addHint($hint, $important = false)
|
public function addHint($hint, $important = false)
|
||||||
{
|
{
|
||||||
if ($hint != null && $hint != '') {
|
if (!empty($hint)) {
|
||||||
if ($important) {
|
if ($important) {
|
||||||
$this->important = true;
|
$this->important = true;
|
||||||
$this->hints[] = error($hint, true);
|
$this->hints[] = error($hint, true);
|
||||||
|
|
|
@ -472,7 +472,7 @@ function User_view_worklog($worklog, $admin_user_worklog_privilege) {
|
||||||
)
|
)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'date' => glyph('calendar') . date('Y-m-d', $worklog['work_timestamp']),
|
'date' => glyph('calendar') . date('Y-m-d', $worklog['work_timestamp']),
|
||||||
'duration' => '<b>' . sprintf('%.2f', $worklog['work_hours']) . '</b>',
|
'duration' => '<b>' . sprintf('%.2f', $worklog['work_hours']) . '</b>',
|
||||||
|
@ -480,8 +480,8 @@ function User_view_worklog($worklog, $admin_user_worklog_privilege) {
|
||||||
'shift_info' => _('Work log entry'),
|
'shift_info' => _('Work log entry'),
|
||||||
'comment' => $worklog['comment'] . '<br>'
|
'comment' => $worklog['comment'] . '<br>'
|
||||||
. sprintf(
|
. sprintf(
|
||||||
_('Added by %s at %s'),
|
_('Added by %s at %s'),
|
||||||
User_Nick_render(User($worklog['created_user_id'])),
|
User_Nick_render(User($worklog['created_user_id'])),
|
||||||
date('Y-m-d H:i', $worklog['created_timestamp'])
|
date('Y-m-d H:i', $worklog['created_timestamp'])
|
||||||
),
|
),
|
||||||
'actions' => $actions
|
'actions' => $actions
|
||||||
|
@ -748,7 +748,7 @@ function User_angeltypes_render($user_angeltypes)
|
||||||
$output = [];
|
$output = [];
|
||||||
foreach ($user_angeltypes as $angeltype) {
|
foreach ($user_angeltypes as $angeltype) {
|
||||||
$class = 'text-success';
|
$class = 'text-success';
|
||||||
if ($angeltype['restricted'] == 1 && $angeltype['confirm_user_id'] == null) {
|
if ($angeltype['restricted'] == 1 && empty($angeltype['confirm_user_id'])) {
|
||||||
$class = 'text-warning';
|
$class = 'text-warning';
|
||||||
}
|
}
|
||||||
$output[] = '<a href="' . angeltype_link($angeltype['id']) . '" class="' . $class . '">'
|
$output[] = '<a href="' . angeltype_link($angeltype['id']) . '" class="' . $class . '">'
|
||||||
|
@ -821,7 +821,7 @@ 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']) || empty($user['planned_departure_date'])) {
|
||||||
$text = _('Please enter your planned date of departure on your settings page to give us a feeling for teardown capacities.');
|
$text = _('Please enter your planned date of departure on your settings page to give us a feeling for teardown capacities.');
|
||||||
return render_profile_link($text, null, 'alert-link');
|
return render_profile_link($text, null, 'alert-link');
|
||||||
}
|
}
|
||||||
|
@ -857,7 +857,7 @@ function render_user_arrived_hint()
|
||||||
|
|
||||||
if ($user['Gekommen'] == 0) {
|
if ($user['Gekommen'] == 0) {
|
||||||
$event_config = EventConfig();
|
$event_config = EventConfig();
|
||||||
if (!is_null($event_config)
|
if (!empty($event_config)
|
||||||
&& !is_null($event_config['buildup_start_date'])
|
&& !is_null($event_config['buildup_start_date'])
|
||||||
&& time() > $event_config['buildup_start_date']) {
|
&& time() > $event_config['buildup_start_date']) {
|
||||||
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.');
|
||||||
|
|
|
@ -32,6 +32,7 @@ class Db
|
||||||
{
|
{
|
||||||
$return = self::connection()->select($query, $bindings);
|
$return = self::connection()->select($query, $bindings);
|
||||||
|
|
||||||
|
// @TODO: Remove type casting
|
||||||
foreach ($return as $key => $value) {
|
foreach ($return as $key => $value) {
|
||||||
$return[$key] = (array)$value;
|
$return[$key] = (array)$value;
|
||||||
}
|
}
|
||||||
|
@ -44,16 +45,13 @@ class Db
|
||||||
*
|
*
|
||||||
* @param string $query
|
* @param string $query
|
||||||
* @param array $bindings
|
* @param array $bindings
|
||||||
* @return array|null
|
* @return array
|
||||||
*/
|
*/
|
||||||
public static function selectOne($query, array $bindings = [])
|
public static function selectOne($query, array $bindings = [])
|
||||||
{
|
{
|
||||||
$result = self::connection()->selectOne($query, $bindings);
|
$result = self::connection()->selectOne($query, $bindings);
|
||||||
|
|
||||||
if (empty($result)) {
|
// @TODO: remove typecast
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (array)$result;
|
return (array)$result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue