Merge remote-tracking branch 'engelsystem/feature-igel-rewrite'
# Conflicts: # includes/controller/angeltypes_controller.php # includes/pages/admin_groups.php # includes/pages/user_settings.php # includes/sys_page.php # src/Exceptions/Handler.php # src/Http/Request.php
This commit is contained in:
commit
d0074cf006
|
@ -91,7 +91,7 @@ function event_config_edit_controller()
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($valid) {
|
if ($valid) {
|
||||||
$result = EventConfig_update(
|
EventConfig_update(
|
||||||
$event_name,
|
$event_name,
|
||||||
$buildup_start_date,
|
$buildup_start_date,
|
||||||
$event_start_date,
|
$event_start_date,
|
||||||
|
@ -100,10 +100,6 @@ function event_config_edit_controller()
|
||||||
$event_welcome_msg
|
$event_welcome_msg
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($result === false) {
|
|
||||||
engelsystem_error('Unable to update event config.');
|
|
||||||
}
|
|
||||||
|
|
||||||
engelsystem_log(
|
engelsystem_log(
|
||||||
'Changed event config: $event_name, $event_welcome_msg, '
|
'Changed event config: $event_name, $event_welcome_msg, '
|
||||||
. date('Y-m-d', $buildup_start_date) . ', ' . date('Y-m-d', $event_start_date) . ', '
|
. date('Y-m-d', $buildup_start_date) . ', ' . date('Y-m-d', $event_start_date) . ', '
|
||||||
|
|
|
@ -80,10 +80,7 @@ function rooms_controller()
|
||||||
case 'list':
|
case 'list':
|
||||||
default:
|
default:
|
||||||
redirect(page_link_to('admin_rooms'));
|
redirect(page_link_to('admin_rooms'));
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -43,7 +43,7 @@ function shift_entry_add_controller()
|
||||||
$type = AngelType($type_id);
|
$type = AngelType($type_id);
|
||||||
} else {
|
} else {
|
||||||
// TODO: Move queries to model
|
// TODO: Move queries to model
|
||||||
$type = DB::select('
|
$type = DB::selectOne('
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM `UserAngelTypes`
|
FROM `UserAngelTypes`
|
||||||
JOIN `AngelTypes` ON (`UserAngelTypes`.`angeltype_id` = `AngelTypes`.`id`)
|
JOIN `AngelTypes` ON (`UserAngelTypes`.`angeltype_id` = `AngelTypes`.`id`)
|
||||||
|
@ -56,7 +56,6 @@ function shift_entry_add_controller()
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
', [$type_id, $user['UID']]);
|
', [$type_id, $user['UID']]);
|
||||||
$type = array_shift($type);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($type)) {
|
if (empty($type)) {
|
||||||
|
@ -130,7 +129,7 @@ function shift_entry_add_controller()
|
||||||
}
|
}
|
||||||
|
|
||||||
$comment = strip_request_item_nl('comment');
|
$comment = strip_request_item_nl('comment');
|
||||||
$result = ShiftEntry_create([
|
ShiftEntry_create([
|
||||||
'SID' => $shift_id,
|
'SID' => $shift_id,
|
||||||
'TID' => $selected_type_id,
|
'TID' => $selected_type_id,
|
||||||
'UID' => $user_id,
|
'UID' => $user_id,
|
||||||
|
@ -138,9 +137,6 @@ function shift_entry_add_controller()
|
||||||
'freeloaded' => $freeloaded,
|
'freeloaded' => $freeloaded,
|
||||||
'freeload_comment' => $freeload_comment
|
'freeload_comment' => $freeload_comment
|
||||||
]);
|
]);
|
||||||
if ($result === false) {
|
|
||||||
engelsystem_error('Unable to create shift entry.');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (
|
if (
|
||||||
$type['restricted'] == 0
|
$type['restricted'] == 0
|
||||||
|
@ -244,7 +240,7 @@ function shift_entry_delete_controller()
|
||||||
}
|
}
|
||||||
$entry_id = $request->input('entry_id');
|
$entry_id = $request->input('entry_id');
|
||||||
|
|
||||||
$shift_entry_source = DB::select('
|
$shift_entry_source = DB::selectOne('
|
||||||
SELECT
|
SELECT
|
||||||
`User`.`Nick`,
|
`User`.`Nick`,
|
||||||
`ShiftEntry`.`Comment`,
|
`ShiftEntry`.`Comment`,
|
||||||
|
@ -263,19 +259,14 @@ function shift_entry_delete_controller()
|
||||||
WHERE `ShiftEntry`.`id`=?',
|
WHERE `ShiftEntry`.`id`=?',
|
||||||
[$entry_id]
|
[$entry_id]
|
||||||
);
|
);
|
||||||
if (count($shift_entry_source) > 0) {
|
if (!empty($shift_entry_source)) {
|
||||||
$shift_entry_source = array_shift($shift_entry_source);
|
|
||||||
|
|
||||||
if (!in_array('user_shifts_admin', $privileges) && (!in_array('shiftentry_edit_angeltype_supporter',
|
if (!in_array('user_shifts_admin', $privileges) && (!in_array('shiftentry_edit_angeltype_supporter',
|
||||||
$privileges) || !User_is_AngelType_supporter($user, AngelType($shift_entry_source['angeltype_id'])))
|
$privileges) || !User_is_AngelType_supporter($user, AngelType($shift_entry_source['angeltype_id'])))
|
||||||
) {
|
) {
|
||||||
redirect(page_link_to('user_shifts'));
|
redirect(page_link_to('user_shifts'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = ShiftEntry_delete($entry_id);
|
ShiftEntry_delete($entry_id);
|
||||||
if ($result === false) {
|
|
||||||
engelsystem_error('Unable to delete shift entry.');
|
|
||||||
}
|
|
||||||
|
|
||||||
engelsystem_log(
|
engelsystem_log(
|
||||||
'Deleted ' . User_Nick_render($shift_entry_source) . '\'s shift: ' . $shift_entry_source['name']
|
'Deleted ' . User_Nick_render($shift_entry_source) . '\'s shift: ' . $shift_entry_source['name']
|
||||||
|
|
|
@ -141,10 +141,7 @@ function shift_edit_controller()
|
||||||
$shift['start'] = $start;
|
$shift['start'] = $start;
|
||||||
$shift['end'] = $end;
|
$shift['end'] = $end;
|
||||||
|
|
||||||
$result = Shift_update($shift);
|
Shift_update($shift);
|
||||||
if ($result === false) {
|
|
||||||
engelsystem_error('Unable to update shift.');
|
|
||||||
}
|
|
||||||
NeededAngelTypes_delete_by_shift($shift_id);
|
NeededAngelTypes_delete_by_shift($shift_id);
|
||||||
$needed_angel_types_info = [];
|
$needed_angel_types_info = [];
|
||||||
foreach ($needed_angel_types as $type_id => $count) {
|
foreach ($needed_angel_types as $type_id => $count) {
|
||||||
|
@ -337,7 +334,6 @@ function shift_next_controller()
|
||||||
}
|
}
|
||||||
|
|
||||||
redirect(page_link_to('user_shifts'));
|
redirect(page_link_to('user_shifts'));
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -361,9 +357,6 @@ function shifts_json_export_all_controller()
|
||||||
}
|
}
|
||||||
|
|
||||||
$shifts_source = Shifts();
|
$shifts_source = Shifts();
|
||||||
if ($shifts_source === false) {
|
|
||||||
engelsystem_error('Unable to load shifts.');
|
|
||||||
}
|
|
||||||
|
|
||||||
header('Content-Type: application/json; charset=utf-8');
|
header('Content-Type: application/json; charset=utf-8');
|
||||||
raw_output(json_encode($shifts_source));
|
raw_output(json_encode($shifts_source));
|
||||||
|
|
|
@ -28,10 +28,7 @@ function shifttype_delete_controller()
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($request->has('confirmed')) {
|
if ($request->has('confirmed')) {
|
||||||
$result = ShiftType_delete($shifttype['id']);
|
ShiftType_delete($shifttype['id']);
|
||||||
if (empty($result)) {
|
|
||||||
engelsystem_error('Unable to delete shifttype.');
|
|
||||||
}
|
|
||||||
|
|
||||||
engelsystem_log('Deleted shifttype ' . $shifttype['name']);
|
engelsystem_log('Deleted shifttype ' . $shifttype['name']);
|
||||||
success(sprintf(_('Shifttype %s deleted.'), $shifttype['name']));
|
success(sprintf(_('Shifttype %s deleted.'), $shifttype['name']));
|
||||||
|
@ -93,17 +90,13 @@ function shifttype_edit_controller()
|
||||||
|
|
||||||
if ($valid) {
|
if ($valid) {
|
||||||
if ($shifttype_id) {
|
if ($shifttype_id) {
|
||||||
$result = ShiftType_update($shifttype_id, $name, $angeltype_id, $description);
|
ShiftType_update($shifttype_id, $name, $angeltype_id, $description);
|
||||||
if ($result === false) {
|
|
||||||
engelsystem_error('Unable to update shifttype.');
|
|
||||||
}
|
|
||||||
engelsystem_log('Updated shifttype ' . $name);
|
engelsystem_log('Updated shifttype ' . $name);
|
||||||
success(_('Updated shifttype.'));
|
success(_('Updated shifttype.'));
|
||||||
} else {
|
} else {
|
||||||
$shifttype_id = ShiftType_create($name, $angeltype_id, $description);
|
$shifttype_id = ShiftType_create($name, $angeltype_id, $description);
|
||||||
if ($shifttype_id === false) {
|
|
||||||
engelsystem_error('Unable to create shifttype.');
|
|
||||||
}
|
|
||||||
engelsystem_log('Created shifttype ' . $name);
|
engelsystem_log('Created shifttype ' . $name);
|
||||||
success(_('Created shifttype.'));
|
success(_('Created shifttype.'));
|
||||||
}
|
}
|
||||||
|
@ -150,9 +143,6 @@ function shifttype_controller()
|
||||||
function shifttypes_list_controller()
|
function shifttypes_list_controller()
|
||||||
{
|
{
|
||||||
$shifttypes = ShiftTypes();
|
$shifttypes = ShiftTypes();
|
||||||
if ($shifttypes === false) {
|
|
||||||
engelsystem_error('Unable to load shifttypes.');
|
|
||||||
}
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
shifttypes_title(),
|
shifttypes_title(),
|
||||||
|
|
|
@ -214,10 +214,7 @@ function user_angeltype_delete_controller()
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($request->has('confirmed')) {
|
if ($request->has('confirmed')) {
|
||||||
$result = UserAngelType_delete($user_angeltype);
|
UserAngelType_delete($user_angeltype);
|
||||||
if ($result === false) {
|
|
||||||
engelsystem_error('Unable to delete user angeltype.');
|
|
||||||
}
|
|
||||||
|
|
||||||
$success_message = sprintf(_('User %s removed from %s.'), User_Nick_render($user_source), $angeltype['name']);
|
$success_message = sprintf(_('User %s removed from %s.'), User_Nick_render($user_source), $angeltype['name']);
|
||||||
engelsystem_log($success_message);
|
engelsystem_log($success_message);
|
||||||
|
@ -421,6 +418,5 @@ function user_angeltypes_controller()
|
||||||
return user_angeltype_add_controller();
|
return user_angeltype_add_controller();
|
||||||
default:
|
default:
|
||||||
redirect(page_link_to('angeltypes'));
|
redirect(page_link_to('angeltypes'));
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,10 +76,7 @@ function user_delete_controller()
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($valid) {
|
if ($valid) {
|
||||||
$result = User_delete($user_source['UID']);
|
User_delete($user_source['UID']);
|
||||||
if ($result === false) {
|
|
||||||
engelsystem_error('Unable to delete user.');
|
|
||||||
}
|
|
||||||
|
|
||||||
mail_user_delete($user_source);
|
mail_user_delete($user_source);
|
||||||
success(_('User deleted.'));
|
success(_('User deleted.'));
|
||||||
|
@ -166,10 +163,7 @@ function user_edit_vouchers_controller()
|
||||||
if ($valid) {
|
if ($valid) {
|
||||||
$user_source['got_voucher'] = $vouchers;
|
$user_source['got_voucher'] = $vouchers;
|
||||||
|
|
||||||
$result = User_update($user_source);
|
User_update($user_source);
|
||||||
if ($result === false) {
|
|
||||||
engelsystem_error('Unable to update user.');
|
|
||||||
}
|
|
||||||
|
|
||||||
success(_('Saved the number of vouchers.'));
|
success(_('Saved the number of vouchers.'));
|
||||||
engelsystem_log(User_Nick_render($user_source) . ': ' . sprintf('Got %s vouchers',
|
engelsystem_log(User_Nick_render($user_source) . ': ' . sprintf('Got %s vouchers',
|
||||||
|
@ -265,10 +259,6 @@ function users_list_controller()
|
||||||
}
|
}
|
||||||
|
|
||||||
$users = Users($order_by);
|
$users = Users($order_by);
|
||||||
if ($users === false) {
|
|
||||||
engelsystem_error('Unable to load users.');
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($users as &$user) {
|
foreach ($users as &$user) {
|
||||||
$user['freeloads'] = count(ShiftEntries_freeloaded_by_user($user));
|
$user['freeloads'] = count(ShiftEntries_freeloaded_by_user($user));
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,31 +77,25 @@ function AngelType_contact_info($angeltype)
|
||||||
* Delete an Angeltype.
|
* Delete an Angeltype.
|
||||||
*
|
*
|
||||||
* @param array $angeltype
|
* @param array $angeltype
|
||||||
* @return bool
|
|
||||||
*/
|
*/
|
||||||
function AngelType_delete($angeltype)
|
function AngelType_delete($angeltype)
|
||||||
{
|
{
|
||||||
$result = DB::delete('
|
DB::delete('
|
||||||
DELETE FROM `AngelTypes`
|
DELETE FROM `AngelTypes`
|
||||||
WHERE `id`=?
|
WHERE `id`=?
|
||||||
LIMIT 1
|
LIMIT 1
|
||||||
', [$angeltype['id']]);
|
', [$angeltype['id']]);
|
||||||
if (is_null($result)) {
|
|
||||||
engelsystem_error('Unable to delete angeltype.');
|
|
||||||
}
|
|
||||||
engelsystem_log('Deleted angeltype: ' . AngelType_name_render($angeltype));
|
engelsystem_log('Deleted angeltype: ' . AngelType_name_render($angeltype));
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update Angeltype.
|
* Update Angeltype.
|
||||||
*
|
*
|
||||||
* @param array $angeltype The angeltype
|
* @param array $angeltype The angeltype
|
||||||
* @return bool
|
|
||||||
*/
|
*/
|
||||||
function AngelType_update($angeltype)
|
function AngelType_update($angeltype)
|
||||||
{
|
{
|
||||||
$result = DB::update('
|
DB::update('
|
||||||
UPDATE `AngelTypes` SET
|
UPDATE `AngelTypes` SET
|
||||||
`name` = ?,
|
`name` = ?,
|
||||||
`restricted` = ?,
|
`restricted` = ?,
|
||||||
|
@ -126,15 +120,12 @@ function AngelType_update($angeltype)
|
||||||
$angeltype['id'],
|
$angeltype['id'],
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
if (is_null($result)) {
|
|
||||||
engelsystem_error('Unable to update angeltype.');
|
|
||||||
}
|
|
||||||
engelsystem_log(
|
engelsystem_log(
|
||||||
'Updated angeltype: ' . $angeltype['name'] . ($angeltype['restricted'] ? ', restricted' : '')
|
'Updated angeltype: ' . $angeltype['name'] . ($angeltype['restricted'] ? ', restricted' : '')
|
||||||
. ($angeltype['no_self_signup'] ? ', no_self_signup' : '')
|
. ($angeltype['no_self_signup'] ? ', no_self_signup' : '')
|
||||||
. ($angeltype['requires_driver_license'] ? ', requires driver license' : '')
|
. ($angeltype['requires_driver_license'] ? ', requires driver license' : '')
|
||||||
);
|
);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -145,7 +136,7 @@ function AngelType_update($angeltype)
|
||||||
*/
|
*/
|
||||||
function AngelType_create($angeltype)
|
function AngelType_create($angeltype)
|
||||||
{
|
{
|
||||||
$result = DB::insert('
|
DB::insert('
|
||||||
INSERT INTO `AngelTypes` (
|
INSERT INTO `AngelTypes` (
|
||||||
`name`,
|
`name`,
|
||||||
`restricted`,
|
`restricted`,
|
||||||
|
@ -171,9 +162,7 @@ function AngelType_create($angeltype)
|
||||||
$angeltype['contact_email'],
|
$angeltype['contact_email'],
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
if (is_null($result)) {
|
|
||||||
engelsystem_error('Unable to create angeltype.');
|
|
||||||
}
|
|
||||||
$angeltype['id'] = DB::getPdo()->lastInsertId();
|
$angeltype['id'] = DB::getPdo()->lastInsertId();
|
||||||
engelsystem_log(
|
engelsystem_log(
|
||||||
'Created angeltype: ' . $angeltype['name']
|
'Created angeltype: ' . $angeltype['name']
|
||||||
|
@ -224,7 +213,7 @@ function AngelType_validate_name($name, $angeltype)
|
||||||
*/
|
*/
|
||||||
function AngelTypes_with_user($user)
|
function AngelTypes_with_user($user)
|
||||||
{
|
{
|
||||||
$result = DB::select('
|
return DB::select('
|
||||||
SELECT `AngelTypes`.*,
|
SELECT `AngelTypes`.*,
|
||||||
`UserAngelTypes`.`id` AS `user_angeltype_id`,
|
`UserAngelTypes`.`id` AS `user_angeltype_id`,
|
||||||
`UserAngelTypes`.`confirm_user_id`,
|
`UserAngelTypes`.`confirm_user_id`,
|
||||||
|
@ -233,11 +222,6 @@ function AngelTypes_with_user($user)
|
||||||
LEFT JOIN `UserAngelTypes` ON `AngelTypes`.`id`=`UserAngelTypes`.`angeltype_id`
|
LEFT JOIN `UserAngelTypes` ON `AngelTypes`.`id`=`UserAngelTypes`.`angeltype_id`
|
||||||
AND `UserAngelTypes`.`user_id` = ?
|
AND `UserAngelTypes`.`user_id` = ?
|
||||||
ORDER BY `name`', [$user['UID']]);
|
ORDER BY `name`', [$user['UID']]);
|
||||||
|
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
engelsystem_error('Unable to load angeltypes.');
|
|
||||||
}
|
|
||||||
return $result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -247,15 +231,10 @@ function AngelTypes_with_user($user)
|
||||||
*/
|
*/
|
||||||
function AngelTypes()
|
function AngelTypes()
|
||||||
{
|
{
|
||||||
$result = DB::select('
|
return DB::select('
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM `AngelTypes`
|
FROM `AngelTypes`
|
||||||
ORDER BY `name`');
|
ORDER BY `name`');
|
||||||
|
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
engelsystem_error('Unable to load angeltypes.');
|
|
||||||
}
|
|
||||||
return $result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -266,10 +245,6 @@ function AngelTypes()
|
||||||
function AngelType_ids()
|
function AngelType_ids()
|
||||||
{
|
{
|
||||||
$result = DB::select('SELECT `id` FROM `AngelTypes`');
|
$result = DB::select('SELECT `id` FROM `AngelTypes`');
|
||||||
|
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
engelsystem_error('Unable to load angeltypes.');
|
|
||||||
}
|
|
||||||
return select_array($result, 'id', 'id');
|
return select_array($result, 'id', 'id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -281,18 +256,8 @@ function AngelType_ids()
|
||||||
*/
|
*/
|
||||||
function AngelType($angeltype_id)
|
function AngelType($angeltype_id)
|
||||||
{
|
{
|
||||||
$angelType_source = DB::select(
|
return DB::selectOne(
|
||||||
'SELECT * FROM `AngelTypes` WHERE `id`=?',
|
'SELECT * FROM `AngelTypes` WHERE `id`=?',
|
||||||
[$angeltype_id]
|
[$angeltype_id]
|
||||||
);
|
);
|
||||||
|
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
engelsystem_error('Unable to load angeltype.');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($angelType_source)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return array_shift($angelType_source);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,17 +9,7 @@ use Engelsystem\Database\DB;
|
||||||
*/
|
*/
|
||||||
function EventConfig()
|
function EventConfig()
|
||||||
{
|
{
|
||||||
$event_config = DB::select('SELECT * FROM `EventConfig` LIMIT 1');
|
return DB::selectOne('SELECT * FROM `EventConfig` LIMIT 1');
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
engelsystem_error('Unable to load event config.');
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($event_config)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return array_shift($event_config);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -31,7 +21,7 @@ function EventConfig()
|
||||||
* @param int $event_end_date
|
* @param int $event_end_date
|
||||||
* @param int $teardown_end_date
|
* @param int $teardown_end_date
|
||||||
* @param string $event_welcome_msg
|
* @param string $event_welcome_msg
|
||||||
* @return bool
|
* @return int Rows updated
|
||||||
*/
|
*/
|
||||||
function EventConfig_update(
|
function EventConfig_update(
|
||||||
$event_name,
|
$event_name,
|
||||||
|
|
|
@ -20,11 +20,7 @@ function Message_ids()
|
||||||
*/
|
*/
|
||||||
function Message($message_id)
|
function Message($message_id)
|
||||||
{
|
{
|
||||||
$message_source = DB::select('SELECT * FROM `Messages` WHERE `id`=? LIMIT 1', [$message_id]);
|
return DB::selectOne('SELECT * FROM `Messages` WHERE `id`=? LIMIT 1', [$message_id]);
|
||||||
if (empty($message_source)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return array_shift($message_source);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -17,7 +17,7 @@ use Engelsystem\Database\DB;
|
||||||
*/
|
*/
|
||||||
function NeededAngelType_add($shift_id, $angeltype_id, $room_id, $count)
|
function NeededAngelType_add($shift_id, $angeltype_id, $room_id, $count)
|
||||||
{
|
{
|
||||||
$result = DB::insert('
|
DB::insert('
|
||||||
INSERT INTO `NeededAngelTypes` ( `shift_id`, `angel_type_id`, `room_id`, `count`)
|
INSERT INTO `NeededAngelTypes` ( `shift_id`, `angel_type_id`, `room_id`, `count`)
|
||||||
VALUES (?, ?, ?, ?)
|
VALUES (?, ?, ?, ?)
|
||||||
',
|
',
|
||||||
|
@ -27,9 +27,6 @@ function NeededAngelType_add($shift_id, $angeltype_id, $room_id, $count)
|
||||||
$room_id,
|
$room_id,
|
||||||
$count,
|
$count,
|
||||||
]);
|
]);
|
||||||
if ($result === false) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return DB::getPdo()->lastInsertId();
|
return DB::getPdo()->lastInsertId();
|
||||||
}
|
}
|
||||||
|
@ -38,22 +35,20 @@ function NeededAngelType_add($shift_id, $angeltype_id, $room_id, $count)
|
||||||
* Deletes all needed angel types from given shift.
|
* Deletes all needed angel types from given shift.
|
||||||
*
|
*
|
||||||
* @param int $shift_id id of the shift
|
* @param int $shift_id id of the shift
|
||||||
* @return int count of affected rows
|
|
||||||
*/
|
*/
|
||||||
function NeededAngelTypes_delete_by_shift($shift_id)
|
function NeededAngelTypes_delete_by_shift($shift_id)
|
||||||
{
|
{
|
||||||
return (int)DB::delete('DELETE FROM `NeededAngelTypes` WHERE `shift_id` = ?', [$shift_id]);
|
DB::delete('DELETE FROM `NeededAngelTypes` WHERE `shift_id` = ?', [$shift_id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes all needed angel types from given room.
|
* Deletes all needed angel types from given room.
|
||||||
*
|
*
|
||||||
* @param int $room_id id of the room
|
* @param int $room_id id of the room
|
||||||
* @return int count of affected rows
|
|
||||||
*/
|
*/
|
||||||
function NeededAngelTypes_delete_by_room($room_id)
|
function NeededAngelTypes_delete_by_room($room_id)
|
||||||
{
|
{
|
||||||
return (int)DB::delete(
|
DB::delete(
|
||||||
'DELETE FROM `NeededAngelTypes` WHERE `room_id` = ?',
|
'DELETE FROM `NeededAngelTypes` WHERE `room_id` = ?',
|
||||||
[$room_id]
|
[$room_id]
|
||||||
);
|
);
|
||||||
|
@ -76,9 +71,6 @@ function NeededAngelTypes_by_shift($shiftId)
|
||||||
ORDER BY `room_id` DESC',
|
ORDER BY `room_id` DESC',
|
||||||
[$shiftId]
|
[$shiftId]
|
||||||
);
|
);
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
engelsystem_error('Unable to load needed angeltypes.');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Use settings from room
|
// Use settings from room
|
||||||
if (count($needed_angeltypes_source) == 0) {
|
if (count($needed_angeltypes_source) == 0) {
|
||||||
|
@ -91,9 +83,6 @@ function NeededAngelTypes_by_shift($shiftId)
|
||||||
AND `count` > 0
|
AND `count` > 0
|
||||||
ORDER BY `room_id` DESC
|
ORDER BY `room_id` DESC
|
||||||
', [$shiftId]);
|
', [$shiftId]);
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
engelsystem_error('Unable to load needed angeltypes.');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$shift_entries = ShiftEntries_by_shift($shiftId);
|
$shift_entries = ShiftEntries_by_shift($shiftId);
|
||||||
|
|
|
@ -17,11 +17,10 @@ function Rooms($show_all = false)
|
||||||
* Delete a room
|
* Delete a room
|
||||||
*
|
*
|
||||||
* @param int $room_id
|
* @param int $room_id
|
||||||
* @return bool
|
|
||||||
*/
|
*/
|
||||||
function Room_delete($room_id)
|
function Room_delete($room_id)
|
||||||
{
|
{
|
||||||
return DB::delete('DELETE FROM `Room` WHERE `RID` = ?', [$room_id]);
|
DB::delete('DELETE FROM `Room` WHERE `RID` = ?', [$room_id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -35,7 +34,7 @@ function Room_delete($room_id)
|
||||||
*/
|
*/
|
||||||
function Room_create($name, $from_frab, $public, $number = null)
|
function Room_create($name, $from_frab, $public, $number = null)
|
||||||
{
|
{
|
||||||
$result = DB::insert('
|
DB::insert('
|
||||||
INSERT INTO `Room` (`Name`, `FromPentabarf`, `show`, `Number`)
|
INSERT INTO `Room` (`Name`, `FromPentabarf`, `show`, `Number`)
|
||||||
VALUES (?, ?, ?, ?)
|
VALUES (?, ?, ?, ?)
|
||||||
',
|
',
|
||||||
|
@ -46,9 +45,6 @@ function Room_create($name, $from_frab, $public, $number = null)
|
||||||
(int)$number,
|
(int)$number,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
if (!$result) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return DB::getPdo()->lastInsertId();
|
return DB::getPdo()->lastInsertId();
|
||||||
}
|
}
|
||||||
|
@ -62,21 +58,11 @@ function Room_create($name, $from_frab, $public, $number = null)
|
||||||
*/
|
*/
|
||||||
function Room($room_id, $onlyVisible = true)
|
function Room($room_id, $onlyVisible = true)
|
||||||
{
|
{
|
||||||
$room_source = DB::select('
|
return DB::selectOne('
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM `Room`
|
FROM `Room`
|
||||||
WHERE `RID` = ?
|
WHERE `RID` = ?
|
||||||
' . ($onlyVisible ? 'AND `show` = \'Y\'' : ''),
|
' . ($onlyVisible ? 'AND `show` = \'Y\'' : ''),
|
||||||
[$room_id]
|
[$room_id]
|
||||||
);
|
);
|
||||||
|
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($room_source)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return array_shift($room_source);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,10 +28,9 @@ function ShiftEntry_new()
|
||||||
*/
|
*/
|
||||||
function ShiftEntries_freeleaded_count()
|
function ShiftEntries_freeleaded_count()
|
||||||
{
|
{
|
||||||
$result = DB::select('SELECT COUNT(*) FROM `ShiftEntry` WHERE `freeloaded` = 1');
|
$result = DB::selectOne('SELECT COUNT(*) FROM `ShiftEntry` WHERE `freeloaded` = 1');
|
||||||
$result = array_shift($result);
|
|
||||||
|
|
||||||
if (!is_array($result)) {
|
if (empty($result)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,7 +101,6 @@ function ShiftEntry_create($shift_entry)
|
||||||
* Update a shift entry.
|
* Update a shift entry.
|
||||||
*
|
*
|
||||||
* @param array $shift_entry
|
* @param array $shift_entry
|
||||||
* @return bool
|
|
||||||
*/
|
*/
|
||||||
function ShiftEntry_update($shift_entry)
|
function ShiftEntry_update($shift_entry)
|
||||||
{
|
{
|
||||||
|
@ -120,39 +118,29 @@ function ShiftEntry_update($shift_entry)
|
||||||
$shift_entry['id']
|
$shift_entry['id']
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
return (DB::getStm()->errorCode() == '00000');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a shift entry.
|
* Get a shift entry.
|
||||||
*
|
*
|
||||||
* @param int $shift_entry_id
|
* @param int $shift_entry_id
|
||||||
* @return array|false|null
|
* @return array|null
|
||||||
*/
|
*/
|
||||||
function ShiftEntry($shift_entry_id)
|
function ShiftEntry($shift_entry_id)
|
||||||
{
|
{
|
||||||
$shift_entry = DB::select('SELECT * FROM `ShiftEntry` WHERE `id` = ?', [$shift_entry_id]);
|
return DB::selectOne('SELECT * FROM `ShiftEntry` WHERE `id` = ?', [$shift_entry_id]);
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (empty($shift_entry)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return $shift_entry[0];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a shift entry.
|
* Delete a shift entry.
|
||||||
*
|
*
|
||||||
* @param int $shift_entry_id
|
* @param int $shift_entry_id
|
||||||
* @return bool
|
|
||||||
*/
|
*/
|
||||||
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 DB::delete('DELETE FROM `ShiftEntry` WHERE `id` = ?', [$shift_entry_id]);
|
DB::delete('DELETE FROM `ShiftEntry` WHERE `id` = ?', [$shift_entry_id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -213,7 +201,7 @@ function ShiftEntries_finished_by_user($user)
|
||||||
*/
|
*/
|
||||||
function ShiftEntries_by_shift_and_angeltype($shift_id, $angeltype_id)
|
function ShiftEntries_by_shift_and_angeltype($shift_id, $angeltype_id)
|
||||||
{
|
{
|
||||||
$result = DB::select('
|
return DB::select('
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM `ShiftEntry`
|
FROM `ShiftEntry`
|
||||||
WHERE `SID` = ?
|
WHERE `SID` = ?
|
||||||
|
@ -224,10 +212,6 @@ function ShiftEntries_by_shift_and_angeltype($shift_id, $angeltype_id)
|
||||||
$angeltype_id,
|
$angeltype_id,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
engelsystem_error('Unable to load shift entries.');
|
|
||||||
}
|
|
||||||
return $result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -6,11 +6,10 @@ use Engelsystem\Database\DB;
|
||||||
* Delete a shift type.
|
* Delete a shift type.
|
||||||
*
|
*
|
||||||
* @param int $shifttype_id
|
* @param int $shifttype_id
|
||||||
* @return bool
|
|
||||||
*/
|
*/
|
||||||
function ShiftType_delete($shifttype_id)
|
function ShiftType_delete($shifttype_id)
|
||||||
{
|
{
|
||||||
return DB::delete('DELETE FROM `ShiftTypes` WHERE `id`=?', [$shifttype_id]);
|
DB::delete('DELETE FROM `ShiftTypes` WHERE `id`=?', [$shifttype_id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -20,7 +19,6 @@ function ShiftType_delete($shifttype_id)
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @param int $angeltype_id
|
* @param int $angeltype_id
|
||||||
* @param string $description
|
* @param string $description
|
||||||
* @return bool
|
|
||||||
*/
|
*/
|
||||||
function ShiftType_update($shifttype_id, $name, $angeltype_id, $description)
|
function ShiftType_update($shifttype_id, $name, $angeltype_id, $description)
|
||||||
{
|
{
|
||||||
|
@ -38,8 +36,6 @@ function ShiftType_update($shifttype_id, $name, $angeltype_id, $description)
|
||||||
$shifttype_id,
|
$shifttype_id,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
return DB::getStm()->errorCode() == '00000';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -52,7 +48,7 @@ function ShiftType_update($shifttype_id, $name, $angeltype_id, $description)
|
||||||
*/
|
*/
|
||||||
function ShiftType_create($name, $angeltype_id, $description)
|
function ShiftType_create($name, $angeltype_id, $description)
|
||||||
{
|
{
|
||||||
$result = DB::insert('
|
DB::insert('
|
||||||
INSERT INTO `ShiftTypes` (`name`, `angeltype_id`, `description`)
|
INSERT INTO `ShiftTypes` (`name`, `angeltype_id`, `description`)
|
||||||
VALUES(?, ?, ?)
|
VALUES(?, ?, ?)
|
||||||
',
|
',
|
||||||
|
@ -63,10 +59,6 @@ function ShiftType_create($name, $angeltype_id, $description)
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($result === false) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return DB::getPdo()->lastInsertId();
|
return DB::getPdo()->lastInsertId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,28 +70,15 @@ function ShiftType_create($name, $angeltype_id, $description)
|
||||||
*/
|
*/
|
||||||
function ShiftType($shifttype_id)
|
function ShiftType($shifttype_id)
|
||||||
{
|
{
|
||||||
$shifttype = DB::select('SELECT * FROM `ShiftTypes` WHERE `id`=?', [$shifttype_id]);
|
return DB::selectOne('SELECT * FROM `ShiftTypes` WHERE `id`=?', [$shifttype_id]);
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
engelsystem_error('Unable to load shift type.');
|
|
||||||
}
|
|
||||||
if (empty($shifttype)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return array_shift($shifttype);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all shift types.
|
* Get all shift types.
|
||||||
*
|
*
|
||||||
* @return array|false
|
* @return array
|
||||||
*/
|
*/
|
||||||
function ShiftTypes()
|
function ShiftTypes()
|
||||||
{
|
{
|
||||||
$result = DB::select('SELECT * FROM `ShiftTypes` ORDER BY `name`');
|
return DB::select('SELECT * FROM `ShiftTypes` ORDER BY `name`');
|
||||||
|
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $result;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,11 +10,7 @@ use Engelsystem\ShiftSignupState;
|
||||||
*/
|
*/
|
||||||
function Shifts_by_room($room)
|
function Shifts_by_room($room)
|
||||||
{
|
{
|
||||||
$result = DB::select('SELECT * FROM `Shifts` WHERE `RID`=? ORDER BY `start`', [$room['RID']]);
|
return DB::select('SELECT * FROM `Shifts` WHERE `RID`=? ORDER BY `start`', [$room['RID']]);
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
engelsystem_error('Unable to load shifts.');
|
|
||||||
}
|
|
||||||
return $result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -49,7 +45,8 @@ function Shifts_by_ShiftsFilter(ShiftsFilter $shiftsFilter)
|
||||||
AND NOT `Shifts`.`PSID` IS NULL) AS tmp_shifts
|
AND NOT `Shifts`.`PSID` IS NULL) AS tmp_shifts
|
||||||
|
|
||||||
ORDER BY `start`';
|
ORDER BY `start`';
|
||||||
$result = DB::select(
|
|
||||||
|
return DB::select(
|
||||||
$sql,
|
$sql,
|
||||||
[
|
[
|
||||||
$shiftsFilter->getStartTime(),
|
$shiftsFilter->getStartTime(),
|
||||||
|
@ -58,10 +55,6 @@ function Shifts_by_ShiftsFilter(ShiftsFilter $shiftsFilter)
|
||||||
$shiftsFilter->getEndTime(),
|
$shiftsFilter->getEndTime(),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
engelsystem_error('Unable to load shifts by filter.');
|
|
||||||
}
|
|
||||||
return $result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -100,7 +93,8 @@ function NeededAngeltypes_by_ShiftsFilter(ShiftsFilter $shiftsFilter)
|
||||||
WHERE `Shifts`.`RID` IN (' . implode(',', $shiftsFilter->getRooms()) . ')
|
WHERE `Shifts`.`RID` IN (' . implode(',', $shiftsFilter->getRooms()) . ')
|
||||||
AND `start` BETWEEN ? AND ?
|
AND `start` BETWEEN ? AND ?
|
||||||
AND NOT `Shifts`.`PSID` IS NULL';
|
AND NOT `Shifts`.`PSID` IS NULL';
|
||||||
$result = DB::select(
|
|
||||||
|
return DB::select(
|
||||||
$sql,
|
$sql,
|
||||||
[
|
[
|
||||||
$shiftsFilter->getStartTime(),
|
$shiftsFilter->getStartTime(),
|
||||||
|
@ -109,10 +103,6 @@ function NeededAngeltypes_by_ShiftsFilter(ShiftsFilter $shiftsFilter)
|
||||||
$shiftsFilter->getEndTime(),
|
$shiftsFilter->getEndTime(),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
engelsystem_error('Unable to load needed angeltypes by filter.');
|
|
||||||
}
|
|
||||||
return $result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -122,7 +112,7 @@ function NeededAngeltypes_by_ShiftsFilter(ShiftsFilter $shiftsFilter)
|
||||||
*/
|
*/
|
||||||
function NeededAngeltype_by_Shift_and_Angeltype($shift, $angeltype)
|
function NeededAngeltype_by_Shift_and_Angeltype($shift, $angeltype)
|
||||||
{
|
{
|
||||||
$result = DB::select('
|
return DB::selectOne('
|
||||||
SELECT
|
SELECT
|
||||||
`NeededAngelTypes`.*,
|
`NeededAngelTypes`.*,
|
||||||
`Shifts`.`SID`,
|
`Shifts`.`SID`,
|
||||||
|
@ -160,13 +150,6 @@ function NeededAngeltype_by_Shift_and_Angeltype($shift, $angeltype)
|
||||||
$angeltype['id']
|
$angeltype['id']
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
engelsystem_error('Unable to load needed angeltypes by filter.');
|
|
||||||
}
|
|
||||||
if (empty($result)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return $result[0];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -193,17 +176,13 @@ function ShiftEntries_by_ShiftsFilter(ShiftsFilter $shiftsFilter)
|
||||||
WHERE `Shifts`.`RID` IN (' . implode(',', $shiftsFilter->getRooms()) . ')
|
WHERE `Shifts`.`RID` IN (' . implode(',', $shiftsFilter->getRooms()) . ')
|
||||||
AND `start` BETWEEN ? AND ?
|
AND `start` BETWEEN ? AND ?
|
||||||
ORDER BY `Shifts`.`start`';
|
ORDER BY `Shifts`.`start`';
|
||||||
$result = DB::select(
|
return DB::select(
|
||||||
$sql,
|
$sql,
|
||||||
[
|
[
|
||||||
$shiftsFilter->getStartTime(),
|
$shiftsFilter->getStartTime(),
|
||||||
$shiftsFilter->getEndTime(),
|
$shiftsFilter->getEndTime(),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
engelsystem_error('Unable to load shift entries by filter.');
|
|
||||||
}
|
|
||||||
return $result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -402,41 +381,29 @@ function Shift_signup_allowed(
|
||||||
* Delete a shift by its external id.
|
* Delete a shift by its external id.
|
||||||
*
|
*
|
||||||
* @param int $shift_psid
|
* @param int $shift_psid
|
||||||
* @return bool
|
|
||||||
*/
|
*/
|
||||||
function Shift_delete_by_psid($shift_psid)
|
function Shift_delete_by_psid($shift_psid)
|
||||||
{
|
{
|
||||||
DB::delete('DELETE FROM `Shifts` WHERE `PSID`=?', [$shift_psid]);
|
DB::delete('DELETE FROM `Shifts` WHERE `PSID`=?', [$shift_psid]);
|
||||||
|
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a shift.
|
* Delete a shift.
|
||||||
*
|
*
|
||||||
* @param int $shift_id
|
* @param int $shift_id
|
||||||
* @return bool
|
|
||||||
*/
|
*/
|
||||||
function Shift_delete($shift_id)
|
function Shift_delete($shift_id)
|
||||||
{
|
{
|
||||||
mail_shift_delete(Shift($shift_id));
|
mail_shift_delete(Shift($shift_id));
|
||||||
|
|
||||||
$result = DB::delete('DELETE FROM `Shifts` WHERE `SID`=?', [$shift_id]);
|
DB::delete('DELETE FROM `Shifts` WHERE `SID`=?', [$shift_id]);
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
engelsystem_error('Unable to delete shift.');
|
|
||||||
}
|
|
||||||
return $result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update a shift.
|
* Update a shift.
|
||||||
*
|
*
|
||||||
* @param array $shift
|
* @param array $shift
|
||||||
* @return bool
|
* @return int Updated row count
|
||||||
*/
|
*/
|
||||||
function Shift_update($shift)
|
function Shift_update($shift)
|
||||||
{
|
{
|
||||||
|
@ -444,7 +411,7 @@ function Shift_update($shift)
|
||||||
$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);
|
||||||
|
|
||||||
return (bool)DB::update('
|
return DB::update('
|
||||||
UPDATE `Shifts` SET
|
UPDATE `Shifts` SET
|
||||||
`shifttype_id` = ?,
|
`shifttype_id` = ?,
|
||||||
`start` = ?,
|
`start` = ?,
|
||||||
|
@ -480,16 +447,13 @@ function Shift_update($shift)
|
||||||
*/
|
*/
|
||||||
function Shift_update_by_psid($shift)
|
function Shift_update_by_psid($shift)
|
||||||
{
|
{
|
||||||
$shift_source = DB::select('SELECT `SID` FROM `Shifts` WHERE `PSID`=?', [$shift['PSID']]);
|
$shift_source = DB::selectOne('SELECT `SID` FROM `Shifts` WHERE `PSID`=?', [$shift['PSID']]);
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($shift_source)) {
|
if (empty($shift_source)) {
|
||||||
return null;
|
throw new Exception('Shift not found.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$shift['SID'] = $shift_source[0]['SID'];
|
$shift['SID'] = $shift_source['SID'];
|
||||||
return Shift_update($shift);
|
return Shift_update($shift);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -497,7 +461,7 @@ function Shift_update_by_psid($shift)
|
||||||
* Create a new shift.
|
* Create a new shift.
|
||||||
*
|
*
|
||||||
* @param array $shift
|
* @param array $shift
|
||||||
* @return int|false shift id or false
|
* @return int ID of the new created shift
|
||||||
*/
|
*/
|
||||||
function Shift_create($shift)
|
function Shift_create($shift)
|
||||||
{
|
{
|
||||||
|
@ -528,9 +492,7 @@ function Shift_create($shift)
|
||||||
time(),
|
time(),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return DB::getPdo()->lastInsertId();
|
return DB::getPdo()->lastInsertId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -543,7 +505,7 @@ function Shift_create($shift)
|
||||||
*/
|
*/
|
||||||
function Shifts_by_user($user, $include_freeload_comments = false)
|
function Shifts_by_user($user, $include_freeload_comments = false)
|
||||||
{
|
{
|
||||||
$result = DB::select('
|
return DB::select('
|
||||||
SELECT `ShiftTypes`.`id` AS `shifttype_id`, `ShiftTypes`.`name`,
|
SELECT `ShiftTypes`.`id` AS `shifttype_id`, `ShiftTypes`.`name`,
|
||||||
`ShiftEntry`.`id`, `ShiftEntry`.`SID`, `ShiftEntry`.`TID`, `ShiftEntry`.`UID`, `ShiftEntry`.`freeloaded`, `ShiftEntry`.`Comment`,
|
`ShiftEntry`.`id`, `ShiftEntry`.`SID`, `ShiftEntry`.`TID`, `ShiftEntry`.`UID`, `ShiftEntry`.`freeloaded`, `ShiftEntry`.`Comment`,
|
||||||
' . ($include_freeload_comments ? '`ShiftEntry`.`freeload_comment`, ' : '') . '
|
' . ($include_freeload_comments ? '`ShiftEntry`.`freeload_comment`, ' : '') . '
|
||||||
|
@ -559,10 +521,6 @@ function Shifts_by_user($user, $include_freeload_comments = false)
|
||||||
$user['UID']
|
$user['UID']
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
engelsystem_error('Unable to load users shifts.');
|
|
||||||
}
|
|
||||||
return $result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -573,22 +531,16 @@ function Shifts_by_user($user, $include_freeload_comments = false)
|
||||||
*/
|
*/
|
||||||
function Shift($shift_id)
|
function Shift($shift_id)
|
||||||
{
|
{
|
||||||
$shifts_source = DB::select('
|
$result = DB::selectOne('
|
||||||
SELECT `Shifts`.*, `ShiftTypes`.`name`
|
SELECT `Shifts`.*, `ShiftTypes`.`name`
|
||||||
FROM `Shifts`
|
FROM `Shifts`
|
||||||
JOIN `ShiftTypes` ON (`ShiftTypes`.`id` = `Shifts`.`shifttype_id`)
|
JOIN `ShiftTypes` ON (`ShiftTypes`.`id` = `Shifts`.`shifttype_id`)
|
||||||
WHERE `SID`=?', [$shift_id]);
|
WHERE `SID`=?', [$shift_id]);
|
||||||
|
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
if (empty($result)) {
|
||||||
engelsystem_error('Unable to load shift.');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($shifts_source)) {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $shifts_source[0];
|
|
||||||
|
|
||||||
$shiftsEntry_source = DB::select('
|
$shiftsEntry_source = DB::select('
|
||||||
SELECT `id`, `TID` , `UID` , `freeloaded`
|
SELECT `id`, `TID` , `UID` , `freeloaded`
|
||||||
FROM `ShiftEntry`
|
FROM `ShiftEntry`
|
||||||
|
@ -613,7 +565,7 @@ function Shift($shift_id)
|
||||||
/**
|
/**
|
||||||
* Returns all shifts with needed angeltypes and count of subscribed jobs.
|
* Returns all shifts with needed angeltypes and count of subscribed jobs.
|
||||||
*
|
*
|
||||||
* @return array|false
|
* @return array
|
||||||
*/
|
*/
|
||||||
function Shifts()
|
function Shifts()
|
||||||
{
|
{
|
||||||
|
@ -624,10 +576,6 @@ function Shifts()
|
||||||
JOIN `Room` ON `Room`.`RID` = `Shifts`.`RID`
|
JOIN `Room` ON `Room`.`RID` = `Shifts`.`RID`
|
||||||
');
|
');
|
||||||
|
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($shifts_source as &$shift) {
|
foreach ($shifts_source as &$shift) {
|
||||||
$needed_angeltypes = NeededAngelTypes_by_shift($shift['SID']);
|
$needed_angeltypes = NeededAngelTypes_by_shift($shift['SID']);
|
||||||
$shift['angeltypes'] = $needed_angeltypes;
|
$shift['angeltypes'] = $needed_angeltypes;
|
||||||
|
|
|
@ -27,23 +27,16 @@ function UserAngelType_exists($user, $angeltype)
|
||||||
* List users angeltypes.
|
* List users angeltypes.
|
||||||
*
|
*
|
||||||
* @param array $user
|
* @param array $user
|
||||||
* @return array|false
|
* @return array
|
||||||
*/
|
*/
|
||||||
function User_angeltypes($user)
|
function User_angeltypes($user)
|
||||||
{
|
{
|
||||||
$result = DB::select('
|
return DB::select('
|
||||||
SELECT `AngelTypes`.*, `UserAngelTypes`.`confirm_user_id`, `UserAngelTypes`.`supporter`
|
SELECT `AngelTypes`.*, `UserAngelTypes`.`confirm_user_id`, `UserAngelTypes`.`supporter`
|
||||||
FROM `UserAngelTypes`
|
FROM `UserAngelTypes`
|
||||||
JOIN `AngelTypes` ON `UserAngelTypes`.`angeltype_id` = `AngelTypes`.`id`
|
JOIN `AngelTypes` ON `UserAngelTypes`.`angeltype_id` = `AngelTypes`.`id`
|
||||||
WHERE `UserAngelTypes`.`user_id`=?
|
WHERE `UserAngelTypes`.`user_id`=?
|
||||||
', [$user['UID']]);
|
', [$user['UID']]);
|
||||||
|
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
engelsystem_error('Unable to load user angeltypes.');
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -54,7 +47,7 @@ function User_angeltypes($user)
|
||||||
*/
|
*/
|
||||||
function User_unconfirmed_AngelTypes($user)
|
function User_unconfirmed_AngelTypes($user)
|
||||||
{
|
{
|
||||||
$result = DB::select('
|
return DB::select('
|
||||||
SELECT
|
SELECT
|
||||||
`UserAngelTypes`.*,
|
`UserAngelTypes`.*,
|
||||||
`AngelTypes`.`name`,
|
`AngelTypes`.`name`,
|
||||||
|
@ -69,12 +62,6 @@ function User_unconfirmed_AngelTypes($user)
|
||||||
GROUP BY `UserAngelTypes`.`angeltype_id`
|
GROUP BY `UserAngelTypes`.`angeltype_id`
|
||||||
ORDER BY `AngelTypes`.`name`
|
ORDER BY `AngelTypes`.`name`
|
||||||
', [$user['UID']]);
|
', [$user['UID']]);
|
||||||
|
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
engelsystem_error('Unable to load user angeltypes.');
|
|
||||||
}
|
|
||||||
|
|
||||||
return $result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -110,29 +97,21 @@ function User_is_AngelType_supporter(&$user, $angeltype)
|
||||||
*
|
*
|
||||||
* @param int $user_angeltype_id
|
* @param int $user_angeltype_id
|
||||||
* @param bool $supporter
|
* @param bool $supporter
|
||||||
* @return int
|
|
||||||
*/
|
*/
|
||||||
function UserAngelType_update($user_angeltype_id, $supporter)
|
function UserAngelType_update($user_angeltype_id, $supporter)
|
||||||
{
|
{
|
||||||
$result = DB::update('
|
DB::update('
|
||||||
UPDATE `UserAngelTypes`
|
UPDATE `UserAngelTypes`
|
||||||
SET `supporter`=?
|
SET `supporter`=?
|
||||||
WHERE `id`=?
|
WHERE `id`=?
|
||||||
LIMIT 1
|
LIMIT 1
|
||||||
', [$supporter, $user_angeltype_id]);
|
', [$supporter, $user_angeltype_id]);
|
||||||
|
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
engelsystem_error('Unable to update supporter rights.');
|
|
||||||
}
|
|
||||||
|
|
||||||
return $result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete all unconfirmed UserAngelTypes for given Angeltype.
|
* Delete all unconfirmed UserAngelTypes for given Angeltype.
|
||||||
*
|
*
|
||||||
* @param int $angeltype_id
|
* @param int $angeltype_id
|
||||||
* @return bool
|
|
||||||
*/
|
*/
|
||||||
function UserAngelTypes_delete_all($angeltype_id)
|
function UserAngelTypes_delete_all($angeltype_id)
|
||||||
{
|
{
|
||||||
|
@ -141,12 +120,6 @@ function UserAngelTypes_delete_all($angeltype_id)
|
||||||
WHERE `angeltype_id`=?
|
WHERE `angeltype_id`=?
|
||||||
AND `confirm_user_id` IS NULL
|
AND `confirm_user_id` IS NULL
|
||||||
', [$angeltype_id]);
|
', [$angeltype_id]);
|
||||||
|
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
engelsystem_error('Unable to delete all unconfirmed users.');
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -154,22 +127,15 @@ function UserAngelTypes_delete_all($angeltype_id)
|
||||||
*
|
*
|
||||||
* @param int $angeltype_id
|
* @param int $angeltype_id
|
||||||
* @param array $confirm_user
|
* @param array $confirm_user
|
||||||
* @return bool
|
|
||||||
*/
|
*/
|
||||||
function UserAngelTypes_confirm_all($angeltype_id, $confirm_user)
|
function UserAngelTypes_confirm_all($angeltype_id, $confirm_user)
|
||||||
{
|
{
|
||||||
$result = DB::update('
|
DB::update('
|
||||||
UPDATE `UserAngelTypes`
|
UPDATE `UserAngelTypes`
|
||||||
SET `confirm_user_id`=?
|
SET `confirm_user_id`=?
|
||||||
WHERE `angeltype_id`=?
|
WHERE `angeltype_id`=?
|
||||||
AND `confirm_user_id` IS NULL
|
AND `confirm_user_id` IS NULL
|
||||||
', [$confirm_user['UID'], $angeltype_id]);
|
', [$confirm_user['UID'], $angeltype_id]);
|
||||||
|
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
engelsystem_error('Unable to confirm all users.');
|
|
||||||
}
|
|
||||||
|
|
||||||
return (bool)$result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -181,26 +147,21 @@ function UserAngelTypes_confirm_all($angeltype_id, $confirm_user)
|
||||||
*/
|
*/
|
||||||
function UserAngelType_confirm($user_angeltype_id, $confirm_user)
|
function UserAngelType_confirm($user_angeltype_id, $confirm_user)
|
||||||
{
|
{
|
||||||
$result = DB::update('
|
DB::update('
|
||||||
UPDATE `UserAngelTypes`
|
UPDATE `UserAngelTypes`
|
||||||
SET `confirm_user_id`=?
|
SET `confirm_user_id`=?
|
||||||
WHERE `id`=?
|
WHERE `id`=?
|
||||||
LIMIT 1', [$confirm_user['UID'], $user_angeltype_id]);
|
LIMIT 1', [$confirm_user['UID'], $user_angeltype_id]);
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
engelsystem_error('Unable to confirm user angeltype.');
|
|
||||||
}
|
|
||||||
return (bool)$result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete an UserAngelType.
|
* Delete an UserAngelType.
|
||||||
*
|
*
|
||||||
* @param array $user_angeltype
|
* @param array $user_angeltype
|
||||||
* @return bool
|
|
||||||
*/
|
*/
|
||||||
function UserAngelType_delete($user_angeltype)
|
function UserAngelType_delete($user_angeltype)
|
||||||
{
|
{
|
||||||
return (bool)DB::delete('
|
DB::delete('
|
||||||
DELETE FROM `UserAngelTypes`
|
DELETE FROM `UserAngelTypes`
|
||||||
WHERE `id`=?
|
WHERE `id`=?
|
||||||
LIMIT 1', [$user_angeltype['id']]);
|
LIMIT 1', [$user_angeltype['id']]);
|
||||||
|
@ -225,10 +186,6 @@ function UserAngelType_create($user, $angeltype)
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
engelsystem_error('Unable to create user angeltype.');
|
|
||||||
}
|
|
||||||
|
|
||||||
return DB::getPdo()->lastInsertId();
|
return DB::getPdo()->lastInsertId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -240,21 +197,11 @@ function UserAngelType_create($user, $angeltype)
|
||||||
*/
|
*/
|
||||||
function UserAngelType($user_angeltype_id)
|
function UserAngelType($user_angeltype_id)
|
||||||
{
|
{
|
||||||
$angeltype = DB::select('
|
return DB::selectOne('
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM `UserAngelTypes`
|
FROM `UserAngelTypes`
|
||||||
WHERE `id`=?
|
WHERE `id`=?
|
||||||
LIMIT 1', [$user_angeltype_id]);
|
LIMIT 1', [$user_angeltype_id]);
|
||||||
|
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
engelsystem_error('Unable to load user angeltype.');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($angeltype)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $angeltype[0];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -266,7 +213,7 @@ function UserAngelType($user_angeltype_id)
|
||||||
*/
|
*/
|
||||||
function UserAngelType_by_User_and_AngelType($user, $angeltype)
|
function UserAngelType_by_User_and_AngelType($user, $angeltype)
|
||||||
{
|
{
|
||||||
$angeltype = DB::select('
|
return DB::selectOne('
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM `UserAngelTypes`
|
FROM `UserAngelTypes`
|
||||||
WHERE `user_id`=?
|
WHERE `user_id`=?
|
||||||
|
@ -278,14 +225,4 @@ function UserAngelType_by_User_and_AngelType($user, $angeltype)
|
||||||
$angeltype['id']
|
$angeltype['id']
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
engelsystem_error('Unable to load user angeltype.');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($angeltype)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return array_shift($angeltype);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,25 +41,14 @@ function UserDriverLicense_valid($user_driver_license)
|
||||||
* Get a users driver license information
|
* Get a users driver license information
|
||||||
*
|
*
|
||||||
* @param int $user_id The users id
|
* @param int $user_id The users id
|
||||||
* @return array|false|null
|
* @return array|null
|
||||||
*/
|
*/
|
||||||
function UserDriverLicense($user_id)
|
function UserDriverLicense($user_id)
|
||||||
{
|
{
|
||||||
$user_driver_license = DB::select('
|
return DB::selectOne('
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM `UserDriverLicenses`
|
FROM `UserDriverLicenses`
|
||||||
WHERE `user_id`=?', [$user_id]);
|
WHERE `user_id`=?', [$user_id]);
|
||||||
|
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
engelsystem_error('Unable to load user driver license.');
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($user_driver_license)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return array_shift($user_driver_license);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -94,9 +83,6 @@ function UserDriverLicenses_create($user_driver_license, $user)
|
||||||
(bool)$user_driver_license['has_license_forklift'],
|
(bool)$user_driver_license['has_license_forklift'],
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
engelsystem_error('Unable to create user driver license');
|
|
||||||
}
|
|
||||||
|
|
||||||
return $user_driver_license;
|
return $user_driver_license;
|
||||||
}
|
}
|
||||||
|
@ -105,11 +91,10 @@ function UserDriverLicenses_create($user_driver_license, $user)
|
||||||
* Update a user's driver license entry
|
* Update a user's driver license entry
|
||||||
*
|
*
|
||||||
* @param array $user_driver_license The UserDriverLicense to update
|
* @param array $user_driver_license The UserDriverLicense to update
|
||||||
* @return bool
|
|
||||||
*/
|
*/
|
||||||
function UserDriverLicenses_update($user_driver_license)
|
function UserDriverLicenses_update($user_driver_license)
|
||||||
{
|
{
|
||||||
$result = DB::update('
|
DB::update('
|
||||||
UPDATE `UserDriverLicenses`
|
UPDATE `UserDriverLicenses`
|
||||||
SET
|
SET
|
||||||
`has_car`=?,
|
`has_car`=?,
|
||||||
|
@ -130,23 +115,14 @@ function UserDriverLicenses_update($user_driver_license)
|
||||||
$user_driver_license['user_id'],
|
$user_driver_license['user_id'],
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
engelsystem_error('Unable to update user driver license information');
|
|
||||||
}
|
|
||||||
return $result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a user's driver license entry
|
* Delete a user's driver license entry
|
||||||
*
|
*
|
||||||
* @param int $user_id
|
* @param int $user_id
|
||||||
* @return bool
|
|
||||||
*/
|
*/
|
||||||
function UserDriverLicenses_delete($user_id)
|
function UserDriverLicenses_delete($user_id)
|
||||||
{
|
{
|
||||||
$result = DB::delete('DELETE FROM `UserDriverLicenses` WHERE `user_id`=?', [$user_id]);
|
DB::delete('DELETE FROM `UserDriverLicenses` WHERE `user_id`=?', [$user_id]);
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
engelsystem_error('Unable to remove user driver license information');
|
|
||||||
}
|
|
||||||
return $result;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,24 +11,20 @@ use Engelsystem\ValidationResult;
|
||||||
* Delete a user
|
* Delete a user
|
||||||
*
|
*
|
||||||
* @param int $user_id
|
* @param int $user_id
|
||||||
* @return bool
|
|
||||||
*/
|
*/
|
||||||
function User_delete($user_id)
|
function User_delete($user_id)
|
||||||
{
|
{
|
||||||
DB::delete('DELETE FROM `User` WHERE `UID`=?', [$user_id]);
|
DB::delete('DELETE FROM `User` WHERE `UID`=?', [$user_id]);
|
||||||
|
|
||||||
return DB::getStm()->errorCode() == '00000';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update user.
|
* Update user.
|
||||||
*
|
*
|
||||||
* @param array $user
|
* @param array $user
|
||||||
* @return bool
|
|
||||||
*/
|
*/
|
||||||
function User_update($user)
|
function User_update($user)
|
||||||
{
|
{
|
||||||
return (bool)DB::update('
|
DB::update('
|
||||||
UPDATE `User` SET
|
UPDATE `User` SET
|
||||||
`Nick`=?,
|
`Nick`=?,
|
||||||
`Name`=?,
|
`Name`=?,
|
||||||
|
@ -91,8 +87,7 @@ function User_update($user)
|
||||||
*/
|
*/
|
||||||
function User_force_active_count()
|
function User_force_active_count()
|
||||||
{
|
{
|
||||||
$result = DB::select('SELECT COUNT(*) FROM `User` WHERE `force_active` = 1');
|
$result = DB::selectOne('SELECT COUNT(*) FROM `User` WHERE `force_active` = 1');
|
||||||
$result = array_shift($result);
|
|
||||||
|
|
||||||
if (empty($result)) {
|
if (empty($result)) {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -106,8 +101,7 @@ function User_force_active_count()
|
||||||
*/
|
*/
|
||||||
function User_active_count()
|
function User_active_count()
|
||||||
{
|
{
|
||||||
$result = DB::select('SELECT COUNT(*) FROM `User` WHERE `Aktiv` = 1');
|
$result = DB::selectOne('SELECT COUNT(*) FROM `User` WHERE `Aktiv` = 1');
|
||||||
$result = array_shift($result);
|
|
||||||
|
|
||||||
if (empty($result)) {
|
if (empty($result)) {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -121,8 +115,7 @@ function User_active_count()
|
||||||
*/
|
*/
|
||||||
function User_got_voucher_count()
|
function User_got_voucher_count()
|
||||||
{
|
{
|
||||||
$result = DB::select('SELECT SUM(`got_voucher`) FROM `User`');
|
$result = DB::selectOne('SELECT SUM(`got_voucher`) FROM `User`');
|
||||||
$result = array_shift($result);
|
|
||||||
|
|
||||||
if (empty($result)) {
|
if (empty($result)) {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -136,8 +129,7 @@ function User_got_voucher_count()
|
||||||
*/
|
*/
|
||||||
function User_arrived_count()
|
function User_arrived_count()
|
||||||
{
|
{
|
||||||
$result = DB::select('SELECT COUNT(*) FROM `User` WHERE `Gekommen` = 1');
|
$result = DB::selectOne('SELECT COUNT(*) FROM `User` WHERE `Gekommen` = 1');
|
||||||
$result = array_shift($result);
|
|
||||||
|
|
||||||
if (empty($result)) {
|
if (empty($result)) {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -151,8 +143,7 @@ function User_arrived_count()
|
||||||
*/
|
*/
|
||||||
function User_tshirts_count()
|
function User_tshirts_count()
|
||||||
{
|
{
|
||||||
$result = DB::select('SELECT COUNT(*) FROM `User` WHERE `Tshirt` = 1');
|
$result = DB::selectOne('SELECT COUNT(*) FROM `User` WHERE `Tshirt` = 1');
|
||||||
$result = array_shift($result);
|
|
||||||
|
|
||||||
if (empty($result)) {
|
if (empty($result)) {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -188,23 +179,17 @@ function User_sortable_columns()
|
||||||
* Get all users, ordered by Nick by default or by given param.
|
* Get all users, ordered by Nick by default or by given param.
|
||||||
*
|
*
|
||||||
* @param string $order_by
|
* @param string $order_by
|
||||||
* @return array|false
|
* @return array
|
||||||
*/
|
*/
|
||||||
function Users($order_by = 'Nick')
|
function Users($order_by = 'Nick')
|
||||||
{
|
{
|
||||||
$result = DB::select(sprintf('
|
return DB::select(sprintf('
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM `User`
|
FROM `User`
|
||||||
ORDER BY `%s` ASC
|
ORDER BY `%s` ASC
|
||||||
',
|
',
|
||||||
trim(DB::getPdo()->quote($order_by), '\'')
|
trim(DB::getPdo()->quote($order_by), '\'')
|
||||||
));
|
));
|
||||||
|
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -228,7 +213,7 @@ function User_is_freeloader($user)
|
||||||
*/
|
*/
|
||||||
function Users_by_angeltype_inverted($angeltype)
|
function Users_by_angeltype_inverted($angeltype)
|
||||||
{
|
{
|
||||||
$result = DB::select('
|
return DB::select('
|
||||||
SELECT `User`.*
|
SELECT `User`.*
|
||||||
FROM `User`
|
FROM `User`
|
||||||
LEFT JOIN `UserAngelTypes`
|
LEFT JOIN `UserAngelTypes`
|
||||||
|
@ -240,10 +225,6 @@ function Users_by_angeltype_inverted($angeltype)
|
||||||
$angeltype['id']
|
$angeltype['id']
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
engelsystem_error('Unable to load users.');
|
|
||||||
}
|
|
||||||
return $result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -254,12 +235,13 @@ function Users_by_angeltype_inverted($angeltype)
|
||||||
*/
|
*/
|
||||||
function Users_by_angeltype($angeltype)
|
function Users_by_angeltype($angeltype)
|
||||||
{
|
{
|
||||||
$result = DB::select('
|
return DB::select('
|
||||||
SELECT
|
SELECT
|
||||||
`User`.*,
|
`User`.*,
|
||||||
`UserAngelTypes`.`id` AS `user_angeltype_id`,
|
`UserAngelTypes`.`id` AS `user_angeltype_id`,
|
||||||
`UserAngelTypes`.`confirm_user_id`,
|
`UserAngelTypes`.`confirm_user_id`,
|
||||||
`UserAngelTypes`.`supporter`,
|
`UserAngelTypes`.`supporter`,
|
||||||
|
(`UserDriverLicenses`.`user_id` IS NOT NULL) as `wants_to_drive`,
|
||||||
`UserDriverLicenses`.*
|
`UserDriverLicenses`.*
|
||||||
FROM `User`
|
FROM `User`
|
||||||
JOIN `UserAngelTypes` ON `User`.`UID`=`UserAngelTypes`.`user_id`
|
JOIN `UserAngelTypes` ON `User`.`UID`=`UserAngelTypes`.`user_id`
|
||||||
|
@ -271,10 +253,6 @@ function Users_by_angeltype($angeltype)
|
||||||
$angeltype['id']
|
$angeltype['id']
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
engelsystem_error('Unable to load members.');
|
|
||||||
}
|
|
||||||
return $result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -399,17 +377,7 @@ function User_validate_planned_departure_date($planned_arrival_date, $planned_de
|
||||||
*/
|
*/
|
||||||
function User($user_id)
|
function User($user_id)
|
||||||
{
|
{
|
||||||
$user_source = DB::select('SELECT * FROM `User` WHERE `UID`=? LIMIT 1', [$user_id]);
|
return DB::selectOne('SELECT * FROM `User` WHERE `UID`=? LIMIT 1', [$user_id]);
|
||||||
|
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
engelsystem_error('Unable to load user.');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($user_source)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return array_shift($user_source);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -417,21 +385,11 @@ function User($user_id)
|
||||||
*
|
*
|
||||||
* @param string $api_key
|
* @param string $api_key
|
||||||
* User api key
|
* User api key
|
||||||
* @return array|null Matching user, null on error
|
* @return array|null Matching user, null if not found
|
||||||
*/
|
*/
|
||||||
function User_by_api_key($api_key)
|
function User_by_api_key($api_key)
|
||||||
{
|
{
|
||||||
$user = DB::select('SELECT * FROM `User` WHERE `api_key`=? LIMIT 1', [$api_key]);
|
return DB::selectOne('SELECT * FROM `User` WHERE `api_key`=? LIMIT 1', [$api_key]);
|
||||||
|
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
engelsystem_error('Unable to find user by api key.');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($user)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $user[0];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -442,38 +400,18 @@ function User_by_api_key($api_key)
|
||||||
*/
|
*/
|
||||||
function User_by_email($email)
|
function User_by_email($email)
|
||||||
{
|
{
|
||||||
$user = DB::select('SELECT * FROM `User` WHERE `email`=? LIMIT 1', [$email]);
|
return DB::selectOne('SELECT * FROM `User` WHERE `email`=? LIMIT 1', [$email]);
|
||||||
|
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
engelsystem_error('Unable to load user.');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($user)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return array_shift($user);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns User by password token.
|
* Returns User by password token.
|
||||||
*
|
*
|
||||||
* @param string $token
|
* @param string $token
|
||||||
* @return array|null Matching user, null or false on error
|
* @return array|null Matching user, null when not found
|
||||||
*/
|
*/
|
||||||
function User_by_password_recovery_token($token)
|
function User_by_password_recovery_token($token)
|
||||||
{
|
{
|
||||||
$user = DB::select('SELECT * FROM `User` WHERE `password_recovery_token`=? LIMIT 1', [$token]);
|
return DB::selectOne('SELECT * FROM `User` WHERE `password_recovery_token`=? LIMIT 1', [$token]);
|
||||||
|
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
engelsystem_error('Unable to load user.');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($user)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return array_shift($user);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -481,7 +419,6 @@ function User_by_password_recovery_token($token)
|
||||||
*
|
*
|
||||||
* @param array $user
|
* @param array $user
|
||||||
* @param bool $log
|
* @param bool $log
|
||||||
* @return bool
|
|
||||||
*/
|
*/
|
||||||
function User_reset_api_key(&$user, $log = true)
|
function User_reset_api_key(&$user, $log = true)
|
||||||
{
|
{
|
||||||
|
@ -497,15 +434,10 @@ function User_reset_api_key(&$user, $log = true)
|
||||||
$user['UID']
|
$user['UID']
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($log) {
|
if ($log) {
|
||||||
engelsystem_log(sprintf('API key resetted (%s).', User_Nick_render($user)));
|
engelsystem_log(sprintf('API key resetted (%s).', User_Nick_render($user)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -528,9 +460,6 @@ function User_generate_password_recovery_token(&$user)
|
||||||
$user['UID'],
|
$user['UID'],
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
engelsystem_error('Unable to generate password recovery token.');
|
|
||||||
}
|
|
||||||
engelsystem_log('Password recovery for ' . User_Nick_render($user) . ' started.');
|
engelsystem_log('Password recovery for ' . User_Nick_render($user) . ' started.');
|
||||||
return $user['password_recovery_token'];
|
return $user['password_recovery_token'];
|
||||||
}
|
}
|
||||||
|
|
|
@ -232,19 +232,17 @@ function admin_active()
|
||||||
$shirt_statistics = [];
|
$shirt_statistics = [];
|
||||||
foreach (array_keys($tshirt_sizes) as $size) {
|
foreach (array_keys($tshirt_sizes) as $size) {
|
||||||
if (!empty($size)) {
|
if (!empty($size)) {
|
||||||
$sc = DB::select(
|
$sc = DB::selectOne(
|
||||||
'SELECT count(*) FROM `User` WHERE `Size`=? AND `Gekommen`=1',
|
'SELECT count(*) FROM `User` WHERE `Size`=? AND `Gekommen`=1',
|
||||||
[$size]
|
[$size]
|
||||||
);
|
);
|
||||||
$sc = array_shift($sc);
|
$sc = array_shift($sc);
|
||||||
$sc = array_shift($sc);
|
|
||||||
|
|
||||||
$gc = DB::select(
|
$gc = DB::selectOne(
|
||||||
'SELECT count(*) FROM `User` WHERE `Size`=? AND `Tshirt`=1',
|
'SELECT count(*) FROM `User` WHERE `Size`=? AND `Tshirt`=1',
|
||||||
[$size]
|
[$size]
|
||||||
);
|
);
|
||||||
$gc = array_shift($gc);
|
$gc = array_shift($gc);
|
||||||
$gc = array_shift($gc);
|
|
||||||
|
|
||||||
$shirt_statistics[] = [
|
$shirt_statistics[] = [
|
||||||
'size' => $size,
|
'size' => $size,
|
||||||
|
@ -254,8 +252,7 @@ function admin_active()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$uc = DB::select('SELECT count(*) FROM `User` WHERE `Tshirt`=1');
|
$uc = DB::selectOne('SELECT count(*) FROM `User` WHERE `Tshirt`=1');
|
||||||
$uc = array_shift($uc);
|
|
||||||
$uc = array_shift($uc);
|
$uc = array_shift($uc);
|
||||||
|
|
||||||
$shirt_statistics[] = [
|
$shirt_statistics[] = [
|
||||||
|
|
|
@ -112,23 +112,21 @@ function admin_groups()
|
||||||
return error('Incomplete call, missing Groups ID.', true);
|
return error('Incomplete call, missing Groups ID.', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
$group = DB::select('SELECT * FROM `Groups` WHERE `UID`=? LIMIT 1', [$group_id]);
|
$group = DB::selectOne('SELECT * FROM `Groups` WHERE `UID`=? LIMIT 1', [$group_id]);
|
||||||
$privileges = $request->postData('privileges');
|
$privileges = $request->postData('privileges');
|
||||||
if (!is_array($privileges)) {
|
if (!is_array($privileges)) {
|
||||||
$privileges = [];
|
$privileges = [];
|
||||||
}
|
}
|
||||||
if (!empty($group)) {
|
if (!empty($group)) {
|
||||||
$group = array_shift($group);
|
|
||||||
DB::delete('DELETE FROM `GroupPrivileges` WHERE `group_id`=?', [$group_id]);
|
DB::delete('DELETE FROM `GroupPrivileges` WHERE `group_id`=?', [$group_id]);
|
||||||
$privilege_names = [];
|
$privilege_names = [];
|
||||||
foreach ($privileges as $privilege) {
|
foreach ($privileges as $privilege) {
|
||||||
if (preg_match('/^\d{1,}$/', $privilege)) {
|
if (preg_match('/^\d{1,}$/', $privilege)) {
|
||||||
$group_privileges_source = DB::select(
|
$group_privileges_source = DB::selectOne(
|
||||||
'SELECT `name` FROM `Privileges` WHERE `id`=? LIMIT 1',
|
'SELECT `name` FROM `Privileges` WHERE `id`=? LIMIT 1',
|
||||||
[$privilege]
|
[$privilege]
|
||||||
);
|
);
|
||||||
if (!empty($group_privileges_source)) {
|
if (!empty($group_privileges_source)) {
|
||||||
$group_privileges_source = array_shift($group_privileges_source);
|
|
||||||
DB::insert(
|
DB::insert(
|
||||||
'INSERT INTO `GroupPrivileges` (`group_id`, `privilege_id`) VALUES (?, ?)',
|
'INSERT INTO `GroupPrivileges` (`group_id`, `privilege_id`) VALUES (?, ?)',
|
||||||
[$group_id, $privilege]
|
[$group_id, $privilege]
|
||||||
|
|
|
@ -45,9 +45,6 @@ function admin_import()
|
||||||
$add_minutes_end = 15;
|
$add_minutes_end = 15;
|
||||||
|
|
||||||
$shifttypes_source = ShiftTypes();
|
$shifttypes_source = ShiftTypes();
|
||||||
if ($shifttypes_source === false) {
|
|
||||||
engelsystem_error('Unable to load shifttypes.');
|
|
||||||
}
|
|
||||||
$shifttypes = [];
|
$shifttypes = [];
|
||||||
foreach ($shifttypes_source as $shifttype) {
|
foreach ($shifttypes_source as $shifttype) {
|
||||||
$shifttypes[$shifttype['id']] = $shifttype['name'];
|
$shifttypes[$shifttype['id']] = $shifttype['name'];
|
||||||
|
@ -251,9 +248,7 @@ function admin_import()
|
||||||
list($rooms_new, $rooms_deleted) = prepare_rooms($import_file);
|
list($rooms_new, $rooms_deleted) = prepare_rooms($import_file);
|
||||||
foreach ($rooms_new as $room) {
|
foreach ($rooms_new as $room) {
|
||||||
$result = Room_create($room, true, true);
|
$result = Room_create($room, true, true);
|
||||||
if ($result === false) {
|
|
||||||
engelsystem_error('Unable to create room.');
|
|
||||||
}
|
|
||||||
$rooms_import[trim($room)] = $result;
|
$rooms_import[trim($room)] = $result;
|
||||||
}
|
}
|
||||||
foreach ($rooms_deleted as $room) {
|
foreach ($rooms_deleted as $room) {
|
||||||
|
@ -267,24 +262,15 @@ function admin_import()
|
||||||
$add_minutes_end
|
$add_minutes_end
|
||||||
);
|
);
|
||||||
foreach ($events_new as $event) {
|
foreach ($events_new as $event) {
|
||||||
$result = Shift_create($event);
|
Shift_create($event);
|
||||||
if ($result === false) {
|
|
||||||
engelsystem_error('Unable to create shift.');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($events_updated as $event) {
|
foreach ($events_updated as $event) {
|
||||||
$result = Shift_update_by_psid($event);
|
Shift_update_by_psid($event);
|
||||||
if ($result === false) {
|
|
||||||
engelsystem_error('Unable to update shift.');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($events_deleted as $event) {
|
foreach ($events_deleted as $event) {
|
||||||
$result = Shift_delete_by_psid($event['PSID']);
|
Shift_delete_by_psid($event['PSID']);
|
||||||
if ($result === false) {
|
|
||||||
engelsystem_error('Unable to delete shift.');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
engelsystem_log('Frab import done');
|
engelsystem_log('Frab import done');
|
||||||
|
|
|
@ -21,14 +21,13 @@ function admin_news()
|
||||||
return error('Incomplete call, missing News ID.', true);
|
return error('Incomplete call, missing News ID.', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
$news = DB::select('SELECT * FROM `News` WHERE `ID`=? LIMIT 1', [$news_id]);
|
$news = DB::selectOne('SELECT * FROM `News` WHERE `ID`=? LIMIT 1', [$news_id]);
|
||||||
if (empty($news)) {
|
if (empty($news)) {
|
||||||
return error('No News found.', true);
|
return error('No News found.', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ($request->input('action')) {
|
switch ($request->input('action')) {
|
||||||
case 'edit':
|
case 'edit':
|
||||||
$news = array_shift($news);
|
|
||||||
$user_source = User($news['UID']);
|
$user_source = User($news['UID']);
|
||||||
|
|
||||||
$html .= form(
|
$html .= form(
|
||||||
|
@ -81,7 +80,6 @@ function admin_news()
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'delete':
|
case 'delete':
|
||||||
$news = array_shift($news);
|
|
||||||
DB::delete('DELETE FROM `News` WHERE `ID`=? LIMIT 1', [$news_id]);
|
DB::delete('DELETE FROM `News` WHERE `ID`=? LIMIT 1', [$news_id]);
|
||||||
engelsystem_log('News deleted: ' . $news['Betreff']);
|
engelsystem_log('News deleted: ' . $news['Betreff']);
|
||||||
success(_('News entry deleted.'));
|
success(_('News entry deleted.'));
|
||||||
|
|
|
@ -105,11 +105,11 @@ function admin_questions()
|
||||||
return error('Incomplete call, missing Question ID.', true);
|
return error('Incomplete call, missing Question ID.', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
$question = DB::select(
|
$question = DB::selectOne(
|
||||||
'SELECT * FROM `Questions` WHERE `QID`=? LIMIT 1',
|
'SELECT * FROM `Questions` WHERE `QID`=? LIMIT 1',
|
||||||
[$question_id]
|
[$question_id]
|
||||||
);
|
);
|
||||||
if (count($question) > 0 && $question[0]['AID'] == null) {
|
if (!empty($question) && $question['AID'] == null) {
|
||||||
$answer = trim(
|
$answer = trim(
|
||||||
preg_replace("/([^\p{L}\p{P}\p{Z}\p{N}\n]{1,})/ui",
|
preg_replace("/([^\p{L}\p{P}\p{Z}\p{N}\n]{1,})/ui",
|
||||||
'',
|
'',
|
||||||
|
@ -129,7 +129,7 @@ function admin_questions()
|
||||||
$question_id,
|
$question_id,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
engelsystem_log('Question ' . $question[0]['Question'] . ' answered: ' . $answer);
|
engelsystem_log('Question ' . $question['Question'] . ' answered: ' . $answer);
|
||||||
redirect(page_link_to('admin_questions'));
|
redirect(page_link_to('admin_questions'));
|
||||||
} else {
|
} else {
|
||||||
return error('Enter an answer!', true);
|
return error('Enter an answer!', true);
|
||||||
|
@ -145,13 +145,13 @@ function admin_questions()
|
||||||
return error('Incomplete call, missing Question ID.', true);
|
return error('Incomplete call, missing Question ID.', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
$question = DB::select(
|
$question = DB::selectOne(
|
||||||
'SELECT * FROM `Questions` WHERE `QID`=? LIMIT 1',
|
'SELECT * FROM `Questions` WHERE `QID`=? LIMIT 1',
|
||||||
[$question_id]
|
[$question_id]
|
||||||
);
|
);
|
||||||
if (count($question) > 0) {
|
if (!empty($question)) {
|
||||||
DB::delete('DELETE FROM `Questions` WHERE `QID`=? LIMIT 1', [$question_id]);
|
DB::delete('DELETE FROM `Questions` WHERE `QID`=? LIMIT 1', [$question_id]);
|
||||||
engelsystem_log('Question deleted: ' . $question[0]['Question']);
|
engelsystem_log('Question deleted: ' . $question['Question']);
|
||||||
redirect(page_link_to('admin_questions'));
|
redirect(page_link_to('admin_questions'));
|
||||||
} else {
|
} else {
|
||||||
return error('No question found.', true);
|
return error('No question found.', true);
|
||||||
|
|
|
@ -22,8 +22,8 @@ function admin_rooms()
|
||||||
foreach ($rooms_source as $room) {
|
foreach ($rooms_source as $room) {
|
||||||
$rooms[] = [
|
$rooms[] = [
|
||||||
'name' => Room_name_render($room),
|
'name' => Room_name_render($room),
|
||||||
'from_pentabarf' => $room['FromPentabarf'] == 'Y' ? '✓' : '',
|
'from_pentabarf' => glyph_bool($room['FromPentabarf'] == 'Y'),
|
||||||
'public' => $room['show'] == 'Y' ? '✓' : '',
|
'public' => glyph_bool($room['show'] == 'Y'),
|
||||||
'actions' => table_buttons([
|
'actions' => table_buttons([
|
||||||
button(page_link_to('admin_rooms', ['show' => 'edit', 'id' => $room['RID']]), _('edit'), 'btn-xs'),
|
button(page_link_to('admin_rooms', ['show' => 'edit', 'id' => $room['RID']]), _('edit'), 'btn-xs'),
|
||||||
button(page_link_to('admin_rooms', ['show' => 'delete', 'id' => $room['RID']]), _('delete'), 'btn-xs')
|
button(page_link_to('admin_rooms', ['show' => 'delete', 'id' => $room['RID']]), _('delete'), 'btn-xs')
|
||||||
|
@ -50,9 +50,6 @@ function admin_rooms()
|
||||||
|
|
||||||
if (test_request_int('id')) {
|
if (test_request_int('id')) {
|
||||||
$room = Room($request->input('id'), false);
|
$room = Room($request->input('id'), false);
|
||||||
if ($room === false) {
|
|
||||||
engelsystem_error('Unable to load room.');
|
|
||||||
}
|
|
||||||
if ($room == null) {
|
if ($room == null) {
|
||||||
redirect(page_link_to('admin_rooms'));
|
redirect(page_link_to('admin_rooms'));
|
||||||
}
|
}
|
||||||
|
@ -150,9 +147,7 @@ function admin_rooms()
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
$room_id = Room_create($name, $from_pentabarf, $public, $number);
|
$room_id = Room_create($name, $from_pentabarf, $public, $number);
|
||||||
if ($room_id === false) {
|
|
||||||
engelsystem_error('Unable to create room.');
|
|
||||||
}
|
|
||||||
engelsystem_log(
|
engelsystem_log(
|
||||||
'Room created: ' . $name
|
'Room created: ' . $name
|
||||||
. ', pentabarf import: '
|
. ', pentabarf import: '
|
||||||
|
@ -214,9 +209,7 @@ function admin_rooms()
|
||||||
]);
|
]);
|
||||||
} elseif ($request->input('show') == 'delete') {
|
} elseif ($request->input('show') == 'delete') {
|
||||||
if ($request->has('ack')) {
|
if ($request->has('ack')) {
|
||||||
if (!Room_delete($room_id)) {
|
Room_delete($room_id);
|
||||||
engelsystem_error('Unable to delete room.');
|
|
||||||
}
|
|
||||||
|
|
||||||
engelsystem_log('Room deleted: ' . $name);
|
engelsystem_log('Room deleted: ' . $name);
|
||||||
success(sprintf(_('Room %s deleted.'), $name));
|
success(sprintf(_('Room %s deleted.'), $name));
|
||||||
|
|
|
@ -44,9 +44,6 @@ function admin_shifts()
|
||||||
|
|
||||||
// Load shift types
|
// Load shift types
|
||||||
$shifttypes_source = ShiftTypes();
|
$shifttypes_source = ShiftTypes();
|
||||||
if ($shifttypes_source === false) {
|
|
||||||
engelsystem_error('Unable to load shift types.');
|
|
||||||
}
|
|
||||||
$shifttypes = [];
|
$shifttypes = [];
|
||||||
foreach ($shifttypes_source as $shifttype) {
|
foreach ($shifttypes_source as $shifttype) {
|
||||||
$shifttypes[$shifttype['id']] = $shifttype['name'];
|
$shifttypes[$shifttype['id']] = $shifttype['name'];
|
||||||
|
@ -317,9 +314,6 @@ function admin_shifts()
|
||||||
$shift['URL'] = null;
|
$shift['URL'] = null;
|
||||||
$shift['PSID'] = null;
|
$shift['PSID'] = null;
|
||||||
$shift_id = Shift_create($shift);
|
$shift_id = Shift_create($shift);
|
||||||
if ($shift_id === false) {
|
|
||||||
engelsystem_error('Unable to create shift.');
|
|
||||||
}
|
|
||||||
|
|
||||||
engelsystem_log(
|
engelsystem_log(
|
||||||
'Shift created: ' . $shifttypes[$shift['shifttype_id']]
|
'Shift created: ' . $shifttypes[$shift['shifttype_id']]
|
||||||
|
@ -329,7 +323,7 @@ function admin_shifts()
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach ($_SESSION['admin_shifts_types'] as $type_id => $count) {
|
foreach ($_SESSION['admin_shifts_types'] as $type_id => $count) {
|
||||||
$angel_type_source = DB::select('
|
$angel_type_source = DB::selectOne('
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM `AngelTypes`
|
FROM `AngelTypes`
|
||||||
WHERE `id` = ?
|
WHERE `id` = ?
|
||||||
|
@ -345,7 +339,7 @@ function admin_shifts()
|
||||||
$count
|
$count
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
$needed_angel_types_info[] = $angel_type_source[0]['name'] . ': ' . $count;
|
$needed_angel_types_info[] = $angel_type_source['name'] . ': ' . $count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,20 +119,20 @@ function admin_user()
|
||||||
|
|
||||||
$html .= '<hr />';
|
$html .= '<hr />';
|
||||||
|
|
||||||
$my_highest_group = DB::select(
|
$my_highest_group = DB::selectOne(
|
||||||
'SELECT group_id FROM `UserGroups` WHERE `uid`=? ORDER BY `group_id` LIMIT 1',
|
'SELECT group_id FROM `UserGroups` WHERE `uid`=? ORDER BY `group_id` LIMIT 1',
|
||||||
[$user['UID']]
|
[$user['UID']]
|
||||||
);
|
);
|
||||||
if (count($my_highest_group) > 0) {
|
if (!empty($my_highest_group)) {
|
||||||
$my_highest_group = $my_highest_group[0]['group_id'];
|
$my_highest_group = $my_highest_group['group_id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$his_highest_group = DB::select(
|
$his_highest_group = DB::selectOne(
|
||||||
'SELECT `group_id` FROM `UserGroups` WHERE `uid`=? ORDER BY `group_id` LIMIT 1',
|
'SELECT `group_id` FROM `UserGroups` WHERE `uid`=? ORDER BY `group_id` LIMIT 1',
|
||||||
[$user_id]
|
[$user_id]
|
||||||
);
|
);
|
||||||
if (count($his_highest_group) > 0) {
|
if (!empty($his_highest_group)) {
|
||||||
$his_highest_group = $his_highest_group[0]['group_id'];
|
$his_highest_group = $his_highest_group['group_id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($user_id != $user['UID'] && $my_highest_group <= $his_highest_group) {
|
if ($user_id != $user['UID'] && $my_highest_group <= $his_highest_group) {
|
||||||
|
@ -192,7 +192,7 @@ function admin_user()
|
||||||
count($my_highest_group) > 0
|
count($my_highest_group) > 0
|
||||||
&& (
|
&& (
|
||||||
count($his_highest_group) == 0
|
count($his_highest_group) == 0
|
||||||
|| ($my_highest_group[0]['group_id'] <= $his_highest_group[0]['group_id'])
|
|| ($my_highest_group['group_id'] <= $his_highest_group['group_id'])
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
$groups_source = DB::select('
|
$groups_source = DB::select('
|
||||||
|
@ -207,7 +207,7 @@ function admin_user()
|
||||||
',
|
',
|
||||||
[
|
[
|
||||||
$user_id,
|
$user_id,
|
||||||
$my_highest_group[0]['group_id'],
|
$my_highest_group['group_id'],
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
$groups = [];
|
$groups = [];
|
||||||
|
|
|
@ -399,9 +399,8 @@ function guest_login()
|
||||||
if ($request->has('submit')) {
|
if ($request->has('submit')) {
|
||||||
if ($request->has('nick') && strlen(User_validate_Nick($request->input('nick'))) > 0) {
|
if ($request->has('nick') && strlen(User_validate_Nick($request->input('nick'))) > 0) {
|
||||||
$nick = User_validate_Nick($request->input('nick'));
|
$nick = User_validate_Nick($request->input('nick'));
|
||||||
$login_user = DB::select('SELECT * FROM `User` WHERE `Nick`=?', [$nick]);
|
$login_user = DB::selectOne('SELECT * FROM `User` WHERE `Nick`=?', [$nick]);
|
||||||
if (count($login_user) > 0) {
|
if (!empty($login_user)) {
|
||||||
$login_user = $login_user[0];
|
|
||||||
if ($request->has('password')) {
|
if ($request->has('password')) {
|
||||||
if (!verify_password($request->postData('password'), $login_user['Passwort'], $login_user['UID'])) {
|
if (!verify_password($request->postData('password'), $login_user['Passwort'], $login_user['UID'])) {
|
||||||
$valid = false;
|
$valid = false;
|
||||||
|
|
|
@ -17,13 +17,12 @@ function guest_stats()
|
||||||
list($arrived_user_count) = DB::select('SELECT count(*) AS `user_count` FROM `User` WHERE `Gekommen`=1');
|
list($arrived_user_count) = DB::select('SELECT count(*) AS `user_count` FROM `User` WHERE `Gekommen`=1');
|
||||||
$stats['arrived_user_count'] = $arrived_user_count['user_count'];
|
$stats['arrived_user_count'] = $arrived_user_count['user_count'];
|
||||||
|
|
||||||
$done_shifts_seconds = DB::select('
|
$done_shifts_seconds = DB::selectOne('
|
||||||
SELECT SUM(`Shifts`.`end` - `Shifts`.`start`)
|
SELECT SUM(`Shifts`.`end` - `Shifts`.`start`)
|
||||||
FROM `ShiftEntry`
|
FROM `ShiftEntry`
|
||||||
JOIN `Shifts` USING (`SID`)
|
JOIN `Shifts` USING (`SID`)
|
||||||
WHERE `Shifts`.`end` < UNIX_TIMESTAMP()
|
WHERE `Shifts`.`end` < UNIX_TIMESTAMP()
|
||||||
');
|
');
|
||||||
$done_shifts_seconds = array_shift($done_shifts_seconds);
|
|
||||||
$done_shifts_seconds = (int)array_shift($done_shifts_seconds);
|
$done_shifts_seconds = (int)array_shift($done_shifts_seconds);
|
||||||
$stats['done_work_hours'] = round($done_shifts_seconds / (60 * 60), 0);
|
$stats['done_work_hours'] = round($done_shifts_seconds / (60 * 60), 0);
|
||||||
|
|
||||||
|
|
|
@ -130,11 +130,11 @@ function user_messages()
|
||||||
return error(_('Incomplete call, missing Message ID.'), true);
|
return error(_('Incomplete call, missing Message ID.'), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
$message = DB::select(
|
$message = DB::selectOne(
|
||||||
'SELECT `RUID` FROM `Messages` WHERE `id`=? LIMIT 1',
|
'SELECT `RUID` FROM `Messages` WHERE `id`=? LIMIT 1',
|
||||||
[$message_id]
|
[$message_id]
|
||||||
);
|
);
|
||||||
if (count($message) > 0 && $message[0]['RUID'] == $user['UID']) {
|
if (!empty($message) && $message['RUID'] == $user['UID']) {
|
||||||
DB::update(
|
DB::update(
|
||||||
'UPDATE `Messages` SET `isRead`=\'Y\' WHERE `id`=? LIMIT 1',
|
'UPDATE `Messages` SET `isRead`=\'Y\' WHERE `id`=? LIMIT 1',
|
||||||
[$message_id]
|
[$message_id]
|
||||||
|
@ -152,11 +152,11 @@ function user_messages()
|
||||||
return error(_('Incomplete call, missing Message ID.'), true);
|
return error(_('Incomplete call, missing Message ID.'), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
$message = DB::select(
|
$message = DB::selectOne(
|
||||||
'SELECT `SUID` FROM `Messages` WHERE `id`=? LIMIT 1',
|
'SELECT `SUID` FROM `Messages` WHERE `id`=? LIMIT 1',
|
||||||
[$message_id]
|
[$message_id]
|
||||||
);
|
);
|
||||||
if (count($message) > 0 && $message[0]['SUID'] == $user['UID']) {
|
if (!empty($message) && $message['SUID'] == $user['UID']) {
|
||||||
DB::delete('DELETE FROM `Messages` WHERE `id`=? LIMIT 1', [$message_id]);
|
DB::delete('DELETE FROM `Messages` WHERE `id`=? LIMIT 1', [$message_id]);
|
||||||
redirect(page_link_to('user_messages'));
|
redirect(page_link_to('user_messages'));
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -31,8 +31,7 @@ function user_myshifts()
|
||||||
$user_id = $user['UID'];
|
$user_id = $user['UID'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$shifts_user = DB::select('SELECT * FROM `User` WHERE `UID`=? LIMIT 1', [$user_id]);
|
$shifts_user = DB::selectOne('SELECT * FROM `User` WHERE `UID`=? LIMIT 1', [$user_id]);
|
||||||
$shifts_user = array_shift($shifts_user);
|
|
||||||
|
|
||||||
if ($request->has('reset')) {
|
if ($request->has('reset')) {
|
||||||
if ($request->input('reset') == 'ack') {
|
if ($request->input('reset') == 'ack') {
|
||||||
|
@ -49,7 +48,7 @@ function user_myshifts()
|
||||||
]);
|
]);
|
||||||
} elseif ($request->has('edit') && preg_match('/^\d*$/', $request->input('edit'))) {
|
} elseif ($request->has('edit') && preg_match('/^\d*$/', $request->input('edit'))) {
|
||||||
$user_id = $request->input('edit');
|
$user_id = $request->input('edit');
|
||||||
$shift = DB::select('
|
$shift = DB::selectOne('
|
||||||
SELECT
|
SELECT
|
||||||
`ShiftEntry`.`freeloaded`,
|
`ShiftEntry`.`freeloaded`,
|
||||||
`ShiftEntry`.`freeload_comment`,
|
`ShiftEntry`.`freeload_comment`,
|
||||||
|
@ -74,7 +73,6 @@ function user_myshifts()
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
if (count($shift) > 0) {
|
if (count($shift) > 0) {
|
||||||
$shift = array_shift($shift);
|
|
||||||
$freeloaded = $shift['freeloaded'];
|
$freeloaded = $shift['freeloaded'];
|
||||||
$freeload_comment = $shift['freeload_comment'];
|
$freeload_comment = $shift['freeload_comment'];
|
||||||
|
|
||||||
|
@ -93,15 +91,12 @@ function user_myshifts()
|
||||||
$user_source = User($shift['UID']);
|
$user_source = User($shift['UID']);
|
||||||
|
|
||||||
if ($valid) {
|
if ($valid) {
|
||||||
$result = ShiftEntry_update([
|
ShiftEntry_update([
|
||||||
'id' => $user_id,
|
'id' => $user_id,
|
||||||
'Comment' => $comment,
|
'Comment' => $comment,
|
||||||
'freeloaded' => $freeloaded,
|
'freeloaded' => $freeloaded,
|
||||||
'freeload_comment' => $freeload_comment
|
'freeload_comment' => $freeload_comment
|
||||||
]);
|
]);
|
||||||
if ($result === false) {
|
|
||||||
engelsystem_error('Unable to update shift entry.');
|
|
||||||
}
|
|
||||||
|
|
||||||
engelsystem_log(
|
engelsystem_log(
|
||||||
'Updated ' . User_Nick_render($user_source) . '\'s shift ' . $shift['name']
|
'Updated ' . User_Nick_render($user_source) . '\'s shift ' . $shift['name']
|
||||||
|
@ -131,7 +126,7 @@ function user_myshifts()
|
||||||
}
|
}
|
||||||
} elseif ($request->has('cancel') && preg_match('/^\d*$/', $request->input('cancel'))) {
|
} elseif ($request->has('cancel') && preg_match('/^\d*$/', $request->input('cancel'))) {
|
||||||
$user_id = $request->input('cancel');
|
$user_id = $request->input('cancel');
|
||||||
$shift = DB::select('
|
$shift = DB::selectOne('
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM `Shifts`
|
FROM `Shifts`
|
||||||
INNER JOIN `ShiftEntry` USING (`SID`)
|
INNER JOIN `ShiftEntry` USING (`SID`)
|
||||||
|
@ -143,15 +138,12 @@ function user_myshifts()
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
if (count($shift) > 0) {
|
if (count($shift) > 0) {
|
||||||
$shift = array_shift($shift);
|
|
||||||
if (
|
if (
|
||||||
($shift['start'] > time() + config('last_unsubscribe') * 3600)
|
($shift['start'] > time() + config('last_unsubscribe') * 3600)
|
||||||
|| in_array('user_shifts_admin', $privileges)
|
|| in_array('user_shifts_admin', $privileges)
|
||||||
) {
|
) {
|
||||||
$result = ShiftEntry_delete($user_id);
|
ShiftEntry_delete($user_id);
|
||||||
if ($result === false) {
|
|
||||||
engelsystem_error('Unable to delete shift entry.');
|
|
||||||
}
|
|
||||||
$room = Room($shift['RID']);
|
$room = Room($shift['RID']);
|
||||||
$angeltype = AngelType($shift['TID']);
|
$angeltype = AngelType($shift['TID']);
|
||||||
$shifttype = ShiftType($shift['shifttype_id']);
|
$shifttype = ShiftType($shift['shifttype_id']);
|
||||||
|
|
|
@ -126,8 +126,7 @@ function user_news_comments()
|
||||||
&& count(DB::select('SELECT `ID` FROM `News` WHERE `ID`=? LIMIT 1', [$request->input('nid')])) > 0
|
&& count(DB::select('SELECT `ID` FROM `News` WHERE `ID`=? LIMIT 1', [$request->input('nid')])) > 0
|
||||||
) {
|
) {
|
||||||
$nid = $request->input('nid');
|
$nid = $request->input('nid');
|
||||||
$news = DB::select('SELECT * FROM `News` WHERE `ID`=? LIMIT 1', [$nid]);
|
$news = DB::selectOne('SELECT * FROM `News` WHERE `ID`=? LIMIT 1', [$nid]);
|
||||||
$news = array_shift($news);
|
|
||||||
if ($request->has('text')) {
|
if ($request->has('text')) {
|
||||||
$text = preg_replace("/([^\p{L}\p{P}\p{Z}\p{N}\n]{1,})/ui", '', strip_tags($request->input('text')));
|
$text = preg_replace("/([^\p{L}\p{P}\p{Z}\p{N}\n]{1,})/ui", '', strip_tags($request->input('text')));
|
||||||
DB::insert('
|
DB::insert('
|
||||||
|
|
|
@ -43,15 +43,13 @@ function user_questions()
|
||||||
case 'ask':
|
case 'ask':
|
||||||
$question = strip_request_item_nl('question');
|
$question = strip_request_item_nl('question');
|
||||||
if ($question != '') {
|
if ($question != '') {
|
||||||
$result = DB::insert('
|
DB::insert('
|
||||||
INSERT INTO `Questions` (`UID`, `Question`)
|
INSERT INTO `Questions` (`UID`, `Question`)
|
||||||
VALUES (?, ?)
|
VALUES (?, ?)
|
||||||
',
|
',
|
||||||
[$user['UID'], $question]
|
[$user['UID'], $question]
|
||||||
);
|
);
|
||||||
if (!$result) {
|
|
||||||
engelsystem_error(_('Unable to save question.'));
|
|
||||||
}
|
|
||||||
success(_('You question was saved.'));
|
success(_('You question was saved.'));
|
||||||
redirect(page_link_to('user_questions'));
|
redirect(page_link_to('user_questions'));
|
||||||
} else {
|
} else {
|
||||||
|
@ -67,11 +65,11 @@ function user_questions()
|
||||||
return error(_('Incomplete call, missing Question ID.'), true);
|
return error(_('Incomplete call, missing Question ID.'), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
$question = DB::select(
|
$question = DB::selectOne(
|
||||||
'SELECT `UID` FROM `Questions` WHERE `QID`=? LIMIT 1',
|
'SELECT `UID` FROM `Questions` WHERE `QID`=? LIMIT 1',
|
||||||
[$question_id]
|
[$question_id]
|
||||||
);
|
);
|
||||||
if (count($question) > 0 && $question[0]['UID'] == $user['UID']) {
|
if (!empty($question) && $question['UID'] == $user['UID']) {
|
||||||
DB::delete(
|
DB::delete(
|
||||||
'DELETE FROM `Questions` WHERE `QID`=? LIMIT 1',
|
'DELETE FROM `Questions` WHERE `QID`=? LIMIT 1',
|
||||||
[$question_id]
|
[$question_id]
|
||||||
|
|
|
@ -84,6 +84,7 @@ function user_settings_main($user_source, $enable_tshirt_size, $tshirt_sizes)
|
||||||
|
|
||||||
if ($valid) {
|
if ($valid) {
|
||||||
User_update($user_source);
|
User_update($user_source);
|
||||||
|
|
||||||
success(_('Settings saved.'));
|
success(_('Settings saved.'));
|
||||||
redirect(page_link_to('user_settings'));
|
redirect(page_link_to('user_settings'));
|
||||||
}
|
}
|
||||||
|
@ -108,10 +109,9 @@ function user_settings_password($user_source)
|
||||||
error(_('Your password is to short (please use at least 6 characters).'));
|
error(_('Your password is to short (please use at least 6 characters).'));
|
||||||
} elseif ($request->postData('new_password') != $request->postData('new_password2')) {
|
} elseif ($request->postData('new_password') != $request->postData('new_password2')) {
|
||||||
error(_('Your passwords don\'t match.'));
|
error(_('Your passwords don\'t match.'));
|
||||||
} elseif (set_password($user_source['UID'], $request->postData('new_password'))) {
|
|
||||||
success(_('Password saved.'));
|
|
||||||
} else {
|
} else {
|
||||||
error(_('Failed setting password.'));
|
set_password($user_source['UID'], $request->postData('new_password'));
|
||||||
|
success(_('Password saved.'));
|
||||||
}
|
}
|
||||||
redirect(page_link_to('user_settings'));
|
redirect(page_link_to('user_settings'));
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,10 +11,9 @@ function load_auth()
|
||||||
|
|
||||||
$user = null;
|
$user = null;
|
||||||
if (isset($_SESSION['uid'])) {
|
if (isset($_SESSION['uid'])) {
|
||||||
$user = DB::select('SELECT * FROM `User` WHERE `UID`=? LIMIT 1', [$_SESSION['uid']]);
|
$user = DB::selectOne('SELECT * FROM `User` WHERE `UID`=? LIMIT 1', [$_SESSION['uid']]);
|
||||||
if (count($user) > 0) {
|
if (!empty($user)) {
|
||||||
// User ist eingeloggt, Datensatz zur Verfügung stellen und Timestamp updaten
|
// User ist eingeloggt, Datensatz zur Verfügung stellen und Timestamp updaten
|
||||||
$user = array_shift($user);
|
|
||||||
DB::update('
|
DB::update('
|
||||||
UPDATE `User`
|
UPDATE `User`
|
||||||
SET `lastLogIn` = ?
|
SET `lastLogIn` = ?
|
||||||
|
@ -55,11 +54,10 @@ function generate_salt($length = 16)
|
||||||
*
|
*
|
||||||
* @param int $uid
|
* @param int $uid
|
||||||
* @param string $password
|
* @param string $password
|
||||||
* @return bool
|
|
||||||
*/
|
*/
|
||||||
function set_password($uid, $password)
|
function set_password($uid, $password)
|
||||||
{
|
{
|
||||||
$result = DB::update('
|
DB::update('
|
||||||
UPDATE `User`
|
UPDATE `User`
|
||||||
SET `Passwort` = ?,
|
SET `Passwort` = ?,
|
||||||
`password_recovery_token`=NULL
|
`password_recovery_token`=NULL
|
||||||
|
@ -71,10 +69,6 @@ function set_password($uid, $password)
|
||||||
$uid
|
$uid
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
engelsystem_error('Unable to update password.');
|
|
||||||
}
|
|
||||||
return $result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -411,7 +411,7 @@ 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)) {
|
||||||
$html .= '<option value="' . $key . '" selected="selected">' . $row . '</option>';
|
$html .= '<option value="' . $key . '" selected="selected">' . $row . '</option>';
|
||||||
} else {
|
} else {
|
||||||
$html .= '<option value="' . $key . '">' . $row . '</option>';
|
$html .= '<option value="' . $key . '">' . $row . '</option>';
|
||||||
|
|
|
@ -184,7 +184,6 @@ function AngelType_view_members($angeltype, $members, $admin_user_angeltypes, $a
|
||||||
$members_unconfirmed = [];
|
$members_unconfirmed = [];
|
||||||
foreach ($members as $member) {
|
foreach ($members as $member) {
|
||||||
$member['Nick'] = User_Nick_render($member);
|
$member['Nick'] = User_Nick_render($member);
|
||||||
|
|
||||||
if ($angeltype['requires_driver_license']) {
|
if ($angeltype['requires_driver_license']) {
|
||||||
$member['wants_to_drive'] = glyph_bool($member['wants_to_drive']);
|
$member['wants_to_drive'] = glyph_bool($member['wants_to_drive']);
|
||||||
$member['has_car'] = glyph_bool($member['has_car']);
|
$member['has_car'] = glyph_bool($member['has_car']);
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
namespace Engelsystem;
|
namespace Engelsystem;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a single lane in a shifts calendar.
|
* Represents a single lane in a shifts calendar.
|
||||||
*/
|
*/
|
||||||
|
@ -38,15 +40,15 @@ class ShiftCalendarLane
|
||||||
* Returns true on success.
|
* Returns true on success.
|
||||||
*
|
*
|
||||||
* @param array $shift The shift to add
|
* @param array $shift The shift to add
|
||||||
* @return boolean true on success
|
* @throws Exception if the shift doesn't fit into the lane.
|
||||||
*/
|
*/
|
||||||
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;
|
||||||
}
|
}
|
||||||
return false;
|
throw new Exception('Unable to add shift to shift calendar lane.');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Engelsystem;
|
namespace Engelsystem;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
|
||||||
class ShiftCalendarRenderer
|
class ShiftCalendarRenderer
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 15m * 60s/m = 900s
|
* 15m * 60s/m = 900s
|
||||||
*/
|
*/
|
||||||
|
@ -67,7 +69,8 @@ class ShiftCalendarRenderer
|
||||||
/**
|
/**
|
||||||
* Assigns the shifts to different lanes per room if they collide
|
* Assigns the shifts to different lanes per room if they collide
|
||||||
*
|
*
|
||||||
* @param array[] $shifts The shifts to assign
|
* @param array[] $shifts
|
||||||
|
* The shifts to assign
|
||||||
*
|
*
|
||||||
* @return array Returns an array that assigns a room_id to an array of ShiftCalendarLane containing the shifts
|
* @return array Returns an array that assigns a room_id to an array of ShiftCalendarLane containing the shifts
|
||||||
*/
|
*/
|
||||||
|
@ -82,7 +85,7 @@ class ShiftCalendarRenderer
|
||||||
'RID' => $room_id,
|
'RID' => $room_id,
|
||||||
'Name' => $shift['room_name']
|
'Name' => $shift['room_name']
|
||||||
]);
|
]);
|
||||||
if (!isset($lanes[$room_id])) {
|
if (! isset($lanes[$room_id])) {
|
||||||
// initialize room with one lane
|
// initialize room with one lane
|
||||||
$lanes[$room_id] = [
|
$lanes[$room_id] = [
|
||||||
new ShiftCalendarLane($header, $this->getFirstBlockStartTime(), $this->getBlocksPerSlot())
|
new ShiftCalendarLane($header, $this->getFirstBlockStartTime(), $this->getBlocksPerSlot())
|
||||||
|
@ -92,17 +95,16 @@ class ShiftCalendarRenderer
|
||||||
$shift_added = false;
|
$shift_added = false;
|
||||||
foreach ($lanes[$room_id] as $lane) {
|
foreach ($lanes[$room_id] as $lane) {
|
||||||
/** @var ShiftCalendarLane $lane */
|
/** @var ShiftCalendarLane $lane */
|
||||||
$shift_added = $lane->addShift($shift);
|
if($lane->shiftFits($shift)) {
|
||||||
if ($shift_added == true) {
|
$lane->addShift($shift);
|
||||||
|
$shift_added = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// If all lanes for this room are busy, create a new lane and add shift to it
|
// If all lanes for this room are busy, create a new lane and add shift to it
|
||||||
if ($shift_added == false) {
|
if ($shift_added == false) {
|
||||||
$newLane = new ShiftCalendarLane($header, $this->getFirstBlockStartTime(), $this->getBlocksPerSlot());
|
$newLane = new ShiftCalendarLane($header, $this->getFirstBlockStartTime(), $this->getBlocksPerSlot());
|
||||||
if (!$newLane->addShift($shift)) {
|
$newLane->addShift($shift);
|
||||||
engelsystem_error('Unable to add shift to new lane.');
|
|
||||||
}
|
|
||||||
$lanes[$room_id][] = $newLane;
|
$lanes[$room_id][] = $newLane;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -111,6 +113,7 @@ class ShiftCalendarRenderer
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function getFirstBlockStartTime()
|
public function getFirstBlockStartTime()
|
||||||
|
@ -119,6 +122,7 @@ class ShiftCalendarRenderer
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function getLastBlockEndTime()
|
public function getLastBlockEndTime()
|
||||||
|
@ -127,6 +131,7 @@ class ShiftCalendarRenderer
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
public function getBlocksPerSlot()
|
public function getBlocksPerSlot()
|
||||||
|
@ -173,7 +178,8 @@ class ShiftCalendarRenderer
|
||||||
/**
|
/**
|
||||||
* Renders a single lane
|
* Renders a single lane
|
||||||
*
|
*
|
||||||
* @param ShiftCalendarLane $lane The lane to render
|
* @param ShiftCalendarLane $lane
|
||||||
|
* The lane to render
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
private function renderLane(ShiftCalendarLane $lane)
|
private function renderLane(ShiftCalendarLane $lane)
|
||||||
|
@ -190,12 +196,7 @@ class ShiftCalendarRenderer
|
||||||
$rendered_until += ShiftCalendarRenderer::SECONDS_PER_ROW;
|
$rendered_until += ShiftCalendarRenderer::SECONDS_PER_ROW;
|
||||||
}
|
}
|
||||||
|
|
||||||
list($shift_height, $shift_html) = $shift_renderer->render(
|
list ($shift_height, $shift_html) = $shift_renderer->render($shift, $this->needed_angeltypes[$shift['SID']], $this->shift_entries[$shift['SID']], $user);
|
||||||
$shift,
|
|
||||||
$this->needed_angeltypes[$shift['SID']],
|
|
||||||
$this->shift_entries[$shift['SID']],
|
|
||||||
$user
|
|
||||||
);
|
|
||||||
$html .= $shift_html;
|
$html .= $shift_html;
|
||||||
$rendered_until += $shift_height * ShiftCalendarRenderer::SECONDS_PER_ROW;
|
$rendered_until += $shift_height * ShiftCalendarRenderer::SECONDS_PER_ROW;
|
||||||
}
|
}
|
||||||
|
@ -214,21 +215,23 @@ class ShiftCalendarRenderer
|
||||||
/**
|
/**
|
||||||
* Renders a tick/block for given time
|
* Renders a tick/block for given time
|
||||||
*
|
*
|
||||||
* @param int $time unix timestamp
|
* @param int $time
|
||||||
* @param boolean $label Should time labels be generated?
|
* unix timestamp
|
||||||
|
* @param boolean $label
|
||||||
|
* Should time labels be generated?
|
||||||
* @return string rendered tick html
|
* @return string 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');
|
||||||
}
|
}
|
||||||
return div('tick day', [
|
return div('tick day', [
|
||||||
date('m-d<b\r />H:i', $time)
|
date('m-d<b\r />H:i', $time)
|
||||||
]);
|
]);
|
||||||
} elseif ($time % (60 * 60) == 0) {
|
} elseif ($time % (60 * 60) == 0) {
|
||||||
if (!$label) {
|
if (! $label) {
|
||||||
return div('tick hour');
|
return div('tick hour');
|
||||||
}
|
}
|
||||||
return div('tick hour', [
|
return div('tick hour', [
|
||||||
|
@ -250,7 +253,7 @@ class ShiftCalendarRenderer
|
||||||
_('Time')
|
_('Time')
|
||||||
])
|
])
|
||||||
];
|
];
|
||||||
for ($block = 0; $block < $this->getBlocksPerSlot(); $block++) {
|
for ($block = 0; $block < $this->getBlocksPerSlot(); $block ++) {
|
||||||
$thistime = $this->getFirstBlockStartTime() + ($block * ShiftCalendarRenderer::SECONDS_PER_ROW);
|
$thistime = $this->getFirstBlockStartTime() + ($block * ShiftCalendarRenderer::SECONDS_PER_ROW);
|
||||||
$time_slot[] = $this->renderTick($thistime, true);
|
$time_slot[] = $this->renderTick($thistime, true);
|
||||||
}
|
}
|
||||||
|
@ -258,6 +261,7 @@ class ShiftCalendarRenderer
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* @param array[] $shifts
|
* @param array[] $shifts
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
|
@ -273,6 +277,7 @@ class ShiftCalendarRenderer
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* @param array[] $shifts
|
* @param array[] $shifts
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
|
@ -288,6 +293,7 @@ class ShiftCalendarRenderer
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
private function calcBlocksPerSlot()
|
private function calcBlocksPerSlot()
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*!
|
/*!
|
||||||
* Bootstrap v3.3.6 (http://getbootstrap.com)
|
* Bootstrap v3.3.7 (http://getbootstrap.com)
|
||||||
* Copyright 2011-2015 Twitter, Inc.
|
* Copyright 2011-2016 Twitter, Inc.
|
||||||
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
||||||
*/
|
*/
|
||||||
/*! normalize.css v3.0.3 | MIT License | github.com/necolas/normalize.css */
|
/*! normalize.css v3.0.3 | MIT License | github.com/necolas/normalize.css */
|
||||||
|
@ -1095,7 +1095,6 @@ a:focus {
|
||||||
text-decoration: underline;
|
text-decoration: underline;
|
||||||
}
|
}
|
||||||
a:focus {
|
a:focus {
|
||||||
outline: thin dotted;
|
|
||||||
outline: 5px auto -webkit-focus-ring-color;
|
outline: 5px auto -webkit-focus-ring-color;
|
||||||
outline-offset: -2px;
|
outline-offset: -2px;
|
||||||
}
|
}
|
||||||
|
@ -2524,7 +2523,6 @@ select[size] {
|
||||||
input[type="file"]:focus,
|
input[type="file"]:focus,
|
||||||
input[type="radio"]:focus,
|
input[type="radio"]:focus,
|
||||||
input[type="checkbox"]:focus {
|
input[type="checkbox"]:focus {
|
||||||
outline: thin dotted;
|
|
||||||
outline: 5px auto -webkit-focus-ring-color;
|
outline: 5px auto -webkit-focus-ring-color;
|
||||||
outline-offset: -2px;
|
outline-offset: -2px;
|
||||||
}
|
}
|
||||||
|
@ -3015,7 +3013,6 @@ select[multiple].input-lg {
|
||||||
.btn.focus,
|
.btn.focus,
|
||||||
.btn:active.focus,
|
.btn:active.focus,
|
||||||
.btn.active.focus {
|
.btn.active.focus {
|
||||||
outline: thin dotted;
|
|
||||||
outline: 5px auto -webkit-focus-ring-color;
|
outline: 5px auto -webkit-focus-ring-color;
|
||||||
outline-offset: -2px;
|
outline-offset: -2px;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
THE SOFTWARE.
|
THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
/*!
|
/*!
|
||||||
* Bootstrap v3.3.6 (http://getbootstrap.com)
|
* Bootstrap v3.3.7 (http://getbootstrap.com)
|
||||||
* Copyright 2011-2015 Twitter, Inc.
|
* Copyright 2011-2016 Twitter, Inc.
|
||||||
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
||||||
*/
|
*/
|
||||||
/*! normalize.css v3.0.3 | MIT License | github.com/necolas/normalize.css */
|
/*! normalize.css v3.0.3 | MIT License | github.com/necolas/normalize.css */
|
||||||
|
@ -1118,7 +1118,6 @@ a:focus {
|
||||||
text-decoration: underline;
|
text-decoration: underline;
|
||||||
}
|
}
|
||||||
a:focus {
|
a:focus {
|
||||||
outline: thin dotted;
|
|
||||||
outline: 5px auto -webkit-focus-ring-color;
|
outline: 5px auto -webkit-focus-ring-color;
|
||||||
outline-offset: -2px;
|
outline-offset: -2px;
|
||||||
}
|
}
|
||||||
|
@ -2547,7 +2546,6 @@ select[size] {
|
||||||
input[type="file"]:focus,
|
input[type="file"]:focus,
|
||||||
input[type="radio"]:focus,
|
input[type="radio"]:focus,
|
||||||
input[type="checkbox"]:focus {
|
input[type="checkbox"]:focus {
|
||||||
outline: thin dotted;
|
|
||||||
outline: 5px auto -webkit-focus-ring-color;
|
outline: 5px auto -webkit-focus-ring-color;
|
||||||
outline-offset: -2px;
|
outline-offset: -2px;
|
||||||
}
|
}
|
||||||
|
@ -3038,7 +3036,6 @@ select[multiple].input-lg {
|
||||||
.btn.focus,
|
.btn.focus,
|
||||||
.btn:active.focus,
|
.btn:active.focus,
|
||||||
.btn.active.focus {
|
.btn.active.focus {
|
||||||
outline: thin dotted;
|
|
||||||
outline: 5px auto -webkit-focus-ring-color;
|
outline: 5px auto -webkit-focus-ring-color;
|
||||||
outline-offset: -2px;
|
outline-offset: -2px;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*!
|
/*!
|
||||||
* Bootstrap v3.3.6 (http://getbootstrap.com)
|
* Bootstrap v3.3.7 (http://getbootstrap.com)
|
||||||
* Copyright 2011-2015 Twitter, Inc.
|
* Copyright 2011-2016 Twitter, Inc.
|
||||||
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
||||||
*/
|
*/
|
||||||
/*! normalize.css v3.0.3 | MIT License | github.com/necolas/normalize.css */
|
/*! normalize.css v3.0.3 | MIT License | github.com/necolas/normalize.css */
|
||||||
|
@ -1095,7 +1095,6 @@ a:focus {
|
||||||
text-decoration: underline;
|
text-decoration: underline;
|
||||||
}
|
}
|
||||||
a:focus {
|
a:focus {
|
||||||
outline: thin dotted;
|
|
||||||
outline: 5px auto -webkit-focus-ring-color;
|
outline: 5px auto -webkit-focus-ring-color;
|
||||||
outline-offset: -2px;
|
outline-offset: -2px;
|
||||||
}
|
}
|
||||||
|
@ -2524,7 +2523,6 @@ select[size] {
|
||||||
input[type="file"]:focus,
|
input[type="file"]:focus,
|
||||||
input[type="radio"]:focus,
|
input[type="radio"]:focus,
|
||||||
input[type="checkbox"]:focus {
|
input[type="checkbox"]:focus {
|
||||||
outline: thin dotted;
|
|
||||||
outline: 5px auto -webkit-focus-ring-color;
|
outline: 5px auto -webkit-focus-ring-color;
|
||||||
outline-offset: -2px;
|
outline-offset: -2px;
|
||||||
}
|
}
|
||||||
|
@ -3015,7 +3013,6 @@ select[multiple].input-lg {
|
||||||
.btn.focus,
|
.btn.focus,
|
||||||
.btn:active.focus,
|
.btn:active.focus,
|
||||||
.btn.active.focus {
|
.btn.active.focus {
|
||||||
outline: thin dotted;
|
|
||||||
outline: 5px auto -webkit-focus-ring-color;
|
outline: 5px auto -webkit-focus-ring-color;
|
||||||
outline-offset: -2px;
|
outline-offset: -2px;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,8 +8,8 @@
|
||||||
color: #000;
|
color: #000;
|
||||||
}
|
}
|
||||||
/*!
|
/*!
|
||||||
* Bootstrap v3.3.6 (http://getbootstrap.com)
|
* Bootstrap v3.3.7 (http://getbootstrap.com)
|
||||||
* Copyright 2011-2015 Twitter, Inc.
|
* Copyright 2011-2016 Twitter, Inc.
|
||||||
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
||||||
*/
|
*/
|
||||||
/*! normalize.css v3.0.3 | MIT License | github.com/necolas/normalize.css */
|
/*! normalize.css v3.0.3 | MIT License | github.com/necolas/normalize.css */
|
||||||
|
@ -1104,7 +1104,6 @@ a:focus {
|
||||||
text-decoration: underline;
|
text-decoration: underline;
|
||||||
}
|
}
|
||||||
a:focus {
|
a:focus {
|
||||||
outline: thin dotted;
|
|
||||||
outline: 5px auto -webkit-focus-ring-color;
|
outline: 5px auto -webkit-focus-ring-color;
|
||||||
outline-offset: -2px;
|
outline-offset: -2px;
|
||||||
}
|
}
|
||||||
|
@ -2533,7 +2532,6 @@ select[size] {
|
||||||
input[type="file"]:focus,
|
input[type="file"]:focus,
|
||||||
input[type="radio"]:focus,
|
input[type="radio"]:focus,
|
||||||
input[type="checkbox"]:focus {
|
input[type="checkbox"]:focus {
|
||||||
outline: thin dotted;
|
|
||||||
outline: 5px auto -webkit-focus-ring-color;
|
outline: 5px auto -webkit-focus-ring-color;
|
||||||
outline-offset: -2px;
|
outline-offset: -2px;
|
||||||
}
|
}
|
||||||
|
@ -3024,7 +3022,6 @@ select[multiple].input-lg {
|
||||||
.btn.focus,
|
.btn.focus,
|
||||||
.btn:active.focus,
|
.btn:active.focus,
|
||||||
.btn.active.focus {
|
.btn.active.focus {
|
||||||
outline: thin dotted;
|
|
||||||
outline: 5px auto -webkit-focus-ring-color;
|
outline: 5px auto -webkit-focus-ring-color;
|
||||||
outline-offset: -2px;
|
outline-offset: -2px;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
THE SOFTWARE.
|
THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
/*!
|
/*!
|
||||||
* Bootstrap v3.3.6 (http://getbootstrap.com)
|
* Bootstrap v3.3.7 (http://getbootstrap.com)
|
||||||
* Copyright 2011-2015 Twitter, Inc.
|
* Copyright 2011-2016 Twitter, Inc.
|
||||||
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
||||||
*/
|
*/
|
||||||
/*! normalize.css v3.0.3 | MIT License | github.com/necolas/normalize.css */
|
/*! normalize.css v3.0.3 | MIT License | github.com/necolas/normalize.css */
|
||||||
|
@ -1118,7 +1118,6 @@ a:focus {
|
||||||
text-decoration: underline;
|
text-decoration: underline;
|
||||||
}
|
}
|
||||||
a:focus {
|
a:focus {
|
||||||
outline: thin dotted;
|
|
||||||
outline: 5px auto -webkit-focus-ring-color;
|
outline: 5px auto -webkit-focus-ring-color;
|
||||||
outline-offset: -2px;
|
outline-offset: -2px;
|
||||||
}
|
}
|
||||||
|
@ -2547,7 +2546,6 @@ select[size] {
|
||||||
input[type="file"]:focus,
|
input[type="file"]:focus,
|
||||||
input[type="radio"]:focus,
|
input[type="radio"]:focus,
|
||||||
input[type="checkbox"]:focus {
|
input[type="checkbox"]:focus {
|
||||||
outline: thin dotted;
|
|
||||||
outline: 5px auto -webkit-focus-ring-color;
|
outline: 5px auto -webkit-focus-ring-color;
|
||||||
outline-offset: -2px;
|
outline-offset: -2px;
|
||||||
}
|
}
|
||||||
|
@ -3038,7 +3036,6 @@ select[multiple].input-lg {
|
||||||
.btn.focus,
|
.btn.focus,
|
||||||
.btn:active.focus,
|
.btn:active.focus,
|
||||||
.btn.active.focus {
|
.btn.active.focus {
|
||||||
outline: thin dotted;
|
|
||||||
outline: 5px auto -webkit-focus-ring-color;
|
outline: 5px auto -webkit-focus-ring-color;
|
||||||
outline-offset: -2px;
|
outline-offset: -2px;
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,18 +80,35 @@ class Db
|
||||||
return self::$stm->fetchAll(PDO::FETCH_ASSOC);
|
return self::$stm->fetchAll(PDO::FETCH_ASSOC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run a select query and return only the first result or null if no result is found.
|
||||||
|
* @param string $query
|
||||||
|
* @param array $bindings
|
||||||
|
* @return array|null
|
||||||
|
*/
|
||||||
|
public static function selectOne($query, array $bindings = [])
|
||||||
|
{
|
||||||
|
$result = self::select($query, $bindings);
|
||||||
|
|
||||||
|
if(empty($result)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return array_shift($result);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run an insert query
|
* Run an insert query
|
||||||
*
|
*
|
||||||
* @param string $query
|
* @param string $query
|
||||||
* @param array $bindings
|
* @param array $bindings
|
||||||
* @return int|bool
|
* @return int Row count
|
||||||
*/
|
*/
|
||||||
public static function insert($query, array $bindings = [])
|
public static function insert($query, array $bindings = [])
|
||||||
{
|
{
|
||||||
self::query($query, $bindings);
|
self::query($query, $bindings);
|
||||||
|
|
||||||
return (self::$lastStatus ? self::$stm->rowCount() : false);
|
return self::$stm->rowCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -99,13 +116,13 @@ class Db
|
||||||
*
|
*
|
||||||
* @param string $query
|
* @param string $query
|
||||||
* @param array $bindings
|
* @param array $bindings
|
||||||
* @return int|bool
|
* @return int
|
||||||
*/
|
*/
|
||||||
public static function update($query, array $bindings = [])
|
public static function update($query, array $bindings = [])
|
||||||
{
|
{
|
||||||
self::query($query, $bindings);
|
self::query($query, $bindings);
|
||||||
|
|
||||||
return (self::$lastStatus ? self::$stm->rowCount() : false);
|
return self::$stm->rowCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -113,13 +130,13 @@ class Db
|
||||||
*
|
*
|
||||||
* @param string $query
|
* @param string $query
|
||||||
* @param array $bindings
|
* @param array $bindings
|
||||||
* @return int|bool
|
* @return int
|
||||||
*/
|
*/
|
||||||
public static function delete($query, array $bindings = [])
|
public static function delete($query, array $bindings = [])
|
||||||
{
|
{
|
||||||
self::query($query, $bindings);
|
self::query($query, $bindings);
|
||||||
|
|
||||||
return (self::$lastStatus ? self::$stm->rowCount() : false);
|
return self::$stm->rowCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace Engelsystem\Exceptions;
|
namespace Engelsystem\Exceptions;
|
||||||
|
|
||||||
use Exception;
|
use Throwable;
|
||||||
|
|
||||||
class Handler
|
class Handler
|
||||||
{
|
{
|
||||||
|
@ -40,9 +40,9 @@ class Handler
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Exception $e
|
* @param Throwable $e
|
||||||
*/
|
*/
|
||||||
public function exceptionHandler(Exception $e)
|
public function exceptionHandler(Throwable $e)
|
||||||
{
|
{
|
||||||
$this->handle(
|
$this->handle(
|
||||||
'exception',
|
'exception',
|
||||||
|
|
Loading…
Reference in New Issue