'requested', MUAMBA_ACCEPTED => 'accepted', MUAMBA_REJECTED => 'rejected', MUAMBA_CANCELLED => 'cancelled', MUAMBA_RETURNED => 'returned', MUAMBA_RECOVERED => 'recovered', MUAMBA_LOST => 'lost', ); if ($code == NULL) { return $status; } return $status[$code]; } /** * Get status callback name. * * @param $code * Optional status code. * * @return * Array of callback names or callback * name if $code is supplied. */ function muamba_actions($code = NULL) { $status = array( MUAMBA_REQUESTED => 'request', MUAMBA_ACCEPTED => 'accept', MUAMBA_REJECTED => 'reject', MUAMBA_CANCELLED => 'cancel', MUAMBA_RETURNED => 'return', MUAMBA_RECOVERED => 'recover', MUAMBA_LOST => 'lost', ); if ($code === NULL) { return $status; } 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 (!user_is_logged_in() || !$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 (!user_is_logged_in()) { return FALSE; } 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 (!user_is_logged_in() || !$node || $node->type != MUAMBA_NODE_TYPE || $node->uid != $user->uid) { return FALSE; } return TRUE; }