Replaced DB with Db
This commit is contained in:
parent
05e94bbfee
commit
3ebea2ae15
|
@ -206,7 +206,7 @@ function user_controller()
|
||||||
$shifts = Shifts_by_user($user_source->id, auth()->can('user_shifts_admin'));
|
$shifts = Shifts_by_user($user_source->id, auth()->can('user_shifts_admin'));
|
||||||
foreach ($shifts as &$shift) {
|
foreach ($shifts as &$shift) {
|
||||||
// TODO: Move queries to model
|
// TODO: Move queries to model
|
||||||
$shift['needed_angeltypes'] = DB::select('
|
$shift['needed_angeltypes'] = Db::select('
|
||||||
SELECT DISTINCT `AngelTypes`.*
|
SELECT DISTINCT `AngelTypes`.*
|
||||||
FROM `ShiftEntry`
|
FROM `ShiftEntry`
|
||||||
JOIN `AngelTypes` ON `ShiftEntry`.`TID`=`AngelTypes`.`id`
|
JOIN `AngelTypes` ON `ShiftEntry`.`TID`=`AngelTypes`.`id`
|
||||||
|
@ -216,7 +216,7 @@ function user_controller()
|
||||||
[$shift['SID']]
|
[$shift['SID']]
|
||||||
);
|
);
|
||||||
foreach ($shift['needed_angeltypes'] as &$needed_angeltype) {
|
foreach ($shift['needed_angeltypes'] as &$needed_angeltype) {
|
||||||
$needed_angeltype['users'] = DB::select('
|
$needed_angeltype['users'] = Db::select('
|
||||||
SELECT `ShiftEntry`.`freeloaded`, `users`.*
|
SELECT `ShiftEntry`.`freeloaded`, `users`.*
|
||||||
FROM `ShiftEntry`
|
FROM `ShiftEntry`
|
||||||
JOIN `users` ON `ShiftEntry`.`UID`=`users`.`id`
|
JOIN `users` ON `ShiftEntry`.`UID`=`users`.`id`
|
||||||
|
|
|
@ -43,7 +43,7 @@ function AngelType_has_contact_info($angeltype)
|
||||||
*/
|
*/
|
||||||
function AngelType_delete($angeltype)
|
function AngelType_delete($angeltype)
|
||||||
{
|
{
|
||||||
DB::delete('
|
Db::delete('
|
||||||
DELETE FROM `AngelTypes`
|
DELETE FROM `AngelTypes`
|
||||||
WHERE `id`=?
|
WHERE `id`=?
|
||||||
LIMIT 1
|
LIMIT 1
|
||||||
|
@ -58,7 +58,7 @@ function AngelType_delete($angeltype)
|
||||||
*/
|
*/
|
||||||
function AngelType_update($angeltype)
|
function AngelType_update($angeltype)
|
||||||
{
|
{
|
||||||
DB::update('
|
Db::update('
|
||||||
UPDATE `AngelTypes` SET
|
UPDATE `AngelTypes` SET
|
||||||
`name` = ?,
|
`name` = ?,
|
||||||
`restricted` = ?,
|
`restricted` = ?,
|
||||||
|
@ -104,7 +104,7 @@ function AngelType_update($angeltype)
|
||||||
*/
|
*/
|
||||||
function AngelType_create($angeltype)
|
function AngelType_create($angeltype)
|
||||||
{
|
{
|
||||||
DB::insert('
|
Db::insert('
|
||||||
INSERT INTO `AngelTypes` (
|
INSERT INTO `AngelTypes` (
|
||||||
`name`,
|
`name`,
|
||||||
`restricted`,
|
`restricted`,
|
||||||
|
@ -131,7 +131,7 @@ function AngelType_create($angeltype)
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
$angeltype['id'] = DB::getPdo()->lastInsertId();
|
$angeltype['id'] = Db::getPdo()->lastInsertId();
|
||||||
engelsystem_log(
|
engelsystem_log(
|
||||||
'Created angeltype: ' . $angeltype['name']
|
'Created angeltype: ' . $angeltype['name']
|
||||||
. ($angeltype['restricted'] ? ', restricted' : '')
|
. ($angeltype['restricted'] ? ', restricted' : '')
|
||||||
|
@ -161,7 +161,7 @@ function AngelType_validate_name($name, $angeltype)
|
||||||
return new ValidationResult(false, '');
|
return new ValidationResult(false, '');
|
||||||
}
|
}
|
||||||
if (!empty($angeltype) && isset($angeltype['id'])) {
|
if (!empty($angeltype) && isset($angeltype['id'])) {
|
||||||
$valid = (count(DB::select('
|
$valid = (count(Db::select('
|
||||||
SELECT `id`
|
SELECT `id`
|
||||||
FROM `AngelTypes`
|
FROM `AngelTypes`
|
||||||
WHERE `name`=?
|
WHERE `name`=?
|
||||||
|
@ -170,7 +170,7 @@ function AngelType_validate_name($name, $angeltype)
|
||||||
', [$name, $angeltype['id']])) == 0);
|
', [$name, $angeltype['id']])) == 0);
|
||||||
return new ValidationResult($valid, $name);
|
return new ValidationResult($valid, $name);
|
||||||
}
|
}
|
||||||
$valid = (count(DB::select('
|
$valid = (count(Db::select('
|
||||||
SELECT `id`
|
SELECT `id`
|
||||||
FROM `AngelTypes`
|
FROM `AngelTypes`
|
||||||
WHERE `name`=?
|
WHERE `name`=?
|
||||||
|
@ -187,7 +187,7 @@ function AngelType_validate_name($name, $angeltype)
|
||||||
*/
|
*/
|
||||||
function AngelTypes_with_user($userId)
|
function AngelTypes_with_user($userId)
|
||||||
{
|
{
|
||||||
return 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`,
|
||||||
|
@ -205,7 +205,7 @@ function AngelTypes_with_user($userId)
|
||||||
*/
|
*/
|
||||||
function AngelTypes()
|
function AngelTypes()
|
||||||
{
|
{
|
||||||
return DB::select('
|
return Db::select('
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM `AngelTypes`
|
FROM `AngelTypes`
|
||||||
ORDER BY `name`
|
ORDER BY `name`
|
||||||
|
@ -219,7 +219,7 @@ function AngelTypes()
|
||||||
*/
|
*/
|
||||||
function AngelType_ids()
|
function AngelType_ids()
|
||||||
{
|
{
|
||||||
$result = DB::select('SELECT `id` FROM `AngelTypes`');
|
$result = Db::select('SELECT `id` FROM `AngelTypes`');
|
||||||
return select_array($result, 'id', 'id');
|
return select_array($result, 'id', 'id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,7 +231,7 @@ function AngelType_ids()
|
||||||
*/
|
*/
|
||||||
function AngelType($angeltype_id)
|
function AngelType($angeltype_id)
|
||||||
{
|
{
|
||||||
$angelType = DB::selectOne(
|
$angelType = Db::selectOne(
|
||||||
'SELECT * FROM `AngelTypes` WHERE `id`=?',
|
'SELECT * FROM `AngelTypes` WHERE `id`=?',
|
||||||
[$angeltype_id]
|
[$angeltype_id]
|
||||||
);
|
);
|
||||||
|
|
|
@ -18,7 +18,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)
|
||||||
{
|
{
|
||||||
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 (?, ?, ?, ?)
|
||||||
',
|
',
|
||||||
|
@ -29,7 +29,7 @@ function NeededAngelType_add($shift_id, $angeltype_id, $room_id, $count)
|
||||||
$count,
|
$count,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return DB::getPdo()->lastInsertId();
|
return Db::getPdo()->lastInsertId();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -39,7 +39,7 @@ function NeededAngelType_add($shift_id, $angeltype_id, $room_id, $count)
|
||||||
*/
|
*/
|
||||||
function NeededAngelTypes_delete_by_shift($shift_id)
|
function NeededAngelTypes_delete_by_shift($shift_id)
|
||||||
{
|
{
|
||||||
DB::delete('DELETE FROM `NeededAngelTypes` WHERE `shift_id` = ?', [$shift_id]);
|
Db::delete('DELETE FROM `NeededAngelTypes` WHERE `shift_id` = ?', [$shift_id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -49,7 +49,7 @@ function NeededAngelTypes_delete_by_shift($shift_id)
|
||||||
*/
|
*/
|
||||||
function NeededAngelTypes_delete_by_room($room_id)
|
function NeededAngelTypes_delete_by_room($room_id)
|
||||||
{
|
{
|
||||||
DB::delete(
|
Db::delete(
|
||||||
'DELETE FROM `NeededAngelTypes` WHERE `room_id` = ?',
|
'DELETE FROM `NeededAngelTypes` WHERE `room_id` = ?',
|
||||||
[$room_id]
|
[$room_id]
|
||||||
);
|
);
|
||||||
|
@ -63,7 +63,7 @@ function NeededAngelTypes_delete_by_room($room_id)
|
||||||
*/
|
*/
|
||||||
function NeededAngelTypes_by_room($room_id)
|
function NeededAngelTypes_by_room($room_id)
|
||||||
{
|
{
|
||||||
return DB::select(
|
return Db::select(
|
||||||
'SELECT `angel_type_id`, `count` FROM `NeededAngelTypes` WHERE `room_id`=?',
|
'SELECT `angel_type_id`, `count` FROM `NeededAngelTypes` WHERE `room_id`=?',
|
||||||
[$room_id]
|
[$room_id]
|
||||||
);
|
);
|
||||||
|
@ -77,7 +77,7 @@ function NeededAngelTypes_by_room($room_id)
|
||||||
*/
|
*/
|
||||||
function NeededAngelTypes_by_shift($shiftId)
|
function NeededAngelTypes_by_shift($shiftId)
|
||||||
{
|
{
|
||||||
$needed_angeltypes_source = DB::select('
|
$needed_angeltypes_source = Db::select('
|
||||||
SELECT
|
SELECT
|
||||||
`NeededAngelTypes`.*,
|
`NeededAngelTypes`.*,
|
||||||
`AngelTypes`.`id`,
|
`AngelTypes`.`id`,
|
||||||
|
@ -94,7 +94,7 @@ function NeededAngelTypes_by_shift($shiftId)
|
||||||
|
|
||||||
// Use settings from room
|
// Use settings from room
|
||||||
if (count($needed_angeltypes_source) == 0) {
|
if (count($needed_angeltypes_source) == 0) {
|
||||||
$needed_angeltypes_source = DB::select('
|
$needed_angeltypes_source = Db::select('
|
||||||
SELECT `NeededAngelTypes`.*, `AngelTypes`.`name`, `AngelTypes`.`restricted`
|
SELECT `NeededAngelTypes`.*, `AngelTypes`.`name`, `AngelTypes`.`restricted`
|
||||||
FROM `NeededAngelTypes`
|
FROM `NeededAngelTypes`
|
||||||
JOIN `AngelTypes` ON `AngelTypes`.`id` = `NeededAngelTypes`.`angel_type_id`
|
JOIN `AngelTypes` ON `AngelTypes`.`id` = `NeededAngelTypes`.`angel_type_id`
|
||||||
|
|
|
@ -12,7 +12,7 @@ use Engelsystem\Models\User\User;
|
||||||
*/
|
*/
|
||||||
function ShiftEntries_freeloaded_count()
|
function ShiftEntries_freeloaded_count()
|
||||||
{
|
{
|
||||||
$result = DB::selectOne('SELECT COUNT(*) FROM `ShiftEntry` WHERE `freeloaded` = 1');
|
$result = Db::selectOne('SELECT COUNT(*) FROM `ShiftEntry` WHERE `freeloaded` = 1');
|
||||||
|
|
||||||
if (empty($result)) {
|
if (empty($result)) {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -29,7 +29,7 @@ function ShiftEntries_freeloaded_count()
|
||||||
*/
|
*/
|
||||||
function ShiftEntries_by_shift($shift_id)
|
function ShiftEntries_by_shift($shift_id)
|
||||||
{
|
{
|
||||||
return DB::select('
|
return Db::select('
|
||||||
SELECT
|
SELECT
|
||||||
`users`.*,
|
`users`.*,
|
||||||
`ShiftEntry`.`UID`,
|
`ShiftEntry`.`UID`,
|
||||||
|
@ -60,7 +60,7 @@ function ShiftEntry_create($shift_entry)
|
||||||
$shifttype = ShiftType($shift['shifttype_id']);
|
$shifttype = ShiftType($shift['shifttype_id']);
|
||||||
$room = Room::find($shift['RID']);
|
$room = Room::find($shift['RID']);
|
||||||
$angeltype = AngelType($shift_entry['TID']);
|
$angeltype = AngelType($shift_entry['TID']);
|
||||||
$result = DB::insert('
|
$result = Db::insert('
|
||||||
INSERT INTO `ShiftEntry` (
|
INSERT INTO `ShiftEntry` (
|
||||||
`SID`,
|
`SID`,
|
||||||
`TID`,
|
`TID`,
|
||||||
|
@ -101,7 +101,7 @@ function ShiftEntry_create($shift_entry)
|
||||||
*/
|
*/
|
||||||
function ShiftEntry_update($shift_entry)
|
function ShiftEntry_update($shift_entry)
|
||||||
{
|
{
|
||||||
DB::update('
|
Db::update('
|
||||||
UPDATE `ShiftEntry`
|
UPDATE `ShiftEntry`
|
||||||
SET
|
SET
|
||||||
`Comment` = ?,
|
`Comment` = ?,
|
||||||
|
@ -126,7 +126,7 @@ function ShiftEntry_update($shift_entry)
|
||||||
*/
|
*/
|
||||||
function ShiftEntry($shift_entry_id)
|
function ShiftEntry($shift_entry_id)
|
||||||
{
|
{
|
||||||
$shiftEntry = DB::selectOne('SELECT * FROM `ShiftEntry` WHERE `id` = ?', [$shift_entry_id]);
|
$shiftEntry = Db::selectOne('SELECT * FROM `ShiftEntry` WHERE `id` = ?', [$shift_entry_id]);
|
||||||
|
|
||||||
return empty($shiftEntry) ? null : $shiftEntry;
|
return empty($shiftEntry) ? null : $shiftEntry;
|
||||||
}
|
}
|
||||||
|
@ -138,7 +138,7 @@ function ShiftEntry($shift_entry_id)
|
||||||
*/
|
*/
|
||||||
function ShiftEntry_delete($shiftEntry)
|
function ShiftEntry_delete($shiftEntry)
|
||||||
{
|
{
|
||||||
DB::delete('DELETE FROM `ShiftEntry` WHERE `id` = ?', [$shiftEntry['id']]);
|
Db::delete('DELETE FROM `ShiftEntry` WHERE `id` = ?', [$shiftEntry['id']]);
|
||||||
|
|
||||||
$signout_user = User::find($shiftEntry['UID']);
|
$signout_user = User::find($shiftEntry['UID']);
|
||||||
$shift = Shift($shiftEntry['SID']);
|
$shift = Shift($shiftEntry['SID']);
|
||||||
|
@ -167,7 +167,7 @@ function ShiftEntry_delete($shiftEntry)
|
||||||
*/
|
*/
|
||||||
function ShiftEntries_upcoming_for_user($userId)
|
function ShiftEntries_upcoming_for_user($userId)
|
||||||
{
|
{
|
||||||
return DB::select('
|
return Db::select('
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM `ShiftEntry`
|
FROM `ShiftEntry`
|
||||||
JOIN `Shifts` ON (`Shifts`.`SID` = `ShiftEntry`.`SID`)
|
JOIN `Shifts` ON (`Shifts`.`SID` = `ShiftEntry`.`SID`)
|
||||||
|
@ -192,7 +192,7 @@ function ShiftEntries_upcoming_for_user($userId)
|
||||||
*/
|
*/
|
||||||
function ShiftEntries_finished_by_user($userId, Carbon $sinceTime = null)
|
function ShiftEntries_finished_by_user($userId, Carbon $sinceTime = null)
|
||||||
{
|
{
|
||||||
return DB::select('
|
return Db::select('
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM `ShiftEntry`
|
FROM `ShiftEntry`
|
||||||
JOIN `Shifts` ON (`Shifts`.`SID` = `ShiftEntry`.`SID`)
|
JOIN `Shifts` ON (`Shifts`.`SID` = `ShiftEntry`.`SID`)
|
||||||
|
@ -219,7 +219,7 @@ function ShiftEntries_finished_by_user($userId, Carbon $sinceTime = null)
|
||||||
*/
|
*/
|
||||||
function ShiftEntries_by_shift_and_angeltype($shift_id, $angeltype_id)
|
function ShiftEntries_by_shift_and_angeltype($shift_id, $angeltype_id)
|
||||||
{
|
{
|
||||||
return DB::select('
|
return Db::select('
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM `ShiftEntry`
|
FROM `ShiftEntry`
|
||||||
WHERE `SID` = ?
|
WHERE `SID` = ?
|
||||||
|
@ -240,7 +240,7 @@ function ShiftEntries_by_shift_and_angeltype($shift_id, $angeltype_id)
|
||||||
*/
|
*/
|
||||||
function ShiftEntries_freeloaded_by_user($userId)
|
function ShiftEntries_freeloaded_by_user($userId)
|
||||||
{
|
{
|
||||||
return DB::select('
|
return Db::select('
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM `ShiftEntry`
|
FROM `ShiftEntry`
|
||||||
WHERE `freeloaded` = 1
|
WHERE `freeloaded` = 1
|
||||||
|
|
|
@ -9,7 +9,7 @@ use Engelsystem\Database\Db;
|
||||||
*/
|
*/
|
||||||
function ShiftType_delete($shifttype_id)
|
function ShiftType_delete($shifttype_id)
|
||||||
{
|
{
|
||||||
DB::delete('DELETE FROM `ShiftTypes` WHERE `id`=?', [$shifttype_id]);
|
Db::delete('DELETE FROM `ShiftTypes` WHERE `id`=?', [$shifttype_id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -22,7 +22,7 @@ function ShiftType_delete($shifttype_id)
|
||||||
*/
|
*/
|
||||||
function ShiftType_update($shifttype_id, $name, $angeltype_id, $description)
|
function ShiftType_update($shifttype_id, $name, $angeltype_id, $description)
|
||||||
{
|
{
|
||||||
DB::update('
|
Db::update('
|
||||||
UPDATE `ShiftTypes` SET
|
UPDATE `ShiftTypes` SET
|
||||||
`name`=?,
|
`name`=?,
|
||||||
`angeltype_id`=?,
|
`angeltype_id`=?,
|
||||||
|
@ -48,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)
|
||||||
{
|
{
|
||||||
DB::insert('
|
Db::insert('
|
||||||
INSERT INTO `ShiftTypes` (`name`, `angeltype_id`, `description`)
|
INSERT INTO `ShiftTypes` (`name`, `angeltype_id`, `description`)
|
||||||
VALUES(?, ?, ?)
|
VALUES(?, ?, ?)
|
||||||
',
|
',
|
||||||
|
@ -59,7 +59,7 @@ function ShiftType_create($name, $angeltype_id, $description)
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
return DB::getPdo()->lastInsertId();
|
return Db::getPdo()->lastInsertId();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -70,7 +70,7 @@ function ShiftType_create($name, $angeltype_id, $description)
|
||||||
*/
|
*/
|
||||||
function ShiftType($shifttype_id)
|
function ShiftType($shifttype_id)
|
||||||
{
|
{
|
||||||
$shiftType = DB::selectOne('SELECT * FROM `ShiftTypes` WHERE `id`=?', [$shifttype_id]);
|
$shiftType = Db::selectOne('SELECT * FROM `ShiftTypes` WHERE `id`=?', [$shifttype_id]);
|
||||||
|
|
||||||
return empty($shiftType) ? null : $shiftType;
|
return empty($shiftType) ? null : $shiftType;
|
||||||
}
|
}
|
||||||
|
@ -82,5 +82,5 @@ function ShiftType($shifttype_id)
|
||||||
*/
|
*/
|
||||||
function ShiftTypes()
|
function ShiftTypes()
|
||||||
{
|
{
|
||||||
return DB::select('SELECT * FROM `ShiftTypes` ORDER BY `name`');
|
return Db::select('SELECT * FROM `ShiftTypes` ORDER BY `name`');
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ use Engelsystem\ShiftSignupState;
|
||||||
*/
|
*/
|
||||||
function Shifts_by_angeltype($angeltype)
|
function Shifts_by_angeltype($angeltype)
|
||||||
{
|
{
|
||||||
return DB::select('
|
return Db::select('
|
||||||
SELECT DISTINCT `Shifts`.* FROM `Shifts`
|
SELECT DISTINCT `Shifts`.* FROM `Shifts`
|
||||||
JOIN `NeededAngelTypes` ON `NeededAngelTypes`.`shift_id` = `Shifts`.`SID`
|
JOIN `NeededAngelTypes` ON `NeededAngelTypes`.`shift_id` = `Shifts`.`SID`
|
||||||
LEFT JOIN schedule_shift AS s on Shifts.SID = s.shift_id
|
LEFT JOIN schedule_shift AS s on Shifts.SID = s.shift_id
|
||||||
|
@ -84,7 +84,7 @@ function Shifts_free($start, $end, ShiftsFilter $filter = null)
|
||||||
*/
|
*/
|
||||||
function Shifts_by_room(Room $room)
|
function Shifts_by_room(Room $room)
|
||||||
{
|
{
|
||||||
return DB::select(
|
return Db::select(
|
||||||
'SELECT * FROM `Shifts` WHERE `RID`=? ORDER BY `start`',
|
'SELECT * FROM `Shifts` WHERE `RID`=? ORDER BY `start`',
|
||||||
[$room->id]
|
[$room->id]
|
||||||
);
|
);
|
||||||
|
@ -128,7 +128,7 @@ function Shifts_by_ShiftsFilter(ShiftsFilter $shiftsFilter)
|
||||||
ORDER BY `room_name`, `start`
|
ORDER BY `room_name`, `start`
|
||||||
';
|
';
|
||||||
|
|
||||||
return DB::select(
|
return Db::select(
|
||||||
$sql,
|
$sql,
|
||||||
[
|
[
|
||||||
$shiftsFilter->getStartTime(),
|
$shiftsFilter->getStartTime(),
|
||||||
|
@ -179,7 +179,7 @@ function NeededAngeltypes_by_ShiftsFilter(ShiftsFilter $shiftsFilter)
|
||||||
AND NOT s.shift_id IS NULL
|
AND NOT s.shift_id IS NULL
|
||||||
';
|
';
|
||||||
|
|
||||||
return DB::select(
|
return Db::select(
|
||||||
$sql,
|
$sql,
|
||||||
[
|
[
|
||||||
$shiftsFilter->getStartTime(),
|
$shiftsFilter->getStartTime(),
|
||||||
|
@ -197,7 +197,7 @@ function NeededAngeltypes_by_ShiftsFilter(ShiftsFilter $shiftsFilter)
|
||||||
*/
|
*/
|
||||||
function NeededAngeltype_by_Shift_and_Angeltype($shift, $angeltype)
|
function NeededAngeltype_by_Shift_and_Angeltype($shift, $angeltype)
|
||||||
{
|
{
|
||||||
return DB::selectOne('
|
return Db::selectOne('
|
||||||
SELECT
|
SELECT
|
||||||
`NeededAngelTypes`.*,
|
`NeededAngelTypes`.*,
|
||||||
`Shifts`.`SID`,
|
`Shifts`.`SID`,
|
||||||
|
@ -262,7 +262,7 @@ function ShiftEntries_by_ShiftsFilter(ShiftsFilter $shiftsFilter)
|
||||||
',
|
',
|
||||||
implode(',', $shiftsFilter->getRooms())
|
implode(',', $shiftsFilter->getRooms())
|
||||||
);
|
);
|
||||||
return DB::select(
|
return Db::select(
|
||||||
$sql,
|
$sql,
|
||||||
[
|
[
|
||||||
$shiftsFilter->getStartTime(),
|
$shiftsFilter->getStartTime(),
|
||||||
|
@ -513,7 +513,7 @@ function Shift_signup_allowed(
|
||||||
function Shift_delete($shift_id)
|
function Shift_delete($shift_id)
|
||||||
{
|
{
|
||||||
mail_shift_delete(Shift($shift_id));
|
mail_shift_delete(Shift($shift_id));
|
||||||
DB::delete('DELETE FROM `Shifts` WHERE `SID`=?', [$shift_id]);
|
Db::delete('DELETE FROM `Shifts` WHERE `SID`=?', [$shift_id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -528,7 +528,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 DB::update('
|
return Db::update('
|
||||||
UPDATE `Shifts` SET
|
UPDATE `Shifts` SET
|
||||||
`shifttype_id` = ?,
|
`shifttype_id` = ?,
|
||||||
`start` = ?,
|
`start` = ?,
|
||||||
|
@ -561,11 +561,11 @@ function Shift_update($shift)
|
||||||
*
|
*
|
||||||
* @param array $shift
|
* @param array $shift
|
||||||
* @param int $transactionId
|
* @param int $transactionId
|
||||||
* @return int ID of the new created shift
|
* @return int|false ID of the new created shift
|
||||||
*/
|
*/
|
||||||
function Shift_create($shift, $transactionId = null)
|
function Shift_create($shift, $transactionId = null)
|
||||||
{
|
{
|
||||||
DB::insert('
|
Db::insert('
|
||||||
INSERT INTO `Shifts` (
|
INSERT INTO `Shifts` (
|
||||||
`shifttype_id`,
|
`shifttype_id`,
|
||||||
`start`,
|
`start`,
|
||||||
|
@ -596,7 +596,7 @@ function Shift_create($shift, $transactionId = null)
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
return DB::getPdo()->lastInsertId();
|
return Db::getPdo()->lastInsertId();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -608,7 +608,7 @@ function Shift_create($shift, $transactionId = null)
|
||||||
*/
|
*/
|
||||||
function Shifts_by_user($userId, $include_freeload_comments = false)
|
function Shifts_by_user($userId, $include_freeload_comments = false)
|
||||||
{
|
{
|
||||||
return DB::select('
|
return Db::select('
|
||||||
SELECT
|
SELECT
|
||||||
`rooms`.*,
|
`rooms`.*,
|
||||||
`rooms`.name AS Name,
|
`rooms`.name AS Name,
|
||||||
|
@ -646,7 +646,7 @@ function Shifts_by_user($userId, $include_freeload_comments = false)
|
||||||
*/
|
*/
|
||||||
function Shift($shift_id)
|
function Shift($shift_id)
|
||||||
{
|
{
|
||||||
$result = DB::selectOne('
|
$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`)
|
||||||
|
@ -656,7 +656,7 @@ function Shift($shift_id)
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$shiftsEntry_source = DB::select('
|
$shiftsEntry_source = Db::select('
|
||||||
SELECT `ShiftEntry`.`id`, `ShiftEntry`.`TID` , `ShiftEntry`.`UID` , `ShiftEntry`.`freeloaded`, `users`.`name` AS `username`
|
SELECT `ShiftEntry`.`id`, `ShiftEntry`.`TID` , `ShiftEntry`.`UID` , `ShiftEntry`.`freeloaded`, `users`.`name` AS `username`
|
||||||
FROM `ShiftEntry`
|
FROM `ShiftEntry`
|
||||||
LEFT JOIN `users` ON (`users`.`id` = `ShiftEntry`.`UID`)
|
LEFT JOIN `users` ON (`users`.`id` = `ShiftEntry`.`UID`)
|
||||||
|
|
|
@ -16,7 +16,7 @@ use Engelsystem\Models\User\User;
|
||||||
*/
|
*/
|
||||||
function UserAngelType_exists($userId, $angeltype)
|
function UserAngelType_exists($userId, $angeltype)
|
||||||
{
|
{
|
||||||
return count(DB::select('
|
return count(Db::select('
|
||||||
SELECT `id`
|
SELECT `id`
|
||||||
FROM `UserAngelTypes`
|
FROM `UserAngelTypes`
|
||||||
WHERE `UserAngelTypes`.`user_id`=?
|
WHERE `UserAngelTypes`.`user_id`=?
|
||||||
|
@ -32,7 +32,7 @@ function UserAngelType_exists($userId, $angeltype)
|
||||||
*/
|
*/
|
||||||
function User_angeltypes($userId)
|
function User_angeltypes($userId)
|
||||||
{
|
{
|
||||||
return 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`
|
||||||
|
@ -48,7 +48,7 @@ function User_angeltypes($userId)
|
||||||
*/
|
*/
|
||||||
function User_unconfirmed_AngelTypes($userId)
|
function User_unconfirmed_AngelTypes($userId)
|
||||||
{
|
{
|
||||||
return DB::select('
|
return Db::select('
|
||||||
SELECT
|
SELECT
|
||||||
`UserAngelTypes`.*,
|
`UserAngelTypes`.*,
|
||||||
`AngelTypes`.`name`,
|
`AngelTypes`.`name`,
|
||||||
|
@ -80,7 +80,7 @@ function User_is_AngelType_supporter($user, $angeltype)
|
||||||
|
|
||||||
$privileges = privileges_for_user($user->id);
|
$privileges = privileges_for_user($user->id);
|
||||||
|
|
||||||
return (count(DB::select('
|
return (count(Db::select('
|
||||||
SELECT `id`
|
SELECT `id`
|
||||||
FROM `UserAngelTypes`
|
FROM `UserAngelTypes`
|
||||||
WHERE `user_id`=?
|
WHERE `user_id`=?
|
||||||
|
@ -104,7 +104,7 @@ function User_is_AngelType_supporter($user, $angeltype)
|
||||||
*/
|
*/
|
||||||
function UserAngelType_update($user_angeltype_id, $supporter)
|
function UserAngelType_update($user_angeltype_id, $supporter)
|
||||||
{
|
{
|
||||||
DB::update('
|
Db::update('
|
||||||
UPDATE `UserAngelTypes`
|
UPDATE `UserAngelTypes`
|
||||||
SET `supporter`=?
|
SET `supporter`=?
|
||||||
WHERE `id`=?
|
WHERE `id`=?
|
||||||
|
@ -119,7 +119,7 @@ function UserAngelType_update($user_angeltype_id, $supporter)
|
||||||
*/
|
*/
|
||||||
function UserAngelTypes_delete_all($angeltype_id)
|
function UserAngelTypes_delete_all($angeltype_id)
|
||||||
{
|
{
|
||||||
DB::delete('
|
Db::delete('
|
||||||
DELETE FROM `UserAngelTypes`
|
DELETE FROM `UserAngelTypes`
|
||||||
WHERE `angeltype_id`=?
|
WHERE `angeltype_id`=?
|
||||||
AND `confirm_user_id` IS NULL
|
AND `confirm_user_id` IS NULL
|
||||||
|
@ -134,7 +134,7 @@ function UserAngelTypes_delete_all($angeltype_id)
|
||||||
*/
|
*/
|
||||||
function UserAngelTypes_confirm_all($angeltype_id, $confirm_user_id)
|
function UserAngelTypes_confirm_all($angeltype_id, $confirm_user_id)
|
||||||
{
|
{
|
||||||
DB::update('
|
Db::update('
|
||||||
UPDATE `UserAngelTypes`
|
UPDATE `UserAngelTypes`
|
||||||
SET `confirm_user_id`=?
|
SET `confirm_user_id`=?
|
||||||
WHERE `angeltype_id`=?
|
WHERE `angeltype_id`=?
|
||||||
|
@ -149,7 +149,7 @@ function UserAngelTypes_confirm_all($angeltype_id, $confirm_user_id)
|
||||||
*/
|
*/
|
||||||
function UserAngelTypes_all_unconfirmed($angeltype_id)
|
function UserAngelTypes_all_unconfirmed($angeltype_id)
|
||||||
{
|
{
|
||||||
return DB::select('
|
return Db::select('
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM `UserAngelTypes`
|
FROM `UserAngelTypes`
|
||||||
WHERE `angeltype_id`=?
|
WHERE `angeltype_id`=?
|
||||||
|
@ -165,7 +165,7 @@ function UserAngelTypes_all_unconfirmed($angeltype_id)
|
||||||
*/
|
*/
|
||||||
function UserAngelType_confirm($user_angeltype_id, $confirm_user_id)
|
function UserAngelType_confirm($user_angeltype_id, $confirm_user_id)
|
||||||
{
|
{
|
||||||
DB::update('
|
Db::update('
|
||||||
UPDATE `UserAngelTypes`
|
UPDATE `UserAngelTypes`
|
||||||
SET `confirm_user_id`=?
|
SET `confirm_user_id`=?
|
||||||
WHERE `id`=?
|
WHERE `id`=?
|
||||||
|
@ -179,7 +179,7 @@ function UserAngelType_confirm($user_angeltype_id, $confirm_user_id)
|
||||||
*/
|
*/
|
||||||
function UserAngelType_delete($user_angeltype)
|
function UserAngelType_delete($user_angeltype)
|
||||||
{
|
{
|
||||||
DB::delete('
|
Db::delete('
|
||||||
DELETE FROM `UserAngelTypes`
|
DELETE FROM `UserAngelTypes`
|
||||||
WHERE `id`=?
|
WHERE `id`=?
|
||||||
LIMIT 1', [$user_angeltype['id']]);
|
LIMIT 1', [$user_angeltype['id']]);
|
||||||
|
@ -194,7 +194,7 @@ function UserAngelType_delete($user_angeltype)
|
||||||
*/
|
*/
|
||||||
function UserAngelType_create($userId, $angeltype)
|
function UserAngelType_create($userId, $angeltype)
|
||||||
{
|
{
|
||||||
DB::insert('
|
Db::insert('
|
||||||
INSERT INTO `UserAngelTypes` (`user_id`, `angeltype_id`, `supporter`)
|
INSERT INTO `UserAngelTypes` (`user_id`, `angeltype_id`, `supporter`)
|
||||||
VALUES (?, ?, FALSE)
|
VALUES (?, ?, FALSE)
|
||||||
',
|
',
|
||||||
|
@ -204,7 +204,7 @@ function UserAngelType_create($userId, $angeltype)
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
return DB::getPdo()->lastInsertId();
|
return Db::getPdo()->lastInsertId();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -215,7 +215,7 @@ function UserAngelType_create($userId, $angeltype)
|
||||||
*/
|
*/
|
||||||
function UserAngelType($user_angeltype_id)
|
function UserAngelType($user_angeltype_id)
|
||||||
{
|
{
|
||||||
$angelType = DB::selectOne('
|
$angelType = Db::selectOne('
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM `UserAngelTypes`
|
FROM `UserAngelTypes`
|
||||||
WHERE `id`=?
|
WHERE `id`=?
|
||||||
|
@ -233,7 +233,7 @@ function UserAngelType($user_angeltype_id)
|
||||||
*/
|
*/
|
||||||
function UserAngelType_by_User_and_AngelType($userId, $angeltype)
|
function UserAngelType_by_User_and_AngelType($userId, $angeltype)
|
||||||
{
|
{
|
||||||
$angelType = DB::selectOne('
|
$angelType = Db::selectOne('
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM `UserAngelTypes`
|
FROM `UserAngelTypes`
|
||||||
WHERE `user_id`=?
|
WHERE `user_id`=?
|
||||||
|
@ -258,7 +258,7 @@ function UserAngelType_by_User_and_AngelType($userId, $angeltype)
|
||||||
*/
|
*/
|
||||||
function UserAngelTypes_by_User($userId, $onlyConfirmed=false)
|
function UserAngelTypes_by_User($userId, $onlyConfirmed=false)
|
||||||
{
|
{
|
||||||
return DB::select(
|
return Db::select(
|
||||||
'
|
'
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM `UserAngelTypes`
|
FROM `UserAngelTypes`
|
||||||
|
|
|
@ -10,7 +10,7 @@ use Engelsystem\Database\Db;
|
||||||
*/
|
*/
|
||||||
function User_groups($userId)
|
function User_groups($userId)
|
||||||
{
|
{
|
||||||
return DB::select('
|
return Db::select('
|
||||||
SELECT `Groups`.*
|
SELECT `Groups`.*
|
||||||
FROM `UserGroups`
|
FROM `UserGroups`
|
||||||
JOIN `Groups` ON `Groups`.`UID`=`UserGroups`.`group_id`
|
JOIN `Groups` ON `Groups`.`UID`=`UserGroups`.`group_id`
|
||||||
|
|
|
@ -22,7 +22,7 @@ use Illuminate\Support\Collection;
|
||||||
function User_tshirt_score($userId)
|
function User_tshirt_score($userId)
|
||||||
{
|
{
|
||||||
$shift_sum_formula = User_get_shifts_sum_query();
|
$shift_sum_formula = User_get_shifts_sum_query();
|
||||||
$result_shifts = DB::selectOne(sprintf('
|
$result_shifts = Db::selectOne(sprintf('
|
||||||
SELECT ROUND((%s) / 3600, 2) AS `tshirt_score`
|
SELECT ROUND((%s) / 3600, 2) AS `tshirt_score`
|
||||||
FROM `users` LEFT JOIN `ShiftEntry` ON `users`.`id` = `ShiftEntry`.`UID`
|
FROM `users` LEFT JOIN `ShiftEntry` ON `users`.`id` = `ShiftEntry`.`UID`
|
||||||
LEFT JOIN `Shifts` ON `ShiftEntry`.`SID` = `Shifts`.`SID`
|
LEFT JOIN `Shifts` ON `ShiftEntry`.`SID` = `Shifts`.`SID`
|
||||||
|
|
|
@ -24,7 +24,7 @@ function admin_free()
|
||||||
$search = strip_request_item('search');
|
$search = strip_request_item('search');
|
||||||
}
|
}
|
||||||
|
|
||||||
$angel_types_source = DB::select('SELECT `id`, `name` FROM `AngelTypes` ORDER BY `name`');
|
$angel_types_source = Db::select('SELECT `id`, `name` FROM `AngelTypes` ORDER BY `name`');
|
||||||
$angel_types = [
|
$angel_types = [
|
||||||
'' => __('All')
|
'' => __('All')
|
||||||
];
|
];
|
||||||
|
|
|
@ -17,12 +17,12 @@ function admin_groups()
|
||||||
{
|
{
|
||||||
$html = '';
|
$html = '';
|
||||||
$request = request();
|
$request = request();
|
||||||
$groups = DB::select('SELECT * FROM `Groups` ORDER BY `Name`');
|
$groups = Db::select('SELECT * FROM `Groups` ORDER BY `Name`');
|
||||||
|
|
||||||
if (!$request->has('action')) {
|
if (!$request->has('action')) {
|
||||||
$groups_table = [];
|
$groups_table = [];
|
||||||
foreach ($groups as $group) {
|
foreach ($groups as $group) {
|
||||||
$privileges = DB::select('
|
$privileges = Db::select('
|
||||||
SELECT `name`
|
SELECT `name`
|
||||||
FROM `GroupPrivileges`
|
FROM `GroupPrivileges`
|
||||||
JOIN `Privileges` ON (`GroupPrivileges`.`privilege_id` = `Privileges`.`id`)
|
JOIN `Privileges` ON (`GroupPrivileges`.`privilege_id` = `Privileges`.`id`)
|
||||||
|
@ -63,9 +63,9 @@ 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::select('SELECT * FROM `Groups` WHERE `UID`=? LIMIT 1', [$group_id]);
|
||||||
if (!empty($group)) {
|
if (!empty($group)) {
|
||||||
$privileges = DB::select('
|
$privileges = Db::select('
|
||||||
SELECT `Privileges`.*, `GroupPrivileges`.`group_id`
|
SELECT `Privileges`.*, `GroupPrivileges`.`group_id`
|
||||||
FROM `Privileges`
|
FROM `Privileges`
|
||||||
LEFT OUTER JOIN `GroupPrivileges`
|
LEFT OUTER JOIN `GroupPrivileges`
|
||||||
|
@ -121,22 +121,22 @@ function admin_groups()
|
||||||
return error('Incomplete call, missing Groups ID.', true);
|
return error('Incomplete call, missing Groups ID.', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
$group = DB::selectOne('SELECT * FROM `Groups` WHERE `UID`=? LIMIT 1', [$group_id]);
|
$group = Db::selectOne('SELECT * FROM `Groups` WHERE `UID`=? LIMIT 1', [$group_id]);
|
||||||
$privileges = $request->request->all('privileges');
|
$privileges = $request->request->all('privileges');
|
||||||
if (!is_array($privileges)) {
|
if (!is_array($privileges)) {
|
||||||
$privileges = [];
|
$privileges = [];
|
||||||
}
|
}
|
||||||
if (!empty($group)) {
|
if (!empty($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::selectOne(
|
$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)) {
|
||||||
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,7 +45,7 @@ function admin_shifts()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Engeltypen laden
|
// Engeltypen laden
|
||||||
$types = DB::select('SELECT * FROM `AngelTypes` ORDER BY `name`');
|
$types = Db::select('SELECT * FROM `AngelTypes` ORDER BY `name`');
|
||||||
$needed_angel_types = [];
|
$needed_angel_types = [];
|
||||||
foreach ($types as $type) {
|
foreach ($types as $type) {
|
||||||
$needed_angel_types[$type['id']] = 0;
|
$needed_angel_types[$type['id']] = 0;
|
||||||
|
@ -182,7 +182,7 @@ function admin_shifts()
|
||||||
if ($valid) {
|
if ($valid) {
|
||||||
if ($angelmode == 'location') {
|
if ($angelmode == 'location') {
|
||||||
$needed_angel_types = [];
|
$needed_angel_types = [];
|
||||||
$needed_angel_types_location = DB::select(
|
$needed_angel_types_location = Db::select(
|
||||||
'
|
'
|
||||||
SELECT `angel_type_id`, `count`
|
SELECT `angel_type_id`, `count`
|
||||||
FROM `NeededAngelTypes`
|
FROM `NeededAngelTypes`
|
||||||
|
@ -382,14 +382,14 @@ function admin_shifts()
|
||||||
|
|
||||||
$needed_angel_types_info = [];
|
$needed_angel_types_info = [];
|
||||||
foreach ($session->get('admin_shifts_types', []) as $type_id => $count) {
|
foreach ($session->get('admin_shifts_types', []) as $type_id => $count) {
|
||||||
$angel_type_source = DB::selectOne('
|
$angel_type_source = Db::selectOne('
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM `AngelTypes`
|
FROM `AngelTypes`
|
||||||
WHERE `id` = ?
|
WHERE `id` = ?
|
||||||
LIMIT 1', [$type_id]);
|
LIMIT 1', [$type_id]);
|
||||||
|
|
||||||
if (!empty($angel_type_source)) {
|
if (!empty($angel_type_source)) {
|
||||||
DB::insert('
|
Db::insert('
|
||||||
INSERT INTO `NeededAngelTypes` (`shift_id`, `angel_type_id`, `count`)
|
INSERT INTO `NeededAngelTypes` (`shift_id`, `angel_type_id`, `count`)
|
||||||
VALUES (?, ?, ?)
|
VALUES (?, ?, ?)
|
||||||
',
|
',
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Engelsystem\Database\Db;
|
use Engelsystem\Database\DB;
|
||||||
use Engelsystem\Models\User\User;
|
use Engelsystem\Models\User\User;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -125,7 +125,7 @@ function admin_user()
|
||||||
|
|
||||||
$html .= '<hr />';
|
$html .= '<hr />';
|
||||||
|
|
||||||
$my_highest_group = DB::selectOne(
|
$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->id]
|
[$user->id]
|
||||||
);
|
);
|
||||||
|
@ -133,7 +133,7 @@ function admin_user()
|
||||||
$my_highest_group = $my_highest_group['group_id'];
|
$my_highest_group = $my_highest_group['group_id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$his_highest_group = DB::selectOne(
|
$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]
|
||||||
);
|
);
|
||||||
|
@ -151,7 +151,7 @@ function admin_user()
|
||||||
$html .= form_csrf();
|
$html .= form_csrf();
|
||||||
$html .= '<table>';
|
$html .= '<table>';
|
||||||
|
|
||||||
$groups = DB::select('
|
$groups = Db::select('
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM `Groups`
|
FROM `Groups`
|
||||||
LEFT OUTER JOIN `UserGroups` ON (
|
LEFT OUTER JOIN `UserGroups` ON (
|
||||||
|
@ -189,11 +189,11 @@ function admin_user()
|
||||||
switch ($request->input('action')) {
|
switch ($request->input('action')) {
|
||||||
case 'save_groups':
|
case 'save_groups':
|
||||||
if ($user_id != $user->id || auth()->can('admin_groups')) {
|
if ($user_id != $user->id || auth()->can('admin_groups')) {
|
||||||
$my_highest_group = DB::selectOne(
|
$my_highest_group = Db::selectOne(
|
||||||
'SELECT * FROM `UserGroups` WHERE `uid`=? ORDER BY `group_id`',
|
'SELECT * FROM `UserGroups` WHERE `uid`=? ORDER BY `group_id`',
|
||||||
[$user->id]
|
[$user->id]
|
||||||
);
|
);
|
||||||
$his_highest_group = DB::selectOne(
|
$his_highest_group = Db::selectOne(
|
||||||
'SELECT * FROM `UserGroups` WHERE `uid`=? ORDER BY `group_id`',
|
'SELECT * FROM `UserGroups` WHERE `uid`=? ORDER BY `group_id`',
|
||||||
[$user_id]
|
[$user_id]
|
||||||
);
|
);
|
||||||
|
@ -205,7 +205,7 @@ function admin_user()
|
||||||
|| ($my_highest_group['group_id'] <= $his_highest_group['group_id'])
|
|| ($my_highest_group['group_id'] <= $his_highest_group['group_id'])
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
$groups_source = DB::select('
|
$groups_source = Db::select('
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM `Groups`
|
FROM `Groups`
|
||||||
LEFT OUTER JOIN `UserGroups` ON (
|
LEFT OUTER JOIN `UserGroups` ON (
|
||||||
|
@ -232,11 +232,11 @@ function admin_user()
|
||||||
$groupsRequest = [];
|
$groupsRequest = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
DB::delete('DELETE FROM `UserGroups` WHERE `uid`=?', [$user_id]);
|
Db::delete('DELETE FROM `UserGroups` WHERE `uid`=?', [$user_id]);
|
||||||
$user_groups_info = [];
|
$user_groups_info = [];
|
||||||
foreach ($groupsRequest as $group) {
|
foreach ($groupsRequest as $group) {
|
||||||
if (in_array($group, $grouplist)) {
|
if (in_array($group, $grouplist)) {
|
||||||
DB::insert(
|
Db::insert(
|
||||||
'INSERT INTO `UserGroups` (`uid`, `group_id`) VALUES (?, ?)',
|
'INSERT INTO `UserGroups` (`uid`, `group_id`) VALUES (?, ?)',
|
||||||
[$user_id, $group]
|
[$user_id, $group]
|
||||||
);
|
);
|
||||||
|
|
|
@ -287,7 +287,7 @@ function guest_register()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assign user-group and set password
|
// Assign user-group and set password
|
||||||
DB::insert('INSERT INTO `UserGroups` (`uid`, `group_id`) VALUES (?, -20)', [$user->id]);
|
Db::insert('INSERT INTO `UserGroups` (`uid`, `group_id`) VALUES (?, -20)', [$user->id]);
|
||||||
if ($enable_password) {
|
if ($enable_password) {
|
||||||
auth()->setPassword($user, $request->postData('password'));
|
auth()->setPassword($user, $request->postData('password'));
|
||||||
}
|
}
|
||||||
|
@ -295,7 +295,7 @@ function guest_register()
|
||||||
// Assign angel-types
|
// Assign angel-types
|
||||||
$user_angel_types_info = [];
|
$user_angel_types_info = [];
|
||||||
foreach ($selected_angel_types as $selected_angel_type_id) {
|
foreach ($selected_angel_types as $selected_angel_type_id) {
|
||||||
DB::insert(
|
Db::insert(
|
||||||
'INSERT INTO `UserAngelTypes` (`user_id`, `angeltype_id`, `supporter`) VALUES (?, ?, FALSE)',
|
'INSERT INTO `UserAngelTypes` (`user_id`, `angeltype_id`, `supporter`) VALUES (?, ?, FALSE)',
|
||||||
[$user->id, $selected_angel_type_id]
|
[$user->id, $selected_angel_type_id]
|
||||||
);
|
);
|
||||||
|
|
|
@ -48,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'))) {
|
||||||
$shift_entry_id = $request->input('edit');
|
$shift_entry_id = $request->input('edit');
|
||||||
$shift = DB::selectOne('
|
$shift = Db::selectOne('
|
||||||
SELECT
|
SELECT
|
||||||
`ShiftEntry`.`freeloaded`,
|
`ShiftEntry`.`freeloaded`,
|
||||||
`ShiftEntry`.`freeload_comment`,
|
`ShiftEntry`.`freeload_comment`,
|
||||||
|
|
|
@ -118,7 +118,7 @@ function load_rooms()
|
||||||
*/
|
*/
|
||||||
function load_days()
|
function load_days()
|
||||||
{
|
{
|
||||||
$days = (new Collection(DB::select(
|
$days = (new Collection(Db::select(
|
||||||
'
|
'
|
||||||
SELECT DISTINCT DATE(FROM_UNIXTIME(`start`)) AS `id`, DATE(FROM_UNIXTIME(`start`)) AS `name`
|
SELECT DISTINCT DATE(FROM_UNIXTIME(`start`)) AS `id`, DATE(FROM_UNIXTIME(`start`)) AS `name`
|
||||||
FROM `Shifts`
|
FROM `Shifts`
|
||||||
|
@ -145,11 +145,11 @@ function load_types()
|
||||||
{
|
{
|
||||||
$user = auth()->user();
|
$user = auth()->user();
|
||||||
|
|
||||||
if (!count(DB::select('SELECT `id`, `name` FROM `AngelTypes`'))) {
|
if (!count(Db::select('SELECT `id`, `name` FROM `AngelTypes`'))) {
|
||||||
error(__('The administration has not configured any angeltypes yet - or you are not subscribed to any angeltype.'));
|
error(__('The administration has not configured any angeltypes yet - or you are not subscribed to any angeltype.'));
|
||||||
throw_redirect(page_link_to('/'));
|
throw_redirect(page_link_to('/'));
|
||||||
}
|
}
|
||||||
$types = DB::select('
|
$types = Db::select('
|
||||||
SELECT
|
SELECT
|
||||||
`AngelTypes`.`id`,
|
`AngelTypes`.`id`,
|
||||||
`AngelTypes`.`name`,
|
`AngelTypes`.`name`,
|
||||||
|
@ -183,7 +183,7 @@ function load_types()
|
||||||
*/
|
*/
|
||||||
function unrestricted_angeltypes()
|
function unrestricted_angeltypes()
|
||||||
{
|
{
|
||||||
return DB::select('SELECT `id`, `name` FROM `AngelTypes` WHERE `restricted` = 0');
|
return Db::select('SELECT `id`, `name` FROM `AngelTypes` WHERE `restricted` = 0');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -9,7 +9,7 @@ use Engelsystem\Database\Db;
|
||||||
function privileges_for_user($user_id)
|
function privileges_for_user($user_id)
|
||||||
{
|
{
|
||||||
$privileges = [];
|
$privileges = [];
|
||||||
$user_privileges = DB::select('
|
$user_privileges = Db::select('
|
||||||
SELECT `Privileges`.`name`
|
SELECT `Privileges`.`name`
|
||||||
FROM `users`
|
FROM `users`
|
||||||
JOIN `UserGroups` ON (`users`.`id` = `UserGroups`.`uid`)
|
JOIN `UserGroups` ON (`users`.`id` = `UserGroups`.`uid`)
|
||||||
|
@ -30,7 +30,7 @@ function privileges_for_user($user_id)
|
||||||
function privileges_for_group($group_id)
|
function privileges_for_group($group_id)
|
||||||
{
|
{
|
||||||
$privileges = [];
|
$privileges = [];
|
||||||
$groups_privileges = DB::select('
|
$groups_privileges = Db::select('
|
||||||
SELECT `name`
|
SELECT `name`
|
||||||
FROM `GroupPrivileges`
|
FROM `GroupPrivileges`
|
||||||
JOIN `Privileges` ON (`GroupPrivileges`.`privilege_id` = `Privileges`.`id`)
|
JOIN `Privileges` ON (`GroupPrivileges`.`privilege_id` = `Privileges`.`id`)
|
||||||
|
|
Loading…
Reference in New Issue