aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2011-11-09 11:36:03 -0200
committerSilvio Rhatto <rhatto@riseup.net>2011-11-09 11:36:03 -0200
commitc594011b5e4a5c72bd3dbf8ab4580ee7f0efcd20 (patch)
tree0232cd3a07e692d4a30d16ee02a9d1cf052612b6
parent9b01ff78b704d3a6f922769fe1dc2f0cff58baa5 (diff)
downloadmuamba-c594011b5e4a5c72bd3dbf8ab4580ee7f0efcd20.tar.gz
muamba-c594011b5e4a5c72bd3dbf8ab4580ee7f0efcd20.tar.bz2
Adding another case to muamba_availability_info()
-rw-r--r--muamba.business.inc30
1 files changed, 26 insertions, 4 deletions
diff --git a/muamba.business.inc b/muamba.business.inc
index 859c091..adf5bd6 100644
--- a/muamba.business.inc
+++ b/muamba.business.inc
@@ -181,6 +181,9 @@ function muamba_request($nid) {
*
* @param $mid
* Transaction id.
+ *
+ * @todo
+ * Reject all other existing requests on the item.
*/
function muamba_accept($mid) {
global $user;
@@ -417,14 +420,33 @@ function muamba_widget($node, $size = 'small') {
*/
function muamba_availability_info($nid) {
global $user;
- $available = muamba_check_availability($nid);
- $node = node_load($nid);
- $transaction = muamba_current_transactions($nid, $user->uid);
+ $available = muamba_check_availability($nid);
+ $node = node_load($nid);
if ($node->uid == $user->uid) {
- return t('You own the item');
+ $transactions = muamba_current_transactions($nid);
+ $transaction = $transactions[0];
+
+ if (!empty($transaction)) {
+ 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,
+ ));
+ }
+ }
+ else {
+ return t('Yes');
+ }
}
else {
+ $transaction = muamba_current_transactions($nid, $user->uid);
+
if (!$available) {
if (isset($transaction['uid']) && $transaction['uid'] == $user->uid) {
return t('You requested, status is @status', array(