aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CREDITS.txt2
-rw-r--r--images/cancel.orig.pngbin0 -> 44388 bytes
-rw-r--r--images/cancel.pngbin0 -> 10838 bytes
-rw-r--r--images/unavailable.orig.pngbin0 -> 69262 bytes
-rw-r--r--images/unavailable.pngbin0 -> 12484 bytes
-rw-r--r--muamba-widget.tpl.php42
-rw-r--r--muamba.misc.inc2
-rw-r--r--muamba.module7
-rw-r--r--muamba.theme.inc24
9 files changed, 62 insertions, 15 deletions
diff --git a/CREDITS.txt b/CREDITS.txt
index ee91239..85e71bd 100644
--- a/CREDITS.txt
+++ b/CREDITS.txt
@@ -17,3 +17,5 @@ http://www.openclipart.org/detail/57079/recover-symbol-by-doctormo
http://www.openclipart.org/detail/147421/home-by-netalloy-147421
http://www.openclipart.org/detail/107473/folder-inbox-by-anonymous
http://www.openclipart.org/detail/160369/eshop-by-lbear
+http://www.openclipart.org/detail/110/red-square-error-warning-icon-by-molumen
+http://www.openclipart.org/detail/57745/denied-by-chovynz
diff --git a/images/cancel.orig.png b/images/cancel.orig.png
new file mode 100644
index 0000000..c65dc65
--- /dev/null
+++ b/images/cancel.orig.png
Binary files differ
diff --git a/images/cancel.png b/images/cancel.png
new file mode 100644
index 0000000..e6ec59d
--- /dev/null
+++ b/images/cancel.png
Binary files differ
diff --git a/images/unavailable.orig.png b/images/unavailable.orig.png
new file mode 100644
index 0000000..945bcfc
--- /dev/null
+++ b/images/unavailable.orig.png
Binary files differ
diff --git a/images/unavailable.png b/images/unavailable.png
new file mode 100644
index 0000000..7b4f6d4
--- /dev/null
+++ b/images/unavailable.png
Binary files differ
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;
diff --git a/muamba.misc.inc b/muamba.misc.inc
index b5c1111..70aa598 100644
--- a/muamba.misc.inc
+++ b/muamba.misc.inc
@@ -76,7 +76,7 @@ function muamba_actions($code = NULL) {
MUAMBA_LOST => 'lost',
);
- if ($code == NULL) {
+ if ($code === NULL) {
return $status;
}
diff --git a/muamba.module b/muamba.module
index fcd6565..b530bb9 100644
--- a/muamba.module
+++ b/muamba.module
@@ -198,6 +198,13 @@ function muamba_theme($existing, $type, $theme, $path) {
),
'file' => 'muamba.theme.inc',
),
+ 'muamba_widget_icon' => array(
+ 'variables' => array(
+ 'status' => MUAMBA_REQUESTED,
+ 'id' => NULL,
+ ),
+ 'file' => 'muamba.theme.inc',
+ ),
);
}
diff --git a/muamba.theme.inc b/muamba.theme.inc
index 4e201f7..a51f6f6 100644
--- a/muamba.theme.inc
+++ b/muamba.theme.inc
@@ -134,3 +134,27 @@ function theme_muamba_recovered_message($transaction = NULL) {
function theme_muamba_lost_message($transaction = NULL) {
return t('I declare that my item is lost');
}
+
+/**
+ * Theme callback.
+ */
+function theme_muamba_widget_icon($variables) {
+ $status = $variables['status'];
+ $id = $variables['id'];
+ $path = drupal_get_path('module', 'muamba');
+ $action = muamba_actions($status);
+ $image = $path .'/images/'. $action .'.png';
+ $title = ucfirst($action) .' item';
+
+ $icon = theme('image',
+ array(
+ 'path' => $image,
+ 'alt' => t($title),
+ 'title' => t($title),
+ )
+ );
+
+ $output = l($icon, 'muamba/'. $action .'/'. $id, array('html' => TRUE));
+
+ return $output;
+}