Replaced DB with Db

This commit is contained in:
Bot 2022-06-16 22:50:52 +02:00 committed by Igor Scheller
parent 05e94bbfee
commit 3ebea2ae15
17 changed files with 97 additions and 97 deletions

View File

@ -206,7 +206,7 @@ function user_controller()
$shifts = Shifts_by_user($user_source->id, auth()->can('user_shifts_admin'));
foreach ($shifts as &$shift) {
// TODO: Move queries to model
$shift['needed_angeltypes'] = DB::select('
$shift['needed_angeltypes'] = Db::select('
SELECT DISTINCT `AngelTypes`.*
FROM `ShiftEntry`
JOIN `AngelTypes` ON `ShiftEntry`.`TID`=`AngelTypes`.`id`
@ -216,7 +216,7 @@ function user_controller()
[$shift['SID']]
);
foreach ($shift['needed_angeltypes'] as &$needed_angeltype) {
$needed_angeltype['users'] = DB::select('
$needed_angeltype['users'] = Db::select('
SELECT `ShiftEntry`.`freeloaded`, `users`.*
FROM `ShiftEntry`
JOIN `users` ON `ShiftEntry`.`UID`=`users`.`id`

View File

@ -43,7 +43,7 @@ function AngelType_has_contact_info($angeltype)
*/
function AngelType_delete($angeltype)
{
DB::delete('
Db::delete('
DELETE FROM `AngelTypes`
WHERE `id`=?
LIMIT 1
@ -58,7 +58,7 @@ function AngelType_delete($angeltype)
*/
function AngelType_update($angeltype)
{
DB::update('
Db::update('
UPDATE `AngelTypes` SET
`name` = ?,
`restricted` = ?,
@ -104,7 +104,7 @@ function AngelType_update($angeltype)
*/
function AngelType_create($angeltype)
{
DB::insert('
Db::insert('
INSERT INTO `AngelTypes` (
`name`,
`restricted`,
@ -131,7 +131,7 @@ function AngelType_create($angeltype)
]
);
$angeltype['id'] = DB::getPdo()->lastInsertId();
$angeltype['id'] = Db::getPdo()->lastInsertId();
engelsystem_log(
'Created angeltype: ' . $angeltype['name']
. ($angeltype['restricted'] ? ', restricted' : '')
@ -161,7 +161,7 @@ function AngelType_validate_name($name, $angeltype)
return new ValidationResult(false, '');
}
if (!empty($angeltype) && isset($angeltype['id'])) {
$valid = (count(DB::select('
$valid = (count(Db::select('
SELECT `id`
FROM `AngelTypes`
WHERE `name`=?
@ -170,7 +170,7 @@ function AngelType_validate_name($name, $angeltype)
', [$name, $angeltype['id']])) == 0);
return new ValidationResult($valid, $name);
}
$valid = (count(DB::select('
$valid = (count(Db::select('
SELECT `id`
FROM `AngelTypes`
WHERE `name`=?
@ -187,7 +187,7 @@ function AngelType_validate_name($name, $angeltype)
*/
function AngelTypes_with_user($userId)
{
return DB::select('
return Db::select('
SELECT `AngelTypes`.*,
`UserAngelTypes`.`id` AS `user_angeltype_id`,
`UserAngelTypes`.`confirm_user_id`,
@ -205,7 +205,7 @@ function AngelTypes_with_user($userId)
*/
function AngelTypes()
{
return DB::select('
return Db::select('
SELECT *
FROM `AngelTypes`
ORDER BY `name`
@ -219,7 +219,7 @@ function AngelTypes()
*/
function AngelType_ids()
{
$result = DB::select('SELECT `id` FROM `AngelTypes`');
$result = Db::select('SELECT `id` FROM `AngelTypes`');
return select_array($result, 'id', 'id');
}
@ -231,7 +231,7 @@ function AngelType_ids()
*/
function AngelType($angeltype_id)
{
$angelType = DB::selectOne(
$angelType = Db::selectOne(
'SELECT * FROM `AngelTypes` WHERE `id`=?',
[$angeltype_id]
);

View File

@ -18,7 +18,7 @@ use Engelsystem\Database\Db;
*/
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`)
VALUES (?, ?, ?, ?)
',
@ -29,7 +29,7 @@ function NeededAngelType_add($shift_id, $angeltype_id, $room_id, $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)
{
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)
{
DB::delete(
Db::delete(
'DELETE FROM `NeededAngelTypes` WHERE `room_id` = ?',
[$room_id]
);
@ -63,7 +63,7 @@ function NeededAngelTypes_delete_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`=?',
[$room_id]
);
@ -77,7 +77,7 @@ function NeededAngelTypes_by_room($room_id)
*/
function NeededAngelTypes_by_shift($shiftId)
{
$needed_angeltypes_source = DB::select('
$needed_angeltypes_source = Db::select('
SELECT
`NeededAngelTypes`.*,
`AngelTypes`.`id`,
@ -94,7 +94,7 @@ function NeededAngelTypes_by_shift($shiftId)
// Use settings from room
if (count($needed_angeltypes_source) == 0) {
$needed_angeltypes_source = DB::select('
$needed_angeltypes_source = Db::select('
SELECT `NeededAngelTypes`.*, `AngelTypes`.`name`, `AngelTypes`.`restricted`
FROM `NeededAngelTypes`
JOIN `AngelTypes` ON `AngelTypes`.`id` = `NeededAngelTypes`.`angel_type_id`

View File

@ -12,7 +12,7 @@ use Engelsystem\Models\User\User;
*/
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)) {
return 0;
@ -29,7 +29,7 @@ function ShiftEntries_freeloaded_count()
*/
function ShiftEntries_by_shift($shift_id)
{
return DB::select('
return Db::select('
SELECT
`users`.*,
`ShiftEntry`.`UID`,
@ -60,7 +60,7 @@ function ShiftEntry_create($shift_entry)
$shifttype = ShiftType($shift['shifttype_id']);
$room = Room::find($shift['RID']);
$angeltype = AngelType($shift_entry['TID']);
$result = DB::insert('
$result = Db::insert('
INSERT INTO `ShiftEntry` (
`SID`,
`TID`,
@ -101,7 +101,7 @@ function ShiftEntry_create($shift_entry)
*/
function ShiftEntry_update($shift_entry)
{
DB::update('
Db::update('
UPDATE `ShiftEntry`
SET
`Comment` = ?,
@ -126,7 +126,7 @@ function ShiftEntry_update($shift_entry)
*/
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;
}
@ -138,7 +138,7 @@ function ShiftEntry($shift_entry_id)
*/
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']);
$shift = Shift($shiftEntry['SID']);
@ -167,7 +167,7 @@ function ShiftEntry_delete($shiftEntry)
*/
function ShiftEntries_upcoming_for_user($userId)
{
return DB::select('
return Db::select('
SELECT *
FROM `ShiftEntry`
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)
{
return DB::select('
return Db::select('
SELECT *
FROM `ShiftEntry`
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)
{
return DB::select('
return Db::select('
SELECT *
FROM `ShiftEntry`
WHERE `SID` = ?
@ -240,7 +240,7 @@ function ShiftEntries_by_shift_and_angeltype($shift_id, $angeltype_id)
*/
function ShiftEntries_freeloaded_by_user($userId)
{
return DB::select('
return Db::select('
SELECT *
FROM `ShiftEntry`
WHERE `freeloaded` = 1

View File

@ -9,7 +9,7 @@ use Engelsystem\Database\Db;
*/
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)
{
DB::update('
Db::update('
UPDATE `ShiftTypes` SET
`name`=?,
`angeltype_id`=?,
@ -48,7 +48,7 @@ function ShiftType_update($shifttype_id, $name, $angeltype_id, $description)
*/
function ShiftType_create($name, $angeltype_id, $description)
{
DB::insert('
Db::insert('
INSERT INTO `ShiftTypes` (`name`, `angeltype_id`, `description`)
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)
{
$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;
}
@ -82,5 +82,5 @@ function ShiftType($shifttype_id)
*/
function ShiftTypes()
{
return DB::select('SELECT * FROM `ShiftTypes` ORDER BY `name`');
return Db::select('SELECT * FROM `ShiftTypes` ORDER BY `name`');
}

View File

@ -12,7 +12,7 @@ use Engelsystem\ShiftSignupState;
*/
function Shifts_by_angeltype($angeltype)
{
return DB::select('
return Db::select('
SELECT DISTINCT `Shifts`.* FROM `Shifts`
JOIN `NeededAngelTypes` ON `NeededAngelTypes`.`shift_id` = `Shifts`.`SID`
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)
{
return DB::select(
return Db::select(
'SELECT * FROM `Shifts` WHERE `RID`=? ORDER BY `start`',
[$room->id]
);
@ -128,7 +128,7 @@ function Shifts_by_ShiftsFilter(ShiftsFilter $shiftsFilter)
ORDER BY `room_name`, `start`
';
return DB::select(
return Db::select(
$sql,
[
$shiftsFilter->getStartTime(),
@ -179,7 +179,7 @@ function NeededAngeltypes_by_ShiftsFilter(ShiftsFilter $shiftsFilter)
AND NOT s.shift_id IS NULL
';
return DB::select(
return Db::select(
$sql,
[
$shiftsFilter->getStartTime(),
@ -197,7 +197,7 @@ function NeededAngeltypes_by_ShiftsFilter(ShiftsFilter $shiftsFilter)
*/
function NeededAngeltype_by_Shift_and_Angeltype($shift, $angeltype)
{
return DB::selectOne('
return Db::selectOne('
SELECT
`NeededAngelTypes`.*,
`Shifts`.`SID`,
@ -262,7 +262,7 @@ function ShiftEntries_by_ShiftsFilter(ShiftsFilter $shiftsFilter)
',
implode(',', $shiftsFilter->getRooms())
);
return DB::select(
return Db::select(
$sql,
[
$shiftsFilter->getStartTime(),
@ -513,7 +513,7 @@ function Shift_signup_allowed(
function Shift_delete($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'];
mail_shift_change(Shift($shift['SID']), $shift);
return DB::update('
return Db::update('
UPDATE `Shifts` SET
`shifttype_id` = ?,
`start` = ?,
@ -561,11 +561,11 @@ function Shift_update($shift)
*
* @param array $shift
* @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)
{
DB::insert('
Db::insert('
INSERT INTO `Shifts` (
`shifttype_id`,
`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)
{
return DB::select('
return Db::select('
SELECT
`rooms`.*,
`rooms`.name AS Name,
@ -646,7 +646,7 @@ function Shifts_by_user($userId, $include_freeload_comments = false)
*/
function Shift($shift_id)
{
$result = DB::selectOne('
$result = Db::selectOne('
SELECT `Shifts`.*, `ShiftTypes`.`name`
FROM `Shifts`
JOIN `ShiftTypes` ON (`ShiftTypes`.`id` = `Shifts`.`shifttype_id`)
@ -656,7 +656,7 @@ function Shift($shift_id)
return null;
}
$shiftsEntry_source = DB::select('
$shiftsEntry_source = Db::select('
SELECT `ShiftEntry`.`id`, `ShiftEntry`.`TID` , `ShiftEntry`.`UID` , `ShiftEntry`.`freeloaded`, `users`.`name` AS `username`
FROM `ShiftEntry`
LEFT JOIN `users` ON (`users`.`id` = `ShiftEntry`.`UID`)

View File

@ -16,7 +16,7 @@ use Engelsystem\Models\User\User;
*/
function UserAngelType_exists($userId, $angeltype)
{
return count(DB::select('
return count(Db::select('
SELECT `id`
FROM `UserAngelTypes`
WHERE `UserAngelTypes`.`user_id`=?
@ -32,7 +32,7 @@ function UserAngelType_exists($userId, $angeltype)
*/
function User_angeltypes($userId)
{
return DB::select('
return Db::select('
SELECT `AngelTypes`.*, `UserAngelTypes`.`confirm_user_id`, `UserAngelTypes`.`supporter`
FROM `UserAngelTypes`
JOIN `AngelTypes` ON `UserAngelTypes`.`angeltype_id` = `AngelTypes`.`id`
@ -48,7 +48,7 @@ function User_angeltypes($userId)
*/
function User_unconfirmed_AngelTypes($userId)
{
return DB::select('
return Db::select('
SELECT
`UserAngelTypes`.*,
`AngelTypes`.`name`,
@ -80,7 +80,7 @@ function User_is_AngelType_supporter($user, $angeltype)
$privileges = privileges_for_user($user->id);
return (count(DB::select('
return (count(Db::select('
SELECT `id`
FROM `UserAngelTypes`
WHERE `user_id`=?
@ -104,7 +104,7 @@ function User_is_AngelType_supporter($user, $angeltype)
*/
function UserAngelType_update($user_angeltype_id, $supporter)
{
DB::update('
Db::update('
UPDATE `UserAngelTypes`
SET `supporter`=?
WHERE `id`=?
@ -119,7 +119,7 @@ function UserAngelType_update($user_angeltype_id, $supporter)
*/
function UserAngelTypes_delete_all($angeltype_id)
{
DB::delete('
Db::delete('
DELETE FROM `UserAngelTypes`
WHERE `angeltype_id`=?
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)
{
DB::update('
Db::update('
UPDATE `UserAngelTypes`
SET `confirm_user_id`=?
WHERE `angeltype_id`=?
@ -149,7 +149,7 @@ function UserAngelTypes_confirm_all($angeltype_id, $confirm_user_id)
*/
function UserAngelTypes_all_unconfirmed($angeltype_id)
{
return DB::select('
return Db::select('
SELECT *
FROM `UserAngelTypes`
WHERE `angeltype_id`=?
@ -165,7 +165,7 @@ function UserAngelTypes_all_unconfirmed($angeltype_id)
*/
function UserAngelType_confirm($user_angeltype_id, $confirm_user_id)
{
DB::update('
Db::update('
UPDATE `UserAngelTypes`
SET `confirm_user_id`=?
WHERE `id`=?
@ -179,7 +179,7 @@ function UserAngelType_confirm($user_angeltype_id, $confirm_user_id)
*/
function UserAngelType_delete($user_angeltype)
{
DB::delete('
Db::delete('
DELETE FROM `UserAngelTypes`
WHERE `id`=?
LIMIT 1', [$user_angeltype['id']]);
@ -194,7 +194,7 @@ function UserAngelType_delete($user_angeltype)
*/
function UserAngelType_create($userId, $angeltype)
{
DB::insert('
Db::insert('
INSERT INTO `UserAngelTypes` (`user_id`, `angeltype_id`, `supporter`)
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)
{
$angelType = DB::selectOne('
$angelType = Db::selectOne('
SELECT *
FROM `UserAngelTypes`
WHERE `id`=?
@ -233,7 +233,7 @@ function UserAngelType($user_angeltype_id)
*/
function UserAngelType_by_User_and_AngelType($userId, $angeltype)
{
$angelType = DB::selectOne('
$angelType = Db::selectOne('
SELECT *
FROM `UserAngelTypes`
WHERE `user_id`=?
@ -258,7 +258,7 @@ function UserAngelType_by_User_and_AngelType($userId, $angeltype)
*/
function UserAngelTypes_by_User($userId, $onlyConfirmed=false)
{
return DB::select(
return Db::select(
'
SELECT *
FROM `UserAngelTypes`

View File

@ -10,7 +10,7 @@ use Engelsystem\Database\Db;
*/
function User_groups($userId)
{
return DB::select('
return Db::select('
SELECT `Groups`.*
FROM `UserGroups`
JOIN `Groups` ON `Groups`.`UID`=`UserGroups`.`group_id`

View File

@ -22,7 +22,7 @@ use Illuminate\Support\Collection;
function User_tshirt_score($userId)
{
$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`
FROM `users` LEFT JOIN `ShiftEntry` ON `users`.`id` = `ShiftEntry`.`UID`
LEFT JOIN `Shifts` ON `ShiftEntry`.`SID` = `Shifts`.`SID`

View File

@ -24,7 +24,7 @@ function admin_free()
$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 = [
'' => __('All')
];

View File

@ -17,12 +17,12 @@ function admin_groups()
{
$html = '';
$request = request();
$groups = DB::select('SELECT * FROM `Groups` ORDER BY `Name`');
$groups = Db::select('SELECT * FROM `Groups` ORDER BY `Name`');
if (!$request->has('action')) {
$groups_table = [];
foreach ($groups as $group) {
$privileges = DB::select('
$privileges = Db::select('
SELECT `name`
FROM `GroupPrivileges`
JOIN `Privileges` ON (`GroupPrivileges`.`privilege_id` = `Privileges`.`id`)
@ -63,9 +63,9 @@ function admin_groups()
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)) {
$privileges = DB::select('
$privileges = Db::select('
SELECT `Privileges`.*, `GroupPrivileges`.`group_id`
FROM `Privileges`
LEFT OUTER JOIN `GroupPrivileges`
@ -121,22 +121,22 @@ function admin_groups()
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');
if (!is_array($privileges)) {
$privileges = [];
}
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 = [];
foreach ($privileges as $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',
[$privilege]
);
if (!empty($group_privileges_source)) {
DB::insert(
Db::insert(
'INSERT INTO `GroupPrivileges` (`group_id`, `privilege_id`) VALUES (?, ?)',
[$group_id, $privilege]
);

View File

@ -45,7 +45,7 @@ function admin_shifts()
}
// Engeltypen laden
$types = DB::select('SELECT * FROM `AngelTypes` ORDER BY `name`');
$types = Db::select('SELECT * FROM `AngelTypes` ORDER BY `name`');
$needed_angel_types = [];
foreach ($types as $type) {
$needed_angel_types[$type['id']] = 0;
@ -182,7 +182,7 @@ function admin_shifts()
if ($valid) {
if ($angelmode == 'location') {
$needed_angel_types = [];
$needed_angel_types_location = DB::select(
$needed_angel_types_location = Db::select(
'
SELECT `angel_type_id`, `count`
FROM `NeededAngelTypes`
@ -382,14 +382,14 @@ function admin_shifts()
$needed_angel_types_info = [];
foreach ($session->get('admin_shifts_types', []) as $type_id => $count) {
$angel_type_source = DB::selectOne('
$angel_type_source = Db::selectOne('
SELECT *
FROM `AngelTypes`
WHERE `id` = ?
LIMIT 1', [$type_id]);
if (!empty($angel_type_source)) {
DB::insert('
Db::insert('
INSERT INTO `NeededAngelTypes` (`shift_id`, `angel_type_id`, `count`)
VALUES (?, ?, ?)
',

View File

@ -1,6 +1,6 @@
<?php
use Engelsystem\Database\Db;
use Engelsystem\Database\DB;
use Engelsystem\Models\User\User;
/**
@ -125,7 +125,7 @@ function admin_user()
$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',
[$user->id]
);
@ -133,7 +133,7 @@ function admin_user()
$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',
[$user_id]
);
@ -151,7 +151,7 @@ function admin_user()
$html .= form_csrf();
$html .= '<table>';
$groups = DB::select('
$groups = Db::select('
SELECT *
FROM `Groups`
LEFT OUTER JOIN `UserGroups` ON (
@ -189,11 +189,11 @@ function admin_user()
switch ($request->input('action')) {
case 'save_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`',
[$user->id]
);
$his_highest_group = DB::selectOne(
$his_highest_group = Db::selectOne(
'SELECT * FROM `UserGroups` WHERE `uid`=? ORDER BY `group_id`',
[$user_id]
);
@ -205,7 +205,7 @@ function admin_user()
|| ($my_highest_group['group_id'] <= $his_highest_group['group_id'])
)
) {
$groups_source = DB::select('
$groups_source = Db::select('
SELECT *
FROM `Groups`
LEFT OUTER JOIN `UserGroups` ON (
@ -232,11 +232,11 @@ function admin_user()
$groupsRequest = [];
}
DB::delete('DELETE FROM `UserGroups` WHERE `uid`=?', [$user_id]);
Db::delete('DELETE FROM `UserGroups` WHERE `uid`=?', [$user_id]);
$user_groups_info = [];
foreach ($groupsRequest as $group) {
if (in_array($group, $grouplist)) {
DB::insert(
Db::insert(
'INSERT INTO `UserGroups` (`uid`, `group_id`) VALUES (?, ?)',
[$user_id, $group]
);

View File

@ -287,7 +287,7 @@ function guest_register()
}
// 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) {
auth()->setPassword($user, $request->postData('password'));
}
@ -295,7 +295,7 @@ function guest_register()
// Assign angel-types
$user_angel_types_info = [];
foreach ($selected_angel_types as $selected_angel_type_id) {
DB::insert(
Db::insert(
'INSERT INTO `UserAngelTypes` (`user_id`, `angeltype_id`, `supporter`) VALUES (?, ?, FALSE)',
[$user->id, $selected_angel_type_id]
);

View File

@ -48,7 +48,7 @@ function user_myshifts()
]);
} elseif ($request->has('edit') && preg_match('/^\d+$/', $request->input('edit'))) {
$shift_entry_id = $request->input('edit');
$shift = DB::selectOne('
$shift = Db::selectOne('
SELECT
`ShiftEntry`.`freeloaded`,
`ShiftEntry`.`freeload_comment`,

View File

@ -118,7 +118,7 @@ function load_rooms()
*/
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`
FROM `Shifts`
@ -145,11 +145,11 @@ function load_types()
{
$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.'));
throw_redirect(page_link_to('/'));
}
$types = DB::select('
$types = Db::select('
SELECT
`AngelTypes`.`id`,
`AngelTypes`.`name`,
@ -183,7 +183,7 @@ function load_types()
*/
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');
}
/**

View File

@ -9,7 +9,7 @@ use Engelsystem\Database\Db;
function privileges_for_user($user_id)
{
$privileges = [];
$user_privileges = DB::select('
$user_privileges = Db::select('
SELECT `Privileges`.`name`
FROM `users`
JOIN `UserGroups` ON (`users`.`id` = `UserGroups`.`uid`)
@ -30,7 +30,7 @@ function privileges_for_user($user_id)
function privileges_for_group($group_id)
{
$privileges = [];
$groups_privileges = DB::select('
$groups_privileges = Db::select('
SELECT `name`
FROM `GroupPrivileges`
JOIN `Privileges` ON (`GroupPrivileges`.`privilege_id` = `Privileges`.`id`)