aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2011-11-06 22:01:21 -0200
committerSilvio Rhatto <rhatto@riseup.net>2011-11-06 22:01:21 -0200
commitc205ae2d3a8eafcd8a07d2f0bcac1b2ea48a6a0f (patch)
treeadd5494bea847a401da29a33c715e0493456fc8b
parentafa74968958b5dd54c7aadf737b159faa91af84b (diff)
downloadmuamba-c205ae2d3a8eafcd8a07d2f0bcac1b2ea48a6a0f.tar.gz
muamba-c205ae2d3a8eafcd8a07d2f0bcac1b2ea48a6a0f.tar.bz2
Partial views_handler_field_muamba_actions()
-rw-r--r--muamba.handlers.inc36
-rw-r--r--muamba.module32
2 files changed, 44 insertions, 24 deletions
diff --git a/muamba.handlers.inc b/muamba.handlers.inc
index 7a1c3f3..f6c0982 100644
--- a/muamba.handlers.inc
+++ b/muamba.handlers.inc
@@ -58,7 +58,7 @@ class views_handler_field_muamba_available extends views_handler_field {
elseif (!$available) {
$transaction = muamba_current_transactions($values->nid, $user->uid);
- if ($transaction['uid'] == $user->uid) {
+ if (isset($transaction['uid']) && $transaction['uid'] == $user->uid) {
return t('You requested');
}
else {
@@ -74,6 +74,7 @@ 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 {
/**
@@ -88,11 +89,36 @@ class views_handler_field_muamba_actions extends views_handler_field {
/**
* Renders the field.
- *
- * @todo
*/
function render($values) {
- dpm($values);
- return "TODO";
+ global $user;
+
+ 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);
+ }
+ else {
+ $transactions = muamba_current_transactions($values->nid);
+ }
+
+ return theme('muamba_widget', array(
+ 'node' => $node,
+ 'transactions' => $transactions,
+ 'available' => $available,
+ ));
+ }
}
}
diff --git a/muamba.module b/muamba.module
index 66e0b52..2b76df9 100644
--- a/muamba.module
+++ b/muamba.module
@@ -117,30 +117,24 @@ function muamba_node_view($node, $view_mode, $langcode) {
}
if ($view_mode == 'full') {
- if ($node->uid != $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,
- 'transactions' => $transactions,
- 'available' => $available,
+ $available = muamba_check_availability($node->nid);
- )),
- '#weight' => 100,
- );
+ if ($node->uid != $user->uid) {
+ $transactions = muamba_current_transactions($node, $user->uid);
}
else {
- $transactions = muamba_current_transactions($node);
- $node->content['muamba'] = array(
- '#markup' => theme('muamba_widget', array(
- 'node' => $node,
- 'transactions' => $transactions
- )),
- '#weight' => 100,
- );
+ $transactions = muamba_current_transactions($node);
}
+ $node->content['muamba'] = array(
+ '#markup' => theme('muamba_widget', array(
+ 'node' => $node,
+ 'transactions' => $transactions,
+ 'available' => $available,
+ )),
+ '#weight' => 100,
+ );
+
return $node;
}
}