aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2011-11-09 14:23:04 -0200
committerSilvio Rhatto <rhatto@riseup.net>2011-11-09 14:23:04 -0200
commit61c12bd9539cd0d74f43bc74414f79609621b397 (patch)
treec95cf6f5815378985fb52d1dc64eb24f86ec60b2
parent79a1634a5b5a2b14d0d487a8d5d4a9d305aba6ce (diff)
downloadmuamba-61c12bd9539cd0d74f43bc74414f79609621b397.tar.gz
muamba-61c12bd9539cd0d74f43bc74414f79609621b397.tar.bz2
Showing muamba widget at muamba_privatemsg_view_alter()
-rw-r--r--muamba.db.inc13
-rw-r--r--muamba.module23
-rw-r--r--muamba.theme.inc4
3 files changed, 31 insertions, 9 deletions
diff --git a/muamba.db.inc b/muamba.db.inc
index ff682f5..773e65e 100644
--- a/muamba.db.inc
+++ b/muamba.db.inc
@@ -82,16 +82,23 @@ function muamba_get_transactions($uid, $type = 'sent', $status = NULL) {
/**
* Get a single transaction.
*
- * @param $mid
+ * @param $id
* Transaction id.
*
+ * @param $index
+ * Index (mid or thread_id).
+ *
* @return
* Transaction data.
*/
-function muamba_get_transaction($mid) {
+function muamba_get_transaction($id, $index = 'mid') {
+ if ($index != 'mid' && $index != 'thread_id') {
+ return;
+ }
+
$query = db_select('muamba', 'm');
$query->fields('m', array('mid', 'nid', 'uid', 'owner', 'status', 'thread_id'));
- $query->condition('m.mid', (int) $mid, '=');
+ $query->condition('m.'. $index, (int) $id, '=');
$rows = array();
$results = $query->execute()->fetchAll();
diff --git a/muamba.module b/muamba.module
index 3aa94bc..b03dea8 100644
--- a/muamba.module
+++ b/muamba.module
@@ -249,12 +249,27 @@ function muamba_block_view($delta = '') {
/**
* Implements hook_privatemsg_view_alter()
- *
- * @todo
*/
function muamba_privatemsg_view_alter(&$content) {
- $bar = 'TODO: Add here request management bar.';
- $content['participants']['#markup'] = $bar . $content['participants']['#markup'];
+ $thread = $content['#thread']['thread_id'];
+ $transaction = muamba_get_transaction($thread, 'thread_id');
+
+ if (!empty($transaction)) {
+ global $user;
+
+ $node = node_load($transaction['nid']);
+ $available = muamba_check_availability($node->nid);
+ $widget = ($node->uid == $user->uid) ? 'owner' : 'requester';
+
+ $bar = theme('muamba_widget_'. $widget, array(
+ 'node' => $node,
+ 'transaction' => $transaction,
+ 'available' => $available,
+ 'size' => 'big',
+ ));
+
+ $content['participants']['#markup'] = $bar . $content['participants']['#markup'];
+ }
}
/**
diff --git a/muamba.theme.inc b/muamba.theme.inc
index 29029dc..9707a0f 100644
--- a/muamba.theme.inc
+++ b/muamba.theme.inc
@@ -170,8 +170,8 @@ function theme_muamba_widget_owner($variables) {
$requester = user_load($transaction['uid']);
if ($size != 'small') {
- $content .= t('Request from @name.', array('@name' => $requester->name));
- $content .= '<br />';
+ $content .= t('Request from @name.', array('@name' => $requester->name));
+ $content .= '<br />';
}
foreach (muamba_actions_available('received', $transaction['status']) as $action) {