summaryrefslogtreecommitdiff
path: root/modules/drupal/drupal.module
blob: d69351083b084f592f9751d312cbabd493366190 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php

function drupal_info($field = 0) {
  $info["name"] = "Drupal";
  $info["protocol"] = "XML-RPC";

  if ($field) {
    return $info[$field];
  }
  else {
    return $info;
  }
}

function drupal_auth($username, $password, $server) {

  $message = new xmlrpcmsg("drupal.login", array(new xmlrpcval($username, "string"), new xmlrpcval($password, "string")));

  $client = new xmlrpc_client("/xmlrpc.php", $server, 80);

  $result = $client->send($message, 5);
  if ($result && !$result->faultCode()) {
    $value = $result->value();
    $login = $value->scalarval();
  }

  return $login;
}

function drupal_page() {
  global $theme;
  $theme->header();
  $theme->box("Drupal", drupal_auth_help());
  $theme->footer();
}

function drupal_auth_help() {
  $site = variable_get("site_name", "this web site");

  $output = "
   <p><a href=\"http://www.drupal.org\">Drupal</a> is the name of the software which powers %s. There are Drupal websites all over the world, and many of them share their registration databases so that users may freely login to any Drupal site using a single <b>Drupal ID</b>.</p>
   <p>So please feel free to login to your account here at %s with a username from another Drupal site. The format of a Drupal ID is similar to an  email address: <b>username</b>@<i>server</i>. An example of valid Drupal ID is <b>mwlily</b><i>@www.drop.org</i>.</p>";

  return sprintf(t($output), $site, $site);
}

?>