clear delete queries from false resuls

This commit is contained in:
msquare 2017-07-28 18:50:00 +02:00
parent 144b453bc6
commit 5794c4cab8
17 changed files with 19 additions and 76 deletions

View File

@ -269,10 +269,7 @@ function shift_entry_delete_controller()
redirect(page_link_to('user_shifts'));
}
$result = ShiftEntry_delete($entry_id);
if ($result === false) {
engelsystem_error('Unable to delete shift entry.');
}
ShiftEntry_delete($entry_id);
engelsystem_log(
'Deleted ' . User_Nick_render($shift_entry_source) . '\'s shift: ' . $shift_entry_source['name']

View File

@ -28,10 +28,7 @@ function shifttype_delete_controller()
}
if ($request->has('confirmed')) {
$result = ShiftType_delete($shifttype['id']);
if (empty($result)) {
engelsystem_error('Unable to delete shifttype.');
}
ShiftType_delete($shifttype['id']);
engelsystem_log('Deleted shifttype ' . $shifttype['name']);
success(sprintf(_('Shifttype %s deleted.'), $shifttype['name']));

View File

@ -215,10 +215,7 @@ function user_angeltype_delete_controller()
}
if ($request->has('confirmed')) {
$result = UserAngelType_delete($user_angeltype);
if ($result === false) {
engelsystem_error('Unable to delete user angeltype.');
}
UserAngelType_delete($user_angeltype);
$success_message = sprintf(_('User %s removed from %s.'), User_Nick_render($user_source), $angeltype['name']);
engelsystem_log($success_message);

View File

@ -76,10 +76,7 @@ function user_delete_controller()
}
if ($valid) {
$result = User_delete($user_source['UID']);
if ($result === false) {
engelsystem_error('Unable to delete user.');
}
User_delete($user_source['UID']);
mail_user_delete($user_source);
success(_('User deleted.'));

View File

@ -77,20 +77,15 @@ function AngelType_contact_info($angeltype)
* Delete an Angeltype.
*
* @param array $angeltype
* @return bool
*/
function AngelType_delete($angeltype)
{
$result = DB::delete('
DB::delete('
DELETE FROM `AngelTypes`
WHERE `id`=?
LIMIT 1
', [$angeltype['id']]);
if (is_null($result)) {
engelsystem_error('Unable to delete angeltype.');
}
engelsystem_log('Deleted angeltype: ' . AngelType_name_render($angeltype));
return true;
}
/**

View File

@ -35,22 +35,20 @@ function NeededAngelType_add($shift_id, $angeltype_id, $room_id, $count)
* Deletes all needed angel types from given shift.
*
* @param int $shift_id id of the shift
* @return int count of affected rows
*/
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.
*
* @param int $room_id id of the room
* @return int count of affected rows
*/
function NeededAngelTypes_delete_by_room($room_id)
{
return (int)DB::delete(
DB::delete(
'DELETE FROM `NeededAngelTypes` WHERE `room_id` = ?',
[$room_id]
);

View File

@ -17,11 +17,10 @@ function Rooms($show_all = false)
* Delete a room
*
* @param int $room_id
* @return bool
*/
function Room_delete($room_id)
{
return DB::delete('DELETE FROM `Room` WHERE `RID` = ?', [$room_id]);
DB::delete('DELETE FROM `Room` WHERE `RID` = ?', [$room_id]);
}
/**

View File

@ -143,13 +143,12 @@ function ShiftEntry($shift_entry_id)
* Delete a shift entry.
*
* @param int $shift_entry_id
* @return bool
*/
function ShiftEntry_delete($shift_entry_id)
{
$shift_entry = ShiftEntry($shift_entry_id);
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]);
}
/**

View File

@ -6,11 +6,10 @@ use Engelsystem\Database\DB;
* Delete a shift type.
*
* @param int $shifttype_id
* @return bool
*/
function ShiftType_delete($shifttype_id)
{
return DB::delete('DELETE FROM `ShiftTypes` WHERE `id`=?', [$shifttype_id]);
DB::delete('DELETE FROM `ShiftTypes` WHERE `id`=?', [$shifttype_id]);
}
/**

View File

@ -402,34 +402,22 @@ function Shift_signup_allowed(
* Delete a shift by its external id.
*
* @param int $shift_psid
* @return bool
*/
function Shift_delete_by_psid($shift_psid)
{
DB::delete('DELETE FROM `Shifts` WHERE `PSID`=?', [$shift_psid]);
if (DB::getStm()->errorCode() != '00000') {
return false;
}
return true;
}
/**
* Delete a shift.
*
* @param int $shift_id
* @return bool
*/
function Shift_delete($shift_id)
{
mail_shift_delete(Shift($shift_id));
$result = DB::delete('DELETE FROM `Shifts` WHERE `SID`=?', [$shift_id]);
if (DB::getStm()->errorCode() != '00000') {
engelsystem_error('Unable to delete shift.');
}
return $result;
DB::delete('DELETE FROM `Shifts` WHERE `SID`=?', [$shift_id]);
}
/**

View File

@ -125,7 +125,6 @@ function UserAngelType_update($user_angeltype_id, $supporter)
* Delete all unconfirmed UserAngelTypes for given Angeltype.
*
* @param int $angeltype_id
* @return bool
*/
function UserAngelTypes_delete_all($angeltype_id)
{
@ -134,12 +133,6 @@ function UserAngelTypes_delete_all($angeltype_id)
WHERE `angeltype_id`=?
AND `confirm_user_id` IS NULL
', [$angeltype_id]);
if (DB::getStm()->errorCode() != '00000') {
engelsystem_error('Unable to delete all unconfirmed users.');
}
return true;
}
/**
@ -178,11 +171,10 @@ function UserAngelType_confirm($user_angeltype_id, $confirm_user)
* Delete an UserAngelType.
*
* @param array $user_angeltype
* @return bool
*/
function UserAngelType_delete($user_angeltype)
{
return (bool)DB::delete('
DB::delete('
DELETE FROM `UserAngelTypes`
WHERE `id`=?
LIMIT 1', [$user_angeltype['id']]);

View File

@ -132,13 +132,8 @@ function UserDriverLicenses_update($user_driver_license)
* Delete a user's driver license entry
*
* @param int $user_id
* @return bool
*/
function UserDriverLicenses_delete($user_id)
{
$result = 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;
DB::delete('DELETE FROM `UserDriverLicenses` WHERE `user_id`=?', [$user_id]);
}

View File

@ -11,13 +11,10 @@ use Engelsystem\ValidationResult;
* Delete a user
*
* @param int $user_id
* @return bool
*/
function User_delete($user_id)
{
DB::delete('DELETE FROM `User` WHERE `UID`=?', [$user_id]);
return DB::getStm()->errorCode() == '00000';
}
/**

View File

@ -279,10 +279,7 @@ function admin_import()
}
foreach ($events_deleted as $event) {
$result = Shift_delete_by_psid($event['PSID']);
if ($result === false) {
engelsystem_error('Unable to delete shift.');
}
Shift_delete_by_psid($event['PSID']);
}
engelsystem_log('Frab import done');

View File

@ -209,9 +209,7 @@ function admin_rooms()
]);
} elseif ($request->input('show') == 'delete') {
if ($request->has('ack')) {
if (!Room_delete($room_id)) {
engelsystem_error('Unable to delete room.');
}
Room_delete($room_id);
engelsystem_log('Room deleted: ' . $name);
success(sprintf(_('Room %s deleted.'), $name));

View File

@ -145,10 +145,8 @@ function user_myshifts()
($shift['start'] > time() + config('last_unsubscribe') * 3600)
|| in_array('user_shifts_admin', $privileges)
) {
$result = ShiftEntry_delete($user_id);
if ($result === false) {
engelsystem_error('Unable to delete shift entry.');
}
ShiftEntry_delete($user_id);
$room = Room($shift['RID']);
$angeltype = AngelType($shift['TID']);
$shifttype = ShiftType($shift['shifttype_id']);

View File

@ -113,13 +113,13 @@ class Db
*
* @param string $query
* @param array $bindings
* @return int|bool
* @return int
*/
public static function delete($query, array $bindings = [])
{
self::query($query, $bindings);
return (self::$lastStatus ? self::$stm->rowCount() : false);
return self::$stm->rowCount();
}
/**