aboutsummaryrefslogtreecommitdiff
path: root/muamba-widget.tpl.php
blob: 7d4cc5a56219f24eb2903db7a56c0d1ad0343b88 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php

/**
 * @file
 * Template for displaying the muamba widget.
 */

// 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');

$content = '';
$output  = '';

if ($node->uid != $user->uid) {
  if (!user_is_logged_in()) {
    print t('You have to be logged in to be able to ask for this item.');
    return;
  }
  elseif (!$available && $transactions['uid'] != $user->uid) {
    if (variable_get('muamba_allow_request_unavailable', FALSE) == TRUE) {
      $content .= theme('muamba_widget_icon', array(
        'status' => MUAMBA_REQUESTED,
        'id'     => $node->nid,
        'size'   => $size,
      ));
    }
    else {
      $content .= theme('image',
        array(
          'path'  => $path .'/images/unavailable.png',
          'alt'   => t('Item unavailable'),
          'title' => t('Item unavailable'),
        )
      );
    }
  }
  elseif ($transactions['uid'] == $user->uid) {
    $content .= theme('muamba_widget_requester', array(
      'transaction' => $transactions,
      'size'        => $size,
      'messages'    => $messages,
    ));
  }
  else {
    $content .= theme('muamba_widget_icon', array(
      'status' => MUAMBA_REQUESTED,
      'id'     => $node->nid,
      'size'   => $size,
    ));
  }
}
else {
  foreach ($transactions as $transaction) {
    $content .= theme('muamba_widget_owner', array(
      'transaction' => $transaction,
      'size'        => $size,
      'messages'    => $messages,
   ));
  }
}

if (!empty($content)) {
  $output  = '<div class="muamba-widget">';

  if ($size != 'small') {
    $output .= '<h3>'. t('Options') .'</h3>';
  }

  $output .= $content;
  $output .= '</div>';
}

print $output;