function user_controller() { global $privileges, $user; if (isset($_REQUEST['user_id'])) { $user_source = User($_REQUEST['user_id']); } else { $user_source = $user; } $shifts = Shifts_by_user($user_source); foreach ($shifts as &$shift) { // TODO: Move queries to model $shift['needed_angeltypes'] = sql_select("SELECT DISTINCT `AngelTypes`.* FROM `ShiftEntry` JOIN `AngelTypes` ON `ShiftEntry`.`TID`=`AngelTypes`.`id` WHERE `ShiftEntry`.`SID`='" . sql_escape($shift['SID']) . "' ORDER BY `AngelTypes`.`name`"); foreach ($shift['needed_angeltypes'] as &$needed_angeltype) { $needed_angeltype['users'] = sql_select("\n SELECT `ShiftEntry`.`freeloaded`, `User`.*\n FROM `ShiftEntry`\n JOIN `User` ON `ShiftEntry`.`UID`=`User`.`UID`\n WHERE `ShiftEntry`.`SID`='" . sql_escape($shift['SID']) . "'\n AND `ShiftEntry`.`TID`='" . sql_escape($needed_angeltype['id']) . "'"); } } if ($user_source['api_key'] == "") { User_reset_api_key($user_source, false); } return array($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'])); }
/** * Generates a hint, if user joined angeltypes that require a driving license and the user has no driver license information provided. */ function user_driver_license_required_hint() { global $user; $angeltypes = User_angeltypes($user); if ($angeltypes === false) { engelsystem_error("Unable to load user angeltypes."); } $user_driver_license = UserDriverLicense($user['UID']); if ($user_driver_license === false) { engelsystem_error("Unable to load user driver license."); } $driving_license_information_required = false; foreach ($angeltypes as $angeltype) { if ($angeltype['requires_driver_license']) { $driving_license_information_required = true; break; } } 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 ''; }