aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2011-11-08 20:20:14 -0200
committerSilvio Rhatto <rhatto@riseup.net>2011-11-08 20:20:14 -0200
commitf8a758f6d8b460a4c22a7aa8835ffa57708e800f (patch)
tree1f3bc8d44ad0896dedce3720f8fdc5ccd0b02b3c
parent645c6115b04a66d22c6f26695e11deb8eecb2573 (diff)
downloadmuamba-f8a758f6d8b460a4c22a7aa8835ffa57708e800f.tar.gz
muamba-f8a758f6d8b460a4c22a7aa8835ffa57708e800f.tar.bz2
Adding muamba_availability_info()
-rw-r--r--muamba.business.inc37
-rw-r--r--muamba.handlers.inc25
2 files changed, 42 insertions, 20 deletions
diff --git a/muamba.business.inc b/muamba.business.inc
index 56a1237..d7de834 100644
--- a/muamba.business.inc
+++ b/muamba.business.inc
@@ -50,6 +50,12 @@ function muamba_actions_available($type = 'sent', $status) {
);
break;
+ case MUAMBA_REJECTED:
+ $actions = array(
+ MUAMBA_REQUESTED,
+ );
+ break;
+
default:
$actions = array();
}
@@ -399,3 +405,34 @@ function muamba_widget($node, $size = 'small') {
'size' => $size,
));
}
+
+/**
+ * Return availability information.
+ *
+ * @param $nid
+ * Muamba node id.
+ *
+ * @return
+ * Human-readable availability information.
+ */
+function muamba_availability_info($nid) {
+ global $user;
+ $available = muamba_check_availability($nid);
+ $node = node_load($nid);
+
+ if ($node->uid == $user->uid) {
+ return t('You own the item');
+ }
+ elseif (!$available) {
+ $transaction = muamba_current_transactions($nid, $user->uid);
+
+ if (isset($transaction['uid']) && $transaction['uid'] == $user->uid) {
+ return t('You requested');
+ }
+ else {
+ return t('No');
+ }
+ }
+
+ return t('Yes');
+}
diff --git a/muamba.handlers.inc b/muamba.handlers.inc
index 2745130..06c80b1 100644
--- a/muamba.handlers.inc
+++ b/muamba.handlers.inc
@@ -47,28 +47,13 @@ class views_handler_field_muamba_available extends views_handler_field {
* Renders the field.
*/
function render($values) {
- if (!isset($values->nid)) {
- return;
- }
-
- global $user;
- $available = muamba_check_availability($values->nid);
-
- if ($values->users_node_uid == $user->uid) {
- return t('You own the item');
+ if (isset($values->mid)) {
+ $transaction = muamba_get_transaction($values->mid);
+ return muamba_availability_info($transaction['nid']);
}
- elseif (!$available) {
- $transaction = muamba_current_transactions($values->nid, $user->uid);
-
- if (isset($transaction['uid']) && $transaction['uid'] == $user->uid) {
- return t('You requested');
- }
- else {
- return t('No');
- }
+ elseif (isset($values->nid)) {
+ return muamba_availability_info($values->nid);
}
-
- return t('Yes');
}
}