]> gitweb.fluxo.info Git - drupal/muamba.git/commitdiff
Enhanced message page
authorSilvio Rhatto <rhatto@riseup.net>
Tue, 22 Nov 2011 16:55:57 +0000 (14:55 -0200)
committerSilvio Rhatto <rhatto@riseup.net>
Tue, 22 Nov 2011 16:55:57 +0000 (14:55 -0200)
muamba.embed.inc [new file with mode: 0644]
muamba.module
muamba.theme.inc

diff --git a/muamba.embed.inc b/muamba.embed.inc
new file mode 100644 (file)
index 0000000..944dd2f
--- /dev/null
@@ -0,0 +1,45 @@
+<?php
+// $Id$
+
+/**
+ * @file
+ * Embed functions.
+ */
+
+/**
+ * Embeds a view.
+ *
+ * @param $viewname
+ *   Name of the view.
+ *
+ * @param $args
+ *   View arguments.
+ *
+ * @param $display
+ *   Display to use.
+ *
+ * @param $return
+ *   Whether to return a rendered view or the view object.
+ *
+ * @return
+ *   Rendered view.
+ */
+function muamba_embed_view($viewname, $args, $display = 'default', $return = 'preview') {
+  $view                = views_get_view($viewname);
+  $view->override_path = $_GET['q'];
+  $output              = $view->preview($display, $args);
+
+  if ($return == 'preview') {
+    // Do not output empty views.
+    if ($view->result) {
+      return $output;
+    }
+  }
+  else if ($return == 'output') {
+    // Return output, even if empty result set.
+    return $output;
+  }
+  else {
+    return $view;
+  }
+}
index b35949d8475d6b1fd1c546603629cc4a0221c97e..1a5967d48af4c0cdb2d21d90a153a4917c29d9c0 100644 (file)
@@ -267,18 +267,25 @@ function muamba_privatemsg_view_alter(&$content) {
   if (!empty($transaction)) {
     global $user;
 
+    include_once('muamba.embed.inc');
+
     $node      = node_load($transaction['nid']);
     $available = muamba_check_availability($node->nid);
     $widget    = ($node->uid == $user->uid) ? 'owner' : 'requester';
+    $info      = muamba_embed_view('muambas', array($node->nid), 'info');
+    $title     = '<h2>'. t('Messages') .'</h2>';
 
+    /*
     $bar = theme('muamba_widget_'. $widget, array(
       'node'        => $node,
       'transaction' => $transaction,
       'available'   => $available,
       'size'        => 'big',
     ));
+     */
 
-    $content['participants']['#markup'] = $bar . $content['participants']['#markup'];
+    //$content['participants']['#markup'] = $bar . $content['participants']['#markup'];
+    $content['participants']['#markup'] = $info . $title;
   }
 }
 
index ef169bf856133d553cf7d09c612c56578248f7fc..8369e6f9e7ecc4c99c14b4af7f2d8e891ce6763f 100644 (file)
@@ -88,9 +88,7 @@ function theme_muamba_colorbox_link($variables) {
  * Theme callback.
  */
 function theme_muamba_request_message($transaction = NULL) {
-  $link = l(t('your requests page'), 'muamba');
-  return t('Hi, I would like to request this item of yours. Please visit @link to manage this request',
-    array('@link' => $link));
+  return t('Hi, I would like to request this item of yours.');
 }
 
 /**
@@ -189,10 +187,16 @@ function theme_muamba_widget_owner($variables) {
  * Theme callback.
  */
 function theme_muamba_widget_requester($variables) {
-  $content     = '';
+  $output  = '';
+  $content = '';
   $transaction = $variables['transaction'];
   $size        = $variables['size'];
 
+  if ($size != 'small') {
+    $output .= '<h3>'. t('Options') .'</h3>';
+    $output .= '<br />';
+  }  
+
   foreach (muamba_actions_available('sent', $transaction) as $action) {
     $content .= theme('muamba_widget_icon', array(
       'status' => $action,
@@ -201,5 +205,7 @@ function theme_muamba_widget_requester($variables) {
     ));
   }
 
-  return $content;
+  if (!empty($content)) {
+    return $output . $content;
+  }
 }