You are here

function drupalgap_autoassignrole_services_request_postprocess_alter in DrupalGap 7

Implements hook_services_request_postprocess_alter().

File

modules/drupalgap_autoassignrole/drupalgap_autoassignrole.module, line 19

Code

function drupalgap_autoassignrole_services_request_postprocess_alter($controller, $args, &$result) {
  if ($controller['callback'] == '_system_resource_connect') {
    $roles = variable_get('autoassignrole_user_roles', array());

    // @TODO change to use a single db_query.
    foreach ($roles as $rid => $value) {
      if (!$value) {
        continue;
      }
      $role = user_role_load($rid);
      $roles[$rid] = $role->name;
    }
    asort($roles);
    $result->autoassignrole = array(
      'autoassignrole_user_roles' => $roles,
    );
  }
}