aboutsummaryrefslogtreecommitdiff
path: root/muamba-widget.tpl.php
diff options
context:
space:
mode:
Diffstat (limited to 'muamba-widget.tpl.php')
-rw-r--r--muamba-widget.tpl.php42
1 files changed, 28 insertions, 14 deletions
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 = '<div class="muamba-widget">';
-$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 .= '</div>';
print $output;