aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2011-09-26 20:34:59 -0300
committerSilvio Rhatto <rhatto@riseup.net>2011-09-26 20:34:59 -0300
commit8bc407811575c36fc24dda235e263e9366efbe1e (patch)
tree5cd9e5d65c19925362f1be80f0678e9e997ab0a5
parentcfadf58b293e7c6c030184a8f2bd1d93688fe85a (diff)
downloadmuamba-8bc407811575c36fc24dda235e263e9366efbe1e.tar.gz
muamba-8bc407811575c36fc24dda235e263e9366efbe1e.tar.bz2
Sketching muamba_actions()
-rw-r--r--muamba.business.inc44
-rw-r--r--muamba.db.inc4
-rw-r--r--muamba.module13
-rw-r--r--muamba.theme.inc32
4 files changed, 71 insertions, 22 deletions
diff --git a/muamba.business.inc b/muamba.business.inc
index db89305..5efb469 100644
--- a/muamba.business.inc
+++ b/muamba.business.inc
@@ -5,8 +5,24 @@
* Business logic for Muamba.
*/
-// Database functions.
+// Load requirements.
include_once('muamba.db.inc');
+include_once('muamba.misc.inc');
+
+/**
+ * Transaction management page.
+ */
+function muamba() {
+ global $user;
+
+ $sent = muamba_transactions_summary(muamba_get_transactions($user->uid));
+ $received = muamba_transactions_summary(muamba_get_transactions($user->uid, 'received'));
+
+ $output = theme('muamba_transactions', array('transactions' => $sent, 'type' => 'sent'));
+ $output .= theme('muamba_transactions', array('transactions' => $received, 'type' => 'received'));
+
+ return $output;
+}
/**
* Request an item.
@@ -59,21 +75,6 @@ function muamba_request($nid) {
}
/**
- * Transaction management page.
- */
-function muamba() {
- global $user;
-
- $sent = muamba_get_transactions($user->uid);
- $received = muamba_get_transactions($user->uid, 'received');
-
- $output = theme('muamba_transactions', array('transactions' => $sent));
- $output .= theme('muamba_transactions', array('transactions' => $received));
-
- return $output;
-}
-
-/**
* Accept a transaction request.
*
* @param $mid
@@ -130,3 +131,14 @@ function muamba_release($mid) {
*/
function muamba_return($mid) {
}
+
+/**
+ * Cancel a request.
+ *
+ * @param $mid
+ * Transaction id.
+ *
+ * @todo
+ */
+function muamba_cancel($mid) {
+}
diff --git a/muamba.db.inc b/muamba.db.inc
index a8bf8b9..93eb5bc 100644
--- a/muamba.db.inc
+++ b/muamba.db.inc
@@ -51,13 +51,13 @@ function muamba_get_transactions($uid, $type = 'sent', $status = MUAMBA_REQUESTE
$query
->condition('m.uid', $uid, '=')
->condition('m.status', $status, '=')
- ->fields('m', array('mid', 'uid', 'owner', 'thread_id'));
+ ->fields('m', array('mid', 'nid', 'uid', 'owner', 'thread_id'));
}
else {
$query
->condition('m.owner', $uid, '=')
->condition('m.status', $status, '=')
- ->fields('m', array('mid', 'uid', 'owner', 'thread_id'));
+ ->fields('m', array('mid', 'nid', 'uid', 'owner', 'status', 'thread_id'));
}
$rows = array();
diff --git a/muamba.module b/muamba.module
index deb1b2d..9588dac 100644
--- a/muamba.module
+++ b/muamba.module
@@ -79,6 +79,14 @@ function muamba_menu() {
'file' => 'muamba.business.inc',
);
+ $items['muamba/cancel'] = array(
+ 'title' => 'Cancel a request',
+ 'page callback' => 'muamba_cancel',
+ 'access arguments' => array('cancel item'),
+ 'type' => MENU_SUGGESTED_ITEM,
+ 'file' => 'muamba.business.inc',
+ );
+
return $items;
}
@@ -120,7 +128,10 @@ function muamba_theme($existing, $type, $theme, $path) {
'template' => 'muamba-powered',
),
'muamba_transactions' => array(
- 'variables' => array('transactions' => NULL),
+ 'variables' => array(
+ 'transactions' => NULL,
+ 'type' => NULL,
+ ),
'file' => 'muamba.theme.inc',
),
);
diff --git a/muamba.theme.inc b/muamba.theme.inc
index c13a15f..771c80b 100644
--- a/muamba.theme.inc
+++ b/muamba.theme.inc
@@ -6,13 +6,39 @@
*/
function theme_muamba_transactions($variables) {
+ $rows = array();
+ $type = $variables['type'];
$transactions = $variables['transactions'];
+
$output = '<div class="muamba-transactions">';
- $output .= '<h2>'. t('Transactions') .'</h2>';
+
+ 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) {
+ $rows[] = array(
+ 'asset' => $transaction['node']->title,
+ 'user' => $transaction['user']->name,
+ 'status' => muamba_statuses($transaction['status']),
+ 'actions' => 'accept', // TODO
+ );
+ }
// Make a table for them.
- $header = array(t('Id'), t('uid'), t('Owner'), t('Thread'));
- $output .= theme('table', array('header' => $header, 'rows' => $transactions));
+ $header = array(t('Asset'), t('User'), t('Status'), t('Actions'));
+ $output .= theme('table', array('header' => $header, 'rows' => $rows));
$output .= '</div>';
return $output;