aboutsummaryrefslogtreecommitdiff
path: root/muamba.misc.inc
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2011-10-04 13:10:59 -0300
committerSilvio Rhatto <rhatto@riseup.net>2011-10-04 13:10:59 -0300
commitf47b73d4bc46351a2ed6fdb842ce452b815df58e (patch)
treeb3618ceb3918b13661d0e394b8cd32cdfcac5b5a /muamba.misc.inc
parenta3336da7dd92a2b8d31f2f33a6106a1802b5a387 (diff)
downloadmuamba-f47b73d4bc46351a2ed6fdb842ce452b815df58e.tar.gz
muamba-f47b73d4bc46351a2ed6fdb842ce452b815df58e.tar.bz2
Enhancing request/accept
Diffstat (limited to 'muamba.misc.inc')
-rw-r--r--muamba.misc.inc64
1 files changed, 64 insertions, 0 deletions
diff --git a/muamba.misc.inc b/muamba.misc.inc
index 4b2d2e6..8c26159 100644
--- a/muamba.misc.inc
+++ b/muamba.misc.inc
@@ -78,3 +78,67 @@ function muamba_actions($code = NULL) {
return $status[$code];
}
+
+/**
+ * Check if an user has request access.
+ *
+ * @param $node
+ * Requested node.
+ *
+ * @return
+ * TRUE on success, FALSE otherwise.
+ */
+function muamba_has_request_access($node) {
+ if (!$node || $node->type != MUAMBA_NODE_TYPE || !node_access('view', $node)) {
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+/**
+ * Check if user has been blocked by an item owner.
+ *
+ * @param $node
+ * Requested node.
+ *
+ * @param $user
+ * User to be checked against.
+ *
+ * @return
+ * TRUE if block exists, FALSE otherwise.
+ */
+function muamba_user_has_blocked($node, $user) {
+ if (module_exists('pm_block_user')) {
+ $owner = user_load($node->uid);
+ if (pm_block_user_has_blocked($user, $owner)) {
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+/**
+ * Check if an user has management privileges for an item.
+ *
+ * @param $node
+ * Requested node.
+ *
+ * @param $user
+ * Optional user object, defaults to the logged in user.
+ *
+ * @return
+ * TRUE on access, FALSE otherwise.
+ */
+function muamba_has_management_access($node, $user = NULL) {
+ if ($user == NULL) {
+ global $user;
+ }
+
+ if (!$node || $node->type != MUAMBA_NODE_TYPE || $node->uid != $user->uid) {
+ return FALSE;
+ }
+
+ return TRUE;
+}