]> gitweb.fluxo.info Git - drupal/muamba.git/commitdiff
Do not reject all other requests
authorSilvio Rhatto <rhatto@riseup.net>
Mon, 14 Nov 2011 20:47:01 +0000 (18:47 -0200)
committerSilvio Rhatto <rhatto@riseup.net>
Mon, 14 Nov 2011 20:47:01 +0000 (18:47 -0200)
muamba.business.inc
muamba.db.inc
muamba.handlers.inc

index 5a29c9e48e2c3949adb817dfb676958e869f8662..5d853a70c874536edcf2b1484ae4b12f1ee1603d 100644 (file)
@@ -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 {
index 773e65e99e58ecb68290103f0c343a075fd0150f..f06e3be0edd8a37445a065f4aac2be72a57b2b51 100644 (file)
@@ -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.
  *
index 33c312aef1554d0dda784aa59605e03e7c8d090a..87d0dd89548e676180c731b985a764120f1fc5e8 100644 (file)
@@ -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;