You are here

function nicemessages_are_enabled in Nice messages 7.2

Same name and namespace in other branches
  1. 7 nicemessages.module \nicemessages_are_enabled()

Check if nicemessages are enabled for current user.

1 call to nicemessages_are_enabled()
nicemessages_preprocess_page in ./nicemessages.module
Implements hook_preprocess_page().

File

./nicemessages.module, line 131
Nicemessages module

Code

function nicemessages_are_enabled() {
  if (variable_get('nicemessages_default_state') === 'on') {
    return TRUE;
  }
  elseif (variable_get('nicemessages_default_state') === 'off') {
    return FALSE;
  }
  elseif (variable_get('nicemessages_default_state') === 'user' && user_access('toggle nicemessages')) {
    global $user;

    // Load the full user entity with fields attached.
    $accounts = entity_load('user', array(
      $user->uid,
    ));
    $account = array_shift($accounts);
    return empty($account->{NICEMESSAGES_FIELDNAME}[LANGUAGE_NONE][0]['value']) ? FALSE : TRUE;
  }
  else {
    return TRUE;
  }
}