PSR-2 formatting
This commit is contained in:
parent
b839e40106
commit
7313e15ce8
|
@ -66,4 +66,3 @@ $config = [
|
||||||
'pw' => "",
|
'pw' => "",
|
||||||
'db' => "engelsystem"
|
'db' => "engelsystem"
|
||||||
];
|
];
|
||||||
?>
|
|
||||||
|
|
|
@ -3,14 +3,16 @@
|
||||||
/**
|
/**
|
||||||
* Text for Angeltype related links.
|
* Text for Angeltype related links.
|
||||||
*/
|
*/
|
||||||
function angeltypes_title() {
|
function angeltypes_title()
|
||||||
|
{
|
||||||
return _("Angeltypes");
|
return _("Angeltypes");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Route angeltype actions.
|
* Route angeltype actions.
|
||||||
*/
|
*/
|
||||||
function angeltypes_controller() {
|
function angeltypes_controller()
|
||||||
|
{
|
||||||
$action = strip_request_item('action', 'list');
|
$action = strip_request_item('action', 'list');
|
||||||
|
|
||||||
switch ($action) {
|
switch ($action) {
|
||||||
|
@ -33,14 +35,16 @@ function angeltypes_controller() {
|
||||||
*
|
*
|
||||||
* @param AngelType $angeltype_id
|
* @param AngelType $angeltype_id
|
||||||
*/
|
*/
|
||||||
function angeltype_link($angeltype_id) {
|
function angeltype_link($angeltype_id)
|
||||||
|
{
|
||||||
return page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype_id;
|
return page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Job description for all angeltypes (public to everyone)
|
* Job description for all angeltypes (public to everyone)
|
||||||
*/
|
*/
|
||||||
function angeltypes_about_controller() {
|
function angeltypes_about_controller()
|
||||||
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
if (isset($user)) {
|
if (isset($user)) {
|
||||||
|
@ -58,7 +62,8 @@ function angeltypes_about_controller() {
|
||||||
/**
|
/**
|
||||||
* Delete an Angeltype.
|
* Delete an Angeltype.
|
||||||
*/
|
*/
|
||||||
function angeltype_delete_controller() {
|
function angeltype_delete_controller()
|
||||||
|
{
|
||||||
global $privileges;
|
global $privileges;
|
||||||
|
|
||||||
if (! in_array('admin_angel_types', $privileges)) {
|
if (! in_array('admin_angel_types', $privileges)) {
|
||||||
|
@ -82,7 +87,8 @@ function angeltype_delete_controller() {
|
||||||
/**
|
/**
|
||||||
* Change an Angeltype.
|
* Change an Angeltype.
|
||||||
*/
|
*/
|
||||||
function angeltype_edit_controller() {
|
function angeltype_edit_controller()
|
||||||
|
{
|
||||||
global $privileges, $user;
|
global $privileges, $user;
|
||||||
|
|
||||||
// In supporter mode only allow to modify description
|
// In supporter mode only allow to modify description
|
||||||
|
@ -146,7 +152,8 @@ function angeltype_edit_controller() {
|
||||||
/**
|
/**
|
||||||
* View details of a given angeltype.
|
* View details of a given angeltype.
|
||||||
*/
|
*/
|
||||||
function angeltype_controller() {
|
function angeltype_controller()
|
||||||
|
{
|
||||||
global $privileges, $user;
|
global $privileges, $user;
|
||||||
|
|
||||||
if (! in_array('angeltypes', $privileges)) {
|
if (! in_array('angeltypes', $privileges)) {
|
||||||
|
@ -167,7 +174,8 @@ function angeltype_controller() {
|
||||||
/**
|
/**
|
||||||
* View a list of all angeltypes.
|
* View a list of all angeltypes.
|
||||||
*/
|
*/
|
||||||
function angeltypes_list_controller() {
|
function angeltypes_list_controller()
|
||||||
|
{
|
||||||
global $privileges, $user;
|
global $privileges, $user;
|
||||||
|
|
||||||
if (! in_array('angeltypes', $privileges)) {
|
if (! in_array('angeltypes', $privileges)) {
|
||||||
|
@ -210,7 +218,8 @@ function angeltypes_list_controller() {
|
||||||
/**
|
/**
|
||||||
* Loads an angeltype from given angeltype_id request param.
|
* Loads an angeltype from given angeltype_id request param.
|
||||||
*/
|
*/
|
||||||
function load_angeltype() {
|
function load_angeltype()
|
||||||
|
{
|
||||||
if (! isset($_REQUEST['angeltype_id'])) {
|
if (! isset($_REQUEST['angeltype_id'])) {
|
||||||
redirect(page_link_to('angeltypes'));
|
redirect(page_link_to('angeltypes'));
|
||||||
}
|
}
|
||||||
|
@ -223,4 +232,3 @@ function load_angeltype() {
|
||||||
|
|
||||||
return $angeltype;
|
return $angeltype;
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
function event_config_title() {
|
function event_config_title()
|
||||||
|
{
|
||||||
return _("Event config");
|
return _("Event config");
|
||||||
}
|
}
|
||||||
|
|
||||||
function event_config_edit_controller() {
|
function event_config_edit_controller()
|
||||||
|
{
|
||||||
global $privileges;
|
global $privileges;
|
||||||
|
|
||||||
if (! in_array('admin_event_config', $privileges)) {
|
if (! in_array('admin_event_config', $privileges)) {
|
||||||
|
@ -99,5 +101,3 @@ function event_config_edit_controller() {
|
||||||
EventConfig_edit_view($event_name, $event_welcome_msg, $buildup_start_date, $event_start_date, $event_end_date, $teardown_end_date)
|
EventConfig_edit_view($event_name, $event_welcome_msg, $buildup_start_date, $event_start_date, $event_end_date, $teardown_end_date)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
|
@ -10,7 +10,8 @@ use Engelsystem\ShiftCalendarRenderer;
|
||||||
/**
|
/**
|
||||||
* View a room with its shifts.
|
* View a room with its shifts.
|
||||||
*/
|
*/
|
||||||
function room_controller() {
|
function room_controller()
|
||||||
|
{
|
||||||
global $privileges;
|
global $privileges;
|
||||||
|
|
||||||
if (! in_array('view_rooms', $privileges)) {
|
if (! in_array('view_rooms', $privileges)) {
|
||||||
|
@ -54,7 +55,8 @@ function room_controller() {
|
||||||
/**
|
/**
|
||||||
* Dispatch different room actions.
|
* Dispatch different room actions.
|
||||||
*/
|
*/
|
||||||
function rooms_controller() {
|
function rooms_controller()
|
||||||
|
{
|
||||||
if (! isset($_REQUEST['action'])) {
|
if (! isset($_REQUEST['action'])) {
|
||||||
$_REQUEST['action'] = 'list';
|
$_REQUEST['action'] = 'list';
|
||||||
}
|
}
|
||||||
|
@ -68,18 +70,21 @@ function rooms_controller() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function room_link($room) {
|
function room_link($room)
|
||||||
|
{
|
||||||
return page_link_to('rooms') . '&action=view&room_id=' . $room['RID'];
|
return page_link_to('rooms') . '&action=view&room_id=' . $room['RID'];
|
||||||
}
|
}
|
||||||
|
|
||||||
function room_edit_link($room) {
|
function room_edit_link($room)
|
||||||
|
{
|
||||||
return page_link_to('admin_rooms') . '&show=edit&id=' . $room['RID'];
|
return page_link_to('admin_rooms') . '&show=edit&id=' . $room['RID'];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads room by request param room_id
|
* Loads room by request param room_id
|
||||||
*/
|
*/
|
||||||
function load_room() {
|
function load_room()
|
||||||
|
{
|
||||||
if (! test_request_int('room_id')) {
|
if (! test_request_int('room_id')) {
|
||||||
redirect(page_link_to());
|
redirect(page_link_to());
|
||||||
}
|
}
|
||||||
|
@ -91,5 +96,3 @@ function load_room() {
|
||||||
|
|
||||||
return $room;
|
return $room;
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
|
@ -3,7 +3,8 @@
|
||||||
/**
|
/**
|
||||||
* Sign up for a shift.
|
* Sign up for a shift.
|
||||||
*/
|
*/
|
||||||
function shift_entry_add_controller() {
|
function shift_entry_add_controller()
|
||||||
|
{
|
||||||
global $privileges, $user;
|
global $privileges, $user;
|
||||||
|
|
||||||
if (isset($_REQUEST['shift_id']) && preg_match("/^[0-9]*$/", $_REQUEST['shift_id'])) {
|
if (isset($_REQUEST['shift_id']) && preg_match("/^[0-9]*$/", $_REQUEST['shift_id'])) {
|
||||||
|
@ -60,7 +61,6 @@ function shift_entry_add_controller() {
|
||||||
if (isset($_REQUEST['submit'])) {
|
if (isset($_REQUEST['submit'])) {
|
||||||
$selected_type_id = $type_id;
|
$selected_type_id = $type_id;
|
||||||
if (in_array('user_shifts_admin', $privileges) || in_array('shiftentry_edit_angeltype_supporter', $privileges)) {
|
if (in_array('user_shifts_admin', $privileges) || in_array('shiftentry_edit_angeltype_supporter', $privileges)) {
|
||||||
|
|
||||||
if (sql_num_query("SELECT * FROM `User` WHERE `UID`='" . sql_escape($user_id) . "' LIMIT 1") == 0) {
|
if (sql_num_query("SELECT * FROM `User` WHERE `UID`='" . sql_escape($user_id) . "' LIMIT 1") == 0) {
|
||||||
redirect(page_link_to('user_shifts'));
|
redirect(page_link_to('user_shifts'));
|
||||||
}
|
}
|
||||||
|
@ -147,7 +147,8 @@ function shift_entry_add_controller() {
|
||||||
/**
|
/**
|
||||||
* Remove somebody from a shift.
|
* Remove somebody from a shift.
|
||||||
*/
|
*/
|
||||||
function shift_entry_delete_controller() {
|
function shift_entry_delete_controller()
|
||||||
|
{
|
||||||
global $privileges, $user;
|
global $privileges, $user;
|
||||||
|
|
||||||
if (! isset($_REQUEST['entry_id']) || ! test_request_int('entry_id')) {
|
if (! isset($_REQUEST['entry_id']) || ! test_request_int('entry_id')) {
|
||||||
|
@ -183,5 +184,3 @@ function shift_entry_delete_controller() {
|
||||||
}
|
}
|
||||||
redirect(shift_link($shift_entry_source));
|
redirect(shift_link($shift_entry_source));
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
|
@ -1,22 +1,26 @@
|
||||||
<?php
|
<?php
|
||||||
use Engelsystem\ShiftSignupState;
|
use Engelsystem\ShiftSignupState;
|
||||||
|
|
||||||
function shift_link($shift) {
|
function shift_link($shift)
|
||||||
|
{
|
||||||
return page_link_to('shifts') . '&action=view&shift_id=' . $shift['SID'];
|
return page_link_to('shifts') . '&action=view&shift_id=' . $shift['SID'];
|
||||||
}
|
}
|
||||||
|
|
||||||
function shift_delete_link($shift) {
|
function shift_delete_link($shift)
|
||||||
|
{
|
||||||
return page_link_to('user_shifts') . '&delete_shift=' . $shift['SID'];
|
return page_link_to('user_shifts') . '&delete_shift=' . $shift['SID'];
|
||||||
}
|
}
|
||||||
|
|
||||||
function shift_edit_link($shift) {
|
function shift_edit_link($shift)
|
||||||
|
{
|
||||||
return page_link_to('user_shifts') . '&edit_shift=' . $shift['SID'];
|
return page_link_to('user_shifts') . '&edit_shift=' . $shift['SID'];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Edit a single shift.
|
* Edit a single shift.
|
||||||
*/
|
*/
|
||||||
function shift_edit_controller() {
|
function shift_edit_controller()
|
||||||
|
{
|
||||||
global $privileges;
|
global $privileges;
|
||||||
|
|
||||||
// Schicht bearbeiten
|
// Schicht bearbeiten
|
||||||
|
@ -146,7 +150,8 @@ function shift_edit_controller() {
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function shift_delete_controller() {
|
function shift_delete_controller()
|
||||||
|
{
|
||||||
global $privileges;
|
global $privileges;
|
||||||
|
|
||||||
if (! in_array('user_shifts_admin', $privileges)) {
|
if (! in_array('user_shifts_admin', $privileges)) {
|
||||||
|
@ -179,7 +184,8 @@ function shift_delete_controller() {
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function shift_controller() {
|
function shift_controller()
|
||||||
|
{
|
||||||
global $user, $privileges;
|
global $user, $privileges;
|
||||||
|
|
||||||
if (! in_array('user_shifts', $privileges)) {
|
if (! in_array('user_shifts', $privileges)) {
|
||||||
|
@ -221,7 +227,8 @@ function shift_controller() {
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
function shifts_controller() {
|
function shifts_controller()
|
||||||
|
{
|
||||||
if (! isset($_REQUEST['action'])) {
|
if (! isset($_REQUEST['action'])) {
|
||||||
redirect(page_link_to('user_shifts'));
|
redirect(page_link_to('user_shifts'));
|
||||||
}
|
}
|
||||||
|
@ -239,7 +246,8 @@ function shifts_controller() {
|
||||||
/**
|
/**
|
||||||
* Redirects the user to his next shift.
|
* Redirects the user to his next shift.
|
||||||
*/
|
*/
|
||||||
function shift_next_controller() {
|
function shift_next_controller()
|
||||||
|
{
|
||||||
global $user, $privileges;
|
global $user, $privileges;
|
||||||
|
|
||||||
if (! in_array('user_shifts', $privileges)) {
|
if (! in_array('user_shifts', $privileges)) {
|
||||||
|
@ -261,7 +269,8 @@ function shift_next_controller() {
|
||||||
/**
|
/**
|
||||||
* Export all shifts using api-key.
|
* Export all shifts using api-key.
|
||||||
*/
|
*/
|
||||||
function shifts_json_export_all_controller() {
|
function shifts_json_export_all_controller()
|
||||||
|
{
|
||||||
global $api_key;
|
global $api_key;
|
||||||
|
|
||||||
if ($api_key == "") {
|
if ($api_key == "") {
|
||||||
|
@ -289,7 +298,8 @@ function shifts_json_export_all_controller() {
|
||||||
* Export filtered shifts via JSON.
|
* Export filtered shifts via JSON.
|
||||||
* (Like iCal Export or shifts view)
|
* (Like iCal Export or shifts view)
|
||||||
*/
|
*/
|
||||||
function shifts_json_export_controller() {
|
function shifts_json_export_controller()
|
||||||
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
if (! isset($_REQUEST['key']) || ! preg_match("/^[0-9a-f]{32}$/", $_REQUEST['key'])) {
|
if (! isset($_REQUEST['key']) || ! preg_match("/^[0-9a-f]{32}$/", $_REQUEST['key'])) {
|
||||||
|
@ -315,10 +325,9 @@ function shifts_json_export_controller() {
|
||||||
/**
|
/**
|
||||||
* Returns users shifts to export.
|
* Returns users shifts to export.
|
||||||
*/
|
*/
|
||||||
function load_ical_shifts() {
|
function load_ical_shifts()
|
||||||
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
return Shifts_by_user($user);
|
return Shifts_by_user($user);
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
|
@ -1,13 +1,15 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
function shifttype_link($shifttype) {
|
function shifttype_link($shifttype)
|
||||||
|
{
|
||||||
return page_link_to('shifttypes') . '&action=view&shifttype_id=' . $shifttype['id'];
|
return page_link_to('shifttypes') . '&action=view&shifttype_id=' . $shifttype['id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a shifttype.
|
* Delete a shifttype.
|
||||||
*/
|
*/
|
||||||
function shifttype_delete_controller() {
|
function shifttype_delete_controller()
|
||||||
|
{
|
||||||
if (! isset($_REQUEST['shifttype_id'])) {
|
if (! isset($_REQUEST['shifttype_id'])) {
|
||||||
redirect(page_link_to('shifttypes'));
|
redirect(page_link_to('shifttypes'));
|
||||||
}
|
}
|
||||||
|
@ -41,7 +43,8 @@ function shifttype_delete_controller() {
|
||||||
/**
|
/**
|
||||||
* Edit or create shift type.
|
* Edit or create shift type.
|
||||||
*/
|
*/
|
||||||
function shifttype_edit_controller() {
|
function shifttype_edit_controller()
|
||||||
|
{
|
||||||
$shifttype_id = null;
|
$shifttype_id = null;
|
||||||
$name = "";
|
$name = "";
|
||||||
$angeltype_id = null;
|
$angeltype_id = null;
|
||||||
|
@ -110,7 +113,8 @@ function shifttype_edit_controller() {
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
function shifttype_controller() {
|
function shifttype_controller()
|
||||||
|
{
|
||||||
if (! isset($_REQUEST['shifttype_id'])) {
|
if (! isset($_REQUEST['shifttype_id'])) {
|
||||||
redirect(page_link_to('shifttypes'));
|
redirect(page_link_to('shifttypes'));
|
||||||
}
|
}
|
||||||
|
@ -136,7 +140,8 @@ function shifttype_controller() {
|
||||||
/**
|
/**
|
||||||
* List all shift types.
|
* List all shift types.
|
||||||
*/
|
*/
|
||||||
function shifttypes_list_controller() {
|
function shifttypes_list_controller()
|
||||||
|
{
|
||||||
$shifttypes = ShiftTypes();
|
$shifttypes = ShiftTypes();
|
||||||
if ($shifttypes === false) {
|
if ($shifttypes === false) {
|
||||||
engelsystem_error("Unable to load shifttypes.");
|
engelsystem_error("Unable to load shifttypes.");
|
||||||
|
@ -151,14 +156,16 @@ function shifttypes_list_controller() {
|
||||||
/**
|
/**
|
||||||
* Text for shift type related links.
|
* Text for shift type related links.
|
||||||
*/
|
*/
|
||||||
function shifttypes_title() {
|
function shifttypes_title()
|
||||||
|
{
|
||||||
return _("Shifttypes");
|
return _("Shifttypes");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Route shift type actions
|
* Route shift type actions
|
||||||
*/
|
*/
|
||||||
function shifttypes_controller() {
|
function shifttypes_controller()
|
||||||
|
{
|
||||||
if (! isset($_REQUEST['action'])) {
|
if (! isset($_REQUEST['action'])) {
|
||||||
$_REQUEST['action'] = 'list';
|
$_REQUEST['action'] = 'list';
|
||||||
}
|
}
|
||||||
|
@ -175,5 +182,3 @@ function shifttypes_controller() {
|
||||||
return shifttype_delete_controller();
|
return shifttype_delete_controller();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
|
@ -3,7 +3,8 @@
|
||||||
/**
|
/**
|
||||||
* Display a hint for team/angeltype supporters if there are unconfirmed users for his angeltype.
|
* Display a hint for team/angeltype supporters if there are unconfirmed users for his angeltype.
|
||||||
*/
|
*/
|
||||||
function user_angeltypes_unconfirmed_hint() {
|
function user_angeltypes_unconfirmed_hint()
|
||||||
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
$unconfirmed_user_angeltypes = User_unconfirmed_AngelTypes($user);
|
$unconfirmed_user_angeltypes = User_unconfirmed_AngelTypes($user);
|
||||||
|
@ -22,7 +23,8 @@ function user_angeltypes_unconfirmed_hint() {
|
||||||
/**
|
/**
|
||||||
* Remove all unconfirmed users from a specific angeltype.
|
* Remove all unconfirmed users from a specific angeltype.
|
||||||
*/
|
*/
|
||||||
function user_angeltypes_delete_all_controller() {
|
function user_angeltypes_delete_all_controller()
|
||||||
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
if (! isset($_REQUEST['angeltype_id'])) {
|
if (! isset($_REQUEST['angeltype_id'])) {
|
||||||
|
@ -58,7 +60,8 @@ function user_angeltypes_delete_all_controller() {
|
||||||
/**
|
/**
|
||||||
* Confirm all unconfirmed users for an angeltype.
|
* Confirm all unconfirmed users for an angeltype.
|
||||||
*/
|
*/
|
||||||
function user_angeltypes_confirm_all_controller() {
|
function user_angeltypes_confirm_all_controller()
|
||||||
|
{
|
||||||
global $user, $privileges;
|
global $user, $privileges;
|
||||||
|
|
||||||
if (! isset($_REQUEST['angeltype_id'])) {
|
if (! isset($_REQUEST['angeltype_id'])) {
|
||||||
|
@ -100,7 +103,8 @@ function user_angeltypes_confirm_all_controller() {
|
||||||
/**
|
/**
|
||||||
* Confirm an user for an angeltype.
|
* Confirm an user for an angeltype.
|
||||||
*/
|
*/
|
||||||
function user_angeltype_confirm_controller() {
|
function user_angeltype_confirm_controller()
|
||||||
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
if (! isset($_REQUEST['user_angeltype_id'])) {
|
if (! isset($_REQUEST['user_angeltype_id'])) {
|
||||||
|
@ -151,7 +155,8 @@ function user_angeltype_confirm_controller() {
|
||||||
/**
|
/**
|
||||||
* Remove a user from an Angeltype.
|
* Remove a user from an Angeltype.
|
||||||
*/
|
*/
|
||||||
function user_angeltype_delete_controller() {
|
function user_angeltype_delete_controller()
|
||||||
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
if (! isset($_REQUEST['user_angeltype_id'])) {
|
if (! isset($_REQUEST['user_angeltype_id'])) {
|
||||||
|
@ -204,7 +209,8 @@ function user_angeltype_delete_controller() {
|
||||||
/**
|
/**
|
||||||
* Update an UserAngelType.
|
* Update an UserAngelType.
|
||||||
*/
|
*/
|
||||||
function user_angeltype_update_controller() {
|
function user_angeltype_update_controller()
|
||||||
|
{
|
||||||
global $privileges;
|
global $privileges;
|
||||||
|
|
||||||
if (! in_array('admin_angel_types', $privileges)) {
|
if (! in_array('admin_angel_types', $privileges)) {
|
||||||
|
@ -261,7 +267,8 @@ function user_angeltype_update_controller() {
|
||||||
/**
|
/**
|
||||||
* User joining an Angeltype (Or supporter doing this for him).
|
* User joining an Angeltype (Or supporter doing this for him).
|
||||||
*/
|
*/
|
||||||
function user_angeltype_add_controller() {
|
function user_angeltype_add_controller()
|
||||||
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
$angeltype = load_angeltype();
|
$angeltype = load_angeltype();
|
||||||
|
@ -304,7 +311,8 @@ function user_angeltype_add_controller() {
|
||||||
/**
|
/**
|
||||||
* A user joins an angeltype.
|
* A user joins an angeltype.
|
||||||
*/
|
*/
|
||||||
function user_angeltype_join_controller($angeltype) {
|
function user_angeltype_join_controller($angeltype)
|
||||||
|
{
|
||||||
global $user, $privileges;
|
global $user, $privileges;
|
||||||
|
|
||||||
$user_angeltype = UserAngelType_by_User_and_AngelType($user, $angeltype);
|
$user_angeltype = UserAngelType_by_User_and_AngelType($user, $angeltype);
|
||||||
|
@ -337,7 +345,8 @@ function user_angeltype_join_controller($angeltype) {
|
||||||
/**
|
/**
|
||||||
* Route UserAngelType actions.
|
* Route UserAngelType actions.
|
||||||
*/
|
*/
|
||||||
function user_angeltypes_controller() {
|
function user_angeltypes_controller()
|
||||||
|
{
|
||||||
if (! isset($_REQUEST['action'])) {
|
if (! isset($_REQUEST['action'])) {
|
||||||
redirect(page_link_to('angeltypes'));
|
redirect(page_link_to('angeltypes'));
|
||||||
}
|
}
|
||||||
|
@ -359,5 +368,3 @@ function user_angeltypes_controller() {
|
||||||
redirect(page_link_to('angeltypes'));
|
redirect(page_link_to('angeltypes'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
|
@ -3,7 +3,8 @@
|
||||||
/**
|
/**
|
||||||
* Generates a hint, if user joined angeltypes that require a driving license and the user has no driver license information provided.
|
* Generates a hint, if user joined angeltypes that require a driving license and the user has no driver license information provided.
|
||||||
*/
|
*/
|
||||||
function user_driver_license_required_hint() {
|
function user_driver_license_required_hint()
|
||||||
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
$angeltypes = User_angeltypes($user);
|
$angeltypes = User_angeltypes($user);
|
||||||
|
@ -26,7 +27,8 @@ function user_driver_license_required_hint() {
|
||||||
/**
|
/**
|
||||||
* Route user driver licenses actions.
|
* Route user driver licenses actions.
|
||||||
*/
|
*/
|
||||||
function user_driver_licenses_controller() {
|
function user_driver_licenses_controller()
|
||||||
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
if (! isset($user)) {
|
if (! isset($user)) {
|
||||||
|
@ -47,7 +49,8 @@ function user_driver_licenses_controller() {
|
||||||
*
|
*
|
||||||
* @param User $user
|
* @param User $user
|
||||||
*/
|
*/
|
||||||
function user_driver_license_edit_link($user = null) {
|
function user_driver_license_edit_link($user = null)
|
||||||
|
{
|
||||||
if ($user == null) {
|
if ($user == null) {
|
||||||
return page_link_to('user_driver_licenses');
|
return page_link_to('user_driver_licenses');
|
||||||
}
|
}
|
||||||
|
@ -57,7 +60,8 @@ function user_driver_license_edit_link($user = null) {
|
||||||
/**
|
/**
|
||||||
* Loads the user for the driver license.
|
* Loads the user for the driver license.
|
||||||
*/
|
*/
|
||||||
function user_driver_license_load_user() {
|
function user_driver_license_load_user()
|
||||||
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
$user_source = $user;
|
$user_source = $user;
|
||||||
|
@ -75,7 +79,8 @@ function user_driver_license_load_user() {
|
||||||
/**
|
/**
|
||||||
* Edit a users driver license information.
|
* Edit a users driver license information.
|
||||||
*/
|
*/
|
||||||
function user_driver_license_edit_controller() {
|
function user_driver_license_edit_controller()
|
||||||
|
{
|
||||||
global $privileges, $user;
|
global $privileges, $user;
|
||||||
|
|
||||||
$user_source = user_driver_license_load_user();
|
$user_source = user_driver_license_load_user();
|
||||||
|
@ -128,5 +133,3 @@ function user_driver_license_edit_controller() {
|
||||||
UserDriverLicense_edit_view($user_source, $wants_to_drive, $user_driver_license)
|
UserDriverLicense_edit_view($user_source, $wants_to_drive, $user_driver_license)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
|
@ -5,7 +5,8 @@ use Engelsystem\ShiftCalendarRenderer;
|
||||||
/**
|
/**
|
||||||
* Route user actions.
|
* Route user actions.
|
||||||
*/
|
*/
|
||||||
function users_controller() {
|
function users_controller()
|
||||||
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
if (! isset($user)) {
|
if (! isset($user)) {
|
||||||
|
@ -34,7 +35,8 @@ function users_controller() {
|
||||||
/**
|
/**
|
||||||
* Delete a user, requires to enter own password for reasons.
|
* Delete a user, requires to enter own password for reasons.
|
||||||
*/
|
*/
|
||||||
function user_delete_controller() {
|
function user_delete_controller()
|
||||||
|
{
|
||||||
global $privileges, $user;
|
global $privileges, $user;
|
||||||
|
|
||||||
if (isset($_REQUEST['user_id'])) {
|
if (isset($_REQUEST['user_id'])) {
|
||||||
|
@ -81,23 +83,28 @@ function user_delete_controller() {
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
function users_link() {
|
function users_link()
|
||||||
|
{
|
||||||
return page_link_to('users');
|
return page_link_to('users');
|
||||||
}
|
}
|
||||||
|
|
||||||
function user_edit_link($user) {
|
function user_edit_link($user)
|
||||||
|
{
|
||||||
return page_link_to('admin_user') . '&user_id=' . $user['UID'];
|
return page_link_to('admin_user') . '&user_id=' . $user['UID'];
|
||||||
}
|
}
|
||||||
|
|
||||||
function user_delete_link($user) {
|
function user_delete_link($user)
|
||||||
|
{
|
||||||
return page_link_to('users') . '&action=delete&user_id=' . $user['UID'];
|
return page_link_to('users') . '&action=delete&user_id=' . $user['UID'];
|
||||||
}
|
}
|
||||||
|
|
||||||
function user_link($user) {
|
function user_link($user)
|
||||||
|
{
|
||||||
return page_link_to('users') . '&action=view&user_id=' . $user['UID'];
|
return page_link_to('users') . '&action=view&user_id=' . $user['UID'];
|
||||||
}
|
}
|
||||||
|
|
||||||
function user_edit_vouchers_controller() {
|
function user_edit_vouchers_controller()
|
||||||
|
{
|
||||||
global $privileges, $user;
|
global $privileges, $user;
|
||||||
|
|
||||||
if (isset($_REQUEST['user_id'])) {
|
if (isset($_REQUEST['user_id'])) {
|
||||||
|
@ -141,7 +148,8 @@ function user_edit_vouchers_controller() {
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
function user_controller() {
|
function user_controller()
|
||||||
|
{
|
||||||
global $privileges, $user;
|
global $privileges, $user;
|
||||||
|
|
||||||
$user_source = $user;
|
$user_source = $user;
|
||||||
|
@ -180,7 +188,8 @@ function user_controller() {
|
||||||
/**
|
/**
|
||||||
* List all users.
|
* List all users.
|
||||||
*/
|
*/
|
||||||
function users_list_controller() {
|
function users_list_controller()
|
||||||
|
{
|
||||||
global $privileges;
|
global $privileges;
|
||||||
|
|
||||||
if (! in_array('admin_user', $privileges)) {
|
if (! in_array('admin_user', $privileges)) {
|
||||||
|
@ -210,7 +219,8 @@ function users_list_controller() {
|
||||||
/**
|
/**
|
||||||
* Second step of password recovery: set a new password using the token link from email
|
* Second step of password recovery: set a new password using the token link from email
|
||||||
*/
|
*/
|
||||||
function user_password_recovery_set_new_controller() {
|
function user_password_recovery_set_new_controller()
|
||||||
|
{
|
||||||
global $min_password_length;
|
global $min_password_length;
|
||||||
$user_source = User_by_password_recovery_token($_REQUEST['token']);
|
$user_source = User_by_password_recovery_token($_REQUEST['token']);
|
||||||
if ($user_source == null) {
|
if ($user_source == null) {
|
||||||
|
@ -244,7 +254,8 @@ function user_password_recovery_set_new_controller() {
|
||||||
/**
|
/**
|
||||||
* First step of password recovery: display a form that asks for your email and send email with recovery link
|
* First step of password recovery: display a form that asks for your email and send email with recovery link
|
||||||
*/
|
*/
|
||||||
function user_password_recovery_start_controller() {
|
function user_password_recovery_start_controller()
|
||||||
|
{
|
||||||
if (isset($_REQUEST['submit'])) {
|
if (isset($_REQUEST['submit'])) {
|
||||||
$valid = true;
|
$valid = true;
|
||||||
|
|
||||||
|
@ -280,7 +291,8 @@ function user_password_recovery_start_controller() {
|
||||||
* User password recovery in 2 steps.
|
* User password recovery in 2 steps.
|
||||||
* (By email)
|
* (By email)
|
||||||
*/
|
*/
|
||||||
function user_password_recovery_controller() {
|
function user_password_recovery_controller()
|
||||||
|
{
|
||||||
if (isset($_REQUEST['token'])) {
|
if (isset($_REQUEST['token'])) {
|
||||||
return user_password_recovery_set_new_controller();
|
return user_password_recovery_set_new_controller();
|
||||||
} else {
|
} else {
|
||||||
|
@ -291,14 +303,16 @@ function user_password_recovery_controller() {
|
||||||
/**
|
/**
|
||||||
* Menu title for password recovery.
|
* Menu title for password recovery.
|
||||||
*/
|
*/
|
||||||
function user_password_recovery_title() {
|
function user_password_recovery_title()
|
||||||
|
{
|
||||||
return _("Password recovery");
|
return _("Password recovery");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads a user from param user_id.
|
* Loads a user from param user_id.
|
||||||
*/
|
*/
|
||||||
function load_user() {
|
function load_user()
|
||||||
|
{
|
||||||
if (! isset($_REQUEST['user_id'])) {
|
if (! isset($_REQUEST['user_id'])) {
|
||||||
redirect(page_link_to());
|
redirect(page_link_to());
|
||||||
}
|
}
|
||||||
|
@ -316,7 +330,8 @@ function load_user() {
|
||||||
return $user;
|
return $user;
|
||||||
}
|
}
|
||||||
|
|
||||||
function shiftCalendarRendererByShiftFilter(ShiftsFilter $shiftsFilter) {
|
function shiftCalendarRendererByShiftFilter(ShiftsFilter $shiftsFilter)
|
||||||
|
{
|
||||||
$shifts = Shifts_by_ShiftsFilter($shiftsFilter);
|
$shifts = Shifts_by_ShiftsFilter($shiftsFilter);
|
||||||
$needed_angeltypes_source = NeededAngeltypes_by_ShiftsFilter($shiftsFilter);
|
$needed_angeltypes_source = NeededAngeltypes_by_ShiftsFilter($shiftsFilter);
|
||||||
$shift_entries_source = ShiftEntries_by_ShiftsFilter($shiftsFilter);
|
$shift_entries_source = ShiftEntries_by_ShiftsFilter($shiftsFilter);
|
||||||
|
@ -367,5 +382,3 @@ function shiftCalendarRendererByShiftFilter(ShiftsFilter $shiftsFilter) {
|
||||||
|
|
||||||
return new ShiftCalendarRenderer($filtered_shifts, $needed_angeltypes, $shift_entries, $shiftsFilter);
|
return new ShiftCalendarRenderer($filtered_shifts, $needed_angeltypes, $shift_entries, $shiftsFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
|
@ -103,5 +103,3 @@ gettext_init();
|
||||||
sql_connect($config['host'], $config['user'], $config['pw'], $config['db']);
|
sql_connect($config['host'], $config['user'], $config['pw'], $config['db']);
|
||||||
|
|
||||||
load_auth();
|
load_auth();
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
function engelsystem_email_to_user($recipient_user, $title, $message, $not_if_its_me = false) {
|
function engelsystem_email_to_user($recipient_user, $title, $message, $not_if_its_me = false)
|
||||||
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
if ($not_if_its_me && $user['UID'] == $recipient_user['UID']) {
|
if ($not_if_its_me && $user['UID'] == $recipient_user['UID']) {
|
||||||
|
@ -15,11 +16,10 @@ function engelsystem_email_to_user($recipient_user, $title, $message, $not_if_it
|
||||||
return engelsystem_email($recipient_user['email'], $title, $message);
|
return engelsystem_email($recipient_user['email'], $title, $message);
|
||||||
}
|
}
|
||||||
|
|
||||||
function engelsystem_email($address, $title, $message) {
|
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) {
|
if ($result === false) {
|
||||||
engelsystem_error('Unable to send email.');
|
engelsystem_error('Unable to send email.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
|
@ -5,8 +5,7 @@
|
||||||
*
|
*
|
||||||
* @param string $message
|
* @param string $message
|
||||||
*/
|
*/
|
||||||
function engelsystem_error($message) {
|
function engelsystem_error($message)
|
||||||
|
{
|
||||||
raw_output($message);
|
raw_output($message);
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
|
@ -7,7 +7,8 @@
|
||||||
* @param unknown $colors colors for the data rows
|
* @param unknown $colors colors for the data rows
|
||||||
* @param unknown $data the data
|
* @param unknown $data the data
|
||||||
*/
|
*/
|
||||||
function bargraph($dom_id, $key, $row_names, $colors, $data) {
|
function bargraph($dom_id, $key, $row_names, $colors, $data)
|
||||||
|
{
|
||||||
$labels = [];
|
$labels = [];
|
||||||
foreach ($data as $dataset) {
|
foreach ($data as $dataset) {
|
||||||
$labels[] = $dataset[$key];
|
$labels[] = $dataset[$key];
|
||||||
|
@ -37,5 +38,3 @@ function bargraph($dom_id, $key, $row_names, $colors, $data) {
|
||||||
});
|
});
|
||||||
</script>';
|
</script>';
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
|
@ -9,21 +9,24 @@ $default_locale = 'en_US.UTF-8';
|
||||||
/**
|
/**
|
||||||
* Return currently active locale
|
* Return currently active locale
|
||||||
*/
|
*/
|
||||||
function locale() {
|
function locale()
|
||||||
|
{
|
||||||
return $_SESSION['locale'];
|
return $_SESSION['locale'];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns two letter language code from currently active locale
|
* Returns two letter language code from currently active locale
|
||||||
*/
|
*/
|
||||||
function locale_short() {
|
function locale_short()
|
||||||
|
{
|
||||||
return substr(locale(), 0, 2);
|
return substr(locale(), 0, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes gettext for internationalization and updates the sessions locale to use for translation.
|
* Initializes gettext for internationalization and updates the sessions locale to use for translation.
|
||||||
*/
|
*/
|
||||||
function gettext_init() {
|
function gettext_init()
|
||||||
|
{
|
||||||
global $locales, $default_locale;
|
global $locales, $default_locale;
|
||||||
|
|
||||||
if (isset($_REQUEST['set_locale']) && isset($locales[$_REQUEST['set_locale']])) {
|
if (isset($_REQUEST['set_locale']) && isset($locales[$_REQUEST['set_locale']])) {
|
||||||
|
@ -43,7 +46,8 @@ function gettext_init() {
|
||||||
*
|
*
|
||||||
* @param string $locale
|
* @param string $locale
|
||||||
*/
|
*/
|
||||||
function gettext_locale($locale = null) {
|
function gettext_locale($locale = null)
|
||||||
|
{
|
||||||
if ($locale == null) {
|
if ($locale == null) {
|
||||||
$locale = $_SESSION['locale'];
|
$locale = $_SESSION['locale'];
|
||||||
}
|
}
|
||||||
|
@ -57,7 +61,8 @@ function gettext_locale($locale = null) {
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function make_langselect() {
|
function make_langselect()
|
||||||
|
{
|
||||||
global $locales;
|
global $locales;
|
||||||
$URL = $_SERVER["REQUEST_URI"] . (strpos($_SERVER["REQUEST_URI"], "?") > 0 ? '&' : '?') . "set_locale=";
|
$URL = $_SERVER["REQUEST_URI"] . (strpos($_SERVER["REQUEST_URI"], "?") > 0 ? '&' : '?') . "set_locale=";
|
||||||
|
|
||||||
|
@ -67,5 +72,3 @@ function make_langselect() {
|
||||||
}
|
}
|
||||||
return $items;
|
return $items;
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
|
@ -3,7 +3,8 @@
|
||||||
/**
|
/**
|
||||||
* Gibt zwischengespeicherte Fehlermeldungen zurück und löscht den Zwischenspeicher
|
* Gibt zwischengespeicherte Fehlermeldungen zurück und löscht den Zwischenspeicher
|
||||||
*/
|
*/
|
||||||
function msg() {
|
function msg()
|
||||||
|
{
|
||||||
if (! isset($_SESSION['msg'])) {
|
if (! isset($_SESSION['msg'])) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
@ -15,28 +16,32 @@ function msg() {
|
||||||
/**
|
/**
|
||||||
* Rendert eine Information
|
* Rendert eine Information
|
||||||
*/
|
*/
|
||||||
function info($msg, $immediatly = false) {
|
function info($msg, $immediatly = false)
|
||||||
|
{
|
||||||
return alert('info', $msg, $immediatly);
|
return alert('info', $msg, $immediatly);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rendert eine Fehlermeldung
|
* Rendert eine Fehlermeldung
|
||||||
*/
|
*/
|
||||||
function error($msg, $immediatly = false) {
|
function error($msg, $immediatly = false)
|
||||||
|
{
|
||||||
return alert('danger', $msg, $immediatly);
|
return alert('danger', $msg, $immediatly);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rendert eine Erfolgsmeldung
|
* Rendert eine Erfolgsmeldung
|
||||||
*/
|
*/
|
||||||
function success($msg, $immediatly = false) {
|
function success($msg, $immediatly = false)
|
||||||
|
{
|
||||||
return alert('success', $msg, $immediatly);
|
return alert('success', $msg, $immediatly);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renders an alert with given alert-* class.
|
* Renders an alert with given alert-* class.
|
||||||
*/
|
*/
|
||||||
function alert($class, $msg, $immediatly = false) {
|
function alert($class, $msg, $immediatly = false)
|
||||||
|
{
|
||||||
if ($immediatly) {
|
if ($immediatly) {
|
||||||
if ($msg == "") {
|
if ($msg == "") {
|
||||||
return "";
|
return "";
|
||||||
|
@ -49,5 +54,3 @@ function alert($class, $msg, $immediatly = false) {
|
||||||
}
|
}
|
||||||
$_SESSION['msg'] .= alert($class, $msg, true);
|
$_SESSION['msg'] .= alert($class, $msg, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
function mail_shift_change($old_shift, $new_shift) {
|
function mail_shift_change($old_shift, $new_shift)
|
||||||
|
{
|
||||||
$users = ShiftEntries_by_shift($old_shift["SID"]);
|
$users = ShiftEntries_by_shift($old_shift["SID"]);
|
||||||
$old_room = Room($old_shift["RID"]);
|
$old_room = Room($old_shift["RID"]);
|
||||||
$new_room = Room($new_shift["RID"]);
|
$new_room = Room($new_shift["RID"]);
|
||||||
|
@ -55,7 +56,8 @@ function mail_shift_change($old_shift, $new_shift) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function mail_shift_delete($shift) {
|
function mail_shift_delete($shift)
|
||||||
|
{
|
||||||
$users = ShiftEntries_by_shift($shift["SID"]);
|
$users = ShiftEntries_by_shift($shift["SID"]);
|
||||||
$room = Room($shift["RID"]);
|
$room = Room($shift["RID"]);
|
||||||
|
|
||||||
|
@ -73,7 +75,8 @@ function mail_shift_delete($shift) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function mail_shift_assign($user, $shift) {
|
function mail_shift_assign($user, $shift)
|
||||||
|
{
|
||||||
if ($user["email_shiftinfo"]) {
|
if ($user["email_shiftinfo"]) {
|
||||||
$room = Room($shift["RID"]);
|
$room = Room($shift["RID"]);
|
||||||
|
|
||||||
|
@ -87,7 +90,8 @@ function mail_shift_assign($user, $shift) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function mail_shift_removed($user, $shift) {
|
function mail_shift_removed($user, $shift)
|
||||||
|
{
|
||||||
if ($user["email_shiftinfo"]) {
|
if ($user["email_shiftinfo"]) {
|
||||||
$room = Room($shift["RID"]);
|
$room = Room($shift["RID"]);
|
||||||
|
|
||||||
|
@ -100,5 +104,3 @@ function mail_shift_removed($user, $shift) {
|
||||||
engelsystem_email_to_user($user, '[engelsystem] ' . _("Removed from Shift"), $message, true);
|
engelsystem_email_to_user($user, '[engelsystem] ' . _("Removed from Shift"), $message, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
/**
|
/**
|
||||||
* @param User $user_source
|
* @param User $user_source
|
||||||
*/
|
*/
|
||||||
function mail_user_delete($user) {
|
function mail_user_delete($user)
|
||||||
|
{
|
||||||
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."));
|
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."));
|
||||||
}
|
}
|
||||||
?>
|
|
|
@ -5,7 +5,8 @@ use Engelsystem\ValidationResult;
|
||||||
* Returns an array containing the basic attributes of angeltypes.
|
* Returns an array containing the basic attributes of angeltypes.
|
||||||
* FIXME! This is the big sign for needing entity objects
|
* FIXME! This is the big sign for needing entity objects
|
||||||
*/
|
*/
|
||||||
function AngelType_new() {
|
function AngelType_new()
|
||||||
|
{
|
||||||
return [
|
return [
|
||||||
'id' => null,
|
'id' => null,
|
||||||
'name' => "",
|
'name' => "",
|
||||||
|
@ -27,7 +28,8 @@ function AngelType_new() {
|
||||||
* The angeltype
|
* The angeltype
|
||||||
* @return ValidationResult
|
* @return ValidationResult
|
||||||
*/
|
*/
|
||||||
function AngelType_validate_contact_user_id($angeltype) {
|
function AngelType_validate_contact_user_id($angeltype)
|
||||||
|
{
|
||||||
if (! isset($angeltype['contact_user_id'])) {
|
if (! isset($angeltype['contact_user_id'])) {
|
||||||
return new ValidationResult(true, null);
|
return new ValidationResult(true, null);
|
||||||
}
|
}
|
||||||
|
@ -46,7 +48,8 @@ function AngelType_validate_contact_user_id($angeltype) {
|
||||||
* @param Angeltype $angeltype
|
* @param Angeltype $angeltype
|
||||||
* The angeltype
|
* The angeltype
|
||||||
*/
|
*/
|
||||||
function AngelType_contact_info($angeltype) {
|
function AngelType_contact_info($angeltype)
|
||||||
|
{
|
||||||
if (isset($angeltype['contact_user_id'])) {
|
if (isset($angeltype['contact_user_id'])) {
|
||||||
$contact_user = User($angeltype['contact_user_id']);
|
$contact_user = User($angeltype['contact_user_id']);
|
||||||
$contact_data = [
|
$contact_data = [
|
||||||
|
@ -73,7 +76,8 @@ function AngelType_contact_info($angeltype) {
|
||||||
*
|
*
|
||||||
* @param Angeltype $angeltype
|
* @param Angeltype $angeltype
|
||||||
*/
|
*/
|
||||||
function AngelType_delete($angeltype) {
|
function AngelType_delete($angeltype)
|
||||||
|
{
|
||||||
$result = sql_query("
|
$result = sql_query("
|
||||||
DELETE FROM `AngelTypes`
|
DELETE FROM `AngelTypes`
|
||||||
WHERE `id`='" . sql_escape($angeltype['id']) . "'
|
WHERE `id`='" . sql_escape($angeltype['id']) . "'
|
||||||
|
@ -91,7 +95,8 @@ function AngelType_delete($angeltype) {
|
||||||
* @param Angeltype $angeltype
|
* @param Angeltype $angeltype
|
||||||
* The angeltype
|
* The angeltype
|
||||||
*/
|
*/
|
||||||
function AngelType_update($angeltype) {
|
function AngelType_update($angeltype)
|
||||||
|
{
|
||||||
$result = sql_query("
|
$result = sql_query("
|
||||||
UPDATE `AngelTypes` SET
|
UPDATE `AngelTypes` SET
|
||||||
`name`='" . sql_escape($angeltype['name']) . "',
|
`name`='" . sql_escape($angeltype['name']) . "',
|
||||||
|
@ -118,7 +123,8 @@ function AngelType_update($angeltype) {
|
||||||
* The angeltype
|
* The angeltype
|
||||||
* @return the created angeltype
|
* @return the created angeltype
|
||||||
*/
|
*/
|
||||||
function AngelType_create($angeltype) {
|
function AngelType_create($angeltype)
|
||||||
|
{
|
||||||
$result = sql_query("
|
$result = sql_query("
|
||||||
INSERT INTO `AngelTypes` SET
|
INSERT INTO `AngelTypes` SET
|
||||||
`name`='" . sql_escape($angeltype['name']) . "',
|
`name`='" . sql_escape($angeltype['name']) . "',
|
||||||
|
@ -148,7 +154,8 @@ function AngelType_create($angeltype) {
|
||||||
* The angeltype the name is for
|
* The angeltype the name is for
|
||||||
* @return ValidationResult result and validated name
|
* @return ValidationResult result and validated name
|
||||||
*/
|
*/
|
||||||
function AngelType_validate_name($name, $angeltype) {
|
function AngelType_validate_name($name, $angeltype)
|
||||||
|
{
|
||||||
$name = strip_item($name);
|
$name = strip_item($name);
|
||||||
if ($name == "") {
|
if ($name == "") {
|
||||||
return new ValidationResult(false, "");
|
return new ValidationResult(false, "");
|
||||||
|
@ -175,7 +182,8 @@ function AngelType_validate_name($name, $angeltype) {
|
||||||
*
|
*
|
||||||
* @param User $user
|
* @param User $user
|
||||||
*/
|
*/
|
||||||
function AngelTypes_with_user($user) {
|
function AngelTypes_with_user($user)
|
||||||
|
{
|
||||||
$result = sql_select("
|
$result = sql_select("
|
||||||
SELECT `AngelTypes`.*,
|
SELECT `AngelTypes`.*,
|
||||||
`UserAngelTypes`.`id` as `user_angeltype_id`,
|
`UserAngelTypes`.`id` as `user_angeltype_id`,
|
||||||
|
@ -194,7 +202,8 @@ function AngelTypes_with_user($user) {
|
||||||
/**
|
/**
|
||||||
* Returns all angeltypes.
|
* Returns all angeltypes.
|
||||||
*/
|
*/
|
||||||
function AngelTypes() {
|
function AngelTypes()
|
||||||
|
{
|
||||||
$result = sql_select("
|
$result = sql_select("
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM `AngelTypes`
|
FROM `AngelTypes`
|
||||||
|
@ -208,7 +217,8 @@ function AngelTypes() {
|
||||||
/**
|
/**
|
||||||
* Returns AngelType id array
|
* Returns AngelType id array
|
||||||
*/
|
*/
|
||||||
function AngelType_ids() {
|
function AngelType_ids()
|
||||||
|
{
|
||||||
$result = sql_select("SELECT `id` FROM `AngelTypes`");
|
$result = sql_select("SELECT `id` FROM `AngelTypes`");
|
||||||
if ($result === false) {
|
if ($result === false) {
|
||||||
engelsystem_error("Unable to load angeltypes.");
|
engelsystem_error("Unable to load angeltypes.");
|
||||||
|
@ -222,7 +232,8 @@ function AngelType_ids() {
|
||||||
* @param $angeltype_id angelType
|
* @param $angeltype_id angelType
|
||||||
* ID
|
* ID
|
||||||
*/
|
*/
|
||||||
function AngelType($angeltype_id) {
|
function AngelType($angeltype_id)
|
||||||
|
{
|
||||||
$angelType_source = sql_select("SELECT * FROM `AngelTypes` WHERE `id`='" . sql_escape($angeltype_id) . "'");
|
$angelType_source = sql_select("SELECT * FROM `AngelTypes` WHERE `id`='" . sql_escape($angeltype_id) . "'");
|
||||||
if ($angelType_source === false) {
|
if ($angelType_source === false) {
|
||||||
engelsystem_error("Unable to load angeltype.");
|
engelsystem_error("Unable to load angeltype.");
|
||||||
|
@ -232,5 +243,3 @@ function AngelType($angeltype_id) {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
/**
|
/**
|
||||||
* Get event config.
|
* Get event config.
|
||||||
*/
|
*/
|
||||||
function EventConfig() {
|
function EventConfig()
|
||||||
|
{
|
||||||
$event_config = sql_select("SELECT * FROM `EventConfig` LIMIT 1");
|
$event_config = sql_select("SELECT * FROM `EventConfig` LIMIT 1");
|
||||||
if ($event_config === false) {
|
if ($event_config === false) {
|
||||||
engelsystem_error("Unable to load event config.");
|
engelsystem_error("Unable to load event config.");
|
||||||
|
@ -25,7 +26,8 @@ function EventConfig() {
|
||||||
* @param int $teardown_end_date
|
* @param int $teardown_end_date
|
||||||
* @param string $event_welcome_msg
|
* @param string $event_welcome_msg
|
||||||
*/
|
*/
|
||||||
function EventConfig_update($event_name, $buildup_start_date, $event_start_date, $event_end_date, $teardown_end_date, $event_welcome_msg) {
|
function EventConfig_update($event_name, $buildup_start_date, $event_start_date, $event_end_date, $teardown_end_date, $event_welcome_msg)
|
||||||
|
{
|
||||||
if (EventConfig() == null) {
|
if (EventConfig() == null) {
|
||||||
return sql_query("INSERT INTO `EventConfig` SET
|
return sql_query("INSERT INTO `EventConfig` SET
|
||||||
`event_name`=" . sql_null($event_name) . ",
|
`event_name`=" . sql_null($event_name) . ",
|
||||||
|
@ -43,4 +45,3 @@ function EventConfig_update($event_name, $buildup_start_date, $event_start_date,
|
||||||
`teardown_end_date`=" . sql_null($teardown_end_date) . ",
|
`teardown_end_date`=" . sql_null($teardown_end_date) . ",
|
||||||
`event_welcome_msg`=" . sql_null($event_welcome_msg));
|
`event_welcome_msg`=" . sql_null($event_welcome_msg));
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
|
|
@ -7,21 +7,24 @@
|
||||||
* @param $message Log
|
* @param $message Log
|
||||||
* Message
|
* Message
|
||||||
*/
|
*/
|
||||||
function LogEntry_create($nick, $message) {
|
function LogEntry_create($nick, $message)
|
||||||
|
{
|
||||||
return sql_query("INSERT INTO `LogEntries` SET `timestamp`='" . sql_escape(time()) . "', `nick`='" . sql_escape($nick) . "', `message`='" . sql_escape($message) . "'");
|
return sql_query("INSERT INTO `LogEntries` SET `timestamp`='" . sql_escape(time()) . "', `nick`='" . sql_escape($nick) . "', `message`='" . sql_escape($message) . "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns log entries with maximum count of 10000.
|
* Returns log entries with maximum count of 10000.
|
||||||
*/
|
*/
|
||||||
function LogEntries() {
|
function LogEntries()
|
||||||
|
{
|
||||||
return sql_select("SELECT * FROM `LogEntries` ORDER BY `timestamp` DESC LIMIT 10000");
|
return sql_select("SELECT * FROM `LogEntries` ORDER BY `timestamp` DESC LIMIT 10000");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns log entries filtered by a keyword
|
* Returns log entries filtered by a keyword
|
||||||
*/
|
*/
|
||||||
function LogEntries_filter($keyword) {
|
function LogEntries_filter($keyword)
|
||||||
|
{
|
||||||
if ($keyword == "") {
|
if ($keyword == "") {
|
||||||
return LogEntries();
|
return LogEntries();
|
||||||
}
|
}
|
||||||
|
@ -31,8 +34,7 @@ function LogEntries_filter($keyword) {
|
||||||
/**
|
/**
|
||||||
* Delete all log entries.
|
* Delete all log entries.
|
||||||
*/
|
*/
|
||||||
function LogEntries_clear_all() {
|
function LogEntries_clear_all()
|
||||||
|
{
|
||||||
return sql_query("TRUNCATE `LogEntries`");
|
return sql_query("TRUNCATE `LogEntries`");
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
/**
|
/**
|
||||||
* Returns Message id array
|
* Returns Message id array
|
||||||
*/
|
*/
|
||||||
function Message_ids() {
|
function Message_ids()
|
||||||
|
{
|
||||||
return sql_select("SELECT `id` FROM `Messages`");
|
return sql_select("SELECT `id` FROM `Messages`");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +14,8 @@ function Message_ids() {
|
||||||
* @param $message_id message
|
* @param $message_id message
|
||||||
* ID
|
* ID
|
||||||
*/
|
*/
|
||||||
function Message($message_id) {
|
function Message($message_id)
|
||||||
|
{
|
||||||
$message_source = sql_select("SELECT * FROM `Messages` WHERE `id`='" . sql_escape($message_id) . "' LIMIT 1");
|
$message_source = sql_select("SELECT * FROM `Messages` WHERE `id`='" . sql_escape($message_id) . "' LIMIT 1");
|
||||||
if ($message_source === false) {
|
if ($message_source === false) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -34,7 +36,8 @@ function Message($message_id) {
|
||||||
* @param $text Text
|
* @param $text Text
|
||||||
* of Message
|
* of Message
|
||||||
*/
|
*/
|
||||||
function Message_send($receiver_user_id, $text) {
|
function Message_send($receiver_user_id, $text)
|
||||||
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
$text = preg_replace("/([^\p{L}\p{P}\p{Z}\p{N}\n]{1,})/ui", '', strip_tags($text));
|
$text = preg_replace("/([^\p{L}\p{P}\p{Z}\p{N}\n]{1,})/ui", '', strip_tags($text));
|
||||||
|
@ -47,5 +50,3 @@ function Message_send($receiver_user_id, $text) {
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
|
@ -16,7 +16,8 @@
|
||||||
* @param int $count
|
* @param int $count
|
||||||
* How many angels are needed?
|
* How many angels are needed?
|
||||||
*/
|
*/
|
||||||
function NeededAngelType_add($shift_id, $angeltype_id, $room_id, $count) {
|
function NeededAngelType_add($shift_id, $angeltype_id, $room_id, $count)
|
||||||
|
{
|
||||||
$result = sql_query("
|
$result = sql_query("
|
||||||
INSERT INTO `NeededAngelTypes` SET
|
INSERT INTO `NeededAngelTypes` SET
|
||||||
`shift_id`=" . sql_null($shift_id) . ",
|
`shift_id`=" . sql_null($shift_id) . ",
|
||||||
|
@ -35,7 +36,8 @@ function NeededAngelType_add($shift_id, $angeltype_id, $room_id, $count) {
|
||||||
* @param int $shift_id
|
* @param int $shift_id
|
||||||
* id of the shift
|
* id of the shift
|
||||||
*/
|
*/
|
||||||
function NeededAngelTypes_delete_by_shift($shift_id) {
|
function NeededAngelTypes_delete_by_shift($shift_id)
|
||||||
|
{
|
||||||
return sql_query("DELETE FROM `NeededAngelTypes` WHERE `shift_id`='" . sql_escape($shift_id) . "'");
|
return sql_query("DELETE FROM `NeededAngelTypes` WHERE `shift_id`='" . sql_escape($shift_id) . "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,7 +47,8 @@ function NeededAngelTypes_delete_by_shift($shift_id) {
|
||||||
* @param int $room_id
|
* @param int $room_id
|
||||||
* id of the room
|
* id of the room
|
||||||
*/
|
*/
|
||||||
function NeededAngelTypes_delete_by_room($room_id) {
|
function NeededAngelTypes_delete_by_room($room_id)
|
||||||
|
{
|
||||||
return sql_query("DELETE FROM `NeededAngelTypes` WHERE `room_id`='" . sql_escape($room_id) . "'");
|
return sql_query("DELETE FROM `NeededAngelTypes` WHERE `room_id`='" . sql_escape($room_id) . "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +58,8 @@ function NeededAngelTypes_delete_by_room($room_id) {
|
||||||
* @param int $shiftID
|
* @param int $shiftID
|
||||||
* id of shift
|
* id of shift
|
||||||
*/
|
*/
|
||||||
function NeededAngelTypes_by_shift($shiftId) {
|
function NeededAngelTypes_by_shift($shiftId)
|
||||||
|
{
|
||||||
$needed_angeltypes_source = sql_select("
|
$needed_angeltypes_source = sql_select("
|
||||||
SELECT `NeededAngelTypes`.*, `AngelTypes`.`id`, `AngelTypes`.`name`, `AngelTypes`.`restricted`, `AngelTypes`.`no_self_signup`
|
SELECT `NeededAngelTypes`.*, `AngelTypes`.`id`, `AngelTypes`.`name`, `AngelTypes`.`restricted`, `AngelTypes`.`no_self_signup`
|
||||||
FROM `NeededAngelTypes`
|
FROM `NeededAngelTypes`
|
||||||
|
@ -101,5 +105,3 @@ function NeededAngelTypes_by_shift($shiftId) {
|
||||||
|
|
||||||
return $needed_angeltypes;
|
return $needed_angeltypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
|
@ -4,7 +4,8 @@
|
||||||
* returns a list of rooms.
|
* returns a list of rooms.
|
||||||
* @param boolean $show_all returns also hidden rooms when true
|
* @param boolean $show_all returns also hidden rooms when true
|
||||||
*/
|
*/
|
||||||
function Rooms($show_all = false) {
|
function Rooms($show_all = false)
|
||||||
|
{
|
||||||
return sql_select("SELECT * FROM `Room`" . ($show_all ? "" : " WHERE `show`='Y'") . " ORDER BY `Name`");
|
return sql_select("SELECT * FROM `Room`" . ($show_all ? "" : " WHERE `show`='Y'") . " ORDER BY `Name`");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +14,8 @@ function Rooms($show_all = false) {
|
||||||
*
|
*
|
||||||
* @param int $room_id
|
* @param int $room_id
|
||||||
*/
|
*/
|
||||||
function Room_delete($room_id) {
|
function Room_delete($room_id)
|
||||||
|
{
|
||||||
return sql_query("DELETE FROM `Room` WHERE `RID`=" . sql_escape($room_id));
|
return sql_query("DELETE FROM `Room` WHERE `RID`=" . sql_escape($room_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +29,8 @@ function Room_delete($room_id) {
|
||||||
* @param boolean $public
|
* @param boolean $public
|
||||||
* Is the room visible for angels?
|
* Is the room visible for angels?
|
||||||
*/
|
*/
|
||||||
function Room_create($name, $from_frab, $public) {
|
function Room_create($name, $from_frab, $public)
|
||||||
|
{
|
||||||
$result = sql_query("
|
$result = sql_query("
|
||||||
INSERT INTO `Room` SET
|
INSERT INTO `Room` SET
|
||||||
`Name`='" . sql_escape($name) . "',
|
`Name`='" . sql_escape($name) . "',
|
||||||
|
@ -45,7 +48,8 @@ function Room_create($name, $from_frab, $public) {
|
||||||
*
|
*
|
||||||
* @param $room_id RID
|
* @param $room_id RID
|
||||||
*/
|
*/
|
||||||
function Room($room_id) {
|
function Room($room_id)
|
||||||
|
{
|
||||||
$room_source = sql_select("SELECT * FROM `Room` WHERE `RID`='" . sql_escape($room_id) . "' AND `show` = 'Y'");
|
$room_source = sql_select("SELECT * FROM `Room` WHERE `RID`='" . sql_escape($room_id) . "' AND `show` = 'Y'");
|
||||||
|
|
||||||
if ($room_source === false) {
|
if ($room_source === false) {
|
||||||
|
@ -56,5 +60,3 @@ function Room($room_id) {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
|
@ -4,7 +4,8 @@
|
||||||
* Returns an array with the attributes of shift entries.
|
* Returns an array with the attributes of shift entries.
|
||||||
* FIXME! Needs entity object.
|
* FIXME! Needs entity object.
|
||||||
*/
|
*/
|
||||||
function ShiftEntry_new() {
|
function ShiftEntry_new()
|
||||||
|
{
|
||||||
return [
|
return [
|
||||||
'id' => null,
|
'id' => null,
|
||||||
'SID' => null,
|
'SID' => null,
|
||||||
|
@ -19,14 +20,16 @@ function ShiftEntry_new() {
|
||||||
/**
|
/**
|
||||||
* Counts all freeloaded shifts.
|
* Counts all freeloaded shifts.
|
||||||
*/
|
*/
|
||||||
function ShiftEntries_freeleaded_count() {
|
function ShiftEntries_freeleaded_count()
|
||||||
|
{
|
||||||
return sql_select_single_cell("SELECT COUNT(*) FROM `ShiftEntry` WHERE `freeloaded` = 1");
|
return sql_select_single_cell("SELECT COUNT(*) FROM `ShiftEntry` WHERE `freeloaded` = 1");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List users subsribed to a given shift.
|
* List users subsribed to a given shift.
|
||||||
*/
|
*/
|
||||||
function ShiftEntries_by_shift($shift_id) {
|
function ShiftEntries_by_shift($shift_id)
|
||||||
|
{
|
||||||
return sql_select("
|
return sql_select("
|
||||||
SELECT `User`.`Nick`, `User`.`email`, `User`.`email_shiftinfo`, `User`.`Sprache`, `User`.`Gekommen`, `ShiftEntry`.`UID`, `ShiftEntry`.`TID`, `ShiftEntry`.`SID`, `AngelTypes`.`name` as `angel_type_name`, `ShiftEntry`.`Comment`, `ShiftEntry`.`freeloaded`
|
SELECT `User`.`Nick`, `User`.`email`, `User`.`email_shiftinfo`, `User`.`Sprache`, `User`.`Gekommen`, `ShiftEntry`.`UID`, `ShiftEntry`.`TID`, `ShiftEntry`.`SID`, `AngelTypes`.`name` as `angel_type_name`, `ShiftEntry`.`Comment`, `ShiftEntry`.`freeloaded`
|
||||||
FROM `ShiftEntry`
|
FROM `ShiftEntry`
|
||||||
|
@ -40,7 +43,8 @@ function ShiftEntries_by_shift($shift_id) {
|
||||||
*
|
*
|
||||||
* @param ShiftEntry $shift_entry
|
* @param ShiftEntry $shift_entry
|
||||||
*/
|
*/
|
||||||
function ShiftEntry_create($shift_entry) {
|
function ShiftEntry_create($shift_entry)
|
||||||
|
{
|
||||||
mail_shift_assign(User($shift_entry['UID']), Shift($shift_entry['SID']));
|
mail_shift_assign(User($shift_entry['UID']), Shift($shift_entry['SID']));
|
||||||
return sql_query("INSERT INTO `ShiftEntry` SET
|
return sql_query("INSERT INTO `ShiftEntry` SET
|
||||||
`SID`='" . sql_escape($shift_entry['SID']) . "',
|
`SID`='" . sql_escape($shift_entry['SID']) . "',
|
||||||
|
@ -54,7 +58,8 @@ function ShiftEntry_create($shift_entry) {
|
||||||
/**
|
/**
|
||||||
* Update a shift entry.
|
* Update a shift entry.
|
||||||
*/
|
*/
|
||||||
function ShiftEntry_update($shift_entry) {
|
function ShiftEntry_update($shift_entry)
|
||||||
|
{
|
||||||
return sql_query("UPDATE `ShiftEntry` SET
|
return sql_query("UPDATE `ShiftEntry` SET
|
||||||
`Comment`='" . sql_escape($shift_entry['Comment']) . "',
|
`Comment`='" . sql_escape($shift_entry['Comment']) . "',
|
||||||
`freeload_comment`='" . sql_escape($shift_entry['freeload_comment']) . "',
|
`freeload_comment`='" . sql_escape($shift_entry['freeload_comment']) . "',
|
||||||
|
@ -65,7 +70,8 @@ function ShiftEntry_update($shift_entry) {
|
||||||
/**
|
/**
|
||||||
* Get a shift entry.
|
* Get a shift entry.
|
||||||
*/
|
*/
|
||||||
function ShiftEntry($shift_entry_id) {
|
function ShiftEntry($shift_entry_id)
|
||||||
|
{
|
||||||
$shift_entry = sql_select("SELECT * FROM `ShiftEntry` WHERE `id`='" . sql_escape($shift_entry_id) . "'");
|
$shift_entry = sql_select("SELECT * FROM `ShiftEntry` WHERE `id`='" . sql_escape($shift_entry_id) . "'");
|
||||||
if ($shift_entry === false) {
|
if ($shift_entry === false) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -79,7 +85,8 @@ function ShiftEntry($shift_entry_id) {
|
||||||
/**
|
/**
|
||||||
* Delete a shift entry.
|
* Delete a shift entry.
|
||||||
*/
|
*/
|
||||||
function ShiftEntry_delete($shift_entry_id) {
|
function ShiftEntry_delete($shift_entry_id)
|
||||||
|
{
|
||||||
$shift_entry = ShiftEntry($shift_entry_id);
|
$shift_entry = ShiftEntry($shift_entry_id);
|
||||||
mail_shift_removed(User($shift_entry['UID']), Shift($shift_entry['SID']));
|
mail_shift_removed(User($shift_entry['UID']), Shift($shift_entry['SID']));
|
||||||
return sql_query("DELETE FROM `ShiftEntry` WHERE `id`='" . sql_escape($shift_entry_id) . "'");
|
return sql_query("DELETE FROM `ShiftEntry` WHERE `id`='" . sql_escape($shift_entry_id) . "'");
|
||||||
|
@ -90,7 +97,8 @@ function ShiftEntry_delete($shift_entry_id) {
|
||||||
*
|
*
|
||||||
* @param User $user
|
* @param User $user
|
||||||
*/
|
*/
|
||||||
function ShiftEntries_upcoming_for_user($user) {
|
function ShiftEntries_upcoming_for_user($user)
|
||||||
|
{
|
||||||
return sql_select("
|
return sql_select("
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM `ShiftEntry`
|
FROM `ShiftEntry`
|
||||||
|
@ -107,7 +115,8 @@ function ShiftEntries_upcoming_for_user($user) {
|
||||||
*
|
*
|
||||||
* @param User $user
|
* @param User $user
|
||||||
*/
|
*/
|
||||||
function ShiftEntries_finished_by_user($user) {
|
function ShiftEntries_finished_by_user($user)
|
||||||
|
{
|
||||||
return sql_select("
|
return sql_select("
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM `ShiftEntry`
|
FROM `ShiftEntry`
|
||||||
|
@ -126,7 +135,8 @@ function ShiftEntries_finished_by_user($user) {
|
||||||
* @param int $shift_id
|
* @param int $shift_id
|
||||||
* @param int $angeltype_id
|
* @param int $angeltype_id
|
||||||
*/
|
*/
|
||||||
function ShiftEntries_by_shift_and_angeltype($shift_id, $angeltype_id) {
|
function ShiftEntries_by_shift_and_angeltype($shift_id, $angeltype_id)
|
||||||
|
{
|
||||||
$result = sql_select("
|
$result = sql_select("
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM `ShiftEntry`
|
FROM `ShiftEntry`
|
||||||
|
@ -142,11 +152,10 @@ function ShiftEntries_by_shift_and_angeltype($shift_id, $angeltype_id) {
|
||||||
/**
|
/**
|
||||||
* Returns all freeloaded shifts for given user.
|
* Returns all freeloaded shifts for given user.
|
||||||
*/
|
*/
|
||||||
function ShiftEntries_freeloaded_by_user($user) {
|
function ShiftEntries_freeloaded_by_user($user)
|
||||||
|
{
|
||||||
return sql_select("SELECT *
|
return sql_select("SELECT *
|
||||||
FROM `ShiftEntry`
|
FROM `ShiftEntry`
|
||||||
WHERE `freeloaded` = 1
|
WHERE `freeloaded` = 1
|
||||||
AND `UID`=" . sql_escape($user['UID']));
|
AND `UID`=" . sql_escape($user['UID']));
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
|
@ -6,7 +6,8 @@ namespace Engelsystem;
|
||||||
* BO to represent if there are free slots on a shift for a given angeltype
|
* BO to represent if there are free slots on a shift for a given angeltype
|
||||||
* and if signup for a given user is possible (or not, because of collisions, etc.)
|
* and if signup for a given user is possible (or not, because of collisions, etc.)
|
||||||
*/
|
*/
|
||||||
class ShiftSignupState {
|
class ShiftSignupState
|
||||||
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shift has free places
|
* Shift has free places
|
||||||
|
@ -47,7 +48,8 @@ class ShiftSignupState {
|
||||||
|
|
||||||
private $freeEntries;
|
private $freeEntries;
|
||||||
|
|
||||||
public function __construct($state, $free_entries) {
|
public function __construct($state, $free_entries)
|
||||||
|
{
|
||||||
$this->state = $state;
|
$this->state = $state;
|
||||||
$this->freeEntries = $free_entries;
|
$this->freeEntries = $free_entries;
|
||||||
}
|
}
|
||||||
|
@ -58,7 +60,8 @@ class ShiftSignupState {
|
||||||
* @param ShiftSignupState $shiftSignupState
|
* @param ShiftSignupState $shiftSignupState
|
||||||
* The other state to combine
|
* The other state to combine
|
||||||
*/
|
*/
|
||||||
public function combineWith(ShiftSignupState $shiftSignupState) {
|
public function combineWith(ShiftSignupState $shiftSignupState)
|
||||||
|
{
|
||||||
$this->freeEntries += $shiftSignupState->getFreeEntries();
|
$this->freeEntries += $shiftSignupState->getFreeEntries();
|
||||||
|
|
||||||
if ($this->valueForState($shiftSignupState->state) > $this->valueForState($this->state)) {
|
if ($this->valueForState($shiftSignupState->state) > $this->valueForState($this->state)) {
|
||||||
|
@ -66,7 +69,8 @@ class ShiftSignupState {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function valueForState($state) {
|
private function valueForState($state)
|
||||||
|
{
|
||||||
switch ($state) {
|
switch ($state) {
|
||||||
case ShiftSignupState::SHIFT_ENDED:
|
case ShiftSignupState::SHIFT_ENDED:
|
||||||
return 100;
|
return 100;
|
||||||
|
@ -90,7 +94,8 @@ class ShiftSignupState {
|
||||||
/**
|
/**
|
||||||
* Returns true, if signup is allowed
|
* Returns true, if signup is allowed
|
||||||
*/
|
*/
|
||||||
public function isSignupAllowed() {
|
public function isSignupAllowed()
|
||||||
|
{
|
||||||
switch ($this->state) {
|
switch ($this->state) {
|
||||||
case ShiftSignupState::FREE:
|
case ShiftSignupState::FREE:
|
||||||
case ShiftSignupState::ADMIN:
|
case ShiftSignupState::ADMIN:
|
||||||
|
@ -102,16 +107,16 @@ class ShiftSignupState {
|
||||||
/**
|
/**
|
||||||
* Return the shift signup state
|
* Return the shift signup state
|
||||||
*/
|
*/
|
||||||
public function getState() {
|
public function getState()
|
||||||
|
{
|
||||||
return $this->state;
|
return $this->state;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* How many places are free in this shift for the angeltype?
|
* How many places are free in this shift for the angeltype?
|
||||||
*/
|
*/
|
||||||
public function getFreeEntries() {
|
public function getFreeEntries()
|
||||||
|
{
|
||||||
return $this->freeEntries;
|
return $this->freeEntries;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
|
@ -4,7 +4,8 @@
|
||||||
* Delete a shift type.
|
* Delete a shift type.
|
||||||
* @param int $shifttype_id
|
* @param int $shifttype_id
|
||||||
*/
|
*/
|
||||||
function ShiftType_delete($shifttype_id) {
|
function ShiftType_delete($shifttype_id)
|
||||||
|
{
|
||||||
return sql_query("DELETE FROM `ShiftTypes` WHERE `id`='" . sql_escape($shifttype_id) . "'");
|
return sql_query("DELETE FROM `ShiftTypes` WHERE `id`='" . sql_escape($shifttype_id) . "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,7 +17,8 @@ function ShiftType_delete($shifttype_id) {
|
||||||
* @param int $angeltype_id
|
* @param int $angeltype_id
|
||||||
* @param string $description
|
* @param string $description
|
||||||
*/
|
*/
|
||||||
function ShiftType_update($shifttype_id, $name, $angeltype_id, $description) {
|
function ShiftType_update($shifttype_id, $name, $angeltype_id, $description)
|
||||||
|
{
|
||||||
return sql_query("UPDATE `ShiftTypes` SET
|
return sql_query("UPDATE `ShiftTypes` SET
|
||||||
`name`='" . sql_escape($name) . "',
|
`name`='" . sql_escape($name) . "',
|
||||||
`angeltype_id`=" . sql_null($angeltype_id) . ",
|
`angeltype_id`=" . sql_null($angeltype_id) . ",
|
||||||
|
@ -32,7 +34,8 @@ function ShiftType_update($shifttype_id, $name, $angeltype_id, $description) {
|
||||||
* @param string $description
|
* @param string $description
|
||||||
* @return new shifttype id
|
* @return new shifttype id
|
||||||
*/
|
*/
|
||||||
function ShiftType_create($name, $angeltype_id, $description) {
|
function ShiftType_create($name, $angeltype_id, $description)
|
||||||
|
{
|
||||||
$result = sql_query("INSERT INTO `ShiftTypes` SET
|
$result = sql_query("INSERT INTO `ShiftTypes` SET
|
||||||
`name`='" . sql_escape($name) . "',
|
`name`='" . sql_escape($name) . "',
|
||||||
`angeltype_id`=" . sql_null($angeltype_id) . ",
|
`angeltype_id`=" . sql_null($angeltype_id) . ",
|
||||||
|
@ -48,7 +51,8 @@ function ShiftType_create($name, $angeltype_id, $description) {
|
||||||
*
|
*
|
||||||
* @param int $shifttype_id
|
* @param int $shifttype_id
|
||||||
*/
|
*/
|
||||||
function ShiftType($shifttype_id) {
|
function ShiftType($shifttype_id)
|
||||||
|
{
|
||||||
$shifttype = sql_select("SELECT * FROM `ShiftTypes` WHERE `id`='" . sql_escape($shifttype_id) . "'");
|
$shifttype = sql_select("SELECT * FROM `ShiftTypes` WHERE `id`='" . sql_escape($shifttype_id) . "'");
|
||||||
if ($shifttype === false) {
|
if ($shifttype === false) {
|
||||||
engelsystem_error('Unable to load shift type.');
|
engelsystem_error('Unable to load shift type.');
|
||||||
|
@ -62,8 +66,7 @@ function ShiftType($shifttype_id) {
|
||||||
/**
|
/**
|
||||||
* Get all shift types.
|
* Get all shift types.
|
||||||
*/
|
*/
|
||||||
function ShiftTypes() {
|
function ShiftTypes()
|
||||||
|
{
|
||||||
return sql_select("SELECT * FROM `ShiftTypes` ORDER BY `name`");
|
return sql_select("SELECT * FROM `ShiftTypes` ORDER BY `name`");
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
|
@ -7,7 +7,8 @@ namespace Engelsystem;
|
||||||
*
|
*
|
||||||
* @author msquare
|
* @author msquare
|
||||||
*/
|
*/
|
||||||
class ShiftsFilter {
|
class ShiftsFilter
|
||||||
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* How long can the time interval be?
|
* How long can the time interval be?
|
||||||
|
@ -42,7 +43,8 @@ class ShiftsFilter {
|
||||||
|
|
||||||
private $endTime = null;
|
private $endTime = null;
|
||||||
|
|
||||||
public function __construct($user_shifts_admin, $rooms, $types) {
|
public function __construct($user_shifts_admin, $rooms, $types)
|
||||||
|
{
|
||||||
$this->user_shifts_admin = $user_shifts_admin;
|
$this->user_shifts_admin = $user_shifts_admin;
|
||||||
$this->rooms = $rooms;
|
$this->rooms = $rooms;
|
||||||
$this->types = $types;
|
$this->types = $types;
|
||||||
|
@ -56,26 +58,31 @@ class ShiftsFilter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getStartTime() {
|
public function getStartTime()
|
||||||
|
{
|
||||||
return $this->startTime;
|
return $this->startTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setStartTime($startTime) {
|
public function setStartTime($startTime)
|
||||||
|
{
|
||||||
$this->startTime = $startTime;
|
$this->startTime = $startTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getEndTime() {
|
public function getEndTime()
|
||||||
|
{
|
||||||
return $this->endTime;
|
return $this->endTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setEndTime($endTime) {
|
public function setEndTime($endTime)
|
||||||
|
{
|
||||||
if ($endTime - $this->startTime > ShiftsFilter::MAX_DURATION) {
|
if ($endTime - $this->startTime > ShiftsFilter::MAX_DURATION) {
|
||||||
$endTime = $this->startTime + ShiftsFilter::MAX_DURATION;
|
$endTime = $this->startTime + ShiftsFilter::MAX_DURATION;
|
||||||
}
|
}
|
||||||
$this->endTime = $endTime;
|
$this->endTime = $endTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTypes() {
|
public function getTypes()
|
||||||
|
{
|
||||||
if (count($this->types) == 0) {
|
if (count($this->types) == 0) {
|
||||||
return [
|
return [
|
||||||
0
|
0
|
||||||
|
@ -84,11 +91,13 @@ class ShiftsFilter {
|
||||||
return $this->types;
|
return $this->types;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setTypes($types) {
|
public function setTypes($types)
|
||||||
|
{
|
||||||
$this->types = $types;
|
$this->types = $types;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getRooms() {
|
public function getRooms()
|
||||||
|
{
|
||||||
if (count($this->rooms) == 0) {
|
if (count($this->rooms) == 0) {
|
||||||
return [
|
return [
|
||||||
0
|
0
|
||||||
|
@ -97,25 +106,28 @@ class ShiftsFilter {
|
||||||
return $this->rooms;
|
return $this->rooms;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setRooms($rooms) {
|
public function setRooms($rooms)
|
||||||
|
{
|
||||||
$this->rooms = $rooms;
|
$this->rooms = $rooms;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isUserShiftsAdmin() {
|
public function isUserShiftsAdmin()
|
||||||
|
{
|
||||||
return $this->userShiftsAdmin;
|
return $this->userShiftsAdmin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setUserShiftsAdmin($userShiftsAdmin) {
|
public function setUserShiftsAdmin($userShiftsAdmin)
|
||||||
|
{
|
||||||
$this->userShiftsAdmin = $userShiftsAdmin;
|
$this->userShiftsAdmin = $userShiftsAdmin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFilled() {
|
public function getFilled()
|
||||||
|
{
|
||||||
return $this->filled;
|
return $this->filled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setFilled($filled) {
|
public function setFilled($filled)
|
||||||
|
{
|
||||||
$this->filled = $filled;
|
$this->filled = $filled;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
|
@ -2,7 +2,8 @@
|
||||||
use Engelsystem\ShiftsFilter;
|
use Engelsystem\ShiftsFilter;
|
||||||
use Engelsystem\ShiftSignupState;
|
use Engelsystem\ShiftSignupState;
|
||||||
|
|
||||||
function Shifts_by_room($room) {
|
function Shifts_by_room($room)
|
||||||
|
{
|
||||||
$result = sql_select("SELECT * FROM `Shifts` WHERE `RID`=" . sql_escape($room['RID']) . " ORDER BY `start`");
|
$result = sql_select("SELECT * FROM `Shifts` WHERE `RID`=" . sql_escape($room['RID']) . " ORDER BY `start`");
|
||||||
if ($result === false) {
|
if ($result === false) {
|
||||||
engelsystem_error("Unable to load shifts.");
|
engelsystem_error("Unable to load shifts.");
|
||||||
|
@ -10,7 +11,8 @@ function Shifts_by_room($room) {
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function Shifts_by_ShiftsFilter(ShiftsFilter $shiftsFilter) {
|
function Shifts_by_ShiftsFilter(ShiftsFilter $shiftsFilter)
|
||||||
|
{
|
||||||
$SQL = "SELECT * FROM (
|
$SQL = "SELECT * FROM (
|
||||||
SELECT DISTINCT `Shifts`.*, `ShiftTypes`.`name`, `Room`.`Name` as `room_name`
|
SELECT DISTINCT `Shifts`.*, `ShiftTypes`.`name`, `Room`.`Name` as `room_name`
|
||||||
FROM `Shifts`
|
FROM `Shifts`
|
||||||
|
@ -44,7 +46,8 @@ function Shifts_by_ShiftsFilter(ShiftsFilter $shiftsFilter) {
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function NeededAngeltypes_by_ShiftsFilter(ShiftsFilter $shiftsFilter) {
|
function NeededAngeltypes_by_ShiftsFilter(ShiftsFilter $shiftsFilter)
|
||||||
|
{
|
||||||
$SQL = "SELECT `NeededAngelTypes`.*, `Shifts`.`SID`, `AngelTypes`.`id`, `AngelTypes`.`name`, `AngelTypes`.`restricted`, `AngelTypes`.`no_self_signup`
|
$SQL = "SELECT `NeededAngelTypes`.*, `Shifts`.`SID`, `AngelTypes`.`id`, `AngelTypes`.`name`, `AngelTypes`.`restricted`, `AngelTypes`.`no_self_signup`
|
||||||
FROM `Shifts`
|
FROM `Shifts`
|
||||||
JOIN `NeededAngelTypes` ON `NeededAngelTypes`.`shift_id`=`Shifts`.`SID`
|
JOIN `NeededAngelTypes` ON `NeededAngelTypes`.`shift_id`=`Shifts`.`SID`
|
||||||
|
@ -69,7 +72,8 @@ function NeededAngeltypes_by_ShiftsFilter(ShiftsFilter $shiftsFilter) {
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function NeededAngeltype_by_Shift_and_Angeltype($shift, $angeltype) {
|
function NeededAngeltype_by_Shift_and_Angeltype($shift, $angeltype)
|
||||||
|
{
|
||||||
$result = sql_select("SELECT `NeededAngelTypes`.*, `Shifts`.`SID`, `AngelTypes`.`id`, `AngelTypes`.`name`, `AngelTypes`.`restricted`, `AngelTypes`.`no_self_signup`
|
$result = sql_select("SELECT `NeededAngelTypes`.*, `Shifts`.`SID`, `AngelTypes`.`id`, `AngelTypes`.`name`, `AngelTypes`.`restricted`, `AngelTypes`.`no_self_signup`
|
||||||
FROM `Shifts`
|
FROM `Shifts`
|
||||||
JOIN `NeededAngelTypes` ON `NeededAngelTypes`.`shift_id`=`Shifts`.`SID`
|
JOIN `NeededAngelTypes` ON `NeededAngelTypes`.`shift_id`=`Shifts`.`SID`
|
||||||
|
@ -96,7 +100,8 @@ function NeededAngeltype_by_Shift_and_Angeltype($shift, $angeltype) {
|
||||||
return $result[0];
|
return $result[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
function ShiftEntries_by_ShiftsFilter(ShiftsFilter $shiftsFilter) {
|
function ShiftEntries_by_ShiftsFilter(ShiftsFilter $shiftsFilter)
|
||||||
|
{
|
||||||
$SQL = "SELECT `User`.`Nick`, `User`.`email`, `User`.`email_shiftinfo`, `User`.`Sprache`, `User`.`Gekommen`, `ShiftEntry`.`UID`, `ShiftEntry`.`TID`, `ShiftEntry`.`SID`, `ShiftEntry`.`Comment`, `ShiftEntry`.`freeloaded`
|
$SQL = "SELECT `User`.`Nick`, `User`.`email`, `User`.`email_shiftinfo`, `User`.`Sprache`, `User`.`Gekommen`, `ShiftEntry`.`UID`, `ShiftEntry`.`TID`, `ShiftEntry`.`SID`, `ShiftEntry`.`Comment`, `ShiftEntry`.`freeloaded`
|
||||||
FROM `Shifts`
|
FROM `Shifts`
|
||||||
JOIN `ShiftEntry` ON `ShiftEntry`.`SID`=`Shifts`.`SID`
|
JOIN `ShiftEntry` ON `ShiftEntry`.`SID`=`Shifts`.`SID`
|
||||||
|
@ -117,7 +122,8 @@ function ShiftEntries_by_ShiftsFilter(ShiftsFilter $shiftsFilter) {
|
||||||
* @param Shift $shift
|
* @param Shift $shift
|
||||||
* @param array<Shift> $shifts
|
* @param array<Shift> $shifts
|
||||||
*/
|
*/
|
||||||
function Shift_collides($shift, $shifts) {
|
function Shift_collides($shift, $shifts)
|
||||||
|
{
|
||||||
foreach ($shifts as $other_shift) {
|
foreach ($shifts as $other_shift) {
|
||||||
if ($shift['SID'] != $other_shift['SID']) {
|
if ($shift['SID'] != $other_shift['SID']) {
|
||||||
if (! ($shift['start'] >= $other_shift['end'] || $shift['end'] <= $other_shift['start'])) {
|
if (! ($shift['start'] >= $other_shift['end'] || $shift['end'] <= $other_shift['start'])) {
|
||||||
|
@ -131,7 +137,8 @@ function Shift_collides($shift, $shifts) {
|
||||||
/**
|
/**
|
||||||
* Returns the number of needed angels/free shift entries for an angeltype.
|
* Returns the number of needed angels/free shift entries for an angeltype.
|
||||||
*/
|
*/
|
||||||
function Shift_free_entries($needed_angeltype, $shift_entries) {
|
function Shift_free_entries($needed_angeltype, $shift_entries)
|
||||||
|
{
|
||||||
$taken = 0;
|
$taken = 0;
|
||||||
foreach ($shift_entries as $shift_entry) {
|
foreach ($shift_entries as $shift_entry) {
|
||||||
if ($shift_entry['freeloaded'] == 0) {
|
if ($shift_entry['freeloaded'] == 0) {
|
||||||
|
@ -153,7 +160,8 @@ function Shift_free_entries($needed_angeltype, $shift_entries) {
|
||||||
* @param boolean $angeltype_supporter
|
* @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.
|
* True, if the user has angeltype supporter rights for the angeltype, which enables him to sign somebody up for the shift.
|
||||||
*/
|
*/
|
||||||
function Shift_signup_allowed_angel($user, $shift, $angeltype, $user_angeltype, $user_shifts, $needed_angeltype, $shift_entries) {
|
function Shift_signup_allowed_angel($user, $shift, $angeltype, $user_angeltype, $user_shifts, $needed_angeltype, $shift_entries)
|
||||||
|
{
|
||||||
$free_entries = Shift_free_entries($needed_angeltype, $shift_entries);
|
$free_entries = Shift_free_entries($needed_angeltype, $shift_entries);
|
||||||
|
|
||||||
if ($user['Gekommen'] == 0) {
|
if ($user['Gekommen'] == 0) {
|
||||||
|
@ -210,7 +218,8 @@ function Shift_signup_allowed_angel($user, $shift, $angeltype, $user_angeltype,
|
||||||
/**
|
/**
|
||||||
* Check if an angeltype supporter can sign up a user to a shift.
|
* Check if an angeltype supporter can sign up a user to a shift.
|
||||||
*/
|
*/
|
||||||
function Shift_signup_allowed_angeltype_supporter($angeltype, $needed_angeltype, $shift_entries) {
|
function Shift_signup_allowed_angeltype_supporter($angeltype, $needed_angeltype, $shift_entries)
|
||||||
|
{
|
||||||
$free_entries = Shift_free_entries($needed_angeltype, $shift_entries);
|
$free_entries = Shift_free_entries($needed_angeltype, $shift_entries);
|
||||||
if ($free_entries == 0) {
|
if ($free_entries == 0) {
|
||||||
return new ShiftSignupState(ShiftSignupState::OCCUPIED, $free_entries);
|
return new ShiftSignupState(ShiftSignupState::OCCUPIED, $free_entries);
|
||||||
|
@ -227,7 +236,8 @@ function Shift_signup_allowed_angeltype_supporter($angeltype, $needed_angeltype,
|
||||||
* @param AngelType $angeltype
|
* @param AngelType $angeltype
|
||||||
* The angeltype to which the user wants to sign up
|
* The angeltype to which the user wants to sign up
|
||||||
*/
|
*/
|
||||||
function Shift_signup_allowed_admin($angeltype, $needed_angeltype, $shift_entries) {
|
function Shift_signup_allowed_admin($angeltype, $needed_angeltype, $shift_entries)
|
||||||
|
{
|
||||||
$free_entries = Shift_free_entries($needed_angeltype, $shift_entries);
|
$free_entries = Shift_free_entries($needed_angeltype, $shift_entries);
|
||||||
|
|
||||||
if ($free_entries == 0) {
|
if ($free_entries == 0) {
|
||||||
|
@ -248,7 +258,8 @@ function Shift_signup_allowed_admin($angeltype, $needed_angeltype, $shift_entrie
|
||||||
* @param array<Shift> $user_shifts
|
* @param array<Shift> $user_shifts
|
||||||
* List of the users shifts
|
* List of the users shifts
|
||||||
*/
|
*/
|
||||||
function Shift_signup_allowed($signup_user, $shift, $angeltype, $user_angeltype = null, $user_shifts = null, $needed_angeltype, $shift_entries) {
|
function Shift_signup_allowed($signup_user, $shift, $angeltype, $user_angeltype = null, $user_shifts = null, $needed_angeltype, $shift_entries)
|
||||||
|
{
|
||||||
global $user, $privileges;
|
global $user, $privileges;
|
||||||
|
|
||||||
if (in_array('user_shifts_admin', $privileges)) {
|
if (in_array('user_shifts_admin', $privileges)) {
|
||||||
|
@ -265,14 +276,16 @@ function Shift_signup_allowed($signup_user, $shift, $angeltype, $user_angeltype
|
||||||
/**
|
/**
|
||||||
* Delete a shift by its external id.
|
* Delete a shift by its external id.
|
||||||
*/
|
*/
|
||||||
function Shift_delete_by_psid($shift_psid) {
|
function Shift_delete_by_psid($shift_psid)
|
||||||
|
{
|
||||||
return sql_query("DELETE FROM `Shifts` WHERE `PSID`='" . sql_escape($shift_psid) . "'");
|
return sql_query("DELETE FROM `Shifts` WHERE `PSID`='" . sql_escape($shift_psid) . "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a shift.
|
* Delete a shift.
|
||||||
*/
|
*/
|
||||||
function Shift_delete($shift_id) {
|
function Shift_delete($shift_id)
|
||||||
|
{
|
||||||
mail_shift_delete(Shift($shift_id));
|
mail_shift_delete(Shift($shift_id));
|
||||||
|
|
||||||
$result = sql_query("DELETE FROM `Shifts` WHERE `SID`='" . sql_escape($shift_id) . "'");
|
$result = sql_query("DELETE FROM `Shifts` WHERE `SID`='" . sql_escape($shift_id) . "'");
|
||||||
|
@ -285,7 +298,8 @@ function Shift_delete($shift_id) {
|
||||||
/**
|
/**
|
||||||
* Update a shift.
|
* Update a shift.
|
||||||
*/
|
*/
|
||||||
function Shift_update($shift) {
|
function Shift_update($shift)
|
||||||
|
{
|
||||||
global $user;
|
global $user;
|
||||||
$shift['name'] = ShiftType($shift['shifttype_id'])['name'];
|
$shift['name'] = ShiftType($shift['shifttype_id'])['name'];
|
||||||
mail_shift_change(Shift($shift['SID']), $shift);
|
mail_shift_change(Shift($shift['SID']), $shift);
|
||||||
|
@ -306,7 +320,8 @@ function Shift_update($shift) {
|
||||||
/**
|
/**
|
||||||
* Update a shift by its external id.
|
* Update a shift by its external id.
|
||||||
*/
|
*/
|
||||||
function Shift_update_by_psid($shift) {
|
function Shift_update_by_psid($shift)
|
||||||
|
{
|
||||||
$shift_source = sql_select("SELECT `SID` FROM `Shifts` WHERE `PSID`=" . $shift['PSID']);
|
$shift_source = sql_select("SELECT `SID` FROM `Shifts` WHERE `PSID`=" . $shift['PSID']);
|
||||||
if ($shift_source === false) {
|
if ($shift_source === false) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -323,7 +338,8 @@ function Shift_update_by_psid($shift) {
|
||||||
*
|
*
|
||||||
* @return new shift id or false
|
* @return new shift id or false
|
||||||
*/
|
*/
|
||||||
function Shift_create($shift) {
|
function Shift_create($shift)
|
||||||
|
{
|
||||||
global $user;
|
global $user;
|
||||||
$result = sql_query("INSERT INTO `Shifts` SET
|
$result = sql_query("INSERT INTO `Shifts` SET
|
||||||
`shifttype_id`='" . sql_escape($shift['shifttype_id']) . "',
|
`shifttype_id`='" . sql_escape($shift['shifttype_id']) . "',
|
||||||
|
@ -344,7 +360,8 @@ function Shift_create($shift) {
|
||||||
/**
|
/**
|
||||||
* Return users shifts.
|
* Return users shifts.
|
||||||
*/
|
*/
|
||||||
function Shifts_by_user($user, $include_freeload_comments = false) {
|
function Shifts_by_user($user, $include_freeload_comments = false)
|
||||||
|
{
|
||||||
$result = sql_select("
|
$result = sql_select("
|
||||||
SELECT `ShiftTypes`.`id` as `shifttype_id`, `ShiftTypes`.`name`,
|
SELECT `ShiftTypes`.`id` as `shifttype_id`, `ShiftTypes`.`name`,
|
||||||
`ShiftEntry`.`id`, `ShiftEntry`.`SID`, `ShiftEntry`.`TID`, `ShiftEntry`.`UID`, `ShiftEntry`.`freeloaded`, `ShiftEntry`.`Comment`,
|
`ShiftEntry`.`id`, `ShiftEntry`.`SID`, `ShiftEntry`.`TID`, `ShiftEntry`.`UID`, `ShiftEntry`.`freeloaded`, `ShiftEntry`.`Comment`,
|
||||||
|
@ -369,7 +386,8 @@ function Shifts_by_user($user, $include_freeload_comments = false) {
|
||||||
* @param $shift_id Shift
|
* @param $shift_id Shift
|
||||||
* ID
|
* ID
|
||||||
*/
|
*/
|
||||||
function Shift($shift_id) {
|
function Shift($shift_id)
|
||||||
|
{
|
||||||
$shifts_source = sql_select("
|
$shifts_source = sql_select("
|
||||||
SELECT `Shifts`.*, `ShiftTypes`.`name`
|
SELECT `Shifts`.*, `ShiftTypes`.`name`
|
||||||
FROM `Shifts`
|
FROM `Shifts`
|
||||||
|
@ -406,7 +424,8 @@ function Shift($shift_id) {
|
||||||
/**
|
/**
|
||||||
* Returns all shifts with needed angeltypes and count of subscribed jobs.
|
* Returns all shifts with needed angeltypes and count of subscribed jobs.
|
||||||
*/
|
*/
|
||||||
function Shifts() {
|
function Shifts()
|
||||||
|
{
|
||||||
$shifts_source = sql_select("
|
$shifts_source = sql_select("
|
||||||
SELECT `ShiftTypes`.`name`, `Shifts`.*, `Room`.`RID`, `Room`.`Name` as `room_name`
|
SELECT `ShiftTypes`.`name`, `Shifts`.*, `Room`.`RID`, `Room`.`Name` as `room_name`
|
||||||
FROM `Shifts`
|
FROM `Shifts`
|
||||||
|
@ -428,5 +447,3 @@ function Shifts() {
|
||||||
|
|
||||||
return $shifts_source;
|
return $shifts_source;
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
|
@ -13,7 +13,8 @@
|
||||||
* The angeltype to be checked
|
* The angeltype to be checked
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function UserAngelType_exists($user, $angeltype) {
|
function UserAngelType_exists($user, $angeltype)
|
||||||
|
{
|
||||||
return sql_num_query("
|
return sql_num_query("
|
||||||
SELECT `id`
|
SELECT `id`
|
||||||
FROM `UserAngelTypes`
|
FROM `UserAngelTypes`
|
||||||
|
@ -27,7 +28,8 @@ function UserAngelType_exists($user, $angeltype) {
|
||||||
*
|
*
|
||||||
* @param User $user
|
* @param User $user
|
||||||
*/
|
*/
|
||||||
function User_angeltypes($user) {
|
function User_angeltypes($user)
|
||||||
|
{
|
||||||
$result = sql_select("
|
$result = sql_select("
|
||||||
SELECT `AngelTypes`.*, `UserAngelTypes`.`confirm_user_id`, `UserAngelTypes`.`supporter`
|
SELECT `AngelTypes`.*, `UserAngelTypes`.`confirm_user_id`, `UserAngelTypes`.`supporter`
|
||||||
FROM `UserAngelTypes`
|
FROM `UserAngelTypes`
|
||||||
|
@ -46,7 +48,8 @@ function User_angeltypes($user) {
|
||||||
*
|
*
|
||||||
* @param User $user
|
* @param User $user
|
||||||
*/
|
*/
|
||||||
function User_unconfirmed_AngelTypes($user) {
|
function User_unconfirmed_AngelTypes($user)
|
||||||
|
{
|
||||||
$result = sql_select("
|
$result = sql_select("
|
||||||
SELECT
|
SELECT
|
||||||
`UserAngelTypes`.*,
|
`UserAngelTypes`.*,
|
||||||
|
@ -73,7 +76,8 @@ function User_unconfirmed_AngelTypes($user) {
|
||||||
* @param User $user
|
* @param User $user
|
||||||
* @param AngelType $angeltype
|
* @param AngelType $angeltype
|
||||||
*/
|
*/
|
||||||
function User_is_AngelType_supporter(&$user, $angeltype) {
|
function User_is_AngelType_supporter(&$user, $angeltype)
|
||||||
|
{
|
||||||
if (!isset($user['privileges'])) {
|
if (!isset($user['privileges'])) {
|
||||||
$user['privileges'] = privileges_for_user($user['UID']);
|
$user['privileges'] = privileges_for_user($user['UID']);
|
||||||
}
|
}
|
||||||
|
@ -92,7 +96,8 @@ function User_is_AngelType_supporter(&$user, $angeltype) {
|
||||||
* @param int $user_angeltype_id
|
* @param int $user_angeltype_id
|
||||||
* @param bool $supporter
|
* @param bool $supporter
|
||||||
*/
|
*/
|
||||||
function UserAngelType_update($user_angeltype_id, $supporter) {
|
function UserAngelType_update($user_angeltype_id, $supporter)
|
||||||
|
{
|
||||||
$result = sql_query("
|
$result = sql_query("
|
||||||
UPDATE `UserAngelTypes`
|
UPDATE `UserAngelTypes`
|
||||||
SET `supporter`=" . sql_bool($supporter) . "
|
SET `supporter`=" . sql_bool($supporter) . "
|
||||||
|
@ -109,7 +114,8 @@ function UserAngelType_update($user_angeltype_id, $supporter) {
|
||||||
*
|
*
|
||||||
* @param int $angeltype_id
|
* @param int $angeltype_id
|
||||||
*/
|
*/
|
||||||
function UserAngelTypes_delete_all($angeltype_id) {
|
function UserAngelTypes_delete_all($angeltype_id)
|
||||||
|
{
|
||||||
$result = sql_query("
|
$result = sql_query("
|
||||||
DELETE FROM `UserAngelTypes`
|
DELETE FROM `UserAngelTypes`
|
||||||
WHERE `angeltype_id`='" . sql_escape($angeltype_id) . "'
|
WHERE `angeltype_id`='" . sql_escape($angeltype_id) . "'
|
||||||
|
@ -126,7 +132,8 @@ function UserAngelTypes_delete_all($angeltype_id) {
|
||||||
* @param int $angeltype_id
|
* @param int $angeltype_id
|
||||||
* @param User $confirm_user
|
* @param User $confirm_user
|
||||||
*/
|
*/
|
||||||
function UserAngelTypes_confirm_all($angeltype_id, $confirm_user) {
|
function UserAngelTypes_confirm_all($angeltype_id, $confirm_user)
|
||||||
|
{
|
||||||
$result = sql_query("
|
$result = sql_query("
|
||||||
UPDATE `UserAngelTypes`
|
UPDATE `UserAngelTypes`
|
||||||
SET `confirm_user_id`='" . sql_escape($confirm_user['UID']) . "'
|
SET `confirm_user_id`='" . sql_escape($confirm_user['UID']) . "'
|
||||||
|
@ -144,7 +151,8 @@ function UserAngelTypes_confirm_all($angeltype_id, $confirm_user) {
|
||||||
* @param int $user_angeltype_id
|
* @param int $user_angeltype_id
|
||||||
* @param User $confirm_user
|
* @param User $confirm_user
|
||||||
*/
|
*/
|
||||||
function UserAngelType_confirm($user_angeltype_id, $confirm_user) {
|
function UserAngelType_confirm($user_angeltype_id, $confirm_user)
|
||||||
|
{
|
||||||
$result = sql_query("
|
$result = sql_query("
|
||||||
UPDATE `UserAngelTypes`
|
UPDATE `UserAngelTypes`
|
||||||
SET `confirm_user_id`='" . sql_escape($confirm_user['UID']) . "'
|
SET `confirm_user_id`='" . sql_escape($confirm_user['UID']) . "'
|
||||||
|
@ -161,7 +169,8 @@ function UserAngelType_confirm($user_angeltype_id, $confirm_user) {
|
||||||
*
|
*
|
||||||
* @param UserAngelType $user_angeltype
|
* @param UserAngelType $user_angeltype
|
||||||
*/
|
*/
|
||||||
function UserAngelType_delete($user_angeltype) {
|
function UserAngelType_delete($user_angeltype)
|
||||||
|
{
|
||||||
return sql_query("
|
return sql_query("
|
||||||
DELETE FROM `UserAngelTypes`
|
DELETE FROM `UserAngelTypes`
|
||||||
WHERE `id`='" . sql_escape($user_angeltype['id']) . "'
|
WHERE `id`='" . sql_escape($user_angeltype['id']) . "'
|
||||||
|
@ -174,7 +183,8 @@ function UserAngelType_delete($user_angeltype) {
|
||||||
* @param User $user
|
* @param User $user
|
||||||
* @param Angeltype $angeltype
|
* @param Angeltype $angeltype
|
||||||
*/
|
*/
|
||||||
function UserAngelType_create($user, $angeltype) {
|
function UserAngelType_create($user, $angeltype)
|
||||||
|
{
|
||||||
$result = sql_query("
|
$result = sql_query("
|
||||||
INSERT INTO `UserAngelTypes` SET
|
INSERT INTO `UserAngelTypes` SET
|
||||||
`user_id`='" . sql_escape($user['UID']) . "',
|
`user_id`='" . sql_escape($user['UID']) . "',
|
||||||
|
@ -190,7 +200,8 @@ function UserAngelType_create($user, $angeltype) {
|
||||||
*
|
*
|
||||||
* @param int $user_angeltype_id
|
* @param int $user_angeltype_id
|
||||||
*/
|
*/
|
||||||
function UserAngelType($user_angeltype_id) {
|
function UserAngelType($user_angeltype_id)
|
||||||
|
{
|
||||||
$angeltype = sql_select("
|
$angeltype = sql_select("
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM `UserAngelTypes`
|
FROM `UserAngelTypes`
|
||||||
|
@ -211,7 +222,8 @@ function UserAngelType($user_angeltype_id) {
|
||||||
* @param User $user
|
* @param User $user
|
||||||
* @param Angeltype $angeltype
|
* @param Angeltype $angeltype
|
||||||
*/
|
*/
|
||||||
function UserAngelType_by_User_and_AngelType($user, $angeltype) {
|
function UserAngelType_by_User_and_AngelType($user, $angeltype)
|
||||||
|
{
|
||||||
$angeltype = sql_select("
|
$angeltype = sql_select("
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM `UserAngelTypes`
|
FROM `UserAngelTypes`
|
||||||
|
@ -226,4 +238,3 @@ function UserAngelType_by_User_and_AngelType($user, $angeltype) {
|
||||||
}
|
}
|
||||||
return $angeltype[0];
|
return $angeltype[0];
|
||||||
}
|
}
|
||||||
?>
|
|
|
@ -4,7 +4,8 @@
|
||||||
* Returns a new empty UserDriverLicense
|
* Returns a new empty UserDriverLicense
|
||||||
* FIXME entity object needed
|
* FIXME entity object needed
|
||||||
*/
|
*/
|
||||||
function UserDriverLicense_new() {
|
function UserDriverLicense_new()
|
||||||
|
{
|
||||||
return [
|
return [
|
||||||
'user_id' => null,
|
'user_id' => null,
|
||||||
'has_car' => false,
|
'has_car' => false,
|
||||||
|
@ -23,7 +24,8 @@ function UserDriverLicense_new() {
|
||||||
* The UserDriverLicense to check
|
* The UserDriverLicense to check
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function UserDriverLicense_valid($user_driver_license) {
|
function UserDriverLicense_valid($user_driver_license)
|
||||||
|
{
|
||||||
return $user_driver_license['has_car'] || $user_driver_license['has_license_car'] || $user_driver_license['has_license_3_5t_transporter'] || $user_driver_license['has_license_7_5t_truck'] || $user_driver_license['has_license_12_5t_truck'] || $user_driver_license['has_license_forklift'];
|
return $user_driver_license['has_car'] || $user_driver_license['has_license_car'] || $user_driver_license['has_license_3_5t_transporter'] || $user_driver_license['has_license_7_5t_truck'] || $user_driver_license['has_license_12_5t_truck'] || $user_driver_license['has_license_forklift'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,7 +35,8 @@ function UserDriverLicense_valid($user_driver_license) {
|
||||||
* @param int $user_id
|
* @param int $user_id
|
||||||
* The users id
|
* The users id
|
||||||
*/
|
*/
|
||||||
function UserDriverLicense($user_id) {
|
function UserDriverLicense($user_id)
|
||||||
|
{
|
||||||
$user_driver_license = sql_select("SELECT * FROM `UserDriverLicenses` WHERE `user_id`='" . sql_escape($user_id) . "'");
|
$user_driver_license = sql_select("SELECT * FROM `UserDriverLicenses` WHERE `user_id`='" . sql_escape($user_id) . "'");
|
||||||
if ($user_driver_license === false) {
|
if ($user_driver_license === false) {
|
||||||
engelsystem_error('Unable to load user driver license.');
|
engelsystem_error('Unable to load user driver license.');
|
||||||
|
@ -51,7 +54,8 @@ function UserDriverLicense($user_id) {
|
||||||
* @param UserDriverLicense $user_driver_license
|
* @param UserDriverLicense $user_driver_license
|
||||||
* The UserDriverLicense to create
|
* The UserDriverLicense to create
|
||||||
*/
|
*/
|
||||||
function UserDriverLicenses_create($user_driver_license, $user) {
|
function UserDriverLicenses_create($user_driver_license, $user)
|
||||||
|
{
|
||||||
$user_driver_license['user_id'] = $user['UID'];
|
$user_driver_license['user_id'] = $user['UID'];
|
||||||
$result = sql_query("
|
$result = sql_query("
|
||||||
INSERT INTO `UserDriverLicenses` SET
|
INSERT INTO `UserDriverLicenses` SET
|
||||||
|
@ -74,7 +78,8 @@ function UserDriverLicenses_create($user_driver_license, $user) {
|
||||||
* @param UserDriverLicense $user_driver_license
|
* @param UserDriverLicense $user_driver_license
|
||||||
* The UserDriverLicense to update
|
* The UserDriverLicense to update
|
||||||
*/
|
*/
|
||||||
function UserDriverLicenses_update($user_driver_license) {
|
function UserDriverLicenses_update($user_driver_license)
|
||||||
|
{
|
||||||
$result = sql_query("UPDATE `UserDriverLicenses` SET
|
$result = sql_query("UPDATE `UserDriverLicenses` SET
|
||||||
`has_car`=" . sql_bool($user_driver_license['has_car']) . ",
|
`has_car`=" . sql_bool($user_driver_license['has_car']) . ",
|
||||||
`has_license_car`=" . sql_bool($user_driver_license['has_license_car']) . ",
|
`has_license_car`=" . sql_bool($user_driver_license['has_license_car']) . ",
|
||||||
|
@ -94,11 +99,11 @@ function UserDriverLicenses_update($user_driver_license) {
|
||||||
*
|
*
|
||||||
* @param int $user_id
|
* @param int $user_id
|
||||||
*/
|
*/
|
||||||
function UserDriverLicenses_delete($user_id) {
|
function UserDriverLicenses_delete($user_id)
|
||||||
|
{
|
||||||
$result = sql_query("DELETE FROM `UserDriverLicenses` WHERE `user_id`=" . sql_escape($user_id));
|
$result = sql_query("DELETE FROM `UserDriverLicenses` WHERE `user_id`=" . sql_escape($user_id));
|
||||||
if ($result === false) {
|
if ($result === false) {
|
||||||
engelsystem_error("Unable to remove user driver license information");
|
engelsystem_error("Unable to remove user driver license information");
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
?>
|
|
|
@ -4,7 +4,8 @@
|
||||||
* Returns users groups
|
* Returns users groups
|
||||||
* @param User $user
|
* @param User $user
|
||||||
*/
|
*/
|
||||||
function User_groups($user) {
|
function User_groups($user)
|
||||||
|
{
|
||||||
return sql_select("
|
return sql_select("
|
||||||
SELECT `Groups`.*
|
SELECT `Groups`.*
|
||||||
FROM `UserGroups`
|
FROM `UserGroups`
|
||||||
|
@ -13,5 +14,3 @@ function User_groups($user) {
|
||||||
ORDER BY `UserGroups`.`group_id`
|
ORDER BY `UserGroups`.`group_id`
|
||||||
");
|
");
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
|
@ -10,7 +10,8 @@ use Engelsystem\ValidationResult;
|
||||||
*
|
*
|
||||||
* @param int $user_id
|
* @param int $user_id
|
||||||
*/
|
*/
|
||||||
function User_delete($user_id) {
|
function User_delete($user_id)
|
||||||
|
{
|
||||||
return sql_query("DELETE FROM `User` WHERE `UID`='" . sql_escape($user_id) . "'");
|
return sql_query("DELETE FROM `User` WHERE `UID`='" . sql_escape($user_id) . "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +20,8 @@ function User_delete($user_id) {
|
||||||
*
|
*
|
||||||
* @param User $user
|
* @param User $user
|
||||||
*/
|
*/
|
||||||
function User_update($user) {
|
function User_update($user)
|
||||||
|
{
|
||||||
return sql_query("UPDATE `User` SET
|
return sql_query("UPDATE `User` SET
|
||||||
`Nick`='" . sql_escape($user['Nick']) . "',
|
`Nick`='" . sql_escape($user['Nick']) . "',
|
||||||
`Name`='" . sql_escape($user['Name']) . "',
|
`Name`='" . sql_escape($user['Name']) . "',
|
||||||
|
@ -50,30 +52,36 @@ function User_update($user) {
|
||||||
/**
|
/**
|
||||||
* Counts all forced active users.
|
* Counts all forced active users.
|
||||||
*/
|
*/
|
||||||
function User_force_active_count() {
|
function User_force_active_count()
|
||||||
|
{
|
||||||
return sql_select_single_cell("SELECT COUNT(*) FROM `User` WHERE `force_active` = 1");
|
return sql_select_single_cell("SELECT COUNT(*) FROM `User` WHERE `force_active` = 1");
|
||||||
}
|
}
|
||||||
|
|
||||||
function User_active_count() {
|
function User_active_count()
|
||||||
|
{
|
||||||
return sql_select_single_cell("SELECT COUNT(*) FROM `User` WHERE `Aktiv` = 1");
|
return sql_select_single_cell("SELECT COUNT(*) FROM `User` WHERE `Aktiv` = 1");
|
||||||
}
|
}
|
||||||
|
|
||||||
function User_got_voucher_count() {
|
function User_got_voucher_count()
|
||||||
|
{
|
||||||
return sql_select_single_cell("SELECT SUM(`got_voucher`) FROM `User`");
|
return sql_select_single_cell("SELECT SUM(`got_voucher`) FROM `User`");
|
||||||
}
|
}
|
||||||
|
|
||||||
function User_arrived_count() {
|
function User_arrived_count()
|
||||||
|
{
|
||||||
return sql_select_single_cell("SELECT COUNT(*) FROM `User` WHERE `Gekommen` = 1");
|
return sql_select_single_cell("SELECT COUNT(*) FROM `User` WHERE `Gekommen` = 1");
|
||||||
}
|
}
|
||||||
|
|
||||||
function User_tshirts_count() {
|
function User_tshirts_count()
|
||||||
|
{
|
||||||
return sql_select_single_cell("SELECT COUNT(*) FROM `User` WHERE `Tshirt` = 1");
|
return sql_select_single_cell("SELECT COUNT(*) FROM `User` WHERE `Tshirt` = 1");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns all column names for sorting in an array.
|
* Returns all column names for sorting in an array.
|
||||||
*/
|
*/
|
||||||
function User_sortable_columns() {
|
function User_sortable_columns()
|
||||||
|
{
|
||||||
return [
|
return [
|
||||||
'Nick',
|
'Nick',
|
||||||
'Name',
|
'Name',
|
||||||
|
@ -95,7 +103,8 @@ function User_sortable_columns() {
|
||||||
*
|
*
|
||||||
* @param string $order_by
|
* @param string $order_by
|
||||||
*/
|
*/
|
||||||
function Users($order_by = 'Nick') {
|
function Users($order_by = 'Nick')
|
||||||
|
{
|
||||||
return sql_select("SELECT * FROM `User` ORDER BY `" . sql_escape($order_by) . "` ASC");
|
return sql_select("SELECT * FROM `User` ORDER BY `" . sql_escape($order_by) . "` ASC");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,7 +113,8 @@ function Users($order_by = 'Nick') {
|
||||||
*
|
*
|
||||||
* @param User $user
|
* @param User $user
|
||||||
*/
|
*/
|
||||||
function User_is_freeloader($user) {
|
function User_is_freeloader($user)
|
||||||
|
{
|
||||||
global $max_freeloadable_shifts, $user;
|
global $max_freeloadable_shifts, $user;
|
||||||
|
|
||||||
return count(ShiftEntries_freeloaded_by_user($user)) >= $max_freeloadable_shifts;
|
return count(ShiftEntries_freeloaded_by_user($user)) >= $max_freeloadable_shifts;
|
||||||
|
@ -115,7 +125,8 @@ function User_is_freeloader($user) {
|
||||||
*
|
*
|
||||||
* @param Angeltype $angeltype
|
* @param Angeltype $angeltype
|
||||||
*/
|
*/
|
||||||
function Users_by_angeltype_inverted($angeltype) {
|
function Users_by_angeltype_inverted($angeltype)
|
||||||
|
{
|
||||||
$result = sql_select("
|
$result = sql_select("
|
||||||
SELECT `User`.*
|
SELECT `User`.*
|
||||||
FROM `User`
|
FROM `User`
|
||||||
|
@ -133,7 +144,8 @@ function Users_by_angeltype_inverted($angeltype) {
|
||||||
*
|
*
|
||||||
* @param Angeltype $angeltype
|
* @param Angeltype $angeltype
|
||||||
*/
|
*/
|
||||||
function Users_by_angeltype($angeltype) {
|
function Users_by_angeltype($angeltype)
|
||||||
|
{
|
||||||
$result = sql_select("
|
$result = sql_select("
|
||||||
SELECT
|
SELECT
|
||||||
`User`.*,
|
`User`.*,
|
||||||
|
@ -155,7 +167,8 @@ function Users_by_angeltype($angeltype) {
|
||||||
/**
|
/**
|
||||||
* Returns User id array
|
* Returns User id array
|
||||||
*/
|
*/
|
||||||
function User_ids() {
|
function User_ids()
|
||||||
|
{
|
||||||
return sql_select("SELECT `UID` FROM `User`");
|
return sql_select("SELECT `UID` FROM `User`");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,7 +177,8 @@ function User_ids() {
|
||||||
*
|
*
|
||||||
* @param string $nick
|
* @param string $nick
|
||||||
*/
|
*/
|
||||||
function User_validate_Nick($nick) {
|
function User_validate_Nick($nick)
|
||||||
|
{
|
||||||
return preg_replace("/([^a-z0-9üöäß. _+*-]{1,})/ui", '', $nick);
|
return preg_replace("/([^a-z0-9üöäß. _+*-]{1,})/ui", '', $nick);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,7 +189,8 @@ function User_validate_Nick($nick) {
|
||||||
* The email address to validate
|
* The email address to validate
|
||||||
* @return ValidationResult
|
* @return ValidationResult
|
||||||
*/
|
*/
|
||||||
function User_validate_mail($mail) {
|
function User_validate_mail($mail)
|
||||||
|
{
|
||||||
$mail = strip_item($mail);
|
$mail = strip_item($mail);
|
||||||
return new ValidationResult(check_email($mail), $mail);
|
return new ValidationResult(check_email($mail), $mail);
|
||||||
}
|
}
|
||||||
|
@ -187,7 +202,8 @@ function User_validate_mail($mail) {
|
||||||
* Jabber-ID to validate
|
* Jabber-ID to validate
|
||||||
* @return ValidationResult
|
* @return ValidationResult
|
||||||
*/
|
*/
|
||||||
function User_validate_jabber($jabber) {
|
function User_validate_jabber($jabber)
|
||||||
|
{
|
||||||
$jabber = strip_item($jabber);
|
$jabber = strip_item($jabber);
|
||||||
if ($jabber == '') {
|
if ($jabber == '') {
|
||||||
// Empty is ok
|
// Empty is ok
|
||||||
|
@ -203,7 +219,8 @@ function User_validate_jabber($jabber) {
|
||||||
* Unix timestamp
|
* Unix timestamp
|
||||||
* @return ValidationResult
|
* @return ValidationResult
|
||||||
*/
|
*/
|
||||||
function User_validate_planned_arrival_date($planned_arrival_date) {
|
function User_validate_planned_arrival_date($planned_arrival_date)
|
||||||
|
{
|
||||||
if ($planned_arrival_date == null) {
|
if ($planned_arrival_date == null) {
|
||||||
// null is not okay
|
// null is not okay
|
||||||
return new ValidationResult(false, time());
|
return new ValidationResult(false, time());
|
||||||
|
@ -233,7 +250,8 @@ function User_validate_planned_arrival_date($planned_arrival_date) {
|
||||||
* Unix timestamp
|
* Unix timestamp
|
||||||
* @return ValidationResult
|
* @return ValidationResult
|
||||||
*/
|
*/
|
||||||
function User_validate_planned_departure_date($planned_arrival_date, $planned_departure_date) {
|
function User_validate_planned_departure_date($planned_arrival_date, $planned_departure_date)
|
||||||
|
{
|
||||||
if ($planned_departure_date == null) {
|
if ($planned_departure_date == null) {
|
||||||
// null is okay
|
// null is okay
|
||||||
return new ValidationResult(true, null);
|
return new ValidationResult(true, null);
|
||||||
|
@ -263,7 +281,8 @@ function User_validate_planned_departure_date($planned_arrival_date, $planned_de
|
||||||
*
|
*
|
||||||
* @param $user_id UID
|
* @param $user_id UID
|
||||||
*/
|
*/
|
||||||
function User($user_id) {
|
function User($user_id)
|
||||||
|
{
|
||||||
$user_source = sql_select("SELECT * FROM `User` WHERE `UID`='" . sql_escape($user_id) . "' LIMIT 1");
|
$user_source = sql_select("SELECT * FROM `User` WHERE `UID`='" . sql_escape($user_id) . "' LIMIT 1");
|
||||||
if ($user_source === false) {
|
if ($user_source === false) {
|
||||||
engelsystem_error("Unable to load user.");
|
engelsystem_error("Unable to load user.");
|
||||||
|
@ -281,7 +300,8 @@ function User($user_id) {
|
||||||
* User api key
|
* User api key
|
||||||
* @return Matching user, null or false on error
|
* @return Matching user, null or false on error
|
||||||
*/
|
*/
|
||||||
function User_by_api_key($api_key) {
|
function User_by_api_key($api_key)
|
||||||
|
{
|
||||||
$user = sql_select("SELECT * FROM `User` WHERE `api_key`='" . sql_escape($api_key) . "' LIMIT 1");
|
$user = sql_select("SELECT * FROM `User` WHERE `api_key`='" . sql_escape($api_key) . "' LIMIT 1");
|
||||||
if ($user === false) {
|
if ($user === false) {
|
||||||
engelsystem_error("Unable to find user by api key.");
|
engelsystem_error("Unable to find user by api key.");
|
||||||
|
@ -298,7 +318,8 @@ function User_by_api_key($api_key) {
|
||||||
* @param string $email
|
* @param string $email
|
||||||
* @return Matching user, null or false on error
|
* @return Matching user, null or false on error
|
||||||
*/
|
*/
|
||||||
function User_by_email($email) {
|
function User_by_email($email)
|
||||||
|
{
|
||||||
$user = sql_select("SELECT * FROM `User` WHERE `email`='" . sql_escape($email) . "' LIMIT 1");
|
$user = sql_select("SELECT * FROM `User` WHERE `email`='" . sql_escape($email) . "' LIMIT 1");
|
||||||
if ($user === false) {
|
if ($user === false) {
|
||||||
engelsystem_error("Unable to load user.");
|
engelsystem_error("Unable to load user.");
|
||||||
|
@ -315,7 +336,8 @@ function User_by_email($email) {
|
||||||
* @param string $token
|
* @param string $token
|
||||||
* @return Matching user, null or false on error
|
* @return Matching user, null or false on error
|
||||||
*/
|
*/
|
||||||
function User_by_password_recovery_token($token) {
|
function User_by_password_recovery_token($token)
|
||||||
|
{
|
||||||
$user = sql_select("SELECT * FROM `User` WHERE `password_recovery_token`='" . sql_escape($token) . "' LIMIT 1");
|
$user = sql_select("SELECT * FROM `User` WHERE `password_recovery_token`='" . sql_escape($token) . "' LIMIT 1");
|
||||||
if ($user === false) {
|
if ($user === false) {
|
||||||
engelsystem_error("Unable to load user.");
|
engelsystem_error("Unable to load user.");
|
||||||
|
@ -331,7 +353,8 @@ function User_by_password_recovery_token($token) {
|
||||||
*
|
*
|
||||||
* @param User $user
|
* @param User $user
|
||||||
*/
|
*/
|
||||||
function User_reset_api_key(&$user, $log = true) {
|
function User_reset_api_key(&$user, $log = true)
|
||||||
|
{
|
||||||
$user['api_key'] = md5($user['Nick'] . time() . rand());
|
$user['api_key'] = md5($user['Nick'] . time() . rand());
|
||||||
$result = sql_query("UPDATE `User` SET `api_key`='" . sql_escape($user['api_key']) . "' WHERE `UID`='" . sql_escape($user['UID']) . "' LIMIT 1");
|
$result = sql_query("UPDATE `User` SET `api_key`='" . sql_escape($user['api_key']) . "' WHERE `UID`='" . sql_escape($user['UID']) . "' LIMIT 1");
|
||||||
if ($result === false) {
|
if ($result === false) {
|
||||||
|
@ -347,7 +370,8 @@ function User_reset_api_key(&$user, $log = true) {
|
||||||
*
|
*
|
||||||
* @param User $user
|
* @param User $user
|
||||||
*/
|
*/
|
||||||
function User_generate_password_recovery_token(&$user) {
|
function User_generate_password_recovery_token(&$user)
|
||||||
|
{
|
||||||
$user['password_recovery_token'] = md5($user['Nick'] . time() . rand());
|
$user['password_recovery_token'] = md5($user['Nick'] . time() . rand());
|
||||||
$result = sql_query("UPDATE `User` SET `password_recovery_token`='" . sql_escape($user['password_recovery_token']) . "' WHERE `UID`='" . sql_escape($user['UID']) . "' LIMIT 1");
|
$result = sql_query("UPDATE `User` SET `password_recovery_token`='" . sql_escape($user['password_recovery_token']) . "' WHERE `UID`='" . sql_escape($user['UID']) . "' LIMIT 1");
|
||||||
if ($result === false) {
|
if ($result === false) {
|
||||||
|
@ -357,7 +381,8 @@ function User_generate_password_recovery_token(&$user) {
|
||||||
return $user['password_recovery_token'];
|
return $user['password_recovery_token'];
|
||||||
}
|
}
|
||||||
|
|
||||||
function User_get_eligable_voucher_count(&$user) {
|
function User_get_eligable_voucher_count(&$user)
|
||||||
|
{
|
||||||
global $voucher_settings;
|
global $voucher_settings;
|
||||||
|
|
||||||
$shifts_done = count(ShiftEntries_finished_by_user($user));
|
$shifts_done = count(ShiftEntries_finished_by_user($user));
|
||||||
|
@ -370,5 +395,3 @@ function User_get_eligable_voucher_count(&$user) {
|
||||||
|
|
||||||
return $elegible_vouchers;
|
return $elegible_vouchers;
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
|
@ -6,8 +6,8 @@ namespace Engelsystem;
|
||||||
* BO that represents the result of an entity attribute validation.
|
* BO that represents the result of an entity attribute validation.
|
||||||
* It contains the validated value and a bool for validation success.
|
* It contains the validated value and a bool for validation success.
|
||||||
*/
|
*/
|
||||||
class ValidationResult {
|
class ValidationResult
|
||||||
|
{
|
||||||
private $valid;
|
private $valid;
|
||||||
|
|
||||||
private $value;
|
private $value;
|
||||||
|
@ -20,7 +20,8 @@ class ValidationResult {
|
||||||
* @param * $value
|
* @param * $value
|
||||||
* The validated value
|
* The validated value
|
||||||
*/
|
*/
|
||||||
public function __construct($valid, $value) {
|
public function __construct($valid, $value)
|
||||||
|
{
|
||||||
$this->valid = $valid;
|
$this->valid = $valid;
|
||||||
$this->value = $value;
|
$this->value = $value;
|
||||||
}
|
}
|
||||||
|
@ -28,15 +29,16 @@ class ValidationResult {
|
||||||
/**
|
/**
|
||||||
* Is the value valid?
|
* Is the value valid?
|
||||||
*/
|
*/
|
||||||
public function isValid() {
|
public function isValid()
|
||||||
|
{
|
||||||
return $this->valid;
|
return $this->valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The parsed/validated value.
|
* The parsed/validated value.
|
||||||
*/
|
*/
|
||||||
public function getValue() {
|
public function getValue()
|
||||||
|
{
|
||||||
return $this->value;
|
return $this->value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
|
|
@ -3,7 +3,8 @@
|
||||||
/**
|
/**
|
||||||
* Close connection.
|
* Close connection.
|
||||||
*/
|
*/
|
||||||
function sql_close() {
|
function sql_close()
|
||||||
|
{
|
||||||
global $sql_connection;
|
global $sql_connection;
|
||||||
|
|
||||||
return $sql_connection->close();
|
return $sql_connection->close();
|
||||||
|
@ -12,14 +13,16 @@ function sql_close() {
|
||||||
/**
|
/**
|
||||||
* Return NULL if given value is null.
|
* Return NULL if given value is null.
|
||||||
*/
|
*/
|
||||||
function sql_null($value = null) {
|
function sql_null($value = null)
|
||||||
|
{
|
||||||
return $value == null ? 'NULL' : ("'" . sql_escape($value) . "'");
|
return $value == null ? 'NULL' : ("'" . sql_escape($value) . "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start new transaction.
|
* Start new transaction.
|
||||||
*/
|
*/
|
||||||
function sql_transaction_start() {
|
function sql_transaction_start()
|
||||||
|
{
|
||||||
global $sql_nested_transaction_level;
|
global $sql_nested_transaction_level;
|
||||||
|
|
||||||
if ($sql_nested_transaction_level ++ == 0) {
|
if ($sql_nested_transaction_level ++ == 0) {
|
||||||
|
@ -32,7 +35,8 @@ function sql_transaction_start() {
|
||||||
/**
|
/**
|
||||||
* Commit transaction.
|
* Commit transaction.
|
||||||
*/
|
*/
|
||||||
function sql_transaction_commit() {
|
function sql_transaction_commit()
|
||||||
|
{
|
||||||
global $sql_nested_transaction_level;
|
global $sql_nested_transaction_level;
|
||||||
|
|
||||||
if (-- $sql_nested_transaction_level == 0) {
|
if (-- $sql_nested_transaction_level == 0) {
|
||||||
|
@ -45,7 +49,8 @@ function sql_transaction_commit() {
|
||||||
/**
|
/**
|
||||||
* Stop transaction, revert database.
|
* Stop transaction, revert database.
|
||||||
*/
|
*/
|
||||||
function sql_transaction_rollback() {
|
function sql_transaction_rollback()
|
||||||
|
{
|
||||||
global $sql_nested_transaction_level;
|
global $sql_nested_transaction_level;
|
||||||
|
|
||||||
if (-- $sql_nested_transaction_level == 0) {
|
if (-- $sql_nested_transaction_level == 0) {
|
||||||
|
@ -61,7 +66,8 @@ function sql_transaction_rollback() {
|
||||||
* @param string $message
|
* @param string $message
|
||||||
* @return false
|
* @return false
|
||||||
*/
|
*/
|
||||||
function sql_error($message) {
|
function sql_error($message)
|
||||||
|
{
|
||||||
sql_close();
|
sql_close();
|
||||||
|
|
||||||
$message = trim($message) . "\n";
|
$message = trim($message) . "\n";
|
||||||
|
@ -85,7 +91,8 @@ function sql_error($message) {
|
||||||
* DB to select
|
* DB to select
|
||||||
* @return mysqli The connection handler
|
* @return mysqli The connection handler
|
||||||
*/
|
*/
|
||||||
function sql_connect($host, $user, $pass, $db_name) {
|
function sql_connect($host, $user, $pass, $db_name)
|
||||||
|
{
|
||||||
global $sql_connection;
|
global $sql_connection;
|
||||||
|
|
||||||
$sql_connection = new mysqli($host, $user, $pass, $db_name);
|
$sql_connection = new mysqli($host, $user, $pass, $db_name);
|
||||||
|
@ -114,7 +121,8 @@ function sql_connect($host, $user, $pass, $db_name) {
|
||||||
* $db_name
|
* $db_name
|
||||||
* @return bool true on success, false on error
|
* @return bool true on success, false on error
|
||||||
*/
|
*/
|
||||||
function sql_select_db($db_name) {
|
function sql_select_db($db_name)
|
||||||
|
{
|
||||||
global $sql_connection;
|
global $sql_connection;
|
||||||
if (! $sql_connection->select_db($db_name)) {
|
if (! $sql_connection->select_db($db_name)) {
|
||||||
return sql_error("No database selected.");
|
return sql_error("No database selected.");
|
||||||
|
@ -128,7 +136,8 @@ function sql_select_db($db_name) {
|
||||||
* @param string $query
|
* @param string $query
|
||||||
* @return Result array or false on error
|
* @return Result array or false on error
|
||||||
*/
|
*/
|
||||||
function sql_select($query) {
|
function sql_select($query)
|
||||||
|
{
|
||||||
global $sql_connection;
|
global $sql_connection;
|
||||||
|
|
||||||
// echo $query . ";\n";
|
// echo $query . ";\n";
|
||||||
|
@ -152,7 +161,8 @@ function sql_select($query) {
|
||||||
* @param string $query
|
* @param string $query
|
||||||
* @return mysqli_result boolean resource or false on error
|
* @return mysqli_result boolean resource or false on error
|
||||||
*/
|
*/
|
||||||
function sql_query($query) {
|
function sql_query($query)
|
||||||
|
{
|
||||||
global $sql_connection;
|
global $sql_connection;
|
||||||
|
|
||||||
$result = $sql_connection->query($query);
|
$result = $sql_connection->query($query);
|
||||||
|
@ -168,7 +178,8 @@ function sql_query($query) {
|
||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
function sql_id() {
|
function sql_id()
|
||||||
|
{
|
||||||
global $sql_connection;
|
global $sql_connection;
|
||||||
return $sql_connection->insert_id;
|
return $sql_connection->insert_id;
|
||||||
}
|
}
|
||||||
|
@ -179,7 +190,8 @@ function sql_id() {
|
||||||
* @param string $query
|
* @param string $query
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function sql_escape($query) {
|
function sql_escape($query)
|
||||||
|
{
|
||||||
global $sql_connection;
|
global $sql_connection;
|
||||||
return $sql_connection->real_escape_string($query);
|
return $sql_connection->real_escape_string($query);
|
||||||
}
|
}
|
||||||
|
@ -190,7 +202,8 @@ function sql_escape($query) {
|
||||||
* @param boolean $boolean
|
* @param boolean $boolean
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function sql_bool($boolean) {
|
function sql_bool($boolean)
|
||||||
|
{
|
||||||
return $boolean == true ? 'TRUE' : 'FALSE';
|
return $boolean == true ? 'TRUE' : 'FALSE';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,17 +213,18 @@ function sql_bool($boolean) {
|
||||||
* @param string $query
|
* @param string $query
|
||||||
* @return int Count of result lines
|
* @return int Count of result lines
|
||||||
*/
|
*/
|
||||||
function sql_num_query($query) {
|
function sql_num_query($query)
|
||||||
|
{
|
||||||
return sql_query($query)->num_rows;
|
return sql_query($query)->num_rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
function sql_select_single_col($query) {
|
function sql_select_single_col($query)
|
||||||
|
{
|
||||||
$result = sql_select($query);
|
$result = sql_select($query);
|
||||||
return array_map('array_shift', $result);
|
return array_map('array_shift', $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
function sql_select_single_cell($query) {
|
function sql_select_single_cell($query)
|
||||||
|
{
|
||||||
return array_shift(array_shift(sql_select($query)));
|
return array_shift(array_shift(sql_select($query)));
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
function admin_active_title() {
|
function admin_active_title()
|
||||||
|
{
|
||||||
return _("Active angels");
|
return _("Active angels");
|
||||||
}
|
}
|
||||||
|
|
||||||
function admin_active() {
|
function admin_active()
|
||||||
|
{
|
||||||
global $tshirt_sizes, $shift_sum_formula;
|
global $tshirt_sizes, $shift_sum_formula;
|
||||||
|
|
||||||
$msg = "";
|
$msg = "";
|
||||||
|
@ -199,4 +201,3 @@ function admin_active() {
|
||||||
], $shirt_statistics)
|
], $shirt_statistics)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
function admin_arrive_title() {
|
function admin_arrive_title()
|
||||||
|
{
|
||||||
return _("Arrived angels");
|
return _("Arrived angels");
|
||||||
}
|
}
|
||||||
|
|
||||||
function admin_arrive() {
|
function admin_arrive()
|
||||||
|
{
|
||||||
$msg = "";
|
$msg = "";
|
||||||
$search = "";
|
$search = "";
|
||||||
if (isset($_REQUEST['search'])) {
|
if (isset($_REQUEST['search'])) {
|
||||||
|
@ -198,4 +200,3 @@ function admin_arrive() {
|
||||||
])
|
])
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
function admin_free_title() {
|
function admin_free_title()
|
||||||
|
{
|
||||||
return _("Free angels");
|
return _("Free angels");
|
||||||
}
|
}
|
||||||
|
|
||||||
function admin_free() {
|
function admin_free()
|
||||||
|
{
|
||||||
global $privileges;
|
global $privileges;
|
||||||
|
|
||||||
$search = "";
|
$search = "";
|
||||||
|
@ -98,4 +100,3 @@ function admin_free() {
|
||||||
], $free_users_table)
|
], $free_users_table)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
function admin_groups_title() {
|
function admin_groups_title()
|
||||||
|
{
|
||||||
return _("Grouprights");
|
return _("Grouprights");
|
||||||
}
|
}
|
||||||
|
|
||||||
function admin_groups() {
|
function admin_groups()
|
||||||
|
{
|
||||||
$html = "";
|
$html = "";
|
||||||
$groups = sql_select("SELECT * FROM `Groups` ORDER BY `Name`");
|
$groups = sql_select("SELECT * FROM `Groups` ORDER BY `Name`");
|
||||||
if (! isset($_REQUEST["action"])) {
|
if (! isset($_REQUEST["action"])) {
|
||||||
|
@ -94,4 +96,3 @@ function admin_groups() {
|
||||||
}
|
}
|
||||||
return $html;
|
return $html;
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
function admin_import_title() {
|
function admin_import_title()
|
||||||
|
{
|
||||||
return _("Frab import");
|
return _("Frab import");
|
||||||
}
|
}
|
||||||
|
|
||||||
function admin_import() {
|
function admin_import()
|
||||||
|
{
|
||||||
global $rooms_import;
|
global $rooms_import;
|
||||||
global $user;
|
global $user;
|
||||||
$html = "";
|
$html = "";
|
||||||
|
@ -263,7 +265,8 @@ function admin_import() {
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function prepare_rooms($file) {
|
function prepare_rooms($file)
|
||||||
|
{
|
||||||
global $rooms_import;
|
global $rooms_import;
|
||||||
$data = read_xml($file);
|
$data = read_xml($file);
|
||||||
|
|
||||||
|
@ -295,7 +298,8 @@ function prepare_rooms($file) {
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
function prepare_events($file, $shifttype_id, $add_minutes_start, $add_minutes_end) {
|
function prepare_events($file, $shifttype_id, $add_minutes_start, $add_minutes_end)
|
||||||
|
{
|
||||||
global $rooms_import;
|
global $rooms_import;
|
||||||
$data = read_xml($file);
|
$data = read_xml($file);
|
||||||
|
|
||||||
|
@ -355,7 +359,8 @@ function prepare_events($file, $shifttype_id, $add_minutes_start, $add_minutes_e
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
function read_xml($file) {
|
function read_xml($file)
|
||||||
|
{
|
||||||
global $xml_import;
|
global $xml_import;
|
||||||
if (! isset($xml_import)) {
|
if (! isset($xml_import)) {
|
||||||
$xml_import = simplexml_load_file($file);
|
$xml_import = simplexml_load_file($file);
|
||||||
|
@ -363,7 +368,8 @@ function read_xml($file) {
|
||||||
return $xml_import;
|
return $xml_import;
|
||||||
}
|
}
|
||||||
|
|
||||||
function shifts_printable($shifts, $shifttypes) {
|
function shifts_printable($shifts, $shifttypes)
|
||||||
|
{
|
||||||
global $rooms_import;
|
global $rooms_import;
|
||||||
$rooms = array_flip($rooms_import);
|
$rooms = array_flip($rooms_import);
|
||||||
|
|
||||||
|
@ -386,7 +392,7 @@ function shifts_printable($shifts, $shifttypes) {
|
||||||
return $shifts_printable;
|
return $shifts_printable;
|
||||||
}
|
}
|
||||||
|
|
||||||
function shift_sort($shift_a, $shift_b) {
|
function shift_sort($shift_a, $shift_b)
|
||||||
|
{
|
||||||
return ($shift_a['start'] < $shift_b['start']) ? - 1 : 1;
|
return ($shift_a['start'] < $shift_b['start']) ? - 1 : 1;
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
function admin_log_title() {
|
function admin_log_title()
|
||||||
|
{
|
||||||
return _("Log");
|
return _("Log");
|
||||||
}
|
}
|
||||||
|
|
||||||
function admin_log() {
|
function admin_log()
|
||||||
|
{
|
||||||
$filter = "";
|
$filter = "";
|
||||||
if (isset($_REQUEST['keyword'])) {
|
if (isset($_REQUEST['keyword'])) {
|
||||||
$filter = strip_request_item('keyword');
|
$filter = strip_request_item('keyword');
|
||||||
|
@ -30,4 +32,3 @@ function admin_log() {
|
||||||
], $log_entries)
|
], $log_entries)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
function admin_news() {
|
function admin_news()
|
||||||
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
if (! isset($_GET["action"])) {
|
if (! isset($_GET["action"])) {
|
||||||
|
@ -64,4 +65,3 @@ function admin_news() {
|
||||||
}
|
}
|
||||||
return $html . '</div>';
|
return $html . '</div>';
|
||||||
}
|
}
|
||||||
?>
|
|
|
@ -1,13 +1,15 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
function admin_questions_title() {
|
function admin_questions_title()
|
||||||
|
{
|
||||||
return _("Answer questions");
|
return _("Answer questions");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renders a hint for new questions to answer.
|
* Renders a hint for new questions to answer.
|
||||||
*/
|
*/
|
||||||
function admin_new_questions() {
|
function admin_new_questions()
|
||||||
|
{
|
||||||
global $privileges, $page;
|
global $privileges, $page;
|
||||||
|
|
||||||
if ($page != "admin_questions") {
|
if ($page != "admin_questions") {
|
||||||
|
@ -23,7 +25,8 @@ function admin_new_questions() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function admin_questions() {
|
function admin_questions()
|
||||||
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
if (! isset($_REQUEST['action'])) {
|
if (! isset($_REQUEST['action'])) {
|
||||||
|
@ -117,4 +120,3 @@ function admin_questions() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
function admin_rooms_title() {
|
function admin_rooms_title()
|
||||||
|
{
|
||||||
return _("Rooms");
|
return _("Rooms");
|
||||||
}
|
}
|
||||||
|
|
||||||
function admin_rooms() {
|
function admin_rooms()
|
||||||
|
{
|
||||||
$rooms_source = sql_select("SELECT * FROM `Room` ORDER BY `Name`");
|
$rooms_source = sql_select("SELECT * FROM `Room` ORDER BY `Name`");
|
||||||
$rooms = [];
|
$rooms = [];
|
||||||
foreach ($rooms_source as $room) {
|
foreach ($rooms_source as $room) {
|
||||||
|
@ -193,4 +195,3 @@ function admin_rooms() {
|
||||||
], $rooms)
|
], $rooms)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
function admin_shifts_title() {
|
function admin_shifts_title()
|
||||||
|
{
|
||||||
return _("Create shifts");
|
return _("Create shifts");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assistent zum Anlegen mehrerer neuer Schichten
|
// Assistent zum Anlegen mehrerer neuer Schichten
|
||||||
function admin_shifts() {
|
function admin_shifts()
|
||||||
|
{
|
||||||
$valid = true;
|
$valid = true;
|
||||||
|
|
||||||
$rid = 0;
|
$rid = 0;
|
||||||
|
@ -343,4 +345,3 @@ function admin_shifts() {
|
||||||
])
|
])
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
function admin_user_title() {
|
function admin_user_title()
|
||||||
|
{
|
||||||
return _("All Angels");
|
return _("All Angels");
|
||||||
}
|
}
|
||||||
|
|
||||||
function admin_user() {
|
function admin_user()
|
||||||
|
{
|
||||||
global $user, $privileges, $tshirt_sizes, $privileges;
|
global $user, $privileges, $tshirt_sizes, $privileges;
|
||||||
|
|
||||||
$html = '';
|
$html = '';
|
||||||
|
@ -205,4 +207,3 @@ function admin_user() {
|
||||||
$html
|
$html
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
<?php
|
<?php
|
||||||
function credits_title() {
|
function credits_title()
|
||||||
|
{
|
||||||
return _("Credits");
|
return _("Credits");
|
||||||
}
|
}
|
||||||
|
|
||||||
function guest_credits() {
|
function guest_credits()
|
||||||
|
{
|
||||||
return template_render(__DIR__ . '/../../templates/guest_credits.html', []);
|
return template_render(__DIR__ . '/../../templates/guest_credits.html', []);
|
||||||
}
|
}
|
||||||
?>
|
|
|
@ -1,19 +1,23 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
function login_title() {
|
function login_title()
|
||||||
|
{
|
||||||
return _("Login");
|
return _("Login");
|
||||||
}
|
}
|
||||||
|
|
||||||
function register_title() {
|
function register_title()
|
||||||
|
{
|
||||||
return _("Register");
|
return _("Register");
|
||||||
}
|
}
|
||||||
|
|
||||||
function logout_title() {
|
function logout_title()
|
||||||
|
{
|
||||||
return _("Logout");
|
return _("Logout");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Engel registrieren
|
// Engel registrieren
|
||||||
function guest_register() {
|
function guest_register()
|
||||||
|
{
|
||||||
global $tshirt_sizes, $enable_tshirt_size, $default_theme, $user, $min_password_length;
|
global $tshirt_sizes, $enable_tshirt_size, $default_theme, $user, $min_password_length;
|
||||||
|
|
||||||
$event_config = EventConfig();
|
$event_config = EventConfig();
|
||||||
|
@ -287,23 +291,25 @@ function guest_register() {
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function entry_required() {
|
function entry_required()
|
||||||
|
{
|
||||||
return '<span class="text-info glyphicon glyphicon-warning-sign"></span>';
|
return '<span class="text-info glyphicon glyphicon-warning-sign"></span>';
|
||||||
}
|
}
|
||||||
|
|
||||||
function guest_logout() {
|
function guest_logout()
|
||||||
|
{
|
||||||
session_destroy();
|
session_destroy();
|
||||||
redirect(page_link_to("start"));
|
redirect(page_link_to("start"));
|
||||||
}
|
}
|
||||||
|
|
||||||
function guest_login() {
|
function guest_login()
|
||||||
|
{
|
||||||
$nick = "";
|
$nick = "";
|
||||||
|
|
||||||
unset($_SESSION['uid']);
|
unset($_SESSION['uid']);
|
||||||
$valid = true;
|
$valid = true;
|
||||||
|
|
||||||
if (isset($_REQUEST['submit'])) {
|
if (isset($_REQUEST['submit'])) {
|
||||||
|
|
||||||
if (isset($_REQUEST['nick']) && strlen(User_validate_Nick($_REQUEST['nick'])) > 0) {
|
if (isset($_REQUEST['nick']) && strlen(User_validate_Nick($_REQUEST['nick'])) > 0) {
|
||||||
$nick = User_validate_Nick($_REQUEST['nick']);
|
$nick = User_validate_Nick($_REQUEST['nick']);
|
||||||
$login_user = sql_select("SELECT * FROM `User` WHERE `Nick`='" . sql_escape($nick) . "'");
|
$login_user = sql_select("SELECT * FROM `User` WHERE `Nick`='" . sql_escape($nick) . "'");
|
||||||
|
@ -382,7 +388,8 @@ function guest_login() {
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_register_hint() {
|
function get_register_hint()
|
||||||
|
{
|
||||||
global $privileges;
|
global $privileges;
|
||||||
|
|
||||||
if (in_array('register', $privileges)) {
|
if (in_array('register', $privileges)) {
|
||||||
|
@ -397,4 +404,3 @@ function get_register_hint() {
|
||||||
//FIXME: return error(_("Registration is disabled."), true);
|
//FIXME: return error(_("Registration is disabled."), true);
|
||||||
return error("Registration is <a href='https://engelsystem.de/33c3/overwhelmed.html'>disabled</a>.", true);
|
return error("Registration is <a href='https://engelsystem.de/33c3/overwhelmed.html'>disabled</a>.", true);
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
function guest_start() {
|
function guest_start()
|
||||||
|
{
|
||||||
redirect(page_link_to('login'));
|
redirect(page_link_to('login'));
|
||||||
}
|
}
|
||||||
?>
|
|
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
function guest_stats() {
|
function guest_stats()
|
||||||
|
{
|
||||||
global $api_key;
|
global $api_key;
|
||||||
|
|
||||||
if (isset($_REQUEST['api_key'])) {
|
if (isset($_REQUEST['api_key'])) {
|
||||||
|
@ -31,5 +32,3 @@ function guest_stats() {
|
||||||
'error' => "Missing parameter api_key."
|
'error' => "Missing parameter api_key."
|
||||||
]));
|
]));
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
// publically available page to feed the news to feedreaders
|
// publically available page to feed the news to feedreaders
|
||||||
function user_atom() {
|
function user_atom()
|
||||||
|
{
|
||||||
global $user, $DISPLAY_NEWS;
|
global $user, $DISPLAY_NEWS;
|
||||||
|
|
||||||
if (! isset($_REQUEST['key']) || ! preg_match("/^[0-9a-f]{32}$/", $_REQUEST['key'])) {
|
if (! isset($_REQUEST['key']) || ! preg_match("/^[0-9a-f]{32}$/", $_REQUEST['key'])) {
|
||||||
|
@ -26,7 +27,8 @@ function user_atom() {
|
||||||
raw_output($output);
|
raw_output($output);
|
||||||
}
|
}
|
||||||
|
|
||||||
function make_atom_entries_from_news($news_entries) {
|
function make_atom_entries_from_news($news_entries)
|
||||||
|
{
|
||||||
$html = '<?xml version="1.0" encoding="utf-8"?>
|
$html = '<?xml version="1.0" encoding="utf-8"?>
|
||||||
<feed xmlns="http://www.w3.org/2005/Atom">
|
<feed xmlns="http://www.w3.org/2005/Atom">
|
||||||
<title>Engelsystem</title>
|
<title>Engelsystem</title>
|
||||||
|
@ -39,7 +41,8 @@ function make_atom_entries_from_news($news_entries) {
|
||||||
return $html;
|
return $html;
|
||||||
}
|
}
|
||||||
|
|
||||||
function make_atom_entry_from_news($news_entry) {
|
function make_atom_entry_from_news($news_entry)
|
||||||
|
{
|
||||||
return " <entry>
|
return " <entry>
|
||||||
<title>" . htmlspecialchars($news_entry['Betreff']) . "</title>
|
<title>" . htmlspecialchars($news_entry['Betreff']) . "</title>
|
||||||
<link href=\"" . page_link_to_absolute("news_comments&nid=") . "${news_entry['ID']}\"/>
|
<link href=\"" . page_link_to_absolute("news_comments&nid=") . "${news_entry['ID']}\"/>
|
||||||
|
@ -48,4 +51,3 @@ function make_atom_entry_from_news($news_entry) {
|
||||||
<summary type=\"html\">" . htmlspecialchars($news_entry['Text']) . "</summary>
|
<summary type=\"html\">" . htmlspecialchars($news_entry['Text']) . "</summary>
|
||||||
</entry>\n";
|
</entry>\n";
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
/**
|
/**
|
||||||
* Controller for ical output of users own shifts or any user_shifts filter.
|
* Controller for ical output of users own shifts or any user_shifts filter.
|
||||||
*/
|
*/
|
||||||
function user_ical() {
|
function user_ical()
|
||||||
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
if (! isset($_REQUEST['key']) || ! preg_match("/^[0-9a-f]{32}$/", $_REQUEST['key'])) {
|
if (! isset($_REQUEST['key']) || ! preg_match("/^[0-9a-f]{32}$/", $_REQUEST['key'])) {
|
||||||
|
@ -30,7 +31,8 @@ function user_ical() {
|
||||||
*
|
*
|
||||||
* @param array<Shift> $shifts
|
* @param array<Shift> $shifts
|
||||||
*/
|
*/
|
||||||
function send_ical_from_shifts($shifts) {
|
function send_ical_from_shifts($shifts)
|
||||||
|
{
|
||||||
header("Content-Type: text/calendar; charset=utf-8");
|
header("Content-Type: text/calendar; charset=utf-8");
|
||||||
$output = "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//-//Engelsystem//DE\r\nCALSCALE:GREGORIAN\r\n";
|
$output = "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//-//Engelsystem//DE\r\nCALSCALE:GREGORIAN\r\n";
|
||||||
foreach ($shifts as $shift) {
|
foreach ($shifts as $shift) {
|
||||||
|
@ -47,7 +49,8 @@ function send_ical_from_shifts($shifts) {
|
||||||
*
|
*
|
||||||
* @param Shift $shift
|
* @param Shift $shift
|
||||||
*/
|
*/
|
||||||
function make_ical_entry_from_shift($shift) {
|
function make_ical_entry_from_shift($shift)
|
||||||
|
{
|
||||||
$output = "BEGIN:VEVENT\r\n";
|
$output = "BEGIN:VEVENT\r\n";
|
||||||
$output .= "UID:" . md5($shift['start'] . $shift['end'] . $shift['name']) . "\r\n";
|
$output .= "UID:" . md5($shift['start'] . $shift['end'] . $shift['name']) . "\r\n";
|
||||||
$output .= "SUMMARY:" . str_replace("\n", "\\n", $shift['name']) . " (" . str_replace("\n", "\\n", $shift['title']) . ")\r\n";
|
$output .= "SUMMARY:" . str_replace("\n", "\\n", $shift['name']) . " (" . str_replace("\n", "\\n", $shift['title']) . ")\r\n";
|
||||||
|
@ -60,4 +63,3 @@ function make_ical_entry_from_shift($shift) {
|
||||||
$output .= "END:VEVENT\r\n";
|
$output .= "END:VEVENT\r\n";
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
function messages_title() {
|
function messages_title()
|
||||||
|
{
|
||||||
return _("Messages");
|
return _("Messages");
|
||||||
}
|
}
|
||||||
|
|
||||||
function user_unread_messages() {
|
function user_unread_messages()
|
||||||
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
if (isset($user)) {
|
if (isset($user)) {
|
||||||
|
@ -16,7 +18,8 @@ function user_unread_messages() {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
function user_messages() {
|
function user_messages()
|
||||||
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
if (! isset($_REQUEST['action'])) {
|
if (! isset($_REQUEST['action'])) {
|
||||||
|
@ -128,4 +131,3 @@ function user_messages() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
function myshifts_title() {
|
function myshifts_title()
|
||||||
|
{
|
||||||
return _("My shifts");
|
return _("My shifts");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Zeigt die Schichten an, die ein Benutzer belegt
|
// Zeigt die Schichten an, die ein Benutzer belegt
|
||||||
function user_myshifts() {
|
function user_myshifts()
|
||||||
|
{
|
||||||
global $LETZTES_AUSTRAGEN;
|
global $LETZTES_AUSTRAGEN;
|
||||||
global $user, $privileges;
|
global $user, $privileges;
|
||||||
|
|
||||||
|
@ -115,4 +117,3 @@ function user_myshifts() {
|
||||||
|
|
||||||
redirect(page_link_to('users') . '&action=view&user_id=' . $shifts_user['UID']);
|
redirect(page_link_to('users') . '&action=view&user_id=' . $shifts_user['UID']);
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
|
|
@ -1,18 +1,22 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
function user_news_comments_title() {
|
function user_news_comments_title()
|
||||||
|
{
|
||||||
return _("News comments");
|
return _("News comments");
|
||||||
}
|
}
|
||||||
|
|
||||||
function news_title() {
|
function news_title()
|
||||||
|
{
|
||||||
return _("News");
|
return _("News");
|
||||||
}
|
}
|
||||||
|
|
||||||
function meetings_title() {
|
function meetings_title()
|
||||||
|
{
|
||||||
return _("Meetings");
|
return _("Meetings");
|
||||||
}
|
}
|
||||||
|
|
||||||
function user_meetings() {
|
function user_meetings()
|
||||||
|
{
|
||||||
global $DISPLAY_NEWS;
|
global $DISPLAY_NEWS;
|
||||||
|
|
||||||
$html = '<div class="col-md-12"><h1>' . meetings_title() . '</h1>' . msg();
|
$html = '<div class="col-md-12"><h1>' . meetings_title() . '</h1>' . msg();
|
||||||
|
@ -45,7 +49,8 @@ function user_meetings() {
|
||||||
return $html;
|
return $html;
|
||||||
}
|
}
|
||||||
|
|
||||||
function display_news($news) {
|
function display_news($news)
|
||||||
|
{
|
||||||
global $privileges, $page;
|
global $privileges, $page;
|
||||||
|
|
||||||
$html = '';
|
$html = '';
|
||||||
|
@ -72,7 +77,8 @@ function display_news($news) {
|
||||||
return $html;
|
return $html;
|
||||||
}
|
}
|
||||||
|
|
||||||
function user_news_comments() {
|
function user_news_comments()
|
||||||
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
$html = '<div class="col-md-12"><h1>' . user_news_comments_title() . '</h1>';
|
$html = '<div class="col-md-12"><h1>' . user_news_comments_title() . '</h1>';
|
||||||
|
@ -113,7 +119,8 @@ function user_news_comments() {
|
||||||
return $html . '</div>';
|
return $html . '</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
function user_news() {
|
function user_news()
|
||||||
|
{
|
||||||
global $DISPLAY_NEWS, $privileges, $user;
|
global $DISPLAY_NEWS, $privileges, $user;
|
||||||
|
|
||||||
$html = '<div class="col-md-12"><h1>' . news_title() . '</h1>' . msg();
|
$html = '<div class="col-md-12"><h1>' . news_title() . '</h1>' . msg();
|
||||||
|
@ -166,4 +173,3 @@ function user_news() {
|
||||||
}
|
}
|
||||||
return $html . '</div>';
|
return $html . '</div>';
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
function questions_title() {
|
function questions_title()
|
||||||
|
{
|
||||||
return _("Ask the Heaven");
|
return _("Ask the Heaven");
|
||||||
}
|
}
|
||||||
|
|
||||||
function user_questions() {
|
function user_questions()
|
||||||
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
if (! isset($_REQUEST['action'])) {
|
if (! isset($_REQUEST['action'])) {
|
||||||
|
@ -54,4 +56,3 @@ function user_questions() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
|
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
function settings_title() {
|
function settings_title()
|
||||||
|
{
|
||||||
return _("Settings");
|
return _("Settings");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,7 +11,8 @@ function settings_title() {
|
||||||
* @param User $user_source
|
* @param User $user_source
|
||||||
* The user
|
* The user
|
||||||
*/
|
*/
|
||||||
function user_settings_main($user_source, $enable_tshirt_size, $tshirt_sizes) {
|
function user_settings_main($user_source, $enable_tshirt_size, $tshirt_sizes)
|
||||||
|
{
|
||||||
$valid = true;
|
$valid = true;
|
||||||
|
|
||||||
if (isset($_REQUEST['mail'])) {
|
if (isset($_REQUEST['mail'])) {
|
||||||
|
@ -87,7 +89,8 @@ function user_settings_main($user_source, $enable_tshirt_size, $tshirt_sizes) {
|
||||||
* @param User $user_source
|
* @param User $user_source
|
||||||
* The user
|
* The user
|
||||||
*/
|
*/
|
||||||
function user_settings_password($user_source) {
|
function user_settings_password($user_source)
|
||||||
|
{
|
||||||
global $min_password_length;
|
global $min_password_length;
|
||||||
if (! isset($_REQUEST['password']) || ! verify_password($_REQUEST['password'], $user_source['Passwort'], $user_source['UID'])) {
|
if (! isset($_REQUEST['password']) || ! verify_password($_REQUEST['password'], $user_source['Passwort'], $user_source['UID'])) {
|
||||||
error(_("-> not OK. Please try again."));
|
error(_("-> not OK. Please try again."));
|
||||||
|
@ -111,7 +114,8 @@ function user_settings_password($user_source) {
|
||||||
* @param array<String> $themes
|
* @param array<String> $themes
|
||||||
* List of available themes
|
* List of available themes
|
||||||
*/
|
*/
|
||||||
function user_settings_theme($user_source, $themes) {
|
function user_settings_theme($user_source, $themes)
|
||||||
|
{
|
||||||
$valid = true;
|
$valid = true;
|
||||||
|
|
||||||
if (isset($_REQUEST['theme']) && isset($themes[$_REQUEST['theme']])) {
|
if (isset($_REQUEST['theme']) && isset($themes[$_REQUEST['theme']])) {
|
||||||
|
@ -138,7 +142,8 @@ function user_settings_theme($user_source, $themes) {
|
||||||
* @param array<String> $locales
|
* @param array<String> $locales
|
||||||
* List of available locales
|
* List of available locales
|
||||||
*/
|
*/
|
||||||
function user_settings_locale($user_source, $locales) {
|
function user_settings_locale($user_source, $locales)
|
||||||
|
{
|
||||||
$valid = true;
|
$valid = true;
|
||||||
|
|
||||||
if (isset($_REQUEST['language']) && isset($locales[$_REQUEST['language']])) {
|
if (isset($_REQUEST['language']) && isset($locales[$_REQUEST['language']])) {
|
||||||
|
@ -161,7 +166,8 @@ function user_settings_locale($user_source, $locales) {
|
||||||
/**
|
/**
|
||||||
* Main user settings page/controller
|
* Main user settings page/controller
|
||||||
*/
|
*/
|
||||||
function user_settings() {
|
function user_settings()
|
||||||
|
{
|
||||||
global $enable_tshirt_size, $tshirt_sizes, $themes, $locales;
|
global $enable_tshirt_size, $tshirt_sizes, $themes, $locales;
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
|
@ -191,4 +197,3 @@ function user_settings() {
|
||||||
|
|
||||||
return User_settings_view($user_source, $locales, $themes, $buildup_start_date, $teardown_end_date, $enable_tshirt_size, $tshirt_sizes);
|
return User_settings_view($user_source, $locales, $themes, $buildup_start_date, $teardown_end_date, $enable_tshirt_size, $tshirt_sizes);
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
use Engelsystem\ShiftsFilter;
|
use Engelsystem\ShiftsFilter;
|
||||||
|
|
||||||
function shifts_title() {
|
function shifts_title()
|
||||||
|
{
|
||||||
return _("Shifts");
|
return _("Shifts");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,7 +13,8 @@ function shifts_title() {
|
||||||
* Split actions into shift edit, shift delete, shift entry edit, shift entry delete
|
* Split actions into shift edit, shift delete, shift entry edit, shift entry delete
|
||||||
* Introduce simpler and beautiful actions for shift entry join/leave for users
|
* Introduce simpler and beautiful actions for shift entry join/leave for users
|
||||||
*/
|
*/
|
||||||
function user_shifts() {
|
function user_shifts()
|
||||||
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
if (User_is_freeloader($user)) {
|
if (User_is_freeloader($user)) {
|
||||||
|
@ -39,7 +41,8 @@ function user_shifts() {
|
||||||
* @param ShiftsFilter $shiftsFilter
|
* @param ShiftsFilter $shiftsFilter
|
||||||
* The shiftfilter to update.
|
* The shiftfilter to update.
|
||||||
*/
|
*/
|
||||||
function update_ShiftsFilter_timerange(ShiftsFilter $shiftsFilter, $days) {
|
function update_ShiftsFilter_timerange(ShiftsFilter $shiftsFilter, $days)
|
||||||
|
{
|
||||||
$start_time = $shiftsFilter->getStartTime();
|
$start_time = $shiftsFilter->getStartTime();
|
||||||
if ($start_time == null) {
|
if ($start_time == null) {
|
||||||
$start_time = time();
|
$start_time = time();
|
||||||
|
@ -68,7 +71,8 @@ function update_ShiftsFilter_timerange(ShiftsFilter $shiftsFilter, $days) {
|
||||||
* @param string[] $days
|
* @param string[] $days
|
||||||
* An array of available filter days
|
* An array of available filter days
|
||||||
*/
|
*/
|
||||||
function update_ShiftsFilter(ShiftsFilter $shiftsFilter, $user_shifts_admin, $days) {
|
function update_ShiftsFilter(ShiftsFilter $shiftsFilter, $user_shifts_admin, $days)
|
||||||
|
{
|
||||||
$shiftsFilter->setUserShiftsAdmin($user_shifts_admin);
|
$shiftsFilter->setUserShiftsAdmin($user_shifts_admin);
|
||||||
$shiftsFilter->setFilled(check_request_int_array('filled', $shiftsFilter->getFilled()));
|
$shiftsFilter->setFilled(check_request_int_array('filled', $shiftsFilter->getFilled()));
|
||||||
$shiftsFilter->setRooms(check_request_int_array('rooms', $shiftsFilter->getRooms()));
|
$shiftsFilter->setRooms(check_request_int_array('rooms', $shiftsFilter->getRooms()));
|
||||||
|
@ -76,7 +80,8 @@ function update_ShiftsFilter(ShiftsFilter $shiftsFilter, $user_shifts_admin, $da
|
||||||
update_ShiftsFilter_timerange($shiftsFilter, $days);
|
update_ShiftsFilter_timerange($shiftsFilter, $days);
|
||||||
}
|
}
|
||||||
|
|
||||||
function load_rooms() {
|
function load_rooms()
|
||||||
|
{
|
||||||
$rooms = sql_select("SELECT `RID` AS `id`, `Name` AS `name` FROM `Room` WHERE `show`='Y' ORDER BY `Name`");
|
$rooms = sql_select("SELECT `RID` AS `id`, `Name` AS `name` FROM `Room` WHERE `show`='Y' ORDER BY `Name`");
|
||||||
if (count($rooms) == 0) {
|
if (count($rooms) == 0) {
|
||||||
error(_("The administration has not configured any rooms yet."));
|
error(_("The administration has not configured any rooms yet."));
|
||||||
|
@ -85,7 +90,8 @@ function load_rooms() {
|
||||||
return $rooms;
|
return $rooms;
|
||||||
}
|
}
|
||||||
|
|
||||||
function load_days() {
|
function load_days()
|
||||||
|
{
|
||||||
$days = sql_select_single_col("
|
$days = sql_select_single_col("
|
||||||
SELECT DISTINCT DATE(FROM_UNIXTIME(`start`)) AS `id`, DATE(FROM_UNIXTIME(`start`)) AS `name`
|
SELECT DISTINCT DATE(FROM_UNIXTIME(`start`)) AS `id`, DATE(FROM_UNIXTIME(`start`)) AS `name`
|
||||||
FROM `Shifts`
|
FROM `Shifts`
|
||||||
|
@ -97,7 +103,8 @@ function load_days() {
|
||||||
return $days;
|
return $days;
|
||||||
}
|
}
|
||||||
|
|
||||||
function load_types() {
|
function load_types()
|
||||||
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
if (sql_num_query("SELECT `id`, `name` FROM `AngelTypes` WHERE `restricted` = 0") == 0) {
|
if (sql_num_query("SELECT `id`, `name` FROM `AngelTypes` WHERE `restricted` = 0") == 0) {
|
||||||
|
@ -111,7 +118,8 @@ function load_types() {
|
||||||
return $types;
|
return $types;
|
||||||
}
|
}
|
||||||
|
|
||||||
function view_user_shifts() {
|
function view_user_shifts()
|
||||||
|
{
|
||||||
global $user, $privileges;
|
global $user, $privileges;
|
||||||
global $ical_shifts;
|
global $ical_shifts;
|
||||||
|
|
||||||
|
@ -172,11 +180,13 @@ function view_user_shifts() {
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_ids_from_array($array) {
|
function get_ids_from_array($array)
|
||||||
|
{
|
||||||
return $array["id"];
|
return $array["id"];
|
||||||
}
|
}
|
||||||
|
|
||||||
function make_select($items, $selected, $name, $title = null) {
|
function make_select($items, $selected, $name, $title = null)
|
||||||
|
{
|
||||||
$html_items = [];
|
$html_items = [];
|
||||||
if (isset($title)) {
|
if (isset($title)) {
|
||||||
$html_items[] = '<h4>' . $title . '</h4>' . "\n";
|
$html_items[] = '<h4>' . $title . '</h4>' . "\n";
|
||||||
|
@ -194,4 +204,3 @@ function make_select($items, $selected, $name, $title = null) {
|
||||||
$html .= '</div>' . "\n";
|
$html .= '</div>' . "\n";
|
||||||
return $html;
|
return $html;
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
/**
|
/**
|
||||||
* Testet ob ein User eingeloggt ist und lädt die entsprechenden Privilegien
|
* Testet ob ein User eingeloggt ist und lädt die entsprechenden Privilegien
|
||||||
*/
|
*/
|
||||||
function load_auth() {
|
function load_auth()
|
||||||
|
{
|
||||||
global $user, $privileges;
|
global $user, $privileges;
|
||||||
|
|
||||||
$user = null;
|
$user = null;
|
||||||
|
@ -26,7 +27,8 @@ function load_auth() {
|
||||||
/**
|
/**
|
||||||
* generate a salt (random string) of arbitrary length suitable for the use with crypt()
|
* generate a salt (random string) of arbitrary length suitable for the use with crypt()
|
||||||
*/
|
*/
|
||||||
function generate_salt($length = 16) {
|
function generate_salt($length = 16)
|
||||||
|
{
|
||||||
$alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
$alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||||
$salt = "";
|
$salt = "";
|
||||||
for ($i = 0; $i < $length; $i ++) {
|
for ($i = 0; $i < $length; $i ++) {
|
||||||
|
@ -38,7 +40,8 @@ function generate_salt($length = 16) {
|
||||||
/**
|
/**
|
||||||
* set the password of a user
|
* set the password of a user
|
||||||
*/
|
*/
|
||||||
function set_password($uid, $password) {
|
function set_password($uid, $password)
|
||||||
|
{
|
||||||
global $crypt_alg;
|
global $crypt_alg;
|
||||||
$result = sql_query("UPDATE `User` SET `Passwort` = '" . sql_escape(crypt($password, $crypt_alg . '$' . generate_salt(16) . '$')) . "', `password_recovery_token`=NULL WHERE `UID` = " . intval($uid) . " LIMIT 1");
|
$result = sql_query("UPDATE `User` SET `Passwort` = '" . sql_escape(crypt($password, $crypt_alg . '$' . generate_salt(16) . '$')) . "', `password_recovery_token`=NULL WHERE `UID` = " . intval($uid) . " LIMIT 1");
|
||||||
if ($result === false) {
|
if ($result === false) {
|
||||||
|
@ -51,7 +54,8 @@ function set_password($uid, $password) {
|
||||||
* verify a password given a precomputed salt.
|
* verify a password given a precomputed salt.
|
||||||
* if $uid is given and $salt is an old-style salt (plain md5), we convert it automatically
|
* if $uid is given and $salt is an old-style salt (plain md5), we convert it automatically
|
||||||
*/
|
*/
|
||||||
function verify_password($password, $salt, $uid = false) {
|
function verify_password($password, $salt, $uid = false)
|
||||||
|
{
|
||||||
global $crypt_alg;
|
global $crypt_alg;
|
||||||
$correct = false;
|
$correct = false;
|
||||||
if (substr($salt, 0, 1) == '$') { // new-style crypt()
|
if (substr($salt, 0, 1) == '$') { // new-style crypt()
|
||||||
|
@ -71,7 +75,8 @@ function verify_password($password, $salt, $uid = false) {
|
||||||
return $correct;
|
return $correct;
|
||||||
}
|
}
|
||||||
|
|
||||||
function privileges_for_user($user_id) {
|
function privileges_for_user($user_id)
|
||||||
|
{
|
||||||
$privileges = [];
|
$privileges = [];
|
||||||
$user_privs = sql_select("SELECT `Privileges`.`name` FROM `User` JOIN `UserGroups` ON (`User`.`UID` = `UserGroups`.`uid`) JOIN `GroupPrivileges` ON (`UserGroups`.`group_id` = `GroupPrivileges`.`group_id`) JOIN `Privileges` ON (`GroupPrivileges`.`privilege_id` = `Privileges`.`id`) WHERE `User`.`UID`='" . sql_escape($user_id) . "'");
|
$user_privs = sql_select("SELECT `Privileges`.`name` FROM `User` JOIN `UserGroups` ON (`User`.`UID` = `UserGroups`.`uid`) JOIN `GroupPrivileges` ON (`UserGroups`.`group_id` = `GroupPrivileges`.`group_id`) JOIN `Privileges` ON (`GroupPrivileges`.`privilege_id` = `Privileges`.`id`) WHERE `User`.`UID`='" . sql_escape($user_id) . "'");
|
||||||
foreach ($user_privs as $user_priv) {
|
foreach ($user_privs as $user_priv) {
|
||||||
|
@ -80,7 +85,8 @@ function privileges_for_user($user_id) {
|
||||||
return $privileges;
|
return $privileges;
|
||||||
}
|
}
|
||||||
|
|
||||||
function privileges_for_group($group_id) {
|
function privileges_for_group($group_id)
|
||||||
|
{
|
||||||
$privileges = [];
|
$privileges = [];
|
||||||
$groups_privs = sql_select("SELECT * FROM `GroupPrivileges` JOIN `Privileges` ON (`GroupPrivileges`.`privilege_id` = `Privileges`.`id`) WHERE `group_id`='" . sql_escape($group_id) . "'");
|
$groups_privs = sql_select("SELECT * FROM `GroupPrivileges` JOIN `Privileges` ON (`GroupPrivileges`.`privilege_id` = `Privileges`.`id`) WHERE `group_id`='" . sql_escape($group_id) . "'");
|
||||||
foreach ($groups_privs as $guest_priv) {
|
foreach ($groups_privs as $guest_priv) {
|
||||||
|
@ -88,4 +94,3 @@ function privileges_for_group($group_id) {
|
||||||
}
|
}
|
||||||
return $privileges;
|
return $privileges;
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
|
|
@ -10,14 +10,16 @@
|
||||||
* The value
|
* The value
|
||||||
* @return string rendered html
|
* @return string rendered html
|
||||||
*/
|
*/
|
||||||
function form_hidden($name, $value) {
|
function form_hidden($name, $value)
|
||||||
|
{
|
||||||
return '<input type="hidden" name="' . $name . '" value="' . $value . '" />';
|
return '<input type="hidden" name="' . $name . '" value="' . $value . '" />';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rendert ein Zahlenfeld mit Buttons zum verstellen
|
* Rendert ein Zahlenfeld mit Buttons zum verstellen
|
||||||
*/
|
*/
|
||||||
function form_spinner($name, $label, $value) {
|
function form_spinner($name, $label, $value)
|
||||||
|
{
|
||||||
return form_element($label, '
|
return form_element($label, '
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<input id="spinner-' . $name . '" class="form-control" type="text" name="' . $name . '" value="' . $value . '" />
|
<input id="spinner-' . $name . '" class="form-control" type="text" name="' . $name . '" value="' . $value . '" />
|
||||||
|
@ -54,7 +56,8 @@ function form_spinner($name, $label, $value) {
|
||||||
* Earliest possible date
|
* Earliest possible date
|
||||||
* @return HTML
|
* @return HTML
|
||||||
*/
|
*/
|
||||||
function form_date($name, $label, $value, $start_date = '', $end_date = '') {
|
function form_date($name, $label, $value, $start_date = '', $end_date = '')
|
||||||
|
{
|
||||||
$dom_id = $name . '-date';
|
$dom_id = $name . '-date';
|
||||||
$value = is_numeric($value) ? date('Y-m-d', $value) : '';
|
$value = is_numeric($value) ? date('Y-m-d', $value) : '';
|
||||||
$start_date = is_numeric($start_date) ? date('Y-m-d', $start_date) : '';
|
$start_date = is_numeric($start_date) ? date('Y-m-d', $start_date) : '';
|
||||||
|
@ -89,7 +92,8 @@ function form_date($name, $label, $value, $start_date = '', $end_date = '') {
|
||||||
* @param
|
* @param
|
||||||
* selected Array mit den Keys, die ausgewählt sind
|
* selected Array mit den Keys, die ausgewählt sind
|
||||||
*/
|
*/
|
||||||
function form_checkboxes($name, $label, $items, $selected) {
|
function form_checkboxes($name, $label, $items, $selected)
|
||||||
|
{
|
||||||
$html = form_element($label, '');
|
$html = form_element($label, '');
|
||||||
foreach ($items as $key => $item) {
|
foreach ($items as $key => $item) {
|
||||||
$html .= form_checkbox($name . '_' . $key, $item, array_search($key, $selected) !== false);
|
$html .= form_checkbox($name . '_' . $key, $item, array_search($key, $selected) !== false);
|
||||||
|
@ -111,7 +115,8 @@ function form_checkboxes($name, $label, $items, $selected) {
|
||||||
* @param
|
* @param
|
||||||
* disabled Wie selected, nur dass die entsprechenden Checkboxen deaktiviert statt markiert sind
|
* disabled Wie selected, nur dass die entsprechenden Checkboxen deaktiviert statt markiert sind
|
||||||
*/
|
*/
|
||||||
function form_multi_checkboxes($names, $label, $items, $selected, $disabled = []) {
|
function form_multi_checkboxes($names, $label, $items, $selected, $disabled = [])
|
||||||
|
{
|
||||||
$html = "<table><thead><tr>";
|
$html = "<table><thead><tr>";
|
||||||
foreach ($names as $title) {
|
foreach ($names as $title) {
|
||||||
$html .= "<th>$title</th>";
|
$html .= "<th>$title</th>";
|
||||||
|
@ -136,21 +141,24 @@ function form_multi_checkboxes($names, $label, $items, $selected, $disabled = []
|
||||||
/**
|
/**
|
||||||
* Rendert eine Checkbox
|
* Rendert eine Checkbox
|
||||||
*/
|
*/
|
||||||
function form_checkbox($name, $label, $selected, $value = 'checked') {
|
function form_checkbox($name, $label, $selected, $value = 'checked')
|
||||||
|
{
|
||||||
return '<div class="checkbox"><label><input type="checkbox" id="' . $name . '" name="' . $name . '" value="' . $value . '"' . ($selected ? ' checked="checked"' : '') . ' /> ' . $label . '</label></div>';
|
return '<div class="checkbox"><label><input type="checkbox" id="' . $name . '" name="' . $name . '" value="' . $value . '"' . ($selected ? ' checked="checked"' : '') . ' /> ' . $label . '</label></div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rendert einen Radio
|
* Rendert einen Radio
|
||||||
*/
|
*/
|
||||||
function form_radio($name, $label, $selected, $value) {
|
function form_radio($name, $label, $selected, $value)
|
||||||
|
{
|
||||||
return '<div class="radio"><label><input type="radio" id="' . $name . '" name="' . $name . '" value="' . $value . '"' . ($selected ? ' checked="checked"' : '') . ' /> ' . $label . '</label></div>';
|
return '<div class="radio"><label><input type="radio" id="' . $name . '" name="' . $name . '" value="' . $value . '"' . ($selected ? ' checked="checked"' : '') . ' /> ' . $label . '</label></div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rendert einen Infotext in das Formular
|
* Rendert einen Infotext in das Formular
|
||||||
*/
|
*/
|
||||||
function form_info($label, $text = "") {
|
function form_info($label, $text = "")
|
||||||
|
{
|
||||||
if ($label == "") {
|
if ($label == "") {
|
||||||
return '<span class="help-block">' . glyph('info-sign') . $text . '</span>';
|
return '<span class="help-block">' . glyph('info-sign') . $text . '</span>';
|
||||||
}
|
}
|
||||||
|
@ -163,14 +171,16 @@ function form_info($label, $text = "") {
|
||||||
/**
|
/**
|
||||||
* Rendert den Absenden-Button eines Formulars
|
* Rendert den Absenden-Button eines Formulars
|
||||||
*/
|
*/
|
||||||
function form_submit($name, $label) {
|
function form_submit($name, $label)
|
||||||
|
{
|
||||||
return form_element('<input class="btn btn-primary" type="submit" name="' . $name . '" value="' . $label . '" />', "");
|
return form_element('<input class="btn btn-primary" type="submit" name="' . $name . '" value="' . $label . '" />', "");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rendert ein Formular-Textfeld
|
* Rendert ein Formular-Textfeld
|
||||||
*/
|
*/
|
||||||
function form_text($name, $label, $value, $disabled = false) {
|
function form_text($name, $label, $value, $disabled = false)
|
||||||
|
{
|
||||||
$disabled = $disabled ? ' disabled="disabled"' : '';
|
$disabled = $disabled ? ' disabled="disabled"' : '';
|
||||||
return form_element($label, '<input class="form-control" id="form_' . $name . '" type="text" name="' . $name . '" value="' . htmlspecialchars($value) . '" ' . $disabled . '/>', 'form_' . $name);
|
return form_element($label, '<input class="form-control" id="form_' . $name . '" type="text" name="' . $name . '" value="' . htmlspecialchars($value) . '" ' . $disabled . '/>', 'form_' . $name);
|
||||||
}
|
}
|
||||||
|
@ -187,7 +197,8 @@ function form_text($name, $label, $value, $disabled = false) {
|
||||||
* @param Boolean $disabled
|
* @param Boolean $disabled
|
||||||
* Is the field enabled?
|
* Is the field enabled?
|
||||||
*/
|
*/
|
||||||
function form_text_placeholder($name, $placeholder, $value, $disabled = false) {
|
function form_text_placeholder($name, $placeholder, $value, $disabled = false)
|
||||||
|
{
|
||||||
$disabled = $disabled ? ' disabled="disabled"' : '';
|
$disabled = $disabled ? ' disabled="disabled"' : '';
|
||||||
return form_element('', '<input class="form-control" id="form_' . $name . '" type="text" name="' . $name . '" value="' . htmlspecialchars($value) . '" placeholder="' . $placeholder . '" ' . $disabled . '/>');
|
return form_element('', '<input class="form-control" id="form_' . $name . '" type="text" name="' . $name . '" value="' . htmlspecialchars($value) . '" placeholder="' . $placeholder . '" ' . $disabled . '/>');
|
||||||
}
|
}
|
||||||
|
@ -195,7 +206,8 @@ function form_text_placeholder($name, $placeholder, $value, $disabled = false) {
|
||||||
/**
|
/**
|
||||||
* Rendert ein Formular-Emailfeld
|
* Rendert ein Formular-Emailfeld
|
||||||
*/
|
*/
|
||||||
function form_email($name, $label, $value, $disabled = false) {
|
function form_email($name, $label, $value, $disabled = false)
|
||||||
|
{
|
||||||
$disabled = $disabled ? ' disabled="disabled"' : '';
|
$disabled = $disabled ? ' disabled="disabled"' : '';
|
||||||
return form_element($label, '<input class="form-control" id="form_' . $name . '" type="email" name="' . $name . '" value="' . htmlspecialchars($value) . '" ' . $disabled . '/>', 'form_' . $name);
|
return form_element($label, '<input class="form-control" id="form_' . $name . '" type="email" name="' . $name . '" value="' . htmlspecialchars($value) . '" ' . $disabled . '/>', 'form_' . $name);
|
||||||
}
|
}
|
||||||
|
@ -203,14 +215,16 @@ function form_email($name, $label, $value, $disabled = false) {
|
||||||
/**
|
/**
|
||||||
* Rendert ein Formular-Dateifeld
|
* Rendert ein Formular-Dateifeld
|
||||||
*/
|
*/
|
||||||
function form_file($name, $label) {
|
function form_file($name, $label)
|
||||||
|
{
|
||||||
return form_element($label, '<input id="form_' . $name . '" type="file" name="' . $name . '" />', 'form_' . $name);
|
return form_element($label, '<input id="form_' . $name . '" type="file" name="' . $name . '" />', 'form_' . $name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rendert ein Formular-Passwortfeld
|
* Rendert ein Formular-Passwortfeld
|
||||||
*/
|
*/
|
||||||
function form_password($name, $label, $disabled = false) {
|
function form_password($name, $label, $disabled = false)
|
||||||
|
{
|
||||||
$disabled = $disabled ? ' disabled="disabled"' : '';
|
$disabled = $disabled ? ' disabled="disabled"' : '';
|
||||||
return form_element($label, '<input class="form-control" id="form_' . $name . '" type="password" name="' . $name . '" value="" ' . $disabled . '/>', 'form_' . $name);
|
return form_element($label, '<input class="form-control" id="form_' . $name . '" type="password" name="' . $name . '" value="" ' . $disabled . '/>', 'form_' . $name);
|
||||||
}
|
}
|
||||||
|
@ -218,7 +232,8 @@ function form_password($name, $label, $disabled = false) {
|
||||||
/**
|
/**
|
||||||
* Renders a password input with placeholder instead of label.
|
* Renders a password input with placeholder instead of label.
|
||||||
*/
|
*/
|
||||||
function form_password_placeholder($name, $placeholder, $disabled = false) {
|
function form_password_placeholder($name, $placeholder, $disabled = false)
|
||||||
|
{
|
||||||
$disabled = $disabled ? ' disabled="disabled"' : '';
|
$disabled = $disabled ? ' disabled="disabled"' : '';
|
||||||
return form_element('', '<input class="form-control" id="form_' . $name . '" type="password" name="' . $name . '" value="" placeholder="' . $placeholder . '" ' . $disabled . '/>', 'form_' . $name);
|
return form_element('', '<input class="form-control" id="form_' . $name . '" type="password" name="' . $name . '" value="" placeholder="' . $placeholder . '" ' . $disabled . '/>', 'form_' . $name);
|
||||||
}
|
}
|
||||||
|
@ -226,7 +241,8 @@ function form_password_placeholder($name, $placeholder, $disabled = false) {
|
||||||
/**
|
/**
|
||||||
* Rendert ein Formular-Textfeld
|
* Rendert ein Formular-Textfeld
|
||||||
*/
|
*/
|
||||||
function form_textarea($name, $label, $value, $disabled = false) {
|
function form_textarea($name, $label, $value, $disabled = false)
|
||||||
|
{
|
||||||
$disabled = $disabled ? ' disabled="disabled"' : '';
|
$disabled = $disabled ? ' disabled="disabled"' : '';
|
||||||
return form_element($label, '<textarea rows="5" class="form-control" id="form_' . $name . '" type="text" name="' . $name . '" ' . $disabled . '>' . $value . '</textarea>', 'form_' . $name);
|
return form_element($label, '<textarea rows="5" class="form-control" id="form_' . $name . '" type="text" name="' . $name . '" ' . $disabled . '>' . $value . '</textarea>', 'form_' . $name);
|
||||||
}
|
}
|
||||||
|
@ -234,14 +250,16 @@ function form_textarea($name, $label, $value, $disabled = false) {
|
||||||
/**
|
/**
|
||||||
* Rendert ein Formular-Auswahlfeld
|
* Rendert ein Formular-Auswahlfeld
|
||||||
*/
|
*/
|
||||||
function form_select($name, $label, $values, $selected) {
|
function form_select($name, $label, $values, $selected)
|
||||||
|
{
|
||||||
return form_element($label, html_select_key('form_' . $name, $name, $values, $selected), 'form_' . $name);
|
return form_element($label, html_select_key('form_' . $name, $name, $values, $selected), 'form_' . $name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rendert ein Formular-Element
|
* Rendert ein Formular-Element
|
||||||
*/
|
*/
|
||||||
function form_element($label, $input, $for = "") {
|
function form_element($label, $input, $for = "")
|
||||||
|
{
|
||||||
if ($label == '') {
|
if ($label == '') {
|
||||||
return '<div class="form-group">' . $input . '</div>';
|
return '<div class="form-group">' . $input . '</div>';
|
||||||
}
|
}
|
||||||
|
@ -252,11 +270,13 @@ function form_element($label, $input, $for = "") {
|
||||||
/**
|
/**
|
||||||
* Rendert ein Formular
|
* Rendert ein Formular
|
||||||
*/
|
*/
|
||||||
function form($elements, $action = "") {
|
function form($elements, $action = "")
|
||||||
|
{
|
||||||
return '<form role="form" action="' . $action . '" enctype="multipart/form-data" method="post">' . join($elements) . '</form>';
|
return '<form role="form" action="' . $action . '" enctype="multipart/form-data" method="post">' . join($elements) . '</form>';
|
||||||
}
|
}
|
||||||
|
|
||||||
function html_options($name, $options, $selected = "") {
|
function html_options($name, $options, $selected = "")
|
||||||
|
{
|
||||||
$html = "";
|
$html = "";
|
||||||
foreach ($options as $value => $label) {
|
foreach ($options as $value => $label) {
|
||||||
$html .= '<input type="radio"' . ($value == $selected ? ' checked="checked"' : '') . ' name="' . $name . '" value="' . $value . '"> ' . $label;
|
$html .= '<input type="radio"' . ($value == $selected ? ' checked="checked"' : '') . ' name="' . $name . '" value="' . $value . '"> ' . $label;
|
||||||
|
@ -265,7 +285,8 @@ function html_options($name, $options, $selected = "") {
|
||||||
return $html;
|
return $html;
|
||||||
}
|
}
|
||||||
|
|
||||||
function html_select_key($dom_id, $name, $rows, $selected) {
|
function html_select_key($dom_id, $name, $rows, $selected)
|
||||||
|
{
|
||||||
$html = '<select class="form-control" id="' . $dom_id . '" name="' . $name . '">';
|
$html = '<select class="form-control" id="' . $dom_id . '" name="' . $name . '">';
|
||||||
foreach ($rows as $key => $row) {
|
foreach ($rows as $key => $row) {
|
||||||
if (($key == $selected) || ($row == $selected)) {
|
if (($key == $selected) || ($row == $selected)) {
|
||||||
|
@ -277,5 +298,3 @@ function html_select_key($dom_id, $name, $rows, $selected) {
|
||||||
$html .= '</select>';
|
$html .= '</select>';
|
||||||
return $html;
|
return $html;
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
|
@ -7,7 +7,8 @@
|
||||||
* @param
|
* @param
|
||||||
* $message
|
* $message
|
||||||
*/
|
*/
|
||||||
function engelsystem_log($message) {
|
function engelsystem_log($message)
|
||||||
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
$nick = "Guest";
|
$nick = "Guest";
|
||||||
|
@ -20,7 +21,8 @@ function engelsystem_log($message) {
|
||||||
/**
|
/**
|
||||||
* Generates a PHP Stacktrace.
|
* Generates a PHP Stacktrace.
|
||||||
*/
|
*/
|
||||||
function debug_string_backtrace() {
|
function debug_string_backtrace()
|
||||||
|
{
|
||||||
ob_start();
|
ob_start();
|
||||||
debug_print_backtrace();
|
debug_print_backtrace();
|
||||||
$trace = ob_get_contents();
|
$trace = ob_get_contents();
|
||||||
|
@ -35,5 +37,3 @@ function debug_string_backtrace() {
|
||||||
|
|
||||||
return $trace;
|
return $trace;
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
|
@ -1,21 +1,24 @@
|
||||||
<?php
|
<?php
|
||||||
use Engelsystem\UserHintsRenderer;
|
use Engelsystem\UserHintsRenderer;
|
||||||
|
|
||||||
function page_link_to($page = "") {
|
function page_link_to($page = "")
|
||||||
|
{
|
||||||
if ($page == "") {
|
if ($page == "") {
|
||||||
return '?';
|
return '?';
|
||||||
}
|
}
|
||||||
return '?p=' . $page;
|
return '?p=' . $page;
|
||||||
}
|
}
|
||||||
|
|
||||||
function page_link_to_absolute($page) {
|
function page_link_to_absolute($page)
|
||||||
|
{
|
||||||
return (isset($_SERVER['HTTPS']) ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . preg_replace("/\?.*$/", '', $_SERVER['REQUEST_URI']) . page_link_to($page);
|
return (isset($_SERVER['HTTPS']) ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . preg_replace("/\?.*$/", '', $_SERVER['REQUEST_URI']) . page_link_to($page);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render the user hints
|
* Render the user hints
|
||||||
*/
|
*/
|
||||||
function header_render_hints() {
|
function header_render_hints()
|
||||||
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
$hints_renderer = new UserHintsRenderer();
|
$hints_renderer = new UserHintsRenderer();
|
||||||
|
@ -39,7 +42,8 @@ function header_render_hints() {
|
||||||
/**
|
/**
|
||||||
* Renders the header toolbar containing search, login/logout, user and settings links.
|
* Renders the header toolbar containing search, login/logout, user and settings links.
|
||||||
*/
|
*/
|
||||||
function header_toolbar() {
|
function header_toolbar()
|
||||||
|
{
|
||||||
global $page, $privileges, $user;
|
global $page, $privileges, $user;
|
||||||
|
|
||||||
$toolbar_items = [];
|
$toolbar_items = [];
|
||||||
|
@ -73,7 +77,8 @@ function header_toolbar() {
|
||||||
return toolbar($toolbar_items, true);
|
return toolbar($toolbar_items, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
function make_user_submenu() {
|
function make_user_submenu()
|
||||||
|
{
|
||||||
global $privileges, $page;
|
global $privileges, $page;
|
||||||
|
|
||||||
$user_submenu = make_langselect();
|
$user_submenu = make_langselect();
|
||||||
|
@ -93,7 +98,8 @@ function make_user_submenu() {
|
||||||
return $user_submenu;
|
return $user_submenu;
|
||||||
}
|
}
|
||||||
|
|
||||||
function make_navigation() {
|
function make_navigation()
|
||||||
|
{
|
||||||
global $page, $privileges;
|
global $page, $privileges;
|
||||||
|
|
||||||
$menu = [];
|
$menu = [];
|
||||||
|
@ -148,7 +154,8 @@ function make_navigation() {
|
||||||
* @param string[] $menu
|
* @param string[] $menu
|
||||||
* Rendered menu
|
* Rendered menu
|
||||||
*/
|
*/
|
||||||
function make_room_navigation($menu) {
|
function make_room_navigation($menu)
|
||||||
|
{
|
||||||
global $privileges;
|
global $privileges;
|
||||||
|
|
||||||
if (! in_array('view_rooms', $privileges)) {
|
if (! in_array('view_rooms', $privileges)) {
|
||||||
|
@ -172,8 +179,7 @@ function make_room_navigation($menu) {
|
||||||
return $menu;
|
return $menu;
|
||||||
}
|
}
|
||||||
|
|
||||||
function make_menu() {
|
function make_menu()
|
||||||
|
{
|
||||||
return make_navigation();
|
return make_navigation();
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
|
@ -17,7 +17,8 @@ use Engelsystem\ValidationResult;
|
||||||
* @param int $default_value
|
* @param int $default_value
|
||||||
* Default value unix timestamp
|
* Default value unix timestamp
|
||||||
*/
|
*/
|
||||||
function check_request_datetime($date_name, $time_name, $allowed_days, $default_value) {
|
function check_request_datetime($date_name, $time_name, $allowed_days, $default_value)
|
||||||
|
{
|
||||||
$time = date("H:i", $default_value);
|
$time = date("H:i", $default_value);
|
||||||
$day = date("Y-m-d", $default_value);
|
$day = date("Y-m-d", $default_value);
|
||||||
|
|
||||||
|
@ -40,7 +41,8 @@ function check_request_datetime($date_name, $time_name, $allowed_days, $default_
|
||||||
* The string to parse
|
* The string to parse
|
||||||
* @return The parsed unix timestamp
|
* @return The parsed unix timestamp
|
||||||
*/
|
*/
|
||||||
function parse_date($pattern, $value) {
|
function parse_date($pattern, $value)
|
||||||
|
{
|
||||||
$datetime = DateTime::createFromFormat($pattern, trim($value));
|
$datetime = DateTime::createFromFormat($pattern, trim($value));
|
||||||
if ($datetime == null) {
|
if ($datetime == null) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -51,7 +53,8 @@ function parse_date($pattern, $value) {
|
||||||
/**
|
/**
|
||||||
* Leitet den Browser an die übergebene URL weiter und hält das Script an.
|
* Leitet den Browser an die übergebene URL weiter und hält das Script an.
|
||||||
*/
|
*/
|
||||||
function redirect($url) {
|
function redirect($url)
|
||||||
|
{
|
||||||
header("Location: " . $url, true, 302);
|
header("Location: " . $url, true, 302);
|
||||||
raw_output("");
|
raw_output("");
|
||||||
}
|
}
|
||||||
|
@ -62,7 +65,8 @@ function redirect($url) {
|
||||||
* @param String $output
|
* @param String $output
|
||||||
* String to display
|
* String to display
|
||||||
*/
|
*/
|
||||||
function raw_output($output) {
|
function raw_output($output)
|
||||||
|
{
|
||||||
echo $output;
|
echo $output;
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
|
@ -77,7 +81,8 @@ function raw_output($output) {
|
||||||
* @param string $value_name
|
* @param string $value_name
|
||||||
* name of the column to use as displayed value
|
* name of the column to use as displayed value
|
||||||
*/
|
*/
|
||||||
function select_array($data, $key_name, $value_name) {
|
function select_array($data, $key_name, $value_name)
|
||||||
|
{
|
||||||
$ret = [];
|
$ret = [];
|
||||||
foreach ($data as $value) {
|
foreach ($data as $value) {
|
||||||
$ret[$value[$key_name]] = $value[$value_name];
|
$ret[$value[$key_name]] = $value[$value_name];
|
||||||
|
@ -93,7 +98,8 @@ function select_array($data, $key_name, $value_name) {
|
||||||
* @param array<int> $default
|
* @param array<int> $default
|
||||||
* Default return value, if param is not set
|
* Default return value, if param is not set
|
||||||
*/
|
*/
|
||||||
function check_request_int_array($name, $default = []) {
|
function check_request_int_array($name, $default = [])
|
||||||
|
{
|
||||||
if (isset($_REQUEST[$name]) && is_array($_REQUEST[$name])) {
|
if (isset($_REQUEST[$name]) && is_array($_REQUEST[$name])) {
|
||||||
return array_filter($_REQUEST[$name], 'is_numeric');
|
return array_filter($_REQUEST[$name], 'is_numeric');
|
||||||
}
|
}
|
||||||
|
@ -112,7 +118,8 @@ function check_request_int_array($name, $default = []) {
|
||||||
* is a null value allowed?
|
* is a null value allowed?
|
||||||
* @return ValidationResult containing the parsed date
|
* @return ValidationResult containing the parsed date
|
||||||
*/
|
*/
|
||||||
function check_request_date($name, $error_message = null, $null_allowed = false) {
|
function check_request_date($name, $error_message = null, $null_allowed = false)
|
||||||
|
{
|
||||||
if (! isset($_REQUEST[$name])) {
|
if (! isset($_REQUEST[$name])) {
|
||||||
return new ValidationResult($null_allowed, null);
|
return new ValidationResult($null_allowed, null);
|
||||||
}
|
}
|
||||||
|
@ -131,7 +138,8 @@ function check_request_date($name, $error_message = null, $null_allowed = false)
|
||||||
* is a null value allowed?
|
* is a null value allowed?
|
||||||
* @return ValidationResult containing the parsed date
|
* @return ValidationResult containing the parsed date
|
||||||
*/
|
*/
|
||||||
function check_date($input, $error_message = null, $null_allowed = false) {
|
function check_date($input, $error_message = null, $null_allowed = false)
|
||||||
|
{
|
||||||
if ($tmp = parse_date("Y-m-d H:i", trim($input) . " 00:00")) {
|
if ($tmp = parse_date("Y-m-d H:i", trim($input) . " 00:00")) {
|
||||||
return new ValidationResult(true, $tmp);
|
return new ValidationResult(true, $tmp);
|
||||||
}
|
}
|
||||||
|
@ -146,7 +154,8 @@ function check_date($input, $error_message = null, $null_allowed = false) {
|
||||||
/**
|
/**
|
||||||
* Returns REQUEST value filtered or default value (null) if not set.
|
* Returns REQUEST value filtered or default value (null) if not set.
|
||||||
*/
|
*/
|
||||||
function strip_request_item($name, $default_value = null) {
|
function strip_request_item($name, $default_value = null)
|
||||||
|
{
|
||||||
if (isset($_REQUEST[$name])) {
|
if (isset($_REQUEST[$name])) {
|
||||||
return strip_item($_REQUEST[$name]);
|
return strip_item($_REQUEST[$name]);
|
||||||
}
|
}
|
||||||
|
@ -157,7 +166,8 @@ function strip_request_item($name, $default_value = null) {
|
||||||
* Testet, ob der angegebene REQUEST Wert ein Integer ist, bzw.
|
* Testet, ob der angegebene REQUEST Wert ein Integer ist, bzw.
|
||||||
* eine ID sein könnte.
|
* eine ID sein könnte.
|
||||||
*/
|
*/
|
||||||
function test_request_int($name) {
|
function test_request_int($name)
|
||||||
|
{
|
||||||
if (isset($_REQUEST[$name])) {
|
if (isset($_REQUEST[$name])) {
|
||||||
return preg_match("/^[0-9]*$/", $_REQUEST[$name]);
|
return preg_match("/^[0-9]*$/", $_REQUEST[$name]);
|
||||||
}
|
}
|
||||||
|
@ -167,7 +177,8 @@ function test_request_int($name) {
|
||||||
/**
|
/**
|
||||||
* Gibt den gefilterten REQUEST Wert mit Zeilenumbrüchen zurück
|
* Gibt den gefilterten REQUEST Wert mit Zeilenumbrüchen zurück
|
||||||
*/
|
*/
|
||||||
function strip_request_item_nl($name, $default_value = null) {
|
function strip_request_item_nl($name, $default_value = null)
|
||||||
|
{
|
||||||
if (isset($_REQUEST[$name])) {
|
if (isset($_REQUEST[$name])) {
|
||||||
return preg_replace("/([^\p{L}\p{S}\p{P}\p{Z}\p{N}+\n]{1,})/ui", '', strip_tags($_REQUEST[$name]));
|
return preg_replace("/([^\p{L}\p{S}\p{P}\p{Z}\p{N}+\n]{1,})/ui", '', strip_tags($_REQUEST[$name]));
|
||||||
}
|
}
|
||||||
|
@ -177,15 +188,15 @@ function strip_request_item_nl($name, $default_value = null) {
|
||||||
/**
|
/**
|
||||||
* Entfernt unerwünschte Zeichen
|
* Entfernt unerwünschte Zeichen
|
||||||
*/
|
*/
|
||||||
function strip_item($item) {
|
function strip_item($item)
|
||||||
|
{
|
||||||
return preg_replace("/([^\p{L}\p{S}\p{P}\p{Z}\p{N}+]{1,})/ui", '', strip_tags($item));
|
return preg_replace("/([^\p{L}\p{S}\p{P}\p{Z}\p{N}+]{1,})/ui", '', strip_tags($item));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Überprüft eine E-Mail-Adresse.
|
* Überprüft eine E-Mail-Adresse.
|
||||||
*/
|
*/
|
||||||
function check_email($email) {
|
function check_email($email)
|
||||||
|
{
|
||||||
return (bool) filter_var($email, FILTER_VALIDATE_EMAIL);
|
return (bool) filter_var($email, FILTER_VALIDATE_EMAIL);
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
|
@ -16,7 +16,8 @@ $themes = [
|
||||||
*
|
*
|
||||||
* @param string $text
|
* @param string $text
|
||||||
*/
|
*/
|
||||||
function mute($text) {
|
function mute($text)
|
||||||
|
{
|
||||||
return '<span class="text-muted">' . $text . '</span>';
|
return '<span class="text-muted">' . $text . '</span>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,11 +29,13 @@ function mute($text) {
|
||||||
* @param string $class
|
* @param string $class
|
||||||
* default, primary, info, success, warning, danger
|
* default, primary, info, success, warning, danger
|
||||||
*/
|
*/
|
||||||
function label($content, $class = 'default') {
|
function label($content, $class = 'default')
|
||||||
|
{
|
||||||
return '<span class="label label-' . $class . '">' . $content . '</span>';
|
return '<span class="label label-' . $class . '">' . $content . '</span>';
|
||||||
}
|
}
|
||||||
|
|
||||||
function progress_bar($valuemin, $valuemax, $valuenow, $class = '', $content = '') {
|
function progress_bar($valuemin, $valuemax, $valuenow, $class = '', $content = '')
|
||||||
|
{
|
||||||
return '<div class="progress"><div class="progress-bar ' . $class . '" role="progressbar" aria-valuenow="' . $valuenow . '" aria-valuemin="' . $valuemin . '" aria-valuemax="' . $valuemax . '" style="width: ' . floor(($valuenow - $valuemin) * 100 / ($valuemax - $valuemin)) . '%">' . $content . '</div></div>';
|
return '<div class="progress"><div class="progress-bar ' . $class . '" role="progressbar" aria-valuenow="' . $valuenow . '" aria-valuemin="' . $valuemin . '" aria-valuemax="' . $valuemax . '" style="width: ' . floor(($valuenow - $valuemin) * 100 / ($valuemax - $valuemin)) . '%">' . $content . '</div></div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,7 +44,8 @@ function progress_bar($valuemin, $valuemax, $valuenow, $class = '', $content = '
|
||||||
*
|
*
|
||||||
* @param string $glyph_name
|
* @param string $glyph_name
|
||||||
*/
|
*/
|
||||||
function glyph($glyph_name) {
|
function glyph($glyph_name)
|
||||||
|
{
|
||||||
return ' <span class="glyphicon glyphicon-' . $glyph_name . '"></span> ';
|
return ' <span class="glyphicon glyphicon-' . $glyph_name . '"></span> ';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,11 +54,13 @@ function glyph($glyph_name) {
|
||||||
*
|
*
|
||||||
* @param boolean $boolean
|
* @param boolean $boolean
|
||||||
*/
|
*/
|
||||||
function glyph_bool($boolean) {
|
function glyph_bool($boolean)
|
||||||
|
{
|
||||||
return '<span class="text-' . ($boolean ? 'success' : 'danger') . '">' . glyph($boolean ? 'ok' : 'remove') . '</span>';
|
return '<span class="text-' . ($boolean ? 'success' : 'danger') . '">' . glyph($boolean ? 'ok' : 'remove') . '</span>';
|
||||||
}
|
}
|
||||||
|
|
||||||
function div($class, $content = [], $dom_id = "") {
|
function div($class, $content = [], $dom_id = "")
|
||||||
|
{
|
||||||
if (is_array($content)) {
|
if (is_array($content)) {
|
||||||
$content = join("\n", $content);
|
$content = join("\n", $content);
|
||||||
}
|
}
|
||||||
|
@ -62,7 +68,8 @@ function div($class, $content = [], $dom_id = "") {
|
||||||
return '<div' . $dom_id . ' class="' . $class . '">' . $content . '</div>';
|
return '<div' . $dom_id . ' class="' . $class . '">' . $content . '</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
function heading($content, $number = 1) {
|
function heading($content, $number = 1)
|
||||||
|
{
|
||||||
return "<h" . $number . ">" . $content . "</h" . $number . ">";
|
return "<h" . $number . ">" . $content . "</h" . $number . ">";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,11 +79,13 @@ function heading($content, $number = 1) {
|
||||||
* @param array $items
|
* @param array $items
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function toolbar($items = [], $right = false) {
|
function toolbar($items = [], $right = false)
|
||||||
|
{
|
||||||
return '<ul class="nav navbar-nav' . ($right ? ' navbar-right' : '') . '">' . join("\n", $items) . '</ul>';
|
return '<ul class="nav navbar-nav' . ($right ? ' navbar-right' : '') . '">' . join("\n", $items) . '</ul>';
|
||||||
}
|
}
|
||||||
|
|
||||||
function toolbar_pills($items) {
|
function toolbar_pills($items)
|
||||||
|
{
|
||||||
return '<ul class="nav nav-pills">' . join("\n", $items) . '</ul>';
|
return '<ul class="nav nav-pills">' . join("\n", $items) . '</ul>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,21 +98,25 @@ function toolbar_pills($items) {
|
||||||
* @param bool $selected
|
* @param bool $selected
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function toolbar_item_link($href, $glyphicon, $label, $selected = false) {
|
function toolbar_item_link($href, $glyphicon, $label, $selected = false)
|
||||||
|
{
|
||||||
return '<li class="' . ($selected ? 'active' : '') . '"><a href="' . $href . '">' . ($glyphicon != '' ? '<span class="glyphicon glyphicon-' . $glyphicon . '"></span> ' : '') . $label . '</a></li>';
|
return '<li class="' . ($selected ? 'active' : '') . '"><a href="' . $href . '">' . ($glyphicon != '' ? '<span class="glyphicon glyphicon-' . $glyphicon . '"></span> ' : '') . $label . '</a></li>';
|
||||||
}
|
}
|
||||||
|
|
||||||
function toolbar_item_divider() {
|
function toolbar_item_divider()
|
||||||
|
{
|
||||||
return '<li class="divider"></li>';
|
return '<li class="divider"></li>';
|
||||||
}
|
}
|
||||||
|
|
||||||
function toolbar_dropdown($glyphicon, $label, $submenu, $class = '') {
|
function toolbar_dropdown($glyphicon, $label, $submenu, $class = '')
|
||||||
|
{
|
||||||
return '<li class="dropdown ' . $class . '">
|
return '<li class="dropdown ' . $class . '">
|
||||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">' . ($glyphicon != '' ? '<span class="glyphicon glyphicon-' . $glyphicon . '"></span> ' : '') . $label . ' <span class="caret"></span></a>
|
<a href="#" class="dropdown-toggle" data-toggle="dropdown">' . ($glyphicon != '' ? '<span class="glyphicon glyphicon-' . $glyphicon . '"></span> ' : '') . $label . ' <span class="caret"></span></a>
|
||||||
<ul class="dropdown-menu" role="menu">' . join("\n", $submenu) . '</ul></li>';
|
<ul class="dropdown-menu" role="menu">' . join("\n", $submenu) . '</ul></li>';
|
||||||
}
|
}
|
||||||
|
|
||||||
function toolbar_popover($glyphicon, $label, $content, $class = '') {
|
function toolbar_popover($glyphicon, $label, $content, $class = '')
|
||||||
|
{
|
||||||
$dom_id = md5(microtime() . $glyphicon . $label);
|
$dom_id = md5(microtime() . $glyphicon . $label);
|
||||||
return '<li class="dropdown messages ' . $class . '">
|
return '<li class="dropdown messages ' . $class . '">
|
||||||
<a id="' . $dom_id . '" href="#" tabindex="0">' . ($glyphicon != '' ? '<span class="glyphicon glyphicon-' . $glyphicon . '"></span> ' : '') . $label . ' <span class="caret"></span></a>
|
<a id="' . $dom_id . '" href="#" tabindex="0">' . ($glyphicon != '' ? '<span class="glyphicon glyphicon-' . $glyphicon . '"></span> ' : '') . $label . ' <span class="caret"></span></a>
|
||||||
|
@ -125,7 +138,8 @@ function toolbar_popover($glyphicon, $label, $content, $class = '') {
|
||||||
* Generiert HTML Code für eine "Seite".
|
* Generiert HTML Code für eine "Seite".
|
||||||
* Fügt dazu die übergebenen Elemente zusammen.
|
* Fügt dazu die übergebenen Elemente zusammen.
|
||||||
*/
|
*/
|
||||||
function page($elements) {
|
function page($elements)
|
||||||
|
{
|
||||||
return join($elements);
|
return join($elements);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,14 +147,16 @@ function page($elements) {
|
||||||
* Generiert HTML Code für eine "Seite" mit zentraler Überschrift
|
* Generiert HTML Code für eine "Seite" mit zentraler Überschrift
|
||||||
* Fügt dazu die übergebenen Elemente zusammen.
|
* Fügt dazu die übergebenen Elemente zusammen.
|
||||||
*/
|
*/
|
||||||
function page_with_title($title, $elements) {
|
function page_with_title($title, $elements)
|
||||||
|
{
|
||||||
return '<div class="col-md-12"><h1>' . $title . '</h1>' . join($elements) . '</div>';
|
return '<div class="col-md-12"><h1>' . $title . '</h1>' . join($elements) . '</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rendert eine Datentabelle
|
* Rendert eine Datentabelle
|
||||||
*/
|
*/
|
||||||
function table($columns, $rows_raw, $data = true) {
|
function table($columns, $rows_raw, $data = true)
|
||||||
|
{
|
||||||
// If only one column is given
|
// If only one column is given
|
||||||
if (! is_array($columns)) {
|
if (! is_array($columns)) {
|
||||||
$rows = [];
|
$rows = [];
|
||||||
|
@ -161,7 +177,8 @@ function table($columns, $rows_raw, $data = true) {
|
||||||
* Helper for rendering a html-table.
|
* Helper for rendering a html-table.
|
||||||
* use table()
|
* use table()
|
||||||
*/
|
*/
|
||||||
function render_table($columns, $rows, $data = true) {
|
function render_table($columns, $rows, $data = true)
|
||||||
|
{
|
||||||
if (count($rows) == 0) {
|
if (count($rows) == 0) {
|
||||||
return info(_("No data found."), true);
|
return info(_("No data found."), true);
|
||||||
}
|
}
|
||||||
|
@ -192,30 +209,35 @@ function render_table($columns, $rows, $data = true) {
|
||||||
/**
|
/**
|
||||||
* Rendert einen Knopf
|
* Rendert einen Knopf
|
||||||
*/
|
*/
|
||||||
function button($href, $label, $class = "") {
|
function button($href, $label, $class = "")
|
||||||
|
{
|
||||||
return '<a href="' . $href . '" class="btn btn-default ' . $class . '">' . $label . '</a>';
|
return '<a href="' . $href . '" class="btn btn-default ' . $class . '">' . $label . '</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rendert einen Knopf mit Glyph
|
* Rendert einen Knopf mit Glyph
|
||||||
*/
|
*/
|
||||||
function button_glyph($href, $glyph, $class = "") {
|
function button_glyph($href, $glyph, $class = "")
|
||||||
|
{
|
||||||
return button($href, glyph($glyph), $class);
|
return button($href, glyph($glyph), $class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rendert eine Toolbar mit Knöpfen
|
* Rendert eine Toolbar mit Knöpfen
|
||||||
*/
|
*/
|
||||||
function buttons($buttons = []) {
|
function buttons($buttons = [])
|
||||||
|
{
|
||||||
return '<div class="form-group">' . table_buttons($buttons) . '</div>';
|
return '<div class="form-group">' . table_buttons($buttons) . '</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
function table_buttons($buttons = []) {
|
function table_buttons($buttons = [])
|
||||||
|
{
|
||||||
return '<div class="btn-group">' . join(' ', $buttons) . '</div>';
|
return '<div class="btn-group">' . join(' ', $buttons) . '</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load and render template
|
// Load and render template
|
||||||
function template_render($file, $data) {
|
function template_render($file, $data)
|
||||||
|
{
|
||||||
if (file_exists($file)) {
|
if (file_exists($file)) {
|
||||||
$template = file_get_contents($file);
|
$template = file_get_contents($file);
|
||||||
if (is_array($data)) {
|
if (is_array($data)) {
|
||||||
|
@ -228,14 +250,16 @@ function template_render($file, $data) {
|
||||||
engelsystem_error("Cannot find template file «" . $file . "».");
|
engelsystem_error("Cannot find template file «" . $file . "».");
|
||||||
}
|
}
|
||||||
|
|
||||||
function shorten($str, $length = 50) {
|
function shorten($str, $length = 50)
|
||||||
|
{
|
||||||
if (strlen($str) < $length) {
|
if (strlen($str) < $length) {
|
||||||
return $str;
|
return $str;
|
||||||
}
|
}
|
||||||
return '<span title="' . htmlentities($str, ENT_COMPAT, 'UTF-8') . '">' . substr($str, 0, $length - 3) . '...</span>';
|
return '<span title="' . htmlentities($str, ENT_COMPAT, 'UTF-8') . '">' . substr($str, 0, $length - 3) . '...</span>';
|
||||||
}
|
}
|
||||||
|
|
||||||
function table_body($array) {
|
function table_body($array)
|
||||||
|
{
|
||||||
$html = "";
|
$html = "";
|
||||||
foreach ($array as $line) {
|
foreach ($array as $line) {
|
||||||
$html .= "<tr>";
|
$html .= "<tr>";
|
||||||
|
@ -251,7 +275,8 @@ function table_body($array) {
|
||||||
return $html;
|
return $html;
|
||||||
}
|
}
|
||||||
|
|
||||||
function ReplaceSmilies($neueckig) {
|
function ReplaceSmilies($neueckig)
|
||||||
|
{
|
||||||
$neueckig = str_replace(";o))", "<img src=\"pic/smiles/icon_redface.gif\">", $neueckig);
|
$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(":-))", "<img src=\"pic/smiles/icon_redface.gif\">", $neueckig);
|
||||||
$neueckig = str_replace(";o)", "<img src=\"pic/smiles/icon_wind.gif\">", $neueckig);
|
$neueckig = str_replace(";o)", "<img src=\"pic/smiles/icon_wind.gif\">", $neueckig);
|
||||||
|
@ -275,4 +300,3 @@ function ReplaceSmilies($neueckig) {
|
||||||
|
|
||||||
return $neueckig;
|
return $neueckig;
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
|
|
@ -9,7 +9,8 @@
|
||||||
*
|
*
|
||||||
* @param AngelType $angeltype
|
* @param AngelType $angeltype
|
||||||
*/
|
*/
|
||||||
function AngelType_name_render($angeltype) {
|
function AngelType_name_render($angeltype)
|
||||||
|
{
|
||||||
return '<a href="' . angeltype_link($angeltype['id']) . '">' . ($angeltype['restricted'] ? glyph('lock') : '') . $angeltype['name'] . '</a>';
|
return '<a href="' . angeltype_link($angeltype['id']) . '">' . ($angeltype['restricted'] ? glyph('lock') : '') . $angeltype['name'] . '</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +21,8 @@ function AngelType_name_render($angeltype) {
|
||||||
* UserAngelType and AngelType
|
* UserAngelType and AngelType
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function AngelType_render_membership($user_angeltype) {
|
function AngelType_render_membership($user_angeltype)
|
||||||
|
{
|
||||||
if ($user_angeltype['user_angeltype_id'] != null) {
|
if ($user_angeltype['user_angeltype_id'] != null) {
|
||||||
if ($user_angeltype['restricted']) {
|
if ($user_angeltype['restricted']) {
|
||||||
if ($user_angeltype['confirm_user_id'] == null) {
|
if ($user_angeltype['confirm_user_id'] == null) {
|
||||||
|
@ -37,7 +39,8 @@ function AngelType_render_membership($user_angeltype) {
|
||||||
return glyph_bool(false);
|
return glyph_bool(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
function AngelType_delete_view($angeltype) {
|
function AngelType_delete_view($angeltype)
|
||||||
|
{
|
||||||
return page_with_title(sprintf(_("Delete angeltype %s"), $angeltype['name']), [
|
return page_with_title(sprintf(_("Delete angeltype %s"), $angeltype['name']), [
|
||||||
info(sprintf(_("Do you want to delete angeltype %s?"), $angeltype['name']), true),
|
info(sprintf(_("Do you want to delete angeltype %s?"), $angeltype['name']), true),
|
||||||
buttons([
|
buttons([
|
||||||
|
@ -55,7 +58,8 @@ function AngelType_delete_view($angeltype) {
|
||||||
* @param boolean $supporter_mode
|
* @param boolean $supporter_mode
|
||||||
* Is the user a supporter of this angeltype?
|
* Is the user a supporter of this angeltype?
|
||||||
*/
|
*/
|
||||||
function AngelType_edit_view($angeltype, $supporter_mode) {
|
function AngelType_edit_view($angeltype, $supporter_mode)
|
||||||
|
{
|
||||||
$contact_info = AngelType_contact_info($angeltype);
|
$contact_info = AngelType_contact_info($angeltype);
|
||||||
return page_with_title(sprintf(_("Edit %s"), $angeltype['name']), [
|
return page_with_title(sprintf(_("Edit %s"), $angeltype['name']), [
|
||||||
buttons([
|
buttons([
|
||||||
|
@ -81,7 +85,8 @@ function AngelType_edit_view($angeltype, $supporter_mode) {
|
||||||
/**
|
/**
|
||||||
* Renders the buttons for the angeltype view.
|
* Renders the buttons for the angeltype view.
|
||||||
*/
|
*/
|
||||||
function AngelType_view_buttons($angeltype, $user_angeltype, $admin_angeltypes, $supporter, $user_driver_license, $user) {
|
function AngelType_view_buttons($angeltype, $user_angeltype, $admin_angeltypes, $supporter, $user_driver_license, $user)
|
||||||
|
{
|
||||||
$buttons = [
|
$buttons = [
|
||||||
button(page_link_to('angeltypes'), _("Angeltypes"), 'back')
|
button(page_link_to('angeltypes'), _("Angeltypes"), 'back')
|
||||||
];
|
];
|
||||||
|
@ -118,7 +123,8 @@ function AngelType_view_buttons($angeltype, $user_angeltype, $admin_angeltypes,
|
||||||
*
|
*
|
||||||
* @return [supporters, members, unconfirmed members]
|
* @return [supporters, members, unconfirmed members]
|
||||||
*/
|
*/
|
||||||
function AngelType_view_members($angeltype, $members, $admin_user_angeltypes, $admin_angeltypes) {
|
function AngelType_view_members($angeltype, $members, $admin_user_angeltypes, $admin_angeltypes)
|
||||||
|
{
|
||||||
$supporters = [];
|
$supporters = [];
|
||||||
$members_confirmed = [];
|
$members_confirmed = [];
|
||||||
$members_unconfirmed = [];
|
$members_unconfirmed = [];
|
||||||
|
@ -171,7 +177,8 @@ function AngelType_view_members($angeltype, $members, $admin_user_angeltypes, $a
|
||||||
/**
|
/**
|
||||||
* Creates the needed member table headers according to given rights and settings from the angeltype.
|
* Creates the needed member table headers according to given rights and settings from the angeltype.
|
||||||
*/
|
*/
|
||||||
function AngelType_view_table_headers($angeltype, $supporter, $admin_angeltypes) {
|
function AngelType_view_table_headers($angeltype, $supporter, $admin_angeltypes)
|
||||||
|
{
|
||||||
if ($angeltype['requires_driver_license'] && ($supporter || $admin_angeltypes)) {
|
if ($angeltype['requires_driver_license'] && ($supporter || $admin_angeltypes)) {
|
||||||
return [
|
return [
|
||||||
'Nick' => _("Nick"),
|
'Nick' => _("Nick"),
|
||||||
|
@ -196,7 +203,8 @@ function AngelType_view_table_headers($angeltype, $supporter, $admin_angeltypes)
|
||||||
/**
|
/**
|
||||||
* Render an angeltype page containing the member lists.
|
* Render an angeltype page containing the member lists.
|
||||||
*/
|
*/
|
||||||
function AngelType_view($angeltype, $members, $user_angeltype, $admin_user_angeltypes, $admin_angeltypes, $supporter, $user_driver_license, $user) {
|
function AngelType_view($angeltype, $members, $user_angeltype, $admin_user_angeltypes, $admin_angeltypes, $supporter, $user_driver_license, $user)
|
||||||
|
{
|
||||||
$page = [
|
$page = [
|
||||||
AngelType_view_buttons($angeltype, $user_angeltype, $admin_angeltypes, $supporter, $user_driver_license, $user),
|
AngelType_view_buttons($angeltype, $user_angeltype, $admin_angeltypes, $supporter, $user_driver_license, $user),
|
||||||
msg()
|
msg()
|
||||||
|
@ -257,7 +265,8 @@ function AngelType_view($angeltype, $members, $user_angeltype, $admin_user_angel
|
||||||
*
|
*
|
||||||
* @param array $angeltypes
|
* @param array $angeltypes
|
||||||
*/
|
*/
|
||||||
function AngelTypes_list_view($angeltypes, $admin_angeltypes) {
|
function AngelTypes_list_view($angeltypes, $admin_angeltypes)
|
||||||
|
{
|
||||||
return page_with_title(angeltypes_title(), [
|
return page_with_title(angeltypes_title(), [
|
||||||
msg(),
|
msg(),
|
||||||
buttons([
|
buttons([
|
||||||
|
@ -277,7 +286,8 @@ function AngelTypes_list_view($angeltypes, $admin_angeltypes) {
|
||||||
/**
|
/**
|
||||||
* Renders the about info for an angeltype.
|
* Renders the about info for an angeltype.
|
||||||
*/
|
*/
|
||||||
function AngelTypes_about_view_angeltype($angeltype) {
|
function AngelTypes_about_view_angeltype($angeltype)
|
||||||
|
{
|
||||||
$parsedown = new Parsedown();
|
$parsedown = new Parsedown();
|
||||||
|
|
||||||
$html = '<h2>' . $angeltype['name'] . '</h2>';
|
$html = '<h2>' . $angeltype['name'] . '</h2>';
|
||||||
|
@ -306,7 +316,8 @@ function AngelTypes_about_view_angeltype($angeltype) {
|
||||||
/**
|
/**
|
||||||
* Renders a site that contains every angeltype and its description, basically as an overview of the needed help types.
|
* Renders a site that contains every angeltype and its description, basically as an overview of the needed help types.
|
||||||
*/
|
*/
|
||||||
function AngelTypes_about_view($angeltypes, $user_logged_in) {
|
function AngelTypes_about_view($angeltypes, $user_logged_in)
|
||||||
|
{
|
||||||
global $faq_url;
|
global $faq_url;
|
||||||
|
|
||||||
$content = [
|
$content = [
|
||||||
|
@ -325,5 +336,3 @@ function AngelTypes_about_view($angeltypes, $user_logged_in) {
|
||||||
|
|
||||||
return page_with_title(_("Teams/Job description"), $content);
|
return page_with_title(_("Teams/Job description"), $content);
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
|
@ -4,7 +4,8 @@
|
||||||
* Shows basic event infos and countdowns.
|
* Shows basic event infos and countdowns.
|
||||||
* @param EventConfig $event_config The event configuration
|
* @param EventConfig $event_config The event configuration
|
||||||
*/
|
*/
|
||||||
function EventConfig_countdown_page($event_config) {
|
function EventConfig_countdown_page($event_config)
|
||||||
|
{
|
||||||
if ($event_config == null) {
|
if ($event_config == null) {
|
||||||
return div('col-md-12 text-center', [
|
return div('col-md-12 text-center', [
|
||||||
heading(sprintf(_("Welcome to the %s!"), '<span class="icon-icon_angel"></span> ENGELSYSTEM'), 2)
|
heading(sprintf(_("Welcome to the %s!"), '<span class="icon-icon_angel"></span> ENGELSYSTEM'), 2)
|
||||||
|
@ -57,7 +58,8 @@ function EventConfig_countdown_page($event_config) {
|
||||||
/**
|
/**
|
||||||
* Converts event name and start+end date into a line of text.
|
* Converts event name and start+end date into a line of text.
|
||||||
*/
|
*/
|
||||||
function EventConfig_info($event_config) {
|
function EventConfig_info($event_config)
|
||||||
|
{
|
||||||
if ($event_config == null) {
|
if ($event_config == null) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
@ -97,7 +99,8 @@ function EventConfig_info($event_config) {
|
||||||
* @param date $event_end_date
|
* @param date $event_end_date
|
||||||
* @param date $teardown_end_date
|
* @param date $teardown_end_date
|
||||||
*/
|
*/
|
||||||
function EventConfig_edit_view($event_name, $event_welcome_msg, $buildup_start_date, $event_start_date, $event_end_date, $teardown_end_date) {
|
function EventConfig_edit_view($event_name, $event_welcome_msg, $buildup_start_date, $event_start_date, $event_end_date, $teardown_end_date)
|
||||||
|
{
|
||||||
return page_with_title(event_config_title(), [
|
return page_with_title(event_config_title(), [
|
||||||
msg(),
|
msg(),
|
||||||
form([
|
form([
|
||||||
|
@ -125,5 +128,3 @@ function EventConfig_edit_view($event_name, $event_welcome_msg, $buildup_start_d
|
||||||
])
|
])
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
function Questions_view($open_questions, $answered_questions, $ask_action) {
|
function Questions_view($open_questions, $answered_questions, $ask_action)
|
||||||
|
{
|
||||||
foreach ($open_questions as &$question) {
|
foreach ($open_questions as &$question) {
|
||||||
$question['actions'] = '<a href="' . page_link_to("user_questions") . '&action=delete&id=' . $question['QID'] . '">' . _("delete") . '</a>';
|
$question['actions'] = '<a href="' . page_link_to("user_questions") . '&action=delete&id=' . $question['QID'] . '">' . _("delete") . '</a>';
|
||||||
$question['Question'] = str_replace("\n", '<br />', $question['Question']);
|
$question['Question'] = str_replace("\n", '<br />', $question['Question']);
|
||||||
|
@ -33,5 +34,3 @@ function Questions_view($open_questions, $answered_questions, $ask_action) {
|
||||||
], $ask_action)
|
], $ask_action)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
|
@ -2,19 +2,19 @@
|
||||||
use Engelsystem\ShiftsFilterRenderer;
|
use Engelsystem\ShiftsFilterRenderer;
|
||||||
use Engelsystem\ShiftCalendarRenderer;
|
use Engelsystem\ShiftCalendarRenderer;
|
||||||
|
|
||||||
function Room_view($room, ShiftsFilterRenderer $shiftsFilterRenderer, ShiftCalendarRenderer $shiftCalendarRenderer) {
|
function Room_view($room, ShiftsFilterRenderer $shiftsFilterRenderer, ShiftCalendarRenderer $shiftCalendarRenderer)
|
||||||
|
{
|
||||||
return page_with_title(glyph('map-marker') . $room['Name'], [
|
return page_with_title(glyph('map-marker') . $room['Name'], [
|
||||||
$shiftsFilterRenderer->render(room_link($room)) ,
|
$shiftsFilterRenderer->render(room_link($room)) ,
|
||||||
$shiftCalendarRenderer->render()
|
$shiftCalendarRenderer->render()
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function Room_name_render($room) {
|
function Room_name_render($room)
|
||||||
|
{
|
||||||
global $privileges;
|
global $privileges;
|
||||||
if (in_array('view_rooms', $privileges)) {
|
if (in_array('view_rooms', $privileges)) {
|
||||||
return '<a href="' . room_link($room) . '">' . glyph('map-marker') . $room['Name'] . '</a>';
|
return '<a href="' . room_link($room) . '">' . glyph('map-marker') . $room['Name'] . '</a>';
|
||||||
}
|
}
|
||||||
return glyph('map-marker') . $room['Name'];
|
return glyph('map-marker') . $room['Name'];
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
|
@ -5,8 +5,8 @@ namespace Engelsystem;
|
||||||
/**
|
/**
|
||||||
* Represents a single lane in a shifts calendar.
|
* Represents a single lane in a shifts calendar.
|
||||||
*/
|
*/
|
||||||
class ShiftCalendarLane {
|
class ShiftCalendarLane
|
||||||
|
{
|
||||||
private $firstBlockStartTime;
|
private $firstBlockStartTime;
|
||||||
|
|
||||||
private $blockCount;
|
private $blockCount;
|
||||||
|
@ -15,7 +15,8 @@ class ShiftCalendarLane {
|
||||||
|
|
||||||
private $shifts = [];
|
private $shifts = [];
|
||||||
|
|
||||||
public function __construct($header, $firstBlockStartTime, $blockCount) {
|
public function __construct($header, $firstBlockStartTime, $blockCount)
|
||||||
|
{
|
||||||
$this->header = $header;
|
$this->header = $header;
|
||||||
$this->firstBlockStartTime = $firstBlockStartTime;
|
$this->firstBlockStartTime = $firstBlockStartTime;
|
||||||
$this->blockCount = $blockCount;
|
$this->blockCount = $blockCount;
|
||||||
|
@ -29,7 +30,8 @@ class ShiftCalendarLane {
|
||||||
* The shift to add
|
* The shift to add
|
||||||
* @return boolean true on success
|
* @return boolean true on success
|
||||||
*/
|
*/
|
||||||
public function addShift($shift) {
|
public function addShift($shift)
|
||||||
|
{
|
||||||
if ($this->shiftFits($shift)) {
|
if ($this->shiftFits($shift)) {
|
||||||
$this->shifts[] = $shift;
|
$this->shifts[] = $shift;
|
||||||
return true;
|
return true;
|
||||||
|
@ -43,7 +45,8 @@ class ShiftCalendarLane {
|
||||||
* @param Shift $shift
|
* @param Shift $shift
|
||||||
* The shift to fit into this lane
|
* The shift to fit into this lane
|
||||||
*/
|
*/
|
||||||
public function shiftFits($newShift) {
|
public function shiftFits($newShift)
|
||||||
|
{
|
||||||
foreach ($this->shifts as $laneShift) {
|
foreach ($this->shifts as $laneShift) {
|
||||||
if (! ($newShift['start'] >= $laneShift['end'] || $newShift['end'] <= $laneShift['start'])) {
|
if (! ($newShift['start'] >= $laneShift['end'] || $newShift['end'] <= $laneShift['start'])) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -52,12 +55,13 @@ class ShiftCalendarLane {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getHeader() {
|
public function getHeader()
|
||||||
|
{
|
||||||
return $this->header;
|
return $this->header;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getShifts() {
|
public function getShifts()
|
||||||
|
{
|
||||||
return $this->shifts;
|
return $this->shifts;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
|
|
@ -2,7 +2,8 @@
|
||||||
|
|
||||||
namespace Engelsystem;
|
namespace Engelsystem;
|
||||||
|
|
||||||
class ShiftCalendarRenderer {
|
class ShiftCalendarRenderer
|
||||||
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 15m * 60s/m = 900s
|
* 15m * 60s/m = 900s
|
||||||
|
@ -39,7 +40,8 @@ class ShiftCalendarRenderer {
|
||||||
|
|
||||||
private $shift_entries = null;
|
private $shift_entries = null;
|
||||||
|
|
||||||
public function __construct($shifts, $needed_angeltypes, $shift_entries, ShiftsFilter $shiftsFilter) {
|
public function __construct($shifts, $needed_angeltypes, $shift_entries, ShiftsFilter $shiftsFilter)
|
||||||
|
{
|
||||||
$this->shiftsFilter = $shiftsFilter;
|
$this->shiftsFilter = $shiftsFilter;
|
||||||
$this->firstBlockStartTime = $this->calcFirstBlockStartTime($shifts);
|
$this->firstBlockStartTime = $this->calcFirstBlockStartTime($shifts);
|
||||||
$this->lastBlockEndTime = $this->calcLastBlockEndTime($shifts);
|
$this->lastBlockEndTime = $this->calcLastBlockEndTime($shifts);
|
||||||
|
@ -56,7 +58,8 @@ class ShiftCalendarRenderer {
|
||||||
*
|
*
|
||||||
* @return Returns an array that assigns a room_id to an array of ShiftCalendarLane containing the shifts
|
* @return Returns an array that assigns a room_id to an array of ShiftCalendarLane containing the shifts
|
||||||
*/
|
*/
|
||||||
private function assignShiftsToLanes($shifts) {
|
private function assignShiftsToLanes($shifts)
|
||||||
|
{
|
||||||
// array that assigns a room id to a list of lanes (per room)
|
// array that assigns a room id to a list of lanes (per room)
|
||||||
$lanes = [];
|
$lanes = [];
|
||||||
|
|
||||||
|
@ -93,15 +96,18 @@ class ShiftCalendarRenderer {
|
||||||
return $lanes;
|
return $lanes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFirstBlockStartTime() {
|
public function getFirstBlockStartTime()
|
||||||
|
{
|
||||||
return $this->firstBlockStartTime;
|
return $this->firstBlockStartTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getLastBlockEndTime() {
|
public function getLastBlockEndTime()
|
||||||
|
{
|
||||||
return $this->lastBlockEndTime;
|
return $this->lastBlockEndTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBlocksPerSlot() {
|
public function getBlocksPerSlot()
|
||||||
|
{
|
||||||
if ($this->blocksPerSlot == null) {
|
if ($this->blocksPerSlot == null) {
|
||||||
$this->blocksPerSlot = $this->calcBlocksPerSlot();
|
$this->blocksPerSlot = $this->calcBlocksPerSlot();
|
||||||
}
|
}
|
||||||
|
@ -113,7 +119,8 @@ class ShiftCalendarRenderer {
|
||||||
*
|
*
|
||||||
* @return the generated html
|
* @return the generated html
|
||||||
*/
|
*/
|
||||||
public function render() {
|
public function render()
|
||||||
|
{
|
||||||
if (count($this->lanes) == 0) {
|
if (count($this->lanes) == 0) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
@ -126,7 +133,8 @@ class ShiftCalendarRenderer {
|
||||||
/**
|
/**
|
||||||
* Renders the lanes containing the shifts
|
* Renders the lanes containing the shifts
|
||||||
*/
|
*/
|
||||||
private function renderShiftLanes() {
|
private function renderShiftLanes()
|
||||||
|
{
|
||||||
$html = "";
|
$html = "";
|
||||||
foreach ($this->lanes as $room_lanes) {
|
foreach ($this->lanes as $room_lanes) {
|
||||||
foreach ($room_lanes as $lane) {
|
foreach ($room_lanes as $lane) {
|
||||||
|
@ -143,7 +151,8 @@ class ShiftCalendarRenderer {
|
||||||
* @param ShiftCalendarLane $lane
|
* @param ShiftCalendarLane $lane
|
||||||
* The lane to render
|
* The lane to render
|
||||||
*/
|
*/
|
||||||
private function renderLane(ShiftCalendarLane $lane) {
|
private function renderLane(ShiftCalendarLane $lane)
|
||||||
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
$shift_renderer = new ShiftCalendarShiftRenderer();
|
$shift_renderer = new ShiftCalendarShiftRenderer();
|
||||||
|
@ -181,7 +190,8 @@ class ShiftCalendarRenderer {
|
||||||
* Should time labels be generated?
|
* Should time labels be generated?
|
||||||
* @return rendered tick html
|
* @return rendered tick html
|
||||||
*/
|
*/
|
||||||
private function renderTick($time, $label = false) {
|
private function renderTick($time, $label = false)
|
||||||
|
{
|
||||||
if ($time % (24 * 60 * 60) == 23 * 60 * 60) {
|
if ($time % (24 * 60 * 60) == 23 * 60 * 60) {
|
||||||
if (! $label) {
|
if (! $label) {
|
||||||
return div('tick day');
|
return div('tick day');
|
||||||
|
@ -203,7 +213,8 @@ class ShiftCalendarRenderer {
|
||||||
/**
|
/**
|
||||||
* Renders the left time lane including hour/day ticks
|
* Renders the left time lane including hour/day ticks
|
||||||
*/
|
*/
|
||||||
private function renderTimeLane() {
|
private function renderTimeLane()
|
||||||
|
{
|
||||||
$time_slot = [
|
$time_slot = [
|
||||||
div('header', [
|
div('header', [
|
||||||
_("Time")
|
_("Time")
|
||||||
|
@ -216,7 +227,8 @@ class ShiftCalendarRenderer {
|
||||||
return div('lane time', $time_slot);
|
return div('lane time', $time_slot);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function calcFirstBlockStartTime($shifts) {
|
private function calcFirstBlockStartTime($shifts)
|
||||||
|
{
|
||||||
$start_time = $this->shiftsFilter->getEndTime();
|
$start_time = $this->shiftsFilter->getEndTime();
|
||||||
foreach ($shifts as $shift) {
|
foreach ($shifts as $shift) {
|
||||||
if ($shift['start'] < $start_time) {
|
if ($shift['start'] < $start_time) {
|
||||||
|
@ -226,7 +238,8 @@ class ShiftCalendarRenderer {
|
||||||
return ShiftCalendarRenderer::SECONDS_PER_ROW * floor(($start_time - ShiftCalendarRenderer::TIME_MARGIN) / ShiftCalendarRenderer::SECONDS_PER_ROW);
|
return ShiftCalendarRenderer::SECONDS_PER_ROW * floor(($start_time - ShiftCalendarRenderer::TIME_MARGIN) / ShiftCalendarRenderer::SECONDS_PER_ROW);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function calcLastBlockEndTime($shifts) {
|
private function calcLastBlockEndTime($shifts)
|
||||||
|
{
|
||||||
$end_time = $this->shiftsFilter->getStartTime();
|
$end_time = $this->shiftsFilter->getStartTime();
|
||||||
foreach ($shifts as $shift) {
|
foreach ($shifts as $shift) {
|
||||||
if ($shift['end'] > $end_time) {
|
if ($shift['end'] > $end_time) {
|
||||||
|
@ -236,14 +249,16 @@ class ShiftCalendarRenderer {
|
||||||
return ShiftCalendarRenderer::SECONDS_PER_ROW * ceil(($end_time + ShiftCalendarRenderer::TIME_MARGIN) / ShiftCalendarRenderer::SECONDS_PER_ROW);
|
return ShiftCalendarRenderer::SECONDS_PER_ROW * ceil(($end_time + ShiftCalendarRenderer::TIME_MARGIN) / ShiftCalendarRenderer::SECONDS_PER_ROW);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function calcBlocksPerSlot() {
|
private function calcBlocksPerSlot()
|
||||||
|
{
|
||||||
return ceil(($this->getLastBlockEndTime() - $this->getFirstBlockStartTime()) / ShiftCalendarRenderer::SECONDS_PER_ROW);
|
return ceil(($this->getLastBlockEndTime() - $this->getFirstBlockStartTime()) / ShiftCalendarRenderer::SECONDS_PER_ROW);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renders a legend explaining the shift coloring
|
* Renders a legend explaining the shift coloring
|
||||||
*/
|
*/
|
||||||
private function renderLegend() {
|
private function renderLegend()
|
||||||
|
{
|
||||||
return div('legend', [
|
return div('legend', [
|
||||||
label(_('Your shift'), 'primary'),
|
label(_('Your shift'), 'primary'),
|
||||||
label(_('Help needed'), 'danger'),
|
label(_('Help needed'), 'danger'),
|
||||||
|
@ -253,5 +268,3 @@ class ShiftCalendarRenderer {
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
|
@ -5,7 +5,8 @@ namespace Engelsystem;
|
||||||
/**
|
/**
|
||||||
* Renders a single shift for the shift calendar
|
* Renders a single shift for the shift calendar
|
||||||
*/
|
*/
|
||||||
class ShiftCalendarShiftRenderer {
|
class ShiftCalendarShiftRenderer
|
||||||
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renders a shift
|
* Renders a shift
|
||||||
|
@ -15,7 +16,8 @@ class ShiftCalendarShiftRenderer {
|
||||||
* @param User $user
|
* @param User $user
|
||||||
* The user who is viewing the shift calendar
|
* The user who is viewing the shift calendar
|
||||||
*/
|
*/
|
||||||
public function render($shift, $needed_angeltypes, $shift_entries, $user) {
|
public function render($shift, $needed_angeltypes, $shift_entries, $user)
|
||||||
|
{
|
||||||
$info_text = "";
|
$info_text = "";
|
||||||
if ($shift['title'] != '') {
|
if ($shift['title'] != '') {
|
||||||
$info_text = glyph('info-sign') . $shift['title'] . '<br>';
|
$info_text = glyph('info-sign') . $shift['title'] . '<br>';
|
||||||
|
@ -43,7 +45,8 @@ class ShiftCalendarShiftRenderer {
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
private function classForSignupState(ShiftSignupState $shiftSignupState) {
|
private function classForSignupState(ShiftSignupState $shiftSignupState)
|
||||||
|
{
|
||||||
switch ($shiftSignupState->getState()) {
|
switch ($shiftSignupState->getState()) {
|
||||||
case ShiftSignupState::ADMIN:
|
case ShiftSignupState::ADMIN:
|
||||||
case ShiftSignupState::OCCUPIED:
|
case ShiftSignupState::OCCUPIED:
|
||||||
|
@ -64,7 +67,8 @@ class ShiftCalendarShiftRenderer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function renderShiftNeededAngeltypes($shift, $needed_angeltypes, $shift_entries, $user) {
|
private function renderShiftNeededAngeltypes($shift, $needed_angeltypes, $shift_entries, $user)
|
||||||
|
{
|
||||||
global $privileges;
|
global $privileges;
|
||||||
|
|
||||||
$shift_entries_filtered = [];
|
$shift_entries_filtered = [];
|
||||||
|
@ -117,7 +121,8 @@ class ShiftCalendarShiftRenderer {
|
||||||
* @param User $user
|
* @param User $user
|
||||||
* The user who is viewing the shift calendar
|
* The user who is viewing the shift calendar
|
||||||
*/
|
*/
|
||||||
private function renderShiftNeededAngeltype($shift, $shift_entries, $angeltype, $user) {
|
private function renderShiftNeededAngeltype($shift, $shift_entries, $angeltype, $user)
|
||||||
|
{
|
||||||
$entry_list = [];
|
$entry_list = [];
|
||||||
foreach ($shift_entries as $entry) {
|
foreach ($shift_entries as $entry) {
|
||||||
$style = $entry['freeloaded'] ? " text-decoration: line-through;" : '';
|
$style = $entry['freeloaded'] ? " text-decoration: line-through;" : '';
|
||||||
|
@ -174,7 +179,8 @@ class ShiftCalendarShiftRenderer {
|
||||||
* @param Shift $shift
|
* @param Shift $shift
|
||||||
* The shift
|
* The shift
|
||||||
*/
|
*/
|
||||||
private function renderShiftHead($shift) {
|
private function renderShiftHead($shift)
|
||||||
|
{
|
||||||
global $privileges;
|
global $privileges;
|
||||||
|
|
||||||
$header_buttons = "";
|
$header_buttons = "";
|
||||||
|
@ -191,5 +197,3 @@ class ShiftCalendarShiftRenderer {
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
|
@ -11,7 +11,8 @@
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function ShiftEntry_edit_view($angel, $date, $location, $title, $type, $comment, $freeloaded, $freeload_comment, $user_admin_shifts = false) {
|
function ShiftEntry_edit_view($angel, $date, $location, $title, $type, $comment, $freeloaded, $freeload_comment, $user_admin_shifts = false)
|
||||||
|
{
|
||||||
$freeload_form = [];
|
$freeload_form = [];
|
||||||
if ($user_admin_shifts) {
|
if ($user_admin_shifts) {
|
||||||
$freeload_form = [
|
$freeload_form = [
|
||||||
|
@ -33,5 +34,3 @@ function ShiftEntry_edit_view($angel, $date, $location, $title, $type, $comment,
|
||||||
])
|
])
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
function ShiftType_name_render($shifttype) {
|
function ShiftType_name_render($shifttype)
|
||||||
|
{
|
||||||
global $privileges;
|
global $privileges;
|
||||||
if (in_array('shifttypes', $privileges)) {
|
if (in_array('shifttypes', $privileges)) {
|
||||||
return '<a href="' . shifttype_link($shifttype) . '">' . $shifttype['name'] . '</a>';
|
return '<a href="' . shifttype_link($shifttype) . '">' . $shifttype['name'] . '</a>';
|
||||||
|
@ -8,7 +9,8 @@ function ShiftType_name_render($shifttype) {
|
||||||
return $shifttype['name'];
|
return $shifttype['name'];
|
||||||
}
|
}
|
||||||
|
|
||||||
function ShiftType_delete_view($shifttype) {
|
function ShiftType_delete_view($shifttype)
|
||||||
|
{
|
||||||
return page_with_title(sprintf(_("Delete shifttype %s"), $shifttype['name']), [
|
return page_with_title(sprintf(_("Delete shifttype %s"), $shifttype['name']), [
|
||||||
info(sprintf(_("Do you want to delete shifttype %s?"), $shifttype['name']), true),
|
info(sprintf(_("Do you want to delete shifttype %s?"), $shifttype['name']), true),
|
||||||
buttons([
|
buttons([
|
||||||
|
@ -18,7 +20,8 @@ function ShiftType_delete_view($shifttype) {
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function ShiftType_edit_view($name, $angeltype_id, $angeltypes, $description, $shifttype_id) {
|
function ShiftType_edit_view($name, $angeltype_id, $angeltypes, $description, $shifttype_id)
|
||||||
|
{
|
||||||
$angeltypes_select = [
|
$angeltypes_select = [
|
||||||
'' => _('All')
|
'' => _('All')
|
||||||
];
|
];
|
||||||
|
@ -41,7 +44,8 @@ function ShiftType_edit_view($name, $angeltype_id, $angeltypes, $description, $s
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function ShiftType_view($shifttype, $angeltype) {
|
function ShiftType_view($shifttype, $angeltype)
|
||||||
|
{
|
||||||
$parsedown = new Parsedown();
|
$parsedown = new Parsedown();
|
||||||
$title = $shifttype['name'];
|
$title = $shifttype['name'];
|
||||||
if ($angeltype) {
|
if ($angeltype) {
|
||||||
|
@ -60,7 +64,8 @@ function ShiftType_view($shifttype, $angeltype) {
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function ShiftTypes_list_view($shifttypes) {
|
function ShiftTypes_list_view($shifttypes)
|
||||||
|
{
|
||||||
foreach ($shifttypes as &$shifttype) {
|
foreach ($shifttypes as &$shifttype) {
|
||||||
$shifttype['name'] = '<a href="' . page_link_to('shifttypes') . '&action=view&shifttype_id=' . $shifttype['id'] . '">' . $shifttype['name'] . '</a>';
|
$shifttype['name'] = '<a href="' . page_link_to('shifttypes') . '&action=view&shifttype_id=' . $shifttype['id'] . '">' . $shifttype['name'] . '</a>';
|
||||||
$shifttype['actions'] = table_buttons([
|
$shifttype['actions'] = table_buttons([
|
||||||
|
@ -80,5 +85,3 @@ function ShiftTypes_list_view($shifttypes) {
|
||||||
], $shifttypes)
|
], $shifttypes)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
|
@ -2,7 +2,8 @@
|
||||||
|
|
||||||
namespace Engelsystem;
|
namespace Engelsystem;
|
||||||
|
|
||||||
class ShiftsFilterRenderer {
|
class ShiftsFilterRenderer
|
||||||
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The shiftFilter to render.
|
* The shiftFilter to render.
|
||||||
|
@ -26,7 +27,8 @@ class ShiftsFilterRenderer {
|
||||||
*/
|
*/
|
||||||
private $days = [];
|
private $days = [];
|
||||||
|
|
||||||
public function __construct(ShiftsFilter $shiftsFilter) {
|
public function __construct(ShiftsFilter $shiftsFilter)
|
||||||
|
{
|
||||||
$this->shiftsFilter = $shiftsFilter;
|
$this->shiftsFilter = $shiftsFilter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,7 +37,8 @@ class ShiftsFilterRenderer {
|
||||||
*
|
*
|
||||||
* @return Generated HTML
|
* @return Generated HTML
|
||||||
*/
|
*/
|
||||||
public function render($link_base) {
|
public function render($link_base)
|
||||||
|
{
|
||||||
$toolbar = [];
|
$toolbar = [];
|
||||||
if ($this->daySelectionEnabled && ! empty($this->days)) {
|
if ($this->daySelectionEnabled && ! empty($this->days)) {
|
||||||
$selected_day = date("Y-m-d", $this->shiftsFilter->getStartTime());
|
$selected_day = date("Y-m-d", $this->shiftsFilter->getStartTime());
|
||||||
|
@ -53,7 +56,8 @@ class ShiftsFilterRenderer {
|
||||||
/**
|
/**
|
||||||
* Should the filter display a day selection.
|
* Should the filter display a day selection.
|
||||||
*/
|
*/
|
||||||
public function enableDaySelection($days) {
|
public function enableDaySelection($days)
|
||||||
|
{
|
||||||
$this->daySelectionEnabled = true;
|
$this->daySelectionEnabled = true;
|
||||||
$this->days = $days;
|
$this->days = $days;
|
||||||
}
|
}
|
||||||
|
@ -61,9 +65,8 @@ class ShiftsFilterRenderer {
|
||||||
/**
|
/**
|
||||||
* Should the filter display a day selection.
|
* Should the filter display a day selection.
|
||||||
*/
|
*/
|
||||||
public function isDaySelectionEnabled() {
|
public function isDaySelectionEnabled()
|
||||||
|
{
|
||||||
return $this->daySelectionEnabled;
|
return $this->daySelectionEnabled;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
|
@ -1,7 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
use Engelsystem\ShiftSignupState;
|
use Engelsystem\ShiftSignupState;
|
||||||
|
|
||||||
function Shift_editor_info_render($shift) {
|
function Shift_editor_info_render($shift)
|
||||||
|
{
|
||||||
$info = [];
|
$info = [];
|
||||||
if ($shift['created_by_user_id'] != null) {
|
if ($shift['created_by_user_id'] != null) {
|
||||||
$info[] = sprintf(glyph('plus') . _("created at %s by %s"), date('Y-m-d H:i', $shift['created_at_timestamp']), User_Nick_render(User($shift['created_by_user_id'])));
|
$info[] = sprintf(glyph('plus') . _("created at %s by %s"), date('Y-m-d H:i', $shift['created_at_timestamp']), User_Nick_render(User($shift['created_by_user_id'])));
|
||||||
|
@ -12,7 +13,8 @@ function Shift_editor_info_render($shift) {
|
||||||
return join('<br />', $info);
|
return join('<br />', $info);
|
||||||
}
|
}
|
||||||
|
|
||||||
function Shift_signup_button_render($shift, $angeltype, $user_angeltype = null) {
|
function Shift_signup_button_render($shift, $angeltype, $user_angeltype = null)
|
||||||
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
if ($user_angeltype == null) {
|
if ($user_angeltype == null) {
|
||||||
|
@ -27,7 +29,8 @@ function Shift_signup_button_render($shift, $angeltype, $user_angeltype = null)
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
function Shift_view($shift, $shifttype, $room, $angeltypes_source, ShiftSignupState $shift_signup_state) {
|
function Shift_view($shift, $shifttype, $room, $angeltypes_source, ShiftSignupState $shift_signup_state)
|
||||||
|
{
|
||||||
global $privileges;
|
global $privileges;
|
||||||
|
|
||||||
$shift_admin = in_array('admin_shifts', $privileges);
|
$shift_admin = in_array('admin_shifts', $privileges);
|
||||||
|
@ -97,7 +100,8 @@ function Shift_view($shift, $shifttype, $room, $angeltypes_source, ShiftSignupSt
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function Shift_view_render_needed_angeltype($needed_angeltype, $angeltypes, $shift, $user_shift_admin) {
|
function Shift_view_render_needed_angeltype($needed_angeltype, $angeltypes, $shift, $user_shift_admin)
|
||||||
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
$angeltype = $angeltypes[$needed_angeltype['TID']];
|
$angeltype = $angeltypes[$needed_angeltype['TID']];
|
||||||
|
@ -134,7 +138,8 @@ function Shift_view_render_needed_angeltype($needed_angeltype, $angeltypes, $shi
|
||||||
return $needed_angels;
|
return $needed_angels;
|
||||||
}
|
}
|
||||||
|
|
||||||
function Shift_view_render_shift_entry($shift_entry, $user_shift_admin, $angeltype_supporter) {
|
function Shift_view_render_shift_entry($shift_entry, $user_shift_admin, $angeltype_supporter)
|
||||||
|
{
|
||||||
$entry = User_Nick_render(User($shift_entry['UID']));
|
$entry = User_Nick_render(User($shift_entry['UID']));
|
||||||
if ($shift_entry['freeloaded']) {
|
if ($shift_entry['freeloaded']) {
|
||||||
$entry = '<strike>' . $entry . '</strike>';
|
$entry = '<strike>' . $entry . '</strike>';
|
||||||
|
@ -155,9 +160,9 @@ function Shift_view_render_shift_entry($shift_entry, $user_shift_admin, $angelty
|
||||||
*
|
*
|
||||||
* @param Shift $shift
|
* @param Shift $shift
|
||||||
*/
|
*/
|
||||||
function shift_length($shift) {
|
function shift_length($shift)
|
||||||
|
{
|
||||||
$length = floor(($shift['end'] - $shift['start']) / (60 * 60)) . ":";
|
$length = floor(($shift['end'] - $shift['start']) / (60 * 60)) . ":";
|
||||||
$length .= str_pad((($shift['end'] - $shift['start']) % (60 * 60)) / 60, 2, "0", STR_PAD_LEFT) . "h";
|
$length .= str_pad((($shift['end'] - $shift['start']) % (60 * 60)) / 60, 2, "0", STR_PAD_LEFT) . "h";
|
||||||
return $length;
|
return $length;
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
function UserAngelType_update_view($user_angeltype, $user, $angeltype, $supporter) {
|
function UserAngelType_update_view($user_angeltype, $user, $angeltype, $supporter)
|
||||||
|
{
|
||||||
return page_with_title($supporter ? _("Add supporter rights") : _("Remove supporter rights"), [
|
return page_with_title($supporter ? _("Add supporter rights") : _("Remove supporter rights"), [
|
||||||
msg(),
|
msg(),
|
||||||
info(sprintf($supporter ? _("Do you really want to add supporter rights for %s to %s?") : _("Do you really want to remove supporter rights for %s from %s?"), $angeltype['name'], User_Nick_render($user)), true),
|
info(sprintf($supporter ? _("Do you really want to add supporter rights for %s to %s?") : _("Do you really want to remove supporter rights for %s from %s?"), $angeltype['name'], User_Nick_render($user)), true),
|
||||||
|
@ -11,7 +12,8 @@ function UserAngelType_update_view($user_angeltype, $user, $angeltype, $supporte
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function UserAngelTypes_delete_all_view($angeltype) {
|
function UserAngelTypes_delete_all_view($angeltype)
|
||||||
|
{
|
||||||
return page_with_title(_("Deny all users"), [
|
return page_with_title(_("Deny all users"), [
|
||||||
msg(),
|
msg(),
|
||||||
info(sprintf(_("Do you really want to deny all users for %s?"), $angeltype['name']), true),
|
info(sprintf(_("Do you really want to deny all users for %s?"), $angeltype['name']), true),
|
||||||
|
@ -22,7 +24,8 @@ function UserAngelTypes_delete_all_view($angeltype) {
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function UserAngelTypes_confirm_all_view($angeltype) {
|
function UserAngelTypes_confirm_all_view($angeltype)
|
||||||
|
{
|
||||||
return page_with_title(_("Confirm all users"), [
|
return page_with_title(_("Confirm all users"), [
|
||||||
msg(),
|
msg(),
|
||||||
info(sprintf(_("Do you really want to confirm all users for %s?"), $angeltype['name']), true),
|
info(sprintf(_("Do you really want to confirm all users for %s?"), $angeltype['name']), true),
|
||||||
|
@ -33,7 +36,8 @@ function UserAngelTypes_confirm_all_view($angeltype) {
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function UserAngelType_confirm_view($user_angeltype, $user, $angeltype) {
|
function UserAngelType_confirm_view($user_angeltype, $user, $angeltype)
|
||||||
|
{
|
||||||
return page_with_title(_("Confirm angeltype for user"), [
|
return page_with_title(_("Confirm angeltype for user"), [
|
||||||
msg(),
|
msg(),
|
||||||
info(sprintf(_("Do you really want to confirm %s for %s?"), User_Nick_render($user), $angeltype['name']), true),
|
info(sprintf(_("Do you really want to confirm %s for %s?"), User_Nick_render($user), $angeltype['name']), true),
|
||||||
|
@ -44,7 +48,8 @@ function UserAngelType_confirm_view($user_angeltype, $user, $angeltype) {
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function UserAngelType_delete_view($user_angeltype, $user, $angeltype) {
|
function UserAngelType_delete_view($user_angeltype, $user, $angeltype)
|
||||||
|
{
|
||||||
return page_with_title(_("Remove angeltype"), [
|
return page_with_title(_("Remove angeltype"), [
|
||||||
msg(),
|
msg(),
|
||||||
info(sprintf(_("Do you really want to delete %s from %s?"), User_Nick_render($user), $angeltype['name']), true),
|
info(sprintf(_("Do you really want to delete %s from %s?"), User_Nick_render($user), $angeltype['name']), true),
|
||||||
|
@ -55,7 +60,8 @@ function UserAngelType_delete_view($user_angeltype, $user, $angeltype) {
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function UserAngelType_add_view($angeltype, $users_source, $user_id) {
|
function UserAngelType_add_view($angeltype, $users_source, $user_id)
|
||||||
|
{
|
||||||
$users = [];
|
$users = [];
|
||||||
foreach ($users_source as $user_source) {
|
foreach ($users_source as $user_source) {
|
||||||
$users[$user_source['UID']] = User_Nick_render($user_source);
|
$users[$user_source['UID']] = User_Nick_render($user_source);
|
||||||
|
@ -74,7 +80,8 @@ function UserAngelType_add_view($angeltype, $users_source, $user_id) {
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function UserAngelType_join_view($user, $angeltype) {
|
function UserAngelType_join_view($user, $angeltype)
|
||||||
|
{
|
||||||
return page_with_title(sprintf(_("Become a %s"), $angeltype['name']), [
|
return page_with_title(sprintf(_("Become a %s"), $angeltype['name']), [
|
||||||
msg(),
|
msg(),
|
||||||
info(sprintf(_("Do you really want to add %s to %s?"), User_Nick_render($user), $angeltype['name']), true),
|
info(sprintf(_("Do you really want to add %s to %s?"), User_Nick_render($user), $angeltype['name']), true),
|
||||||
|
@ -84,5 +91,3 @@ function UserAngelType_join_view($user, $angeltype) {
|
||||||
])
|
])
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
|
@ -11,7 +11,8 @@
|
||||||
* The user driver license
|
* The user driver license
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function UserDriverLicense_edit_view($user_source, $wants_to_drive, $user_driver_license) {
|
function UserDriverLicense_edit_view($user_source, $wants_to_drive, $user_driver_license)
|
||||||
|
{
|
||||||
return page_with_title(sprintf(_("Edit %s driving license information"), User_Nick_render($user_source)), [
|
return page_with_title(sprintf(_("Edit %s driving license information"), User_Nick_render($user_source)), [
|
||||||
buttons([
|
buttons([
|
||||||
button(user_link($user_source), _("Back to profile"), 'back')
|
button(user_link($user_source), _("Back to profile"), 'back')
|
||||||
|
@ -52,5 +53,3 @@ function UserDriverLicense_edit_view($user_source, $wants_to_drive, $user_driver
|
||||||
</script>'
|
</script>'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
|
@ -2,8 +2,8 @@
|
||||||
|
|
||||||
namespace Engelsystem;
|
namespace Engelsystem;
|
||||||
|
|
||||||
class UserHintsRenderer {
|
class UserHintsRenderer
|
||||||
|
{
|
||||||
private $hints = [];
|
private $hints = [];
|
||||||
|
|
||||||
private $important = false;
|
private $important = false;
|
||||||
|
@ -11,7 +11,8 @@ class UserHintsRenderer {
|
||||||
/**
|
/**
|
||||||
* Render the added hints to a popover for the toolbar.
|
* Render the added hints to a popover for the toolbar.
|
||||||
*/
|
*/
|
||||||
public function render() {
|
public function render()
|
||||||
|
{
|
||||||
if (count($this->hints) > 0) {
|
if (count($this->hints) > 0) {
|
||||||
$hint_class = $this->important ? 'danger' : 'info';
|
$hint_class = $this->important ? 'danger' : 'info';
|
||||||
$glyphicon = $this->important ? 'warning-sign' : 'info-sign';
|
$glyphicon = $this->important ? 'warning-sign' : 'info-sign';
|
||||||
|
@ -30,7 +31,8 @@ class UserHintsRenderer {
|
||||||
* @param boolean $important
|
* @param boolean $important
|
||||||
* Is the hint important?
|
* Is the hint important?
|
||||||
*/
|
*/
|
||||||
public function addHint($hint, $important = false) {
|
public function addHint($hint, $important = false)
|
||||||
|
{
|
||||||
if ($hint != null && $hint != '') {
|
if ($hint != null && $hint != '') {
|
||||||
if ($important) {
|
if ($important) {
|
||||||
$this->important = true;
|
$this->important = true;
|
||||||
|
@ -44,16 +46,16 @@ class UserHintsRenderer {
|
||||||
/**
|
/**
|
||||||
* Get all hints.
|
* Get all hints.
|
||||||
*/
|
*/
|
||||||
public function getHints() {
|
public function getHints()
|
||||||
|
{
|
||||||
return $this->hints;
|
return $this->hints;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Are there important hints? This leads to a more intensive icon.
|
* Are there important hints? This leads to a more intensive icon.
|
||||||
*/
|
*/
|
||||||
public function isImportant() {
|
public function isImportant()
|
||||||
|
{
|
||||||
return $this->important;
|
return $this->important;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
|
@ -29,7 +29,8 @@ $tshirt_sizes = [
|
||||||
* @param array<String> $themes
|
* @param array<String> $themes
|
||||||
* Available themes
|
* Available themes
|
||||||
*/
|
*/
|
||||||
function User_settings_view($user_source, $locales, $themes, $buildup_start_date, $teardown_end_date, $enable_tshirt_size, $tshirt_sizes) {
|
function User_settings_view($user_source, $locales, $themes, $buildup_start_date, $teardown_end_date, $enable_tshirt_size, $tshirt_sizes)
|
||||||
|
{
|
||||||
return page_with_title(settings_title(), [
|
return page_with_title(settings_title(), [
|
||||||
msg(),
|
msg(),
|
||||||
div('row', [
|
div('row', [
|
||||||
|
@ -82,7 +83,8 @@ function User_settings_view($user_source, $locales, $themes, $buildup_start_date
|
||||||
/**
|
/**
|
||||||
* Displays the welcome message to the user and shows a login form.
|
* Displays the welcome message to the user and shows a login form.
|
||||||
*/
|
*/
|
||||||
function User_registration_success_view($event_welcome_message) {
|
function User_registration_success_view($event_welcome_message)
|
||||||
|
{
|
||||||
$parsedown = new Parsedown();
|
$parsedown = new Parsedown();
|
||||||
$event_welcome_message = $parsedown->text($event_welcome_message);
|
$event_welcome_message = $parsedown->text($event_welcome_message);
|
||||||
return page_with_title(_("Registration successful"), [
|
return page_with_title(_("Registration successful"), [
|
||||||
|
@ -117,7 +119,8 @@ function User_registration_success_view($event_welcome_message) {
|
||||||
/**
|
/**
|
||||||
* Gui for deleting user with password field.
|
* Gui for deleting user with password field.
|
||||||
*/
|
*/
|
||||||
function User_delete_view($user) {
|
function User_delete_view($user)
|
||||||
|
{
|
||||||
return page_with_title(sprintf(_("Delete %s"), User_Nick_render($user)), [
|
return page_with_title(sprintf(_("Delete %s"), User_Nick_render($user)), [
|
||||||
msg(),
|
msg(),
|
||||||
buttons([
|
buttons([
|
||||||
|
@ -134,7 +137,8 @@ function User_delete_view($user) {
|
||||||
/**
|
/**
|
||||||
* View for editing the number of given vouchers
|
* View for editing the number of given vouchers
|
||||||
*/
|
*/
|
||||||
function User_edit_vouchers_view($user) {
|
function User_edit_vouchers_view($user)
|
||||||
|
{
|
||||||
return page_with_title(sprintf(_("%s's vouchers"), User_Nick_render($user)), [
|
return page_with_title(sprintf(_("%s's vouchers"), User_Nick_render($user)), [
|
||||||
msg(),
|
msg(),
|
||||||
buttons([
|
buttons([
|
||||||
|
@ -148,7 +152,8 @@ function User_edit_vouchers_view($user) {
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function Users_view($users, $order_by, $arrived_count, $active_count, $force_active_count, $freeloads_count, $tshirts_count, $voucher_count) {
|
function Users_view($users, $order_by, $arrived_count, $active_count, $force_active_count, $freeloads_count, $tshirts_count, $voucher_count)
|
||||||
|
{
|
||||||
foreach ($users as &$user) {
|
foreach ($users as &$user) {
|
||||||
$user['Nick'] = User_Nick_render($user);
|
$user['Nick'] = User_Nick_render($user);
|
||||||
$user['Gekommen'] = glyph_bool($user['Gekommen']);
|
$user['Gekommen'] = glyph_bool($user['Gekommen']);
|
||||||
|
@ -195,11 +200,13 @@ function Users_view($users, $order_by, $arrived_count, $active_count, $force_act
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function Users_table_header_link($column, $label, $order_by) {
|
function Users_table_header_link($column, $label, $order_by)
|
||||||
|
{
|
||||||
return '<a href="' . page_link_to('users') . '&OrderBy=' . $column . '">' . $label . ($order_by == $column ? ' <span class="caret"></span>' : '') . '</a>';
|
return '<a href="' . page_link_to('users') . '&OrderBy=' . $column . '">' . $label . ($order_by == $column ? ' <span class="caret"></span>' : '') . '</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
function User_shift_state_render($user) {
|
function User_shift_state_render($user)
|
||||||
|
{
|
||||||
$upcoming_shifts = ShiftEntries_upcoming_for_user($user);
|
$upcoming_shifts = ShiftEntries_upcoming_for_user($user);
|
||||||
if ($upcoming_shifts === false) {
|
if ($upcoming_shifts === false) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -223,7 +230,8 @@ function User_shift_state_render($user) {
|
||||||
return '<span class="text-danger moment-countdown" data-timestamp="' . $upcoming_shifts[0]['end'] . '">' . _("Shift ends %c") . '</span>';
|
return '<span class="text-danger moment-countdown" data-timestamp="' . $upcoming_shifts[0]['end'] . '">' . _("Shift ends %c") . '</span>';
|
||||||
}
|
}
|
||||||
|
|
||||||
function User_view_shiftentries($needed_angel_type) {
|
function User_view_shiftentries($needed_angel_type)
|
||||||
|
{
|
||||||
$shift_info = '<br><b>' . $needed_angel_type['name'] . ':</b> ';
|
$shift_info = '<br><b>' . $needed_angel_type['name'] . ':</b> ';
|
||||||
|
|
||||||
$shift_entries = [];
|
$shift_entries = [];
|
||||||
|
@ -243,7 +251,8 @@ function User_view_shiftentries($needed_angel_type) {
|
||||||
/**
|
/**
|
||||||
* Helper that renders a shift line for user view
|
* Helper that renders a shift line for user view
|
||||||
*/
|
*/
|
||||||
function User_view_myshift($shift, $user_source, $its_me) {
|
function User_view_myshift($shift, $user_source, $its_me)
|
||||||
|
{
|
||||||
global $LETZTES_AUSTRAGEN, $privileges;
|
global $LETZTES_AUSTRAGEN, $privileges;
|
||||||
|
|
||||||
$shift_info = '<a href="' . shift_link($shift) . '">' . $shift['name'] . '</a>';
|
$shift_info = '<a href="' . shift_link($shift) . '">' . $shift['name'] . '</a>';
|
||||||
|
@ -287,7 +296,8 @@ function User_view_myshift($shift, $user_source, $its_me) {
|
||||||
/**
|
/**
|
||||||
* Helper that prepares the shift table for user view
|
* Helper that prepares the shift table for user view
|
||||||
*/
|
*/
|
||||||
function User_view_myshifts($shifts, $user_source, $its_me) {
|
function User_view_myshifts($shifts, $user_source, $its_me)
|
||||||
|
{
|
||||||
$myshifts_table = [];
|
$myshifts_table = [];
|
||||||
$timesum = 0;
|
$timesum = 0;
|
||||||
foreach ($shifts as $shift) {
|
foreach ($shifts as $shift) {
|
||||||
|
@ -316,7 +326,8 @@ function User_view_myshifts($shifts, $user_source, $its_me) {
|
||||||
/**
|
/**
|
||||||
* Renders view for a single user
|
* Renders view for a single user
|
||||||
*/
|
*/
|
||||||
function User_view($user_source, $admin_user_privilege, $freeloader, $user_angeltypes, $user_groups, $shifts, $its_me) {
|
function User_view($user_source, $admin_user_privilege, $freeloader, $user_angeltypes, $user_groups, $shifts, $its_me)
|
||||||
|
{
|
||||||
$user_name = htmlspecialchars($user_source['Vorname']) . " " . htmlspecialchars($user_source['Name']);
|
$user_name = htmlspecialchars($user_source['Vorname']) . " " . htmlspecialchars($user_source['Name']);
|
||||||
$myshifts_table = User_view_myshifts($shifts, $user_source, $its_me);
|
$myshifts_table = User_view_myshifts($shifts, $user_source, $its_me);
|
||||||
|
|
||||||
|
@ -378,7 +389,8 @@ function User_view($user_source, $admin_user_privilege, $freeloader, $user_angel
|
||||||
/**
|
/**
|
||||||
* View for password recovery step 1: E-Mail
|
* View for password recovery step 1: E-Mail
|
||||||
*/
|
*/
|
||||||
function User_password_recovery_view() {
|
function User_password_recovery_view()
|
||||||
|
{
|
||||||
return page_with_title(user_password_recovery_title(), [
|
return page_with_title(user_password_recovery_title(), [
|
||||||
msg(),
|
msg(),
|
||||||
_("We will send you an e-mail with a password recovery link. Please use the email address you used for registration."),
|
_("We will send you an e-mail with a password recovery link. Please use the email address you used for registration."),
|
||||||
|
@ -392,7 +404,8 @@ function User_password_recovery_view() {
|
||||||
/**
|
/**
|
||||||
* View for password recovery step 2: New password
|
* View for password recovery step 2: New password
|
||||||
*/
|
*/
|
||||||
function User_password_set_view() {
|
function User_password_set_view()
|
||||||
|
{
|
||||||
return page_with_title(user_password_recovery_title(), [
|
return page_with_title(user_password_recovery_title(), [
|
||||||
msg(),
|
msg(),
|
||||||
_("Please enter a new password."),
|
_("Please enter a new password."),
|
||||||
|
@ -404,7 +417,8 @@ function User_password_set_view() {
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function User_angeltypes_render($user_angeltypes) {
|
function User_angeltypes_render($user_angeltypes)
|
||||||
|
{
|
||||||
$output = [];
|
$output = [];
|
||||||
foreach ($user_angeltypes as $angeltype) {
|
foreach ($user_angeltypes as $angeltype) {
|
||||||
$class = "";
|
$class = "";
|
||||||
|
@ -422,7 +436,8 @@ function User_angeltypes_render($user_angeltypes) {
|
||||||
return join('<br />', $output);
|
return join('<br />', $output);
|
||||||
}
|
}
|
||||||
|
|
||||||
function User_groups_render($user_groups) {
|
function User_groups_render($user_groups)
|
||||||
|
{
|
||||||
$output = [];
|
$output = [];
|
||||||
foreach ($user_groups as $group) {
|
foreach ($user_groups as $group) {
|
||||||
$output[] = substr($group['Name'], 2);
|
$output[] = substr($group['Name'], 2);
|
||||||
|
@ -436,11 +451,13 @@ function User_groups_render($user_groups) {
|
||||||
* @param User $user_source
|
* @param User $user_source
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function User_Nick_render($user_source) {
|
function User_Nick_render($user_source)
|
||||||
|
{
|
||||||
return '<a class="' . ($user_source['Gekommen'] ? '' : 'text-muted') . '" href="' . page_link_to('users') . '&action=view&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') . '&action=view&user_id=' . $user_source['UID'] . '"><span class="icon-icon_angel"></span> ' . htmlspecialchars($user_source['Nick']) . '</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
function render_user_departure_date_hint() {
|
function render_user_departure_date_hint()
|
||||||
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
if (! isset($user['planned_departure_date']) || $user['planned_departure_date'] == null) {
|
if (! isset($user['planned_departure_date']) || $user['planned_departure_date'] == null) {
|
||||||
|
@ -450,7 +467,8 @@ function render_user_departure_date_hint() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function render_user_freeloader_hint() {
|
function render_user_freeloader_hint()
|
||||||
|
{
|
||||||
global $user, $max_freeloadable_shifts;
|
global $user, $max_freeloadable_shifts;
|
||||||
|
|
||||||
if (User_is_freeloader($user)) {
|
if (User_is_freeloader($user)) {
|
||||||
|
@ -461,7 +479,8 @@ function render_user_freeloader_hint() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hinweis für Engel, die noch nicht angekommen sind
|
// Hinweis für Engel, die noch nicht angekommen sind
|
||||||
function render_user_arrived_hint() {
|
function render_user_arrived_hint()
|
||||||
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
if ($user['Gekommen'] == 0) {
|
if ($user['Gekommen'] == 0) {
|
||||||
|
@ -471,7 +490,8 @@ function render_user_arrived_hint() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function render_user_tshirt_hint() {
|
function render_user_tshirt_hint()
|
||||||
|
{
|
||||||
global $enable_tshirt_size, $user;
|
global $enable_tshirt_size, $user;
|
||||||
|
|
||||||
if ($enable_tshirt_size && $user['Size'] == "") {
|
if ($enable_tshirt_size && $user['Size'] == "") {
|
||||||
|
@ -481,7 +501,8 @@ function render_user_tshirt_hint() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function render_user_dect_hint() {
|
function render_user_dect_hint()
|
||||||
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
if ($user['DECT'] == "") {
|
if ($user['DECT'] == "") {
|
||||||
|
@ -490,5 +511,3 @@ function render_user_dect_hint() {
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
|
@ -174,5 +174,3 @@ echo template_render(__DIR__ . '/../templates/layout.html', [
|
||||||
'locale' => locale(),
|
'locale' => locale(),
|
||||||
'event_info' => EventConfig_info($event_config) . '<br />'
|
'event_info' => EventConfig_info($event_config) . '<br />'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
|
@ -2,13 +2,15 @@
|
||||||
|
|
||||||
namespace Engelsystem\Test;
|
namespace Engelsystem\Test;
|
||||||
|
|
||||||
class LogEntriesModelTest extends \PHPUnit_Framework_TestCase {
|
class LogEntriesModelTest extends \PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
public function create_LogEntry() {
|
public function create_LogEntry()
|
||||||
|
{
|
||||||
LogEntry_create('test', 'test');
|
LogEntry_create('test', 'test');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_LogEntry_create() {
|
public function test_LogEntry_create()
|
||||||
|
{
|
||||||
$count = count(LogEntries());
|
$count = count(LogEntries());
|
||||||
$this->assertNotFalse(LogEntry_create('test', 'test_LogEntry_create'));
|
$this->assertNotFalse(LogEntry_create('test', 'test_LogEntry_create'));
|
||||||
|
|
||||||
|
@ -16,7 +18,8 @@ class LogEntriesModelTest extends \PHPUnit_Framework_TestCase {
|
||||||
$this->assertEquals(count(LogEntries()), $count + 1);
|
$this->assertEquals(count(LogEntries()), $count + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_LogEntries_clear_all() {
|
public function test_LogEntries_clear_all()
|
||||||
|
{
|
||||||
$this->create_LogEntry();
|
$this->create_LogEntry();
|
||||||
$this->assertTrue(count(LogEntries()) > 0);
|
$this->assertTrue(count(LogEntries()) > 0);
|
||||||
$this->assertNotFalse(LogEntries_clear_all());
|
$this->assertNotFalse(LogEntries_clear_all());
|
||||||
|
@ -26,9 +29,8 @@ class LogEntriesModelTest extends \PHPUnit_Framework_TestCase {
|
||||||
/**
|
/**
|
||||||
* @after
|
* @after
|
||||||
*/
|
*/
|
||||||
public function teardown() {
|
public function teardown()
|
||||||
|
{
|
||||||
LogEntries_clear_all();
|
LogEntries_clear_all();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
|
@ -2,15 +2,17 @@
|
||||||
|
|
||||||
namespace Engelsystem\Test;
|
namespace Engelsystem\Test;
|
||||||
|
|
||||||
class RoomModelTest extends \PHPUnit_Framework_TestCase {
|
class RoomModelTest extends \PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
private $room_id = null;
|
private $room_id = null;
|
||||||
|
|
||||||
public function create_Room() {
|
public function create_Room()
|
||||||
|
{
|
||||||
$this->room_id = Room_create('test', false, true, '');
|
$this->room_id = Room_create('test', false, true, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_Room() {
|
public function test_Room()
|
||||||
|
{
|
||||||
$this->create_Room();
|
$this->create_Room();
|
||||||
|
|
||||||
$room = Room($this->room_id);
|
$room = Room($this->room_id);
|
||||||
|
@ -25,11 +27,10 @@ class RoomModelTest extends \PHPUnit_Framework_TestCase {
|
||||||
/**
|
/**
|
||||||
* @after
|
* @after
|
||||||
*/
|
*/
|
||||||
public function teardown() {
|
public function teardown()
|
||||||
|
{
|
||||||
if ($this->room_id != null) {
|
if ($this->room_id != null) {
|
||||||
Room_delete($this->room_id);
|
Room_delete($this->room_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
Loading…
Reference in New Issue