Index: modules/drupal/drupal.module =================================================================== RCS file: /cvs/drupal/drupal/modules/drupal/drupal.module,v retrieving revision 1.139 diff -u -p -r1.139 drupal.module --- modules/drupal/drupal.module 24 Jan 2007 14:48:36 -0000 1.139 +++ modules/drupal/drupal.module 25 Feb 2007 02:42:56 -0000 @@ -3,25 +3,18 @@ /** * @file - * Lets users log in using a Drupal ID and can notify a central server about your site. + * Notify a central server about your site. */ /** * Implementation of hook_help(). */ -function drupal_help($section) { +function drupalnet_help($section) { switch ($section) { - case 'admin/help#drupal': + case 'admin/help#drupalnet': $output = '
'. t('The Drupal module uses the XML-RPC network communication protocol to connect your site with a central server that maintains a directory of client sites.') .'
'; - $output .= t('Enabling the Drupal module will allow you to:
-'. t('The Drupal module administration page allows you to set the xml-rpc server page and other related options.') .'
'; + $output .= ''. t('Enabling the Drupalnet module will allow you to register your site with a server, including (optionally) posting information on your installed modules and themes and summary statistics on your number of posts and users, information that can help rank Drupal modules and themes and optionally to enable other sites to register with your site.') .'
'; + $output .= ''. t('The Drupalnet module administration page allows you to set the xml-rpc server page and other related options.') .'
'; $output .= t('If you maintain a directory of sites, you can list them on a page using the drupal_client_page() function. Sample instructions:
<?php -print drupal_client_page(); +print drupalnet_client_page(); ?>
'. t('For more information please read the configuration and customization handbook Drupal page.', array('@drupal' => 'http://drupal.org/handbook/modules/drupal/')) .'
'; + $output .= ''. t('For more information please read the configuration and customization handbook Drupalnet page.', array('@drupal' => 'http://drupal.org/handbook/modules/drupal/')) .'
'; return $output; - case 'admin/settings/distributed-authentication': + case 'admin/settings/sites-registry': return ''. t('Using this your site can "call home" to another Drupal server. By calling home to drupal.org and sending a list of your installed modules and themes, you help rank projects on drupal.org and so assist all Drupal administrators to find the best components for meeting their needs. If you want to register with a different server, you can change the Drupal XML-RPC server setting -- but the server has to be able to handle Drupal XML. Some XML-RPC servers may present directories of all registered sites. To get all your site information listed, go to the site information settings page and set the site name, the e-mail address, the slogan, and the mission statement.', array('@site-settings' => url('admin/settings/site-information'))) .'
'; - case 'user/help#drupal': - return variable_get('drupal_authentication_service', 0) ? t('Drupal is the name of the software that powers %this-site. There are Drupal websites all over the world, and many of them share their registration databases so that users may freely log in to any Drupal site using a single Drupal ID.
-So please feel free to log in to your account here at %this-site with a username from another Drupal site. The format of a Drupal ID is similar to an e-mail address: username@server. An example of a valid Drupal ID is mwlily@drupal.org.
', array('@Drupal' => 'http://drupal.org', '%this-site' => variable_get('site_name', 'Drupal'))) : ''; } } -function drupal_sites_registry_settings() { +function drupalnet_sites_registry_settings() { // Check if all required fields are present if ((variable_get('site_name', 'Drupal') == 'Drupal') || (variable_get('site_name', 'Drupal') == '')) { form_set_error('drupal_directory', t('You must set the name of your site on the administer » settings » site information page.', array('@url' => url('admin/settings/site-information')))); @@ -106,40 +96,10 @@ function drupal_sites_registry_settings( return system_settings_form($form); } -function drupal_distributed_authentication_settings() { - - $options = array('1' => t('Enabled'), '0' => t('Disabled')); - - $form['drupal_authentication_service'] = array( - '#type' => 'radios', - '#title' => t('Authentication service'), - '#default_value' => variable_get('drupal_authentication_service', 0), - '#options' => $options, - '#description' => t('If enabled, your Drupal site will accept logins with the user names of other Drupal sites, and likewise provide authentication for users logging into other Drupal sites, based on their user accounts here.') - ); - - $form['drupal_default_da_server'] = array( - '#type' => 'textfield', - '#title' => t('Default authentication server'), - '#default_value' => variable_get('drupal_default_da_server', ''), - '#description' => t('The URL of the default Drupal authentication server. Omit the %http prefix (e.g. drupal.org, www.example.com, etc.). If the authentication service has been enabled, users registered at the server specified here, will not need to append the server to their user name when logging into your site. This enables users to provide a briefer, more familiar username in the login form.', array('%http' => 'http')) - ); - - $form['drupal_default_da_server_only'] = array( - '#type' => 'radios', - '#title' => t('Only allow authentication from default server'), - '#default_value' => variable_get('drupal_default_da_server_only', 0), - '#options' => $options, - '#description' => t("Only accept remote logins from the above specified default authentication server and not from any other server. Useful when an external system is the solitary authority on user accounts for this site. A common usage is to enable this setting and also enable an authentication module which talks to your company's directory server.") - ); - - return system_settings_form($form); -} - /** * Implementation of hook_cron(); handles pings to and from the site. */ -function drupal_cron() { +function drupalnet_cron() { if (time() - variable_get('cron_last', 0) > 21600) { // If this site acts as a Drupal XML-RPC server, delete the sites that @@ -155,7 +115,7 @@ function drupal_cron() { // If this site acts as a Drupal XML-RPC client, send a message to the // Drupal XML-RPC server. if (variable_get('drupal_register', 0) && variable_get('drupal_server', 0)) { - drupal_notify(variable_get('drupal_server', '')); + drupalnet_notify(variable_get('drupal_server', '')); } } } @@ -163,7 +123,7 @@ function drupal_cron() { /** * Callback function from drupal_xmlrpc() called when another site pings this one. */ -function drupal_client_ping($client, $system) { +function drupalnet_client_ping($client, $system) { /* ** Parse our parameters: */ @@ -210,7 +170,7 @@ function drupal_client_ping($client, $sy * This function may be called from a custom page on sites that are * Drupal directory servers. */ -function drupal_client_page($sort = 'name') { +function drupalnet_client_page($sort = 'name') { $result = db_query('SELECT * FROM {client} ORDER BY %s', $sort); $clients = array(); @@ -239,7 +199,7 @@ function theme_client_list($clients) { /** * Implementation of hook_xmlrpc(). */ -function drupal_xmlrpc() { +function drupalnet_xmlrpc() { $xmlrpc = array(); if (variable_get('drupal_client_service', 0)) { $xmlrpc[] = array( @@ -249,21 +209,13 @@ function drupal_xmlrpc() { t('Handling ping request') ); } - if (variable_get('drupal_authentication_service', 0)) { - $xmlrpc[] = array( - 'drupal.login', - 'drupal_login', - array('int', 'string', 'string'), - t('Logging into a Drupal site') - ); - } return $xmlrpc; } /** * Sends a ping to the Drupal directory server. */ -function drupal_notify($server) { +function drupalnet_notify($server) { global $base_url; $client = array( 'link' => $base_url, @@ -296,7 +248,7 @@ function drupal_notify($server) { /** * Implementation of hook_info(). */ -function drupal_info($field = 0) { +function drupalnet_info($field = 0) { $info['name'] = 'Drupal'; $info['protocol'] = 'XML-RPC'; @@ -309,78 +261,17 @@ function drupal_info($field = 0) { } /** - * Implementation of hook_auth(). - */ -function drupal_auth($username, $password, $server = FALSE) { - if (variable_get('drupal_authentication_service', 0)) { - if (!$server) { - $server = variable_get('drupal_default_da_server', ''); - } - else if (variable_get('drupal_default_da_server_only', 0)) { - if (variable_get('drupal_default_da_server', '') != $server) { - return; - } - } - if (!empty($server)) { - $result = xmlrpc("http://$server/xmlrpc.php", 'drupal.login', $username, $password); - if ($result === FALSE) { - drupal_set_message(t('Error %code: %message', array('%code' => xmlrpc_errno(), '%message' => xmlrpc_error_msg())), 'error'); - } - else { - return $result; - } - } - } -} - -/** * Implementation of hook_menu(). */ -function drupal_menu() { +function drupalnet_menu() { $items['admin/settings/sites-registry'] = array( 'title' => t('Sites registry'), 'description' => t('Register with another Drupal site (drupal.org by default) for statistics sharing, or set up your server to be a central server for registrations.'), 'page callback' => 'drupal_get_form', - 'page arguments' => array('drupal_sites_registry_settings'), + 'page arguments' => array('drupalnet_sites_registry_settings'), 'access arguments' => array('administer site configuration'), ); - $items['admin/settings/distributed-authentication'] = array( - 'title' => t('Distributed authentication'), - 'description' => t('Allow your site to accept logins from other Drupal sites such as drupal.org.'), - 'page callback' => 'drupal_get_form', - 'page arguments' => array('drupal_distributed_authentication_settings'), - 'access arguments' => array('administer site configuration'), - ); - if (variable_get('drupal_authentication_service', 0)) { - $items['drupal'] = array( - 'title' => t('Drupal'), - 'page callback' => 'drupal_page_help', - 'access callback' => TRUE, - 'type' => MENU_SUGGESTED_ITEM, - ); - } - return $items; -} -/** - * Menu callback; print Drupal-authentication-specific information from user/help. - */ -function drupal_page_help() { - return drupal_help('user/help#drupal'); + return $items; } -/** - * Callback function from drupal_xmlrpc() for authenticating remote clients. - * - * Remote clients are usually other Drupal instances. - */ -function drupal_login($username, $password) { - if (variable_get('drupal_authentication_service', 0)) { - if ($user = user_load(array('name' => $username, 'pass' => $password, 'status' => 1))) { - return $user->uid; - } - else { - return 0; - } - } -}