aboutsummaryrefslogtreecommitdiff
path: root/muamba.db.inc
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2011-11-06 14:32:35 -0200
committerSilvio Rhatto <rhatto@riseup.net>2011-11-06 14:32:35 -0200
commit98c2bec78ec6bd0ddc96e6025db47410904ef785 (patch)
tree2df3ea4e60220cfb26e63fbefaad81273b51376b /muamba.db.inc
parent1500660c3e2d43c98bece5b62ae4548133dd03e3 (diff)
downloadmuamba-98c2bec78ec6bd0ddc96e6025db47410904ef785.tar.gz
muamba-98c2bec78ec6bd0ddc96e6025db47410904ef785.tar.bz2
Renaming muamba_current_transaction() to muamba_current_transactions()
Diffstat (limited to 'muamba.db.inc')
-rw-r--r--muamba.db.inc26
1 files changed, 17 insertions, 9 deletions
diff --git a/muamba.db.inc b/muamba.db.inc
index 21e2d8c..6aa4782 100644
--- a/muamba.db.inc
+++ b/muamba.db.inc
@@ -107,19 +107,21 @@ function muamba_get_transaction($mid) {
}
/**
- * Get current transaction for an item.
+ * Get current transaction for an item. Note that there might
+ * be more than one active transaction for a given item if they
+ * all are in the "requested" state.
*
* @param $data
* Item nid or node object.
*
+ * @param $uid
+ * Optional requester user id.
+ *
* @return
- * Data of the ongoing transaction.
- *
- * @todo
- * There might be more than one active transaction for
- * a given item if they all are in the "requested" state.
+ * Data of the ongoing transactions. If $uid is specified,
+ * then just one transaction is returned.
*/
-function muamba_current_transaction($data, $owner = NULL) {
+function muamba_current_transactions($data, $uid = NULL) {
if (is_object($data)) {
$nid = (int) $data->nid;
}
@@ -134,6 +136,10 @@ function muamba_current_transaction($data, $owner = NULL) {
->condition('m.nid', $nid, '=')
->condition('m.active', '1', '=');
+ if ($uid != NULL) {
+ $query->condition('m.uid', (int) $uid, '=');
+ }
+
$results = $query->execute()->fetchAll();
// Sanitize the data before handing it off to the theme layer.
@@ -141,9 +147,11 @@ function muamba_current_transaction($data, $owner = NULL) {
$rows[] = array_map('check_plain', (array) $entry);
}
- if (isset($rows[0])) {
+ if ($uid != NULL && isset($rows[0])) {
return $rows[0];
- }
+ }
+
+ return $rows;
}
/**