]> gitweb.fluxo.info Git - drupal/muamba.git/commitdiff
Coding muamba_get_transactions
authorSilvio Rhatto <rhatto@riseup.net>
Sun, 25 Sep 2011 01:03:33 +0000 (22:03 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Sun, 25 Sep 2011 01:03:33 +0000 (22:03 -0300)
muamba.business.inc
muamba.install

index 45c192e5548bfa039d4b50ce31d698de17d98ef6..22c5d9284487cde4a9da94903ba2d6109dbe2656 100644 (file)
@@ -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();
index 4d2ba42869e4897334b778fe3b4e4eaea852b52c..a9404befec3e10bfced1be91646f9caed4d485ff 100644 (file)
@@ -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,
+    )
+  );
+}