aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2011-11-16 14:27:32 -0200
committerSilvio Rhatto <rhatto@riseup.net>2011-11-16 14:27:32 -0200
commitfdfe199f9b2b185ce95aa51a5d644be821d87d03 (patch)
tree0f2f71cdbee7c55afdcb85030e4a85639d2eee95
parentd57c34290fc50714b330681b31b3eea7c5ea13bd (diff)
downloadmuamba-fdfe199f9b2b185ce95aa51a5d644be821d87d03.tar.gz
muamba-fdfe199f9b2b185ce95aa51a5d644be821d87d03.tar.bz2
Optional uid parameter at muamba_check_availability()
-rw-r--r--muamba.db.inc13
1 files changed, 11 insertions, 2 deletions
diff --git a/muamba.db.inc b/muamba.db.inc
index f06e3be..1c1894e 100644
--- a/muamba.db.inc
+++ b/muamba.db.inc
@@ -169,10 +169,16 @@ function muamba_current_transactions($data, $uid = NULL) {
* @param $data
* Item nid or node object.
*
+ * @param $uid
+ * Optional uid parameter to check if item is currently
+ * available to the user.
+ *
* @return
- * TRUE if item is borrowed, FALSE otherwise.
+ * TRUE if item is available, FALSE otherwise.
*/
-function muamba_check_availability($data) {
+function muamba_check_availability($data, $uid = NULL) {
+ global $user;
+
if (is_object($data)) {
$nid = (int) $data->nid;
}
@@ -193,6 +199,9 @@ function muamba_check_availability($data) {
if (empty($current)) {
return TRUE;
}
+ elseif ($uid !== NULL && $current['uid'] == $user->uid) {
+ return TRUE;
+ }
return FALSE;
}