Commit 51f4b91e authored by Dries's avatar Dries

* User patch by Natrak:

 - Moved the Drupal login XML-RPC API to drupal.module.
 - DA logins are now assigned the proper role.
parent 6ba38a7e
......@@ -95,7 +95,7 @@ function drupal_directory_page() {
}
function drupal_xmlrpc() {
return array("drupal.site.ping" => array("function" => "drupal_directory_ping"));
return array("drupal.site.ping" => array("function" => "drupal_directory_ping"), "drupal.login" => array("function" => "drupal_login"));
}
function drupal_notify($server) {
......@@ -149,6 +149,21 @@ function drupal_page() {
$theme->footer();
}
function drupal_login($arguments) {
// an XML-RPC method called by external clients (usually other Drupal instances)
$argument = $arguments->getparam(0);
$username = $argument->scalarval();
$argument = $arguments->getparam(1);
$password = $argument->scalarval();
if ($user = user_load(array(name => "$username", "pass" => $password, "status" => 1))) {
return new xmlrpcresp(new xmlrpcval($user->uid, "int"));
}
else {
return new xmlrpcresp(new xmlrpcval(0, "int"));
}
}
function drupal_auth_help() {
$site = variable_get("site_name", "this web site");
......
......@@ -95,7 +95,7 @@ function drupal_directory_page() {
}
function drupal_xmlrpc() {
return array("drupal.site.ping" => array("function" => "drupal_directory_ping"));
return array("drupal.site.ping" => array("function" => "drupal_directory_ping"), "drupal.login" => array("function" => "drupal_login"));
}
function drupal_notify($server) {
......@@ -149,6 +149,21 @@ function drupal_page() {
$theme->footer();
}
function drupal_login($arguments) {
// an XML-RPC method called by external clients (usually other Drupal instances)
$argument = $arguments->getparam(0);
$username = $argument->scalarval();
$argument = $arguments->getparam(1);
$password = $argument->scalarval();
if ($user = user_load(array(name => "$username", "pass" => $password, "status" => 1))) {
return new xmlrpcresp(new xmlrpcval($user->uid, "int"));
}
else {
return new xmlrpcresp(new xmlrpcval(0, "int"));
}
}
function drupal_auth_help() {
$site = variable_get("site_name", "this web site");
......
......@@ -399,26 +399,6 @@ function user_link($type) {
return $links ? $links : array();
}
function drupal_login($arguments) {
// an XML-RPC method called by external clients (usually other Drupal instances)
$argument = $arguments->getparam(0);
$username = $argument->scalarval();
$argument = $arguments->getparam(1);
$password = $argument->scalarval();
if ($user = user_load(array(name => "$username", "pass" => $password, "status" => 1))) {
return new xmlrpcresp(new xmlrpcval($user->uid, "int"));
}
else {
return new xmlrpcresp(new xmlrpcval(0, "int"));
}
}
function user_xmlrpc() {
return array("drupal.login" => array("function" => "drupal_login"));
}
/*** Authentication methods ************************************************/
function user_get_authname($account, $module) {
......@@ -542,7 +522,7 @@ function user_login($edit = array(), $msg = "") {
if (module_invoke($module, "auth", $name, $pass, $server)) {
if (variable_get("user_register", 1) == 1 && !user_load(array("name" => "$name@$server"))) { //register this new user
watchdog("user", "new user: $name@$server ($module ID)");
$user = user_save("", array("name" => "$name@$server", "pass" => user_password(), "init" => "$name@$server", "status" => 1, "authname_$module" => "$name@$server"));
$user = user_save("", array("name" => "$name@$server", "pass" => user_password(), "init" => "$name@$server", "status" => 1, "authname_$module" => "$name@$server", "rid" => _user_authenticated_id()));
break;
}
}
......
......@@ -399,26 +399,6 @@ function user_link($type) {
return $links ? $links : array();
}
function drupal_login($arguments) {
// an XML-RPC method called by external clients (usually other Drupal instances)
$argument = $arguments->getparam(0);
$username = $argument->scalarval();
$argument = $arguments->getparam(1);
$password = $argument->scalarval();
if ($user = user_load(array(name => "$username", "pass" => $password, "status" => 1))) {
return new xmlrpcresp(new xmlrpcval($user->uid, "int"));
}
else {
return new xmlrpcresp(new xmlrpcval(0, "int"));
}
}
function user_xmlrpc() {
return array("drupal.login" => array("function" => "drupal_login"));
}
/*** Authentication methods ************************************************/
function user_get_authname($account, $module) {
......@@ -542,7 +522,7 @@ function user_login($edit = array(), $msg = "") {
if (module_invoke($module, "auth", $name, $pass, $server)) {
if (variable_get("user_register", 1) == 1 && !user_load(array("name" => "$name@$server"))) { //register this new user
watchdog("user", "new user: $name@$server ($module ID)");
$user = user_save("", array("name" => "$name@$server", "pass" => user_password(), "init" => "$name@$server", "status" => 1, "authname_$module" => "$name@$server"));
$user = user_save("", array("name" => "$name@$server", "pass" => user_password(), "init" => "$name@$server", "status" => 1, "authname_$module" => "$name@$server", "rid" => _user_authenticated_id()));
break;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment