From 356b2582f3e6a43ecf2607acad4a7fe0b37f659a Mon Sep 17 00:00:00 2001 From: Bot Date: Tue, 3 Jan 2017 03:22:48 +0100 Subject: [PATCH] PPHDoc, formatting, fixes, cleanup --- config/config.default.php | 4 +- includes/controller/angeltypes_controller.php | 25 ++- .../controller/event_config_controller.php | 6 + includes/controller/rooms_controller.php | 23 ++- .../controller/shift_entries_controller.php | 22 ++- includes/controller/shifts_controller.php | 34 +++- includes/controller/shifttypes_controller.php | 23 ++- .../controller/user_angeltypes_controller.php | 26 ++- .../user_driver_licenses_controller.php | 11 +- includes/controller/users_controller.php | 63 +++++- includes/engelsystem_provider.php | 1 + includes/helper/email_helper.php | 25 ++- includes/helper/graph_helper.php | 10 +- .../helper/internationalization_helper.php | 6 +- includes/helper/message_helper.php | 37 +++- includes/mailer/shifts_mailer.php | 69 ++++--- includes/mailer/users_mailer.php | 5 +- includes/model/AngelType_model.php | 38 ++-- includes/model/EventConfig_model.php | 4 + includes/model/LogEntries_model.php | 13 +- includes/model/Message_model.php | 13 +- includes/model/NeededAngelTypes_model.php | 13 +- includes/model/Room_model.php | 13 +- includes/model/ShiftEntry_model.php | 31 ++- includes/model/ShiftSignupState.php | 21 +- includes/model/ShiftTypes_model.php | 7 +- includes/model/ShiftsFilter.php | 51 ++++- includes/model/Shifts_model.php | 131 +++++++++---- includes/model/UserAngelTypes_model.php | 43 +++-- includes/model/UserDriverLicenses_model.php | 27 +-- includes/model/UserGroups_model.php | 3 +- includes/model/User_model.php | 59 ++++-- includes/model/ValidationResult.php | 14 +- includes/mysqli_provider.php | 54 ++++-- includes/pages/admin_active.php | 13 +- includes/pages/admin_arrive.php | 8 +- includes/pages/admin_free.php | 6 + includes/pages/admin_groups.php | 7 +- includes/pages/admin_import.php | 31 +++ includes/pages/admin_log.php | 6 + includes/pages/admin_news.php | 12 +- includes/pages/admin_questions.php | 10 + includes/pages/admin_rooms.php | 9 +- includes/pages/admin_shifts.php | 17 +- includes/pages/admin_user.php | 13 +- includes/pages/guest_credits.php | 7 + includes/pages/guest_login.php | 18 +- includes/pages/guest_start.php | 1 + includes/pages/user_atom.php | 18 +- includes/pages/user_ical.php | 3 +- includes/pages/user_messages.php | 11 ++ includes/pages/user_myshifts.php | 14 +- includes/pages/user_news.php | 73 ++++++- includes/pages/user_questions.php | 8 + includes/pages/user_settings.php | 28 +-- includes/pages/user_shifts.php | 41 +++- includes/sys_auth.php | 24 ++- includes/sys_form.php | 168 +++++++++++----- includes/sys_log.php | 5 +- includes/sys_menu.php | 27 ++- includes/sys_page.php | 79 ++++---- includes/sys_template.php | 181 ++++++++++++++---- includes/view/AngelTypes_view.php | 55 +++++- includes/view/EventConfig_view.php | 21 +- includes/view/Questions_view.php | 6 + includes/view/Rooms_view.php | 10 + includes/view/ShiftCalendarLane.php | 25 ++- includes/view/ShiftCalendarRenderer.php | 77 ++++++-- includes/view/ShiftCalendarShiftRenderer.php | 41 ++-- includes/view/ShiftEntry_view.php | 4 +- includes/view/ShiftTypes_view.php | 25 +++ includes/view/ShiftsFilterRenderer.php | 13 +- includes/view/Shifts_view.php | 36 +++- includes/view/UserAngelTypes_view.php | 38 ++++ includes/view/UserDriverLicenses_view.php | 16 +- includes/view/UserHintsRenderer.php | 13 +- includes/view/User_view.php | 128 ++++++++++--- public/index.php | 109 ++++++----- shift_markup.html | 105 ---------- 79 files changed, 1836 insertions(+), 649 deletions(-) delete mode 100644 shift_markup.html diff --git a/config/config.default.php b/config/config.default.php index fc61e60a..e6833a2b 100644 --- a/config/config.default.php +++ b/config/config.default.php @@ -13,10 +13,10 @@ $contact_email = "mailto:ticket@c3heaven.de"; $default_theme = 1; // Anzahl der News, die auf einer Seite ausgeben werden koennen... -$DISPLAY_NEWS = 6; +$display_news = 6; // Anzahl Stunden bis zum Austragen eigener Schichten -$LETZTES_AUSTRAGEN = 3; +$last_unsubscribe = 3; // Setzt den zu verwendenden Crypto-Algorismus (entsprechend der Dokumentation von crypt()). // Falls ein Benutzerpasswort in einem anderen Format gespeichert ist, diff --git a/includes/controller/angeltypes_controller.php b/includes/controller/angeltypes_controller.php index de4b8a49..12d5287a 100644 --- a/includes/controller/angeltypes_controller.php +++ b/includes/controller/angeltypes_controller.php @@ -2,6 +2,8 @@ /** * Text for Angeltype related links. + * + * @return string */ function angeltypes_title() { @@ -10,15 +12,14 @@ function angeltypes_title() /** * Route angeltype actions. + * + * @return array */ function angeltypes_controller() { $action = strip_request_item('action', 'list'); switch ($action) { - default: - case 'list': - return angeltypes_list_controller(); case 'view': return angeltype_controller(); case 'edit': @@ -27,13 +28,17 @@ function angeltypes_controller() return angeltype_delete_controller(); case 'about': return angeltypes_about_controller(); + case 'list': + default: + return angeltypes_list_controller(); } } /** * Path to angeltype view. * - * @param AngelType $angeltype_id + * @param int $angeltype_id AngelType id + * @return string */ function angeltype_link($angeltype_id) { @@ -42,6 +47,8 @@ function angeltype_link($angeltype_id) /** * Job description for all angeltypes (public to everyone) + * + * @return array */ function angeltypes_about_controller() { @@ -61,6 +68,8 @@ function angeltypes_about_controller() /** * Delete an Angeltype. + * + * @return array */ function angeltype_delete_controller() { @@ -86,6 +95,8 @@ function angeltype_delete_controller() /** * Change an Angeltype. + * + * @return array */ function angeltype_edit_controller() { @@ -151,6 +162,8 @@ function angeltype_edit_controller() /** * View details of a given angeltype. + * + * @return array */ function angeltype_controller() { @@ -182,6 +195,8 @@ function angeltype_controller() /** * View a list of all angeltypes. + * + * @return array */ function angeltypes_list_controller() { @@ -242,6 +257,8 @@ function angeltypes_list_controller() /** * Loads an angeltype from given angeltype_id request param. + * + * @return array */ function load_angeltype() { diff --git a/includes/controller/event_config_controller.php b/includes/controller/event_config_controller.php index 623a2a7a..709d1b2a 100644 --- a/includes/controller/event_config_controller.php +++ b/includes/controller/event_config_controller.php @@ -1,10 +1,16 @@ ' . $user_angeltype['name'] . ' (+' . $user_angeltype['count'] . ')' . ''; + $unconfirmed_links[] = '' . $user_angeltype['name'] + . ' (+' . $user_angeltype['count'] . ')' + . ''; } return sprintf(ngettext("There is %d unconfirmed angeltype.", "There are %d unconfirmed angeltypes.", @@ -25,6 +32,8 @@ function user_angeltypes_unconfirmed_hint() /** * Remove all unconfirmed users from a specific angeltype. + * + * @return array */ function user_angeltypes_delete_all_controller() { @@ -62,6 +71,8 @@ function user_angeltypes_delete_all_controller() /** * Confirm all unconfirmed users for an angeltype. + * + * @return array */ function user_angeltypes_confirm_all_controller() { @@ -105,6 +116,8 @@ function user_angeltypes_confirm_all_controller() /** * Confirm an user for an angeltype. + * + * @return array */ function user_angeltype_confirm_controller() { @@ -165,6 +178,8 @@ function user_angeltype_confirm_controller() /** * Remove a user from an Angeltype. + * + * @return array */ function user_angeltype_delete_controller() { @@ -219,10 +234,13 @@ function user_angeltype_delete_controller() /** * Update an UserAngelType. + * + * @return array */ function user_angeltype_update_controller() { global $privileges; + $supporter = false; if (!in_array('admin_angel_types', $privileges)) { error(_("You are not allowed to set supporter rights.")); @@ -337,6 +355,9 @@ function user_angeltype_add_controller() /** * A user joins an angeltype. + * + * @param array $angeltype + * @return array */ function user_angeltype_join_controller($angeltype) { @@ -375,6 +396,8 @@ function user_angeltype_join_controller($angeltype) /** * Route UserAngelType actions. + * + * @return array */ function user_angeltypes_controller() { @@ -397,5 +420,6 @@ function user_angeltypes_controller() return user_angeltype_add_controller(); default: redirect(page_link_to('angeltypes')); + exit; } } diff --git a/includes/controller/user_driver_licenses_controller.php b/includes/controller/user_driver_licenses_controller.php index a499eff7..f2a1c521 100644 --- a/includes/controller/user_driver_licenses_controller.php +++ b/includes/controller/user_driver_licenses_controller.php @@ -3,6 +3,8 @@ /** * Generates a hint, if user joined angeltypes that require a driving license and the user has no driver license * information provided. + * + * @return string|null */ function user_driver_license_required_hint() { @@ -30,6 +32,8 @@ function user_driver_license_required_hint() /** * Route user driver licenses actions. + * + * @return array */ function user_driver_licenses_controller() { @@ -51,7 +55,8 @@ function user_driver_licenses_controller() /** * Link to user driver license edit page for given user. * - * @param User $user + * @param array $user + * @return string */ function user_driver_license_edit_link($user = null) { @@ -63,6 +68,8 @@ function user_driver_license_edit_link($user = null) /** * Loads the user for the driver license. + * + * @return array */ function user_driver_license_load_user() { @@ -82,6 +89,8 @@ function user_driver_license_load_user() /** * Edit a users driver license information. + * + * @return array */ function user_driver_license_edit_controller() { diff --git a/includes/controller/users_controller.php b/includes/controller/users_controller.php index 4a946aa8..a9f7dd61 100644 --- a/includes/controller/users_controller.php +++ b/includes/controller/users_controller.php @@ -4,6 +4,8 @@ use Engelsystem\ShiftsFilter; /** * Route user actions. + * + * @return array */ function users_controller() { @@ -18,22 +20,22 @@ function users_controller() } switch ($_REQUEST['action']) { - default: - case 'list': - return users_list_controller(); case 'view': return user_controller(); - case 'edit': - return user_edit_controller(); case 'delete': return user_delete_controller(); case 'edit_vouchers': return user_edit_vouchers_controller(); + case 'list': + default: + return users_list_controller(); } } /** * Delete a user, requires to enter own password for reasons. + * + * @return array */ function user_delete_controller() { @@ -85,26 +87,44 @@ function user_delete_controller() ]; } +/** + * @return string + */ function users_link() { return page_link_to('users'); } +/** + * @param array $user + * @return string + */ function user_edit_link($user) { return page_link_to('admin_user') . '&user_id=' . $user['UID']; } +/** + * @param array $user + * @return string + */ function user_delete_link($user) { return page_link_to('users') . '&action=delete&user_id=' . $user['UID']; } +/** + * @param array $user + * @return string + */ function user_link($user) { return page_link_to('users') . '&action=view&user_id=' . $user['UID']; } +/** + * @return array + */ function user_edit_vouchers_controller() { global $privileges, $user; @@ -122,6 +142,7 @@ function user_edit_vouchers_controller() if (isset($_REQUEST['submit'])) { $valid = true; + $vouchers = ''; if (isset($_REQUEST['vouchers']) && test_request_int('vouchers') && trim($_REQUEST['vouchers']) >= 0) { $vouchers = trim($_REQUEST['vouchers']); } else { @@ -151,6 +172,9 @@ function user_edit_vouchers_controller() ]; } +/** + * @return array + */ function user_controller() { global $privileges, $user; @@ -167,7 +191,13 @@ function user_controller() $shifts = Shifts_by_user($user_source, in_array("user_shifts_admin", $privileges)); foreach ($shifts as &$shift) { // TODO: Move queries to model - $shift['needed_angeltypes'] = sql_select("SELECT DISTINCT `AngelTypes`.* FROM `ShiftEntry` JOIN `AngelTypes` ON `ShiftEntry`.`TID`=`AngelTypes`.`id` WHERE `ShiftEntry`.`SID`='" . sql_escape($shift['SID']) . "' ORDER BY `AngelTypes`.`name`"); + $shift['needed_angeltypes'] = sql_select(" + SELECT DISTINCT `AngelTypes`.* + FROM `ShiftEntry` + JOIN `AngelTypes` ON `ShiftEntry`.`TID`=`AngelTypes`.`id` + WHERE `ShiftEntry`.`SID`='" . sql_escape($shift['SID']) . "' + ORDER BY `AngelTypes`.`name` + "); foreach ($shift['needed_angeltypes'] as &$needed_angeltype) { $needed_angeltype['users'] = sql_select(" SELECT `ShiftEntry`.`freeloaded`, `User`.* @@ -198,6 +228,8 @@ function user_controller() /** * List all users. + * + * @return array */ function users_list_controller() { @@ -238,6 +270,8 @@ function users_list_controller() /** * Second step of password recovery: set a new password using the token link from email + * + * @return string */ function user_password_recovery_set_new_controller() { @@ -273,6 +307,8 @@ function user_password_recovery_set_new_controller() /** * First step of password recovery: display a form that asks for your email and send email with recovery link + * + * @return string */ function user_password_recovery_start_controller() { @@ -317,18 +353,22 @@ function user_password_recovery_start_controller() /** * User password recovery in 2 steps. * (By email) + * + * @return string */ function user_password_recovery_controller() { if (isset($_REQUEST['token'])) { return user_password_recovery_set_new_controller(); - } else { - return user_password_recovery_start_controller(); } + + return user_password_recovery_start_controller(); } /** * Menu title for password recovery. + * + * @return string */ function user_password_recovery_title() { @@ -337,6 +377,8 @@ function user_password_recovery_title() /** * Loads a user from param user_id. + * + * return array */ function load_user() { @@ -357,6 +399,10 @@ function load_user() return $user; } +/** + * @param ShiftsFilter $shiftsFilter + * @return ShiftCalendarRenderer + */ function shiftCalendarRendererByShiftFilter(ShiftsFilter $shiftsFilter) { $shifts = Shifts_by_ShiftsFilter($shiftsFilter); @@ -392,6 +438,7 @@ function shiftCalendarRendererByShiftFilter(ShiftsFilter $shiftsFilter) $filtered_shifts = []; foreach ($shifts as $shift) { $needed_angels_count = 0; + $taken = 0; foreach ($needed_angeltypes[$shift['SID']] as $needed_angeltype) { $taken = 0; foreach ($shift_entries[$shift['SID']] as $shift_entry) { diff --git a/includes/engelsystem_provider.php b/includes/engelsystem_provider.php index 176933e0..1a5f5d86 100644 --- a/includes/engelsystem_provider.php +++ b/includes/engelsystem_provider.php @@ -68,6 +68,7 @@ require_once realpath(__DIR__ . '/../includes/helper/email_helper.php'); require_once realpath(__DIR__ . '/../includes/mailer/shifts_mailer.php'); require_once realpath(__DIR__ . '/../includes/mailer/users_mailer.php'); +$config = []; require_once realpath(__DIR__ . '/../config/config.default.php'); if (file_exists(realpath(__DIR__ . '/../config/config.php'))) { require_once realpath(__DIR__ . '/../config/config.php'); diff --git a/includes/helper/email_helper.php b/includes/helper/email_helper.php index 35bdbc9a..18203ecb 100644 --- a/includes/helper/email_helper.php +++ b/includes/helper/email_helper.php @@ -1,5 +1,12 @@ "); + $result = mail( + $address, + $title, + $message, + "Content-Type: text/plain; charset=UTF-8\r\nFrom: Engelsystem " + ); + if ($result === false) { engelsystem_error('Unable to send email.'); } + + return true; } diff --git a/includes/helper/graph_helper.php b/includes/helper/graph_helper.php index d844213c..12c7df6c 100644 --- a/includes/helper/graph_helper.php +++ b/includes/helper/graph_helper.php @@ -3,10 +3,12 @@ /** * Renders a bargraph * - * @param string $key keyname of the x-axis - * @param array $row_names keynames for the data rows - * @param unknown $colors colors for the data rows - * @param unknown $data the data + * @param string $dom_id + * @param string $key key name of the x-axis + * @param array $row_names key names for the data rows + * @param array $colors colors for the data rows + * @param array $data the data + * @return string */ function bargraph($dom_id, $key, $row_names, $colors, $data) { diff --git a/includes/helper/internationalization_helper.php b/includes/helper/internationalization_helper.php index d4df1cb7..ee9339e2 100644 --- a/includes/helper/internationalization_helper.php +++ b/includes/helper/internationalization_helper.php @@ -8,6 +8,8 @@ $default_locale = 'en_US.UTF-8'; /** * Return currently active locale + * + * @return string */ function locale() { @@ -16,6 +18,8 @@ function locale() /** * Returns two letter language code from currently active locale + * + * @return string */ function locale_short() { @@ -59,7 +63,7 @@ function gettext_locale($locale = null) /** * Renders language selection. * - * @return string + * @return array */ function make_langselect() { diff --git a/includes/helper/message_helper.php b/includes/helper/message_helper.php index a085aa0e..613ac32e 100644 --- a/includes/helper/message_helper.php +++ b/includes/helper/message_helper.php @@ -2,6 +2,8 @@ /** * Gibt zwischengespeicherte Fehlermeldungen zurück und löscht den Zwischenspeicher + * + * @return string */ function msg() { @@ -15,34 +17,51 @@ function msg() /** * Rendert eine Information + * + * @param string $msg + * @param bool $immediately + * @return string */ -function info($msg, $immediatly = false) +function info($msg, $immediately = false) { - return alert('info', $msg, $immediatly); + return alert('info', $msg, $immediately); } /** * Rendert eine Fehlermeldung + * + * @param string $msg + * @param bool $immediately + * @return string */ -function error($msg, $immediatly = false) +function error($msg, $immediately = false) { - return alert('danger', $msg, $immediatly); + return alert('danger', $msg, $immediately); } /** * Rendert eine Erfolgsmeldung + * + * @param string $msg + * @param bool $immediately + * @return string */ -function success($msg, $immediatly = false) +function success($msg, $immediately = false) { - return alert('success', $msg, $immediatly); + return alert('success', $msg, $immediately); } /** * Renders an alert with given alert-* class. + * + * @param string $class + * @param string $msg + * @param bool $immediately + * @return string|null */ -function alert($class, $msg, $immediatly = false) +function alert($class, $msg, $immediately = false) { - if ($immediatly) { + if ($immediately) { if ($msg == "") { return ""; } @@ -53,4 +72,6 @@ function alert($class, $msg, $immediatly = false) $_SESSION['msg'] = ""; } $_SESSION['msg'] .= alert($class, $msg, true); + + return null; } diff --git a/includes/mailer/shifts_mailer.php b/includes/mailer/shifts_mailer.php index e000c927..76426dc7 100644 --- a/includes/mailer/shifts_mailer.php +++ b/includes/mailer/shifts_mailer.php @@ -1,24 +1,28 @@ $angeltype['contact_email'] ]; } + return null; } /** * Delete an Angeltype. * - * @param Angeltype $angeltype + * @param array $angeltype + * @return mysqli_result */ function AngelType_delete($angeltype) { @@ -92,8 +93,8 @@ function AngelType_delete($angeltype) /** * Update Angeltype. * - * @param Angeltype $angeltype - * The angeltype + * @param array $angeltype The angeltype + * @return mysqli_result */ function AngelType_update($angeltype) { @@ -119,9 +120,8 @@ function AngelType_update($angeltype) /** * Create an Angeltype. * - * @param Angeltype $angeltype - * The angeltype - * @return the created angeltype + * @param array $angeltype The angeltype + * @return array the created angeltype */ function AngelType_create($angeltype) { @@ -148,10 +148,9 @@ function AngelType_create($angeltype) * Validates a name for angeltypes. * Returns ValidationResult containing validation success and validated name. * - * @param string $name - * Wanted name for the angeltype - * @param AngelType $angeltype - * The angeltype the name is for + * @param string $name Wanted name for the angeltype + * @param array $angeltype The angeltype the name is for + * * @return ValidationResult result and validated name */ function AngelType_validate_name($name, $angeltype) @@ -180,7 +179,8 @@ function AngelType_validate_name($name, $angeltype) /** * Returns all angeltypes and subscription state to each of them for given user. * - * @param User $user + * @param array $user + * @return array */ function AngelTypes_with_user($user) { @@ -201,6 +201,8 @@ function AngelTypes_with_user($user) /** * Returns all angeltypes. + * + * @return array */ function AngelTypes() { @@ -216,6 +218,8 @@ function AngelTypes() /** * Returns AngelType id array + * + * @return array */ function AngelType_ids() { @@ -229,8 +233,8 @@ function AngelType_ids() /** * Returns angelType by id. * - * @param $angeltype_id angelType - * ID + * @param int $angeltype_id angelType ID + * @return array */ function AngelType($angeltype_id) { diff --git a/includes/model/EventConfig_model.php b/includes/model/EventConfig_model.php index 584c1515..93ba1e72 100644 --- a/includes/model/EventConfig_model.php +++ b/includes/model/EventConfig_model.php @@ -2,6 +2,8 @@ /** * Get event config. + * + * łreturn array|false|null */ function EventConfig() { @@ -25,6 +27,7 @@ function EventConfig() * @param int $event_end_date * @param int $teardown_end_date * @param string $event_welcome_msg + * @return mysqli_result|false */ function EventConfig_update( $event_name, @@ -43,6 +46,7 @@ function EventConfig_update( `teardown_end_date`=" . sql_null($teardown_end_date) . ", `event_welcome_msg`=" . sql_null($event_welcome_msg)); } + return sql_query("UPDATE `EventConfig` SET `event_name`=" . sql_null($event_name) . ", `buildup_start_date`=" . sql_null($buildup_start_date) . ", diff --git a/includes/model/LogEntries_model.php b/includes/model/LogEntries_model.php index 47e48f6f..7bcb868e 100644 --- a/includes/model/LogEntries_model.php +++ b/includes/model/LogEntries_model.php @@ -3,9 +3,9 @@ /** * Creates a log entry. * - * @param $nick Username - * @param $message Log - * Message + * @param string $nick Username + * @param string $message Log Message + * @return mysqli_result|false */ function LogEntry_create($nick, $message) { @@ -14,6 +14,8 @@ function LogEntry_create($nick, $message) /** * Returns log entries with maximum count of 10000. + * + * @return array|false */ function LogEntries() { @@ -22,6 +24,9 @@ function LogEntries() /** * Returns log entries filtered by a keyword + * + * @param string $keyword + * @return array|false */ function LogEntries_filter($keyword) { @@ -33,6 +38,8 @@ function LogEntries_filter($keyword) /** * Delete all log entries. + * + * @return mysqli_result|false */ function LogEntries_clear_all() { diff --git a/includes/model/Message_model.php b/includes/model/Message_model.php index 39eada71..57277fbe 100644 --- a/includes/model/Message_model.php +++ b/includes/model/Message_model.php @@ -2,6 +2,8 @@ /** * Returns Message id array + * + * @return array|false */ function Message_ids() { @@ -11,8 +13,8 @@ function Message_ids() /** * Returns message by id. * - * @param $message_id message - * ID + * @param int $message_id message ID + * @return array|false|null */ function Message($message_id) { @@ -31,10 +33,9 @@ function Message($message_id) * TODO: global $user con not be used in model! * send message * - * @param $receiver_user_id User - * ID of Reciever - * @param $text Text - * of Message + * @param int $receiver_user_id User ID of Reciever + * @param string $text Text of Message + * @return bool */ function Message_send($receiver_user_id, $text) { diff --git a/includes/model/NeededAngelTypes_model.php b/includes/model/NeededAngelTypes_model.php index 6a929f2f..ef4698de 100644 --- a/includes/model/NeededAngelTypes_model.php +++ b/includes/model/NeededAngelTypes_model.php @@ -15,6 +15,7 @@ * The room. Can be null, but then a shift_id must be given. * @param int $count * How many angels are needed? + * @return false|int */ function NeededAngelType_add($shift_id, $angeltype_id, $room_id, $count) { @@ -33,8 +34,8 @@ function NeededAngelType_add($shift_id, $angeltype_id, $room_id, $count) /** * Deletes all needed angel types from given shift. * - * @param int $shift_id - * id of the shift + * @param int $shift_id id of the shift + * @return mysqli_result|false */ function NeededAngelTypes_delete_by_shift($shift_id) { @@ -44,8 +45,8 @@ function NeededAngelTypes_delete_by_shift($shift_id) /** * Deletes all needed angel types from given room. * - * @param int $room_id - * id of the room + * @param int $room_id id of the room + * @return mysqli_result|false */ function NeededAngelTypes_delete_by_room($room_id) { @@ -55,8 +56,8 @@ function NeededAngelTypes_delete_by_room($room_id) /** * Returns all needed angeltypes and already taken needs. * - * @param int $shiftID - * id of shift + * @param int $shiftId id of shift + * @return array */ function NeededAngelTypes_by_shift($shiftId) { diff --git a/includes/model/Room_model.php b/includes/model/Room_model.php index 4c097f23..9c202c1e 100644 --- a/includes/model/Room_model.php +++ b/includes/model/Room_model.php @@ -4,6 +4,7 @@ * returns a list of rooms. * * @param boolean $show_all returns also hidden rooms when true + * @return array|false */ function Rooms($show_all = false) { @@ -14,6 +15,7 @@ function Rooms($show_all = false) * Delete a room * * @param int $room_id + * @return mysqli_result|false */ function Room_delete($room_id) { @@ -29,15 +31,19 @@ function Room_delete($room_id) * Is this a frab imported room? * @param boolean $public * Is the room visible for angels? + * @param int $number + * Room number + * @return false|int */ -function Room_create($name, $from_frab, $public) +function Room_create($name, $from_frab, $public, $number = null) { $result = sql_query(" INSERT INTO `Room` SET `Name`='" . sql_escape($name) . "', `FromPentabarf`='" . sql_escape($from_frab ? 'Y' : '') . "', `show`='" . sql_escape($public ? 'Y' : '') . "', - `Number`=0"); + `Number`=" . (int)$number + ); if ($result === false) { return false; } @@ -47,7 +53,8 @@ function Room_create($name, $from_frab, $public) /** * Returns room by id. * - * @param $room_id RID + * @param int $room_id RID + * @return array|false */ function Room($room_id) { diff --git a/includes/model/ShiftEntry_model.php b/includes/model/ShiftEntry_model.php index a0755e3c..84cdb6d8 100644 --- a/includes/model/ShiftEntry_model.php +++ b/includes/model/ShiftEntry_model.php @@ -3,6 +3,8 @@ /** * Returns an array with the attributes of shift entries. * FIXME! Needs entity object. + * + * @return array */ function ShiftEntry_new() { @@ -19,14 +21,19 @@ function ShiftEntry_new() /** * Counts all freeloaded shifts. + * + * @return int */ function ShiftEntries_freeleaded_count() { - return sql_select_single_cell("SELECT COUNT(*) FROM `ShiftEntry` WHERE `freeloaded` = 1"); + return (int)sql_select_single_cell("SELECT COUNT(*) FROM `ShiftEntry` WHERE `freeloaded` = 1"); } /** * List users subsribed to a given shift. + * + * @param int $shift_id + * @return array|false */ function ShiftEntries_by_shift($shift_id) { @@ -52,7 +59,8 @@ function ShiftEntries_by_shift($shift_id) /** * Create a new shift entry. * - * @param ShiftEntry $shift_entry + * @param array $shift_entry + * @return mysqli_result|false */ function ShiftEntry_create($shift_entry) { @@ -68,6 +76,9 @@ function ShiftEntry_create($shift_entry) /** * Update a shift entry. + * + * @param array $shift_entry + * @return false|mysqli_result */ function ShiftEntry_update($shift_entry) { @@ -80,6 +91,9 @@ function ShiftEntry_update($shift_entry) /** * Get a shift entry. + * + * @param int $shift_entry_id + * @return array|false|null */ function ShiftEntry($shift_entry_id) { @@ -95,6 +109,9 @@ function ShiftEntry($shift_entry_id) /** * Delete a shift entry. + * + * @param int $shift_entry_id + * @return mysqli_result|false */ function ShiftEntry_delete($shift_entry_id) { @@ -106,7 +123,8 @@ function ShiftEntry_delete($shift_entry_id) /** * Returns next (or current) shifts of given user. * - * @param User $user + * @param array $user + * @return array|false */ function ShiftEntries_upcoming_for_user($user) { @@ -124,7 +142,8 @@ function ShiftEntries_upcoming_for_user($user) /** * Returns shifts completed by the given user. * - * @param User $user + * @param array $user + * @return array|false */ function ShiftEntries_finished_by_user($user) { @@ -145,6 +164,7 @@ function ShiftEntries_finished_by_user($user) * * @param int $shift_id * @param int $angeltype_id + * @return array|false */ function ShiftEntries_by_shift_and_angeltype($shift_id, $angeltype_id) { @@ -162,6 +182,9 @@ function ShiftEntries_by_shift_and_angeltype($shift_id, $angeltype_id) /** * Returns all freeloaded shifts for given user. + * + * @param array $user + * @return array|false */ function ShiftEntries_freeloaded_by_user($user) { diff --git a/includes/model/ShiftSignupState.php b/includes/model/ShiftSignupState.php index d5c7f457..9b3de496 100644 --- a/includes/model/ShiftSignupState.php +++ b/includes/model/ShiftSignupState.php @@ -8,7 +8,6 @@ namespace Engelsystem; */ class ShiftSignupState { - /** * Shift has free places */ @@ -44,10 +43,18 @@ class ShiftSignupState */ const SIGNED_UP = 'SIGNED_UP'; + /** @var string */ private $state; + /** @var int */ private $freeEntries; + /** + * ShiftSignupState constructor. + * + * @param string $state + * @param int $free_entries + */ public function __construct($state, $free_entries) { $this->state = $state; @@ -69,6 +76,10 @@ class ShiftSignupState } } + /** + * @param string $state + * @return int + */ private function valueForState($state) { switch ($state) { @@ -88,11 +99,15 @@ class ShiftSignupState case ShiftSignupState::OCCUPIED: case ShiftSignupState::ADMIN: return 60; + default: + return 0; } } /** * Returns true, if signup is allowed + * + * @return bool */ public function isSignupAllowed() { @@ -106,6 +121,8 @@ class ShiftSignupState /** * Return the shift signup state + * + * @return string */ public function getState() { @@ -114,6 +131,8 @@ class ShiftSignupState /** * How many places are free in this shift for the angeltype? + * + * @return int */ public function getFreeEntries() { diff --git a/includes/model/ShiftTypes_model.php b/includes/model/ShiftTypes_model.php index 8b1d56b8..ba8fa2c1 100644 --- a/includes/model/ShiftTypes_model.php +++ b/includes/model/ShiftTypes_model.php @@ -4,6 +4,7 @@ * Delete a shift type. * * @param int $shifttype_id + * @return mysqli_result|false */ function ShiftType_delete($shifttype_id) { @@ -17,6 +18,7 @@ function ShiftType_delete($shifttype_id) * @param string $name * @param int $angeltype_id * @param string $description + * @return mysqli_result|false */ function ShiftType_update($shifttype_id, $name, $angeltype_id, $description) { @@ -35,7 +37,7 @@ function ShiftType_update($shifttype_id, $name, $angeltype_id, $description) * @param string $name * @param int $angeltype_id * @param string $description - * @return new shifttype id + * @return int|false new shifttype id */ function ShiftType_create($name, $angeltype_id, $description) { @@ -55,6 +57,7 @@ function ShiftType_create($name, $angeltype_id, $description) * Get a shift type by id. * * @param int $shifttype_id + * @return array|null */ function ShiftType($shifttype_id) { @@ -70,6 +73,8 @@ function ShiftType($shifttype_id) /** * Get all shift types. + * + * @return array|false */ function ShiftTypes() { diff --git a/includes/model/ShiftsFilter.php b/includes/model/ShiftsFilter.php index 1e8d49cf..47ef50d7 100644 --- a/includes/model/ShiftsFilter.php +++ b/includes/model/ShiftsFilter.php @@ -9,12 +9,11 @@ namespace Engelsystem; */ class ShiftsFilter { - /** * How long can the time interval be? + * 86400 = one day */ const MAX_DURATION = 86400; - // one day /** * Shift is completely full. @@ -33,16 +32,28 @@ class ShiftsFilter */ private $userShiftsAdmin; + /** @var int[] */ private $filled = []; + /** @var int[] */ private $rooms = []; + /** @var int[] */ private $types = []; + /** @var int unix timestamp */ private $startTime = null; + /** @var int unix timestamp */ private $endTime = null; + /** + * ShiftsFilter constructor. + * + * @param bool $user_shifts_admin + * @param int[] $rooms + * @param int[] $types + */ public function __construct($user_shifts_admin, $rooms, $types) { $this->user_shifts_admin = $user_shifts_admin; @@ -58,21 +69,33 @@ class ShiftsFilter } } + /** + * @return int unix timestamp + */ public function getStartTime() { return $this->startTime; } + /** + * @param int $startTime unix timestamp + */ public function setStartTime($startTime) { $this->startTime = $startTime; } + /** + * @return int unix timestamp + */ public function getEndTime() { return $this->endTime; } + /** + * @param int $endTime unix timestamp + */ public function setEndTime($endTime) { if ($endTime - $this->startTime > ShiftsFilter::MAX_DURATION) { @@ -81,6 +104,9 @@ class ShiftsFilter $this->endTime = $endTime; } + /** + * @return int[] + */ public function getTypes() { if (count($this->types) == 0) { @@ -89,11 +115,17 @@ class ShiftsFilter return $this->types; } + /** + * @param int[] $types + */ public function setTypes($types) { $this->types = $types; } + /** + * @return int[] + */ public function getRooms() { if (count($this->rooms) == 0) { @@ -102,26 +134,41 @@ class ShiftsFilter return $this->rooms; } + /** + * @param int[] $rooms + */ public function setRooms($rooms) { $this->rooms = $rooms; } + /** + * @return bool + */ public function isUserShiftsAdmin() { return $this->userShiftsAdmin; } + /** + * @param bool $userShiftsAdmin + */ public function setUserShiftsAdmin($userShiftsAdmin) { $this->userShiftsAdmin = $userShiftsAdmin; } + /** + * @return int[] + */ public function getFilled() { return $this->filled; } + /** + * @param int[] $filled + */ public function setFilled($filled) { $this->filled = $filled; diff --git a/includes/model/Shifts_model.php b/includes/model/Shifts_model.php index c489c63e..7c52d305 100644 --- a/includes/model/Shifts_model.php +++ b/includes/model/Shifts_model.php @@ -2,6 +2,10 @@ use Engelsystem\ShiftsFilter; use Engelsystem\ShiftSignupState; +/** + * @param array $room + * @return array + */ function Shifts_by_room($room) { $result = sql_select("SELECT * FROM `Shifts` WHERE `RID`=" . sql_escape($room['RID']) . " ORDER BY `start`"); @@ -11,6 +15,10 @@ function Shifts_by_room($room) return $result; } +/** + * @param ShiftsFilter $shiftsFilter + * @return array[] + */ function Shifts_by_ShiftsFilter(ShiftsFilter $shiftsFilter) { $SQL = "SELECT * FROM ( @@ -46,6 +54,10 @@ function Shifts_by_ShiftsFilter(ShiftsFilter $shiftsFilter) return $result; } +/** + * @param ShiftsFilter $shiftsFilter + * @return array + */ function NeededAngeltypes_by_ShiftsFilter(ShiftsFilter $shiftsFilter) { $SQL = " @@ -85,6 +97,11 @@ function NeededAngeltypes_by_ShiftsFilter(ShiftsFilter $shiftsFilter) return $result; } +/** + * @param array $shift + * @param array $angeltype + * @return array|null + */ function NeededAngeltype_by_Shift_and_Angeltype($shift, $angeltype) { $result = sql_select(" @@ -126,6 +143,10 @@ function NeededAngeltype_by_Shift_and_Angeltype($shift, $angeltype) return $result[0]; } +/** + * @param ShiftsFilter $shiftsFilter + * @return array + */ function ShiftEntries_by_ShiftsFilter(ShiftsFilter $shiftsFilter) { $SQL = " @@ -156,8 +177,9 @@ function ShiftEntries_by_ShiftsFilter(ShiftsFilter $shiftsFilter) /** * Check if a shift collides with other shifts (in time). * - * @param Shift $shift - * @param array $shifts + * @param array $shift + * @param array $shifts + * @return bool */ function Shift_collides($shift, $shifts) { @@ -173,6 +195,10 @@ function Shift_collides($shift, $shifts) /** * Returns the number of needed angels/free shift entries for an angeltype. + * + * @param array $needed_angeltype + * @param array[] $shift_entries + * @return int */ function Shift_free_entries($needed_angeltype, $shift_entries) { @@ -188,15 +214,14 @@ function Shift_free_entries($needed_angeltype, $shift_entries) /** * Check if shift signup is allowed from the end users point of view (no admin like privileges) * - * @param Shift $shift - * The shift - * @param AngelType $angeltype - * The angeltype to which the user wants to sign up - * @param array $user_shifts - * List of the users shifts - * @param boolean $angeltype_supporter - * True, if the user has angeltype supporter rights for the angeltype, which enables him to sign - * somebody up for the shift. + * @param array $user + * @param array $shift The shift + * @param array $angeltype The angeltype to which the user wants to sign up + * @param array|null $user_angeltype + * @param array|null $user_shifts List of the users shifts + * @param array $needed_angeltype + * @param array[] $shift_entries + * @return ShiftSignupState */ function Shift_signup_allowed_angel( $user, @@ -266,6 +291,13 @@ function Shift_signup_allowed_angel( /** * Check if an angeltype supporter can sign up a user to a shift. + * + * @TODO: remove $angeltype + * + * @param array|null $angeltype + * @param array $needed_angeltype + * @param array[] $shift_entries + * @return ShiftSignupState */ function Shift_signup_allowed_angeltype_supporter($angeltype, $needed_angeltype, $shift_entries) { @@ -280,10 +312,12 @@ function Shift_signup_allowed_angeltype_supporter($angeltype, $needed_angeltype, /** * Check if an admin can sign up a user to a shift. * - * @param Shift $shift - * The shift - * @param AngelType $angeltype - * The angeltype to which the user wants to sign up + * @TODO: remove $angeltype + * + * @param array|null $angeltype The angeltype to which the user wants to sign up + * @param array $needed_angeltype + * @param array[] $shift_entries + * @return ShiftSignupState */ function Shift_signup_allowed_admin($angeltype, $needed_angeltype, $shift_entries) { @@ -300,12 +334,14 @@ function Shift_signup_allowed_admin($angeltype, $needed_angeltype, $shift_entrie /** * Check if an angel can sign up for given shift. * - * @param Shift $shift - * The shift - * @param AngelType $angeltype - * The angeltype to which the user wants to sign up - * @param array $user_shifts - * List of the users shifts + * @param array $signup_user + * @param array $shift The shift + * @param array $angeltype The angeltype to which the user wants to sign up + * @param array|null $user_angeltype + * @param array|null $user_shifts List of the users shifts + * @param array $needed_angeltype + * @param array[] $shift_entries + * @return ShiftSignupState */ function Shift_signup_allowed( $signup_user, @@ -342,6 +378,9 @@ function Shift_signup_allowed( /** * Delete a shift by its external id. + * + * @param int $shift_psid + * @return mysqli_result|false */ function Shift_delete_by_psid($shift_psid) { @@ -350,6 +389,9 @@ function Shift_delete_by_psid($shift_psid) /** * Delete a shift. + * + * @param int $shift_id + * @return mysqli_result */ function Shift_delete($shift_id) { @@ -364,6 +406,9 @@ function Shift_delete($shift_id) /** * Update a shift. + * + * @param array $shift + * @return mysqli_result|false */ function Shift_update($shift) { @@ -388,6 +433,9 @@ function Shift_update($shift) /** * Update a shift by its external id. + * + * @param array $shift + * @return mysqli_result|false|null */ function Shift_update_by_psid($shift) { @@ -405,7 +453,8 @@ function Shift_update_by_psid($shift) /** * Create a new shift. * - * @return new shift id or false + * @param array $shift + * @return int|false shift id or false */ function Shift_create($shift) { @@ -430,20 +479,24 @@ function Shift_create($shift) /** * Return users shifts. + * + * @param array $user + * @param bool $include_freeload_comments + * @return array */ function Shifts_by_user($user, $include_freeload_comments = false) { $result = sql_select(" - SELECT `ShiftTypes`.`id` as `shifttype_id`, `ShiftTypes`.`name`, - `ShiftEntry`.`id`, `ShiftEntry`.`SID`, `ShiftEntry`.`TID`, `ShiftEntry`.`UID`, `ShiftEntry`.`freeloaded`, `ShiftEntry`.`Comment`, - " . ($include_freeload_comments ? "`ShiftEntry`.`freeload_comment`, " : "") . " - `Shifts`.*, `Room`.* - FROM `ShiftEntry` - JOIN `Shifts` ON (`ShiftEntry`.`SID` = `Shifts`.`SID`) - JOIN `ShiftTypes` ON (`ShiftTypes`.`id` = `Shifts`.`shifttype_id`) - JOIN `Room` ON (`Shifts`.`RID` = `Room`.`RID`) - WHERE `UID`='" . sql_escape($user['UID']) . "' - ORDER BY `start` + SELECT `ShiftTypes`.`id` AS `shifttype_id`, `ShiftTypes`.`name`, + `ShiftEntry`.`id`, `ShiftEntry`.`SID`, `ShiftEntry`.`TID`, `ShiftEntry`.`UID`, `ShiftEntry`.`freeloaded`, `ShiftEntry`.`Comment`, + " . ($include_freeload_comments ? "`ShiftEntry`.`freeload_comment`, " : "") . " + `Shifts`.*, `Room`.* + FROM `ShiftEntry` + JOIN `Shifts` ON (`ShiftEntry`.`SID` = `Shifts`.`SID`) + JOIN `ShiftTypes` ON (`ShiftTypes`.`id` = `Shifts`.`shifttype_id`) + JOIN `Room` ON (`Shifts`.`RID` = `Room`.`RID`) + WHERE `UID`='" . sql_escape($user['UID']) . "' + ORDER BY `start` "); if ($result === false) { engelsystem_error('Unable to load users shifts.'); @@ -454,8 +507,8 @@ function Shifts_by_user($user, $include_freeload_comments = false) /** * Returns Shift by id. * - * @param $shift_id Shift - * ID + * @param int $shift_id Shift ID + * @return array|null */ function Shift($shift_id) { @@ -494,14 +547,16 @@ function Shift($shift_id) /** * Returns all shifts with needed angeltypes and count of subscribed jobs. + * + * @return array|false */ function Shifts() { $shifts_source = sql_select(" - SELECT `ShiftTypes`.`name`, `Shifts`.*, `Room`.`RID`, `Room`.`Name` AS `room_name` - FROM `Shifts` - JOIN `ShiftTypes` ON (`ShiftTypes`.`id` = `Shifts`.`shifttype_id`) - JOIN `Room` ON `Room`.`RID` = `Shifts`.`RID` + SELECT `ShiftTypes`.`name`, `Shifts`.*, `Room`.`RID`, `Room`.`Name` AS `room_name` + FROM `Shifts` + JOIN `ShiftTypes` ON (`ShiftTypes`.`id` = `Shifts`.`shifttype_id`) + JOIN `Room` ON `Room`.`RID` = `Shifts`.`RID` "); if ($shifts_source === false) { return false; diff --git a/includes/model/UserAngelTypes_model.php b/includes/model/UserAngelTypes_model.php index fae2b996..4b071847 100644 --- a/includes/model/UserAngelTypes_model.php +++ b/includes/model/UserAngelTypes_model.php @@ -7,10 +7,8 @@ /** * Checks if a user joined an angeltype. * - * @param User $user - * The user to be checked - * @param Angeltype $angeltype - * The angeltype to be checked + * @param array $user The user to be checked + * @param array $angeltype The angeltype to be checked * @return boolean */ function UserAngelType_exists($user, $angeltype) @@ -26,7 +24,8 @@ function UserAngelType_exists($user, $angeltype) /** * List users angeltypes. * - * @param User $user + * @param array $user + * @return array|false */ function User_angeltypes($user) { @@ -46,7 +45,8 @@ function User_angeltypes($user) /** * Gets unconfirmed user angeltypes for angeltypes of which the given user is a supporter. * - * @param User $user + * @param array $user + * @return array */ function User_unconfirmed_AngelTypes($user) { @@ -74,8 +74,9 @@ function User_unconfirmed_AngelTypes($user) /** * Returns true if user is angeltype supporter or has privilege admin_user_angeltypes. * - * @param User $user - * @param AngelType $angeltype + * @param array $user + * @param array $angeltype + * @return bool */ function User_is_AngelType_supporter(&$user, $angeltype) { @@ -97,6 +98,7 @@ function User_is_AngelType_supporter(&$user, $angeltype) * * @param int $user_angeltype_id * @param bool $supporter + * @return mysqli_result */ function UserAngelType_update($user_angeltype_id, $supporter) { @@ -116,6 +118,7 @@ function UserAngelType_update($user_angeltype_id, $supporter) * Delete all unconfirmed UserAngelTypes for given Angeltype. * * @param int $angeltype_id + * @return mysqli_result */ function UserAngelTypes_delete_all($angeltype_id) { @@ -133,8 +136,9 @@ function UserAngelTypes_delete_all($angeltype_id) /** * Confirm all unconfirmed UserAngelTypes for given Angeltype. * - * @param int $angeltype_id - * @param User $confirm_user + * @param int $angeltype_id + * @param array $confirm_user + * @return mysqli_result */ function UserAngelTypes_confirm_all($angeltype_id, $confirm_user) { @@ -153,8 +157,9 @@ function UserAngelTypes_confirm_all($angeltype_id, $confirm_user) /** * Confirm an UserAngelType with confirming user. * - * @param int $user_angeltype_id - * @param User $confirm_user + * @param int $user_angeltype_id + * @param array $confirm_user + * @return mysqli_result */ function UserAngelType_confirm($user_angeltype_id, $confirm_user) { @@ -172,7 +177,8 @@ function UserAngelType_confirm($user_angeltype_id, $confirm_user) /** * Delete an UserAngelType. * - * @param UserAngelType $user_angeltype + * @param array $user_angeltype + * @return mysqli_result|false */ function UserAngelType_delete($user_angeltype) { @@ -185,8 +191,9 @@ function UserAngelType_delete($user_angeltype) /** * Create an UserAngelType. * - * @param User $user - * @param Angeltype $angeltype + * @param array $user + * @param array $angeltype + * @return int */ function UserAngelType_create($user, $angeltype) { @@ -204,6 +211,7 @@ function UserAngelType_create($user, $angeltype) * Get an UserAngelType by its id. * * @param int $user_angeltype_id + * @return array|null */ function UserAngelType($user_angeltype_id) { @@ -224,8 +232,9 @@ function UserAngelType($user_angeltype_id) /** * Get an UserAngelType by user and angeltype. * - * @param User $user - * @param Angeltype $angeltype + * @param array $user + * @param array $angeltype + * @return array|null */ function UserAngelType_by_User_and_AngelType($user, $angeltype) { diff --git a/includes/model/UserDriverLicenses_model.php b/includes/model/UserDriverLicenses_model.php index a36b79c1..c1cd081b 100644 --- a/includes/model/UserDriverLicenses_model.php +++ b/includes/model/UserDriverLicenses_model.php @@ -3,6 +3,8 @@ /** * Returns a new empty UserDriverLicense * FIXME entity object needed + * + * @return array */ function UserDriverLicense_new() { @@ -20,8 +22,7 @@ function UserDriverLicense_new() /** * Is it valid? * - * @param UserDriverLicense $user_driver_license - * The UserDriverLicense to check + * @param array $user_driver_license The UserDriverLicense to check * @return boolean */ function UserDriverLicense_valid($user_driver_license) @@ -37,8 +38,8 @@ function UserDriverLicense_valid($user_driver_license) /** * Get a users driver license information * - * @param int $user_id - * The users id + * @param int $user_id The users id + * @return array|false|null */ function UserDriverLicense($user_id) { @@ -47,17 +48,20 @@ function UserDriverLicense($user_id) engelsystem_error('Unable to load user driver license.'); return false; } - if (count($user_driver_license) > 0) { - return $user_driver_license[0]; + + if (count($user_driver_license) == 0) { + return null; } - return null; + + return $user_driver_license[0]; } /** * Create a user's driver license entry * - * @param UserDriverLicense $user_driver_license - * The UserDriverLicense to create + * @param array $user_driver_license The UserDriverLicense to create + * @param array $user + * @return array */ function UserDriverLicenses_create($user_driver_license, $user) { @@ -80,8 +84,8 @@ function UserDriverLicenses_create($user_driver_license, $user) /** * Update a user's driver license entry * - * @param UserDriverLicense $user_driver_license - * The UserDriverLicense to update + * @param array $user_driver_license The UserDriverLicense to update + * @return mysqli_result */ function UserDriverLicenses_update($user_driver_license) { @@ -103,6 +107,7 @@ function UserDriverLicenses_update($user_driver_license) * Delete a user's driver license entry * * @param int $user_id + * @return mysqli_result */ function UserDriverLicenses_delete($user_id) { diff --git a/includes/model/UserGroups_model.php b/includes/model/UserGroups_model.php index bbef85b6..8716114d 100644 --- a/includes/model/UserGroups_model.php +++ b/includes/model/UserGroups_model.php @@ -3,7 +3,8 @@ /** * Returns users groups * - * @param User $user + * @param array $user + * @return array|false */ function User_groups($user) { diff --git a/includes/model/User_model.php b/includes/model/User_model.php index 1a09c160..c9987d4e 100644 --- a/includes/model/User_model.php +++ b/includes/model/User_model.php @@ -9,6 +9,7 @@ use Engelsystem\ValidationResult; * Delete a user * * @param int $user_id + * @return mysqli_result|false */ function User_delete($user_id) { @@ -18,7 +19,8 @@ function User_delete($user_id) /** * Update user. * - * @param User $user + * @param array $user + * @return mysqli_result|false */ function User_update($user) { @@ -53,27 +55,41 @@ function User_update($user) /** * Counts all forced active users. + * + * @return string|null */ function User_force_active_count() { return sql_select_single_cell("SELECT COUNT(*) FROM `User` WHERE `force_active` = 1"); } +/** + * @return string|null + */ function User_active_count() { return sql_select_single_cell("SELECT COUNT(*) FROM `User` WHERE `Aktiv` = 1"); } +/** + * @return string|null + */ function User_got_voucher_count() { return sql_select_single_cell("SELECT SUM(`got_voucher`) FROM `User`"); } +/** + * @return string|null + */ function User_arrived_count() { return sql_select_single_cell("SELECT COUNT(*) FROM `User` WHERE `Gekommen` = 1"); } +/** + * @return string|null + */ function User_tshirts_count() { return sql_select_single_cell("SELECT COUNT(*) FROM `User` WHERE `Tshirt` = 1"); @@ -81,6 +97,8 @@ function User_tshirts_count() /** * Returns all column names for sorting in an array. + * + * @return array */ function User_sortable_columns() { @@ -104,6 +122,7 @@ function User_sortable_columns() * Get all users, ordered by Nick by default or by given param. * * @param string $order_by + * @return array|false */ function Users($order_by = 'Nick') { @@ -113,7 +132,8 @@ function Users($order_by = 'Nick') /** * Returns true if user is freeloader * - * @param User $user + * @param array $user + * @return bool */ function User_is_freeloader($user) { @@ -125,7 +145,8 @@ function User_is_freeloader($user) /** * Returns all users that are not member of given angeltype. * - * @param Angeltype $angeltype + * @param array $angeltype Angeltype + * @return array */ function Users_by_angeltype_inverted($angeltype) { @@ -145,7 +166,8 @@ function Users_by_angeltype_inverted($angeltype) /** * Returns all members of given angeltype. * - * @param Angeltype $angeltype + * @param array $angeltype + * @return array */ function Users_by_angeltype($angeltype) { @@ -169,6 +191,8 @@ function Users_by_angeltype($angeltype) /** * Returns User id array + * + * @return array|false */ function User_ids() { @@ -179,6 +203,7 @@ function User_ids() * Strip unwanted characters from a users nick. * * @param string $nick + * @return string */ function User_validate_Nick($nick) { @@ -218,8 +243,7 @@ function User_validate_jabber($jabber) /** * Validate the planned arrival date * - * @param int $planned_arrival_date - * Unix timestamp + * @param int $planned_arrival_date Unix timestamp * @return ValidationResult */ function User_validate_planned_arrival_date($planned_arrival_date) @@ -282,7 +306,8 @@ function User_validate_planned_departure_date($planned_arrival_date, $planned_de /** * Returns user by id. * - * @param $user_id UID + * @param int $user_id UID + * @return array|null */ function User($user_id) { @@ -301,7 +326,7 @@ function User($user_id) * * @param string $api_key * User api key - * @return Matching user, null or false on error + * @return array|null Matching user, null on error */ function User_by_api_key($api_key) { @@ -319,7 +344,7 @@ function User_by_api_key($api_key) * Returns User by email. * * @param string $email - * @return Matching user, null or false on error + * @return array|null Matching user, null or false on error */ function User_by_email($email) { @@ -337,7 +362,7 @@ function User_by_email($email) * Returns User by password token. * * @param string $token - * @return Matching user, null or false on error + * @return array|null Matching user, null or false on error */ function User_by_password_recovery_token($token) { @@ -354,7 +379,9 @@ function User_by_password_recovery_token($token) /** * Generates a new api key for given user. * - * @param User $user + * @param array $user + * @param bool $log + * @return bool */ function User_reset_api_key(&$user, $log = true) { @@ -363,15 +390,19 @@ function User_reset_api_key(&$user, $log = true) if ($result === false) { return false; } + if ($log) { engelsystem_log(sprintf("API key resetted (%s).", User_Nick_render($user))); } + + return true; } /** * Generates a new password recovery token for given user. * - * @param User $user + * @param array $user + * @return string */ function User_generate_password_recovery_token(&$user) { @@ -384,6 +415,10 @@ function User_generate_password_recovery_token(&$user) return $user['password_recovery_token']; } +/** + * @param array $user + * @return float + */ function User_get_eligable_voucher_count(&$user) { global $voucher_settings; diff --git a/includes/model/ValidationResult.php b/includes/model/ValidationResult.php index b08e9d31..7f88b432 100644 --- a/includes/model/ValidationResult.php +++ b/includes/model/ValidationResult.php @@ -8,17 +8,15 @@ namespace Engelsystem; */ class ValidationResult { + /** @var bool */ private $valid; + /** @var mixed */ private $value; /** - * Constructor. - * - * @param boolean $valid - * Is the value valid? - * @param * $value - * The validated value + * @param boolean $valid Is the value valid? + * @param mixed $value The validated value */ public function __construct($valid, $value) { @@ -28,6 +26,8 @@ class ValidationResult /** * Is the value valid? + * + * @return bool */ public function isValid() { @@ -36,6 +36,8 @@ class ValidationResult /** * The parsed/validated value. + * + * @return mixed */ public function getValue() { diff --git a/includes/mysqli_provider.php b/includes/mysqli_provider.php index 7280cd6d..2d991f4d 100644 --- a/includes/mysqli_provider.php +++ b/includes/mysqli_provider.php @@ -1,7 +1,11 @@ query($query); if ($result) { $data = []; @@ -159,7 +165,7 @@ function sql_select($query) * MySQL execute a query * * @param string $query - * @return mysqli_result boolean resource or false on error + * @return mysqli_result|false boolean resource or false on error */ function sql_query($query) { @@ -224,7 +230,21 @@ function sql_select_single_col($query) return array_map('array_shift', $result); } +/** + * @param string $query + * @return string|null + */ function sql_select_single_cell($query) { - return array_shift(array_shift(sql_select($query))); + $result = sql_select($query); + if ($result == false) { + return null; + } + + $result = array_shift($result); + if (!is_array($result)) { + return null; + } + + return array_shift($result); } diff --git a/includes/pages/admin_active.php b/includes/pages/admin_active.php index 38edbfdb..34b9eb14 100644 --- a/includes/pages/admin_active.php +++ b/includes/pages/admin_active.php @@ -1,10 +1,16 @@ _("Nickname"), 'shirt_size' => _("Size"), diff --git a/includes/pages/admin_arrive.php b/includes/pages/admin_arrive.php index cd910bd0..d0ed4ffc 100644 --- a/includes/pages/admin_arrive.php +++ b/includes/pages/admin_arrive.php @@ -1,10 +1,16 @@ 0) { - list($group) = $group; $privileges = sql_select(" SELECT `Privileges`.*, `GroupPrivileges`.`group_id` FROM `Privileges` diff --git a/includes/pages/admin_import.php b/includes/pages/admin_import.php index 46c13ac7..bef2b86e 100644 --- a/includes/pages/admin_import.php +++ b/includes/pages/admin_import.php @@ -1,10 +1,16 @@ '; } diff --git a/includes/pages/admin_questions.php b/includes/pages/admin_questions.php index c65280d5..032b010e 100644 --- a/includes/pages/admin_questions.php +++ b/includes/pages/admin_questions.php @@ -1,5 +1,8 @@ $shifttype_id ]; } elseif ($mode == 'multi') { - $shift_start = $start; + $shift_start = (int)$start; do { - $shift_end = $shift_start + $length * 60; + $shift_end = $shift_start + (int)$length * 60; if ($shift_end > $end) { $shift_end = $end; @@ -298,6 +304,7 @@ function admin_shifts() redirect(page_link_to('admin_shifts')); } + $needed_angel_types_info = []; foreach ($_SESSION['admin_shifts_shifts'] as $shift) { $shift['URL'] = null; $shift['PSID'] = null; @@ -312,7 +319,7 @@ function admin_shifts() . " from " . date("Y-m-d H:i", $shift['start']) . " to " . date("Y-m-d H:i", $shift['end']) ); - $needed_angel_types_info = []; + foreach ($_SESSION['admin_shifts_types'] as $type_id => $count) { $angel_type_source = sql_select("SELECT * FROM `AngelTypes` WHERE `id`='" . sql_escape($type_id) . "' LIMIT 1"); if (count($angel_type_source) > 0) { diff --git a/includes/pages/admin_user.php b/includes/pages/admin_user.php index 12d92720..c6ce628f 100644 --- a/includes/pages/admin_user.php +++ b/includes/pages/admin_user.php @@ -1,13 +1,19 @@ = '" . sql_escape($my_highest_group) . "' ORDER BY `Groups`.`Name`"); foreach ($groups as $group) { - $html .= '' . $group['Name'] . ''; + $html .= '' . $group['Name'] . ''; } $html .= ''; @@ -167,6 +173,7 @@ function admin_user() case 'save': $force_active = $user['force_active']; + $user_source = User($user_id); if (in_array('admin_active', $privileges)) { $force_active = $_REQUEST['force_active']; } @@ -178,7 +185,7 @@ function admin_user() `Handy` = '" . sql_escape($_POST["eHandy"]) . "', `Alter` = '" . sql_escape($_POST["eAlter"]) . "', `DECT` = '" . sql_escape($_POST["eDECT"]) . "', - " . ($user_source['email_by_human_allowed'] ? "`email` = '" . sql_escape($_POST["eemail"]) . "'" : "") . " + " . ($user_source['email_by_human_allowed'] ? "`email` = '" . sql_escape($_POST["eemail"]) . "'," : "") . " `jabber` = '" . sql_escape($_POST["ejabber"]) . "', `Size` = '" . sql_escape($_POST["eSize"]) . "', `Gekommen`= '" . sql_escape($_POST["eGekommen"]) . "', diff --git a/includes/pages/guest_credits.php b/includes/pages/guest_credits.php index 00b12f73..2e652b6f 100644 --- a/includes/pages/guest_credits.php +++ b/includes/pages/guest_credits.php @@ -1,9 +1,16 @@ diff --git a/includes/pages/user_ical.php b/includes/pages/user_ical.php index 05c67d51..929dc7c7 100644 --- a/includes/pages/user_ical.php +++ b/includes/pages/user_ical.php @@ -47,7 +47,8 @@ function send_ical_from_shifts($shifts) /** * Renders an ical vevent from given shift. * - * @param Shift $shift + * @param array $shift + * @return string */ function make_ical_entry_from_shift($shift) { diff --git a/includes/pages/user_messages.php b/includes/pages/user_messages.php index b7ff093f..5e8c2491 100644 --- a/includes/pages/user_messages.php +++ b/includes/pages/user_messages.php @@ -1,10 +1,16 @@ 0) { $shift = $shift[0]; - if (($shift['start'] > time() + $LETZTES_AUSTRAGEN * 3600) || in_array('user_shifts_admin', $privileges)) { + if (($shift['start'] > time() + $last_unsubscribe * 3600) || in_array('user_shifts_admin', $privileges)) { $result = ShiftEntry_delete($user_id); if ($result === false) { engelsystem_error('Unable to delete shift entry.'); @@ -146,4 +153,5 @@ function user_myshifts() } redirect(page_link_to('users') . '&action=view&user_id=' . $shifts_user['UID']); + return ''; } diff --git a/includes/pages/user_news.php b/includes/pages/user_news.php index 31f38eaa..01da8d27 100644 --- a/includes/pages/user_news.php +++ b/includes/pages/user_news.php @@ -1,23 +1,35 @@

' . meetings_title() . '

' . msg(); @@ -27,12 +39,18 @@ function user_meetings() $page = 0; } - $news = sql_select("SELECT * FROM `News` WHERE `Treffen`=1 ORDER BY `Datum` DESC LIMIT " . sql_escape($page * $DISPLAY_NEWS) . ", " . sql_escape($DISPLAY_NEWS)); + $news = sql_select(" + SELECT * + FROM `News` + WHERE `Treffen`=1 + ORDER BY `Datum`DESC + LIMIT " . sql_escape($page * $display_news) . ", " . sql_escape($display_news) + ); foreach ($news as $entry) { $html .= display_news($entry); } - $dis_rows = ceil(sql_num_query("SELECT * FROM `News`") / $DISPLAY_NEWS); + $dis_rows = ceil(sql_num_query("SELECT * FROM `News`") / $display_news); $html .= '
' . '
    '; for ($i = 0; $i < $dis_rows; $i++) { if (isset($_REQUEST['page']) && $i == $_REQUEST['page']) { @@ -49,6 +67,10 @@ function user_meetings() return $html; } +/** + * @param array $news + * @return string + */ function display_news($news) { global $privileges, $page; @@ -72,13 +94,21 @@ function display_news($news) $html .= User_Nick_render($user_source); if ($page != "news_comments") { - $html .= '  ' . _("Comments") . ' » ' . sql_num_query("SELECT * FROM `NewsComments` WHERE `Refid`='" . sql_escape($news['ID']) . "'") . ''; + $html .= ' ' + . ' ' + . _("Comments") . ' » ' + . '' + . sql_num_query("SELECT * FROM `NewsComments` WHERE `Refid`='" . sql_escape($news['ID']) . "'") + . ''; } $html .= '
'; $html .= ''; return $html; } +/** + * @return string + */ function user_news_comments() { global $user; @@ -93,7 +123,15 @@ function user_news_comments() list($news) = sql_select("SELECT * FROM `News` WHERE `ID`='" . sql_escape($nid) . "' LIMIT 1"); if (isset($_REQUEST["text"])) { $text = preg_replace("/([^\p{L}\p{P}\p{Z}\p{N}\n]{1,})/ui", '', strip_tags($_REQUEST['text'])); - sql_query("INSERT INTO `NewsComments` (`Refid`, `Datum`, `Text`, `UID`) VALUES ('" . sql_escape($nid) . "', '" . date("Y-m-d H:i:s") . "', '" . sql_escape($text) . "', '" . sql_escape($user["UID"]) . "')"); + sql_query(" + INSERT INTO `NewsComments` (`Refid`, `Datum`, `Text`, `UID`) + VALUES ( + '" . sql_escape($nid) . "', + '" . date("Y-m-d H:i:s") . "', + '" . sql_escape($text) . "', + '" . sql_escape($user["UID"]) . "' + ) + "); engelsystem_log("Created news_comment: " . $text); $html .= success(_("Entry saved."), true); } @@ -125,9 +163,12 @@ function user_news_comments() return $html . ''; } +/** + * @return string + */ function user_news() { - global $DISPLAY_NEWS, $privileges, $user; + global $display_news, $privileges, $user; $html = '

' . news_title() . '

' . msg(); @@ -135,7 +176,16 @@ function user_news() if (!isset($_POST["treffen"]) || !in_array("admin_news", $privileges)) { $_POST["treffen"] = 0; } - sql_query("INSERT INTO `News` (`Datum`, `Betreff`, `Text`, `UID`, `Treffen`) " . "VALUES ('" . sql_escape(time()) . "', '" . sql_escape($_POST["betreff"]) . "', '" . sql_escape($_POST["text"]) . "', '" . sql_escape($user['UID']) . "', '" . sql_escape($_POST["treffen"]) . "');"); + sql_query(" + INSERT INTO `News` (`Datum`, `Betreff`, `Text`, `UID`, `Treffen`) + VALUES ( + '" . sql_escape(time()) . "', + '" . sql_escape($_POST["betreff"]) . "', + '" . sql_escape($_POST["text"]) . "', + '" . sql_escape($user['UID']) . "', + '" . sql_escape($_POST["treffen"]) . "' + ) + "); engelsystem_log("Created news: " . $_POST["betreff"] . ", treffen: " . $_POST["treffen"]); success(_("Entry saved.")); redirect(page_link_to('news')); @@ -147,12 +197,17 @@ function user_news() $page = 0; } - $news = sql_select("SELECT * FROM `News` ORDER BY `Datum` DESC LIMIT " . sql_escape($page * $DISPLAY_NEWS) . ", " . sql_escape($DISPLAY_NEWS)); + $news = sql_select(" + SELECT * + FROM `News` + ORDER BY `Datum` + DESC LIMIT " . sql_escape($page * $display_news) . ", " . sql_escape($display_news) + ); foreach ($news as $entry) { $html .= display_news($entry); } - $dis_rows = ceil(sql_num_query("SELECT * FROM `News`") / $DISPLAY_NEWS); + $dis_rows = ceil(sql_num_query("SELECT * FROM `News`") / $display_news); $html .= '
' . '
    '; for ($i = 0; $i < $dis_rows; $i++) { if (isset($_REQUEST['page']) && $i == $_REQUEST['page']) { diff --git a/includes/pages/user_questions.php b/includes/pages/user_questions.php index d1a90292..fa66e8db 100644 --- a/includes/pages/user_questions.php +++ b/includes/pages/user_questions.php @@ -1,10 +1,16 @@ $themes - * List of available themes + * @param array $user_source The user + * @param array $themes List of available themes + * @return mixed */ function user_settings_theme($user_source, $themes) { @@ -140,10 +143,9 @@ function user_settings_theme($user_source, $themes) /** * Change use locale * - * @param User $user_source - * The user - * @param array $locales - * List of available locales + * @param array $user_source The user + * @param array $locales List of available locales + * @return array */ function user_settings_locale($user_source, $locales) { @@ -168,6 +170,8 @@ function user_settings_locale($user_source, $locales) /** * Main user settings page/controller + * + * @return string */ function user_settings() { diff --git a/includes/pages/user_shifts.php b/includes/pages/user_shifts.php index e325989c..405b36ab 100644 --- a/includes/pages/user_shifts.php +++ b/includes/pages/user_shifts.php @@ -1,6 +1,9 @@ '1' . _("The tasks shown here are influenced by the angeltypes you joined already!") - . " " + . ' ' . _("Description of the jobs.") - . "", + . '', 'shifts_table' => msg() . $shiftCalendarRenderer->render(), 'ical_text' => '

    ' . _("iCal export") . '

    ' . sprintf( _("Export of shown shifts. iCal format or JSON format available (please keep secret, otherwise reset the api key)."), @@ -213,6 +230,10 @@ function view_user_shifts() ]); } +/** + * @param array $array + * @return array + */ function get_ids_from_array($array) { return $array["id"]; @@ -227,9 +248,9 @@ function make_select($items, $selected, $name, $title = null) foreach ($items as $i) { $html_items[] = '

    ' - . '' + . ' > ' . $i['name'] . '' . (!isset($i['enabled']) || $i['enabled'] ? '' : glyph("lock")) . '

    '; } diff --git a/includes/sys_auth.php b/includes/sys_auth.php index f3aafc98..734afd57 100644 --- a/includes/sys_auth.php +++ b/includes/sys_auth.php @@ -31,6 +31,9 @@ function load_auth() /** * generate a salt (random string) of arbitrary length suitable for the use with crypt() + * + * @param int $length + * @return string */ function generate_salt($length = 16) { @@ -44,6 +47,10 @@ function generate_salt($length = 16) /** * set the password of a user + * + * @param int $uid + * @param string $password + * @return mysqli_result */ function set_password($uid, $password) { @@ -64,8 +71,13 @@ function set_password($uid, $password) /** * verify a password given a precomputed salt. * if $uid is given and $salt is an old-style salt (plain md5), we convert it automatically + * + * @param string $password + * @param string $salt + * @param int $uid + * @return bool */ -function verify_password($password, $salt, $uid = false) +function verify_password($password, $salt, $uid = null) { global $crypt_alg; $correct = false; @@ -77,7 +89,7 @@ function verify_password($password, $salt, $uid = false) $correct = md5($password) == $salt; } - if ($correct && substr($salt, 0, strlen($crypt_alg)) != $crypt_alg && $uid) { + if ($correct && substr($salt, 0, strlen($crypt_alg)) != $crypt_alg && intval($uid)) { // this password is stored in another format than we want it to be. // let's update it! // we duplicate the query from the above set_password() function to have the extra safety of checking the old hash @@ -92,6 +104,10 @@ function verify_password($password, $salt, $uid = false) return $correct; } +/** + * @param int $user_id + * @return array + */ function privileges_for_user($user_id) { $privileges = []; @@ -109,6 +125,10 @@ function privileges_for_user($user_id) return $privileges; } +/** + * @param int $group_id + * @return array + */ function privileges_for_group($group_id) { $privileges = []; diff --git a/includes/sys_form.php b/includes/sys_form.php index dfd43067..41fcd763 100644 --- a/includes/sys_form.php +++ b/includes/sys_form.php @@ -4,10 +4,8 @@ /** * Renders a hidden input * - * @param string $name - * Name of the input - * @param string $value - * The value + * @param string $name Name of the input + * @param string $value The value * @return string rendered html */ function form_hidden($name, $value) @@ -17,6 +15,11 @@ function form_hidden($name, $value) /** * Rendert ein Zahlenfeld mit Buttons zum verstellen + * + * @param string $name + * @param string $label + * @param string $value + * @return string */ function form_spinner($name, $label, $value) { @@ -33,11 +36,12 @@ function form_spinner($name, $label, $value)
'); @@ -46,15 +50,12 @@ function form_spinner($name, $label, $value) /** * Render a bootstrap datepicker * - * @param string $name - * Name of the parameter - * @param string $label - * Label - * @param int $value - * Unix Timestamp - * @param int $min_date - * Earliest possible date - * @return HTML + * @param string $name Name of the parameter + * @param string $label Label + * @param int $value Unix Timestamp + * @param string $start_date Earliest possible date + * @param string $end_date + * @return string HTML */ function form_date($name, $label, $value, $start_date = '', $end_date = '') { @@ -83,14 +84,11 @@ function form_date($name, $label, $value, $start_date = '', $end_date = '') /** * Rendert eine Liste von Checkboxen für ein Formular * - * @param - * name Die Namen der Checkboxen werden aus name_key gebildet - * @param - * label Die Beschriftung der Liste - * @param - * items Array mit den einzelnen Checkboxen - * @param - * selected Array mit den Keys, die ausgewählt sind + * @param string $name Die Namen der Checkboxen werden aus name_key gebildet + * @param string $label Die Beschriftung der Liste + * @param array $items Array mit den einzelnen Checkboxen + * @param array $selected Array mit den Keys, die ausgewählt sind + * @return string */ function form_checkboxes($name, $label, $items, $selected) { @@ -104,17 +102,13 @@ function form_checkboxes($name, $label, $items, $selected) /** * Rendert eine Tabelle von Checkboxen für ein Formular * - * @param - * names Assoziatives Array mit Namen der Checkboxen als Keys und Überschriften als Values - * @param - * label Die Beschriftung der gesamten Tabelle - * @param - * items Array mit den Beschriftungen der Zeilen - * @param - * selected Mehrdimensionales Array, wobei $selected[foo] ein Array der in der Datenreihe foo markierten - * Checkboxen ist - * @param - * disabled Wie selected, nur dass die entsprechenden Checkboxen deaktiviert statt markiert sind + * @param string[] $names Assoziatives Array mit Namen der Checkboxen als Keys und Überschriften als Values + * @param string $label Die Beschriftung der gesamten Tabelle + * @param string[] $items Array mit den Beschriftungen der Zeilen + * @param array[] $selected Mehrdimensionales Array, wobei $selected[foo] ein Array der in der Datenreihe foo + * markierten Checkboxen ist + * @param array $disabled Wie selected, nur dass die entsprechenden Checkboxen deaktiviert statt markiert sind + * @return string */ function form_multi_checkboxes($names, $label, $items, $selected, $disabled = []) { @@ -125,13 +119,16 @@ function form_multi_checkboxes($names, $label, $items, $selected, $disabled = [] $html .= ""; foreach ($items as $key => $item) { $html .= ""; + $dom_id = ''; foreach ($names as $name => $title) { $dom_id = $name . '_' . $key; $sel = array_search($key, $selected[$name]) !== false ? ' checked="checked"' : ""; if (!empty($disabled) && !empty($disabled[$name]) && array_search($key, $disabled[$name]) !== false) { $sel .= ' disabled="disabled"'; } - $html .= ''; + $html .= '' + . '' + . ''; } $html .= ''; } @@ -141,22 +138,38 @@ function form_multi_checkboxes($names, $label, $items, $selected, $disabled = [] /** * Rendert eine Checkbox + * + * @param string $name + * @param string $label + * @param string $selected + * @param string $value + * @return string */ function form_checkbox($name, $label, $selected, $value = 'checked') { - return '
'; + return '
'; } /** * Rendert einen Radio + * + * @param string $name + * @param string $label + * @param string $selected + * @param string $value + * @return string */ function form_radio($name, $label, $selected, $value) { - return '
'; + return '
'; } /** * Rendert einen Infotext in das Formular + * + * @param string $label + * @param string $text + * @return string */ function form_info($label, $text = "") { @@ -171,6 +184,10 @@ function form_info($label, $text = "") /** * Rendert den Absenden-Button eines Formulars + * + * @param string $name + * @param string $label + * @return string */ function form_submit($name, $label) { @@ -182,6 +199,12 @@ function form_submit($name, $label) /** * Rendert ein Formular-Textfeld + * + * @param string $name + * @param string $label + * @param string $value + * @param bool $disabled + * @return string */ function form_text($name, $label, $value, $disabled = false) { @@ -196,14 +219,11 @@ function form_text($name, $label, $value, $disabled = false) /** * Renders a text input with placeholder instead of label. * - * @param String $name - * Input name - * @param String $placeholder - * Placeholder - * @param String $value - * The value - * @param Boolean $disabled - * Is the field enabled? + * @param String $name Input name + * @param String $placeholder Placeholder + * @param String $value The value + * @param Boolean $disabled Is the field enabled? + * @return string */ function form_text_placeholder($name, $placeholder, $value, $disabled = false) { @@ -214,6 +234,12 @@ function form_text_placeholder($name, $placeholder, $value, $disabled = false) /** * Rendert ein Formular-Emailfeld + * + * @param string $name + * @param string $label + * @param string $value + * @param bool $disabled + * @return string */ function form_email($name, $label, $value, $disabled = false) { @@ -227,6 +253,10 @@ function form_email($name, $label, $value, $disabled = false) /** * Rendert ein Formular-Dateifeld + * + * @param string $name + * @param string $label + * @return string */ function form_file($name, $label) { @@ -235,6 +265,11 @@ function form_file($name, $label) /** * Rendert ein Formular-Passwortfeld + * + * @param string $name + * @param string $label + * @param bool $disabled + * @return string */ function form_password($name, $label, $disabled = false) { @@ -248,6 +283,11 @@ function form_password($name, $label, $disabled = false) /** * Renders a password input with placeholder instead of label. + * + * @param string $name + * @param string $placeholder + * @param bool $disabled + * @return string */ function form_password_placeholder($name, $placeholder, $disabled = false) { @@ -261,6 +301,12 @@ function form_password_placeholder($name, $placeholder, $disabled = false) /** * Rendert ein Formular-Textfeld + * + * @param string $name + * @param string $label + * @param string $value + * @param bool $disabled + * @return string */ function form_textarea($name, $label, $value, $disabled = false) { @@ -274,6 +320,12 @@ function form_textarea($name, $label, $value, $disabled = false) /** * Rendert ein Formular-Auswahlfeld + * + * @param string $name + * @param string $label + * @param string[] $values + * @param string $selected + * @return string */ function form_select($name, $label, $values, $selected) { @@ -282,6 +334,11 @@ function form_select($name, $label, $values, $selected) /** * Rendert ein Formular-Element + * + * @param string $label + * @param string $input + * @param string $for + * @return string */ function form_element($label, $input, $for = "") { @@ -294,12 +351,22 @@ function form_element($label, $input, $for = "") /** * Rendert ein Formular + * + * @param string[] $elements + * @param string $action + * @return string */ function form($elements, $action = "") { return '
' . join($elements) . '
'; } +/** + * @param string $name + * @param String[] $options + * @param string $selected + * @return string + */ function html_options($name, $options, $selected = "") { $html = ""; @@ -310,6 +377,13 @@ function html_options($name, $options, $selected = "") return $html; } +/** + * @param string $dom_id + * @param string $name + * @param string[] $rows + * @param string $selected + * @return string + */ function html_select_key($dom_id, $name, $rows, $selected) { $html = '