aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2011-09-24 19:52:36 -0300
committerSilvio Rhatto <rhatto@riseup.net>2011-09-24 19:52:36 -0300
commit4f15de058dc6dadee6e79d16b441202b54161f02 (patch)
treed3c1afe31b73d8736e785e24a868b0f7c148a1de
parent043d624016705e2b54772e5b6b248024e060bbce (diff)
downloadmuamba-4f15de058dc6dadee6e79d16b441202b54161f02.tar.gz
muamba-4f15de058dc6dadee6e79d16b441202b54161f02.tar.bz2
Adding transactional fields to muamba data model
-rw-r--r--muamba.business.inc (renamed from muamba.misc.inc)9
-rw-r--r--muamba.install74
-rw-r--r--muamba.module10
3 files changed, 84 insertions, 9 deletions
diff --git a/muamba.misc.inc b/muamba.business.inc
index c164664..f7b9e05 100644
--- a/muamba.misc.inc
+++ b/muamba.business.inc
@@ -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');
}
diff --git a/muamba.install b/muamba.install
index ab0bcef..e6b3ead 100644
--- a/muamba.install
+++ b/muamba.install
@@ -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'),
+ )
+ )
+ )
+ );
+}
diff --git a/muamba.module b/muamba.module
index a36b268..411ee07 100644
--- a/muamba.module
+++ b/muamba.module
@@ -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;