diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2011-11-06 20:46:47 -0200 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2011-11-06 20:46:47 -0200 |
commit | 26806c934827c9f58feccb27cc8b6f42d829f38c (patch) | |
tree | 9ad38fba5b4e029caf655a1af3e8a34505cb9cab | |
parent | d60f3e3eb1563ec388b2c4ee15499627d8c0265a (diff) | |
download | muamba-26806c934827c9f58feccb27cc8b6f42d829f38c.tar.gz muamba-26806c934827c9f58feccb27cc8b6f42d829f38c.tar.bz2 |
Fixing #34
-rw-r--r-- | muamba-widget.tpl.php | 49 | ||||
-rw-r--r-- | muamba.module | 27 |
2 files changed, 47 insertions, 29 deletions
diff --git a/muamba-widget.tpl.php b/muamba-widget.tpl.php index 1c79606..09b43bc 100644 --- a/muamba-widget.tpl.php +++ b/muamba-widget.tpl.php @@ -16,31 +16,38 @@ drupal_add_css($path .'/muamba.css'); $content = ''; $output = ''; -if (!user_is_logged_in()) { - print t('You have to be logged in to be able to ask for this item.'); - return; -} -elseif (empty($transaction) && $node->uid != $user->uid) { - $content .= theme('muamba_widget_icon', array('status' => MUAMBA_REQUESTED, 'id' => $node->nid)); -} -elseif ($transaction['uid'] == $user->uid) { - foreach (muamba_actions_available('sent', $transaction['status']) as $action) { - $content .= theme('muamba_widget_icon', array('status' => $action, 'id' => $transaction['mid'])); +if ($node->uid != $user->uid) { + if (!user_is_logged_in()) { + print t('You have to be logged in to be able to ask for this item.'); + return; } -} -elseif ($transaction['owner'] == $user->uid) { - foreach (muamba_actions_available('received', $transaction['status']) as $action) { - $content .= theme('muamba_widget_icon', array('status' => $action, 'id' => $transaction['mid'])); + elseif (!$available && $transactions['uid'] != $user->uid) { + $content .= theme('image', + array( + 'path' => $path .'/images/unavailable.png', + 'alt' => t('Item unavailable'), + 'title' => t('Item unavailable'), + ) + ); + } + elseif ($transactions['uid'] == $user->uid) { + foreach (muamba_actions_available('sent', $transactions['status']) as $action) { + $content .= theme('muamba_widget_icon', array('status' => $action, 'id' => $transactions['mid'])); + } + } + else { + $content .= theme('muamba_widget_icon', array('status' => MUAMBA_REQUESTED, 'id' => $node->nid)); } } else { - $content .= theme('image', - array( - 'path' => $path .'/images/unavailable.png', - 'alt' => t('Item unavailable'), - 'title' => t('Item unavailable'), - ) - ); + foreach ($transactions as $transaction) { + $requester = user_load($transaction['uid']); + $content .= t('Request from @name.', array('@name' => $requester->name)); + $content .= '<br />'; + foreach (muamba_actions_available('received', $transaction['status']) as $action) { + $content .= theme('muamba_widget_icon', array('status' => $action, 'id' => $transaction['mid'])); + } + } } if (!empty($content)) { diff --git a/muamba.module b/muamba.module index 1e010dc..66e0b52 100644 --- a/muamba.module +++ b/muamba.module @@ -107,8 +107,6 @@ function muamba_menu() { /** * Implements hook_node_view() - * - * @todo */ function muamba_node_view($node, $view_mode, $langcode) { global $user; @@ -120,15 +118,27 @@ function muamba_node_view($node, $view_mode, $langcode) { if ($view_mode == 'full') { if ($node->uid != $user->uid) { - $transaction = muamba_current_transactions($node, $user->uid); + $transactions = muamba_current_transactions($node, $user->uid); + $available = muamba_check_availability($node->nid); $node->content['muamba'] = array( - '#markup' => theme('muamba_widget', array('node' => $node, 'transaction' => $transaction)), + '#markup' => theme('muamba_widget', array( + 'node' => $node, + 'transactions' => $transactions, + 'available' => $available, + + )), '#weight' => 100, ); } else { - // @todo: muamba_widget is not working anymore for item owners, make a custom - // widget just for handling multiple requests, see #34 + $transactions = muamba_current_transactions($node); + $node->content['muamba'] = array( + '#markup' => theme('muamba_widget', array( + 'node' => $node, + 'transactions' => $transactions + )), + '#weight' => 100, + ); } return $node; @@ -143,8 +153,9 @@ function muamba_theme($existing, $type, $theme, $path) { 'muamba_widget' => array( 'template' => 'muamba-widget', 'variables' => array( - 'node' => NULL, - 'transaction' => NULL, + 'node' => NULL, + 'transactions' => NULL, + 'available' => NULL, ), ), 'muamba_powered' => array( |