Safe deletion of users
This commit is contained in:
parent
2fc4311c54
commit
1a9acc5ece
2
TODO
2
TODO
@ -5,6 +5,8 @@
|
||||
* cf TODO in files
|
||||
* French template
|
||||
* Favicon
|
||||
* Take account of paybacks in balance table
|
||||
* Confirm all paybacks
|
||||
|
||||
Improvements :
|
||||
==============
|
||||
|
19
index.php
19
index.php
@ -278,16 +278,18 @@
|
||||
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']]);
|
||||
|
||||
$invoice->setUsersIn($users_in);
|
||||
$invoice->save();
|
||||
if(empty($users_in))
|
||||
$invoice->delete();
|
||||
else {
|
||||
$invoice->setUsersIn($users_in);
|
||||
$invoice->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -297,15 +299,14 @@
|
||||
$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();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user