aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2011-09-24 22:03:33 -0300
committerSilvio Rhatto <rhatto@riseup.net>2011-09-24 22:03:33 -0300
commitb69edbdb6464618a8e45a8e5e484a7e267794fd4 (patch)
tree64c821c5cc3477ed4e1596679f75e4227fc8e58b
parent065a0ae24bba01c813d661c7e3b0ac48b6e456c5 (diff)
downloadmuamba-b69edbdb6464618a8e45a8e5e484a7e267794fd4.tar.gz
muamba-b69edbdb6464618a8e45a8e5e484a7e267794fd4.tar.bz2
Coding muamba_get_transactions
-rw-r--r--muamba.business.inc8
-rw-r--r--muamba.install29
2 files changed, 33 insertions, 4 deletions
diff --git a/muamba.business.inc b/muamba.business.inc
index 45c192e..22c5d92 100644
--- a/muamba.business.inc
+++ b/muamba.business.inc
@@ -43,6 +43,7 @@ function muamba_request($nid) {
->fields(
array(
'nid' => $nid,
+ 'owner' => $node->uid,
'uid' => $user->uid,
'status' => MUAMBA_REQUESTED,
'thread_id' => $thread_id,
@@ -117,20 +118,19 @@ function muamba_release($nid, $uid) {
*
* @param $uid
* Requester user uid.
- *
- * @todo
*/
function muamba_get_transactions($uid, $type = 'sent', $status = MUAMBA_REQUESTED) {
$uid = (int) $uid;
if ($type = 'sent') {
- // TODO
$query
->condition('m.uid', $uid, '=')
->condition('m.status', $status, '=');
}
else {
- // TODO
+ $query
+ ->condition('m.owner', $uid, '=')
+ ->condition('m.status', $status, '=');
}
return $query->execute();
diff --git a/muamba.install b/muamba.install
index 4d2ba42..a9404be 100644
--- a/muamba.install
+++ b/muamba.install
@@ -34,6 +34,15 @@ function muamba_schema() {
'not null' => TRUE,
'default' => 0,
),
+ // This assumes that the node won't have his author changed,
+ // which might be reasonable depending on the application.
+ 'owner' => array(
+ 'description' => t('The {user}.owner owner of an item.'),
+ 'type' => 'int',
+ 'unsigned' => TRUE,
+ 'not null' => TRUE,
+ 'default' => 0,
+ ),
'uid' => array(
'description' => t('The {user}.uid requesting an item.'),
'type' => 'int',
@@ -61,6 +70,10 @@ function muamba_schema() {
'table' => 'node',
'columns' => array('nid' => 'nid'),
),
+ 'owner' => array(
+ 'table' => 'users',
+ 'columns' => array('owner' => 'uid'),
+ ),
'requester' => array(
'table' => 'users',
'columns' => array('uid' => 'uid'),
@@ -135,3 +148,19 @@ function muamba_update_7001(&$sandbox) {
)
);
}
+
+
+/**
+ * Adds owner field.
+ */
+function muamba_update_7002(&$sandbox) {
+ db_add_field('muamba', 'owner',
+ array(
+ 'description' => t('The {user}.owner owner of an item.'),
+ 'type' => 'int',
+ 'unsigned' => TRUE,
+ 'not null' => TRUE,
+ 'default' => 0,
+ )
+ );
+}