public function UserpointsTransactionController::save in User Points 7.2
Overrides EntityAPIController::save().
It is not permitted to update a approved or denied transaction except marking it as expird. Any attemt to change a property of such a transaction will result in an immediate exception.
Overrides EntityAPIController::save
File
- ./
userpoints.transaction.inc, line 1206 - Contains the UserpointsTransaction and related classes.
Class
- UserpointsTransactionController
- Userpoints transaction controller.
Code
public function save($entity, DatabaseTransaction $transaction = NULL) {
// Prevent saving when any of the required properties are missing.
if (!$entity
->getPoints() || !$entity
->getUid() || !$entity
->getOperation()) {
$entity
->abort();
throw new UserpointsTransactionIncompleteException();
}
// Call the before hook to allow modules to change and deny this.
// @todo: Rename this hook?
module_invoke_all('userpoints_transaction_before', $entity);
// Abort if the transaction has been denied.
if ($entity
->isDenied()) {
$entity
->abort();
return FALSE;
}
$return = parent::save($entity, $transaction);
// Update totals if the transaction is approved and not expired.
if ($entity
->isApproved() && !$entity
->isExpired()) {
$this
->updateTotals($entity->tid, $entity->uid, $entity->points);
}
// Display a message unless disabled or no message exists.
if ($entity
->getDisplay() && ($message = $entity
->getMessage())) {
drupal_set_message($message);
}
// Reset original status to current one
$entity
->resetOriginalStatus();
return $return;
}