]> gitweb.fluxo.info Git - drupal/muamba.git/commitdiff
Adding transactional fields to muamba data model
authorSilvio Rhatto <rhatto@riseup.net>
Sat, 24 Sep 2011 22:52:36 +0000 (19:52 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Sat, 24 Sep 2011 22:52:36 +0000 (19:52 -0300)
muamba.business.inc [moved from muamba.misc.inc with 89% similarity]
muamba.install
muamba.module

similarity index 89%
rename from muamba.misc.inc
rename to muamba.business.inc
index c164664bbe36676a656bcf53c829cd69a645aa5e..f7b9e05e90ffc0b86378b8f69daa41d6f6f89673 100644 (file)
@@ -2,7 +2,7 @@
 
 /**
  * @file
- * Multiple-user Asset Manager and Borrowing Ambient.
+ * Business logic handling functions for Muamba.
  */
 
 /**
@@ -30,12 +30,13 @@ function muamba_request($nid) {
     // TODO
   }
 
+  // Notify item owner
+  $thread = privatemsg_new_thread(array(user_load($node->uid)), t('Item request'), 'User has requested an item');
+  $thread_id = $thread['message']['thread_id'];
+
   // Issue item request
   // TODO
 
-  // Notify item owner
-  privatemsg_new_thread(array(user_load($node->uid)), t('Item request'), 'User has requested an item');
-
   // User output
   return t('You have requested an item');
 }
index ab0bcef0122084e0fa987b7b2a5ad442d2b9474f..e6b3ead1dfeaa16046ccd990f2096563071ebbec 100644 (file)
@@ -21,6 +21,12 @@ function muamba_schema() {
   $schema['muamba'] = array(
     'description' => 'The base table for muamba assets.',
     'fields'      => array(
+      'mid'       => array(
+        'description' => t('The primary identifier for a muamba transaction.'),
+        'type'        => 'serial',
+        'unsigned'    => TRUE,
+        'not null'    => TRUE,
+      ),
       'nid'       => array(
         'description' => t('The {node}.nid of the borrowed item.'),
         'type'        => 'int',
@@ -35,6 +41,20 @@ function muamba_schema() {
         'not null'    => TRUE,
         'default'     => 0,
       ),
+      'thread_id'       => array(
+        'description' => t('The {thread}.thread_id for the transaction.'),
+        'type'        => 'int',
+        'unsigned'    => TRUE,
+        'not null'    => TRUE,
+        'default'     => 0,
+      ),
+      'status'       => array(
+        'description' => t('Transaction status.'),
+        'type'        => 'int',
+        'unsigned'    => TRUE,
+        'not null'    => TRUE,
+        'default'     => 0,
+      ),
     ),
     'foreign keys' => array(
       'node' => array(
@@ -45,8 +65,62 @@ function muamba_schema() {
         'table'   => 'users',
         'columns' => array('uid' => 'uid'),
       ),
+      'thread' => array(
+        'table'   => 'pm_index',
+        'columns' => array('thread_id' => 'thread_id'),
+      ),
     ),
+    'primary key' => array('mid'),
   );
 
   return $schema;
 }
+
+/**
+ * Adds transactional fields to muamba data model.
+ */
+function muamba_update_7000(&$sandbox) {
+  // Make sure to not run this update twice.
+  if (db_field_exists('muamba', 'mid')) {
+    return;
+  }
+
+  db_add_field('muamba', 'mid',
+    array(
+      'description' => t('The primary identifier for a muamba transaction.'),
+      'type'        => 'int',
+      'unsigned'    => TRUE,
+      'not null'    => TRUE,
+    )
+  );
+
+  db_add_primary_key('muamba', array('mid'));
+
+  db_add_field('muamba', 'status',
+    array(
+      'description' => t('Transaction status.'),
+      'type'        => 'int',
+      'unsigned'    => TRUE,
+      'not null'    => TRUE,
+      'default'     => 0,
+    )
+  );
+
+  db_add_field('muamba', 'thread_id',
+    array(
+      'description' => t('The {thread}.thread_id for the transaction.'),
+      'type'        => 'int',
+      'unsigned'    => TRUE,
+      'not null'    => TRUE,
+      'default'     => 0,
+    ),
+    array(
+      'foreign keys' => array(
+        'thread' => array(
+          'table'   => 'pm_index',
+          'columns' => array('thread_id' => 'thread_id'),
+        )
+      )
+    )
+  );
+}
index a36b2681168425b5dd26189f73ccba3375403d8d..411ee0773cdb0e6f9f4654b1f1c942f439bc8f39 100644 (file)
@@ -31,7 +31,7 @@ function muamba_menu() {
     'page callback'    => 'muamba_request',
     'access arguments' => array('request item'),
     'type'             => MENU_SUGGESTED_ITEM,
-    'file'             => 'muamba.misc.inc',
+    'file'             => 'muamba.business.inc',
   );
 
   $items['muamba/accept'] = array(
@@ -39,7 +39,7 @@ function muamba_menu() {
     'page callback'    => 'muamba_accept',
     'access arguments' => array('accept item'),
     'type'             => MENU_SUGGESTED_ITEM,
-    'file'             => 'muamba.misc.inc',
+    'file'             => 'muamba.business.inc',
   );
 
   $items['muamba/reject'] = array(
@@ -47,7 +47,7 @@ function muamba_menu() {
     'page callback'    => 'muamba_reject',
     'access arguments' => array('reject item'),
     'type'             => MENU_SUGGESTED_ITEM,
-    'file'             => 'muamba.misc.inc',
+    'file'             => 'muamba.business.inc',
   );
 
   $items['muamba/release'] = array(
@@ -55,7 +55,7 @@ function muamba_menu() {
     'page callback'    => 'muamba_release',
     'access arguments' => array('release item'),
     'type'             => MENU_SUGGESTED_ITEM,
-    'file'             => 'muamba.misc.inc',
+    'file'             => 'muamba.business.inc',
   );
 
   $items['muamba/return'] = array(
@@ -63,7 +63,7 @@ function muamba_menu() {
     'page callback'    => 'muamba_return',
     'access arguments' => array('return item'),
     'type'             => MENU_SUGGESTED_ITEM,
-    'file'             => 'muamba.misc.inc',
+    'file'             => 'muamba.business.inc',
   );
 
   return $items;