public function store()
{
global $hist, $emitter;
+ $event = null;
try {
$values = array();
}
$success = true;
- $emitter->emit('member.add', $this);
+ $event = 'member.add';
} else {
$hist->add(_T("Fail to add new member."));
throw new \Exception(
}
$success = true;
- $emitter->emit('member.edit', $this);
+ $event = 'member.edit';
}
//dynamic fields
$success = $this->dynamicsStore();
}
+ //send event at the end of process, once all has been stored
+ if ($event !== null) {
+ $emitter->emit($event, $this);
+ }
return $success;
} catch (\Exception $e) {
Analog::log(
{
global $hist, $emitter;
+ $event = null;
+
if (count($this->errors) > 0) {
throw new \RuntimeException(
'Existing errors prevents storing contribution: ' .
Adherent::getSName($this->zdb, $this->_member)
);
$success = true;
-
- $emitter->emit('contribution.add', $this);
+ $event = 'contribution.add';
} else {
$hist->add(_T("Fail to add new contribution."));
throw new \Exception(
);
}
$success = true;
-
- $emitter->emit('contribution.edit', $this);
+ $event = 'contribution.edit';
}
//update deadline
if ($this->isCotis()) {
$this->zdb->connection->commit();
$this->_orig_amount = $this->_amount;
+
+ //send event at the end of process, once all has been stored
+ if ($event !== null) {
+ $emitter->emit($event, $this);
+ }
+
return true;
} catch (\Exception $e) {
$this->zdb->connection->rollBack();
{
global $emitter;
+ $event = null;
+
try {
if ($transaction) {
$this->zdb->connection->beginTransaction();
if ($transaction) {
$this->zdb->connection->commit();
}
+
$emitter->emit('transaction.remove', $this);
return true;
} catch (\Exception $e) {
Adherent::getSName($this->zdb, $this->_member)
);
$success = true;
-
- $emitter->emit('transaction.add', $this);
+ $event = 'transaction.add';
} else {
$hist->add(_T("Fail to add new transaction."));
throw new \Exception(
);
}
$success = true;
-
- $emitter->emit('transaction.edit', $this);
+ $event = 'transaction.edit';
}
//dynamic fields
}
$this->zdb->connection->commit();
+
+ //send event at the end of process, once all has been stored
+ if ($event !== null) {
+ $emitter->emit($event, $this);
+ }
+
return true;
} catch (\Exception $e) {
$this->zdb->connection->rollBack();
{
global $zdb, $hist, $emitter;
+ $processed = array();
$list = array();
if (is_numeric($ids)) {
//we've got only one identifier
}
}
- $emitter->emit('member.remove', [
+ $processed[] = [
'id_adh' => $member->id_adh,
'nom_adh' => $member->nom_adh,
'prenom_adh' => $member->prenom_adh,
'email_adh' => $member->email_adh
- ]);
+ ];
}
//delete contributions
//commit all changes
$zdb->connection->commit();
+ foreach ($processed as $p) {
+ $emitter->emit('member.remove', $p);
+ }
+
//add an history entry
$hist->add(
_T("Delete members cards, transactions and dues"),