aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--muamba.business.inc28
-rw-r--r--muamba.db.inc2
-rw-r--r--muamba.handlers.inc3
3 files changed, 19 insertions, 14 deletions
diff --git a/muamba.business.inc b/muamba.business.inc
index 5a29c9e..5d853a7 100644
--- a/muamba.business.inc
+++ b/muamba.business.inc
@@ -183,8 +183,8 @@ function muamba_request($nid) {
* Transaction id.
*
* @todo
- * Do not reject all other requests so postponing
- * becomes a feature.
+ * Make rejection of all other pending requests
+ * a configuration option.
*/
function muamba_accept($mid) {
global $user;
@@ -209,8 +209,8 @@ function muamba_accept($mid) {
$message = theme('muamba_accept_message', array('transaction' => $transaction));
$reply = privatemsg_reply($transaction['thread_id'], $message);
- // Reject all other pending requests
- muamba_reject_all($node);
+ // Optionally reject all other pending requests
+ //muamba_reject_all($node);
return t('Accepted item request.');
}
@@ -446,17 +446,23 @@ function muamba_availability_info($nid) {
$transaction = $transactions[0];
if (!empty($transaction)) {
- // TODO: what if there are more than one request?
+ // If the first transaction in the array of active transactions
+ // is a request, then the other ones will be as well.
if ($transaction['status'] == MUAMBA_REQUESTED) {
return t('Yes');
}
else {
- $requester = user_load($transaction['uid']);
-
- return t('No, @status to @user', array(
- '@status' => t(muamba_statuses($transaction['status'])),
- '@user' => $requester->name,
- ));
+ // Find the right requester
+ foreach ($transactions as $transaction) {
+ if ($transaction['status'] != MUAMBA_REQUESTED) {
+ $requester = user_load($transaction['uid']);
+
+ return t('No, @status to @user', array(
+ '@status' => t(muamba_statuses($transaction['status'])),
+ '@user' => $requester->name,
+ ));
+ }
+ }
}
}
else {
diff --git a/muamba.db.inc b/muamba.db.inc
index 773e65e..f06e3be 100644
--- a/muamba.db.inc
+++ b/muamba.db.inc
@@ -114,7 +114,7 @@ function muamba_get_transaction($id, $index = 'mid') {
}
/**
- * Get current transaction for an item. Note that there might
+ * Get current transactions for an item. Note that there might
* be more than one active transaction for a given item if they
* all are in the "requested" state.
*
diff --git a/muamba.handlers.inc b/muamba.handlers.inc
index 33c312a..87d0dd8 100644
--- a/muamba.handlers.inc
+++ b/muamba.handlers.inc
@@ -78,8 +78,7 @@ class views_handler_field_muamba_actions extends views_handler_field {
if (isset($values->mid)) {
// We should point to the current transaction.
$old = muamba_get_transaction($values->mid);
- $node = $old['nid'];
- $transaction = muamba_current_transactions($node, $user->uid);
+ $transaction = muamba_current_transactions($old['nid'], $old['uid']);
if (empty($transaction)) {
return;