diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2011-11-06 21:23:10 -0200 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2011-11-06 21:23:10 -0200 |
commit | afa74968958b5dd54c7aadf737b159faa91af84b (patch) | |
tree | ccb5a5e11d8588e0099043cf8f8d8898aaf7af1b | |
parent | 26806c934827c9f58feccb27cc8b6f42d829f38c (diff) | |
download | muamba-afa74968958b5dd54c7aadf737b159faa91af84b.tar.gz muamba-afa74968958b5dd54c7aadf737b159faa91af84b.tar.bz2 |
Polishing views_handler_field_muamba_available()
-rw-r--r-- | muamba.handlers.inc | 22 |
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'); } } |