diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2011-10-06 17:56:15 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2011-10-06 17:56:15 -0300 |
commit | 3cbd7b81f1f1ddcfdae79c1b290df071e7f2d52d (patch) | |
tree | 009c137e1f2b20d439dcdda693d0ea4e80730ef1 | |
parent | c0f1a1f2c04f84ac4e5b2d1c86e0663de886bbf2 (diff) | |
download | muamba-3cbd7b81f1f1ddcfdae79c1b290df071e7f2d52d.tar.gz muamba-3cbd7b81f1f1ddcfdae79c1b290df071e7f2d52d.tar.bz2 |
Cleanup
-rw-r--r-- | muamba.business.inc | 42 | ||||
-rw-r--r-- | muamba.db.inc | 18 |
2 files changed, 24 insertions, 36 deletions
diff --git a/muamba.business.inc b/muamba.business.inc index 8ca7648..2ec5644 100644 --- a/muamba.business.inc +++ b/muamba.business.inc @@ -191,12 +191,7 @@ function muamba_accept($mid) { } // Update database - $update = db_update('muamba') - ->fields(array( - 'status' => MUAMBA_ACCEPTED, - )) - ->condition('mid', $mid, '=') - ->execute(); + muamba_update_status($mid, MUAMBA_ACCEPTED); // Notify item owner $message = theme('muamba_accept_message', array('transaction' => $transaction)); @@ -228,12 +223,7 @@ function muamba_reject($mid) { } // Update database - $update = db_update('muamba') - ->fields(array( - 'status' => MUAMBA_REJECTED, - )) - ->condition('mid', $mid, '=') - ->execute(); + muamba_update_status($mid, MUAMBA_REJECTED); // Notify item owner $message = theme('muamba_reject_message', array('transaction' => $transaction)); @@ -265,12 +255,7 @@ function muamba_cancel($mid) { } // Update database - $update = db_update('muamba') - ->fields(array( - 'status' => MUAMBA_CANCELLED, - )) - ->condition('mid', $mid, '=') - ->execute(); + muamba_update_status($mid, MUAMBA_CANCELLED); // Notify item owner $message = theme('muamba_cancel_message', array('transaction' => $transaction)); @@ -303,12 +288,7 @@ function muamba_return($mid) { } // Update database - $update = db_update('muamba') - ->fields(array( - 'status' => MUAMBA_RETURNED, - )) - ->condition('mid', $mid, '=') - ->execute(); + muamba_update_status($mid, MUAMBA_RETURNED); // Notify item owner $message = theme('muamba_return_message', array('transaction' => $transaction)); @@ -342,12 +322,7 @@ function muamba_recover($mid) { } // Update database - $update = db_update('muamba') - ->fields(array( - 'status' => MUAMBA_RECOVERED, - )) - ->condition('mid', $mid, '=') - ->execute(); + muamba_update_status($mid, MUAMBA_RECOVERED); // Notify item owner $message = theme('muamba_recover_message', array('transaction' => $transaction)); @@ -380,12 +355,7 @@ function muamba_lost($mid) { } // Update database - $update = db_update('muamba') - ->fields(array( - 'status' => MUAMBA_LOST, - )) - ->condition('mid', $mid, '=') - ->execute(); + muamba_update_status($mid, MUAMBA_LOST); // Notify item owner $message = theme('muamba_lost_message', array('transaction' => $transaction)); diff --git a/muamba.db.inc b/muamba.db.inc index 6c2f74d..3650e08 100644 --- a/muamba.db.inc +++ b/muamba.db.inc @@ -167,3 +167,21 @@ function muamba_check_availability($data) { return FALSE; } + +/** + * Update a transaction status. + * + * @param $mid + * Transaction id. + * + * @param $status + * New status. + */ +function muamba_update_status($mid, $status) { + $update = db_update('muamba') + ->fields(array( + 'status' => $status, + )) + ->condition('mid', $mid, '=') + ->execute(); +} |