PPHDoc, formatting, fixes, cleanup

This commit is contained in:
Bot 2017-01-03 03:22:48 +01:00 committed by Igor Scheller
parent d71e7bbfad
commit 356b2582f3
79 changed files with 1836 additions and 649 deletions

View File

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

View File

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

View File

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

View File

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

View File

@ -2,11 +2,14 @@
/**
* Sign up for a shift.
*
* @return string
*/
function shift_entry_add_controller()
{
global $privileges, $user;
$shift_id = 0;
if (isset($_REQUEST['shift_id']) && preg_match("/^[0-9]*$/", $_REQUEST['shift_id'])) {
$shift_id = $_REQUEST['shift_id'];
} else {
@ -26,6 +29,7 @@ function shift_entry_add_controller()
redirect(page_link_to('user_shifts'));
}
$type_id = 0;
if (isset($_REQUEST['type_id']) && preg_match("/^[0-9]*$/", $_REQUEST['type_id'])) {
$type_id = $_REQUEST['type_id'];
} else {
@ -145,6 +149,7 @@ function shift_entry_add_controller()
redirect(shift_link($shift));
}
$angeltype_select = '';
if (in_array('user_shifts_admin', $privileges)) {
$users = sql_select("
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'];
}
return ShiftEntry_edit_view($user_text, 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));
return ShiftEntry_edit_view(
$user_text,
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 {
error(_("Entry not found."));
}
redirect(shift_link($shift_entry_source));
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -68,6 +68,7 @@ require_once realpath(__DIR__ . '/../includes/helper/email_helper.php');
require_once realpath(__DIR__ . '/../includes/mailer/shifts_mailer.php');
require_once realpath(__DIR__ . '/../includes/mailer/users_mailer.php');
$config = [];
require_once realpath(__DIR__ . '/../config/config.default.php');
if (file_exists(realpath(__DIR__ . '/../config/config.php'))) {
require_once realpath(__DIR__ . '/../config/config.php');

View File

@ -1,5 +1,12 @@
<?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)
{
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.");
gettext_locale();
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)
{
$result = mail($address, $title, $message,
"Content-Type: text/plain; charset=UTF-8\r\nFrom: Engelsystem <noreply@engelsystem.de>");
$result = mail(
$address,
$title,
$message,
"Content-Type: text/plain; charset=UTF-8\r\nFrom: Engelsystem <noreply@engelsystem.de>"
);
if ($result === false) {
engelsystem_error('Unable to send email.');
}
return true;
}

View File

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

View File

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

View File

@ -2,6 +2,8 @@
/**
* Gibt zwischengespeicherte Fehlermeldungen zurück und löscht den Zwischenspeicher
*
* @return string
*/
function msg()
{
@ -15,34 +17,51 @@ function msg()
/**
* Rendert eine Information
*
* @param string $msg
* @param bool $immediately
* @return string
*/
function info($msg, $immediatly = false)
function info($msg, $immediately = false)
{
return alert('info', $msg, $immediatly);
return alert('info', $msg, $immediately);
}
/**
* Rendert eine Fehlermeldung
*
* @param string $msg
* @param bool $immediately
* @return string
*/
function error($msg, $immediatly = false)
function error($msg, $immediately = false)
{
return alert('danger', $msg, $immediatly);
return alert('danger', $msg, $immediately);
}
/**
* Rendert eine Erfolgsmeldung
*
* @param string $msg
* @param bool $immediately
* @return string
*/
function success($msg, $immediatly = false)
function success($msg, $immediately = false)
{
return alert('success', $msg, $immediatly);
return alert('success', $msg, $immediately);
}
/**
* Renders an alert with given alert-* class.
*
* @param string $class
* @param string $msg
* @param bool $immediately
* @return string|null
*/
function alert($class, $msg, $immediatly = false)
function alert($class, $msg, $immediately = false)
{
if ($immediatly) {
if ($immediately) {
if ($msg == "") {
return "";
}
@ -53,4 +72,6 @@ function alert($class, $msg, $immediatly = false)
$_SESSION['msg'] = "";
}
$_SESSION['msg'] .= alert($class, $msg, true);
return null;
}

View File

@ -1,24 +1,28 @@
<?php
/**
* @param array $old_shift
* @param array $new_shift
*/
function mail_shift_change($old_shift, $new_shift)
{
$users = ShiftEntries_by_shift($old_shift["SID"]);
$old_room = Room($old_shift["RID"]);
$new_room = Room($new_shift["RID"]);
$noticable_changes = false;
$noticeable_changes = false;
$message = _("A Shift you are registered on has changed:");
$message .= "\n";
if ($old_shift["name"] != $new_shift["name"]) {
$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"]) {
$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"]) {
@ -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", $new_shift["start"])
) . "\n";
$noticable_changes = true;
$noticeable_changes = true;
}
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", $new_shift["end"])
) . "\n";
$noticable_changes = true;
$noticeable_changes = true;
}
if ($old_shift["RID"] != $new_shift["RID"]) {
$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
return;
}
@ -64,6 +68,9 @@ function mail_shift_change($old_shift, $new_shift)
}
}
/**
* @param array $shift
*/
function mail_shift_delete($shift)
{
$users = ShiftEntries_by_shift($shift["SID"]);
@ -83,9 +90,16 @@ function mail_shift_delete($shift)
}
}
/**
* @param array $user
* @param array $shift
*/
function mail_shift_assign($user, $shift)
{
if ($user["email_shiftinfo"]) {
if (!$user["email_shiftinfo"]) {
return;
}
$room = Room($shift["RID"]);
$message = _("You have been assigned to a Shift:") . "\n";
@ -95,12 +109,14 @@ function mail_shift_assign($user, $shift)
$message .= $room["Name"] . "\n";
engelsystem_email_to_user($user, '[engelsystem] ' . _("Assigned to Shift"), $message, true);
}
}
function mail_shift_removed($user, $shift)
{
if ($user["email_shiftinfo"]) {
if (!$user["email_shiftinfo"]) {
return;
}
$room = Room($shift["RID"]);
$message = _("You have been removed from a Shift:") . "\n";
@ -110,5 +126,4 @@ function mail_shift_removed($user, $shift)
$message .= $room["Name"] . "\n";
engelsystem_email_to_user($user, '[engelsystem] ' . _("Removed from Shift"), $message, true);
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,10 +1,16 @@
<?php
/**
* @return string
*/
function admin_import_title()
{
return _("Frab import");
}
/**
* @return string
*/
function admin_import()
{
global $rooms_import;
@ -290,6 +296,10 @@ function admin_import()
]);
}
/**
* @param string $file
* @return array
*/
function prepare_rooms($file)
{
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)
{
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)
{
global $xml_import;
@ -393,6 +414,11 @@ function read_xml($file)
return $xml_import;
}
/**
* @param array $shifts
* @param array $shifttypes
* @return array
*/
function shifts_printable($shifts, $shifttypes)
{
global $rooms_import;
@ -417,6 +443,11 @@ function shifts_printable($shifts, $shifttypes)
return $shifts_printable;
}
/**
* @param array $shift_a
* @param array $shift_b
* @return int
*/
function shift_sort($shift_a, $shift_b)
{
return ($shift_a['start'] < $shift_b['start']) ? -1 : 1;

View File

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

View File

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

View File

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

View File

@ -1,10 +1,16 @@
<?php
/**
* @return string
*/
function admin_rooms_title()
{
return _("Rooms");
}
/**
* @return string
*/
function admin_rooms()
{
$rooms_source = sql_select("SELECT * FROM `Room` ORDER BY `Name`");
@ -28,6 +34,7 @@ function admin_rooms()
$from_pentabarf = "";
$public = 'Y';
$number = "";
$room_id = 0;
$angeltypes_source = sql_select("SELECT * FROM `AngelTypes` ORDER BY `name`");
$angeltypes = [];
@ -99,7 +106,7 @@ function admin_rooms()
$angeltypes_count[$angeltype_id] = $_REQUEST['angeltype_count_' . $angeltype_id];
} else {
$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);
}
}

View File

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

View File

@ -1,13 +1,19 @@
<?php
/**
* @return string
*/
function admin_user_title()
{
return _("All Angels");
}
/**
* @return string
*/
function admin_user()
{
global $user, $privileges, $tshirt_sizes, $privileges;
global $user, $tshirt_sizes, $privileges;
$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`");
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>';
@ -167,6 +173,7 @@ function admin_user()
case 'save':
$force_active = $user['force_active'];
$user_source = User($user_id);
if (in_array('admin_active', $privileges)) {
$force_active = $_REQUEST['force_active'];
}
@ -178,7 +185,7 @@ function admin_user()
`Handy` = '" . sql_escape($_POST["eHandy"]) . "',
`Alter` = '" . sql_escape($_POST["eAlter"]) . "',
`DECT` = '" . sql_escape($_POST["eDECT"]) . "',
" . ($user_source['email_by_human_allowed'] ? "`email` = '" . sql_escape($_POST["eemail"]) . "'" : "") . "
" . ($user_source['email_by_human_allowed'] ? "`email` = '" . sql_escape($_POST["eemail"]) . "'," : "") . "
`jabber` = '" . sql_escape($_POST["ejabber"]) . "',
`Size` = '" . sql_escape($_POST["eSize"]) . "',
`Gekommen`= '" . sql_escape($_POST["eGekommen"]) . "',

View File

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

View File

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

View File

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

View File

@ -1,9 +1,11 @@
<?php
// publically available page to feed the news to feedreaders
/**
* Publically available page to feed the news to feedreaders
*/
function user_atom()
{
global $user, $DISPLAY_NEWS;
global $user, $display_news;
if (!isset($_REQUEST['key']) || !preg_match("/^[0-9a-f]{32}$/", $_REQUEST['key'])) {
engelsystem_error("Missing key.");
@ -18,7 +20,13 @@ function user_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);
@ -27,6 +35,10 @@ function user_atom()
raw_output($output);
}
/**
* @param array[] $news_entries
* @return string
*/
function make_atom_entries_from_news($news_entries)
{
$html = '<?xml version="1.0" encoding="utf-8"?>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,6 +1,9 @@
<?php
use Engelsystem\ShiftsFilter;
/**
* @return string
*/
function shifts_title()
{
return _("Shifts");
@ -12,6 +15,8 @@ function shifts_title()
* Transform into shift controller and shift entry controller.
* 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
*
* @return string
*/
function user_shifts()
{
@ -23,7 +28,8 @@ function user_shifts()
// Löschen einzelner Schicht-Einträge (Also Belegung einer Schicht von Engeln) durch Admins
if (isset($_REQUEST['entry_id'])) {
return shift_entry_delete_controller();
shift_entry_delete_controller();
return '';
} elseif (isset($_REQUEST['edit_shift'])) {
return shift_edit_controller();
} elseif (isset($_REQUEST['delete_shift'])) {
@ -38,8 +44,8 @@ function user_shifts()
* Helper function that updates the start and end time from request data.
* Use update_ShiftsFilter().
*
* @param ShiftsFilter $shiftsFilter
* The shiftfilter to update.
* @param ShiftsFilter $shiftsFilter The shiftfilter to update.
* @param string[] $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);
}
/**
* @return array
*/
function load_rooms()
{
$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."));
redirect('?');
}
return $rooms;
}
/**
* @return array
*/
function load_days()
{
$days = sql_select_single_col("
@ -103,6 +115,9 @@ function load_days()
return $days;
}
/**
* @return array|false
*/
function load_types()
{
global $user;
@ -136,10 +151,12 @@ function load_types()
return $types;
}
/**
* @return string
*/
function view_user_shifts()
{
global $user, $privileges;
global $ical_shifts;
global $user, $privileges, $ical_shifts;
$ical_shifts = [];
$days = load_days();
@ -197,9 +214,9 @@ function view_user_shifts()
'task_notice' =>
'<sup>1</sup>'
. _("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.")
. "</a>",
. '</a>',
'shifts_table' => msg() . $shiftCalendarRenderer->render(),
'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>)."),
@ -213,6 +230,10 @@ function view_user_shifts()
]);
}
/**
* @param array $array
* @return array
*/
function get_ids_from_array($array)
{
return $array["id"];
@ -227,9 +248,9 @@ function make_select($items, $selected, $name, $title = null)
foreach ($items as $i) {
$html_items[] = '<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"' : '')
. '> ' . $i['name'] . '</label>'
. ' > ' . $i['name'] . '</label>'
. (!isset($i['enabled']) || $i['enabled'] ? '' : glyph("lock"))
. '</div><br />';
}

View File

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

View File

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

View File

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

View File

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

View File

@ -8,14 +8,11 @@ use Engelsystem\ValidationResult;
/**
* Parse a date from da day and a time textfield.
*
* @param string $date_name
* 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[] $allowed_days
* List of allowed days in format Y-m-d
* @param int $default_value
* Default value unix timestamp
* @param string $date_name 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[] $allowed_days List of allowed days in format Y-m-d
* @param int $default_value Default value unix timestamp
* @return int|null
*/
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
*
* @param string $pattern
* The date pattern (i.e. Y-m-d H:i)
* @param string $value
* The string to parse
* @return The parsed unix timestamp
* @param string $pattern The date pattern (i.e. Y-m-d H:i)
* @param string $value The string to parse
* @return int|null The parsed unix timestamp
*/
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.
*
* @param string $url
*/
function redirect($url)
{
@ -62,8 +59,7 @@ function redirect($url)
/**
* Echoes given output and dies.
*
* @param String $output
* String to display
* @param String $output String to display
*/
function raw_output($output)
{
@ -74,12 +70,11 @@ function raw_output($output)
/**
* Helper function for transforming list of entities into array for select boxes.
*
* @param array $data
* The data array
* @param string $key_name
* name of the column to use as id/key
* @param string $value_name
* name of the column to use as displayed value
* @param array $data The data array
* @param string $key_name name of the column to use as id/key
* @param string $value_name name of the column to use as displayed value
*
* @return array
*/
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.
*
* @param String $name
* Name of the request param
* @param array <int> $default
* Default return value, if param is not set
* @param string $name Name of the request param
* @param array $default Default return value, if param is not set
* @return array
*/
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.
* If not parsable, given error message is put into msg() and null is returned.
*
* @param string $input
* String to be parsed into a date.
* @param string $error_message
* the error message displayed if $input is not parsable
* @param boolean $null_allowed
* is a null value allowed?
* @param string $name to be parsed into a date.
* @param string $error_message the error message displayed if $input is not parsable
* @param boolean $null_allowed is a null value allowed?
* @return ValidationResult containing the parsed date
*/
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.
* If not parsable, given error message is put into msg() and null is returned.
*
* @param string $input
* String to be parsed into a date.
* @param string $error_message
* the error message displayed if $input is not parsable
* @param boolean $null_allowed
* is a null value allowed?
* @param string $input String to be parsed into a date.
* @param string $error_message the error message displayed if $input is not parsable
* @param boolean $null_allowed is a null value allowed?
* @return ValidationResult containing the parsed date
*/
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.
*
* @param string $name
* @param string $default_value
* @return mixed|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.
* eine ID sein könnte.
*
* @param string $name
* @return int|false
*/
function test_request_int($name)
{
@ -176,6 +171,10 @@ function test_request_int($name)
/**
* 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)
{
@ -187,6 +186,9 @@ function strip_request_item_nl($name, $default_value = null)
/**
* Entfernt unerwünschte Zeichen
*
* @param string $item
* @return string
*/
function strip_item($item)
{
@ -195,6 +197,9 @@ function strip_item($item)
/**
* Überprüft eine E-Mail-Adresse.
*
* @param string $email
* @return bool
*/
function check_email($email)
{

View File

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

View File

@ -7,7 +7,8 @@
/**
* Renders the angeltypes name as link.
*
* @param AngelType $angeltype
* @param array $angeltype
* @return string
*/
function AngelType_name_render($angeltype)
{
@ -17,8 +18,7 @@ function AngelType_name_render($angeltype)
/**
* Render angeltype membership state
*
* @param UserAngelType $user_angeltype
* UserAngelType and AngelType
* @param array $user_angeltype UserAngelType and AngelType
* @return string
*/
function AngelType_render_membership($user_angeltype)
@ -39,6 +39,10 @@ function AngelType_render_membership($user_angeltype)
return glyph_bool(false);
}
/**
* @param array $angeltype
* @return string
*/
function AngelType_delete_view($angeltype)
{
return page_with_title(sprintf(_("Delete angeltype %s"), $angeltype['name']), [
@ -57,10 +61,9 @@ function AngelType_delete_view($angeltype)
/**
* Render angeltype edit form.
*
* @param Angeltype $angeltype
* The angeltype to edit
* @param boolean $supporter_mode
* Is the user a supporter of this angeltype?
* @param array $angeltype The angeltype to edit
* @param boolean $supporter_mode Is the user a supporter of this angeltype?
* @return string
*/
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.
*
* @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)
{
@ -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.
*
* @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)
{
@ -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.
*
* @param array $angeltype
* @param bool $supporter
* @param bool $admin_angeltypes
* @return array
*/
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.
*
* @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(
$angeltype,
@ -339,6 +369,8 @@ function AngelType_view(
* Display the list of angeltypes.
*
* @param array $angeltypes
* @param bool $admin_angeltypes
* @return string
*/
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.
*
* @param array $angeltype
* @return string
*/
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.
*
* @param array[] $angeltypes
* @param bool $user_logged_in
* @return string
*/
function AngelTypes_about_view($angeltypes, $user_logged_in)
{

View File

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

View File

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

View File

@ -2,6 +2,12 @@
use Engelsystem\ShiftCalendarRenderer;
use Engelsystem\ShiftsFilterRenderer;
/**
* @param array $room
* @param ShiftsFilterRenderer $shiftsFilterRenderer
* @param ShiftCalendarRenderer $shiftCalendarRenderer
* @return string
*/
function Room_view($room, ShiftsFilterRenderer $shiftsFilterRenderer, ShiftCalendarRenderer $shiftCalendarRenderer)
{
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)
{
global $privileges;

View File

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

View File

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

View File

@ -7,14 +7,14 @@ namespace Engelsystem;
*/
class ShiftCalendarShiftRenderer
{
/**
* Renders a shift
*
* @param Shift $shift
* The shift to render
* @param User $user
* The user who is viewing the shift calendar
* @param array $shift The shift to render
* @param array $needed_angeltypes
* @param array $shift_entries
* @param array $user The user who is viewing the shift calendar
* @return array
*/
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)
{
switch ($shiftSignupState->getState()) {
@ -72,9 +76,18 @@ class ShiftCalendarShiftRenderer
case ShiftSignupState::FREE:
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)
{
global $privileges;
@ -88,6 +101,7 @@ class ShiftCalendarShiftRenderer
}
$html = "";
/** @var ShiftSignupState $shift_signup_state */
$shift_signup_state = null;
foreach ($needed_angeltypes as $angeltype) {
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
*
* @param Shift $shift
* The shift which is rendered
* @param Angeltype $angeltype
* The angeltype, containing informations about needed angeltypes and already signed up angels
* @param User $user
* The user who is viewing the shift calendar
* @param array $shift The shift which is rendered
* @param array[] $shift_entries
* @param array[] $angeltype The angeltype, containing informations about needed angeltypes
* and already signed up angels
* @param array $user The user who is viewing the shift calendar
* @return array
*/
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()),
$shift_signup_state->getFreeEntries()
);
switch ($shift_signup_state->getState()) {
case ShiftSignupState::ADMIN:
case ShiftSignupState::FREE:
@ -207,8 +222,8 @@ class ShiftCalendarShiftRenderer
/**
* Renders the shift header
*
* @param Shift $shift
* The shift
* @param array $shift The shift
* @return string
*/
private function renderShiftHead($shift)
{

View File

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

View File

@ -1,5 +1,9 @@
<?php
/**
* @param array $shifttype
* @return string
*/
function ShiftType_name_render($shifttype)
{
global $privileges;
@ -9,6 +13,10 @@ function ShiftType_name_render($shifttype)
return $shifttype['name'];
}
/**
* @param array $shifttype
* @return string
*/
function ShiftType_delete_view($shifttype)
{
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)
{
$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)
{
$parsedown = new Parsedown();
@ -75,6 +96,10 @@ function ShiftType_view($shifttype, $angeltype)
]);
}
/**
* @param array[] $shifttypes
* @return string
*/
function ShiftTypes_list_view($shifttypes)
{
foreach ($shifttypes as &$shifttype) {

View File

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

View File

@ -1,6 +1,10 @@
<?php
use Engelsystem\ShiftSignupState;
/**
* @param array $shift
* @return string
*/
function Shift_editor_info_render($shift)
{
$info = [];
@ -21,6 +25,12 @@ function Shift_editor_info_render($shift)
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)
{
global $user;
@ -44,6 +54,14 @@ function Shift_signup_button_render($shift, $angeltype, $user_angeltype = null)
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)
{
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)
{
global $user;
@ -166,11 +191,17 @@ function Shift_view_render_needed_angeltype($needed_angeltype, $angeltypes, $shi
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)
{
$entry = User_Nick_render(User($shift_entry['UID']));
if ($shift_entry['freeloaded']) {
$entry = '<strike>' . $entry . '</strike>';
$entry = '<del>' . $entry . '</del>';
}
if ($user_shift_admin || $angeltype_supporter) {
$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.
*
* @param Shift $shift
* @param array $shift
* @return string
*/
function shift_length($shift)
{

View File

@ -1,5 +1,12 @@
<?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)
{
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)
{
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)
{
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)
{
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)
{
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)
{
$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)
{
return page_with_title(sprintf(_("Become a %s"), $angeltype['name']), [

View File

@ -3,12 +3,9 @@
/**
* Edit a user's driving license information.
*
* @param User $user_source
* The user
* @param bool $wants_to_drive
* true, if the user wants to drive
* @param UserDriverLicense $user_driver_license
* The user driver license
* @param array $user_source The user
* @param bool $wants_to_drive true, if the user wants to drive
* @param array $user_driver_license The user driver license
* @return string
*/
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">
$(function() {
if($("#wants_to_drive").is(":checked"))
var checkbox = $("#wants_to_drive");
if(checkbox.is(":checked"))
$("#driving_license").show();
else
$("#driving_license").hide();
$("#wants_to_drive").click(
function(e) {
checkbox.click(
function() {
if($("#wants_to_drive").is(":checked"))
$("#driving_license").show();
else

View File

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

View File

@ -22,12 +22,14 @@ $tshirt_sizes = [
/**
* Renders user settings page
*
* @param User $user_source
* The user
* @param array <String> $locales
* Available languages
* @param array <String> $themes
* Available themes
* @param array $user_source The user
* @param array $locales Available languages
* @param array $themes Available themes
* @param int $buildup_start_date Unix timestamp
* @param int $teardown_end_date Unix timestamp
* @param bool $enable_tshirt_size
* @param array $tshirt_sizes
* @return string
*/
function User_settings_view(
$user_source,
@ -52,7 +54,8 @@ function User_settings_view(
'planned_arrival_date',
_("Planned date of arrival") . ' ' . entry_required(),
$user_source['planned_arrival_date'],
$buildup_start_date, $teardown_end_date
$buildup_start_date,
$teardown_end_date
),
form_date(
'planned_departure_date',
@ -113,6 +116,9 @@ function User_settings_view(
/**
* 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)
{
@ -149,6 +155,9 @@ function User_registration_success_view($event_welcome_message)
/**
* Gui for deleting user with password field.
*
* @param array $user
* @return string
*/
function User_delete_view($user)
{
@ -170,6 +179,9 @@ function User_delete_view($user)
/**
* View for editing the number of given vouchers
*
* @param array $user
* @return string
*/
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(
$users,
$order_by,
@ -199,7 +222,6 @@ function Users_view(
foreach ($users as &$user) {
$user['Nick'] = User_Nick_render($user);
$user['Gekommen'] = glyph_bool($user['Gekommen']);
$user['got_voucher'] = $user['got_voucher'];
$user['Aktiv'] = glyph_bool($user['Aktiv']);
$user['force_active'] = glyph_bool($user['force_active']);
$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)
{
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)
{
$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>';
}
/**
* @param array $needed_angel_type
* @return string
*/
function User_view_shiftentries($needed_angel_type)
{
$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) {
$member = User_Nick_render($user_shift);
if ($user_shift['freeloaded']) {
$member = '<strike>' . $member . '</strike>';
$member = '<del>' . $member . '</del>';
}
$shift_entries[] = $member;
@ -292,10 +328,15 @@ function User_view_shiftentries($needed_angel_type)
/**
* 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)
{
global $LETZTES_AUSTRAGEN, $privileges;
global $last_unsubscribe, $privileges;
$shift_info = '<a href="' . shift_link($shift) . '">' . $shift['name'] . '</a>';
if ($shift['title']) {
@ -331,7 +372,7 @@ function User_view_myshift($shift, $user_source, $its_me)
'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(
page_link_to('user_myshifts') . ((!$its_me) ? '&id=' . $user_source['UID'] : '') . '&cancel=' . $shift['id'],
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
*
* @param array[] $shifts
* @param array $user_source
* @param bool $its_me
* @return array
*/
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
*
* @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)
{
@ -489,11 +544,14 @@ function User_view($user_source, $admin_user_privilege, $freeloader, $user_angel
page_link_to('user_shifts')
), true)
: ''
]);
]
);
}
/**
* View for password recovery step 1: E-Mail
*
* @return string
*/
function User_password_recovery_view()
{
@ -509,6 +567,8 @@ function User_password_recovery_view()
/**
* View for password recovery step 2: New password
*
* @return string
*/
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)
{
$output = [];
foreach ($user_angeltypes as $angeltype) {
$class = "";
if ($angeltype['restricted'] == 1) {
if ($angeltype['confirm_user_id'] != null) {
$class = 'text-success';
} else {
if ($angeltype['restricted'] == 1 && $angeltype['confirm_user_id'] == null) {
$class = 'text-warning';
}
} else {
$class = 'text-success';
}
$output[] = '<a href="' . angeltype_link($angeltype['id']) . '" class="' . $class . '">' . ($angeltype['supporter'] ? glyph('education') : '') . $angeltype['name'] . '</a>';
}
return join('<br />', $output);
}
/**
* @param array[] $user_groups
* @return string
*/
function User_groups_render($user_groups)
{
$output = [];
@ -554,14 +616,19 @@ function User_groups_render($user_groups)
/**
* Render a user nickname.
*
* @param User $user_source
* @param array $user_source
* @return string
*/
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()
{
global $user;
@ -573,6 +640,9 @@ function render_user_departure_date_hint()
return null;
}
/**
* @return string|null
*/
function render_user_freeloader_hint()
{
global $user, $max_freeloadable_shifts;
@ -587,7 +657,11 @@ function render_user_freeloader_hint()
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()
{
global $user;
@ -599,6 +673,9 @@ function render_user_arrived_hint()
return null;
}
/**
* @return string|null
*/
function render_user_tshirt_hint()
{
global $enable_tshirt_size, $user;
@ -610,6 +687,9 @@ function render_user_tshirt_hint()
return null;
}
/**
* @return string|null
*/
function render_user_dect_hint()
{
global $user;

View File

@ -20,135 +20,134 @@ $free_pages = [
];
// Gewünschte Seite/Funktion
$page = "";
$page = '';
$title = '';
$content = '';
if (!isset($_REQUEST['p'])) {
$_REQUEST['p'] = isset($user) ? "news" : "login";
$_REQUEST['p'] = isset($user) ? 'news' : 'login';
}
if (
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'], $privileges)
|| (isset($privileges) && in_array($_REQUEST['p'], $privileges))
)
) {
$page = $_REQUEST['p'];
$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');
error("Api disabled temporily.");
redirect(page_link_to('login'));
api_controller();
} elseif ($page == "ical") {
} elseif ($page == 'ical') {
require_once realpath(__DIR__ . '/../includes/pages/user_ical.php');
user_ical();
} elseif ($page == "atom") {
} elseif ($page == 'atom') {
require_once realpath(__DIR__ . '/../includes/pages/user_atom.php');
user_atom();
} elseif ($page == "shifts_json_export") {
} elseif ($page == 'shifts_json_export') {
require_once realpath(__DIR__ . '/../includes/controller/shifts_controller.php');
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');
shifts_json_export_all_controller();
} elseif ($page == "stats") {
} elseif ($page == 'stats') {
require_once realpath(__DIR__ . '/../includes/pages/guest_stats.php');
guest_stats();
} elseif ($page == "user_password_recovery") {
} elseif ($page == 'user_password_recovery') {
require_once realpath(__DIR__ . '/../includes/controller/users_controller.php');
$title = user_password_recovery_title();
$content = user_password_recovery_controller();
} elseif ($page == "angeltypes") {
} elseif ($page == 'angeltypes') {
list($title, $content) = angeltypes_controller();
} elseif ($page == "shifts") {
} elseif ($page == 'shifts') {
list($title, $content) = shifts_controller();
} elseif ($page == "users") {
} elseif ($page == 'users') {
list($title, $content) = users_controller();
} elseif ($page == "user_angeltypes") {
} elseif ($page == 'user_angeltypes') {
list($title, $content) = user_angeltypes_controller();
} elseif ($page == "user_driver_licenses") {
} elseif ($page == 'user_driver_licenses') {
list($title, $content) = user_driver_licenses_controller();
} elseif ($page == "shifttypes") {
} elseif ($page == 'shifttypes') {
list($title, $content) = shifttypes_controller();
} elseif ($page == "admin_event_config") {
} elseif ($page == 'admin_event_config') {
list($title, $content) = event_config_edit_controller();
} elseif ($page == "rooms") {
} elseif ($page == 'rooms') {
list($title, $content) = rooms_controller();
} elseif ($page == "news") {
} elseif ($page == 'news') {
$title = news_title();
$content = user_news();
} elseif ($page == "news_comments") {
} elseif ($page == 'news_comments') {
require_once realpath(__DIR__ . '/../includes/pages/user_news.php');
$title = user_news_comments_title();
$content = user_news_comments();
} elseif ($page == "user_meetings") {
} elseif ($page == 'user_meetings') {
$title = meetings_title();
$content = user_meetings();
} elseif ($page == "user_myshifts") {
} elseif ($page == 'user_myshifts') {
$title = myshifts_title();
$content = user_myshifts();
} elseif ($page == "user_shifts") {
} elseif ($page == 'user_shifts') {
$title = shifts_title();
$content = user_shifts();
} elseif ($page == "user_messages") {
} elseif ($page == 'user_messages') {
$title = messages_title();
$content = user_messages();
} elseif ($page == "user_questions") {
} elseif ($page == 'user_questions') {
$title = questions_title();
$content = user_questions();
} elseif ($page == "user_settings") {
} elseif ($page == 'user_settings') {
$title = settings_title();
$content = user_settings();
} elseif ($page == "login") {
} elseif ($page == 'login') {
$title = login_title();
$content = guest_login();
} elseif ($page == "register") {
} elseif ($page == 'register') {
$title = register_title();
$content = guest_register();
} elseif ($page == "logout") {
} elseif ($page == 'logout') {
$title = logout_title();
$content = guest_logout();
} elseif ($page == "admin_questions") {
} elseif ($page == 'admin_questions') {
$title = admin_questions_title();
$content = admin_questions();
} elseif ($page == "admin_user") {
} elseif ($page == 'admin_user') {
$title = admin_user_title();
$content = admin_user();
} elseif ($page == "admin_arrive") {
} elseif ($page == 'admin_arrive') {
$title = admin_arrive_title();
$content = admin_arrive();
} elseif ($page == "admin_active") {
} elseif ($page == 'admin_active') {
$title = admin_active_title();
$content = admin_active();
} elseif ($page == "admin_free") {
} elseif ($page == 'admin_free') {
$title = admin_free_title();
$content = admin_free();
} elseif ($page == "admin_news") {
} elseif ($page == 'admin_news') {
require_once realpath(__DIR__ . '/../includes/pages/admin_news.php');
$content = admin_news();
} elseif ($page == "admin_rooms") {
} elseif ($page == 'admin_rooms') {
$title = admin_rooms_title();
$content = admin_rooms();
} elseif ($page == "admin_groups") {
} elseif ($page == 'admin_groups') {
$title = admin_groups_title();
$content = admin_groups();
} elseif ($page == "admin_language") {
require_once realpath(__DIR__ . '/../includes/pages/admin_language.php');
$content = admin_language();
} elseif ($page == "admin_import") {
} elseif ($page == 'admin_import') {
$title = admin_import_title();
$content = admin_import();
} elseif ($page == "admin_shifts") {
} elseif ($page == 'admin_shifts') {
$title = admin_shifts_title();
$content = admin_shifts();
} elseif ($page == "admin_log") {
} elseif ($page == 'admin_log') {
$title = admin_log_title();
$content = admin_log();
} elseif ($page == "credits") {
} elseif ($page == 'credits') {
require_once realpath(__DIR__ . '/../includes/pages/guest_credits.php');
$title = credits_title();
$content = guest_credits();
@ -159,11 +158,11 @@ if (
} else {
// Wenn schon eingeloggt, keine-Berechtigung-Seite anzeigen
if (isset($user)) {
$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!");
$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!');
} else {
// 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', [
'theme' => isset($user) ? $user['color'] : $default_theme,
'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(),
'content' => msg() . $content,
'header_toolbar' => header_toolbar(),
'faq_url' => $faq_url,
'contact_email' => $contact_email,
'locale' => locale(),
'event_info' => EventConfig_info($event_config) . '<br />'
'event_info' => EventConfig_info($event_config) . ' < br />'
]);

View File

@ -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>