Commit e52c0f5d authored by Dries's avatar Dries

- Code improvements by JonBob. Thanks.

parent ac3c45dd
......@@ -20,15 +20,14 @@ function admin_help($section) {
*/
function admin_link($type) {
if ($type == 'system') {
menu('admin', t('administer'), user_access('access administration pages') ? 'admin_admin' : MENU_DENIED, 9);
menu('admin', t('administer'), user_access('access administration pages') ? 'admin_main_page' : MENU_DENIED, 9);
}
}
/**
* Menu callback. Provides an overview to serve as the main page of the
* administration section.
* Menu callback; provides the main page of the administration section.
*/
function admin_admin() {
function admin_main_page() {
print theme("page", watchdog_overview("actions"));
}
......
......@@ -68,7 +68,7 @@ function aggregator_help($section) {
}
/**
* Menu callback. Displays the aggregator-specific information from admin/help.
* Menu callback; displays the aggregator-specific information from admin/help.
*/
function aggregator_help_page() {
print theme('page', aggregator_help('admin/help#aggregator'));
......@@ -626,7 +626,7 @@ function aggregator_view() {
}
/**
* Menu callback. Displays the category edit form, or saves changes and
* Menu callback; displays the category edit form, or saves changes and
* displays the overview page.
*/
function aggregator_admin_edit_category($category = 0) {
......@@ -652,8 +652,9 @@ function aggregator_admin_edit_category($category = 0) {
}
/**
* Menu callback. Displays the feed edit form, or saves changes and
* displays the overview page.
* Menu callback; displays the feed edit form.
*
* After editing, saves changes and displays the overview page.
*/
function aggregator_admin_edit_feed($feed = 0) {
$edit = $_POST['edit'];
......@@ -678,7 +679,7 @@ function aggregator_admin_edit_feed($feed = 0) {
}
/**
* Menu callback. Removes all items from a feed, then displays the overview page.
* Menu callback; removes all items from a feed, then displays the overview page.
*/
function aggregator_admin_remove_feed($feed) {
aggregator_remove(aggregator_get_feed($feed));
......@@ -686,7 +687,7 @@ function aggregator_admin_remove_feed($feed) {
}
/**
* Menu callback. Refreshes a feed, then displays the overview page.
* Menu callback; refreshes a feed, then displays the overview page.
*/
function aggregator_admin_refresh_feed($feed) {
aggregator_refresh(aggregator_get_feed($feed));
......@@ -694,21 +695,21 @@ function aggregator_admin_refresh_feed($feed) {
}
/**
* Menu callback. Displays the aggregator administration page.
* Menu callback; displays the aggregator administration page.
*/
function aggregator_admin_overview() {
print theme('page', aggregator_view());
}
/**
* Menu callback. Displays the most recent items gathered from any feed.
* Menu callback; displays the most recent items gathered from any feed.
*/
function aggregator_page_last() {
_aggregator_page_list('SELECT i.*, f.title AS ftitle, f.link AS flink FROM {aggregator_item} i INNER JOIN {aggregator_feed} f ON i.fid = f.fid ORDER BY i.timestamp DESC, i.iid DESC', arg(1));
}
/**
* Menu callback. Displays all the items captured from a particular feed.
* Menu callback; displays all the items captured from a particular feed.
*/
function aggregator_page_source() {
$feed = db_fetch_object(db_query('SELECT * FROM {aggregator_feed} WHERE fid = %d', arg(2)));
......@@ -718,7 +719,7 @@ function aggregator_page_source() {
}
/**
* Menu callback. Displays all the items aggregated in a particular category.
* Menu callback; displays all the items aggregated in a particular category.
*/
function aggregator_page_category() {
$category = db_fetch_object(db_query('SELECT cid, title FROM {aggregator_category} WHERE cid = %d', arg(2)));
......@@ -804,7 +805,7 @@ function _aggregator_page_list($sql, $op, $header = '') {
}
/**
* Menu callback. Displays all the feeds used by the aggregator.
* Menu callback; displays all the feeds used by the aggregator.
*/
function aggregator_page_sources() {
$result = db_query('SELECT f.fid, f.title, f.description, f.image, MAX(i.timestamp) AS last FROM {aggregator_feed} f LEFT JOIN {aggregator_item} i ON f.fid = i.fid GROUP BY fid');
......@@ -829,7 +830,7 @@ function aggregator_page_sources() {
}
/**
* Menu callback. Generates an OPML representation of all feeds.
* Menu callback; generates an OPML representation of all feeds.
*/
function aggregator_page_opml() {
$result = db_query('SELECT * FROM {aggregator_feed} ORDER BY title');
......@@ -854,7 +855,7 @@ function aggregator_page_opml() {
}
/**
* Menu callback. Displays all the categories used by the aggregator.
* Menu callback; displays all the categories used by the aggregator.
*/
function aggregator_page_categories() {
$result = db_query('SELECT c.cid, c.title, c.description FROM {aggregator_category} c LEFT JOIN {aggregator_category_item} ci ON c.cid = ci.cid LEFT JOIN {aggregator_item} i ON ci.iid = i.iid GROUP BY cid');
......
......@@ -68,7 +68,7 @@ function aggregator_help($section) {
}
/**
* Menu callback. Displays the aggregator-specific information from admin/help.
* Menu callback; displays the aggregator-specific information from admin/help.
*/
function aggregator_help_page() {
print theme('page', aggregator_help('admin/help#aggregator'));
......@@ -626,7 +626,7 @@ function aggregator_view() {
}
/**
* Menu callback. Displays the category edit form, or saves changes and
* Menu callback; displays the category edit form, or saves changes and
* displays the overview page.
*/
function aggregator_admin_edit_category($category = 0) {
......@@ -652,8 +652,9 @@ function aggregator_admin_edit_category($category = 0) {
}
/**
* Menu callback. Displays the feed edit form, or saves changes and
* displays the overview page.
* Menu callback; displays the feed edit form.
*
* After editing, saves changes and displays the overview page.
*/
function aggregator_admin_edit_feed($feed = 0) {
$edit = $_POST['edit'];
......@@ -678,7 +679,7 @@ function aggregator_admin_edit_feed($feed = 0) {
}
/**
* Menu callback. Removes all items from a feed, then displays the overview page.
* Menu callback; removes all items from a feed, then displays the overview page.
*/
function aggregator_admin_remove_feed($feed) {
aggregator_remove(aggregator_get_feed($feed));
......@@ -686,7 +687,7 @@ function aggregator_admin_remove_feed($feed) {
}
/**
* Menu callback. Refreshes a feed, then displays the overview page.
* Menu callback; refreshes a feed, then displays the overview page.
*/
function aggregator_admin_refresh_feed($feed) {
aggregator_refresh(aggregator_get_feed($feed));
......@@ -694,21 +695,21 @@ function aggregator_admin_refresh_feed($feed) {
}
/**
* Menu callback. Displays the aggregator administration page.
* Menu callback; displays the aggregator administration page.
*/
function aggregator_admin_overview() {
print theme('page', aggregator_view());
}
/**
* Menu callback. Displays the most recent items gathered from any feed.
* Menu callback; displays the most recent items gathered from any feed.
*/
function aggregator_page_last() {
_aggregator_page_list('SELECT i.*, f.title AS ftitle, f.link AS flink FROM {aggregator_item} i INNER JOIN {aggregator_feed} f ON i.fid = f.fid ORDER BY i.timestamp DESC, i.iid DESC', arg(1));
}
/**
* Menu callback. Displays all the items captured from a particular feed.
* Menu callback; displays all the items captured from a particular feed.
*/
function aggregator_page_source() {
$feed = db_fetch_object(db_query('SELECT * FROM {aggregator_feed} WHERE fid = %d', arg(2)));
......@@ -718,7 +719,7 @@ function aggregator_page_source() {
}
/**
* Menu callback. Displays all the items aggregated in a particular category.
* Menu callback; displays all the items aggregated in a particular category.
*/
function aggregator_page_category() {
$category = db_fetch_object(db_query('SELECT cid, title FROM {aggregator_category} WHERE cid = %d', arg(2)));
......@@ -804,7 +805,7 @@ function _aggregator_page_list($sql, $op, $header = '') {
}
/**
* Menu callback. Displays all the feeds used by the aggregator.
* Menu callback; displays all the feeds used by the aggregator.
*/
function aggregator_page_sources() {
$result = db_query('SELECT f.fid, f.title, f.description, f.image, MAX(i.timestamp) AS last FROM {aggregator_feed} f LEFT JOIN {aggregator_item} i ON f.fid = i.fid GROUP BY fid');
......@@ -829,7 +830,7 @@ function aggregator_page_sources() {
}
/**
* Menu callback. Generates an OPML representation of all feeds.
* Menu callback; generates an OPML representation of all feeds.
*/
function aggregator_page_opml() {
$result = db_query('SELECT * FROM {aggregator_feed} ORDER BY title');
......@@ -854,7 +855,7 @@ function aggregator_page_opml() {
}
/**
* Menu callback. Displays all the categories used by the aggregator.
* Menu callback; displays all the categories used by the aggregator.
*/
function aggregator_page_categories() {
$result = db_query('SELECT c.cid, c.title, c.description FROM {aggregator_category} c LEFT JOIN {aggregator_category_item} ci ON c.cid = ci.cid LEFT JOIN {aggregator_item} i ON ci.iid = i.iid GROUP BY cid');
......
......@@ -208,7 +208,7 @@ function archive_link($type) {
}
/**
* Menu callback. Lists all nodes posted on a given date.
* Menu callback; lists all nodes posted on a given date.
*/
function archive_page($year = 0, $month = 0, $day = 0) {
global $user;
......
......@@ -208,7 +208,7 @@ function archive_link($type) {
}
/**
* Menu callback. Lists all nodes posted on a given date.
* Menu callback; lists all nodes posted on a given date.
*/
function archive_page($year = 0, $month = 0, $day = 0) {
global $user;
......
......@@ -48,7 +48,7 @@ function block_help($section) {
}
/**
* Menu callback. Presents the block-specific information from admin/help.
* Menu callback; presents the block-specific information from admin/help.
*/
function block_help_page() {
print theme('page', block_help('admin/help#block'));
......@@ -192,7 +192,7 @@ function block_admin_display() {
}
/**
* Menu callback. Displays the block layout as it will appear when themed.
* Menu callback; displays the block layout as it will appear when themed.
*/
function block_admin_preview() {
$result = db_query('SELECT * FROM {blocks} WHERE status > 0 AND region = 0 ORDER BY weight');
......@@ -251,8 +251,9 @@ function block_box_get($bid) {
}
/**
* Menu callback. Displays the block editing form, or saves changes and
* displays the block overview.
* Menu callback; displays the block editing form.
*
* On edit, saves changes and displays the block overview.
*/
function block_box_edit($bid = 0) {
$edit = $_POST['edit'];
......@@ -310,7 +311,7 @@ function block_box_save($edit) {
}
/**
* Menu callback. Deletes a custom box, then displays the overview page.
* Menu callback; deletes a custom box, then displays the overview page.
*/
function block_box_delete($bid = 0) {
if ($bid) {
......@@ -322,7 +323,7 @@ function block_box_delete($bid = 0) {
}
/**
* Menu callback. Displays the block overview page.
* Menu callback; displays the block overview page.
*/
function block_admin() {
$edit = $_POST['edit'];
......
......@@ -48,7 +48,7 @@ function block_help($section) {
}
/**
* Menu callback. Presents the block-specific information from admin/help.
* Menu callback; presents the block-specific information from admin/help.
*/
function block_help_page() {
print theme('page', block_help('admin/help#block'));
......@@ -192,7 +192,7 @@ function block_admin_display() {
}
/**
* Menu callback. Displays the block layout as it will appear when themed.
* Menu callback; displays the block layout as it will appear when themed.
*/
function block_admin_preview() {
$result = db_query('SELECT * FROM {blocks} WHERE status > 0 AND region = 0 ORDER BY weight');
......@@ -251,8 +251,9 @@ function block_box_get($bid) {
}
/**
* Menu callback. Displays the block editing form, or saves changes and
* displays the block overview.
* Menu callback; displays the block editing form.
*
* On edit, saves changes and displays the block overview.
*/
function block_box_edit($bid = 0) {
$edit = $_POST['edit'];
......@@ -310,7 +311,7 @@ function block_box_save($edit) {
}
/**
* Menu callback. Deletes a custom box, then displays the overview page.
* Menu callback; deletes a custom box, then displays the overview page.
*/
function block_box_delete($bid = 0) {
if ($bid) {
......@@ -322,7 +323,7 @@ function block_box_delete($bid = 0) {
}
/**
* Menu callback. Displays the block overview page.
* Menu callback; displays the block overview page.
*/
function block_admin() {
$edit = $_POST['edit'];
......
......@@ -80,7 +80,7 @@ function blog_help($section) {
}
/**
* Menu callback. Displays an RSS feed containing recent blog entries.
* Menu callback; displays an RSS feed containing recent blog entries.
*/
function blog_feed($uid = 0) {
if ($uid) {
......@@ -123,7 +123,7 @@ function blog_feed_last() {
}
/**
* Menu callback. Displays a Drupal page containing recent blog entries.
* Menu callback; displays a Drupal page containing recent blog entries.
*/
function blog_page($uid = 0) {
if ($uid) {
......
......@@ -80,7 +80,7 @@ function blog_help($section) {
}
/**
* Menu callback. Displays an RSS feed containing recent blog entries.
* Menu callback; displays an RSS feed containing recent blog entries.
*/
function blog_feed($uid = 0) {
if ($uid) {
......@@ -123,7 +123,7 @@ function blog_feed_last() {
}
/**
* Menu callback. Displays a Drupal page containing recent blog entries.
* Menu callback; displays a Drupal page containing recent blog entries.
*/
function blog_page($uid = 0) {
if ($uid) {
......
......@@ -679,7 +679,7 @@ function book_tree($parent = 0, $depth = 3, $unfold = array()) {
}
/**
* Menu callback. Prints a listing of all books.
* Menu callback; prints a listing of all books.
*/
function book_render() {
......@@ -705,7 +705,7 @@ function book_render() {
}
/**
* Menu callback. Prints a node as a book page, complete with navigation.
* Menu callback; prints a node as a book page, complete with navigation.
*/
function book_view_page($nid = 0, $cid = 0) {
$node = node_load(array('nid' => $nid));
......@@ -714,7 +714,7 @@ function book_view_page($nid = 0, $cid = 0) {
}
/**
* Menu callback. Generates printer-friendly book page will all descendants.
* Menu callback; generates printer-friendly book page will all descendants.
*/
function book_print($nid = 0, $depth = 1) {
global $base_url;
......@@ -845,7 +845,7 @@ function book_admin_save($nid, $edit = array()) {
}
/**
* Menu callback. Displays a listing of all orphaned book pages.
* Menu callback; displays a listing of all orphaned book pages.
*/
function book_admin_orphan() {
$result = db_query("SELECT n.nid, n.title, n.status, b.parent FROM {node} n INNER JOIN {book} b ON n.nid = b.nid");
......@@ -870,9 +870,9 @@ function book_admin_orphan() {
}
/**
* Menu callback. Displays the book administration page.
* Menu callback; displays the book administration page.
*/
function book_admin($nid) {
function book_admin($nid = 0) {
$op = $_POST["op"];
$edit = $_POST["edit"];
......
......@@ -679,7 +679,7 @@ function book_tree($parent = 0, $depth = 3, $unfold = array()) {
}
/**
* Menu callback. Prints a listing of all books.
* Menu callback; prints a listing of all books.
*/
function book_render() {
......@@ -705,7 +705,7 @@ function book_render() {
}
/**
* Menu callback. Prints a node as a book page, complete with navigation.
* Menu callback; prints a node as a book page, complete with navigation.
*/
function book_view_page($nid = 0, $cid = 0) {
$node = node_load(array('nid' => $nid));
......@@ -714,7 +714,7 @@ function book_view_page($nid = 0, $cid = 0) {
}
/**
* Menu callback. Generates printer-friendly book page will all descendants.
* Menu callback; generates printer-friendly book page will all descendants.
*/
function book_print($nid = 0, $depth = 1) {
global $base_url;
......@@ -845,7 +845,7 @@ function book_admin_save($nid, $edit = array()) {
}
/**
* Menu callback. Displays a listing of all orphaned book pages.
* Menu callback; displays a listing of all orphaned book pages.
*/
function book_admin_orphan() {
$result = db_query("SELECT n.nid, n.title, n.status, b.parent FROM {node} n INNER JOIN {book} b ON n.nid = b.nid");
......@@ -870,9 +870,9 @@ function book_admin_orphan() {
}
/**
* Menu callback. Displays the book administration page.
* Menu callback; displays the book administration page.
*/
function book_admin($nid) {
function book_admin($nid = 0) {
$op = $_POST["op"];
$edit = $_POST["edit"];
......
<?php
// $Id$
function drupal_help($section = "admin/help#drupal") {
/**
* Implementation of hook_help().
*/
function drupal_help($section) {
switch ($section) {
case 'admin/help#drupal':
return t("
......@@ -10,62 +12,59 @@ function drupal_help($section = "admin/help#drupal") {
<p>Currently, the main application of this feature is the <a href=\"%drupal-sites\">Drupal sites</a> page. By default, fresh Drupal installations can use <a href=\"%Drupal\">drupal.org</a> as their <em>directory server</em> and report their existence. This reporting occurs via scheduled <a href=\"%xml-rpc\">XML-RPC</a> pings.</p>
<p>Drupal administrators should simply enable this feature to get listed on the <a href=\"%drupal-sites\">Drupal sites</a> page. Just set your site's name, e-mail address, slogan and mission statement on the <a href=\"%site-admin\">site administration</a> page. Then make sure that the field called <em>Drupal XML-RPC server</em> on the <a href=\"%drupal-settings\">administer &raquo; configuration &raquo; modules &raquo; drupal</a> page is set to %drupal-xml-rpc, and enable this feature using the dropdown directly below.</p>
<p>The listing of your site will occur shortly after your site's next <a href=\"%cron-run\">cron run</a>. Note that cron.php should be called using the domain name which you want to have listed at <a href=\"%Drupal\">drupal.org</a>. For example, don't kick off cron by requesting http://127.0.0.1/cron.php. Instead, use a publicly accessible domain name such as http://www.example.com/cron.php.</p>
<p>Also note that your installation need not use drupal.org as its directory server. For example, this feature is perfectly capable of aggregating pings from all of your departmental drupal installations sites within an enterprise.</p>", array("%drupal-sites" => "http://www.drupal.org/sites", "%Drupal" => "http://www.drupal.org", "%drupal-xml-rpc" => "http://www.drupal.org/xmlrpc.php", "%xml-rpc" => "http://www.xmlrpc.com/", "%site-admin" => url("admin/system"), "%drupal-settings" => url("admin/system/modules/drupal"), "%cron" => url("admin/system/help#cron")));
break;
<p>Also note that your installation need not use drupal.org as its directory server. For example, this feature is perfectly capable of aggregating pings from all of your departmental drupal installations sites within an enterprise.</p>", array('%drupal-sites' => 'http://www.drupal.org/sites', '%Drupal' => 'http://www.drupal.org', '%drupal-xml-rpc' => 'http://www.drupal.org/xmlrpc.php', '%xml-rpc' => 'http://www.xmlrpc.com/', '%site-admin' => url('admin/system'), '%drupal-settings' => url('admin/system/modules/drupal'), '%cron' => url('admin/system/help#cron')));
case 'admin/system/modules#description':
return t("Lets users log in using a Drupal ID and can notify a central server about your site.");
break;
return t('Lets users log in using a Drupal ID and can notify a central server about your site.');
case 'admin/system/modules/drupal':
return t("Using this your Drupal site can \"call home\" and add itself to the Drupal directory. If you want it to add itself to a different directory server you can change the <a href=\"%xml-rpc-setting\">Drupal XML-RPC server</a> setting -- but the directory server has to be able to handle Drupal XML. To get all your site information listed go to the <a href=\"%site-admin\">site configuration</a> page and set the site name, the e-mail address, the slogan, and the mission statement.", array("%xml-rpc-setting" => url("admin/system/modules/drupal"), "%site-admin" => url("admin/system")));
break;
return t("Using this your Drupal site can \"call home\" and add itself to the Drupal directory. If you want it to add itself to a different directory server you can change the <a href=\"%xml-rpc-setting\">Drupal XML-RPC server</a> setting -- but the directory server has to be able to handle Drupal XML. To get all your site information listed go to the <a href=\"%site-admin\">site configuration</a> page and set the site name, the e-mail address, the slogan, and the mission statement.", array('%xml-rpc-setting' => url('admin/system/modules/drupal'), '%site-admin' => url('admin/system')));
case 'user/help#drupal':
return t("<p><a href=\"%Drupal\">Drupal</a> is the name of the software which powers %this-site. There are Drupal web sites 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 <strong>Drupal ID</strong>.</p>
<p>So please feel free to login to your account here at %this-site with a username from another Drupal site. The format of a Drupal ID is similar to an email address: <strong>username</strong>@<em>server</em>. An example of a valid Drupal ID is <strong>mwlily</strong>@<em>www.drupal.org</em>.</p>", array("%Drupal" => "http://www.drupal.org", "%this-site" => "<em>". variable_get("site_name", "this web site") ."</em>"));
break;
<p>So please feel free to login to your account here at %this-site with a username from another Drupal site. The format of a Drupal ID is similar to an email address: <strong>username</strong>@<em>server</em>. An example of a valid Drupal ID is <strong>mwlily</strong>@<em>www.drupal.org</em>.</p>", array('%Drupal' => 'http://www.drupal.org', '%this-site' => '<em>'. variable_get('site_name', 'this web site') .'</em>'));
}
return $output;
}
/**
* Implementation of hook_settings().
*/
function drupal_settings() {
// Check if all required fields are present for the Drupal directory
if ((variable_get("site_name", "drupal") == "drupal") || (variable_get("site_name", "drupal") == ""))
$error["drupal_directory"] = theme("error", t("You must set your site's name at the <a href=\"%url\">site configuration</a>.", array("%url" => url("admin/system"))));
else if (variable_get("site_mail", ini_get("sendmail_from")) == "")
$error["drupal_directory"] = theme("error", t("You must set your site's e-mail address at the <a href=\"%url\">site configuration</a>.", array("%url" => url("admin/system"))));
else if (variable_get("site_slogan", "") == "")
$error["drupal_directory"] = theme("error", t("You must set your site's slogan at the <a href=\"%url\">site configuration</a>.", array("%url" => url("admin/system"))));
else if (variable_get("site_mission", "") == "")
$error["drupal_directory"] = theme("error", t("You must set your site's mission at the <a href=\"%url\">site configuration</a>.", array("%url" => url("admin/system"))));
$output = form_textfield(t("Drupal XML-RPC server"), "drupal_server", variable_get("drupal_server", "http://www.drupal.org/xmlrpc.php"), 55, 128, t("The URL of your root Drupal XML-RPC server."));
$output .= form_radios(t("Drupal directory"), "drupal_directory", variable_get("drupal_directory", 0), array(t("Disabled"), t("Enabled")), t("If enabled, your Drupal site will make itself known to the Drupal directory at the specified Drupal XML-RPC server. For this to work properly, you must set your site's name, e-mail address, slogan and mission statement. When the \"Drupal XML-RPC server\" field is set to \"%drupal-xml-rpc\", your web site will get listed on the <a href=\"%drupal-sites\">Drupal sites</a> page. Requires the cron feature to be enabled.", array("%drupal-xml-rpc" => "http://www.drupal.org/xmlrpc.php")) . $error["drupal_directory"]);
if ((variable_get('site_name', 'drupal') == 'drupal') || (variable_get('site_name', 'drupal') == ''))
$error['drupal_directory'] = theme('error', t("You must set your site's name at the <a href=\"%url\">site configuration</a>.", array('%url' => url('admin/system'))));
else if (variable_get('site_mail', ini_get('sendmail_from')) == '')
$error['drupal_directory'] = theme('error', t("You must set your site's e-mail address at the <a href=\"%url\">site configuration</a>.", array('%url' => url('admin/system'))));
else if (variable_get('site_slogan', '') == '')
$error['drupal_directory'] = theme('error', t("You must set your site's slogan at the <a href=\"%url\">site configuration</a>.", array('%url' => url('admin/system'))));
else if (variable_get('site_mission', '') == '')
$error['drupal_directory'] = theme('error', t("You must set your site's mission at the <a href=\"%url\">site configuration</a>.", array('%url' => url('admin/system'))));
$output = form_textfield(t('Drupal XML-RPC server'), 'drupal_server', variable_get('drupal_server', 'http://www.drupal.org/xmlrpc.php'), 55, 128, t('The URL of your root Drupal XML-RPC server.'));
$output .= form_radios(t('Drupal directory'), 'drupal_directory', variable_get('drupal_directory', 0), array(t('Disabled'), t('Enabled')), t("If enabled, your Drupal site will make itself known to the Drupal directory at the specified Drupal XML-RPC server. For this to work properly, you must set your site's name, e-mail address, slogan and mission statement. When the \"Drupal XML-RPC server\" field is set to \"%drupal-xml-rpc\", your web site will get listed on the <a href=\"%drupal-sites\">Drupal sites</a> page. Requires the cron feature to be enabled.", array('%drupal-xml-rpc' => 'http://www.drupal.org/xmlrpc.php')) . $error['drupal_directory']);
return $output;
}
/**
* Implementation of hook_cron(); handles pings to and from the site.
*/
function drupal_cron() {
if (time() - variable_get("drupal_cron_last", 0) > 21600) {
variable_set("drupal_cron_last", time());
/*
** If this site acts as a Drupal XML-RPC server, delete the sites that
** stopped sending "ping" messages.
*/
if (time() - variable_get('drupal_cron_last', 0) > 21600) {
variable_set('drupal_cron_last', time());
// If this site acts as a Drupal XML-RPC server, delete the sites that
// stopped sending "ping" messages.
db_query("DELETE FROM {directory} WHERE timestamp < '". (time() - 259200) ."'");
/*
** If this site acts as a Drupal XML-RPC client, send a message to the
** Drupal XML-RPC server.
*/
if (variable_get("drupal_directory", 0) && variable_get("drupal_server", 0)) {
drupal_notify(variable_get("drupal_server", ""));
// If this site acts as a Drupal XML-RPC client, send a message to the
// Drupal XML-RPC server.
if (variable_get('drupal_directory', 0) && variable_get('drupal_server', 0)) {
drupal_notify(variable_get('drupal_server', ''));
}
}
}
/**
* Callback function from drupal_xmlrpc() called when another site pings this one.
*/
function drupal_directory_ping($arguments) {
/*
......@@ -91,18 +90,24 @@ function drupal_directory_ping($arguments) {
db_query("DELETE FROM {directory} WHERE link = '%s' OR mail = '%s'", $link, $mail);
db_query("INSERT INTO {directory} (link, name, mail, slogan, mission, timestamp) VALUES ('%s', '%s', '%s', '%s', '%s', %d)", $link, $name, $mail, $slogan, $mission, time());
watchdog("regular", "directory: ping from '$name' ($link)");
watchdog('regular', "directory: ping from \"$name\" ($link)");
return new xmlrpcresp(new xmlrpcval(1, "int"));
return new xmlrpcresp(new xmlrpcval(1, 'int'));
}
else {
return new xmlrpcresp(new xmlrpcval(0, "int"));
return new xmlrpcresp(new xmlrpcval(0, 'int'));
}
}
/**
* Formats a list of all sites indexed in the ddirectory.
*
* This function may be called from a custom page on sites that are
* Drupal directory servers.
*/
function drupal_directory_page() {
$result = db_query("SELECT * FROM {directory} ORDER BY name");
$result = db_query('SELECT * FROM {directory} ORDER BY name');
while ($site = db_fetch_object($result)) {
$output .= "<a href=\"$site->link\">$site->name</a> - $site->slogan<div style=\"padding-left: 20px;\">$site->mission</div><br />";
......@@ -111,30 +116,39 @@ function drupal_directory_page() {
return $output;
}
/**
* Implementation of hook_xmlrpc().
*/
function drupal_xmlrpc() {
return array("drupal.site.ping" => array("function" => "drupal_directory_ping"), "drupal.login" => array("function" => "drupal_login"));
return array('drupal.site.ping' => array('function' => 'drupal_directory_ping'), 'drupal.login' => array('function' => 'drupal_login'));
}
/**
* Sends a ping to the Drupal directory server.
*/
function drupal_notify($server) {
global $base_url;
$url = parse_url($server);
$client = new xmlrpc_client($url["path"], $url["host"], 80);
$client = new xmlrpc_client($url['path'], $url['host'], 80);
$message = new xmlrpcmsg("drupal.site.ping", array(new xmlrpcval($base_url, "string"), new xmlrpcval(variable_get("site_name", ""), "string"), new xmlrpcval(variable_get("site_mail", ""), "string"), new xmlrpcval(variable_get("site_slogan", ""), "string"), new xmlrpcval(variable_get("site_mission", ""), "string")));
$message = new xmlrpcmsg('drupal.site.ping', array(new xmlrpcval($base_url, 'string'), new xmlrpcval(variable_get('site_name', ''), 'string'), new xmlrpcval(variable_get('site_mail', ''), 'string'), new xmlrpcval(variable_get('site_slogan', ''), 'string'), new xmlrpcval(variable_get('site_mission', ''), 'string')));