PPHDoc, formatting, fixes, cleanup

main
Bot 8 years ago committed by Igor Scheller
parent d71e7bbfad
commit 356b2582f3

@ -13,10 +13,10 @@ $contact_email = "mailto:ticket@c3heaven.de";
$default_theme = 1; $default_theme = 1;
// Anzahl der News, die auf einer Seite ausgeben werden koennen... // Anzahl der News, die auf einer Seite ausgeben werden koennen...
$DISPLAY_NEWS = 6; $display_news = 6;
// Anzahl Stunden bis zum Austragen eigener Schichten // Anzahl Stunden bis zum Austragen eigener Schichten
$LETZTES_AUSTRAGEN = 3; $last_unsubscribe = 3;
// Setzt den zu verwendenden Crypto-Algorismus (entsprechend der Dokumentation von crypt()). // Setzt den zu verwendenden Crypto-Algorismus (entsprechend der Dokumentation von crypt()).
// Falls ein Benutzerpasswort in einem anderen Format gespeichert ist, // Falls ein Benutzerpasswort in einem anderen Format gespeichert ist,

@ -2,6 +2,8 @@
/** /**
* Text for Angeltype related links. * Text for Angeltype related links.
*
* @return string
*/ */
function angeltypes_title() function angeltypes_title()
{ {
@ -10,15 +12,14 @@ function angeltypes_title()
/** /**
* Route angeltype actions. * Route angeltype actions.
*
* @return array
*/ */
function angeltypes_controller() function angeltypes_controller()
{ {
$action = strip_request_item('action', 'list'); $action = strip_request_item('action', 'list');
switch ($action) { switch ($action) {
default:
case 'list':
return angeltypes_list_controller();
case 'view': case 'view':
return angeltype_controller(); return angeltype_controller();
case 'edit': case 'edit':
@ -27,13 +28,17 @@ function angeltypes_controller()
return angeltype_delete_controller(); return angeltype_delete_controller();
case 'about': case 'about':
return angeltypes_about_controller(); return angeltypes_about_controller();
case 'list':
default:
return angeltypes_list_controller();
} }
} }
/** /**
* Path to angeltype view. * Path to angeltype view.
* *
* @param AngelType $angeltype_id * @param int $angeltype_id AngelType id
* @return string
*/ */
function angeltype_link($angeltype_id) function angeltype_link($angeltype_id)
{ {
@ -42,6 +47,8 @@ function angeltype_link($angeltype_id)
/** /**
* Job description for all angeltypes (public to everyone) * Job description for all angeltypes (public to everyone)
*
* @return array
*/ */
function angeltypes_about_controller() function angeltypes_about_controller()
{ {
@ -61,6 +68,8 @@ function angeltypes_about_controller()
/** /**
* Delete an Angeltype. * Delete an Angeltype.
*
* @return array
*/ */
function angeltype_delete_controller() function angeltype_delete_controller()
{ {
@ -86,6 +95,8 @@ function angeltype_delete_controller()
/** /**
* Change an Angeltype. * Change an Angeltype.
*
* @return array
*/ */
function angeltype_edit_controller() function angeltype_edit_controller()
{ {
@ -151,6 +162,8 @@ function angeltype_edit_controller()
/** /**
* View details of a given angeltype. * View details of a given angeltype.
*
* @return array
*/ */
function angeltype_controller() function angeltype_controller()
{ {
@ -182,6 +195,8 @@ function angeltype_controller()
/** /**
* View a list of all angeltypes. * View a list of all angeltypes.
*
* @return array
*/ */
function angeltypes_list_controller() function angeltypes_list_controller()
{ {
@ -242,6 +257,8 @@ function angeltypes_list_controller()
/** /**
* Loads an angeltype from given angeltype_id request param. * Loads an angeltype from given angeltype_id request param.
*
* @return array
*/ */
function load_angeltype() function load_angeltype()
{ {

@ -1,10 +1,16 @@
<?php <?php
/**
* @return string
*/
function event_config_title() function event_config_title()
{ {
return _("Event config"); return _("Event config");
} }
/**
* @return array
*/
function event_config_edit_controller() function event_config_edit_controller()
{ {
global $privileges; global $privileges;

@ -8,6 +8,8 @@ use Engelsystem\ShiftsFilterRenderer;
/** /**
* View a room with its shifts. * View a room with its shifts.
*
* @return array
*/ */
function room_controller() function room_controller()
{ {
@ -55,6 +57,8 @@ function room_controller()
/** /**
* Dispatch different room actions. * Dispatch different room actions.
*
* @return array
*/ */
function rooms_controller() function rooms_controller()
{ {
@ -63,19 +67,30 @@ function rooms_controller()
} }
switch ($_REQUEST['action']) { switch ($_REQUEST['action']) {
default:
case 'list':
redirect(page_link_to('admin_rooms'));
case 'view': case 'view':
return room_controller(); return room_controller();
case 'list':
default:
redirect(page_link_to('admin_rooms'));
break;
} }
exit;
} }
/**
* @param array $room
* @return string
*/
function room_link($room) function room_link($room)
{ {
return page_link_to('rooms') . '&action=view&room_id=' . $room['RID']; return page_link_to('rooms') . '&action=view&room_id=' . $room['RID'];
} }
/**
* @param array $room
* @return string
*/
function room_edit_link($room) function room_edit_link($room)
{ {
return page_link_to('admin_rooms') . '&show=edit&id=' . $room['RID']; return page_link_to('admin_rooms') . '&show=edit&id=' . $room['RID'];
@ -83,6 +98,8 @@ function room_edit_link($room)
/** /**
* Loads room by request param room_id * Loads room by request param room_id
*
* @return array
*/ */
function load_room() function load_room()
{ {

@ -2,11 +2,14 @@
/** /**
* Sign up for a shift. * Sign up for a shift.
*
* @return string
*/ */
function shift_entry_add_controller() function shift_entry_add_controller()
{ {
global $privileges, $user; global $privileges, $user;
$shift_id = 0;
if (isset($_REQUEST['shift_id']) && preg_match("/^[0-9]*$/", $_REQUEST['shift_id'])) { if (isset($_REQUEST['shift_id']) && preg_match("/^[0-9]*$/", $_REQUEST['shift_id'])) {
$shift_id = $_REQUEST['shift_id']; $shift_id = $_REQUEST['shift_id'];
} else { } else {
@ -26,6 +29,7 @@ function shift_entry_add_controller()
redirect(page_link_to('user_shifts')); redirect(page_link_to('user_shifts'));
} }
$type_id = 0;
if (isset($_REQUEST['type_id']) && preg_match("/^[0-9]*$/", $_REQUEST['type_id'])) { if (isset($_REQUEST['type_id']) && preg_match("/^[0-9]*$/", $_REQUEST['type_id'])) {
$type_id = $_REQUEST['type_id']; $type_id = $_REQUEST['type_id'];
} else { } else {
@ -145,6 +149,7 @@ function shift_entry_add_controller()
redirect(shift_link($shift)); redirect(shift_link($shift));
} }
$angeltype_select = '';
if (in_array('user_shifts_admin', $privileges)) { if (in_array('user_shifts_admin', $privileges)) {
$users = sql_select(" $users = sql_select("
SELECT *, (SELECT count(*) FROM `ShiftEntry` WHERE `freeloaded`=1 AND `ShiftEntry`.`UID`=`User`.`UID`) AS `freeloaded` SELECT *, (SELECT count(*) FROM `ShiftEntry` WHERE `freeloaded`=1 AND `ShiftEntry`.`UID`=`User`.`UID`) AS `freeloaded`
@ -186,9 +191,19 @@ function shift_entry_add_controller()
$angeltype_select = $type['name']; $angeltype_select = $type['name'];
} }
return ShiftEntry_edit_view($user_text, date("Y-m-d H:i", $shift['start']) . ' &ndash; ' . date('Y-m-d H:i', return ShiftEntry_edit_view(
$shift['end']) . ' (' . shift_length($shift) . ')', $shift['Name'], $shift['name'], $angeltype_select, "", $user_text,
false, null, in_array('user_shifts_admin', $privileges)); date("Y-m-d H:i", $shift['start'])
. ' &ndash; '
. date('Y-m-d H:i', $shift['end'])
. ' (' . shift_length($shift) . ')',
$shift['Name'],
$shift['name'],
$angeltype_select, "",
false,
null,
in_array('user_shifts_admin', $privileges)
);
} }
/** /**
@ -245,5 +260,6 @@ function shift_entry_delete_controller()
} else { } else {
error(_("Entry not found.")); error(_("Entry not found."));
} }
redirect(shift_link($shift_entry_source)); redirect(shift_link($shift_entry_source));
} }

@ -1,16 +1,28 @@
<?php <?php
use Engelsystem\ShiftSignupState; use Engelsystem\ShiftSignupState;
/**
* @param array $shift
* @return string
*/
function shift_link($shift) function shift_link($shift)
{ {
return page_link_to('shifts') . '&action=view&shift_id=' . $shift['SID']; return page_link_to('shifts') . '&action=view&shift_id=' . $shift['SID'];
} }
/**
* @param array $shift
* @return string
*/
function shift_delete_link($shift) function shift_delete_link($shift)
{ {
return page_link_to('user_shifts') . '&delete_shift=' . $shift['SID']; return page_link_to('user_shifts') . '&delete_shift=' . $shift['SID'];
} }
/**
* @param array $shift
* @return string
*/
function shift_edit_link($shift) function shift_edit_link($shift)
{ {
return page_link_to('user_shifts') . '&edit_shift=' . $shift['SID']; return page_link_to('user_shifts') . '&edit_shift=' . $shift['SID'];
@ -18,6 +30,8 @@ function shift_edit_link($shift)
/** /**
* Edit a single shift. * Edit a single shift.
*
* @return string
*/ */
function shift_edit_controller() function shift_edit_controller()
{ {
@ -162,6 +176,9 @@ function shift_edit_controller()
); );
} }
/**
* @return string
*/
function shift_delete_controller() function shift_delete_controller()
{ {
global $privileges; global $privileges;
@ -205,6 +222,9 @@ function shift_delete_controller()
]); ]);
} }
/**
* @return array
*/
function shift_controller() function shift_controller()
{ {
global $user, $privileges; global $user, $privileges;
@ -249,6 +269,9 @@ function shift_controller()
]; ];
} }
/**
* @return array|false
*/
function shifts_controller() function shifts_controller()
{ {
if (!isset($_REQUEST['action'])) { if (!isset($_REQUEST['action'])) {
@ -256,17 +279,21 @@ function shifts_controller()
} }
switch ($_REQUEST['action']) { switch ($_REQUEST['action']) {
default:
redirect(page_link_to('?'));
case 'view': case 'view':
return shift_controller(); return shift_controller();
case 'next': case 'next':
return shift_next_controller(); return shift_next_controller();
default:
redirect(page_link_to('?'));
} }
return false;
} }
/** /**
* Redirects the user to his next shift. * Redirects the user to his next shift.
*
* @return false
*/ */
function shift_next_controller() function shift_next_controller()
{ {
@ -286,6 +313,7 @@ function shift_next_controller()
} }
redirect(page_link_to('user_shifts')); redirect(page_link_to('user_shifts'));
exit;
} }
/** /**
@ -346,6 +374,8 @@ function shifts_json_export_controller()
/** /**
* Returns users shifts to export. * Returns users shifts to export.
*
* @return array
*/ */
function load_ical_shifts() function load_ical_shifts()
{ {

@ -1,5 +1,9 @@
<?php <?php
/**
* @param array $shifttype
* @return string
*/
function shifttype_link($shifttype) function shifttype_link($shifttype)
{ {
return page_link_to('shifttypes') . '&action=view&shifttype_id=' . $shifttype['id']; return page_link_to('shifttypes') . '&action=view&shifttype_id=' . $shifttype['id'];
@ -7,6 +11,8 @@ function shifttype_link($shifttype)
/** /**
* Delete a shifttype. * Delete a shifttype.
*
* @return array
*/ */
function shifttype_delete_controller() function shifttype_delete_controller()
{ {
@ -42,6 +48,8 @@ function shifttype_delete_controller()
/** /**
* Edit or create shift type. * Edit or create shift type.
*
* @return array
*/ */
function shifttype_edit_controller() function shifttype_edit_controller()
{ {
@ -113,6 +121,9 @@ function shifttype_edit_controller()
]; ];
} }
/**
* @return array
*/
function shifttype_controller() function shifttype_controller()
{ {
if (!isset($_REQUEST['shifttype_id'])) { if (!isset($_REQUEST['shifttype_id'])) {
@ -139,6 +150,8 @@ function shifttype_controller()
/** /**
* List all shift types. * List all shift types.
*
* @return array
*/ */
function shifttypes_list_controller() function shifttypes_list_controller()
{ {
@ -155,6 +168,8 @@ function shifttypes_list_controller()
/** /**
* Text for shift type related links. * Text for shift type related links.
*
* @return string
*/ */
function shifttypes_title() function shifttypes_title()
{ {
@ -163,6 +178,8 @@ function shifttypes_title()
/** /**
* Route shift type actions * Route shift type actions
*
* @return array
*/ */
function shifttypes_controller() function shifttypes_controller()
{ {
@ -171,14 +188,14 @@ function shifttypes_controller()
} }
switch ($_REQUEST['action']) { switch ($_REQUEST['action']) {
default:
case 'list':
return shifttypes_list_controller();
case 'view': case 'view':
return shifttype_controller(); return shifttype_controller();
case 'edit': case 'edit':
return shifttype_edit_controller(); return shifttype_edit_controller();
case 'delete': case 'delete':
return shifttype_delete_controller(); return shifttype_delete_controller();
case 'list':
default:
return shifttypes_list_controller();
} }
} }

@ -2,6 +2,8 @@
/** /**
* Display a hint for team/angeltype supporters if there are unconfirmed users for his angeltype. * Display a hint for team/angeltype supporters if there are unconfirmed users for his angeltype.
*
* @return string|null
*/ */
function user_angeltypes_unconfirmed_hint() function user_angeltypes_unconfirmed_hint()
{ {
@ -14,7 +16,12 @@ function user_angeltypes_unconfirmed_hint()
$unconfirmed_links = []; $unconfirmed_links = [];
foreach ($unconfirmed_user_angeltypes as $user_angeltype) { foreach ($unconfirmed_user_angeltypes as $user_angeltype) {
$unconfirmed_links[] = '<a href="' . page_link_to('angeltypes') . '&action=view&angeltype_id=' . $user_angeltype['angeltype_id'] . '">' . $user_angeltype['name'] . ' (+' . $user_angeltype['count'] . ')' . '</a>'; $unconfirmed_links[] = '<a href="'
. page_link_to('angeltypes')
. '&action=view&angeltype_id=' . $user_angeltype['angeltype_id']
. '">' . $user_angeltype['name']
. ' (+' . $user_angeltype['count'] . ')'
. '</a>';
} }
return sprintf(ngettext("There is %d unconfirmed angeltype.", "There are %d unconfirmed angeltypes.", 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. * Remove all unconfirmed users from a specific angeltype.
*
* @return array
*/ */
function user_angeltypes_delete_all_controller() function user_angeltypes_delete_all_controller()
{ {
@ -62,6 +71,8 @@ function user_angeltypes_delete_all_controller()
/** /**
* Confirm all unconfirmed users for an angeltype. * Confirm all unconfirmed users for an angeltype.
*
* @return array
*/ */
function user_angeltypes_confirm_all_controller() function user_angeltypes_confirm_all_controller()
{ {
@ -105,6 +116,8 @@ function user_angeltypes_confirm_all_controller()
/** /**
* Confirm an user for an angeltype. * Confirm an user for an angeltype.
*
* @return array
*/ */
function user_angeltype_confirm_controller() function user_angeltype_confirm_controller()
{ {
@ -165,6 +178,8 @@ function user_angeltype_confirm_controller()
/** /**
* Remove a user from an Angeltype. * Remove a user from an Angeltype.
*
* @return array
*/ */
function user_angeltype_delete_controller() function user_angeltype_delete_controller()
{ {
@ -219,10 +234,13 @@ function user_angeltype_delete_controller()
/** /**
* Update an UserAngelType. * Update an UserAngelType.
*
* @return array
*/ */
function user_angeltype_update_controller() function user_angeltype_update_controller()
{ {
global $privileges; global $privileges;
$supporter = false;
if (!in_array('admin_angel_types', $privileges)) { if (!in_array('admin_angel_types', $privileges)) {
error(_("You are not allowed to set supporter rights.")); error(_("You are not allowed to set supporter rights."));
@ -337,6 +355,9 @@ function user_angeltype_add_controller()
/** /**
* A user joins an angeltype. * A user joins an angeltype.
*
* @param array $angeltype
* @return array
*/ */
function user_angeltype_join_controller($angeltype) function user_angeltype_join_controller($angeltype)
{ {
@ -375,6 +396,8 @@ function user_angeltype_join_controller($angeltype)
/** /**
* Route UserAngelType actions. * Route UserAngelType actions.
*
* @return array
*/ */
function user_angeltypes_controller() function user_angeltypes_controller()
{ {
@ -397,5 +420,6 @@ function user_angeltypes_controller()
return user_angeltype_add_controller(); return user_angeltype_add_controller();
default: default:
redirect(page_link_to('angeltypes')); redirect(page_link_to('angeltypes'));
exit;
} }
} }

@ -3,6 +3,8 @@
/** /**
* Generates a hint, if user joined angeltypes that require a driving license and the user has no driver license * Generates a hint, if user joined angeltypes that require a driving license and the user has no driver license
* information provided. * information provided.
*
* @return string|null
*/ */
function user_driver_license_required_hint() function user_driver_license_required_hint()
{ {
@ -30,6 +32,8 @@ function user_driver_license_required_hint()
/** /**
* Route user driver licenses actions. * Route user driver licenses actions.
*
* @return array
*/ */
function user_driver_licenses_controller() function user_driver_licenses_controller()
{ {
@ -51,7 +55,8 @@ function user_driver_licenses_controller()
/** /**
* Link to user driver license edit page for given user. * 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) 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. * Loads the user for the driver license.
*
* @return array
*/ */
function user_driver_license_load_user() function user_driver_license_load_user()
{ {
@ -82,6 +89,8 @@ function user_driver_license_load_user()
/** /**
* Edit a users driver license information. * Edit a users driver license information.
*
* @return array
*/ */
function user_driver_license_edit_controller() function user_driver_license_edit_controller()
{ {

@ -4,6 +4,8 @@ use Engelsystem\ShiftsFilter;
/** /**
* Route user actions. * Route user actions.
*
* @return array
*/ */
function users_controller() function users_controller()
{ {
@ -18,22 +20,22 @@ function users_controller()
} }
switch ($_REQUEST['action']) { switch ($_REQUEST['action']) {
default:
case 'list':
return users_list_controller();
case 'view': case 'view':
return user_controller(); return user_controller();
case 'edit':
return user_edit_controller();
case 'delete': case 'delete':
return user_delete_controller(); return user_delete_controller();
case 'edit_vouchers': case 'edit_vouchers':
return user_edit_vouchers_controller(); return user_edit_vouchers_controller();
case 'list':
default:
return users_list_controller();
} }
} }
/** /**
* Delete a user, requires to enter own password for reasons. * Delete a user, requires to enter own password for reasons.
*
* @return array
*/ */
function user_delete_controller() function user_delete_controller()
{ {
@ -85,26 +87,44 @@ function user_delete_controller()
]; ];
} }
/**
* @return string
*/
function users_link() function users_link()
{ {
return page_link_to('users'); return page_link_to('users');
} }
/**
* @param array $user
* @return string
*/
function user_edit_link($user) function user_edit_link($user)
{ {
return page_link_to('admin_user') . '&user_id=' . $user['UID']; return page_link_to('admin_user') . '&user_id=' . $user['UID'];
} }
/**
* @param array $user
* @return string
*/
function user_delete_link($user) function user_delete_link($user)
{ {
return page_link_to('users') . '&action=delete&user_id=' . $user['UID']; return page_link_to('users') . '&action=delete&user_id=' . $user['UID'];
} }
/**
* @param array $user
* @return string
*/
function user_link($user) function user_link($user)
{ {
return page_link_to('users') . '&action=view&user_id=' . $user['UID']; return page_link_to('users') . '&action=view&user_id=' . $user['UID'];
} }
/**
* @return array
*/
function user_edit_vouchers_controller() function user_edit_vouchers_controller()
{ {
global $privileges, $user; global $privileges, $user;
@ -122,6 +142,7 @@ function user_edit_vouchers_controller()
if (isset($_REQUEST['submit'])) { if (isset($_REQUEST['submit'])) {
$valid = true; $valid = true;
$vouchers = '';
if (isset($_REQUEST['vouchers']) && test_request_int('vouchers') && trim($_REQUEST['vouchers']) >= 0) { if (isset($_REQUEST['vouchers']) && test_request_int('vouchers') && trim($_REQUEST['vouchers']) >= 0) {
$vouchers = trim($_REQUEST['vouchers']); $vouchers = trim($_REQUEST['vouchers']);
} else { } else {
@ -151,6 +172,9 @@ function user_edit_vouchers_controller()
]; ];
} }
/**
* @return array
*/
function user_controller() function user_controller()
{ {
global $privileges, $user; global $privileges, $user;
@ -167,7 +191,13 @@ function user_controller()
$shifts = Shifts_by_user($user_source, in_array("user_shifts_admin", $privileges)); $shifts = Shifts_by_user($user_source, in_array("user_shifts_admin", $privileges));
foreach ($shifts as &$shift) { foreach ($shifts as &$shift) {
// TODO: Move queries to model // TODO: Move queries to model
$shift['needed_angeltypes'] = sql_select("SELECT DISTINCT `AngelTypes`.* FROM `ShiftEntry` JOIN `AngelTypes` ON `ShiftEntry`.`TID`=`AngelTypes`.`id` WHERE `ShiftEntry`.`SID`='" . sql_escape($shift['SID']) . "' ORDER BY `AngelTypes`.`name`"); $shift['needed_angeltypes'] = sql_select("
SELECT DISTINCT `AngelTypes`.*
FROM `ShiftEntry`
JOIN `AngelTypes` ON `ShiftEntry`.`TID`=`AngelTypes`.`id`
WHERE `ShiftEntry`.`SID`='" . sql_escape($shift['SID']) . "'
ORDER BY `AngelTypes`.`name`
");
foreach ($shift['needed_angeltypes'] as &$needed_angeltype) { foreach ($shift['needed_angeltypes'] as &$needed_angeltype) {
$needed_angeltype['users'] = sql_select(" $needed_angeltype['users'] = sql_select("
SELECT `ShiftEntry`.`freeloaded`, `User`.* SELECT `ShiftEntry`.`freeloaded`, `User`.*
@ -198,6 +228,8 @@ function user_controller()
/** /**
* List all users. * List all users.
*
* @return array
*/ */
function users_list_controller() 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 * Second step of password recovery: set a new password using the token link from email
*
* @return string
*/ */
function user_password_recovery_set_new_controller() 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 * 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() function user_password_recovery_start_controller()
{ {
@ -317,18 +353,22 @@ function user_password_recovery_start_controller()
/** /**
* User password recovery in 2 steps. * User password recovery in 2 steps.
* (By email) * (By email)
*
* @return string
*/ */
function user_password_recovery_controller() function user_password_recovery_controller()
{ {
if (isset($_REQUEST['token'])) { if (isset($_REQUEST['token'])) {
return user_password_recovery_set_new_controller(); 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. * Menu title for password recovery.
*
* @return string
*/ */
function user_password_recovery_title() function user_password_recovery_title()
{ {
@ -337,6 +377,8 @@ function user_password_recovery_title()
/** /**
* Loads a user from param user_id. * Loads a user from param user_id.
*
* return array
*/ */
function load_user() function load_user()
{ {
@ -357,6 +399,10 @@ function load_user()
return $user; return $user;
} }
/**
* @param ShiftsFilter $shiftsFilter
* @return ShiftCalendarRenderer
*/
function shiftCalendarRendererByShiftFilter(ShiftsFilter $shiftsFilter) function shiftCalendarRendererByShiftFilter(ShiftsFilter $shiftsFilter)
{ {
$shifts = Shifts_by_ShiftsFilter($shiftsFilter); $shifts = Shifts_by_ShiftsFilter($shiftsFilter);
@ -392,6 +438,7 @@ function shiftCalendarRendererByShiftFilter(ShiftsFilter $shiftsFilter)
$filtered_shifts = []; $filtered_shifts = [];
foreach ($shifts as $shift) { foreach ($shifts as $shift) {
$needed_angels_count = 0; $needed_angels_count = 0;
$taken = 0;
foreach ($needed_angeltypes[$shift['SID']] as $needed_angeltype) { foreach ($needed_angeltypes[$shift['SID']] as $needed_angeltype) {
$taken = 0; $taken = 0;
foreach ($shift_entries[$shift['SID']] as $shift_entry) { foreach ($shift_entries[$shift['SID']] as $shift_entry) {

@ -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/shifts_mailer.php');
require_once realpath(__DIR__ . '/../includes/mailer/users_mailer.php'); require_once realpath(__DIR__ . '/../includes/mailer/users_mailer.php');
$config = [];
require_once realpath(__DIR__ . '/../config/config.default.php'); require_once realpath(__DIR__ . '/../config/config.default.php');
if (file_exists(realpath(__DIR__ . '/../config/config.php'))) { if (file_exists(realpath(__DIR__ . '/../config/config.php'))) {
require_once realpath(__DIR__ . '/../config/config.php'); require_once realpath(__DIR__ . '/../config/config.php');

@ -1,5 +1,12 @@
<?php <?php
/**
* @param array $recipient_user
* @param string $title
* @param string $message
* @param bool $not_if_its_me
* @return bool
*/
function engelsystem_email_to_user($recipient_user, $title, $message, $not_if_its_me = false) function engelsystem_email_to_user($recipient_user, $title, $message, $not_if_its_me = false)
{ {
global $user; global $user;
@ -16,14 +23,28 @@ function engelsystem_email_to_user($recipient_user, $title, $message, $not_if_it
. _("This email is autogenerated and has not to be signed. You got this email because you are registered in the engelsystem."); . _("This email is autogenerated and has not to be signed. You got this email because you are registered in the engelsystem.");
gettext_locale(); gettext_locale();
return engelsystem_email($recipient_user['email'], $title, $message); return engelsystem_email($recipient_user['email'], $title, $message);
} }
/**
* @param string $address
* @param string $title
* @param string $message
* @return bool
*/
function engelsystem_email($address, $title, $message) function engelsystem_email($address, $title, $message)
{ {
$result = mail($address, $title, $message, $result = mail(
"Content-Type: text/plain; charset=UTF-8\r\nFrom: Engelsystem <noreply@engelsystem.de>"); $address,
$title,
$message,
"Content-Type: text/plain; charset=UTF-8\r\nFrom: Engelsystem <noreply@engelsystem.de>"
);
if ($result === false) { if ($result === false) {
engelsystem_error('Unable to send email.'); engelsystem_error('Unable to send email.');
} }
return true;
} }

@ -3,10 +3,12 @@
/** /**
* Renders a bargraph * Renders a bargraph
* *
* @param string $key keyname of the x-axis * @param string $dom_id
* @param array $row_names keynames for the data rows * @param string $key key name of the x-axis
* @param unknown $colors colors for the data rows * @param array $row_names key names for the data rows
* @param unknown $data the data * @param array $colors colors for the data rows
* @param array $data the data
* @return string
*/ */
function bargraph($dom_id, $key, $row_names, $colors, $data) function bargraph($dom_id, $key, $row_names, $colors, $data)
{ {

@ -8,6 +8,8 @@ $default_locale = 'en_US.UTF-8';
/** /**
* Return currently active locale * Return currently active locale
*
* @return string
*/ */
function locale() function locale()
{ {
@ -16,6 +18,8 @@ function locale()
/** /**
* Returns two letter language code from currently active locale * Returns two letter language code from currently active locale
*
* @return string
*/ */
function locale_short() function locale_short()
{ {
@ -59,7 +63,7 @@ function gettext_locale($locale = null)
/** /**
* Renders language selection. * Renders language selection.
* *
* @return string * @return array
*/ */
function make_langselect() function make_langselect()
{ {

@ -2,6 +2,8 @@
/** /**
* Gibt zwischengespeicherte Fehlermeldungen zurück und löscht den Zwischenspeicher * Gibt zwischengespeicherte Fehlermeldungen zurück und löscht den Zwischenspeicher
*
* @return string
*/ */
function msg() function msg()
{ {
@ -15,34 +17,51 @@ function msg()
/** /**
* Rendert eine Information * 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 * 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 * 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. * 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 == "") { if ($msg == "") {
return ""; return "";
} }
@ -53,4 +72,6 @@ function alert($class, $msg, $immediatly = false)
$_SESSION['msg'] = ""; $_SESSION['msg'] = "";
} }
$_SESSION['msg'] .= alert($class, $msg, true); $_SESSION['msg'] .= alert($class, $msg, true);
return null;
} }

@ -1,24 +1,28 @@
<?php <?php
/**
* @param array $old_shift
* @param array $new_shift
*/
function mail_shift_change($old_shift, $new_shift) function mail_shift_change($old_shift, $new_shift)
{ {
$users = ShiftEntries_by_shift($old_shift["SID"]); $users = ShiftEntries_by_shift($old_shift["SID"]);
$old_room = Room($old_shift["RID"]); $old_room = Room($old_shift["RID"]);
$new_room = Room($new_shift["RID"]); $new_room = Room($new_shift["RID"]);
$noticable_changes = false; $noticeable_changes = false;
$message = _("A Shift you are registered on has changed:"); $message = _("A Shift you are registered on has changed:");
$message .= "\n"; $message .= "\n";
if ($old_shift["name"] != $new_shift["name"]) { if ($old_shift["name"] != $new_shift["name"]) {
$message .= sprintf(_("* Shift type changed from %s to %s"), $old_shift["name"], $new_shift["name"]) . "\n"; $message .= sprintf(_("* Shift type changed from %s to %s"), $old_shift["name"], $new_shift["name"]) . "\n";
$noticable_changes = true; $noticeable_changes = true;
} }
if ($old_shift["title"] != $new_shift["title"]) { if ($old_shift["title"] != $new_shift["title"]) {
$message .= sprintf(_("* Shift title changed from %s to %s"), $old_shift["title"], $new_shift["title"]) . "\n"; $message .= sprintf(_("* Shift title changed from %s to %s"), $old_shift["title"], $new_shift["title"]) . "\n";
$noticable_changes = true; $noticeable_changes = true;
} }
if ($old_shift["start"] != $new_shift["start"]) { if ($old_shift["start"] != $new_shift["start"]) {
@ -27,7 +31,7 @@ function mail_shift_change($old_shift, $new_shift)
date("Y-m-d H:i", $old_shift["start"]), date("Y-m-d H:i", $old_shift["start"]),
date("Y-m-d H:i", $new_shift["start"]) date("Y-m-d H:i", $new_shift["start"])
) . "\n"; ) . "\n";
$noticable_changes = true; $noticeable_changes = true;
} }
if ($old_shift["end"] != $new_shift["end"]) { if ($old_shift["end"] != $new_shift["end"]) {
@ -36,15 +40,15 @@ function mail_shift_change($old_shift, $new_shift)
date("Y-m-d H:i", $old_shift["end"]), date("Y-m-d H:i", $old_shift["end"]),
date("Y-m-d H:i", $new_shift["end"]) date("Y-m-d H:i", $new_shift["end"])
) . "\n"; ) . "\n";
$noticable_changes = true; $noticeable_changes = true;
} }
if ($old_shift["RID"] != $new_shift["RID"]) { if ($old_shift["RID"] != $new_shift["RID"]) {
$message .= sprintf(_("* Shift Location changed from %s to %s"), $old_room["Name"], $new_room["Name"]) . "\n"; $message .= sprintf(_("* Shift Location changed from %s to %s"), $old_room["Name"], $new_room["Name"]) . "\n";
$noticable_changes = true; $noticeable_changes = true;
} }
if (!$noticable_changes) { if (!$noticeable_changes) {
// There are no changes worth sending an E-Mail // There are no changes worth sending an E-Mail
return; return;
} }
@ -64,6 +68,9 @@ function mail_shift_change($old_shift, $new_shift)
} }
} }
/**
* @param array $shift
*/
function mail_shift_delete($shift) function mail_shift_delete($shift)
{ {
$users = ShiftEntries_by_shift($shift["SID"]); $users = ShiftEntries_by_shift($shift["SID"]);
@ -83,32 +90,40 @@ function mail_shift_delete($shift)
} }
} }
/**
* @param array $user
* @param array $shift
*/
function mail_shift_assign($user, $shift) function mail_shift_assign($user, $shift)
{ {
if ($user["email_shiftinfo"]) { if (!$user["email_shiftinfo"]) {
$room = Room($shift["RID"]); return;
}
$message = _("You have been assigned to a Shift:") . "\n"; $room = Room($shift["RID"]);
$message .= $shift["name"] . "\n";
$message .= $shift["title"] . "\n";
$message .= date("Y-m-d H:i", $shift["start"]) . " - " . date("H:i", $shift["end"]) . "\n";
$message .= $room["Name"] . "\n";
engelsystem_email_to_user($user, '[engelsystem] ' . _("Assigned to Shift"), $message, true); $message = _("You have been assigned to a Shift:") . "\n";
} $message .= $shift["name"] . "\n";
$message .= $shift["title"] . "\n";
$message .= date("Y-m-d H:i", $shift["start"]) . " - " . date("H:i", $shift["end"]) . "\n";
$message .= $room["Name"] . "\n";
engelsystem_email_to_user($user, '[engelsystem] ' . _("Assigned to Shift"), $message, true);
} }
function mail_shift_removed($user, $shift) function mail_shift_removed($user, $shift)
{ {
if ($user["email_shiftinfo"]) { if (!$user["email_shiftinfo"]) {
$room = Room($shift["RID"]); return;
}
$message = _("You have been removed from a Shift:") . "\n"; $room = Room($shift["RID"]);
$message .= $shift["name"] . "\n";
$message .= $shift["title"] . "\n";
$message .= date("Y-m-d H:i", $shift["start"]) . " - " . date("H:i", $shift["end"]) . "\n";
$message .= $room["Name"] . "\n";
engelsystem_email_to_user($user, '[engelsystem] ' . _("Removed from Shift"), $message, true); $message = _("You have been removed from a Shift:") . "\n";
} $message .= $shift["name"] . "\n";
$message .= $shift["title"] . "\n";
$message .= date("Y-m-d H:i", $shift["start"]) . " - " . date("H:i", $shift["end"]) . "\n";
$message .= $room["Name"] . "\n";
engelsystem_email_to_user($user, '[engelsystem] ' . _("Removed from Shift"), $message, true);
} }

@ -1,11 +1,12 @@
<?php <?php
/** /**
* @param User $user_source * @param array $user
* @return bool
*/ */
function mail_user_delete($user) function mail_user_delete($user)
{ {
engelsystem_email_to_user( return engelsystem_email_to_user(
$user, $user,
'[engelsystem] ' . _("Your account has been deleted"), '[engelsystem] ' . _("Your account has been deleted"),
_("Your angelsystem account has been deleted. If you have any questions regarding your account deletion, please contact heaven.") _("Your angelsystem account has been deleted. If you have any questions regarding your account deletion, please contact heaven.")

@ -24,8 +24,7 @@ function AngelType_new()
/** /**
* Validates the contact user * Validates the contact user
* *
* @param Angeltype $angeltype * @param array $angeltype The angeltype
* The angeltype
* @return ValidationResult * @return ValidationResult
*/ */
function AngelType_validate_contact_user_id($angeltype) function AngelType_validate_contact_user_id($angeltype)
@ -45,8 +44,8 @@ function AngelType_validate_contact_user_id($angeltype)
/** /**
* Returns contact data (name, dect, email) for given angeltype or null * Returns contact data (name, dect, email) for given angeltype or null
* *
* @param Angeltype $angeltype * @param array $angeltype The angeltype
* The angeltype * @return array|null
*/ */
function AngelType_contact_info($angeltype) function AngelType_contact_info($angeltype)
{ {
@ -68,13 +67,15 @@ function AngelType_contact_info($angeltype)
'contact_email' => $angeltype['contact_email'] 'contact_email' => $angeltype['contact_email']
]; ];
} }
return null; return null;
} }
/** /**
* Delete an Angeltype. * Delete an Angeltype.
* *
* @param Angeltype $angeltype * @param array $angeltype
* @return mysqli_result
*/ */
function AngelType_delete($angeltype) function AngelType_delete($angeltype)
{ {
@ -92,8 +93,8 @@ function AngelType_delete($angeltype)
/** /**
* Update Angeltype. * Update Angeltype.
* *
* @param Angeltype $angeltype * @param array $angeltype The angeltype
* The angeltype * @return mysqli_result
*/ */
function AngelType_update($angeltype) function AngelType_update($angeltype)
{ {
@ -119,9 +120,8 @@ function AngelType_update($angeltype)
/** /**
* Create an Angeltype. * Create an Angeltype.
* *
* @param Angeltype $angeltype * @param array $angeltype The angeltype
* The angeltype * @return array the created angeltype
* @return the created angeltype
*/ */
function AngelType_create($angeltype) function AngelType_create($angeltype)
{ {
@ -148,10 +148,9 @@ function AngelType_create($angeltype)
* Validates a name for angeltypes. * Validates a name for angeltypes.
* Returns ValidationResult containing validation success and validated name. * Returns ValidationResult containing validation success and validated name.
* *
* @param string $name * @param string $name Wanted name for the angeltype
* Wanted name for the angeltype * @param array $angeltype The angeltype the name is for
* @param AngelType $angeltype *
* The angeltype the name is for
* @return ValidationResult result and validated name * @return ValidationResult result and validated name
*/ */
function AngelType_validate_name($name, $angeltype) 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. * 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) function AngelTypes_with_user($user)
{ {
@ -201,6 +201,8 @@ function AngelTypes_with_user($user)
/** /**
* Returns all angeltypes. * Returns all angeltypes.
*
* @return array
*/ */
function AngelTypes() function AngelTypes()
{ {
@ -216,6 +218,8 @@ function AngelTypes()
/** /**
* Returns AngelType id array * Returns AngelType id array
*
* @return array
*/ */
function AngelType_ids() function AngelType_ids()
{ {
@ -229,8 +233,8 @@ function AngelType_ids()
/** /**
* Returns angelType by id. * Returns angelType by id.
* *
* @param $angeltype_id angelType * @param int $angeltype_id angelType ID
* ID * @return array
*/ */
function AngelType($angeltype_id) function AngelType($angeltype_id)
{ {

@ -2,6 +2,8 @@
/** /**
* Get event config. * Get event config.
*
* łreturn array|false|null
*/ */
function EventConfig() function EventConfig()
{ {
@ -25,6 +27,7 @@ function EventConfig()
* @param int $event_end_date * @param int $event_end_date
* @param int $teardown_end_date * @param int $teardown_end_date
* @param string $event_welcome_msg * @param string $event_welcome_msg
* @return mysqli_result|false
*/ */
function EventConfig_update( function EventConfig_update(
$event_name, $event_name,
@ -43,6 +46,7 @@ function EventConfig_update(
`teardown_end_date`=" . sql_null($teardown_end_date) . ", `teardown_end_date`=" . sql_null($teardown_end_date) . ",
`event_welcome_msg`=" . sql_null($event_welcome_msg)); `event_welcome_msg`=" . sql_null($event_welcome_msg));
} }
return sql_query("UPDATE `EventConfig` SET return sql_query("UPDATE `EventConfig` SET
`event_name`=" . sql_null($event_name) . ", `event_name`=" . sql_null($event_name) . ",
`buildup_start_date`=" . sql_null($buildup_start_date) . ", `buildup_start_date`=" . sql_null($buildup_start_date) . ",

@ -3,9 +3,9 @@
/** /**
* Creates a log entry. * Creates a log entry.
* *
* @param $nick Username * @param string $nick Username
* @param $message Log * @param string $message Log Message
* Message * @return mysqli_result|false
*/ */
function LogEntry_create($nick, $message) function LogEntry_create($nick, $message)
{ {
@ -14,6 +14,8 @@ function LogEntry_create($nick, $message)
/** /**
* Returns log entries with maximum count of 10000. * Returns log entries with maximum count of 10000.
*
* @return array|false
*/ */
function LogEntries() function LogEntries()
{ {
@ -22,6 +24,9 @@ function LogEntries()
/** /**
* Returns log entries filtered by a keyword * Returns log entries filtered by a keyword
*
* @param string $keyword
* @return array|false
*/ */
function LogEntries_filter($keyword) function LogEntries_filter($keyword)
{ {
@ -33,6 +38,8 @@ function LogEntries_filter($keyword)
/** /**
* Delete all log entries. * Delete all log entries.
*
* @return mysqli_result|false
*/ */
function LogEntries_clear_all() function LogEntries_clear_all()
{ {

@ -2,6 +2,8 @@
/** /**
* Returns Message id array * Returns Message id array
*
* @return array|false
*/ */
function Message_ids() function Message_ids()
{ {
@ -11,8 +13,8 @@ function Message_ids()
/** /**
* Returns message by id. * Returns message by id.
* *
* @param $message_id message * @param int $message_id message ID
* ID * @return array|false|null
*/ */
function Message($message_id) function Message($message_id)
{ {
@ -31,10 +33,9 @@ function Message($message_id)
* TODO: global $user con not be used in model! * TODO: global $user con not be used in model!
* send message * send message
* *
* @param $receiver_user_id User * @param int $receiver_user_id User ID of Reciever
* ID of Reciever * @param string $text Text of Message
* @param $text Text * @return bool
* of Message
*/ */
function Message_send($receiver_user_id, $text) function Message_send($receiver_user_id, $text)
{ {

@ -15,6 +15,7 @@
* The room. Can be null, but then a shift_id must be given. * The room. Can be null, but then a shift_id must be given.
* @param int $count * @param int $count
* How many angels are needed? * How many angels are needed?
* @return false|int
*/ */
function NeededAngelType_add($shift_id, $angeltype_id, $room_id, $count) 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. * Deletes all needed angel types from given shift.
* *
* @param int $shift_id * @param int $shift_id id of the shift
* id of the shift * @return mysqli_result|false
*/ */
function NeededAngelTypes_delete_by_shift($shift_id) 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. * Deletes all needed angel types from given room.
* *
* @param int $room_id * @param int $room_id id of the room
* id of the room * @return mysqli_result|false
*/ */
function NeededAngelTypes_delete_by_room($room_id) 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. * Returns all needed angeltypes and already taken needs.
* *
* @param int $shiftID * @param int $shiftId id of shift
* id of shift * @return array
*/ */
function NeededAngelTypes_by_shift($shiftId) function NeededAngelTypes_by_shift($shiftId)
{ {

@ -4,6 +4,7 @@
* returns a list of rooms. * returns a list of rooms.
* *
* @param boolean $show_all returns also hidden rooms when true * @param boolean $show_all returns also hidden rooms when true
* @return array|false
*/ */
function Rooms($show_all = false) function Rooms($show_all = false)
{ {
@ -14,6 +15,7 @@ function Rooms($show_all = false)
* Delete a room * Delete a room
* *
* @param int $room_id * @param int $room_id
* @return mysqli_result|false
*/ */
function Room_delete($room_id) function Room_delete($room_id)
{ {
@ -29,15 +31,19 @@ function Room_delete($room_id)
* Is this a frab imported room? * Is this a frab imported room?
* @param boolean $public * @param boolean $public
* Is the room visible for angels? * 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(" $result = sql_query("
INSERT INTO `Room` SET INSERT INTO `Room` SET
`Name`='" . sql_escape($name) . "', `Name`='" . sql_escape($name) . "',
`FromPentabarf`='" . sql_escape($from_frab ? 'Y' : '') . "', `FromPentabarf`='" . sql_escape($from_frab ? 'Y' : '') . "',
`show`='" . sql_escape($public ? 'Y' : '') . "', `show`='" . sql_escape($public ? 'Y' : '') . "',
`Number`=0"); `Number`=" . (int)$number
);
if ($result === false) { if ($result === false) {
return false; return false;
} }
@ -47,7 +53,8 @@ function Room_create($name, $from_frab, $public)
/** /**
* Returns room by id. * Returns room by id.
* *
* @param $room_id RID * @param int $room_id RID
* @return array|false
*/ */
function Room($room_id) function Room($room_id)
{ {

@ -3,6 +3,8 @@
/** /**
* Returns an array with the attributes of shift entries. * Returns an array with the attributes of shift entries.
* FIXME! Needs entity object. * FIXME! Needs entity object.
*
* @return array
*/ */
function ShiftEntry_new() function ShiftEntry_new()
{ {
@ -19,14 +21,19 @@ function ShiftEntry_new()
/** /**
* Counts all freeloaded shifts. * Counts all freeloaded shifts.
*
* @return int
*/ */
function ShiftEntries_freeleaded_count() 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. * List users subsribed to a given shift.
*
* @param int $shift_id
* @return array|false
*/ */
function ShiftEntries_by_shift($shift_id) function ShiftEntries_by_shift($shift_id)
{ {
@ -52,7 +59,8 @@ function ShiftEntries_by_shift($shift_id)
/** /**
* Create a new shift entry. * Create a new shift entry.
* *
* @param ShiftEntry $shift_entry * @param array $shift_entry
* @return mysqli_result|false
*/ */
function ShiftEntry_create($shift_entry) function ShiftEntry_create($shift_entry)
{ {
@ -68,6 +76,9 @@ function ShiftEntry_create($shift_entry)
/** /**
* Update a shift entry. * Update a shift entry.
*
* @param array $shift_entry
* @return false|mysqli_result
*/ */
function ShiftEntry_update($shift_entry) function ShiftEntry_update($shift_entry)
{ {
@ -80,6 +91,9 @@ function ShiftEntry_update($shift_entry)
/** /**
* Get a shift entry. * Get a shift entry.
*
* @param int $shift_entry_id
* @return array|false|null
*/ */
function ShiftEntry($shift_entry_id) function ShiftEntry($shift_entry_id)
{ {
@ -95,6 +109,9 @@ function ShiftEntry($shift_entry_id)
/** /**
* Delete a shift entry. * Delete a shift entry.
*
* @param int $shift_entry_id
* @return mysqli_result|false
*/ */
function ShiftEntry_delete($shift_entry_id) function ShiftEntry_delete($shift_entry_id)
{ {
@ -106,7 +123,8 @@ function ShiftEntry_delete($shift_entry_id)
/** /**
* Returns next (or current) shifts of given user. * Returns next (or current) shifts of given user.
* *
* @param User $user * @param array $user
* @return array|false
*/ */
function ShiftEntries_upcoming_for_user($user) function ShiftEntries_upcoming_for_user($user)
{ {
@ -124,7 +142,8 @@ function ShiftEntries_upcoming_for_user($user)
/** /**
* Returns shifts completed by the given user. * Returns shifts completed by the given user.
* *
* @param User $user * @param array $user
* @return array|false
*/ */
function ShiftEntries_finished_by_user($user) function ShiftEntries_finished_by_user($user)
{ {
@ -145,6 +164,7 @@ function ShiftEntries_finished_by_user($user)
* *
* @param int $shift_id * @param int $shift_id
* @param int $angeltype_id * @param int $angeltype_id
* @return array|false
*/ */
function ShiftEntries_by_shift_and_angeltype($shift_id, $angeltype_id) 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. * Returns all freeloaded shifts for given user.
*
* @param array $user
* @return array|false
*/ */
function ShiftEntries_freeloaded_by_user($user) function ShiftEntries_freeloaded_by_user($user)
{ {

@ -8,7 +8,6 @@ namespace Engelsystem;
*/ */
class ShiftSignupState class ShiftSignupState
{ {
/** /**
* Shift has free places * Shift has free places
*/ */
@ -44,10 +43,18 @@ class ShiftSignupState
*/ */
const SIGNED_UP = 'SIGNED_UP'; const SIGNED_UP = 'SIGNED_UP';
/** @var string */
private $state; private $state;
/** @var int */
private $freeEntries; private $freeEntries;
/**
* ShiftSignupState constructor.
*
* @param string $state
* @param int $free_entries
*/
public function __construct($state, $free_entries) public function __construct($state, $free_entries)
{ {
$this->state = $state; $this->state = $state;
@ -69,6 +76,10 @@ class ShiftSignupState
} }
} }
/**
* @param string $state
* @return int
*/
private function valueForState($state) private function valueForState($state)
{ {
switch ($state) { switch ($state) {
@ -88,11 +99,15 @@ class ShiftSignupState
case ShiftSignupState::OCCUPIED: case ShiftSignupState::OCCUPIED:
case ShiftSignupState::ADMIN: case ShiftSignupState::ADMIN:
return 60; return 60;
default:
return 0;
} }
} }
/** /**
* Returns true, if signup is allowed * Returns true, if signup is allowed
*
* @return bool
*/ */
public function isSignupAllowed() public function isSignupAllowed()
{ {
@ -106,6 +121,8 @@ class ShiftSignupState
/** /**
* Return the shift signup state * Return the shift signup state
*
* @return string
*/ */
public function getState() public function getState()
{ {
@ -114,6 +131,8 @@ class ShiftSignupState
/** /**
* How many places are free in this shift for the angeltype? * How many places are free in this shift for the angeltype?
*
* @return int
*/ */
public function getFreeEntries() public function getFreeEntries()
{ {

@ -4,6 +4,7 @@
* Delete a shift type. * Delete a shift type.
* *
* @param int $shifttype_id * @param int $shifttype_id
* @return mysqli_result|false
*/ */
function ShiftType_delete($shifttype_id) function ShiftType_delete($shifttype_id)
{ {
@ -17,6 +18,7 @@ function ShiftType_delete($shifttype_id)
* @param string $name * @param string $name
* @param int $angeltype_id * @param int $angeltype_id
* @param string $description * @param string $description
* @return mysqli_result|false
*/ */
function ShiftType_update($shifttype_id, $name, $angeltype_id, $description) 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 string $name
* @param int $angeltype_id * @param int $angeltype_id
* @param string $description * @param string $description
* @return new shifttype id * @return int|false new shifttype id
*/ */
function ShiftType_create($name, $angeltype_id, $description) function ShiftType_create($name, $angeltype_id, $description)
{ {
@ -55,6 +57,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
*/ */
function ShiftType($shifttype_id) function ShiftType($shifttype_id)
{ {
@ -70,6 +73,8 @@ function ShiftType($shifttype_id)
/** /**
* Get all shift types. * Get all shift types.
*
* @return array|false
*/ */
function ShiftTypes() function ShiftTypes()
{ {

@ -9,12 +9,11 @@ namespace Engelsystem;
*/ */
class ShiftsFilter class ShiftsFilter
{ {
/** /**
* How long can the time interval be? * How long can the time interval be?
* 86400 = one day
*/ */
const MAX_DURATION = 86400; const MAX_DURATION = 86400;
// one day
/** /**
* Shift is completely full. * Shift is completely full.
@ -33,16 +32,28 @@ class ShiftsFilter
*/ */
private $userShiftsAdmin; private $userShiftsAdmin;
/** @var int[] */
private $filled = []; private $filled = [];
/** @var int[] */
private $rooms = []; private $rooms = [];
/** @var int[] */
private $types = []; private $types = [];
/** @var int unix timestamp */
private $startTime = null; private $startTime = null;
/** @var int unix timestamp */
private $endTime = null; private $endTime = null;
/**
* ShiftsFilter constructor.
*
* @param bool $user_shifts_admin
* @param int[] $rooms
* @param int[] $types
*/
public function __construct($user_shifts_admin, $rooms, $types) public function __construct($user_shifts_admin, $rooms, $types)
{ {
$this->user_shifts_admin = $user_shifts_admin; $this->user_shifts_admin = $user_shifts_admin;
@ -58,21 +69,33 @@ class ShiftsFilter
} }
} }
/**
* @return int unix timestamp
*/
public function getStartTime() public function getStartTime()
{ {
return $this->startTime; return $this->startTime;
} }
/**
* @param int $startTime unix timestamp
*/
public function setStartTime($startTime) public function setStartTime($startTime)
{ {
$this->startTime = $startTime; $this->startTime = $startTime;
} }
/**
* @return int unix timestamp
*/
public function getEndTime() public function getEndTime()
{ {
return $this->endTime; return $this->endTime;
} }
/**
* @param int $endTime unix timestamp
*/
public function setEndTime($endTime) public function setEndTime($endTime)
{ {
if ($endTime - $this->startTime > ShiftsFilter::MAX_DURATION) { if ($endTime - $this->startTime > ShiftsFilter::MAX_DURATION) {
@ -81,6 +104,9 @@ class ShiftsFilter
$this->endTime = $endTime; $this->endTime = $endTime;
} }
/**
* @return int[]
*/
public function getTypes() public function getTypes()
{ {
if (count($this->types) == 0) { if (count($this->types) == 0) {
@ -89,11 +115,17 @@ class ShiftsFilter
return $this->types; return $this->types;
} }
/**
* @param int[] $types
*/
public function setTypes($types) public function setTypes($types)
{ {
$this->types = $types; $this->types = $types;
} }
/**
* @return int[]
*/
public function getRooms() public function getRooms()
{ {
if (count($this->rooms) == 0) { if (count($this->rooms) == 0) {
@ -102,26 +134,41 @@ class ShiftsFilter
return $this->rooms; return $this->rooms;
} }
/**
* @param int[] $rooms
*/
public function setRooms($rooms) public function setRooms($rooms)
{ {
$this->rooms = $rooms; $this->rooms = $rooms;
} }
/**
* @return bool
*/
public function isUserShiftsAdmin() public function isUserShiftsAdmin()
{ {
return $this->userShiftsAdmin; return $this->userShiftsAdmin;
} }
/**
* @param bool $userShiftsAdmin
*/
public function setUserShiftsAdmin($userShiftsAdmin) public function setUserShiftsAdmin($userShiftsAdmin)
{ {
$this->userShiftsAdmin = $userShiftsAdmin; $this->userShiftsAdmin = $userShiftsAdmin;
} }
/**
* @return int[]
*/
public function getFilled() public function getFilled()
{ {
return $this->filled; return $this->filled;
} }
/**
* @param int[] $filled
*/
public function setFilled($filled) public function setFilled($filled)
{ {
$this->filled = $filled; $this->filled = $filled;

@ -2,6 +2,10 @@
use Engelsystem\ShiftsFilter; use Engelsystem\ShiftsFilter;
use Engelsystem\ShiftSignupState; use Engelsystem\ShiftSignupState;
/**
* @param array $room
* @return array
*/
function Shifts_by_room($room) function Shifts_by_room($room)
{ {
$result = sql_select("SELECT * FROM `Shifts` WHERE `RID`=" . sql_escape($room['RID']) . " ORDER BY `start`"); $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; return $result;
} }
/**
* @param ShiftsFilter $shiftsFilter
* @return array[]
*/
function Shifts_by_ShiftsFilter(ShiftsFilter $shiftsFilter) function Shifts_by_ShiftsFilter(ShiftsFilter $shiftsFilter)
{ {
$SQL = "SELECT * FROM ( $SQL = "SELECT * FROM (
@ -46,6 +54,10 @@ function Shifts_by_ShiftsFilter(ShiftsFilter $shiftsFilter)
return $result; return $result;
} }
/**
* @param ShiftsFilter $shiftsFilter
* @return array
*/
function NeededAngeltypes_by_ShiftsFilter(ShiftsFilter $shiftsFilter) function NeededAngeltypes_by_ShiftsFilter(ShiftsFilter $shiftsFilter)
{ {
$SQL = " $SQL = "
@ -85,6 +97,11 @@ function NeededAngeltypes_by_ShiftsFilter(ShiftsFilter $shiftsFilter)
return $result; return $result;
} }
/**
* @param array $shift
* @param array $angeltype
* @return array|null
*/
function NeededAngeltype_by_Shift_and_Angeltype($shift, $angeltype) function NeededAngeltype_by_Shift_and_Angeltype($shift, $angeltype)
{ {
$result = sql_select(" $result = sql_select("
@ -126,6 +143,10 @@ function NeededAngeltype_by_Shift_and_Angeltype($shift, $angeltype)
return $result[0]; return $result[0];
} }
/**
* @param ShiftsFilter $shiftsFilter
* @return array
*/
function ShiftEntries_by_ShiftsFilter(ShiftsFilter $shiftsFilter) function ShiftEntries_by_ShiftsFilter(ShiftsFilter $shiftsFilter)
{ {
$SQL = " $SQL = "
@ -156,8 +177,9 @@ function ShiftEntries_by_ShiftsFilter(ShiftsFilter $shiftsFilter)
/** /**
* Check if a shift collides with other shifts (in time). * Check if a shift collides with other shifts (in time).
* *
* @param Shift $shift * @param array $shift
* @param array <Shift> $shifts * @param array $shifts
* @return bool
*/ */
function Shift_collides($shift, $shifts) 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. * 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) 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) * Check if shift signup is allowed from the end users point of view (no admin like privileges)
* *
* @param Shift $shift * @param array $user
* The shift * @param array $shift The shift
* @param AngelType $angeltype * @param array $angeltype The angeltype to which the user wants to sign up
* The angeltype to which the user wants to sign up * @param array|null $user_angeltype
* @param array <Shift> $user_shifts * @param array|null $user_shifts List of the users shifts
* List of the users shifts * @param array $needed_angeltype
* @param boolean $angeltype_supporter * @param array[] $shift_entries
* True, if the user has angeltype supporter rights for the angeltype, which enables him to sign * @return ShiftSignupState
* somebody up for the shift.
*/ */
function Shift_signup_allowed_angel( function Shift_signup_allowed_angel(
$user, $user,
@ -266,6 +291,13 @@ function Shift_signup_allowed_angel(
/** /**
* Check if an angeltype supporter can sign up a user to a shift. * 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) 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. * Check if an admin can sign up a user to a shift.
* *
* @param Shift $shift * @TODO: remove $angeltype
* The shift *
* @param AngelType $angeltype * @param array|null $angeltype The angeltype to which the user wants to sign up
* 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) 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. * Check if an angel can sign up for given shift.
* *
* @param Shift $shift * @param array $signup_user
* The shift * @param array $shift The shift
* @param AngelType $angeltype * @param array $angeltype The angeltype to which the user wants to sign up
* The angeltype to which the user wants to sign up * @param array|null $user_angeltype
* @param array <Shift> $user_shifts * @param array|null $user_shifts List of the users shifts
* List of the users shifts * @param array $needed_angeltype
* @param array[] $shift_entries
* @return ShiftSignupState
*/ */
function Shift_signup_allowed( function Shift_signup_allowed(
$signup_user, $signup_user,
@ -342,6 +378,9 @@ function Shift_signup_allowed(
/** /**
* Delete a shift by its external id. * Delete a shift by its external id.
*
* @param int $shift_psid
* @return mysqli_result|false
*/ */
function Shift_delete_by_psid($shift_psid) function Shift_delete_by_psid($shift_psid)
{ {
@ -350,6 +389,9 @@ function Shift_delete_by_psid($shift_psid)
/** /**
* Delete a shift. * Delete a shift.
*
* @param int $shift_id
* @return mysqli_result
*/ */
function Shift_delete($shift_id) function Shift_delete($shift_id)
{ {
@ -364,6 +406,9 @@ function Shift_delete($shift_id)
/** /**
* Update a shift. * Update a shift.
*
* @param array $shift
* @return mysqli_result|false
*/ */
function Shift_update($shift) function Shift_update($shift)
{ {
@ -388,6 +433,9 @@ function Shift_update($shift)
/** /**
* Update a shift by its external id. * Update a shift by its external id.
*
* @param array $shift
* @return mysqli_result|false|null
*/ */
function Shift_update_by_psid($shift) function Shift_update_by_psid($shift)
{ {
@ -405,7 +453,8 @@ function Shift_update_by_psid($shift)
/** /**
* Create a new 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) function Shift_create($shift)
{ {
@ -430,20 +479,24 @@ function Shift_create($shift)
/** /**
* Return users shifts. * Return users shifts.
*
* @param array $user
* @param bool $include_freeload_comments
* @return array
*/ */
function Shifts_by_user($user, $include_freeload_comments = false) function Shifts_by_user($user, $include_freeload_comments = false)
{ {
$result = sql_select(" $result = sql_select("
SELECT `ShiftTypes`.`id` as `shifttype_id`, `ShiftTypes`.`name`, SELECT `ShiftTypes`.`id` AS `shifttype_id`, `ShiftTypes`.`name`,
`ShiftEntry`.`id`, `ShiftEntry`.`SID`, `ShiftEntry`.`TID`, `ShiftEntry`.`UID`, `ShiftEntry`.`freeloaded`, `ShiftEntry`.`Comment`, `ShiftEntry`.`id`, `ShiftEntry`.`SID`, `ShiftEntry`.`TID`, `ShiftEntry`.`UID`, `ShiftEntry`.`freeloaded`, `ShiftEntry`.`Comment`,
" . ($include_freeload_comments ? "`ShiftEntry`.`freeload_comment`, " : "") . " " . ($include_freeload_comments ? "`ShiftEntry`.`freeload_comment`, " : "") . "
`Shifts`.*, `Room`.* `Shifts`.*, `Room`.*
FROM `ShiftEntry` FROM `ShiftEntry`
JOIN `Shifts` ON (`ShiftEntry`.`SID` = `Shifts`.`SID`) JOIN `Shifts` ON (`ShiftEntry`.`SID` = `Shifts`.`SID`)
JOIN `ShiftTypes` ON (`ShiftTypes`.`id` = `Shifts`.`shifttype_id`) JOIN `ShiftTypes` ON (`ShiftTypes`.`id` = `Shifts`.`shifttype_id`)
JOIN `Room` ON (`Shifts`.`RID` = `Room`.`RID`) JOIN `Room` ON (`Shifts`.`RID` = `Room`.`RID`)
WHERE `UID`='" . sql_escape($user['UID']) . "' WHERE `UID`='" . sql_escape($user['UID']) . "'
ORDER BY `start` ORDER BY `start`
"); ");
if ($result === false) { if ($result === false) {
engelsystem_error('Unable to load users shifts.'); engelsystem_error('Unable to load users shifts.');
@ -454,8 +507,8 @@ function Shifts_by_user($user, $include_freeload_comments = false)
/** /**
* Returns Shift by id. * Returns Shift by id.
* *
* @param $shift_id Shift * @param int $shift_id Shift ID
* ID * @return array|null
*/ */
function Shift($shift_id) function Shift($shift_id)
{ {
@ -494,14 +547,16 @@ function Shift($shift_id)
/** /**
* Returns all shifts with needed angeltypes and count of subscribed jobs. * Returns all shifts with needed angeltypes and count of subscribed jobs.
*
* @return array|false
*/ */
function Shifts() function Shifts()
{ {
$shifts_source = sql_select(" $shifts_source = sql_select("
SELECT `ShiftTypes`.`name`, `Shifts`.*, `Room`.`RID`, `Room`.`Name` AS `room_name` SELECT `ShiftTypes`.`name`, `Shifts`.*, `Room`.`RID`, `Room`.`Name` AS `room_name`
FROM `Shifts` FROM `Shifts`
JOIN `ShiftTypes` ON (`ShiftTypes`.`id` = `Shifts`.`shifttype_id`) JOIN `ShiftTypes` ON (`ShiftTypes`.`id` = `Shifts`.`shifttype_id`)
JOIN `Room` ON `Room`.`RID` = `Shifts`.`RID` JOIN `Room` ON `Room`.`RID` = `Shifts`.`RID`
"); ");
if ($shifts_source === false) { if ($shifts_source === false) {
return false; return false;

@ -7,10 +7,8 @@
/** /**
* Checks if a user joined an angeltype. * Checks if a user joined an angeltype.
* *
* @param User $user * @param array $user The user to be checked
* The user to be checked * @param array $angeltype The angeltype to be checked
* @param Angeltype $angeltype
* The angeltype to be checked
* @return boolean * @return boolean
*/ */
function UserAngelType_exists($user, $angeltype) function UserAngelType_exists($user, $angeltype)
@ -26,7 +24,8 @@ function UserAngelType_exists($user, $angeltype)
/** /**
* List users angeltypes. * List users angeltypes.
* *
* @param User $user * @param array $user
* @return array|false
*/ */
function User_angeltypes($user) 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. * 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) 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. * Returns true if user is angeltype supporter or has privilege admin_user_angeltypes.
* *
* @param User $user * @param array $user
* @param AngelType $angeltype * @param array $angeltype
* @return bool
*/ */
function User_is_AngelType_supporter(&$user, $angeltype) function User_is_AngelType_supporter(&$user, $angeltype)
{ {
@ -97,6 +98,7 @@ function User_is_AngelType_supporter(&$user, $angeltype)
* *
* @param int $user_angeltype_id * @param int $user_angeltype_id
* @param bool $supporter * @param bool $supporter
* @return mysqli_result
*/ */
function UserAngelType_update($user_angeltype_id, $supporter) 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. * Delete all unconfirmed UserAngelTypes for given Angeltype.
* *
* @param int $angeltype_id * @param int $angeltype_id
* @return mysqli_result
*/ */
function UserAngelTypes_delete_all($angeltype_id) function UserAngelTypes_delete_all($angeltype_id)
{ {
@ -133,8 +136,9 @@ function UserAngelTypes_delete_all($angeltype_id)
/** /**
* Confirm all unconfirmed UserAngelTypes for given Angeltype. * Confirm all unconfirmed UserAngelTypes for given Angeltype.
* *
* @param int $angeltype_id * @param int $angeltype_id
* @param User $confirm_user * @param array $confirm_user
* @return mysqli_result
*/ */
function UserAngelTypes_confirm_all($angeltype_id, $confirm_user) 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. * Confirm an UserAngelType with confirming user.
* *
* @param int $user_angeltype_id * @param int $user_angeltype_id
* @param User $confirm_user * @param array $confirm_user
* @return mysqli_result
*/ */
function UserAngelType_confirm($user_angeltype_id, $confirm_user) function UserAngelType_confirm($user_angeltype_id, $confirm_user)
{ {
@ -172,7 +177,8 @@ function UserAngelType_confirm($user_angeltype_id, $confirm_user)
/** /**
* Delete an UserAngelType. * Delete an UserAngelType.
* *
* @param UserAngelType $user_angeltype * @param array $user_angeltype
* @return mysqli_result|false
*/ */
function UserAngelType_delete($user_angeltype) function UserAngelType_delete($user_angeltype)
{ {
@ -185,8 +191,9 @@ function UserAngelType_delete($user_angeltype)
/** /**
* Create an UserAngelType. * Create an UserAngelType.
* *
* @param User $user * @param array $user
* @param Angeltype $angeltype * @param array $angeltype
* @return int
*/ */
function UserAngelType_create($user, $angeltype) function UserAngelType_create($user, $angeltype)
{ {
@ -204,6 +211,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
*/ */
function UserAngelType($user_angeltype_id) function UserAngelType($user_angeltype_id)
{ {
@ -224,8 +232,9 @@ function UserAngelType($user_angeltype_id)
/** /**
* Get an UserAngelType by user and angeltype. * Get an UserAngelType by user and angeltype.
* *
* @param User $user * @param array $user
* @param Angeltype $angeltype * @param array $angeltype
* @return array|null
*/ */
function UserAngelType_by_User_and_AngelType($user, $angeltype) function UserAngelType_by_User_and_AngelType($user, $angeltype)
{ {

@ -3,6 +3,8 @@
/** /**
* Returns a new empty UserDriverLicense * Returns a new empty UserDriverLicense
* FIXME entity object needed * FIXME entity object needed
*
* @return array
*/ */
function UserDriverLicense_new() function UserDriverLicense_new()
{ {
@ -20,8 +22,7 @@ function UserDriverLicense_new()
/** /**
* Is it valid? * Is it valid?
* *
* @param UserDriverLicense $user_driver_license * @param array $user_driver_license The UserDriverLicense to check
* The UserDriverLicense to check
* @return boolean * @return boolean
*/ */
function UserDriverLicense_valid($user_driver_license) function UserDriverLicense_valid($user_driver_license)
@ -37,8 +38,8 @@ function UserDriverLicense_valid($user_driver_license)
/** /**
* Get a users driver license information * Get a users driver license information
* *
* @param int $user_id * @param int $user_id The users id
* The users id * @return array|false|null
*/ */
function UserDriverLicense($user_id) function UserDriverLicense($user_id)
{ {
@ -47,17 +48,20 @@ function UserDriverLicense($user_id)
engelsystem_error('Unable to load user driver license.'); engelsystem_error('Unable to load user driver license.');
return false; 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 * Create a user's driver license entry
* *
* @param UserDriverLicense $user_driver_license * @param array $user_driver_license The UserDriverLicense to create
* The UserDriverLicense to create * @param array $user
* @return array
*/ */
function UserDriverLicenses_create($user_driver_license, $user) 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 * Update a user's driver license entry
* *
* @param UserDriverLicense $user_driver_license * @param array $user_driver_license The UserDriverLicense to update
* The UserDriverLicense to update * @return mysqli_result
*/ */
function UserDriverLicenses_update($user_driver_license) function UserDriverLicenses_update($user_driver_license)
{ {
@ -103,6 +107,7 @@ function UserDriverLicenses_update($user_driver_license)
* Delete a user's driver license entry * Delete a user's driver license entry
* *
* @param int $user_id * @param int $user_id
* @return mysqli_result
*/ */
function UserDriverLicenses_delete($user_id) function UserDriverLicenses_delete($user_id)
{ {

@ -3,7 +3,8 @@
/** /**
* Returns users groups * Returns users groups
* *
* @param User $user * @param array $user
* @return array|false
*/ */
function User_groups($user) function User_groups($user)
{ {

@ -9,6 +9,7 @@ use Engelsystem\ValidationResult;
* Delete a user * Delete a user
* *
* @param int $user_id * @param int $user_id
* @return mysqli_result|false
*/ */
function User_delete($user_id) function User_delete($user_id)
{ {
@ -18,7 +19,8 @@ function User_delete($user_id)
/** /**
* Update user. * Update user.
* *
* @param User $user * @param array $user
* @return mysqli_result|false
*/ */
function User_update($user) function User_update($user)
{ {
@ -53,27 +55,41 @@ function User_update($user)
/** /**
* Counts all forced active users. * Counts all forced active users.
*
* @return string|null
*/ */
function User_force_active_count() function User_force_active_count()
{ {
return sql_select_single_cell("SELECT COUNT(*) FROM `User` WHERE `force_active` = 1"); return sql_select_single_cell("SELECT COUNT(*) FROM `User` WHERE `force_active` = 1");
} }
/**
* @return string|null
*/
function User_active_count() function User_active_count()
{ {
return sql_select_single_cell("SELECT COUNT(*) FROM `User` WHERE `Aktiv` = 1"); return sql_select_single_cell("SELECT COUNT(*) FROM `User` WHERE `Aktiv` = 1");
} }
/**
* @return string|null
*/
function User_got_voucher_count() function User_got_voucher_count()
{ {
return sql_select_single_cell("SELECT SUM(`got_voucher`) FROM `User`"); return sql_select_single_cell("SELECT SUM(`got_voucher`) FROM `User`");
} }
/**
* @return string|null
*/
function User_arrived_count() function User_arrived_count()
{ {
return sql_select_single_cell("SELECT COUNT(*) FROM `User` WHERE `Gekommen` = 1"); return sql_select_single_cell("SELECT COUNT(*) FROM `User` WHERE `Gekommen` = 1");
} }
/**
* @return string|null
*/
function User_tshirts_count() function User_tshirts_count()
{ {
return sql_select_single_cell("SELECT COUNT(*) FROM `User` WHERE `Tshirt` = 1"); 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. * Returns all column names for sorting in an array.
*
* @return array
*/ */
function User_sortable_columns() function User_sortable_columns()
{ {
@ -104,6 +122,7 @@ function User_sortable_columns()
* Get all users, ordered by Nick by default or by given param. * Get all users, ordered by Nick by default or by given param.
* *
* @param string $order_by * @param string $order_by
* @return array|false
*/ */
function Users($order_by = 'Nick') function Users($order_by = 'Nick')
{ {
@ -113,7 +132,8 @@ function Users($order_by = 'Nick')
/** /**
* Returns true if user is freeloader * Returns true if user is freeloader
* *
* @param User $user * @param array $user
* @return bool
*/ */
function User_is_freeloader($user) function User_is_freeloader($user)
{ {
@ -125,7 +145,8 @@ function User_is_freeloader($user)
/** /**
* Returns all users that are not member of given angeltype. * 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) function Users_by_angeltype_inverted($angeltype)
{ {
@ -145,7 +166,8 @@ function Users_by_angeltype_inverted($angeltype)
/** /**
* Returns all members of given angeltype. * Returns all members of given angeltype.
* *
* @param Angeltype $angeltype * @param array $angeltype
* @return array
*/ */
function Users_by_angeltype($angeltype) function Users_by_angeltype($angeltype)
{ {
@ -169,6 +191,8 @@ function Users_by_angeltype($angeltype)
/** /**
* Returns User id array * Returns User id array
*
* @return array|false
*/ */
function User_ids() function User_ids()
{ {
@ -179,6 +203,7 @@ function User_ids()
* Strip unwanted characters from a users nick. * Strip unwanted characters from a users nick.
* *
* @param string $nick * @param string $nick
* @return string
*/ */
function User_validate_Nick($nick) function User_validate_Nick($nick)
{ {
@ -218,8 +243,7 @@ function User_validate_jabber($jabber)
/** /**
* Validate the planned arrival date * Validate the planned arrival date
* *
* @param int $planned_arrival_date * @param int $planned_arrival_date Unix timestamp
* Unix timestamp
* @return ValidationResult * @return ValidationResult
*/ */
function User_validate_planned_arrival_date($planned_arrival_date) 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. * Returns user by id.
* *
* @param $user_id UID * @param int $user_id UID
* @return array|null
*/ */
function User($user_id) function User($user_id)
{ {
@ -301,7 +326,7 @@ function User($user_id)
* *
* @param string $api_key * @param string $api_key
* User 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) function User_by_api_key($api_key)
{ {
@ -319,7 +344,7 @@ function User_by_api_key($api_key)
* Returns User by email. * Returns User by email.
* *
* @param string $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) function User_by_email($email)
{ {
@ -337,7 +362,7 @@ function User_by_email($email)
* Returns User by password token. * Returns User by password token.
* *
* @param string $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) 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. * 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) function User_reset_api_key(&$user, $log = true)
{ {
@ -363,15 +390,19 @@ function User_reset_api_key(&$user, $log = true)
if ($result === false) { if ($result === false) {
return false; return false;
} }
if ($log) { if ($log) {
engelsystem_log(sprintf("API key resetted (%s).", User_Nick_render($user))); engelsystem_log(sprintf("API key resetted (%s).", User_Nick_render($user)));
} }
return true;
} }
/** /**
* Generates a new password recovery token for given user. * Generates a new password recovery token for given user.
* *
* @param User $user * @param array $user
* @return string
*/ */
function User_generate_password_recovery_token(&$user) function User_generate_password_recovery_token(&$user)
{ {
@ -384,6 +415,10 @@ function User_generate_password_recovery_token(&$user)
return $user['password_recovery_token']; return $user['password_recovery_token'];
} }
/**
* @param array $user
* @return float
*/
function User_get_eligable_voucher_count(&$user) function User_get_eligable_voucher_count(&$user)
{ {
global $voucher_settings; global $voucher_settings;

@ -8,17 +8,15 @@ namespace Engelsystem;
*/ */
class ValidationResult class ValidationResult
{ {
/** @var bool */
private $valid; private $valid;
/** @var mixed */
private $value; private $value;
/** /**
* Constructor. * @param boolean $valid Is the value valid?
* * @param mixed $value The validated value
* @param boolean $valid
* Is the value valid?
* @param * $value
* The validated value
*/ */
public function __construct($valid, $value) public function __construct($valid, $value)
{ {
@ -28,6 +26,8 @@ class ValidationResult
/** /**
* Is the value valid? * Is the value valid?
*
* @return bool
*/ */
public function isValid() public function isValid()
{ {
@ -36,6 +36,8 @@ class ValidationResult
/** /**
* The parsed/validated value. * The parsed/validated value.
*
* @return mixed
*/ */
public function getValue() public function getValue()
{ {

@ -1,7 +1,11 @@
<?php <?php
/** @var mysqli $sql_connection */
$sql_connection = null;
/** /**
* Close connection. * Close connection.
*
* @return bool
*/ */
function sql_close() function sql_close()
{ {
@ -12,6 +16,9 @@ function sql_close()
/** /**
* Return NULL if given value is null. * Return NULL if given value is null.
*
* @param mixed $value
* @return bool
*/ */
function sql_null($value = null) function sql_null($value = null)
{ {
@ -20,6 +27,8 @@ function sql_null($value = null)
/** /**
* Start new transaction. * Start new transaction.
*
* @return mysqli_result|bool
*/ */
function sql_transaction_start() function sql_transaction_start()
{ {
@ -34,6 +43,8 @@ function sql_transaction_start()
/** /**
* Commit transaction. * Commit transaction.
*
* @return mysqli_result|bool
*/ */
function sql_transaction_commit() function sql_transaction_commit()
{ {
@ -48,6 +59,8 @@ function sql_transaction_commit()
/** /**
* Stop transaction, revert database. * Stop transaction, revert database.
*
* @return mysqli_result|bool
*/ */
function sql_transaction_rollback() function sql_transaction_rollback()
{ {
@ -68,6 +81,7 @@ function sql_transaction_rollback()
*/ */
function sql_error($message) function sql_error($message)
{ {
// @TODO: Bad idea..
sql_close(); sql_close();
$message = trim($message) . "\n"; $message = trim($message) . "\n";
@ -81,15 +95,11 @@ function sql_error($message)
/** /**
* Connect to mysql server. * Connect to mysql server.
* *
* @param string $host * @param string $host Host
* Host * @param string $user Username
* @param string $user * @param string $pass Password
* Username * @param string $db_name DB to select
* @param string $pass * @return mysqli|false The connection handler
* Password
* @param string $db_name
* DB to select
* @return mysqli The connection handler
*/ */
function sql_connect($host, $user, $pass, $db_name) function sql_connect($host, $user, $pass, $db_name)
{ {
@ -117,8 +127,7 @@ function sql_connect($host, $user, $pass, $db_name)
/** /**
* Change the selected db in current mysql-connection. * Change the selected db in current mysql-connection.
* *
* @param * @param $db_name
* $db_name
* @return bool true on success, false on error * @return bool true on success, false on error
*/ */
function sql_select_db($db_name) function sql_select_db($db_name)
@ -134,15 +143,12 @@ function sql_select_db($db_name)
* MySQL SELECT query * MySQL SELECT query
* *
* @param string $query * @param string $query
* @return Result array or false on error * @return array|false Result array or false on error
*/ */
function sql_select($query) function sql_select($query)
{ {
global $sql_connection; global $sql_connection;
// echo $query . ";\n";
// echo debug_string_backtrace() . "\n";
$result = $sql_connection->query($query); $result = $sql_connection->query($query);
if ($result) { if ($result) {
$data = []; $data = [];
@ -159,7 +165,7 @@ function sql_select($query)
* MySQL execute a query * MySQL execute a query
* *
* @param string $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) function sql_query($query)
{ {
@ -224,7 +230,21 @@ function sql_select_single_col($query)
return array_map('array_shift', $result); return array_map('array_shift', $result);
} }
/**
* @param string $query
* @return string|null
*/
function sql_select_single_cell($query) 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);
} }

@ -1,10 +1,16 @@
<?php <?php
/**
* @return string
*/
function admin_active_title() function admin_active_title()
{ {
return _("Active angels"); return _("Active angels");
} }
/**
* @return string
*/
function admin_active() function admin_active()
{ {
global $tshirt_sizes, $shift_sum_formula; global $tshirt_sizes, $shift_sum_formula;
@ -110,7 +116,10 @@ function admin_active()
} }
$users = sql_select(" $users = sql_select("
SELECT `User`.*, COUNT(`ShiftEntry`.`id`) as `shift_count`, ${shift_sum_formula} as `shift_length` SELECT
`User`.*,
COUNT(`ShiftEntry`.`id`) AS `shift_count`,
${shift_sum_formula} AS `shift_length`
FROM `User` LEFT JOIN `ShiftEntry` ON `User`.`UID` = `ShiftEntry`.`UID` FROM `User` LEFT JOIN `ShiftEntry` ON `User`.`UID` = `ShiftEntry`.`UID`
LEFT JOIN `Shifts` ON `ShiftEntry`.`SID` = `Shifts`.`SID` " . ($show_all_shifts ? "" : "AND (`Shifts`.`end` < " . time() . " OR `Shifts`.`end` IS NULL)") . " LEFT JOIN `Shifts` ON `ShiftEntry`.`SID` = `Shifts`.`SID` " . ($show_all_shifts ? "" : "AND (`Shifts`.`end` < " . time() . " OR `Shifts`.`end` IS NULL)") . "
WHERE `User`.`Gekommen` = 1 WHERE `User`.`Gekommen` = 1
@ -186,7 +195,7 @@ function admin_active()
form_text('count', _("How much angels should be active?"), $count), form_text('count', _("How much angels should be active?"), $count),
form_submit('set_active', _("Preview")) form_submit('set_active', _("Preview"))
]) : $set_active, ]) : $set_active,
msg(), $msg . msg(),
table([ table([
'nick' => _("Nickname"), 'nick' => _("Nickname"),
'shirt_size' => _("Size"), 'shirt_size' => _("Size"),

@ -1,10 +1,16 @@
<?php <?php
/**
* @return string
*/
function admin_arrive_title() function admin_arrive_title()
{ {
return _("Arrived angels"); return _("Arrived angels");
} }
/**
* @return string
*/
function admin_arrive() function admin_arrive()
{ {
$msg = ""; $msg = "";
@ -138,7 +144,7 @@ function admin_arrive()
} }
return page_with_title(admin_arrive_title(), [ return page_with_title(admin_arrive_title(), [
msg(), $msg . msg(),
form([ form([
form_text('search', _("Search"), $search), form_text('search', _("Search"), $search),
form_submit('submit', _("Search")) form_submit('submit', _("Search"))

@ -1,10 +1,16 @@
<?php <?php
/**
* @return string
*/
function admin_free_title() function admin_free_title()
{ {
return _("Free angels"); return _("Free angels");
} }
/**
* @return string
*/
function admin_free() function admin_free()
{ {
global $privileges; global $privileges;

@ -1,10 +1,16 @@
<?php <?php
/**
* @return string
*/
function admin_groups_title() function admin_groups_title()
{ {
return _("Grouprights"); return _("Grouprights");
} }
/**
* @return string
*/
function admin_groups() function admin_groups()
{ {
$html = ""; $html = "";
@ -53,7 +59,6 @@ function admin_groups()
$group = sql_select("SELECT * FROM `Groups` WHERE `UID`='" . sql_escape($group_id) . "' LIMIT 1"); $group = sql_select("SELECT * FROM `Groups` WHERE `UID`='" . sql_escape($group_id) . "' LIMIT 1");
if (count($group) > 0) { if (count($group) > 0) {
list($group) = $group;
$privileges = sql_select(" $privileges = sql_select("
SELECT `Privileges`.*, `GroupPrivileges`.`group_id` SELECT `Privileges`.*, `GroupPrivileges`.`group_id`
FROM `Privileges` FROM `Privileges`

@ -1,10 +1,16 @@
<?php <?php
/**
* @return string
*/
function admin_import_title() function admin_import_title()
{ {
return _("Frab import"); return _("Frab import");
} }
/**
* @return string
*/
function admin_import() function admin_import()
{ {
global $rooms_import; global $rooms_import;
@ -290,6 +296,10 @@ function admin_import()
]); ]);
} }
/**
* @param string $file
* @return array
*/
function prepare_rooms($file) function prepare_rooms($file)
{ {
global $rooms_import; global $rooms_import;
@ -323,6 +333,13 @@ function prepare_rooms($file)
]; ];
} }
/**
* @param string $file
* @param int $shifttype_id
* @param int $add_minutes_start
* @param int $add_minutes_end
* @return array
*/
function prepare_events($file, $shifttype_id, $add_minutes_start, $add_minutes_end) function prepare_events($file, $shifttype_id, $add_minutes_start, $add_minutes_end)
{ {
global $rooms_import; global $rooms_import;
@ -384,6 +401,10 @@ function prepare_events($file, $shifttype_id, $add_minutes_start, $add_minutes_e
]; ];
} }
/**
* @param string $file
* @return SimpleXMLElement
*/
function read_xml($file) function read_xml($file)
{ {
global $xml_import; global $xml_import;
@ -393,6 +414,11 @@ function read_xml($file)
return $xml_import; return $xml_import;
} }
/**
* @param array $shifts
* @param array $shifttypes
* @return array
*/
function shifts_printable($shifts, $shifttypes) function shifts_printable($shifts, $shifttypes)
{ {
global $rooms_import; global $rooms_import;
@ -417,6 +443,11 @@ function shifts_printable($shifts, $shifttypes)
return $shifts_printable; return $shifts_printable;
} }
/**
* @param array $shift_a
* @param array $shift_b
* @return int
*/
function shift_sort($shift_a, $shift_b) function shift_sort($shift_a, $shift_b)
{ {
return ($shift_a['start'] < $shift_b['start']) ? -1 : 1; return ($shift_a['start'] < $shift_b['start']) ? -1 : 1;

@ -1,10 +1,16 @@
<?php <?php
/**
* @return string
*/
function admin_log_title() function admin_log_title()
{ {
return _("Log"); return _("Log");
} }
/**
* @return string
*/
function admin_log() function admin_log()
{ {
$filter = ""; $filter = "";

@ -1,5 +1,8 @@
<?php <?php
/**
* @return string
*/
function admin_news() function admin_news()
{ {
global $user; global $user;
@ -19,12 +22,10 @@ function admin_news()
if (empty($news)) { if (empty($news)) {
return error("No News found.", true); return error("No News found.", true);
} }
switch ($_REQUEST["action"]) { switch ($_REQUEST["action"]) {
default:
redirect(page_link_to('news'));
case 'edit': case 'edit':
list($news) = $news; list($news) = $news;
$user_source = User($news['UID']); $user_source = User($news['UID']);
$html .= form([ $html .= form([
@ -42,8 +43,6 @@ function admin_news()
break; break;
case 'save': case 'save':
list($news) = $news;
sql_query("UPDATE `News` SET sql_query("UPDATE `News` SET
`Datum`='" . sql_escape(time()) . "', `Datum`='" . sql_escape(time()) . "',
`Betreff`='" . sql_escape($_POST["eBetreff"]) . "', `Betreff`='" . sql_escape($_POST["eBetreff"]) . "',
@ -58,12 +57,13 @@ function admin_news()
case 'delete': case 'delete':
list($news) = $news; list($news) = $news;
sql_query("DELETE FROM `News` WHERE `ID`='" . sql_escape($news_id) . "' LIMIT 1"); sql_query("DELETE FROM `News` WHERE `ID`='" . sql_escape($news_id) . "' LIMIT 1");
engelsystem_log("News deleted: " . $news['Betreff']); engelsystem_log("News deleted: " . $news['Betreff']);
success(_("News entry deleted.")); success(_("News entry deleted."));
redirect(page_link_to("news")); redirect(page_link_to("news"));
break; break;
default:
redirect(page_link_to('news'));
} }
return $html . '</div>'; return $html . '</div>';
} }

@ -1,5 +1,8 @@
<?php <?php
/**
* @return string
*/
function admin_questions_title() function admin_questions_title()
{ {
return _("Answer questions"); return _("Answer questions");
@ -7,6 +10,8 @@ function admin_questions_title()
/** /**
* Renders a hint for new questions to answer. * Renders a hint for new questions to answer.
*
* @return string|null
*/ */
function admin_new_questions() function admin_new_questions()
{ {
@ -25,6 +30,9 @@ function admin_new_questions()
return null; return null;
} }
/**
* @return string
*/
function admin_questions() function admin_questions()
{ {
global $user; global $user;
@ -136,4 +144,6 @@ function admin_questions()
break; break;
} }
} }
return '';
} }

@ -1,10 +1,16 @@
<?php <?php
/**
* @return string
*/
function admin_rooms_title() function admin_rooms_title()
{ {
return _("Rooms"); return _("Rooms");
} }
/**
* @return string
*/
function admin_rooms() function admin_rooms()
{ {
$rooms_source = sql_select("SELECT * FROM `Room` ORDER BY `Name`"); $rooms_source = sql_select("SELECT * FROM `Room` ORDER BY `Name`");
@ -28,6 +34,7 @@ function admin_rooms()
$from_pentabarf = ""; $from_pentabarf = "";
$public = 'Y'; $public = 'Y';
$number = ""; $number = "";
$room_id = 0;
$angeltypes_source = sql_select("SELECT * FROM `AngelTypes` ORDER BY `name`"); $angeltypes_source = sql_select("SELECT * FROM `AngelTypes` ORDER BY `name`");
$angeltypes = []; $angeltypes = [];
@ -99,7 +106,7 @@ function admin_rooms()
$angeltypes_count[$angeltype_id] = $_REQUEST['angeltype_count_' . $angeltype_id]; $angeltypes_count[$angeltype_id] = $_REQUEST['angeltype_count_' . $angeltype_id];
} else { } else {
$valid = false; $valid = false;
$msg .= error(sprintf(_("Please enter needed angels for type %s.", $angeltype)), true); $msg .= error(sprintf(_("Please enter needed angels for type %s."), $angeltype), true);
} }
} }

@ -1,16 +1,22 @@
<?php <?php
/**
* @return string
*/
function admin_shifts_title() function admin_shifts_title()
{ {
return _("Create shifts"); return _("Create shifts");
} }
// Assistent zum Anlegen mehrerer neuer Schichten /**
* Assistent zum Anlegen mehrerer neuer Schichten
*
* @return string
*/
function admin_shifts() function admin_shifts()
{ {
$valid = true; $valid = true;
$rid = 0;
$start = parse_date("Y-m-d H:i", date("Y-m-d") . " 00:00"); $start = parse_date("Y-m-d H:i", date("Y-m-d") . " 00:00");
$end = $start; $end = $start;
$mode = 'single'; $mode = 'single';
@ -177,9 +183,9 @@ function admin_shifts()
'shifttype_id' => $shifttype_id 'shifttype_id' => $shifttype_id
]; ];
} elseif ($mode == 'multi') { } elseif ($mode == 'multi') {
$shift_start = $start; $shift_start = (int)$start;
do { do {
$shift_end = $shift_start + $length * 60; $shift_end = $shift_start + (int)$length * 60;
if ($shift_end > $end) { if ($shift_end > $end) {
$shift_end = $end; $shift_end = $end;
@ -298,6 +304,7 @@ function admin_shifts()
redirect(page_link_to('admin_shifts')); redirect(page_link_to('admin_shifts'));
} }
$needed_angel_types_info = [];
foreach ($_SESSION['admin_shifts_shifts'] as $shift) { foreach ($_SESSION['admin_shifts_shifts'] as $shift) {
$shift['URL'] = null; $shift['URL'] = null;
$shift['PSID'] = null; $shift['PSID'] = null;
@ -312,7 +319,7 @@ function admin_shifts()
. " from " . date("Y-m-d H:i", $shift['start']) . " from " . date("Y-m-d H:i", $shift['start'])
. " to " . date("Y-m-d H:i", $shift['end']) . " to " . date("Y-m-d H:i", $shift['end'])
); );
$needed_angel_types_info = [];
foreach ($_SESSION['admin_shifts_types'] as $type_id => $count) { foreach ($_SESSION['admin_shifts_types'] as $type_id => $count) {
$angel_type_source = sql_select("SELECT * FROM `AngelTypes` WHERE `id`='" . sql_escape($type_id) . "' LIMIT 1"); $angel_type_source = sql_select("SELECT * FROM `AngelTypes` WHERE `id`='" . sql_escape($type_id) . "' LIMIT 1");
if (count($angel_type_source) > 0) { if (count($angel_type_source) > 0) {

@ -1,13 +1,19 @@
<?php <?php
/**
* @return string
*/
function admin_user_title() function admin_user_title()
{ {
return _("All Angels"); return _("All Angels");
} }
/**
* @return string
*/
function admin_user() function admin_user()
{ {
global $user, $privileges, $tshirt_sizes, $privileges; global $user, $tshirt_sizes, $privileges;
$html = ''; $html = '';
@ -109,7 +115,7 @@ function admin_user()
$groups = sql_select("SELECT * FROM `Groups` LEFT OUTER JOIN `UserGroups` ON (`UserGroups`.`group_id` = `Groups`.`UID` AND `UserGroups`.`uid` = '" . sql_escape($user_id) . "') WHERE `Groups`.`UID` >= '" . sql_escape($my_highest_group) . "' ORDER BY `Groups`.`Name`"); $groups = sql_select("SELECT * FROM `Groups` LEFT OUTER JOIN `UserGroups` ON (`UserGroups`.`group_id` = `Groups`.`UID` AND `UserGroups`.`uid` = '" . sql_escape($user_id) . "') WHERE `Groups`.`UID` >= '" . sql_escape($my_highest_group) . "' ORDER BY `Groups`.`Name`");
foreach ($groups as $group) { foreach ($groups as $group) {
$html .= '<tr><td><input type="checkbox" name="groups[]" value="' . $group['UID'] . '"' . ($group['group_id'] != "" ? ' checked="checked"' : '') . ' /></td><td>' . $group['Name'] . '</td></tr>'; $html .= '<tr><td><input type="checkbox" name="groups[]" value="' . $group['UID'] . '" ' . ($group['group_id'] != "" ? ' checked="checked"' : '') . ' /></td><td>' . $group['Name'] . '</td></tr>';
} }
$html .= '</table>'; $html .= '</table>';
@ -167,6 +173,7 @@ function admin_user()
case 'save': case 'save':
$force_active = $user['force_active']; $force_active = $user['force_active'];
$user_source = User($user_id);
if (in_array('admin_active', $privileges)) { if (in_array('admin_active', $privileges)) {
$force_active = $_REQUEST['force_active']; $force_active = $_REQUEST['force_active'];
} }
@ -178,7 +185,7 @@ function admin_user()
`Handy` = '" . sql_escape($_POST["eHandy"]) . "', `Handy` = '" . sql_escape($_POST["eHandy"]) . "',
`Alter` = '" . sql_escape($_POST["eAlter"]) . "', `Alter` = '" . sql_escape($_POST["eAlter"]) . "',
`DECT` = '" . sql_escape($_POST["eDECT"]) . "', `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"]) . "', `jabber` = '" . sql_escape($_POST["ejabber"]) . "',
`Size` = '" . sql_escape($_POST["eSize"]) . "', `Size` = '" . sql_escape($_POST["eSize"]) . "',
`Gekommen`= '" . sql_escape($_POST["eGekommen"]) . "', `Gekommen`= '" . sql_escape($_POST["eGekommen"]) . "',

@ -1,9 +1,16 @@
<?php <?php
/**
* @return string
*/
function credits_title() function credits_title()
{ {
return _("Credits"); return _("Credits");
} }
/**
* @return string
*/
function guest_credits() function guest_credits()
{ {
return template_render(__DIR__ . '/../../templates/guest_credits.html', []); return template_render(__DIR__ . '/../../templates/guest_credits.html', []);

@ -1,21 +1,34 @@
<?php <?php
/**
* @return string
*/
function login_title() function login_title()
{ {
return _("Login"); return _("Login");
} }
/**
* @return string
*/
function register_title() function register_title()
{ {
return _("Register"); return _("Register");
} }
/**
* @return string
*/
function logout_title() function logout_title()
{ {
return _("Logout"); return _("Logout");
} }
// Engel registrieren /**
* Engel registrieren
*
* @return string
*/
function guest_register() function guest_register()
{ {
global $tshirt_sizes, $enable_tshirt_size, $default_theme, $user, $min_password_length; global $tshirt_sizes, $enable_tshirt_size, $default_theme, $user, $min_password_length;
@ -335,6 +348,7 @@ function guest_logout()
{ {
session_destroy(); session_destroy();
redirect(page_link_to("start")); redirect(page_link_to("start"));
return true;
} }
function guest_login() function guest_login()
@ -368,7 +382,7 @@ function guest_login()
error(_("Please enter a nickname.")); error(_("Please enter a nickname."));
} }
if ($valid) { if ($valid && !empty($login_user)) {
$_SESSION['uid'] = $login_user['UID']; $_SESSION['uid'] = $login_user['UID'];
$_SESSION['locale'] = $login_user['Sprache']; $_SESSION['locale'] = $login_user['Sprache'];

@ -2,4 +2,5 @@
function guest_start() function guest_start()
{ {
redirect(page_link_to('login')); redirect(page_link_to('login'));
return true;
} }

@ -1,9 +1,11 @@
<?php <?php
// publically available page to feed the news to feedreaders /**
* Publically available page to feed the news to feedreaders
*/
function user_atom() function user_atom()
{ {
global $user, $DISPLAY_NEWS; global $user, $display_news;
if (!isset($_REQUEST['key']) || !preg_match("/^[0-9a-f]{32}$/", $_REQUEST['key'])) { if (!isset($_REQUEST['key']) || !preg_match("/^[0-9a-f]{32}$/", $_REQUEST['key'])) {
engelsystem_error("Missing key."); engelsystem_error("Missing key.");
@ -18,7 +20,13 @@ function user_atom()
engelsystem_error("No privilege for atom."); engelsystem_error("No privilege for atom.");
} }
$news = sql_select("SELECT * FROM `News` " . (empty($_REQUEST['meetings']) ? '' : 'WHERE `Treffen` = 1 ') . "ORDER BY `ID` DESC LIMIT " . sql_escape($DISPLAY_NEWS)); $news = sql_select("
SELECT *
FROM `News`
" . (empty($_REQUEST['meetings']) ? '' : 'WHERE `Treffen` = 1 ') . "
ORDER BY `ID`
DESC LIMIT " . (int)$display_news
);
$output = make_atom_entries_from_news($news); $output = make_atom_entries_from_news($news);
@ -27,6 +35,10 @@ function user_atom()
raw_output($output); raw_output($output);
} }
/**
* @param array[] $news_entries
* @return string
*/
function make_atom_entries_from_news($news_entries) function make_atom_entries_from_news($news_entries)
{ {
$html = '<?xml version="1.0" encoding="utf-8"?> $html = '<?xml version="1.0" encoding="utf-8"?>

@ -47,7 +47,8 @@ function send_ical_from_shifts($shifts)
/** /**
* Renders an ical vevent from given shift. * Renders an ical vevent from given shift.
* *
* @param Shift $shift * @param array $shift
* @return string
*/ */
function make_ical_entry_from_shift($shift) function make_ical_entry_from_shift($shift)
{ {

@ -1,10 +1,16 @@
<?php <?php
/**
* @return string
*/
function messages_title() function messages_title()
{ {
return _("Messages"); return _("Messages");
} }
/**
* @return string
*/
function user_unread_messages() function user_unread_messages()
{ {
global $user; global $user;
@ -18,6 +24,9 @@ function user_unread_messages()
return ''; return '';
} }
/**
* @return string
*/
function user_messages() function user_messages()
{ {
global $user; global $user;
@ -138,4 +147,6 @@ function user_messages()
return error(_("Wrong action."), true); return error(_("Wrong action."), true);
} }
} }
return '';
} }

@ -1,14 +1,21 @@
<?php <?php
/**
* @return string
*/
function myshifts_title() function myshifts_title()
{ {
return _("My shifts"); return _("My shifts");
} }
// Zeigt die Schichten an, die ein Benutzer belegt /**
* Zeigt die Schichten an, die ein Benutzer belegt
*
* @return string
*/
function user_myshifts() function user_myshifts()
{ {
global $LETZTES_AUSTRAGEN; global $last_unsubscribe;
global $user, $privileges; global $user, $privileges;
if ( if (
@ -120,7 +127,7 @@ function user_myshifts()
WHERE `ShiftEntry`.`id`='" . sql_escape($user_id) . "' AND `UID`='" . sql_escape($shifts_user['UID']) . "'"); WHERE `ShiftEntry`.`id`='" . sql_escape($user_id) . "' AND `UID`='" . sql_escape($shifts_user['UID']) . "'");
if (count($shift) > 0) { if (count($shift) > 0) {
$shift = $shift[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); $result = ShiftEntry_delete($user_id);
if ($result === false) { if ($result === false) {
engelsystem_error('Unable to delete shift entry.'); 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']); redirect(page_link_to('users') . '&action=view&user_id=' . $shifts_user['UID']);
return '';
} }

@ -1,23 +1,35 @@
<?php <?php
/**
* @return string
*/
function user_news_comments_title() function user_news_comments_title()
{ {
return _("News comments"); return _("News comments");
} }
/**
* @return string
*/
function news_title() function news_title()
{ {
return _("News"); return _("News");
} }
/**
* @return string
*/
function meetings_title() function meetings_title()
{ {
return _("Meetings"); return _("Meetings");
} }
/**
* @return string
*/
function user_meetings() function user_meetings()
{ {
global $DISPLAY_NEWS; global $display_news;
$html = '<div class="col-md-12"><h1>' . meetings_title() . '</h1>' . msg(); $html = '<div class="col-md-12"><h1>' . meetings_title() . '</h1>' . msg();
@ -27,12 +39,18 @@ function user_meetings()
$page = 0; $page = 0;
} }
$news = sql_select("SELECT * FROM `News` WHERE `Treffen`=1 ORDER BY `Datum` DESC LIMIT " . sql_escape($page * $DISPLAY_NEWS) . ", " . sql_escape($DISPLAY_NEWS)); $news = sql_select("
SELECT *
FROM `News`
WHERE `Treffen`=1
ORDER BY `Datum`DESC
LIMIT " . sql_escape($page * $display_news) . ", " . sql_escape($display_news)
);
foreach ($news as $entry) { foreach ($news as $entry) {
$html .= display_news($entry); $html .= display_news($entry);
} }
$dis_rows = ceil(sql_num_query("SELECT * FROM `News`") / $DISPLAY_NEWS); $dis_rows = ceil(sql_num_query("SELECT * FROM `News`") / $display_news);
$html .= '<div class="text-center">' . '<ul class="pagination">'; $html .= '<div class="text-center">' . '<ul class="pagination">';
for ($i = 0; $i < $dis_rows; $i++) { for ($i = 0; $i < $dis_rows; $i++) {
if (isset($_REQUEST['page']) && $i == $_REQUEST['page']) { if (isset($_REQUEST['page']) && $i == $_REQUEST['page']) {
@ -49,6 +67,10 @@ function user_meetings()
return $html; return $html;
} }
/**
* @param array $news
* @return string
*/
function display_news($news) function display_news($news)
{ {
global $privileges, $page; global $privileges, $page;
@ -72,13 +94,21 @@ function display_news($news)
$html .= User_Nick_render($user_source); $html .= User_Nick_render($user_source);
if ($page != "news_comments") { if ($page != "news_comments") {
$html .= '&emsp;<a href="' . page_link_to("news_comments") . '&nid=' . $news['ID'] . '"><span class="glyphicon glyphicon-comment"></span> ' . _("Comments") . ' &raquo;</a> <span class="badge">' . sql_num_query("SELECT * FROM `NewsComments` WHERE `Refid`='" . sql_escape($news['ID']) . "'") . '</span>'; $html .= '&emsp;<a href="' . page_link_to("news_comments") . '&nid=' . $news['ID'] . '">'
. '<span class="glyphicon glyphicon-comment"></span> '
. _("Comments") . ' &raquo;</a> '
. '<span class="badge">'
. sql_num_query("SELECT * FROM `NewsComments` WHERE `Refid`='" . sql_escape($news['ID']) . "'")
. '</span>';
} }
$html .= '</div>'; $html .= '</div>';
$html .= '</div>'; $html .= '</div>';
return $html; return $html;
} }
/**
* @return string
*/
function user_news_comments() function user_news_comments()
{ {
global $user; global $user;
@ -93,7 +123,15 @@ function user_news_comments()
list($news) = sql_select("SELECT * FROM `News` WHERE `ID`='" . sql_escape($nid) . "' LIMIT 1"); list($news) = sql_select("SELECT * FROM `News` WHERE `ID`='" . sql_escape($nid) . "' LIMIT 1");
if (isset($_REQUEST["text"])) { if (isset($_REQUEST["text"])) {
$text = preg_replace("/([^\p{L}\p{P}\p{Z}\p{N}\n]{1,})/ui", '', strip_tags($_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); engelsystem_log("Created news_comment: " . $text);
$html .= success(_("Entry saved."), true); $html .= success(_("Entry saved."), true);
} }
@ -125,9 +163,12 @@ function user_news_comments()
return $html . '</div>'; return $html . '</div>';
} }
/**
* @return string
*/
function user_news() function user_news()
{ {
global $DISPLAY_NEWS, $privileges, $user; global $display_news, $privileges, $user;
$html = '<div class="col-md-12"><h1>' . news_title() . '</h1>' . msg(); $html = '<div class="col-md-12"><h1>' . news_title() . '</h1>' . msg();
@ -135,7 +176,16 @@ function user_news()
if (!isset($_POST["treffen"]) || !in_array("admin_news", $privileges)) { if (!isset($_POST["treffen"]) || !in_array("admin_news", $privileges)) {
$_POST["treffen"] = 0; $_POST["treffen"] = 0;
} }
sql_query("INSERT INTO `News` (`Datum`, `Betreff`, `Text`, `UID`, `Treffen`) " . "VALUES ('" . sql_escape(time()) . "', '" . sql_escape($_POST["betreff"]) . "', '" . sql_escape($_POST["text"]) . "', '" . sql_escape($user['UID']) . "', '" . sql_escape($_POST["treffen"]) . "');"); sql_query("
INSERT INTO `News` (`Datum`, `Betreff`, `Text`, `UID`, `Treffen`)
VALUES (
'" . sql_escape(time()) . "',
'" . sql_escape($_POST["betreff"]) . "',
'" . sql_escape($_POST["text"]) . "',
'" . sql_escape($user['UID']) . "',
'" . sql_escape($_POST["treffen"]) . "'
)
");
engelsystem_log("Created news: " . $_POST["betreff"] . ", treffen: " . $_POST["treffen"]); engelsystem_log("Created news: " . $_POST["betreff"] . ", treffen: " . $_POST["treffen"]);
success(_("Entry saved.")); success(_("Entry saved."));
redirect(page_link_to('news')); redirect(page_link_to('news'));
@ -147,12 +197,17 @@ function user_news()
$page = 0; $page = 0;
} }
$news = sql_select("SELECT * FROM `News` ORDER BY `Datum` DESC LIMIT " . sql_escape($page * $DISPLAY_NEWS) . ", " . sql_escape($DISPLAY_NEWS)); $news = sql_select("
SELECT *
FROM `News`
ORDER BY `Datum`
DESC LIMIT " . sql_escape($page * $display_news) . ", " . sql_escape($display_news)
);
foreach ($news as $entry) { foreach ($news as $entry) {
$html .= display_news($entry); $html .= display_news($entry);
} }
$dis_rows = ceil(sql_num_query("SELECT * FROM `News`") / $DISPLAY_NEWS); $dis_rows = ceil(sql_num_query("SELECT * FROM `News`") / $display_news);
$html .= '<div class="text-center">' . '<ul class="pagination">'; $html .= '<div class="text-center">' . '<ul class="pagination">';
for ($i = 0; $i < $dis_rows; $i++) { for ($i = 0; $i < $dis_rows; $i++) {
if (isset($_REQUEST['page']) && $i == $_REQUEST['page']) { if (isset($_REQUEST['page']) && $i == $_REQUEST['page']) {

@ -1,10 +1,16 @@
<?php <?php
/**
* @return string
*/
function questions_title() function questions_title()
{ {
return _("Ask the Heaven"); return _("Ask the Heaven");
} }
/**
* @return string
*/
function user_questions() function user_questions()
{ {
global $user; global $user;
@ -62,4 +68,6 @@ function user_questions()
break; break;
} }
} }
return '';
} }

@ -1,5 +1,8 @@
<?php <?php
/**
* @return string
*/
function settings_title() function settings_title()
{ {
return _("Settings"); return _("Settings");
@ -8,8 +11,10 @@ function settings_title()
/** /**
* Change user main attributes (name, dates, etc.) * Change user main attributes (name, dates, etc.)
* *
* @param User $user_source * @param array $user_source The user
* The user * @param bool $enable_tshirt_size
* @param array $tshirt_sizes
* @return array
*/ */
function user_settings_main($user_source, $enable_tshirt_size, $tshirt_sizes) function user_settings_main($user_source, $enable_tshirt_size, $tshirt_sizes)
{ {
@ -86,8 +91,7 @@ function user_settings_main($user_source, $enable_tshirt_size, $tshirt_sizes)
/** /**
* Change user password. * Change user password.
* *
* @param User $user_source * @param array $user_source The user
* The user
*/ */
function user_settings_password($user_source) function user_settings_password($user_source)
{ {
@ -112,10 +116,9 @@ function user_settings_password($user_source)
/** /**
* Change user theme * Change user theme
* *
* @param User $user_sources * @param array $user_source The user
* The user * @param array $themes List of available themes
* @param array <String> $themes * @return mixed
* List of available themes
*/ */
function user_settings_theme($user_source, $themes) function user_settings_theme($user_source, $themes)
{ {
@ -140,10 +143,9 @@ function user_settings_theme($user_source, $themes)
/** /**
* Change use locale * Change use locale
* *
* @param User $user_source * @param array $user_source The user
* The user * @param array $locales List of available locales
* @param array <String> $locales * @return array
* List of available locales
*/ */
function user_settings_locale($user_source, $locales) function user_settings_locale($user_source, $locales)
{ {
@ -168,6 +170,8 @@ function user_settings_locale($user_source, $locales)
/** /**
* Main user settings page/controller * Main user settings page/controller
*
* @return string
*/ */
function user_settings() function user_settings()
{ {

@ -1,6 +1,9 @@
<?php <?php
use Engelsystem\ShiftsFilter; use Engelsystem\ShiftsFilter;
/**
* @return string
*/
function shifts_title() function shifts_title()
{ {
return _("Shifts"); return _("Shifts");
@ -12,6 +15,8 @@ function shifts_title()
* Transform into shift controller and shift entry controller. * Transform into shift controller and shift entry controller.
* Split actions into shift edit, shift delete, shift entry edit, shift entry delete * Split actions into shift edit, shift delete, shift entry edit, shift entry delete
* Introduce simpler and beautiful actions for shift entry join/leave for users * Introduce simpler and beautiful actions for shift entry join/leave for users
*
* @return string
*/ */
function user_shifts() function user_shifts()
{ {
@ -23,7 +28,8 @@ function user_shifts()
// Löschen einzelner Schicht-Einträge (Also Belegung einer Schicht von Engeln) durch Admins // Löschen einzelner Schicht-Einträge (Also Belegung einer Schicht von Engeln) durch Admins
if (isset($_REQUEST['entry_id'])) { if (isset($_REQUEST['entry_id'])) {
return shift_entry_delete_controller(); shift_entry_delete_controller();
return '';
} elseif (isset($_REQUEST['edit_shift'])) { } elseif (isset($_REQUEST['edit_shift'])) {
return shift_edit_controller(); return shift_edit_controller();
} elseif (isset($_REQUEST['delete_shift'])) { } elseif (isset($_REQUEST['delete_shift'])) {
@ -38,8 +44,8 @@ function user_shifts()
* Helper function that updates the start and end time from request data. * Helper function that updates the start and end time from request data.
* Use update_ShiftsFilter(). * Use update_ShiftsFilter().
* *
* @param ShiftsFilter $shiftsFilter * @param ShiftsFilter $shiftsFilter The shiftfilter to update.
* The shiftfilter to update. * @param string[] $days
*/ */
function update_ShiftsFilter_timerange(ShiftsFilter $shiftsFilter, $days) function update_ShiftsFilter_timerange(ShiftsFilter $shiftsFilter, $days)
{ {
@ -80,16 +86,22 @@ function update_ShiftsFilter(ShiftsFilter $shiftsFilter, $user_shifts_admin, $da
update_ShiftsFilter_timerange($shiftsFilter, $days); update_ShiftsFilter_timerange($shiftsFilter, $days);
} }
/**
* @return array
*/
function load_rooms() function load_rooms()
{ {
$rooms = sql_select("SELECT `RID` AS `id`, `Name` AS `name` FROM `Room` WHERE `show`='Y' ORDER BY `Name`"); $rooms = sql_select("SELECT `RID` AS `id`, `Name` AS `name` FROM `Room` WHERE `show`='Y' ORDER BY `Name`");
if (count($rooms) == 0) { if (!$rooms || count($rooms) == 0) {
error(_("The administration has not configured any rooms yet.")); error(_("The administration has not configured any rooms yet."));
redirect('?'); redirect('?');
} }
return $rooms; return $rooms;
} }
/**
* @return array
*/
function load_days() function load_days()
{ {
$days = sql_select_single_col(" $days = sql_select_single_col("
@ -103,6 +115,9 @@ function load_days()
return $days; return $days;
} }
/**
* @return array|false
*/
function load_types() function load_types()
{ {
global $user; global $user;
@ -136,10 +151,12 @@ function load_types()
return $types; return $types;
} }
/**
* @return string
*/
function view_user_shifts() function view_user_shifts()
{ {
global $user, $privileges; global $user, $privileges, $ical_shifts;
global $ical_shifts;
$ical_shifts = []; $ical_shifts = [];
$days = load_days(); $days = load_days();
@ -197,9 +214,9 @@ function view_user_shifts()
'task_notice' => 'task_notice' =>
'<sup>1</sup>' '<sup>1</sup>'
. _("The tasks shown here are influenced by the angeltypes you joined already!") . _("The tasks shown here are influenced by the angeltypes you joined already!")
. " <a href=\"" . page_link_to('angeltypes') . '&action=about' . "\">" . ' <a href="' . page_link_to('angeltypes') . '&action=about' . '">'
. _("Description of the jobs.") . _("Description of the jobs.")
. "</a>", . '</a>',
'shifts_table' => msg() . $shiftCalendarRenderer->render(), 'shifts_table' => msg() . $shiftCalendarRenderer->render(),
'ical_text' => '<h2>' . _("iCal export") . '</h2><p>' . sprintf( 'ical_text' => '<h2>' . _("iCal export") . '</h2><p>' . sprintf(
_("Export of shown shifts. <a href=\"%s\">iCal format</a> or <a href=\"%s\">JSON format</a> available (please keep secret, otherwise <a href=\"%s\">reset the api key</a>)."), _("Export of shown shifts. <a href=\"%s\">iCal format</a> or <a href=\"%s\">JSON format</a> available (please keep secret, otherwise <a href=\"%s\">reset the api key</a>)."),
@ -213,6 +230,10 @@ function view_user_shifts()
]); ]);
} }
/**
* @param array $array
* @return array
*/
function get_ids_from_array($array) function get_ids_from_array($array)
{ {
return $array["id"]; return $array["id"];
@ -227,9 +248,9 @@ function make_select($items, $selected, $name, $title = null)
foreach ($items as $i) { foreach ($items as $i) {
$html_items[] = '<div class="checkbox">' $html_items[] = '<div class="checkbox">'
. '<label><input type="checkbox" name="' . $name . '[]" value="' . $i['id'] . '"' . '<label><input type="checkbox" name="' . $name . '[]" value="' . $i['id'] . '" '
. (in_array($i['id'], $selected) ? ' checked="checked"' : '') . (in_array($i['id'], $selected) ? ' checked="checked"' : '')
. '> ' . $i['name'] . '</label>' . ' > ' . $i['name'] . '</label>'
. (!isset($i['enabled']) || $i['enabled'] ? '' : glyph("lock")) . (!isset($i['enabled']) || $i['enabled'] ? '' : glyph("lock"))
. '</div><br />'; . '</div><br />';
} }

@ -31,6 +31,9 @@ function load_auth()
/** /**
* generate a salt (random string) of arbitrary length suitable for the use with crypt() * generate a salt (random string) of arbitrary length suitable for the use with crypt()
*
* @param int $length
* @return string
*/ */
function generate_salt($length = 16) function generate_salt($length = 16)
{ {
@ -44,6 +47,10 @@ function generate_salt($length = 16)
/** /**
* set the password of a user * set the password of a user
*
* @param int $uid
* @param string $password
* @return mysqli_result
*/ */
function set_password($uid, $password) function set_password($uid, $password)
{ {
@ -64,8 +71,13 @@ function set_password($uid, $password)
/** /**
* verify a password given a precomputed salt. * verify a password given a precomputed salt.
* if $uid is given and $salt is an old-style salt (plain md5), we convert it automatically * 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; global $crypt_alg;
$correct = false; $correct = false;
@ -77,7 +89,7 @@ function verify_password($password, $salt, $uid = false)
$correct = md5($password) == $salt; $correct = md5($password) == $salt;
} }
if ($correct && substr($salt, 0, strlen($crypt_alg)) != $crypt_alg && $uid) { if ($correct && substr($salt, 0, strlen($crypt_alg)) != $crypt_alg && intval($uid)) {
// this password is stored in another format than we want it to be. // this password is stored in another format than we want it to be.
// let's update it! // let's update it!
// we duplicate the query from the above set_password() function to have the extra safety of checking the old hash // we duplicate the query from the above set_password() function to have the extra safety of checking the old hash
@ -92,6 +104,10 @@ function verify_password($password, $salt, $uid = false)
return $correct; return $correct;
} }
/**
* @param int $user_id
* @return array
*/
function privileges_for_user($user_id) function privileges_for_user($user_id)
{ {
$privileges = []; $privileges = [];
@ -109,6 +125,10 @@ function privileges_for_user($user_id)
return $privileges; return $privileges;
} }
/**
* @param int $group_id
* @return array
*/
function privileges_for_group($group_id) function privileges_for_group($group_id)
{ {
$privileges = []; $privileges = [];

@ -4,10 +4,8 @@
/** /**
* Renders a hidden input * Renders a hidden input
* *
* @param string $name * @param string $name Name of the input
* Name of the input * @param string $value The value
* @param string $value
* The value
* @return string rendered html * @return string rendered html
*/ */
function form_hidden($name, $value) function form_hidden($name, $value)
@ -17,6 +15,11 @@ function form_hidden($name, $value)
/** /**
* Rendert ein Zahlenfeld mit Buttons zum verstellen * Rendert ein Zahlenfeld mit Buttons zum verstellen
*
* @param string $name
* @param string $label
* @param string $value
* @return string
*/ */
function form_spinner($name, $label, $value) function form_spinner($name, $label, $value)
{ {
@ -33,11 +36,12 @@ function form_spinner($name, $label, $value)
</div> </div>
</div> </div>
<script type="text/javascript"> <script type="text/javascript">
$("#spinner-' . $name . '-down").click(function(e) { var spinner = $("#spinner-' . $name . '");
$("#spinner-' . $name . '").val(parseInt($("#spinner-' . $name . '").val()) - 1); $("#spinner-' . $name . '-down").click(function() {
spinner.val(parseInt(spinner.val()) - 1);
}); });
$("#spinner-' . $name . '-up").click(function(e) { $("#spinner-' . $name . '-up").click(function() {
$("#spinner-' . $name . '").val(parseInt($("#spinner-' . $name . '").val()) + 1); spinner.val(parseInt(spinner.val()) + 1);
}); });
</script> </script>
'); ');
@ -46,15 +50,12 @@ function form_spinner($name, $label, $value)
/** /**
* Render a bootstrap datepicker * Render a bootstrap datepicker
* *
* @param string $name * @param string $name Name of the parameter
* Name of the parameter * @param string $label Label
* @param string $label * @param int $value Unix Timestamp
* Label * @param string $start_date Earliest possible date
* @param int $value * @param string $end_date
* Unix Timestamp * @return string HTML
* @param int $min_date
* Earliest possible date
* @return HTML
*/ */
function form_date($name, $label, $value, $start_date = '', $end_date = '') 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 * Rendert eine Liste von Checkboxen für ein Formular
* *
* @param * @param string $name Die Namen der Checkboxen werden aus name_key gebildet
* name Die Namen der Checkboxen werden aus name_key gebildet * @param string $label Die Beschriftung der Liste
* @param * @param array $items Array mit den einzelnen Checkboxen
* label Die Beschriftung der Liste * @param array $selected Array mit den Keys, die ausgewählt sind
* @param * @return string
* items Array mit den einzelnen Checkboxen
* @param
* selected Array mit den Keys, die ausgewählt sind
*/ */
function form_checkboxes($name, $label, $items, $selected) 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 * Rendert eine Tabelle von Checkboxen für ein Formular
* *
* @param * @param string[] $names Assoziatives Array mit Namen der Checkboxen als Keys und Überschriften als Values
* names Assoziatives Array mit Namen der Checkboxen als Keys und Überschriften als Values * @param string $label Die Beschriftung der gesamten Tabelle
* @param * @param string[] $items Array mit den Beschriftungen der Zeilen
* label Die Beschriftung der gesamten Tabelle * @param array[] $selected Mehrdimensionales Array, wobei $selected[foo] ein Array der in der Datenreihe foo
* @param * markierten Checkboxen ist
* items Array mit den Beschriftungen der Zeilen * @param array $disabled Wie selected, nur dass die entsprechenden Checkboxen deaktiviert statt markiert sind
* @param * @return string
* 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
*/ */
function form_multi_checkboxes($names, $label, $items, $selected, $disabled = []) function form_multi_checkboxes($names, $label, $items, $selected, $disabled = [])
{ {
@ -125,13 +119,16 @@ function form_multi_checkboxes($names, $label, $items, $selected, $disabled = []
$html .= "</tr></thead><tbody>"; $html .= "</tr></thead><tbody>";
foreach ($items as $key => $item) { foreach ($items as $key => $item) {
$html .= "<tr>"; $html .= "<tr>";
$dom_id = '';
foreach ($names as $name => $title) { foreach ($names as $name => $title) {
$dom_id = $name . '_' . $key; $dom_id = $name . '_' . $key;
$sel = array_search($key, $selected[$name]) !== false ? ' checked="checked"' : ""; $sel = array_search($key, $selected[$name]) !== false ? ' checked="checked"' : "";
if (!empty($disabled) && !empty($disabled[$name]) && array_search($key, $disabled[$name]) !== false) { if (!empty($disabled) && !empty($disabled[$name]) && array_search($key, $disabled[$name]) !== false) {
$sel .= ' disabled="disabled"'; $sel .= ' disabled="disabled"';
} }
$html .= '<td style="text-align: center;"><input type="checkbox" id="' . $dom_id . '" name="' . $name . '[]" value="' . $key . '"' . $sel . ' /></td>'; $html .= '<td style="text-align: center;">'
. '<input type="checkbox" id="' . $dom_id . '" name="' . $name . '[]" value="' . $key . '" ' . $sel . ' />'
. '</td>';
} }
$html .= '<td><label for="' . $dom_id . '">' . $item . '</label></td></tr>'; $html .= '<td><label for="' . $dom_id . '">' . $item . '</label></td></tr>';
} }
@ -141,22 +138,38 @@ function form_multi_checkboxes($names, $label, $items, $selected, $disabled = []
/** /**
* Rendert eine Checkbox * 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') function form_checkbox($name, $label, $selected, $value = 'checked')
{ {
return '<div class="checkbox"><label><input type="checkbox" id="' . $name . '" name="' . $name . '" value="' . $value . '"' . ($selected ? ' checked="checked"' : '') . ' /> ' . $label . '</label></div>'; return '<div class="checkbox"><label><input type="checkbox" id="' . $name . '" name="' . $name . '" value="' . $value . '" ' . ($selected ? ' checked="checked"' : '') . ' /> ' . $label . '</label></div>';
} }
/** /**
* Rendert einen Radio * Rendert einen Radio
*
* @param string $name
* @param string $label
* @param string $selected
* @param string $value
* @return string
*/ */
function form_radio($name, $label, $selected, $value) function form_radio($name, $label, $selected, $value)
{ {
return '<div class="radio"><label><input type="radio" id="' . $name . '" name="' . $name . '" value="' . $value . '"' . ($selected ? ' checked="checked"' : '') . ' /> ' . $label . '</label></div>'; return '<div class="radio"><label><input type="radio" id="' . $name . '" name="' . $name . '" value="' . $value . '" ' . ($selected ? ' checked="checked"' : '') . ' /> ' . $label . '</label></div>';
} }
/** /**
* Rendert einen Infotext in das Formular * Rendert einen Infotext in das Formular
*
* @param string $label
* @param string $text
* @return string
*/ */
function form_info($label, $text = "") function form_info($label, $text = "")
{ {
@ -171,6 +184,10 @@ function form_info($label, $text = "")
/** /**
* Rendert den Absenden-Button eines Formulars * Rendert den Absenden-Button eines Formulars
*
* @param string $name
* @param string $label
* @return string
*/ */
function form_submit($name, $label) function form_submit($name, $label)
{ {
@ -182,6 +199,12 @@ function form_submit($name, $label)
/** /**
* Rendert ein Formular-Textfeld * 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) 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. * Renders a text input with placeholder instead of label.
* *
* @param String $name * @param String $name Input name
* Input name * @param String $placeholder Placeholder
* @param String $placeholder * @param String $value The value
* Placeholder * @param Boolean $disabled Is the field enabled?
* @param String $value * @return string
* The value
* @param Boolean $disabled
* Is the field enabled?
*/ */
function form_text_placeholder($name, $placeholder, $value, $disabled = false) 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 * 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) function form_email($name, $label, $value, $disabled = false)
{ {
@ -227,6 +253,10 @@ function form_email($name, $label, $value, $disabled = false)
/** /**
* Rendert ein Formular-Dateifeld * Rendert ein Formular-Dateifeld
*
* @param string $name
* @param string $label
* @return string
*/ */
function form_file($name, $label) function form_file($name, $label)
{ {
@ -235,6 +265,11 @@ function form_file($name, $label)
/** /**
* Rendert ein Formular-Passwortfeld * Rendert ein Formular-Passwortfeld
*
* @param string $name
* @param string $label
* @param bool $disabled
* @return string
*/ */
function form_password($name, $label, $disabled = false) 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. * 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) function form_password_placeholder($name, $placeholder, $disabled = false)
{ {
@ -261,6 +301,12 @@ function form_password_placeholder($name, $placeholder, $disabled = false)
/** /**
* Rendert ein Formular-Textfeld * 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) function form_textarea($name, $label, $value, $disabled = false)
{ {
@ -274,6 +320,12 @@ function form_textarea($name, $label, $value, $disabled = false)
/** /**
* Rendert ein Formular-Auswahlfeld * 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) function form_select($name, $label, $values, $selected)
{ {
@ -282,6 +334,11 @@ function form_select($name, $label, $values, $selected)
/** /**
* Rendert ein Formular-Element * Rendert ein Formular-Element
*
* @param string $label
* @param string $input
* @param string $for
* @return string
*/ */
function form_element($label, $input, $for = "") function form_element($label, $input, $for = "")
{ {
@ -294,12 +351,22 @@ function form_element($label, $input, $for = "")
/** /**
* Rendert ein Formular * Rendert ein Formular
*
* @param string[] $elements
* @param string $action
* @return string
*/ */
function form($elements, $action = "") function form($elements, $action = "")
{ {
return '<form role="form" action="' . $action . '" enctype="multipart/form-data" method="post">' . join($elements) . '</form>'; return '<form role="form" action="' . $action . '" enctype="multipart/form-data" method="post">' . join($elements) . '</form>';
} }
/**
* @param string $name
* @param String[] $options
* @param string $selected
* @return string
*/
function html_options($name, $options, $selected = "") function html_options($name, $options, $selected = "")
{ {
$html = ""; $html = "";
@ -310,6 +377,13 @@ function html_options($name, $options, $selected = "")
return $html; 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) function html_select_key($dom_id, $name, $rows, $selected)
{ {
$html = '<select class="form-control" id="' . $dom_id . '" name="' . $name . '">'; $html = '<select class="form-control" id="' . $dom_id . '" name="' . $name . '">';

@ -4,8 +4,7 @@
* Write a log entry. * Write a log entry.
* This should be used to log user's activity. * This should be used to log user's activity.
* *
* @param * @param string $message
* $message
*/ */
function engelsystem_log($message) function engelsystem_log($message)
{ {
@ -20,6 +19,8 @@ function engelsystem_log($message)
/** /**
* Generates a PHP Stacktrace. * Generates a PHP Stacktrace.
*
* @return string
*/ */
function debug_string_backtrace() function debug_string_backtrace()
{ {

@ -1,6 +1,10 @@
<?php <?php
use Engelsystem\UserHintsRenderer; use Engelsystem\UserHintsRenderer;
/**
* @param string $page
* @return string
*/
function page_link_to($page = "") function page_link_to($page = "")
{ {
if ($page == "") { if ($page == "") {
@ -9,6 +13,10 @@ function page_link_to($page = "")
return '?p=' . $page; return '?p=' . $page;
} }
/**
* @param string $page
* @return string
*/
function page_link_to_absolute($page) function page_link_to_absolute($page)
{ {
return (isset($_SERVER['HTTPS']) ? 'https' : 'http') . '://' return (isset($_SERVER['HTTPS']) ? 'https' : 'http') . '://'
@ -19,6 +27,8 @@ function page_link_to_absolute($page)
/** /**
* Render the user hints * Render the user hints
*
* @return string
*/ */
function header_render_hints() function header_render_hints()
{ {
@ -44,6 +54,8 @@ function header_render_hints()
/** /**
* Renders the header toolbar containing search, login/logout, user and settings links. * Renders the header toolbar containing search, login/logout, user and settings links.
*
* @return string
*/ */
function header_toolbar() function header_toolbar()
{ {
@ -89,6 +101,9 @@ function header_toolbar()
return toolbar($toolbar_items, true); return toolbar($toolbar_items, true);
} }
/**
* @return array
*/
function make_user_submenu() function make_user_submenu()
{ {
global $privileges, $page; global $privileges, $page;
@ -115,6 +130,9 @@ function make_user_submenu()
return $user_submenu; return $user_submenu;
} }
/**
* @return string
*/
function make_navigation() function make_navigation()
{ {
global $page, $privileges; global $page, $privileges;
@ -168,8 +186,8 @@ function make_navigation()
/** /**
* Adds room navigation to the given menu. * Adds room navigation to the given menu.
* *
* @param string[] $menu * @param string[] $menu Rendered menu
* Rendered menu * @return string[]
*/ */
function make_room_navigation($menu) function make_room_navigation($menu)
{ {
@ -190,12 +208,15 @@ function make_room_navigation($menu)
foreach ($rooms as $room) { foreach ($rooms as $room) {
$room_menu[] = toolbar_item_link(room_link($room), 'map-marker', $room['Name']); $room_menu[] = toolbar_item_link(room_link($room), 'map-marker', $room['Name']);
} }
if (count($room_menu > 0)) { if (count($room_menu) > 0) {
$menu[] = toolbar_dropdown('map-marker', _("Rooms"), $room_menu); $menu[] = toolbar_dropdown('map-marker', _("Rooms"), $room_menu);
} }
return $menu; return $menu;
} }
/**
* @return string
*/
function make_menu() function make_menu()
{ {
return make_navigation(); return make_navigation();

@ -8,14 +8,11 @@ use Engelsystem\ValidationResult;
/** /**
* Parse a date from da day and a time textfield. * Parse a date from da day and a time textfield.
* *
* @param string $date_name * @param string $date_name Name of the textfield containing the day (format Y-m-d)
* Name of the textfield containing the day (format Y-m-d) * @param string $time_name Name of the textfield containing the time (format H:i)
* @param string $time_name * @param string[] $allowed_days List of allowed days in format Y-m-d
* Name of the textfield containing the time (format H:i) * @param int $default_value Default value unix timestamp
* @param string[] $allowed_days * @return int|null
* List of allowed days in format Y-m-d
* @param int $default_value
* Default value unix timestamp
*/ */
function check_request_datetime($date_name, $time_name, $allowed_days, $default_value) function check_request_datetime($date_name, $time_name, $allowed_days, $default_value)
{ {
@ -35,11 +32,9 @@ function check_request_datetime($date_name, $time_name, $allowed_days, $default_
/** /**
* Parse a date into unix timestamp * Parse a date into unix timestamp
* *
* @param string $pattern * @param string $pattern The date pattern (i.e. Y-m-d H:i)
* The date pattern (i.e. Y-m-d H:i) * @param string $value The string to parse
* @param string $value * @return int|null The parsed unix timestamp
* The string to parse
* @return The parsed unix timestamp
*/ */
function parse_date($pattern, $value) function parse_date($pattern, $value)
{ {
@ -52,6 +47,8 @@ function parse_date($pattern, $value)
/** /**
* Leitet den Browser an die übergebene URL weiter und hält das Script an. * Leitet den Browser an die übergebene URL weiter und hält das Script an.
*
* @param string $url
*/ */
function redirect($url) function redirect($url)
{ {
@ -62,8 +59,7 @@ function redirect($url)
/** /**
* Echoes given output and dies. * Echoes given output and dies.
* *
* @param String $output * @param String $output String to display
* String to display
*/ */
function raw_output($output) function raw_output($output)
{ {
@ -74,12 +70,11 @@ function raw_output($output)
/** /**
* Helper function for transforming list of entities into array for select boxes. * Helper function for transforming list of entities into array for select boxes.
* *
* @param array $data * @param array $data The data array
* The data array * @param string $key_name name of the column to use as id/key
* @param string $key_name * @param string $value_name name of the column to use as displayed value
* name of the column to use as id/key *
* @param string $value_name * @return array
* name of the column to use as displayed value
*/ */
function select_array($data, $key_name, $value_name) function select_array($data, $key_name, $value_name)
{ {
@ -93,10 +88,9 @@ function select_array($data, $key_name, $value_name)
/** /**
* Returns an int[] from given request param name. * Returns an int[] from given request param name.
* *
* @param String $name * @param string $name Name of the request param
* Name of the request param * @param array $default Default return value, if param is not set
* @param array <int> $default * @return array
* Default return value, if param is not set
*/ */
function check_request_int_array($name, $default = []) function check_request_int_array($name, $default = [])
{ {
@ -110,12 +104,9 @@ function check_request_int_array($name, $default = [])
* Checks if given request item (name) can be parsed to a date. * Checks if given request item (name) can be parsed to a date.
* If not parsable, given error message is put into msg() and null is returned. * If not parsable, given error message is put into msg() and null is returned.
* *
* @param string $input * @param string $name to be parsed into a date.
* String to be parsed into a date. * @param string $error_message the error message displayed if $input is not parsable
* @param string $error_message * @param boolean $null_allowed is a null value allowed?
* the error message displayed if $input is not parsable
* @param boolean $null_allowed
* is a null value allowed?
* @return ValidationResult containing the parsed date * @return ValidationResult containing the parsed date
*/ */
function check_request_date($name, $error_message = null, $null_allowed = false) function check_request_date($name, $error_message = null, $null_allowed = false)
@ -130,12 +121,9 @@ function check_request_date($name, $error_message = null, $null_allowed = false)
* Checks if given string can be parsed to a date. * Checks if given string can be parsed to a date.
* If not parsable, given error message is put into msg() and null is returned. * If not parsable, given error message is put into msg() and null is returned.
* *
* @param string $input * @param string $input String to be parsed into a date.
* String to be parsed into a date. * @param string $error_message the error message displayed if $input is not parsable
* @param string $error_message * @param boolean $null_allowed is a null value allowed?
* the error message displayed if $input is not parsable
* @param boolean $null_allowed
* is a null value allowed?
* @return ValidationResult containing the parsed date * @return ValidationResult containing the parsed date
*/ */
function check_date($input, $error_message = null, $null_allowed = false) function check_date($input, $error_message = null, $null_allowed = false)
@ -153,6 +141,10 @@ function check_date($input, $error_message = null, $null_allowed = false)
/** /**
* Returns REQUEST value filtered or default value (null) if not set. * Returns REQUEST value filtered or default value (null) if not set.
*
* @param string $name
* @param string $default_value
* @return mixed|null
*/ */
function strip_request_item($name, $default_value = null) function strip_request_item($name, $default_value = null)
{ {
@ -165,6 +157,9 @@ function strip_request_item($name, $default_value = null)
/** /**
* Testet, ob der angegebene REQUEST Wert ein Integer ist, bzw. * Testet, ob der angegebene REQUEST Wert ein Integer ist, bzw.
* eine ID sein könnte. * eine ID sein könnte.
*
* @param string $name
* @return int|false
*/ */
function test_request_int($name) function test_request_int($name)
{ {
@ -176,6 +171,10 @@ function test_request_int($name)
/** /**
* Gibt den gefilterten REQUEST Wert mit Zeilenumbrüchen zurück * Gibt den gefilterten REQUEST Wert mit Zeilenumbrüchen zurück
*
* @param string $name
* @param mixed $default_value
* @return mixed
*/ */
function strip_request_item_nl($name, $default_value = null) function strip_request_item_nl($name, $default_value = null)
{ {
@ -187,6 +186,9 @@ function strip_request_item_nl($name, $default_value = null)
/** /**
* Entfernt unerwünschte Zeichen * Entfernt unerwünschte Zeichen
*
* @param string $item
* @return string
*/ */
function strip_item($item) function strip_item($item)
{ {
@ -195,6 +197,9 @@ function strip_item($item)
/** /**
* Überprüft eine E-Mail-Adresse. * Überprüft eine E-Mail-Adresse.
*
* @param string $email
* @return bool
*/ */
function check_email($email) function check_email($email)
{ {

@ -15,6 +15,7 @@ $themes = [
* Display muted (grey) text. * Display muted (grey) text.
* *
* @param string $text * @param string $text
* @return string
*/ */
function mute($text) function mute($text)
{ {
@ -24,25 +25,40 @@ function mute($text)
/** /**
* Renders a bootstrap label with given content and class. * Renders a bootstrap label with given content and class.
* *
* @param string $content * @param string $content The text
* The text * @param string $class default, primary, info, success, warning, danger
* @param string $class * @return string
* default, primary, info, success, warning, danger
*/ */
function label($content, $class = 'default') function label($content, $class = 'default')
{ {
return '<span class="label label-' . $class . '">' . $content . '</span>'; return '<span class="label label-' . $class . '">' . $content . '</span>';
} }
/**
* @param int $valuemin
* @param int $valuemax
* @param int $valuenow
* @param string $class
* @param string $content
* @return string
*/
function progress_bar($valuemin, $valuemax, $valuenow, $class = '', $content = '') function progress_bar($valuemin, $valuemax, $valuenow, $class = '', $content = '')
{ {
return '<div class="progress"><div class="progress-bar ' . $class . '" role="progressbar" aria-valuenow="' . $valuenow . '" aria-valuemin="' . $valuemin . '" aria-valuemax="' . $valuemax . '" style="width: ' . floor(($valuenow - $valuemin) * 100 / ($valuemax - $valuemin)) . '%">' . $content . '</div></div>'; return '<div class="progress">'
. '<div class="progress-bar ' . $class . '" role="progressbar" '
. 'aria-valuenow="' . $valuenow . '" aria-valuemin="' . $valuemin . '" aria-valuemax="' . $valuemax . '" '
. 'style="width: ' . floor(($valuenow - $valuemin) * 100 / ($valuemax - $valuemin)) . '%"'
. '>'
. $content . ''
. '</div>'
. '</div>';
} }
/** /**
* Render glyphicon * Render glyphicon
* *
* @param string $glyph_name * @param string $glyph_name
* @return string
*/ */
function glyph($glyph_name) function glyph($glyph_name)
{ {
@ -53,12 +69,19 @@ function glyph($glyph_name)
* Renders a tick or a cross by given boolean * Renders a tick or a cross by given boolean
* *
* @param boolean $boolean * @param boolean $boolean
* @return string
*/ */
function glyph_bool($boolean) function glyph_bool($boolean)
{ {
return '<span class="text-' . ($boolean ? 'success' : 'danger') . '">' . glyph($boolean ? 'ok' : 'remove') . '</span>'; return '<span class="text-' . ($boolean ? 'success' : 'danger') . '">' . glyph($boolean ? 'ok' : 'remove') . '</span>';
} }
/**
* @param string $class
* @param array $content
* @param string $dom_id
* @return string
*/
function div($class, $content = [], $dom_id = "") function div($class, $content = [], $dom_id = "")
{ {
if (is_array($content)) { if (is_array($content)) {
@ -68,6 +91,11 @@ function div($class, $content = [], $dom_id = "")
return '<div' . $dom_id . ' class="' . $class . '">' . $content . '</div>'; return '<div' . $dom_id . ' class="' . $class . '">' . $content . '</div>';
} }
/**
* @param string $content
* @param int $number
* @return string
*/
function heading($content, $number = 1) function heading($content, $number = 1)
{ {
return "<h" . $number . ">" . $content . "</h" . $number . ">"; return "<h" . $number . ">" . $content . "</h" . $number . ">";
@ -77,6 +105,7 @@ function heading($content, $number = 1)
* Render a toolbar. * Render a toolbar.
* *
* @param array $items * @param array $items
* @param bool $right
* @return string * @return string
*/ */
function toolbar($items = [], $right = false) function toolbar($items = [], $right = false)
@ -84,6 +113,10 @@ function toolbar($items = [], $right = false)
return '<ul class="nav navbar-nav' . ($right ? ' navbar-right' : '') . '">' . join("\n", $items) . '</ul>'; return '<ul class="nav navbar-nav' . ($right ? ' navbar-right' : '') . '">' . join("\n", $items) . '</ul>';
} }
/**
* @param string[] $items
* @return string
*/
function toolbar_pills($items) function toolbar_pills($items)
{ {
return '<ul class="nav nav-pills">' . join("\n", $items) . '</ul>'; return '<ul class="nav nav-pills">' . join("\n", $items) . '</ul>';
@ -100,26 +133,56 @@ function toolbar_pills($items)
*/ */
function toolbar_item_link($href, $glyphicon, $label, $selected = false) function toolbar_item_link($href, $glyphicon, $label, $selected = false)
{ {
return '<li class="' . ($selected ? 'active' : '') . '"><a href="' . $href . '">' . ($glyphicon != '' ? '<span class="glyphicon glyphicon-' . $glyphicon . '"></span> ' : '') . $label . '</a></li>'; return '<li class="' . ($selected ? 'active' : '') . '">'
. '<a href="' . $href . '">'
. ($glyphicon != '' ? '<span class="glyphicon glyphicon-' . $glyphicon . '"></span> ' : '')
. $label
. '</a>'
. '</li>';
} }
/**
* @return string
*/
function toolbar_item_divider() function toolbar_item_divider()
{ {
return '<li class="divider"></li>'; return '<li class="divider"></li>';
} }
/**
* @param string $glyphicon
* @param string $label
* @param array $submenu
* @param string $class
* @return string
*/
function toolbar_dropdown($glyphicon, $label, $submenu, $class = '') function toolbar_dropdown($glyphicon, $label, $submenu, $class = '')
{ {
return '<li class="dropdown ' . $class . '"> return '<li class="dropdown ' . $class . '">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">' . ($glyphicon != '' ? '<span class="glyphicon glyphicon-' . $glyphicon . '"></span> ' : '') . $label . ' <span class="caret"></span></a> <a href="#" class="dropdown-toggle" data-toggle="dropdown">'
<ul class="dropdown-menu" role="menu">' . join("\n", $submenu) . '</ul></li>'; . ($glyphicon != '' ? '<span class="glyphicon glyphicon-' . $glyphicon . '"></span> ' : '')
. $label
. ' <span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">'
. join("\n", $submenu)
. '</ul></li>';
} }
/**
* @param string $glyphicon
* @param string $label
* @param string[] $content
* @param string $class
* @return string
*/
function toolbar_popover($glyphicon, $label, $content, $class = '') function toolbar_popover($glyphicon, $label, $content, $class = '')
{ {
$dom_id = md5(microtime() . $glyphicon . $label); $dom_id = md5(microtime() . $glyphicon . $label);
return '<li class="dropdown messages ' . $class . '"> return '<li class="dropdown messages ' . $class . '">
<a id="' . $dom_id . '" href="#" tabindex="0">' . ($glyphicon != '' ? '<span class="glyphicon glyphicon-' . $glyphicon . '"></span> ' : '') . $label . ' <span class="caret"></span></a> <a id="' . $dom_id . '" href="#" tabindex="0">'
. ($glyphicon != '' ? '<span class="glyphicon glyphicon-' . $glyphicon . '"></span> ' : '')
. $label
. ' <span class="caret"></span></a>
<script type="text/javascript"> <script type="text/javascript">
$(function(){ $(function(){
$("#' . $dom_id . '").popover({ $("#' . $dom_id . '").popover({
@ -137,6 +200,9 @@ function toolbar_popover($glyphicon, $label, $content, $class = '')
/** /**
* Generiert HTML Code für eine "Seite". * Generiert HTML Code für eine "Seite".
* Fügt dazu die übergebenen Elemente zusammen. * Fügt dazu die übergebenen Elemente zusammen.
*
* @param string[] $elements
* @return string
*/ */
function page($elements) function page($elements)
{ {
@ -146,6 +212,10 @@ function page($elements)
/** /**
* Generiert HTML Code für eine "Seite" mit zentraler Überschrift * Generiert HTML Code für eine "Seite" mit zentraler Überschrift
* Fügt dazu die übergebenen Elemente zusammen. * Fügt dazu die übergebenen Elemente zusammen.
*
* @param string $title
* @param string[] $elements
* @return string
*/ */
function page_with_title($title, $elements) function page_with_title($title, $elements)
{ {
@ -154,6 +224,11 @@ function page_with_title($title, $elements)
/** /**
* Rendert eine Datentabelle * Rendert eine Datentabelle
*
* @param array|string $columns
* @param array[] $rows_raw
* @param bool $data
* @return string
*/ */
function table($columns, $rows_raw, $data = true) function table($columns, $rows_raw, $data = true)
{ {
@ -176,6 +251,11 @@ function table($columns, $rows_raw, $data = true)
/** /**
* Helper for rendering a html-table. * Helper for rendering a html-table.
* use table() * use table()
*
* @param string[] $columns
* @param array[] $rows
* @param bool $data
* @return string
*/ */
function render_table($columns, $rows, $data = true) function render_table($columns, $rows, $data = true)
{ {
@ -208,6 +288,11 @@ function render_table($columns, $rows, $data = true)
/** /**
* Rendert einen Knopf * Rendert einen Knopf
*
* @param string $href
* @param string $label
* @param string $class
* @return string
*/ */
function button($href, $label, $class = "") function button($href, $label, $class = "")
{ {
@ -216,6 +301,11 @@ function button($href, $label, $class = "")
/** /**
* Rendert einen Knopf mit Glyph * Rendert einen Knopf mit Glyph
*
* @param string $href
* @param string $glyph
* @param string $class
* @return string
*/ */
function button_glyph($href, $glyph, $class = "") function button_glyph($href, $glyph, $class = "")
{ {
@ -224,18 +314,31 @@ function button_glyph($href, $glyph, $class = "")
/** /**
* Rendert eine Toolbar mit Knöpfen * Rendert eine Toolbar mit Knöpfen
*
* @param array $buttons
* @return string
*/ */
function buttons($buttons = []) function buttons($buttons = [])
{ {
return '<div class="form-group">' . table_buttons($buttons) . '</div>'; return '<div class="form-group">' . table_buttons($buttons) . '</div>';
} }
/**
* @param array $buttons
* @return string
*/
function table_buttons($buttons = []) function table_buttons($buttons = [])
{ {
return '<div class="btn-group">' . join(' ', $buttons) . '</div>'; return '<div class="btn-group">' . join(' ', $buttons) . '</div>';
} }
// Load and render template /**
* Load and render template
*
* @param string $file
* @param string $data
* @return string
*/
function template_render($file, $data) function template_render($file, $data)
{ {
if (file_exists($file)) { if (file_exists($file)) {
@ -248,8 +351,14 @@ function template_render($file, $data)
return $template; return $template;
} }
engelsystem_error("Cannot find template file &laquo;" . $file . "&raquo;."); engelsystem_error("Cannot find template file &laquo;" . $file . "&raquo;.");
return '';
} }
/**
* @param string $str
* @param int $length
* @return string
*/
function shorten($str, $length = 50) function shorten($str, $length = 50)
{ {
if (strlen($str) < $length) { if (strlen($str) < $length) {
@ -260,6 +369,10 @@ function shorten($str, $length = 50)
. '...</span>'; . '...</span>';
} }
/**
* @param array[] $array
* @return string
*/
function table_body($array) function table_body($array)
{ {
$html = ""; $html = "";
@ -277,28 +390,32 @@ function table_body($array)
return $html; return $html;
} }
function ReplaceSmilies($neueckig) /**
* @param string $msg
* @return mixed
*/
function ReplaceSmilies($msg)
{ {
$neueckig = str_replace(";o))", "<img src=\"pic/smiles/icon_redface.gif\">", $neueckig); $msg = str_replace(";o))", "<img src=\"pic/smiles/icon_redface.gif\">", $msg);
$neueckig = str_replace(":-))", "<img src=\"pic/smiles/icon_redface.gif\">", $neueckig); $msg = str_replace(":-))", "<img src=\"pic/smiles/icon_redface.gif\">", $msg);
$neueckig = str_replace(";o)", "<img src=\"pic/smiles/icon_wind.gif\">", $neueckig); $msg = str_replace(";o)", "<img src=\"pic/smiles/icon_wind.gif\">", $msg);
$neueckig = str_replace(":)", "<img src=\"pic/smiles/icon_smile.gif\">", $neueckig); $msg = str_replace(":)", "<img src=\"pic/smiles/icon_smile.gif\">", $msg);
$neueckig = str_replace(":-)", "<img src=\"pic/smiles/icon_smile.gif\">", $neueckig); $msg = str_replace(":-)", "<img src=\"pic/smiles/icon_smile.gif\">", $msg);
$neueckig = str_replace(":(", "<img src=\"pic/smiles/icon_sad.gif\">", $neueckig); $msg = str_replace(":(", "<img src=\"pic/smiles/icon_sad.gif\">", $msg);
$neueckig = str_replace(":-(", "<img src=\"pic/smiles/icon_sad.gif\">", $neueckig); $msg = str_replace(":-(", "<img src=\"pic/smiles/icon_sad.gif\">", $msg);
$neueckig = str_replace(":o(", "<img src=\"pic/smiles/icon_sad.gif\">", $neueckig); $msg = str_replace(":o(", "<img src=\"pic/smiles/icon_sad.gif\">", $msg);
$neueckig = str_replace(":o)", "<img src=\"pic/smiles/icon_lol.gif\">", $neueckig); $msg = str_replace(":o)", "<img src=\"pic/smiles/icon_lol.gif\">", $msg);
$neueckig = str_replace(";o(", "<img src=\"pic/smiles/icon_cry.gif\">", $neueckig); $msg = str_replace(";o(", "<img src=\"pic/smiles/icon_cry.gif\">", $msg);
$neueckig = str_replace(";(", "<img src=\"pic/smiles/icon_cry.gif\">", $neueckig); $msg = str_replace(";(", "<img src=\"pic/smiles/icon_cry.gif\">", $msg);
$neueckig = str_replace(";-(", "<img src=\"pic/smiles/icon_cry.gif\">", $neueckig); $msg = str_replace(";-(", "<img src=\"pic/smiles/icon_cry.gif\">", $msg);
$neueckig = str_replace("8)", "<img src=\"pic/smiles/icon_rolleyes.gif\">", $neueckig); $msg = str_replace("8)", "<img src=\"pic/smiles/icon_rolleyes.gif\">", $msg);
$neueckig = str_replace("8o)", "<img src=\"pic/smiles/icon_rolleyes.gif\">", $neueckig); $msg = str_replace("8o)", "<img src=\"pic/smiles/icon_rolleyes.gif\">", $msg);
$neueckig = str_replace(":P", "<img src=\"pic/smiles/icon_evil.gif\">", $neueckig); $msg = str_replace(":P", "<img src=\"pic/smiles/icon_evil.gif\">", $msg);
$neueckig = str_replace(":-P", "<img src=\"pic/smiles/icon_evil.gif\">", $neueckig); $msg = str_replace(":-P", "<img src=\"pic/smiles/icon_evil.gif\">", $msg);
$neueckig = str_replace(":oP", "<img src=\"pic/smiles/icon_evil.gif\">", $neueckig); $msg = str_replace(":oP", "<img src=\"pic/smiles/icon_evil.gif\">", $msg);
$neueckig = str_replace(";P", "<img src=\"pic/smiles/icon_mad.gif\">", $neueckig); $msg = str_replace(";P", "<img src=\"pic/smiles/icon_mad.gif\">", $msg);
$neueckig = str_replace(";oP", "<img src=\"pic/smiles/icon_mad.gif\">", $neueckig); $msg = str_replace(";oP", "<img src=\"pic/smiles/icon_mad.gif\">", $msg);
$neueckig = str_replace("?)", "<img src=\"pic/smiles/icon_question.gif\">", $neueckig); $msg = str_replace("?)", "<img src=\"pic/smiles/icon_question.gif\">", $msg);
return $neueckig; return $msg;
} }

@ -7,7 +7,8 @@
/** /**
* Renders the angeltypes name as link. * Renders the angeltypes name as link.
* *
* @param AngelType $angeltype * @param array $angeltype
* @return string
*/ */
function AngelType_name_render($angeltype) function AngelType_name_render($angeltype)
{ {
@ -17,8 +18,7 @@ function AngelType_name_render($angeltype)
/** /**
* Render angeltype membership state * Render angeltype membership state
* *
* @param UserAngelType $user_angeltype * @param array $user_angeltype UserAngelType and AngelType
* UserAngelType and AngelType
* @return string * @return string
*/ */
function AngelType_render_membership($user_angeltype) function AngelType_render_membership($user_angeltype)
@ -39,6 +39,10 @@ function AngelType_render_membership($user_angeltype)
return glyph_bool(false); return glyph_bool(false);
} }
/**
* @param array $angeltype
* @return string
*/
function AngelType_delete_view($angeltype) function AngelType_delete_view($angeltype)
{ {
return page_with_title(sprintf(_("Delete angeltype %s"), $angeltype['name']), [ return page_with_title(sprintf(_("Delete angeltype %s"), $angeltype['name']), [
@ -57,10 +61,9 @@ function AngelType_delete_view($angeltype)
/** /**
* Render angeltype edit form. * Render angeltype edit form.
* *
* @param Angeltype $angeltype * @param array $angeltype The angeltype to edit
* The angeltype to edit * @param boolean $supporter_mode Is the user a supporter of this angeltype?
* @param boolean $supporter_mode * @return string
* Is the user a supporter of this angeltype?
*/ */
function AngelType_edit_view($angeltype, $supporter_mode) function AngelType_edit_view($angeltype, $supporter_mode)
{ {
@ -103,6 +106,14 @@ function AngelType_edit_view($angeltype, $supporter_mode)
/** /**
* Renders the buttons for the angeltype view. * Renders the buttons for the angeltype view.
*
* @param array $angeltype
* @param array|null $user_angeltype
* @param bool $admin_angeltypes
* @param bool $supporter
* @param array|null $user_driver_license
* @param array|null $user
* @return string
*/ */
function AngelType_view_buttons($angeltype, $user_angeltype, $admin_angeltypes, $supporter, $user_driver_license, $user) function AngelType_view_buttons($angeltype, $user_angeltype, $admin_angeltypes, $supporter, $user_driver_license, $user)
{ {
@ -156,7 +167,11 @@ function AngelType_view_buttons($angeltype, $user_angeltype, $admin_angeltypes,
/** /**
* Renders and sorts the members of an angeltype into supporters, members and unconfirmed members. * Renders and sorts the members of an angeltype into supporters, members and unconfirmed members.
* *
* @return [supporters, members, unconfirmed members] * @param array $angeltype
* @param array $members
* @param bool $admin_user_angeltypes
* @param bool $admin_angeltypes
* @return array [supporters, members, unconfirmed members]
*/ */
function AngelType_view_members($angeltype, $members, $admin_user_angeltypes, $admin_angeltypes) function AngelType_view_members($angeltype, $members, $admin_user_angeltypes, $admin_angeltypes)
{ {
@ -230,6 +245,11 @@ function AngelType_view_members($angeltype, $members, $admin_user_angeltypes, $a
/** /**
* Creates the needed member table headers according to given rights and settings from the angeltype. * Creates the needed member table headers according to given rights and settings from the angeltype.
*
* @param array $angeltype
* @param bool $supporter
* @param bool $admin_angeltypes
* @return array
*/ */
function AngelType_view_table_headers($angeltype, $supporter, $admin_angeltypes) function AngelType_view_table_headers($angeltype, $supporter, $admin_angeltypes)
{ {
@ -256,6 +276,16 @@ function AngelType_view_table_headers($angeltype, $supporter, $admin_angeltypes)
/** /**
* Render an angeltype page containing the member lists. * Render an angeltype page containing the member lists.
*
* @param array $angeltype
* @param array[] $members
* @param array $user_angeltype
* @param bool $admin_user_angeltypes
* @param bool $admin_angeltypes
* @param bool $supporter
* @param array $user_driver_license
* @param array $user
* @return string
*/ */
function AngelType_view( function AngelType_view(
$angeltype, $angeltype,
@ -339,6 +369,8 @@ function AngelType_view(
* Display the list of angeltypes. * Display the list of angeltypes.
* *
* @param array $angeltypes * @param array $angeltypes
* @param bool $admin_angeltypes
* @return string
*/ */
function AngelTypes_list_view($angeltypes, $admin_angeltypes) function AngelTypes_list_view($angeltypes, $admin_angeltypes)
{ {
@ -360,6 +392,9 @@ function AngelTypes_list_view($angeltypes, $admin_angeltypes)
/** /**
* Renders the about info for an angeltype. * Renders the about info for an angeltype.
*
* @param array $angeltype
* @return string
*/ */
function AngelTypes_about_view_angeltype($angeltype) function AngelTypes_about_view_angeltype($angeltype)
{ {
@ -401,6 +436,10 @@ function AngelTypes_about_view_angeltype($angeltype)
/** /**
* Renders a site that contains every angeltype and its description, basically as an overview of the needed help types. * Renders a site that contains every angeltype and its description, basically as an overview of the needed help types.
*
* @param array[] $angeltypes
* @param bool $user_logged_in
* @return string
*/ */
function AngelTypes_about_view($angeltypes, $user_logged_in) function AngelTypes_about_view($angeltypes, $user_logged_in)
{ {

@ -3,7 +3,8 @@
/** /**
* Shows basic event infos and countdowns. * Shows basic event infos and countdowns.
* *
* @param EventConfig $event_config The event configuration * @param array $event_config The event configuration
* @return string
*/ */
function EventConfig_countdown_page($event_config) function EventConfig_countdown_page($event_config)
{ {
@ -61,6 +62,9 @@ function EventConfig_countdown_page($event_config)
/** /**
* Converts event name and start+end date into a line of text. * Converts event name and start+end date into a line of text.
*
* @param array $event_config
* @return string
*/ */
function EventConfig_info($event_config) function EventConfig_info($event_config)
{ {
@ -106,14 +110,13 @@ function EventConfig_info($event_config)
/** /**
* Render edit page for event config. * Render edit page for event config.
* *
* @param string $event_name * @param string $event_name The event name
* The event name * @param string $event_welcome_msg The welcome message
* @param string $event_welcome_msg * @param int $buildup_start_date unix time stamp
* The welcome message * @param int $event_start_date unix time stamp
* @param date $buildup_start_date * @param int $event_end_date unix time stamp
* @param date $event_start_date * @param int $teardown_end_date unix time stamp
* @param date $event_end_date * @return string
* @param date $teardown_end_date
*/ */
function EventConfig_edit_view( function EventConfig_edit_view(
$event_name, $event_name,

@ -1,5 +1,11 @@
<?php <?php
/**
* @param array[] $open_questions
* @param array[] $answered_questions
* @param string $ask_action
* @return string
*/
function Questions_view($open_questions, $answered_questions, $ask_action) function Questions_view($open_questions, $answered_questions, $ask_action)
{ {
foreach ($open_questions as &$question) { foreach ($open_questions as &$question) {

@ -2,6 +2,12 @@
use Engelsystem\ShiftCalendarRenderer; use Engelsystem\ShiftCalendarRenderer;
use Engelsystem\ShiftsFilterRenderer; use Engelsystem\ShiftsFilterRenderer;
/**
* @param array $room
* @param ShiftsFilterRenderer $shiftsFilterRenderer
* @param ShiftCalendarRenderer $shiftCalendarRenderer
* @return string
*/
function Room_view($room, ShiftsFilterRenderer $shiftsFilterRenderer, ShiftCalendarRenderer $shiftCalendarRenderer) function Room_view($room, ShiftsFilterRenderer $shiftsFilterRenderer, ShiftCalendarRenderer $shiftCalendarRenderer)
{ {
return page_with_title(glyph('map-marker') . $room['Name'], [ return page_with_title(glyph('map-marker') . $room['Name'], [
@ -10,6 +16,10 @@ function Room_view($room, ShiftsFilterRenderer $shiftsFilterRenderer, ShiftCalen
]); ]);
} }
/**
* @param array $room
* @return string
*/
function Room_name_render($room) function Room_name_render($room)
{ {
global $privileges; global $privileges;

@ -7,14 +7,25 @@ namespace Engelsystem;
*/ */
class ShiftCalendarLane class ShiftCalendarLane
{ {
/** @var int */
private $firstBlockStartTime; private $firstBlockStartTime;
/** @var int */
private $blockCount; private $blockCount;
/** @var string */
private $header; private $header;
/** @var array[] */
private $shifts = []; private $shifts = [];
/**
* ShiftCalendarLane constructor.
*
* @param string $header
* @param int $firstBlockStartTime Unix timestamp
* @param int $blockCount
*/
public function __construct($header, $firstBlockStartTime, $blockCount) public function __construct($header, $firstBlockStartTime, $blockCount)
{ {
$this->header = $header; $this->header = $header;
@ -26,8 +37,7 @@ class ShiftCalendarLane
* Adds a shift to the lane, but only if it fits. * Adds a shift to the lane, but only if it fits.
* Returns true on success. * Returns true on success.
* *
* @param Shift $shift * @param array $shift The shift to add
* The shift to add
* @return boolean true on success * @return boolean true on success
*/ */
public function addShift($shift) public function addShift($shift)
@ -42,8 +52,9 @@ class ShiftCalendarLane
/** /**
* Returns true if given shift fits into this lane. * Returns true if given shift fits into this lane.
* *
* @param Shift $shift * @param array $newShift
* The shift to fit into this lane * @return bool
* @internal param array $shift The shift to fit into this lane
*/ */
public function shiftFits($newShift) public function shiftFits($newShift)
{ {
@ -55,11 +66,17 @@ class ShiftCalendarLane
return true; return true;
} }
/**
* @return string
*/
public function getHeader() public function getHeader()
{ {
return $this->header; return $this->header;
} }
/**
* @return array[]
*/
public function getShifts() public function getShifts()
{ {
return $this->shifts; return $this->shifts;

@ -26,20 +26,35 @@ class ShiftCalendarRenderer
*/ */
const TIME_MARGIN = 1800; const TIME_MARGIN = 1800;
/** @var array */
private $lanes; private $lanes;
/** @var ShiftsFilter */
private $shiftsFilter; private $shiftsFilter;
private $firstBlockStartTime = null; /** @var int */
private $firstBlockStartTime = 0;
private $lastBlockEndTime = null; /** @var int */
private $lastBlockEndTime = 0;
/** @var int */
private $blocksPerSlot = null; private $blocksPerSlot = null;
private $needed_angeltypes = null; /** @var array[] */
private $needed_angeltypes = [];
private $shift_entries = null; /** @var array[] */
private $shift_entries = [];
/**
* ShiftCalendarRenderer constructor.
*
* @param array[] $shifts
* @param array[] $needed_angeltypes
* @param array[] $shift_entries
* @param ShiftsFilter $shiftsFilter
*/
public function __construct($shifts, $needed_angeltypes, $shift_entries, ShiftsFilter $shiftsFilter) public function __construct($shifts, $needed_angeltypes, $shift_entries, ShiftsFilter $shiftsFilter)
{ {
$this->shiftsFilter = $shiftsFilter; $this->shiftsFilter = $shiftsFilter;
@ -53,10 +68,9 @@ class ShiftCalendarRenderer
/** /**
* Assigns the shifts to different lanes per room if they collide * Assigns the shifts to different lanes per room if they collide
* *
* @param Shift[] $shifts * @param array[] $shifts The shifts to assign
* The shifts to assign
* *
* @return Returns an array that assigns a room_id to an array of ShiftCalendarLane containing the shifts * @return array Returns an array that assigns a room_id to an array of ShiftCalendarLane containing the shifts
*/ */
private function assignShiftsToLanes($shifts) private function assignShiftsToLanes($shifts)
{ {
@ -78,6 +92,7 @@ class ShiftCalendarRenderer
// Try to add the shift to the existing lanes for this room // Try to add the shift to the existing lanes for this room
$shift_added = false; $shift_added = false;
foreach ($lanes[$room_id] as $lane) { foreach ($lanes[$room_id] as $lane) {
/** @var ShiftCalendarLane $lane */
$shift_added = $lane->addShift($shift); $shift_added = $lane->addShift($shift);
if ($shift_added == true) { if ($shift_added == true) {
break; break;
@ -96,16 +111,25 @@ class ShiftCalendarRenderer
return $lanes; return $lanes;
} }
/**
* @return int
*/
public function getFirstBlockStartTime() public function getFirstBlockStartTime()
{ {
return $this->firstBlockStartTime; return $this->firstBlockStartTime;
} }
/**
* @return int
*/
public function getLastBlockEndTime() public function getLastBlockEndTime()
{ {
return $this->lastBlockEndTime; return $this->lastBlockEndTime;
} }
/**
* @return float
*/
public function getBlocksPerSlot() public function getBlocksPerSlot()
{ {
if ($this->blocksPerSlot == null) { if ($this->blocksPerSlot == null) {
@ -117,7 +141,7 @@ class ShiftCalendarRenderer
/** /**
* Renders the whole calendar * Renders the whole calendar
* *
* @return the generated html * @return string the generated html
*/ */
public function render() public function render()
{ {
@ -132,6 +156,8 @@ class ShiftCalendarRenderer
/** /**
* Renders the lanes containing the shifts * Renders the lanes containing the shifts
*
* @return string
*/ */
private function renderShiftLanes() private function renderShiftLanes()
{ {
@ -148,8 +174,8 @@ class ShiftCalendarRenderer
/** /**
* Renders a single lane * Renders a single lane
* *
* @param ShiftCalendarLane $lane * @param ShiftCalendarLane $lane The lane to render
* The lane to render * @return string
*/ */
private function renderLane(ShiftCalendarLane $lane) private function renderLane(ShiftCalendarLane $lane)
{ {
@ -165,8 +191,12 @@ class ShiftCalendarRenderer
$rendered_until += ShiftCalendarRenderer::SECONDS_PER_ROW; $rendered_until += ShiftCalendarRenderer::SECONDS_PER_ROW;
} }
list($shift_height, $shift_html) = $shift_renderer->render($shift, $this->needed_angeltypes[$shift['SID']], list($shift_height, $shift_html) = $shift_renderer->render(
$this->shift_entries[$shift['SID']], $user); $shift,
$this->needed_angeltypes[$shift['SID']],
$this->shift_entries[$shift['SID']],
$user
);
$html .= $shift_html; $html .= $shift_html;
$rendered_until += $shift_height * ShiftCalendarRenderer::SECONDS_PER_ROW; $rendered_until += $shift_height * ShiftCalendarRenderer::SECONDS_PER_ROW;
} }
@ -185,11 +215,9 @@ class ShiftCalendarRenderer
/** /**
* Renders a tick/block for given time * Renders a tick/block for given time
* *
* @param int $time * @param int $time unix timestamp
* unix timestamp * @param boolean $label Should time labels be generated?
* @param boolean $label * @return string rendered tick html
* Should time labels be generated?
* @return rendered tick html
*/ */
private function renderTick($time, $label = false) private function renderTick($time, $label = false)
{ {
@ -213,6 +241,8 @@ class ShiftCalendarRenderer
/** /**
* Renders the left time lane including hour/day ticks * Renders the left time lane including hour/day ticks
*
* @return string
*/ */
private function renderTimeLane() private function renderTimeLane()
{ {
@ -228,6 +258,10 @@ class ShiftCalendarRenderer
return div('lane time', $time_slot); return div('lane time', $time_slot);
} }
/**
* @param array[] $shifts
* @return int
*/
private function calcFirstBlockStartTime($shifts) private function calcFirstBlockStartTime($shifts)
{ {
$start_time = $this->shiftsFilter->getEndTime(); $start_time = $this->shiftsFilter->getEndTime();
@ -239,6 +273,10 @@ class ShiftCalendarRenderer
return ShiftCalendarRenderer::SECONDS_PER_ROW * floor(($start_time - ShiftCalendarRenderer::TIME_MARGIN) / ShiftCalendarRenderer::SECONDS_PER_ROW); return ShiftCalendarRenderer::SECONDS_PER_ROW * floor(($start_time - ShiftCalendarRenderer::TIME_MARGIN) / ShiftCalendarRenderer::SECONDS_PER_ROW);
} }
/**
* @param array[] $shifts
* @return int
*/
private function calcLastBlockEndTime($shifts) private function calcLastBlockEndTime($shifts)
{ {
$end_time = $this->shiftsFilter->getStartTime(); $end_time = $this->shiftsFilter->getStartTime();
@ -250,6 +288,9 @@ class ShiftCalendarRenderer
return ShiftCalendarRenderer::SECONDS_PER_ROW * ceil(($end_time + ShiftCalendarRenderer::TIME_MARGIN) / ShiftCalendarRenderer::SECONDS_PER_ROW); return ShiftCalendarRenderer::SECONDS_PER_ROW * ceil(($end_time + ShiftCalendarRenderer::TIME_MARGIN) / ShiftCalendarRenderer::SECONDS_PER_ROW);
} }
/**
* @return int
*/
private function calcBlocksPerSlot() private function calcBlocksPerSlot()
{ {
return ceil(($this->getLastBlockEndTime() - $this->getFirstBlockStartTime()) / ShiftCalendarRenderer::SECONDS_PER_ROW); return ceil(($this->getLastBlockEndTime() - $this->getFirstBlockStartTime()) / ShiftCalendarRenderer::SECONDS_PER_ROW);
@ -257,6 +298,8 @@ class ShiftCalendarRenderer
/** /**
* Renders a legend explaining the shift coloring * Renders a legend explaining the shift coloring
*
* @return string
*/ */
private function renderLegend() private function renderLegend()
{ {

@ -7,14 +7,14 @@ namespace Engelsystem;
*/ */
class ShiftCalendarShiftRenderer class ShiftCalendarShiftRenderer
{ {
/** /**
* Renders a shift * Renders a shift
* *
* @param Shift $shift * @param array $shift The shift to render
* The shift to render * @param array $needed_angeltypes
* @param User $user * @param array $shift_entries
* The user who is viewing the shift calendar * @param array $user The user who is viewing the shift calendar
* @return array
*/ */
public function render($shift, $needed_angeltypes, $shift_entries, $user) public function render($shift, $needed_angeltypes, $shift_entries, $user)
{ {
@ -53,6 +53,10 @@ class ShiftCalendarShiftRenderer
]; ];
} }
/**
* @param ShiftSignupState $shiftSignupState
* @return string
*/
private function classForSignupState(ShiftSignupState $shiftSignupState) private function classForSignupState(ShiftSignupState $shiftSignupState)
{ {
switch ($shiftSignupState->getState()) { switch ($shiftSignupState->getState()) {
@ -72,9 +76,18 @@ class ShiftCalendarShiftRenderer
case ShiftSignupState::FREE: case ShiftSignupState::FREE:
return 'danger'; return 'danger';
default:
return '';
} }
} }
/**
* @param array $shift
* @param array[] $needed_angeltypes
* @param array[] $shift_entries
* @param array $user
* @return array
*/
private function renderShiftNeededAngeltypes($shift, $needed_angeltypes, $shift_entries, $user) private function renderShiftNeededAngeltypes($shift, $needed_angeltypes, $shift_entries, $user)
{ {
global $privileges; global $privileges;
@ -88,6 +101,7 @@ class ShiftCalendarShiftRenderer
} }
$html = ""; $html = "";
/** @var ShiftSignupState $shift_signup_state */
$shift_signup_state = null; $shift_signup_state = null;
foreach ($needed_angeltypes as $angeltype) { foreach ($needed_angeltypes as $angeltype) {
if ($angeltype['count'] > 0 || count($shift_entries_filtered[$angeltype['id']]) > 0) { if ($angeltype['count'] > 0 || count($shift_entries_filtered[$angeltype['id']]) > 0) {
@ -131,12 +145,12 @@ class ShiftCalendarShiftRenderer
/** /**
* Renders a list entry containing the needed angels for an angeltype * Renders a list entry containing the needed angels for an angeltype
* *
* @param Shift $shift * @param array $shift The shift which is rendered
* The shift which is rendered * @param array[] $shift_entries
* @param Angeltype $angeltype * @param array[] $angeltype The angeltype, containing informations about needed angeltypes
* The angeltype, containing informations about needed angeltypes and already signed up angels * and already signed up angels
* @param User $user * @param array $user The user who is viewing the shift calendar
* The user who is viewing the shift calendar * @return array
*/ */
private function renderShiftNeededAngeltype($shift, $shift_entries, $angeltype, $user) private function renderShiftNeededAngeltype($shift, $shift_entries, $angeltype, $user)
{ {
@ -150,6 +164,7 @@ class ShiftCalendarShiftRenderer
ngettext("%d helper needed", "%d helpers needed", $shift_signup_state->getFreeEntries()), ngettext("%d helper needed", "%d helpers needed", $shift_signup_state->getFreeEntries()),
$shift_signup_state->getFreeEntries() $shift_signup_state->getFreeEntries()
); );
switch ($shift_signup_state->getState()) { switch ($shift_signup_state->getState()) {
case ShiftSignupState::ADMIN: case ShiftSignupState::ADMIN:
case ShiftSignupState::FREE: case ShiftSignupState::FREE:
@ -207,8 +222,8 @@ class ShiftCalendarShiftRenderer
/** /**
* Renders the shift header * Renders the shift header
* *
* @param Shift $shift * @param array $shift The shift
* The shift * @return string
*/ */
private function renderShiftHead($shift) private function renderShiftHead($shift)
{ {

@ -9,7 +9,9 @@
* @param string $title * @param string $title
* @param string $type * @param string $type
* @param string $comment * @param string $comment
* * @param bool $freeloaded
* @param string $freeload_comment
* @param bool $user_admin_shifts
* @return string * @return string
*/ */
function ShiftEntry_edit_view( function ShiftEntry_edit_view(

@ -1,5 +1,9 @@
<?php <?php
/**
* @param array $shifttype
* @return string
*/
function ShiftType_name_render($shifttype) function ShiftType_name_render($shifttype)
{ {
global $privileges; global $privileges;
@ -9,6 +13,10 @@ function ShiftType_name_render($shifttype)
return $shifttype['name']; return $shifttype['name'];
} }
/**
* @param array $shifttype
* @return string
*/
function ShiftType_delete_view($shifttype) function ShiftType_delete_view($shifttype)
{ {
return page_with_title(sprintf(_("Delete shifttype %s"), $shifttype['name']), [ return page_with_title(sprintf(_("Delete shifttype %s"), $shifttype['name']), [
@ -24,6 +32,14 @@ function ShiftType_delete_view($shifttype)
]); ]);
} }
/**
* @param string $name
* @param int $angeltype_id
* @param array[] $angeltypes
* @param string $description
* @param int|bool $shifttype_id
* @return string
*/
function ShiftType_edit_view($name, $angeltype_id, $angeltypes, $description, $shifttype_id) function ShiftType_edit_view($name, $angeltype_id, $angeltypes, $description, $shifttype_id)
{ {
$angeltypes_select = [ $angeltypes_select = [
@ -48,6 +64,11 @@ function ShiftType_edit_view($name, $angeltype_id, $angeltypes, $description, $s
]); ]);
} }
/**
* @param array $shifttype
* @param array $angeltype
* @return string
*/
function ShiftType_view($shifttype, $angeltype) function ShiftType_view($shifttype, $angeltype)
{ {
$parsedown = new Parsedown(); $parsedown = new Parsedown();
@ -75,6 +96,10 @@ function ShiftType_view($shifttype, $angeltype)
]); ]);
} }
/**
* @param array[] $shifttypes
* @return string
*/
function ShiftTypes_list_view($shifttypes) function ShiftTypes_list_view($shifttypes)
{ {
foreach ($shifttypes as &$shifttype) { foreach ($shifttypes as &$shifttype) {

@ -4,7 +4,6 @@ namespace Engelsystem;
class ShiftsFilterRenderer class ShiftsFilterRenderer
{ {
/** /**
* The shiftFilter to render. * The shiftFilter to render.
* *
@ -27,6 +26,11 @@ class ShiftsFilterRenderer
*/ */
private $days = []; private $days = [];
/**
* ShiftsFilterRenderer constructor.
*
* @param ShiftsFilter $shiftsFilter
*/
public function __construct(ShiftsFilter $shiftsFilter) public function __construct(ShiftsFilter $shiftsFilter)
{ {
$this->shiftsFilter = $shiftsFilter; $this->shiftsFilter = $shiftsFilter;
@ -35,7 +39,8 @@ class ShiftsFilterRenderer
/** /**
* Renders the filter. * Renders the filter.
* *
* @return Generated HTML * @param string $link_base
* @return string Generated HTML
*/ */
public function render($link_base) public function render($link_base)
{ {
@ -55,6 +60,8 @@ class ShiftsFilterRenderer
/** /**
* Should the filter display a day selection. * Should the filter display a day selection.
*
* @param string[] $days
*/ */
public function enableDaySelection($days) public function enableDaySelection($days)
{ {
@ -64,6 +71,8 @@ class ShiftsFilterRenderer
/** /**
* Should the filter display a day selection. * Should the filter display a day selection.
*
* @return bool
*/ */
public function isDaySelectionEnabled() public function isDaySelectionEnabled()
{ {

@ -1,6 +1,10 @@
<?php <?php
use Engelsystem\ShiftSignupState; use Engelsystem\ShiftSignupState;
/**
* @param array $shift
* @return string
*/
function Shift_editor_info_render($shift) function Shift_editor_info_render($shift)
{ {
$info = []; $info = [];
@ -21,6 +25,12 @@ function Shift_editor_info_render($shift)
return join('<br />', $info); return join('<br />', $info);
} }
/**
* @param array $shift
* @param array $angeltype
* @param array $user_angeltype
* @return string
*/
function Shift_signup_button_render($shift, $angeltype, $user_angeltype = null) function Shift_signup_button_render($shift, $angeltype, $user_angeltype = null)
{ {
global $user; global $user;
@ -44,6 +54,14 @@ function Shift_signup_button_render($shift, $angeltype, $user_angeltype = null)
return ''; return '';
} }
/**
* @param array $shift
* @param array $shifttype
* @param array $room
* @param array[] $angeltypes_source
* @param ShiftSignupState $shift_signup_state
* @return string
*/
function Shift_view($shift, $shifttype, $room, $angeltypes_source, ShiftSignupState $shift_signup_state) function Shift_view($shift, $shifttype, $room, $angeltypes_source, ShiftSignupState $shift_signup_state)
{ {
global $privileges; global $privileges;
@ -122,6 +140,13 @@ function Shift_view($shift, $shifttype, $room, $angeltypes_source, ShiftSignupSt
); );
} }
/**
* @param array $needed_angeltype
* @param array $angeltypes
* @param array[] $shift
* @param bool $user_shift_admin
* @return string
*/
function Shift_view_render_needed_angeltype($needed_angeltype, $angeltypes, $shift, $user_shift_admin) function Shift_view_render_needed_angeltype($needed_angeltype, $angeltypes, $shift, $user_shift_admin)
{ {
global $user; global $user;
@ -166,11 +191,17 @@ function Shift_view_render_needed_angeltype($needed_angeltype, $angeltypes, $shi
return $needed_angels; return $needed_angels;
} }
/**
* @param array $shift_entry
* @param bool $user_shift_admin
* @param bool $angeltype_supporter
* @return string
*/
function Shift_view_render_shift_entry($shift_entry, $user_shift_admin, $angeltype_supporter) function Shift_view_render_shift_entry($shift_entry, $user_shift_admin, $angeltype_supporter)
{ {
$entry = User_Nick_render(User($shift_entry['UID'])); $entry = User_Nick_render(User($shift_entry['UID']));
if ($shift_entry['freeloaded']) { if ($shift_entry['freeloaded']) {
$entry = '<strike>' . $entry . '</strike>'; $entry = '<del>' . $entry . '</del>';
} }
if ($user_shift_admin || $angeltype_supporter) { if ($user_shift_admin || $angeltype_supporter) {
$entry .= ' <div class="btn-group">'; $entry .= ' <div class="btn-group">';
@ -190,7 +221,8 @@ function Shift_view_render_shift_entry($shift_entry, $user_shift_admin, $angelty
/** /**
* Calc shift length in format 12:23h. * Calc shift length in format 12:23h.
* *
* @param Shift $shift * @param array $shift
* @return string
*/ */
function shift_length($shift) function shift_length($shift)
{ {

@ -1,5 +1,12 @@
<?php <?php
/**
* @param array $user_angeltype
* @param array $user
* @param array $angeltype
* @param bool $supporter
* @return string
*/
function UserAngelType_update_view($user_angeltype, $user, $angeltype, $supporter) function UserAngelType_update_view($user_angeltype, $user, $angeltype, $supporter)
{ {
return page_with_title($supporter ? _("Add supporter rights") : _("Remove supporter rights"), [ return page_with_title($supporter ? _("Add supporter rights") : _("Remove supporter rights"), [
@ -25,6 +32,10 @@ function UserAngelType_update_view($user_angeltype, $user, $angeltype, $supporte
]); ]);
} }
/**
* @param array $angeltype
* @return string
*/
function UserAngelTypes_delete_all_view($angeltype) function UserAngelTypes_delete_all_view($angeltype)
{ {
return page_with_title(_("Deny all users"), [ return page_with_title(_("Deny all users"), [
@ -41,6 +52,10 @@ function UserAngelTypes_delete_all_view($angeltype)
]); ]);
} }
/**
* @param array $angeltype
* @return string
*/
function UserAngelTypes_confirm_all_view($angeltype) function UserAngelTypes_confirm_all_view($angeltype)
{ {
return page_with_title(_("Confirm all users"), [ return page_with_title(_("Confirm all users"), [
@ -57,6 +72,12 @@ function UserAngelTypes_confirm_all_view($angeltype)
]); ]);
} }
/**
* @param array $user_angeltype
* @param array $user
* @param array $angeltype
* @return string
*/
function UserAngelType_confirm_view($user_angeltype, $user, $angeltype) function UserAngelType_confirm_view($user_angeltype, $user, $angeltype)
{ {
return page_with_title(_("Confirm angeltype for user"), [ return page_with_title(_("Confirm angeltype for user"), [
@ -73,6 +94,12 @@ function UserAngelType_confirm_view($user_angeltype, $user, $angeltype)
]); ]);
} }
/**
* @param array $user_angeltype
* @param array $user
* @param array $angeltype
* @return string
*/
function UserAngelType_delete_view($user_angeltype, $user, $angeltype) function UserAngelType_delete_view($user_angeltype, $user, $angeltype)
{ {
return page_with_title(_("Remove angeltype"), [ return page_with_title(_("Remove angeltype"), [
@ -89,6 +116,12 @@ function UserAngelType_delete_view($user_angeltype, $user, $angeltype)
]); ]);
} }
/**
* @param array $angeltype
* @param array[] $users_source
* @param int $user_id
* @return string
*/
function UserAngelType_add_view($angeltype, $users_source, $user_id) function UserAngelType_add_view($angeltype, $users_source, $user_id)
{ {
$users = []; $users = [];
@ -109,6 +142,11 @@ function UserAngelType_add_view($angeltype, $users_source, $user_id)
]); ]);
} }
/**
* @param array $user
* @param array $angeltype
* @return string
*/
function UserAngelType_join_view($user, $angeltype) function UserAngelType_join_view($user, $angeltype)
{ {
return page_with_title(sprintf(_("Become a %s"), $angeltype['name']), [ return page_with_title(sprintf(_("Become a %s"), $angeltype['name']), [

@ -3,12 +3,9 @@
/** /**
* Edit a user's driving license information. * Edit a user's driving license information.
* *
* @param User $user_source * @param array $user_source The user
* The user * @param bool $wants_to_drive true, if the user wants to drive
* @param bool $wants_to_drive * @param array $user_driver_license The user driver license
* true, if the user wants to drive
* @param UserDriverLicense $user_driver_license
* The user driver license
* @return string * @return string
*/ */
function UserDriverLicense_edit_view($user_source, $wants_to_drive, $user_driver_license) function UserDriverLicense_edit_view($user_source, $wants_to_drive, $user_driver_license)
@ -52,13 +49,14 @@ function UserDriverLicense_edit_view($user_source, $wants_to_drive, $user_driver
]), ]),
'<script type="text/javascript"> '<script type="text/javascript">
$(function() { $(function() {
if($("#wants_to_drive").is(":checked")) var checkbox = $("#wants_to_drive");
if(checkbox.is(":checked"))
$("#driving_license").show(); $("#driving_license").show();
else else
$("#driving_license").hide(); $("#driving_license").hide();
$("#wants_to_drive").click( checkbox.click(
function(e) { function() {
if($("#wants_to_drive").is(":checked")) if($("#wants_to_drive").is(":checked"))
$("#driving_license").show(); $("#driving_license").show();
else else

@ -4,12 +4,15 @@ namespace Engelsystem;
class UserHintsRenderer class UserHintsRenderer
{ {
/** @var string[] */
private $hints = []; private $hints = [];
private $important = false; private $important = false;
/** /**
* Render the added hints to a popover for the toolbar. * Render the added hints to a popover for the toolbar.
*
* @return string
*/ */
public function render() public function render()
{ {
@ -26,10 +29,8 @@ class UserHintsRenderer
/** /**
* Add a hint to the list, if its not null and a not empty string. * Add a hint to the list, if its not null and a not empty string.
* *
* @param string $hint * @param string $hint The hint
* The hint * @param boolean $important Is the hint important?
* @param boolean $important
* Is the hint important?
*/ */
public function addHint($hint, $important = false) public function addHint($hint, $important = false)
{ {
@ -45,6 +46,8 @@ class UserHintsRenderer
/** /**
* Get all hints. * Get all hints.
*
* @return string[]
*/ */
public function getHints() public function getHints()
{ {
@ -53,6 +56,8 @@ class UserHintsRenderer
/** /**
* Are there important hints? This leads to a more intensive icon. * Are there important hints? This leads to a more intensive icon.
*
* @return bool
*/ */
public function isImportant() public function isImportant()
{ {

@ -22,12 +22,14 @@ $tshirt_sizes = [
/** /**
* Renders user settings page * Renders user settings page
* *
* @param User $user_source * @param array $user_source The user
* The user * @param array $locales Available languages
* @param array <String> $locales * @param array $themes Available themes
* Available languages * @param int $buildup_start_date Unix timestamp
* @param array <String> $themes * @param int $teardown_end_date Unix timestamp
* Available themes * @param bool $enable_tshirt_size
* @param array $tshirt_sizes
* @return string
*/ */
function User_settings_view( function User_settings_view(
$user_source, $user_source,
@ -52,7 +54,8 @@ function User_settings_view(
'planned_arrival_date', 'planned_arrival_date',
_("Planned date of arrival") . ' ' . entry_required(), _("Planned date of arrival") . ' ' . entry_required(),
$user_source['planned_arrival_date'], $user_source['planned_arrival_date'],
$buildup_start_date, $teardown_end_date $buildup_start_date,
$teardown_end_date
), ),
form_date( form_date(
'planned_departure_date', 'planned_departure_date',
@ -113,6 +116,9 @@ function User_settings_view(
/** /**
* Displays the welcome message to the user and shows a login form. * Displays the welcome message to the user and shows a login form.
*
* @param string $event_welcome_message
* @return string
*/ */
function User_registration_success_view($event_welcome_message) function User_registration_success_view($event_welcome_message)
{ {
@ -149,6 +155,9 @@ function User_registration_success_view($event_welcome_message)
/** /**
* Gui for deleting user with password field. * Gui for deleting user with password field.
*
* @param array $user
* @return string
*/ */
function User_delete_view($user) function User_delete_view($user)
{ {
@ -170,6 +179,9 @@ function User_delete_view($user)
/** /**
* View for editing the number of given vouchers * View for editing the number of given vouchers
*
* @param array $user
* @return string
*/ */
function User_edit_vouchers_view($user) function User_edit_vouchers_view($user)
{ {
@ -186,6 +198,17 @@ function User_edit_vouchers_view($user)
]); ]);
} }
/**
* @param array[] $users
* @param string $order_by
* @param int $arrived_count
* @param int $active_count
* @param int $force_active_count
* @param int $freeloads_count
* @param int $tshirts_count
* @param int $voucher_count
* @return string
*/
function Users_view( function Users_view(
$users, $users,
$order_by, $order_by,
@ -199,7 +222,6 @@ function Users_view(
foreach ($users as &$user) { foreach ($users as &$user) {
$user['Nick'] = User_Nick_render($user); $user['Nick'] = User_Nick_render($user);
$user['Gekommen'] = glyph_bool($user['Gekommen']); $user['Gekommen'] = glyph_bool($user['Gekommen']);
$user['got_voucher'] = $user['got_voucher'];
$user['Aktiv'] = glyph_bool($user['Aktiv']); $user['Aktiv'] = glyph_bool($user['Aktiv']);
$user['force_active'] = glyph_bool($user['force_active']); $user['force_active'] = glyph_bool($user['force_active']);
$user['Tshirt'] = glyph_bool($user['Tshirt']); $user['Tshirt'] = glyph_bool($user['Tshirt']);
@ -242,11 +264,21 @@ function Users_view(
]); ]);
} }
/**
* @param string $column
* @param string $label
* @param string $order_by
* @return string
*/
function Users_table_header_link($column, $label, $order_by) function Users_table_header_link($column, $label, $order_by)
{ {
return '<a href="' . page_link_to('users') . '&OrderBy=' . $column . '">' . $label . ($order_by == $column ? ' <span class="caret"></span>' : '') . '</a>'; return '<a href="' . page_link_to('users') . '&OrderBy=' . $column . '">' . $label . ($order_by == $column ? ' <span class="caret"></span>' : '') . '</a>';
} }
/**
* @param array $user
* @return string|false
*/
function User_shift_state_render($user) function User_shift_state_render($user)
{ {
$upcoming_shifts = ShiftEntries_upcoming_for_user($user); $upcoming_shifts = ShiftEntries_upcoming_for_user($user);
@ -272,6 +304,10 @@ function User_shift_state_render($user)
return '<span class="text-danger moment-countdown" data-timestamp="' . $upcoming_shifts[0]['end'] . '">' . _("Shift ends %c") . '</span>'; return '<span class="text-danger moment-countdown" data-timestamp="' . $upcoming_shifts[0]['end'] . '">' . _("Shift ends %c") . '</span>';
} }
/**
* @param array $needed_angel_type
* @return string
*/
function User_view_shiftentries($needed_angel_type) function User_view_shiftentries($needed_angel_type)
{ {
$shift_info = '<br><b>' . $needed_angel_type['name'] . ':</b> '; $shift_info = '<br><b>' . $needed_angel_type['name'] . ':</b> ';
@ -280,7 +316,7 @@ function User_view_shiftentries($needed_angel_type)
foreach ($needed_angel_type['users'] as $user_shift) { foreach ($needed_angel_type['users'] as $user_shift) {
$member = User_Nick_render($user_shift); $member = User_Nick_render($user_shift);
if ($user_shift['freeloaded']) { if ($user_shift['freeloaded']) {
$member = '<strike>' . $member . '</strike>'; $member = '<del>' . $member . '</del>';
} }
$shift_entries[] = $member; $shift_entries[] = $member;
@ -292,10 +328,15 @@ function User_view_shiftentries($needed_angel_type)
/** /**
* Helper that renders a shift line for user view * Helper that renders a shift line for user view
*
* @param array $shift
* @param array $user_source
* @param bool $its_me
* @return array
*/ */
function User_view_myshift($shift, $user_source, $its_me) function User_view_myshift($shift, $user_source, $its_me)
{ {
global $LETZTES_AUSTRAGEN, $privileges; global $last_unsubscribe, $privileges;
$shift_info = '<a href="' . shift_link($shift) . '">' . $shift['name'] . '</a>'; $shift_info = '<a href="' . shift_link($shift) . '">' . $shift['name'] . '</a>';
if ($shift['title']) { if ($shift['title']) {
@ -331,7 +372,7 @@ function User_view_myshift($shift, $user_source, $its_me)
'btn-xs' 'btn-xs'
); );
} }
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)) {
$myshift['actions'][] = button( $myshift['actions'][] = button(
page_link_to('user_myshifts') . ((!$its_me) ? '&id=' . $user_source['UID'] : '') . '&cancel=' . $shift['id'], page_link_to('user_myshifts') . ((!$its_me) ? '&id=' . $user_source['UID'] : '') . '&cancel=' . $shift['id'],
glyph('trash') . _('sign off'), glyph('trash') . _('sign off'),
@ -345,6 +386,11 @@ function User_view_myshift($shift, $user_source, $its_me)
/** /**
* Helper that prepares the shift table for user view * Helper that prepares the shift table for user view
*
* @param array[] $shifts
* @param array $user_source
* @param bool $its_me
* @return array
*/ */
function User_view_myshifts($shifts, $user_source, $its_me) function User_view_myshifts($shifts, $user_source, $its_me)
{ {
@ -375,6 +421,15 @@ function User_view_myshifts($shifts, $user_source, $its_me)
/** /**
* Renders view for a single user * Renders view for a single user
*
* @param array $user_source
* @param bool $admin_user_privilege
* @param bool $freeloader
* @param array[] $user_angeltypes
* @param array[] $user_groups
* @param array[] $shifts
* @param bool $its_me
* @return string
*/ */
function User_view($user_source, $admin_user_privilege, $freeloader, $user_angeltypes, $user_groups, $shifts, $its_me) function User_view($user_source, $admin_user_privilege, $freeloader, $user_angeltypes, $user_groups, $shifts, $its_me)
{ {
@ -489,11 +544,14 @@ function User_view($user_source, $admin_user_privilege, $freeloader, $user_angel
page_link_to('user_shifts') page_link_to('user_shifts')
), true) ), true)
: '' : ''
]); ]
);
} }
/** /**
* View for password recovery step 1: E-Mail * View for password recovery step 1: E-Mail
*
* @return string
*/ */
function User_password_recovery_view() function User_password_recovery_view()
{ {
@ -509,6 +567,8 @@ function User_password_recovery_view()
/** /**
* View for password recovery step 2: New password * View for password recovery step 2: New password
*
* @return string
*/ */
function User_password_set_view() function User_password_set_view()
{ {
@ -523,25 +583,27 @@ function User_password_set_view()
]); ]);
} }
/**
* @param array[] $user_angeltypes
* @return string
*/
function User_angeltypes_render($user_angeltypes) function User_angeltypes_render($user_angeltypes)
{ {
$output = []; $output = [];
foreach ($user_angeltypes as $angeltype) { foreach ($user_angeltypes as $angeltype) {
$class = ""; $class = 'text-success';
if ($angeltype['restricted'] == 1) { if ($angeltype['restricted'] == 1 && $angeltype['confirm_user_id'] == null) {
if ($angeltype['confirm_user_id'] != null) { $class = 'text-warning';
$class = 'text-success';
} else {
$class = 'text-warning';
}
} else {
$class = 'text-success';
} }
$output[] = '<a href="' . angeltype_link($angeltype['id']) . '" class="' . $class . '">' . ($angeltype['supporter'] ? glyph('education') : '') . $angeltype['name'] . '</a>'; $output[] = '<a href="' . angeltype_link($angeltype['id']) . '" class="' . $class . '">' . ($angeltype['supporter'] ? glyph('education') : '') . $angeltype['name'] . '</a>';
} }
return join('<br />', $output); return join('<br />', $output);
} }
/**
* @param array[] $user_groups
* @return string
*/
function User_groups_render($user_groups) function User_groups_render($user_groups)
{ {
$output = []; $output = [];
@ -554,14 +616,19 @@ function User_groups_render($user_groups)
/** /**
* Render a user nickname. * Render a user nickname.
* *
* @param User $user_source * @param array $user_source
* @return string * @return string
*/ */
function User_Nick_render($user_source) function User_Nick_render($user_source)
{ {
return '<a class="' . ($user_source['Gekommen'] ? '' : 'text-muted') . '" href="' . page_link_to('users') . '&amp;action=view&amp;user_id=' . $user_source['UID'] . '"><span class="icon-icon_angel"></span> ' . htmlspecialchars($user_source['Nick']) . '</a>'; return '<a class="' . ($user_source['Gekommen'] ? '' : 'text-muted') . '" href="'
. page_link_to('users') . '&amp;action=view&amp;user_id=' . $user_source['UID']
. '"><span class="icon-icon_angel"></span> ' . htmlspecialchars($user_source['Nick']) . '</a>';
} }
/**
* @return string|null
*/
function render_user_departure_date_hint() function render_user_departure_date_hint()
{ {
global $user; global $user;
@ -573,6 +640,9 @@ function render_user_departure_date_hint()
return null; return null;
} }
/**
* @return string|null
*/
function render_user_freeloader_hint() function render_user_freeloader_hint()
{ {
global $user, $max_freeloadable_shifts; global $user, $max_freeloadable_shifts;
@ -587,7 +657,11 @@ function render_user_freeloader_hint()
return null; return null;
} }
// Hinweis für Engel, die noch nicht angekommen sind /**
* Hinweis für Engel, die noch nicht angekommen sind
*
* @return string|null
*/
function render_user_arrived_hint() function render_user_arrived_hint()
{ {
global $user; global $user;
@ -599,6 +673,9 @@ function render_user_arrived_hint()
return null; return null;
} }
/**
* @return string|null
*/
function render_user_tshirt_hint() function render_user_tshirt_hint()
{ {
global $enable_tshirt_size, $user; global $enable_tshirt_size, $user;
@ -610,6 +687,9 @@ function render_user_tshirt_hint()
return null; return null;
} }
/**
* @return string|null
*/
function render_user_dect_hint() function render_user_dect_hint()
{ {
global $user; global $user;

@ -20,135 +20,134 @@ $free_pages = [
]; ];
// Gewünschte Seite/Funktion // Gewünschte Seite/Funktion
$page = ""; $page = '';
$title = '';
$content = '';
if (!isset($_REQUEST['p'])) { if (!isset($_REQUEST['p'])) {
$_REQUEST['p'] = isset($user) ? "news" : "login"; $_REQUEST['p'] = isset($user) ? 'news' : 'login';
} }
if ( if (
isset($_REQUEST['p']) isset($_REQUEST['p'])
&& preg_match("/^[a-z0-9_]*$/i", $_REQUEST['p']) && preg_match('/^[a-z0-9_]*$/i', $_REQUEST['p'])
&& ( && (
in_array($_REQUEST['p'], $free_pages) in_array($_REQUEST['p'], $free_pages)
|| in_array($_REQUEST['p'], $privileges) || (isset($privileges) && in_array($_REQUEST['p'], $privileges))
) )
) { ) {
$page = $_REQUEST['p']; $page = $_REQUEST['p'];
$title = $page; $title = $page;
$content = "";
if ($page == "api") { if ($page == 'api') {
error('Api disabled temporily.');
redirect(page_link_to());
require_once realpath(__DIR__ . '/../includes/controller/api.php'); require_once realpath(__DIR__ . '/../includes/controller/api.php');
error("Api disabled temporily.");
redirect(page_link_to('login'));
api_controller(); api_controller();
} elseif ($page == "ical") { } elseif ($page == 'ical') {
require_once realpath(__DIR__ . '/../includes/pages/user_ical.php'); require_once realpath(__DIR__ . '/../includes/pages/user_ical.php');
user_ical(); user_ical();
} elseif ($page == "atom") { } elseif ($page == 'atom') {
require_once realpath(__DIR__ . '/../includes/pages/user_atom.php'); require_once realpath(__DIR__ . '/../includes/pages/user_atom.php');
user_atom(); user_atom();
} elseif ($page == "shifts_json_export") { } elseif ($page == 'shifts_json_export') {
require_once realpath(__DIR__ . '/../includes/controller/shifts_controller.php'); require_once realpath(__DIR__ . '/../includes/controller/shifts_controller.php');
shifts_json_export_controller(); shifts_json_export_controller();
} elseif ($page == "shifts_json_export_all") { } elseif ($page == 'shifts_json_export_all') {
require_once realpath(__DIR__ . '/../includes/controller/shifts_controller.php'); require_once realpath(__DIR__ . '/../includes/controller/shifts_controller.php');
shifts_json_export_all_controller(); shifts_json_export_all_controller();
} elseif ($page == "stats") { } elseif ($page == 'stats') {
require_once realpath(__DIR__ . '/../includes/pages/guest_stats.php'); require_once realpath(__DIR__ . '/../includes/pages/guest_stats.php');
guest_stats(); guest_stats();
} elseif ($page == "user_password_recovery") { } elseif ($page == 'user_password_recovery') {
require_once realpath(__DIR__ . '/../includes/controller/users_controller.php'); require_once realpath(__DIR__ . '/../includes/controller/users_controller.php');
$title = user_password_recovery_title(); $title = user_password_recovery_title();
$content = user_password_recovery_controller(); $content = user_password_recovery_controller();
} elseif ($page == "angeltypes") { } elseif ($page == 'angeltypes') {
list($title, $content) = angeltypes_controller(); list($title, $content) = angeltypes_controller();
} elseif ($page == "shifts") { } elseif ($page == 'shifts') {
list($title, $content) = shifts_controller(); list($title, $content) = shifts_controller();
} elseif ($page == "users") { } elseif ($page == 'users') {
list($title, $content) = users_controller(); list($title, $content) = users_controller();
} elseif ($page == "user_angeltypes") { } elseif ($page == 'user_angeltypes') {
list($title, $content) = user_angeltypes_controller(); list($title, $content) = user_angeltypes_controller();
} elseif ($page == "user_driver_licenses") { } elseif ($page == 'user_driver_licenses') {
list($title, $content) = user_driver_licenses_controller(); list($title, $content) = user_driver_licenses_controller();
} elseif ($page == "shifttypes") { } elseif ($page == 'shifttypes') {
list($title, $content) = shifttypes_controller(); list($title, $content) = shifttypes_controller();
} elseif ($page == "admin_event_config") { } elseif ($page == 'admin_event_config') {
list($title, $content) = event_config_edit_controller(); list($title, $content) = event_config_edit_controller();
} elseif ($page == "rooms") { } elseif ($page == 'rooms') {
list($title, $content) = rooms_controller(); list($title, $content) = rooms_controller();
} elseif ($page == "news") { } elseif ($page == 'news') {
$title = news_title(); $title = news_title();
$content = user_news(); $content = user_news();
} elseif ($page == "news_comments") { } elseif ($page == 'news_comments') {
require_once realpath(__DIR__ . '/../includes/pages/user_news.php'); require_once realpath(__DIR__ . '/../includes/pages/user_news.php');
$title = user_news_comments_title(); $title = user_news_comments_title();
$content = user_news_comments(); $content = user_news_comments();
} elseif ($page == "user_meetings") { } elseif ($page == 'user_meetings') {
$title = meetings_title(); $title = meetings_title();
$content = user_meetings(); $content = user_meetings();
} elseif ($page == "user_myshifts") { } elseif ($page == 'user_myshifts') {
$title = myshifts_title(); $title = myshifts_title();
$content = user_myshifts(); $content = user_myshifts();
} elseif ($page == "user_shifts") { } elseif ($page == 'user_shifts') {
$title = shifts_title(); $title = shifts_title();
$content = user_shifts(); $content = user_shifts();
} elseif ($page == "user_messages") { } elseif ($page == 'user_messages') {
$title = messages_title(); $title = messages_title();
$content = user_messages(); $content = user_messages();
} elseif ($page == "user_questions") { } elseif ($page == 'user_questions') {
$title = questions_title(); $title = questions_title();
$content = user_questions(); $content = user_questions();
} elseif ($page == "user_settings") { } elseif ($page == 'user_settings') {
$title = settings_title(); $title = settings_title();
$content = user_settings(); $content = user_settings();
} elseif ($page == "login") { } elseif ($page == 'login') {
$title = login_title(); $title = login_title();
$content = guest_login(); $content = guest_login();
} elseif ($page == "register") { } elseif ($page == 'register') {
$title = register_title(); $title = register_title();
$content = guest_register(); $content = guest_register();
} elseif ($page == "logout") { } elseif ($page == 'logout') {
$title = logout_title(); $title = logout_title();
$content = guest_logout(); $content = guest_logout();
} elseif ($page == "admin_questions") { } elseif ($page == 'admin_questions') {
$title = admin_questions_title(); $title = admin_questions_title();
$content = admin_questions(); $content = admin_questions();
} elseif ($page == "admin_user") { } elseif ($page == 'admin_user') {
$title = admin_user_title(); $title = admin_user_title();
$content = admin_user(); $content = admin_user();
} elseif ($page == "admin_arrive") { } elseif ($page == 'admin_arrive') {
$title = admin_arrive_title(); $title = admin_arrive_title();
$content = admin_arrive(); $content = admin_arrive();
} elseif ($page == "admin_active") { } elseif ($page == 'admin_active') {
$title = admin_active_title(); $title = admin_active_title();
$content = admin_active(); $content = admin_active();
} elseif ($page == "admin_free") { } elseif ($page == 'admin_free') {
$title = admin_free_title(); $title = admin_free_title();
$content = admin_free(); $content = admin_free();
} elseif ($page == "admin_news") { } elseif ($page == 'admin_news') {
require_once realpath(__DIR__ . '/../includes/pages/admin_news.php'); require_once realpath(__DIR__ . '/../includes/pages/admin_news.php');
$content = admin_news(); $content = admin_news();
} elseif ($page == "admin_rooms") { } elseif ($page == 'admin_rooms') {
$title = admin_rooms_title(); $title = admin_rooms_title();
$content = admin_rooms(); $content = admin_rooms();
} elseif ($page == "admin_groups") { } elseif ($page == 'admin_groups') {
$title = admin_groups_title(); $title = admin_groups_title();
$content = admin_groups(); $content = admin_groups();
} elseif ($page == "admin_language") { } elseif ($page == 'admin_import') {
require_once realpath(__DIR__ . '/../includes/pages/admin_language.php');
$content = admin_language();
} elseif ($page == "admin_import") {
$title = admin_import_title(); $title = admin_import_title();
$content = admin_import(); $content = admin_import();
} elseif ($page == "admin_shifts") { } elseif ($page == 'admin_shifts') {
$title = admin_shifts_title(); $title = admin_shifts_title();
$content = admin_shifts(); $content = admin_shifts();
} elseif ($page == "admin_log") { } elseif ($page == 'admin_log') {
$title = admin_log_title(); $title = admin_log_title();
$content = admin_log(); $content = admin_log();
} elseif ($page == "credits") { } elseif ($page == 'credits') {
require_once realpath(__DIR__ . '/../includes/pages/guest_credits.php'); require_once realpath(__DIR__ . '/../includes/pages/guest_credits.php');
$title = credits_title(); $title = credits_title();
$content = guest_credits(); $content = guest_credits();
@ -159,11 +158,11 @@ if (
} else { } else {
// Wenn schon eingeloggt, keine-Berechtigung-Seite anzeigen // Wenn schon eingeloggt, keine-Berechtigung-Seite anzeigen
if (isset($user)) { if (isset($user)) {
$title = _("No Access"); $title = _('No Access');
$content = _("You don't have permission to view this page. You probably have to sign in or register in order to gain access!"); $content = _('You don\'t have permission to view this page . You probably have to sign in or register in order to gain access!');
} else { } else {
// Sonst zur Loginseite leiten // Sonst zur Loginseite leiten
redirect(page_link_to("login")); redirect(page_link_to('login'));
} }
} }
@ -172,12 +171,16 @@ $event_config = EventConfig();
echo template_render(__DIR__ . '/../templates/layout.html', [ echo template_render(__DIR__ . '/../templates/layout.html', [
'theme' => isset($user) ? $user['color'] : $default_theme, 'theme' => isset($user) ? $user['color'] : $default_theme,
'title' => $title, 'title' => $title,
'atom_link' => ($page == 'news' || $page == 'user_meetings') ? '<link href="' . page_link_to('atom') . (($page == 'user_meetings') ? '&amp;meetings=1' : '') . '&amp;key=' . $user['api_key'] . '" type="application/atom+xml" rel="alternate" title="Atom Feed">' : '', 'atom_link' => ($page == 'news' || $page == 'user_meetings')
? ' <link href="' . page_link_to('atom') . (($page == 'user_meetings') ? '&meetings=1' : '')
. '&amp;key=' . (isset($user) ? $user['api_key'] : '')
. '" type = "application/atom+xml" rel = "alternate" title = "Atom Feed">'
: '',
'menu' => make_menu(), 'menu' => make_menu(),
'content' => msg() . $content, 'content' => msg() . $content,
'header_toolbar' => header_toolbar(), 'header_toolbar' => header_toolbar(),
'faq_url' => $faq_url, 'faq_url' => $faq_url,
'contact_email' => $contact_email, 'contact_email' => $contact_email,
'locale' => locale(), 'locale' => locale(),
'event_info' => EventConfig_info($event_config) . '<br />' 'event_info' => EventConfig_info($event_config) . ' < br />'
]); ]);

@ -1,105 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"/>
<link rel="stylesheet" type="text/css" href="public/css/theme3.css"/>
<style>
</style>
</head>
<body>
<div class="shift-calendar">
<div class="lane time">
<div class="header">Time</div>
<div class="tick day">2016-12-27 00:00</div>
<div class="tick"></div>
<div class="tick"></div>
<div class="tick"></div>
<div class="tick hour">11:00</div>
<div class="tick"></div>
<div class="tick"></div>
<div class="tick"></div>
<div class="tick hour">12:00</div>
<div class="tick"></div>
<div class="tick"></div>
<div class="tick"></div>
<div class="tick hour">13:00</div>
<div class="tick"></div>
<div class="tick"></div>
<div class="tick"></div>
</div>
<div class="lane">
<div class="header">
<span class="glyphicon glyphicon-map-marker"></span> Bottle Sorting (Hall H)
</div>
<div class="tick day"></div>
<div class="tick"></div>
<div class="tick"></div>
<div class="tick"></div>
<div class="shift panel panel-success" style="height: 160px;">
<div class="panel-heading">
<a href="?p=shifts&amp;action=view&amp;shift_id=2696">00:00 02:00 — Bottle Collection</a>
<div class="pull-right">
<div class="btn-group">
<a href="?p=user_shifts&amp;edit_shift=2696" class="btn btn-default btn-xs">
<span class="glyphicon glyphicon-edit"></span>
</a>
<a href="?p=user_shifts&amp;delete_shift=2696" class="btn btn-default btn-xs">
<span class="glyphicon glyphicon-trash"></span>
</a>
</div>
</div>
</div>
<div class="panel-body">
<span class="glyphicon glyphicon-info-sign"></span> Bottle Collection Quick Response Team<br>
<a href="?p=rooms&amp;action=view&amp;room_id=42">
<span class="glyphicon glyphicon-map-marker"></span> Bottle Sorting (Hall H)
</a>
</div>
<ul class="list-group">
<li class="list-group-item"><strong><a href="?p=angeltypes&amp;action=view&amp;angeltype_id=104575">Angel</a>:</strong>
<span style="">
<a class="" href="?p=users&amp;action=view&amp;user_id=1755">
<span class="icon-icon_angel"></span> Pantomime
</a>
</span>,
<span style="">
<a class="" href="?p=users&amp;action=view&amp;user_id=50">
<span class="icon-icon_angel"></span> sandzwerg
</a>
</span>
</li>
<li class="list-group-item">
<a href="?p=user_shifts&amp;shift_id=2696&amp;type_id=104575" class="btn btn-default btn-xs">
Neue Engel hinzufügen
</a>
</li>
</ul>
<div class="shift-spacer"></div>
</div>
<div class="tick hour"></div>
<div class="tick"></div>
<div class="tick"></div>
<div class="tick"></div>
</div>
<div class="lane">
<div class="header"></div>
<div class="tick day"></div>
<div class="tick"></div>
<div class="tick"></div>
<div class="tick"></div>
<div class="tick hour"></div>
<div class="tick"></div>
<div class="tick"></div>
<div class="tick"></div>
<div class="tick hour"></div>
<div class="tick"></div>
<div class="tick"></div>
<div class="tick"></div>
<div class="tick hour"></div>
<div class="tick"></div>
<div class="tick"></div>
<div class="tick"></div>
</div>
</div>
</body>
</html>
Loading…
Cancel
Save