From fe5d67700ceb54bdc951dbd1f5f98e9dcae89855 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Thu, 6 Oct 2011 22:41:35 -0300 Subject: Widget updates --- muamba-widget.tpl.php | 42 ++++++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 14 deletions(-) (limited to 'muamba-widget.tpl.php') diff --git a/muamba-widget.tpl.php b/muamba-widget.tpl.php index 3caf614..6923de8 100644 --- a/muamba-widget.tpl.php +++ b/muamba-widget.tpl.php @@ -3,27 +3,41 @@ /** * @file * Template for displaying the muamba widget. - * - * @todo: use $transaction - * Show item status: can it be requested? - * Is this item already requested? */ -// Add javascript and CSS files +// User and path $path = drupal_get_path('module', 'muamba'); +global $user; + +// Add javascript and CSS files drupal_add_js($path .'/muamba.js'); drupal_add_css($path .'/muamba.css'); -$icon = theme('image', - array( - 'path' => $path .'/images/basket.png', - 'alt' => t('Request item'), - 'title' => t('Request item'), - ) -); - $output = '
'; -$output .= l($icon, 'muamba/request/'. $nid, array('html' => TRUE)); + +if (empty($transaction)) { + $output .= theme('muamba_widget_icon', array('status' => MUAMBA_REQUESTED, 'id' => $nid)); +} +elseif ($transaction['uid'] == $user->uid) { + foreach (muamba_actions_available('sent', $transaction['status']) as $action) { + $output .= theme('muamba_widget_icon', array('status' => $action, 'id' => $transaction['mid'])); + } +} +elseif ($transaction['owner'] == $user->uid) { + foreach (muamba_actions_available('received', $transcation['status']) as $action) { + $output .= theme('muamba_widget_icon', array('status' => $action, 'id' => $transaction['mid'])); + } +} +else { + $icon = theme('image', + array( + 'path' => $path .'/images/unavailable.png', + 'alt' => t('Item unavailable'), + 'title' => t('Item unavailable'), + ) + ); +} + $output .= '
'; print $output; -- cgit v1.2.3