You are here

function deploy_auth_sessid_init in Deploy - Content Staging 6

Implementation of the init callback.

1 string reference to 'deploy_auth_sessid_init'
deploy_deploy_auth_info in ./deploy.module
Implementation of hook_deploy_auth_info().

File

./deploy.module, line 1088
Deployment API which enables modules to deploy items between servers.

Code

function deploy_auth_sessid_init($server = array()) {

  // In order to prevent bots from cluttering up the sessions table, you must
  // have an active anonymous session before logging in to Drupal. So that is
  // the first thing we do with system.connect. This session ID is saved
  // to the 'deploy_sessid' variable, which all other xmlrpc calls to the
  // remote server passes.
  $result = deploy_send(array(
    'system.connect',
  ), array());
  variable_set('deploy_auth_sessid', $result['sessid']);

  // Then we can log in.
  $result = deploy_send(array(
    'user.login',
  ), array(
    $server['settings']['username'],
    $server['settings']['password'],
  ));

  // If it fails, then add a message to the log. Otherwise set the session ID into
  // a drupal variable for the other functions to grab.
  if ($result === FALSE) {
    db_query("INSERT INTO {deploy_log_details} (dlid, module, description, result, message) VALUES (%d, '%s', '%s', '%s', '%s')", variable_get('deploy_log_id', ''), 'login', 'Remote user login', 'Error', xmlrpc_error_msg());
  }
  else {
    variable_set('deploy_auth_sessid', $result['sessid']);
    return TRUE;
  }
}