You are here

function admin_content_notification_is_current_user_role_allowed_to_send_notification in Admin Content Notification 7.2

Same name and namespace in other branches
  1. 8 admin_content_notification.module \admin_content_notification_is_current_user_role_allowed_to_send_notification()
  2. 8.2 admin_content_notification.module \admin_content_notification_is_current_user_role_allowed_to_send_notification()

Return roles on which email should be send.

@global Object $user Drupal User

Return value

boolean True if mail should be send.

2 calls to admin_content_notification_is_current_user_role_allowed_to_send_notification()
admin_content_notification_node_insert in ./admin_content_notification.module
Implements hook_node_insert().
admin_content_notification_node_update in ./admin_content_notification.module
Implements hook_node_update().

File

./admin_content_notification.module, line 63
Module admin_content_notification file.

Code

function admin_content_notification_is_current_user_role_allowed_to_send_notification() {
  global $user;
  $allowed_roles = array_values(array_filter(variable_get('admin_content_notification_allowed_roles')));
  if (count($allowed_roles)) {
    foreach ($allowed_roles as $rid) {
      if (array_key_exists($rid, $user->roles)) {
        return TRUE;
      }
    }
    return FALSE;
  }
  return FALSE;
}