aboutsummaryrefslogtreecommitdiff
path: root/muamba.theme.inc
blob: af15da98ceb01b01edd5cc749c8c4cd5deab8a5e (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
<?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');
}