aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2011-11-06 21:23:10 -0200
committerSilvio Rhatto <rhatto@riseup.net>2011-11-06 21:23:10 -0200
commitafa74968958b5dd54c7aadf737b159faa91af84b (patch)
treeccb5a5e11d8588e0099043cf8f8d8898aaf7af1b
parent26806c934827c9f58feccb27cc8b6f42d829f38c (diff)
downloadmuamba-afa74968958b5dd54c7aadf737b159faa91af84b.tar.gz
muamba-afa74968958b5dd54c7aadf737b159faa91af84b.tar.bz2
Polishing views_handler_field_muamba_available()
-rw-r--r--muamba.handlers.inc22
1 files changed, 16 insertions, 6 deletions
diff --git a/muamba.handlers.inc b/muamba.handlers.inc
index d634d6c..7a1c3f3 100644
--- a/muamba.handlers.inc
+++ b/muamba.handlers.inc
@@ -47,16 +47,26 @@ class views_handler_field_muamba_available extends views_handler_field {
/**
* Renders the field.
- *
- * @todo
- * Return also "Yes, you requested this item"
*/
function render($values) {
- if (muamba_check_availability($values->nid)) {
- return t('Yes');
+ global $user;
+ $available = muamba_check_availability($values->nid);
+
+ if ($values->users_node_uid == $user->uid) {
+ return t('You own the item');
+ }
+ elseif (!$available) {
+ $transaction = muamba_current_transactions($values->nid, $user->uid);
+
+ if ($transaction['uid'] == $user->uid) {
+ return t('You requested');
+ }
+ else {
+ return t('No');
+ }
}
- return t('No');
+ return t('Yes');
}
}