<?php

/*
** Maintained by Moshe Weitzman (weitzman@tejasa.com)
*/

function drupal_link($type) {
    if ($type == "auth_help") {
    $links[] = "<a href=\"module.php?mod=drupal\">". t("Drupal") ."</a>";
    }

  return $links ? $links : array();
}

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);
   if ($result && !$result->faultCode()) {
    $value = $result->value();
    $login = $value->scalarval();
  }
   // watchdog("user", "Drupal Auth complete. returning: $login");
  return $login;
}

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

function drupal_auth_help() {
$site = variable_get("site_name","this web site");
$html_output = <<<EOF
  <p><a href="http://www.drupal.org">Drupal</a> is the name of the software which 
  powers <b>$site</b>. There are <a href="http://www.drop.org/node.php?id=618">Drupal 
  web sites all over the world</a>, 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 $site 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 mwlily@www.drop.org</p>
EOF;
return $html_output;
}


?>