$GLOBALS['user']->uid)); //if giver roles found in user roles - return true foreach ($array as $key => $value) { if (in_array($value, $user->roles)) { return TRUE; } } } return FALSE; } /** * Get all the contact emails for users that have a specific role * * @param string $roleName name of the role we are interested in * * @return string a comma separated list of email addresses */ public function roleEmails($roleName) { static $_cache = array(); if (isset($_cache[$roleName])) { return $_cache[$roleName]; } $uids = array(); $sql = " SELECT {users}.uid FROM {users} LEFT JOIN {users_roles} ON {users}.uid = {users_roles}.uid INNER JOIN {role} ON ( {role}.rid = {users_roles}.rid OR {role}.rid = 2 ) WHERE {role}. name LIKE '%%{$roleName}%%' AND {users}.status = 1 "; $query = db_query($sql); while ($result = db_fetch_object($query)) { $uids[] = $result->uid; } $_cache[$roleName] = self::getContactEmails($uids); return $_cache[$roleName]; } /** * Get all the contact emails for users that have a specific permission * * @param string $permissionName name of the permission we are interested in * * @return string a comma separated list of email addresses */ public function permissionEmails($permissionName) { static $_cache = array(); if (isset($_cache[$permissionName])) { return $_cache[$permissionName]; } $uids = array(); $sql = " SELECT {users}.uid, {permission}.perm FROM {users} LEFT JOIN {users_roles} ON {users}.uid = {users_roles}.uid INNER JOIN {permission} ON ( {permission}.rid = {users_roles}.rid OR {permission}.rid = 2 ) WHERE {permission}.perm LIKE '%%{$permissionName}%%' AND {users}.status = 1 "; $query = db_query($sql); while ($result = db_fetch_object($query)) { $uids[] = $result->uid; } $_cache[$permissionName] = self::getContactEmails($uids); return $_cache[$permissionName]; } /** * Remove all vestiges of permissions for the given module. * * Does nothing in Drupal 6. */ function uninstallPermissions($module) { } /** * Ensure that all cached permissions associated with the given module are * actually defined by that module. This is useful during module upgrade * when the newer module version has removed permission that were defined * in the older version. * * Does nothing in Drupal 6. */ function upgradePermissions($module) { } /** * Get the permissions defined in the hook_civicrm_permission implementation * of the given module. * * @return Array of permissions, in the same format as CRM_Core_Permission::getCorePermissions(). */ static function getModulePermissions($module) { $return_permissions = array(); $fn_name = "{$module}_civicrm_permission"; if (function_exists($fn_name)) { $fn_name($return_permissions); } return $return_permissions; } }