You are here

function _piwik_user_roles in Piwik Web Analytics 5

D6 backport orders core standard roles on top and translate core roles.

1 call to _piwik_user_roles()
piwik_admin_settings_form in ./piwik.module
Implementation of hook_admin_settings() for configuring the module

File

./piwik.module, line 577

Code

function _piwik_user_roles() {

  // System roles take the first two positions.
  $roles = array(
    DRUPAL_ANONYMOUS_RID => NULL,
    DRUPAL_AUTHENTICATED_RID => NULL,
  );
  $result = db_query('SELECT * FROM {role} ORDER BY name');
  while ($role = db_fetch_object($result)) {
    switch ($role->rid) {

      // We only translate the built in role names
      case DRUPAL_ANONYMOUS_RID:
        $roles[$role->rid] = t($role->name);
        break;
      case DRUPAL_AUTHENTICATED_RID:
        $roles[$role->rid] = t($role->name);
        break;
      default:
        $roles[$role->rid] = $role->name;
    }
  }

  // Filter to remove unmatched system roles.
  return array_filter($roles);
}