From e52c0f5d41ad9319c9420bbe3a9dcfa76a90222f Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Mon, 17 May 2004 22:00:06 +0000 Subject: - Code improvements by JonBob. Thanks. --- modules/admin.module | 7 +- modules/aggregator.module | 27 ++--- modules/aggregator/aggregator.module | 27 ++--- modules/archive.module | 2 +- modules/archive/archive.module | 2 +- modules/block.module | 13 +-- modules/block/block.module | 13 +-- modules/blog.module | 4 +- modules/blog/blog.module | 4 +- modules/book.module | 12 +-- modules/book/book.module | 12 +-- modules/drupal.module | 136 ++++++++++++++---------- modules/drupal/drupal.module | 136 ++++++++++++++---------- modules/filter.module | 197 ++++++++++++++++++----------------- modules/filter/filter.module | 197 ++++++++++++++++++----------------- modules/forum.module | 2 +- modules/forum/forum.module | 2 +- modules/help.module | 56 +++++----- modules/help/help.module | 56 +++++----- modules/statistics.module | 8 +- modules/statistics/statistics.module | 8 +- 21 files changed, 497 insertions(+), 424 deletions(-) (limited to 'modules') diff --git a/modules/admin.module b/modules/admin.module index 8c9c97e01..276a63a2e 100644 --- a/modules/admin.module +++ b/modules/admin.module @@ -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")); } diff --git a/modules/aggregator.module b/modules/aggregator.module index 707bf0fee..62e131a78 100644 --- a/modules/aggregator.module +++ b/modules/aggregator.module @@ -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'); diff --git a/modules/aggregator/aggregator.module b/modules/aggregator/aggregator.module index 707bf0fee..62e131a78 100644 --- a/modules/aggregator/aggregator.module +++ b/modules/aggregator/aggregator.module @@ -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'); diff --git a/modules/archive.module b/modules/archive.module index cf0e99157..15825ec25 100644 --- a/modules/archive.module +++ b/modules/archive.module @@ -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; diff --git a/modules/archive/archive.module b/modules/archive/archive.module index cf0e99157..15825ec25 100644 --- a/modules/archive/archive.module +++ b/modules/archive/archive.module @@ -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; diff --git a/modules/block.module b/modules/block.module index 1921193b6..17137ec89 100644 --- a/modules/block.module +++ b/modules/block.module @@ -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']; diff --git a/modules/block/block.module b/modules/block/block.module index 1921193b6..17137ec89 100644 --- a/modules/block/block.module +++ b/modules/block/block.module @@ -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']; diff --git a/modules/blog.module b/modules/blog.module index 775b1f581..a6737a8d6 100644 --- a/modules/blog.module +++ b/modules/blog.module @@ -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) { diff --git a/modules/blog/blog.module b/modules/blog/blog.module index 775b1f581..a6737a8d6 100644 --- a/modules/blog/blog.module +++ b/modules/blog/blog.module @@ -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) { diff --git a/modules/book.module b/modules/book.module index 7658a9251..f499db81c 100644 --- a/modules/book.module +++ b/modules/book.module @@ -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"]; diff --git a/modules/book/book.module b/modules/book/book.module index 7658a9251..f499db81c 100644 --- a/modules/book/book.module +++ b/modules/book/book.module @@ -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"]; diff --git a/modules/drupal.module b/modules/drupal.module index 084fb96d1..526e9aefa 100644 --- a/modules/drupal.module +++ b/modules/drupal.module @@ -1,8 +1,10 @@ Currently, the main application of this feature is the Drupal sites page. By default, fresh Drupal installations can use drupal.org as their directory server and report their existence. This reporting occurs via scheduled XML-RPC pings.

Drupal administrators should simply enable this feature to get listed on the Drupal sites page. Just set your site's name, e-mail address, slogan and mission statement on the site administration page. Then make sure that the field called Drupal XML-RPC server on the administer » configuration » modules » drupal page is set to %drupal-xml-rpc, and enable this feature using the dropdown directly below.

The listing of your site will occur shortly after your site's next cron run. Note that cron.php should be called using the domain name which you want to have listed at drupal.org. 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.

-

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.

", 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; +

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.

", 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 Drupal XML-RPC server setting -- but the directory server has to be able to handle Drupal XML. To get all your site information listed go to the site configuration 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 Drupal XML-RPC server setting -- but the directory server has to be able to handle Drupal XML. To get all your site information listed go to the site configuration 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("

Drupal 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 Drupal ID.

-

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: username@server. An example of a valid Drupal ID is mwlily@www.drupal.org.

", array("%Drupal" => "http://www.drupal.org", "%this-site" => "". variable_get("site_name", "this web site") ."")); - break; +

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: username@server. An example of a valid Drupal ID is mwlily@www.drupal.org.

", array('%Drupal' => 'http://www.drupal.org', '%this-site' => ''. variable_get('site_name', 'this web site') .'')); } - - 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 site configuration.", 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 site configuration.", 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 site configuration.", 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 site configuration.", 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 Drupal sites 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 site configuration.", 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 site configuration.", 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 site configuration.", 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 site configuration.", 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 Drupal sites 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 .= "link\">$site->name - $site->slogan
$site->mission

"; @@ -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'))); $result = $client->send($message, 5); if (!$result || $result->faultCode()) { - watchdog("error", "failed to notify '". $url["host"] ."' at '". $url["path"] ."': ". $result->faultString()); + watchdog('error', 'failed to notify "'. $url['host'] .'" at "'. $url['path'] .'": '. $result->faultString()); } } +/** + * Implementation of hook_info(). + */ function drupal_info($field = 0) { - $info["name"] = "Drupal"; - $info["protocol"] = "XML-RPC"; + $info['name'] = 'Drupal'; + $info['protocol'] = 'XML-RPC'; if ($field) { return $info[$field]; @@ -144,13 +158,16 @@ function drupal_info($field = 0) { } } +/** + * Implementation of hook_auth(). + */ function drupal_auth($username, $password, $server) { - $message = new xmlrpcmsg("drupal.login", array(new xmlrpcval($username, "string"), new xmlrpcval($password, "string"))); + $message = new xmlrpcmsg('drupal.login', array(new xmlrpcval($username, 'string'), new xmlrpcval($password, 'string'))); // TODO remove hard coded Port 80 // TODO manage server/path such that HTTP_HOST/xml.rpc.php is not assumed - $client = new xmlrpc_client("/xmlrpc.php", $server, 80); + $client = new xmlrpc_client('/xmlrpc.php', $server, 80); $result = $client->send($message, 5); if ($result && !$result->faultCode()) { $value = $result->value(); @@ -165,26 +182,33 @@ function drupal_auth($username, $password, $server) { */ function drupal_link($type) { if ($type == 'system') { - menu('drupal', t('Drupal'), 'drupal_page', 0, MENU_HIDE); + menu('drupal', t('Drupal'), 'drupal_page_help', 0, MENU_HIDE); } } -function drupal_page() { - print theme("page", drupal_help("user/help#drupal"), t("Drupal")); +/** + * Menu callback; print Drupal-authentication-specific information from user/help. + */ +function drupal_page_help() { + print theme('page', drupal_help('user/help#drupal'), t('Drupal')); } +/** + * Callback function from drupal_xmlrpc() for authenticating remote clients. + * + * Remote clients are usually other Drupal instances. + */ 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")); + 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")); + return new xmlrpcresp(new xmlrpcval(0, 'int')); } } diff --git a/modules/drupal/drupal.module b/modules/drupal/drupal.module index 084fb96d1..526e9aefa 100644 --- a/modules/drupal/drupal.module +++ b/modules/drupal/drupal.module @@ -1,8 +1,10 @@ Currently, the main application of this feature is the Drupal sites page. By default, fresh Drupal installations can use drupal.org as their directory server and report their existence. This reporting occurs via scheduled XML-RPC pings.

Drupal administrators should simply enable this feature to get listed on the Drupal sites page. Just set your site's name, e-mail address, slogan and mission statement on the site administration page. Then make sure that the field called Drupal XML-RPC server on the administer » configuration » modules » drupal page is set to %drupal-xml-rpc, and enable this feature using the dropdown directly below.

The listing of your site will occur shortly after your site's next cron run. Note that cron.php should be called using the domain name which you want to have listed at drupal.org. 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.

-

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.

", 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; +

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.

", 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 Drupal XML-RPC server setting -- but the directory server has to be able to handle Drupal XML. To get all your site information listed go to the site configuration 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 Drupal XML-RPC server setting -- but the directory server has to be able to handle Drupal XML. To get all your site information listed go to the site configuration 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("

Drupal 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 Drupal ID.

-

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: username@server. An example of a valid Drupal ID is mwlily@www.drupal.org.

", array("%Drupal" => "http://www.drupal.org", "%this-site" => "". variable_get("site_name", "this web site") ."")); - break; +

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: username@server. An example of a valid Drupal ID is mwlily@www.drupal.org.

", array('%Drupal' => 'http://www.drupal.org', '%this-site' => ''. variable_get('site_name', 'this web site') .'')); } - - 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 site configuration.", 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 site configuration.", 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 site configuration.", 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 site configuration.", 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 Drupal sites 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 site configuration.", 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 site configuration.", 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 site configuration.", 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 site configuration.", 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 Drupal sites 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 .= "link\">$site->name - $site->slogan
$site->mission

"; @@ -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'))); $result = $client->send($message, 5); if (!$result || $result->faultCode()) { - watchdog("error", "failed to notify '". $url["host"] ."' at '". $url["path"] ."': ". $result->faultString()); + watchdog('error', 'failed to notify "'. $url['host'] .'" at "'. $url['path'] .'": '. $result->faultString()); } } +/** + * Implementation of hook_info(). + */ function drupal_info($field = 0) { - $info["name"] = "Drupal"; - $info["protocol"] = "XML-RPC"; + $info['name'] = 'Drupal'; + $info['protocol'] = 'XML-RPC'; if ($field) { return $info[$field]; @@ -144,13 +158,16 @@ function drupal_info($field = 0) { } } +/** + * Implementation of hook_auth(). + */ function drupal_auth($username, $password, $server) { - $message = new xmlrpcmsg("drupal.login", array(new xmlrpcval($username, "string"), new xmlrpcval($password, "string"))); + $message = new xmlrpcmsg('drupal.login', array(new xmlrpcval($username, 'string'), new xmlrpcval($password, 'string'))); // TODO remove hard coded Port 80 // TODO manage server/path such that HTTP_HOST/xml.rpc.php is not assumed - $client = new xmlrpc_client("/xmlrpc.php", $server, 80); + $client = new xmlrpc_client('/xmlrpc.php', $server, 80); $result = $client->send($message, 5); if ($result && !$result->faultCode()) { $value = $result->value(); @@ -165,26 +182,33 @@ function drupal_auth($username, $password, $server) { */ function drupal_link($type) { if ($type == 'system') { - menu('drupal', t('Drupal'), 'drupal_page', 0, MENU_HIDE); + menu('drupal', t('Drupal'), 'drupal_page_help', 0, MENU_HIDE); } } -function drupal_page() { - print theme("page", drupal_help("user/help#drupal"), t("Drupal")); +/** + * Menu callback; print Drupal-authentication-specific information from user/help. + */ +function drupal_page_help() { + print theme('page', drupal_help('user/help#drupal'), t('Drupal')); } +/** + * Callback function from drupal_xmlrpc() for authenticating remote clients. + * + * Remote clients are usually other Drupal instances. + */ 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")); + 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")); + return new xmlrpcresp(new xmlrpcval(0, 'int')); } } diff --git a/modules/filter.module b/modules/filter.module index 7d32bb3d1..0221d35e7 100644 --- a/modules/filter.module +++ b/modules/filter.module @@ -8,33 +8,36 @@ define('FILTER_HTML_ESCAPE', 2); define('FILTER_STYLE_ALLOW', 0); define('FILTER_STYLE_STRIP', 1); -function filter_help($section = "admin/help#filter") { +/** + * Implementation of hook_help(). + */ +function filter_help($section) { switch ($section) { case 'admin/system/modules#description': - return t("Framework for handling filtering of content."); + return t('Framework for handling filtering of content.'); case 'admin/system/filters': return t("

Filters fit between the raw text in a node and the HTML output. They allow you to replace text selectively. Uses include automatic conversion of emoticons into graphics and filtering HTML content from users' submissions.

-

If you notice some filters are causing conflicts in the output, you can rearrange them.

", array("%url" => url("admin/system/filters/order"))); +

If you notice some filters are causing conflicts in the output, you can rearrange them.

", array('%url' => url('admin/system/filters/order'))); case 'admin/system/filters/order': return t("

Because of the flexible filtering system, you might encounter a situation where one filter prevents another from doing its job. For example: a word in an URL gets converted into a glossary term, before the URL can be converted in a clickable link. When this happens, you will need to rearrange the order in which filters get executed.

Filters are executed from top-to-bottom. You can use the weight column to rearrange them: heavier filters 'sink' to the bottom. Standard HTML filtering is always run first.

"); case 'filter#long-tip': case 'filter#short-tip': - switch (variable_get("filter_html", FILTER_HTML_DONOTHING)) { + switch (variable_get('filter_html', FILTER_HTML_DONOTHING)) { case 0: - return t("All HTML tags allowed"); + return t('All HTML tags allowed'); break; case 1: - if ($allowed_html = variable_get("allowed_html", "