aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--muamba.business.inc16
-rw-r--r--muamba.db.inc26
-rw-r--r--muamba.theme.inc2
3 files changed, 43 insertions, 1 deletions
diff --git a/muamba.business.inc b/muamba.business.inc
index b6128e3..b68443c 100644
--- a/muamba.business.inc
+++ b/muamba.business.inc
@@ -143,6 +143,22 @@ function muamba_request($nid) {
* @todo
*/
function muamba_accept($mid) {
+ global $user;
+ $mid = (int) $mid;
+ $transaction = muamba_get_transaction($mid);
+
+ // Access check
+ // TODO: also check if user owns the item
+ $node = node_load($transaction->nid);
+ if (!$node || $node->type != MUAMBA_NODE_TYPE || !node_access('view', $node)) {
+ drupal_not_found();
+ }
+
+ // TODO
+ // Update database
+ // Notify item owner
+
+ return t('Accepted item request.');
}
/**
diff --git a/muamba.db.inc b/muamba.db.inc
index 0e29ca6..e8e1c70 100644
--- a/muamba.db.inc
+++ b/muamba.db.inc
@@ -78,3 +78,29 @@ function muamba_get_transactions($uid, $type = 'sent', $status = NULL) {
return $rows;
}
+
+/**
+ * Get a single transaction.
+ *
+ * @param $mid
+ * Transaction id.
+ *
+ * @return
+ * Transaction data.
+ */
+function muamba_get_transaction($mid) {
+ $mid = (int) $mid;
+ $query = db_select('muamba', 'm');
+ $query->fields('m', array('mid', 'nid', 'uid', 'owner', 'status', 'thread_id'));
+ $query->condition('m.mid', $mid, '=');
+
+ $rows = array();
+ $results = $query->execute()->fetchAll();
+
+ // Sanitize the data before handing it off to the theme layer.
+ foreach ($results as $entry) {
+ $rows[] = array_map('check_plain', (array) $entry);
+ }
+
+ return $rows[0];
+}
diff --git a/muamba.theme.inc b/muamba.theme.inc
index c8db199..6254074 100644
--- a/muamba.theme.inc
+++ b/muamba.theme.inc
@@ -36,7 +36,7 @@ function theme_muamba_transactions($variables) {
foreach($transactions as $transaction) {
foreach (muamba_actions_available($type, $transaction['status']) as $action) {
$callback = muamba_actions($action);
- $actions[] = l(t($callback), $callback);
+ $actions[] = l(t($callback), 'muamba/'. $callback .'/'. $transaction['mid']);
}
$rows[] = array(