Safe deletion of users

This commit is contained in:
Phyks 2013-09-15 16:19:37 +02:00
parent 2fc4311c54
commit 1a9acc5ece
2 changed files with 12 additions and 9 deletions

2
TODO
View File

@ -5,6 +5,8 @@
* cf TODO in files
* French template
* Favicon
* Take account of paybacks in balance table
* Confirm all paybacks
Improvements :
==============

View File

@ -278,34 +278,35 @@
if($invoices !== FALSE) {
foreach($invoices as $invoice) {
if($invoice->getBuyer() == $_GET['user_id']) {
$invoice->setBuyer(0);
$invoice->save();
$invoice->delete();
}
if($invoice->getUsersIn()->inUsersIn($_GET['user_id'])) {
$users_in = $invoice->getUsersIn()->get();
$users_in[0] = $users_in[$_GET['user_id']];
unset($users_in[$_GET['user_id']]);
if(empty($users_in))
$invoice->delete();
else {
$invoice->setUsersIn($users_in);
$invoice->save();
}
}
}
}
// Update paybacks
$paybacks = new Payback();
$paybacks = $paybacks->load(array('from_user'=>(int) $_GET['user_id']));
if($paybacks !== FALSE) {
foreach($paybacks as $payback) {
$payback->setFrom(0);
$payback->save();
$payback->delete();
}
}
$paybacks = new Payback();
$paybacks = $paybacks->load(array('to_user'=>(int) $_GET['user_id']));
if($paybacks !== FALSE) {
foreach($paybacks as $payback) {
$payback->setTo(0);
$payback->save();
$payback->delete();
}
}