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
|
* cf TODO in files
|
||||||
* French template
|
* French template
|
||||||
* Favicon
|
* Favicon
|
||||||
|
* Take account of paybacks in balance table
|
||||||
|
* Confirm all paybacks
|
||||||
|
|
||||||
Improvements :
|
Improvements :
|
||||||
==============
|
==============
|
||||||
|
19
index.php
19
index.php
@ -278,16 +278,18 @@
|
|||||||
if($invoices !== FALSE) {
|
if($invoices !== FALSE) {
|
||||||
foreach($invoices as $invoice) {
|
foreach($invoices as $invoice) {
|
||||||
if($invoice->getBuyer() == $_GET['user_id']) {
|
if($invoice->getBuyer() == $_GET['user_id']) {
|
||||||
$invoice->setBuyer(0);
|
$invoice->delete();
|
||||||
$invoice->save();
|
|
||||||
}
|
}
|
||||||
if($invoice->getUsersIn()->inUsersIn($_GET['user_id'])) {
|
if($invoice->getUsersIn()->inUsersIn($_GET['user_id'])) {
|
||||||
$users_in = $invoice->getUsersIn()->get();
|
$users_in = $invoice->getUsersIn()->get();
|
||||||
$users_in[0] = $users_in[$_GET['user_id']];
|
|
||||||
unset($users_in[$_GET['user_id']]);
|
unset($users_in[$_GET['user_id']]);
|
||||||
|
|
||||||
$invoice->setUsersIn($users_in);
|
if(empty($users_in))
|
||||||
$invoice->save();
|
$invoice->delete();
|
||||||
|
else {
|
||||||
|
$invoice->setUsersIn($users_in);
|
||||||
|
$invoice->save();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -297,15 +299,14 @@
|
|||||||
$paybacks = $paybacks->load(array('from_user'=>(int) $_GET['user_id']));
|
$paybacks = $paybacks->load(array('from_user'=>(int) $_GET['user_id']));
|
||||||
if($paybacks !== FALSE) {
|
if($paybacks !== FALSE) {
|
||||||
foreach($paybacks as $payback) {
|
foreach($paybacks as $payback) {
|
||||||
$payback->setFrom(0);
|
$payback->delete();
|
||||||
$payback->save();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$paybacks = new Payback();
|
||||||
$paybacks = $paybacks->load(array('to_user'=>(int) $_GET['user_id']));
|
$paybacks = $paybacks->load(array('to_user'=>(int) $_GET['user_id']));
|
||||||
if($paybacks !== FALSE) {
|
if($paybacks !== FALSE) {
|
||||||
foreach($paybacks as $payback) {
|
foreach($paybacks as $payback) {
|
||||||
$payback->setTo(0);
|
$payback->delete();
|
||||||
$payback->save();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user