diff options
Diffstat (limited to 'muamba.handlers.inc')
-rw-r--r-- | muamba.handlers.inc | 36 |
1 files changed, 12 insertions, 24 deletions
diff --git a/muamba.handlers.inc b/muamba.handlers.inc index f6c0982..4f75d94 100644 --- a/muamba.handlers.inc +++ b/muamba.handlers.inc @@ -49,6 +49,10 @@ 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); @@ -72,9 +76,6 @@ class views_handler_field_muamba_available extends views_handler_field { /** * Field handler for muamba transaction status. - * - * @todo - * Show widget also in a transaction view. */ class views_handler_field_muamba_actions extends views_handler_field { /** @@ -95,30 +96,17 @@ class views_handler_field_muamba_actions extends views_handler_field { if (isset($values->mid)) { $transaction = muamba_get_transaction($values->mid); - // @todo - return 'TODO'; - } - elseif (isset($values->nid)) { - $available = muamba_check_availability($values->nid); - $node = node_load($values->nid); - - // Check if widget can be shown - if ($node->type != MUAMBA_NODE_TYPE || !muamba_has_request_access($node)) { - return; - } - if ($node->uid != $user->uid) { - $transactions = muamba_current_transactions($values->nid, $user->uid); + if ($transaction['owner'] == $user->uid) { + return theme('muamba_widget_owner', array('transaction' => $transaction)); } - else { - $transactions = muamba_current_transactions($values->nid); + elseif ($transaction['uid'] == $user->uid) { + return theme('muamba_widget_requester', array('transaction' => $transactions)); } - - return theme('muamba_widget', array( - 'node' => $node, - 'transactions' => $transactions, - 'available' => $available, - )); + } + elseif (isset($values->nid)) { + $node = node_load($values->nid); + return muamba_widget($node); } } } |