You are here

function clients_connection_drupal_services::testConnectionLogin in Web Service Clients 6.2

Same name and namespace in other branches
  1. 7.2 connections/clients_drupal/clients_drupal.inc \clients_connection_drupal_services::testConnectionLogin()

Connection test button handler: user login.

File

connections/clients_drupal/clients_drupal.inc, line 128
Contains classes for Client connections handlers.

Class

clients_connection_drupal_services
Base class for Drupal client connections.

Code

function testConnectionLogin(&$button_form_values) {
  try {

    // Call the login method.
    $login = $this
      ->callMethodArray('user.login');

    // Eep. we need user details!!!
  } catch (Exception $e) {
    drupal_set_message(t('Could not log in to the remote site, got error message "@message".', array(
      '@message' => $e
        ->getMessage(),
    )), 'warning');

    //dsm($e);
    return;
  }
  if (is_array($login) && isset($login['user'])) {
    drupal_set_message(t('Sucessfully logged in to the remote site; got back details for user %user (uid @uid).', array(
      '%user' => $login['user']['name'],
      '@uid' => $login['user']['uid'],
    )));
  }
  else {
    drupal_set_message(t('Could not log in to the remote site.'), 'warning');
  }
  return $login;
}