From f47b73d4bc46351a2ed6fdb842ce452b815df58e Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Tue, 4 Oct 2011 13:10:59 -0300 Subject: Enhancing request/accept --- muamba.misc.inc | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) (limited to 'muamba.misc.inc') 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; +} -- cgit v1.2.3