You are here

function drd_server_server_svn_update in Drupal Remote Dashboard Server 6

Same name and namespace in other branches
  1. 7 drd_server.server.inc \drd_server_server_svn_update()
1 string reference to 'drd_server_server_svn_update'
drd_server_xmlrpc in ./drd_server.module
Implementation of hook_xmlrpc().

File

./drd_server.server.inc, line 132

Code

function drd_server_server_svn_update($sid, $svn_user, $svn_password, $force_external = FALSE) {
  $user = drd_server_load_user($sid);
  if (is_string($user)) {
    return drd_server_error($user);
  }
  if (function_exists('set_time_limit')) {
    @set_time_limit(0);
  }
  $status = array();
  if (function_exists('svn_update') && $force_external === FALSE) {
    svn_auth_set_parameter(SVN_AUTH_PARAM_DEFAULT_USERNAME, $svn_user);
    svn_auth_set_parameter(SVN_AUTH_PARAM_DEFAULT_PASSWORD, $svn_password);
    ob_start();
    $revision = svn_update(DRUPAL_ROOT);
    $output = ob_get_contents();
    ob_end_clean();
    $status[] = $output;
  }
  else {
    $cmd = "svn update " . DRUPAL_ROOT . " --accept theirs-full --force --username {$svn_user} --password {$svn_password} --non-interactive";
    $result = explode(' ', exec($cmd, $output, $cmd_status));
    if ($cmd_status) {
      $cmd = "/usr/bin/" . $cmd;
      $result = explode(':', exec($cmd, $output, $cmd_status));
    }
    $revision = array_pop($result);
    array_pop($output);
    foreach ($output as $line) {
      $file_status = substr($line, 0, 3);
      $line = trim(substr($line, 5));
      $file_path = trim($line);
      $status[] = array(
        'file_path' => $file_path,
        'file_status' => $file_status,
      );
    }
    $status[] = array(
      'info' => 'SVN update performed by commandline tool',
    );
  }
  return drd_server_result('server.svn.update', array(
    $revision,
    $status,
  ));
}