aboutsummaryrefslogtreecommitdiff
path: root/muamba.theme.inc
blob: ac8cdc71046f796bccddbe6758de2fc8b03e1598 (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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<?php

/**
 * @file
 * Misc theme functions.
 */

/**
 * Theme callback.
 */
function theme_muamba_transactions($variables) {
  $path = drupal_get_path('module', 'muamba');
  drupal_add_js($path  .'/muamba.js');

  $rows         = array();
  $type         = $variables['type'];
  $transactions = $variables['transactions'];

  $output = '<div class="muamba-transactions">';

  if ($type == 'sent') {
    $title = t('Items I requested from people');
  }
  else {
    $title = t('My items that people requested');
  }

  $output .= '<h2>'. $title .'</h2>';

  if (empty($transactions)) {
    $output .= t('There are no transactions.');
    $output .= '</div>';
    return $output;
  }

  foreach($transactions as $transaction) {
    foreach (muamba_actions_available($type, $transaction['status']) as $action) {
      $callback  = muamba_actions($action);
      $actions[] = l(t($callback), 'muamba/'. $callback .'/'. $transaction['mid']);
    }

    $rows[] = array(
      'asset'   => $transaction['node']->title,
      'user'    => $transaction['user']->name,
      'status'  => t(muamba_statuses($transaction['status'])),
      'actions' => implode($actions, ' | '),
      //'thread'  => theme('muamba_colorbox_link', array(
      //  'path' => '/messages/view/'. $transaction['thread_id'],
      //  'text' => t('view messages'),
      //)),
      'thread'  => l(
        t('view messages'),
        'messages/view/'. $transaction['thread_id'],
        array(
          'attributes' => array(
            //'class' => array('colorbox-ajax', 'colorbox-load')
          )
        )
      )
    );
  }

  // Make a table for them.
  $header = array(t('Item'), t('User'), t('Status'), t('Actions'), t('Negotiation'));
  $output .= theme('table', array('header' => $header, 'rows' => $rows));  
  $output .= '</div>';

  return $output;
}

/**
 * Theme callback.
 */
function theme_muamba_colorbox_link($variables) {
  $path    = $variables['path'];
  $text    = $variables['text'];

  $output  = '<a href="'. $path .'?width=500&height=500&iframe=true';
  $output .= '" class="colorbox-ajax colorbox-load">';
  $output .= $text .'</a>';

  return $output;
}

/**
 * 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));
}

/**
 * Theme callback.
 */
function theme_muamba_accept_message($transaction = NULL) {
  return t('I accept your item request');
}

/**
 * Theme callback.
 */
function theme_muamba_reject_message($transaction = NULL) {
  return t('I reject your item request');
}