From 20397ad3d9dad39670ed92923d2513bd89c7b0bb Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sun, 20 May 2001 13:51:40 +0000 Subject: CHANGES - Redid settings.module and even renamed it to conf.module. * Settings are now grouped in basic categories like "system settings", "module settings" and "filters". * Added new settings to make Drupal easier to configure and to make some aspects like the watchdog scale better. - Renamed includes/settings.php to includes/conf.php. - Added filter support to conf.module and introduced filter hooks so modules can implement and export new filters. Example filters are an HTML filter (implemented), a profanity filter, an url converter, ASCII smileys to images filter and so on ... - Reworked the check_* functions: user contributed content/input is only verified and filtered once in its lifespan. NOTES - Altough this is a large commit, no database changes are required. --- modules/book.module | 8 +-- modules/book/book.module | 8 +-- modules/box.module | 6 +- modules/conf.module | 133 +++++++++++++++++++++++++++++++++++++++ modules/cvs.module | 2 +- modules/diary.module | 18 +++--- modules/headline.module | 2 +- modules/locale.module | 6 +- modules/locale/locale.module | 6 +- modules/node.module | 25 +++++++- modules/node/node.module | 25 +++++++- modules/poll.module | 6 +- modules/poll/poll.module | 6 +- modules/rating.module | 2 +- modules/settings.module | 116 ---------------------------------- modules/story.module | 10 +-- modules/story/story.module | 10 +-- modules/watchdog.module | 2 +- modules/watchdog/watchdog.module | 2 +- 19 files changed, 230 insertions(+), 163 deletions(-) create mode 100644 modules/conf.module delete mode 100644 modules/settings.module (limited to 'modules') diff --git a/modules/book.module b/modules/book.module index 887f9f8f1..c46e7cd0d 100644 --- a/modules/book.module +++ b/modules/book.module @@ -101,7 +101,7 @@ function book_toc($parent = "", $indent = "", $toc = array()) { } function book_form($edit = array()) { - global $allowed_html, $REQUEST_URI, $user; + global $REQUEST_URI, $user; $form .= form_item(t("Author"), format_username(($edit[userid] ? $edit[userid] : $user->userid))); $form .= form_hidden(userid, $edit[userid]); @@ -117,7 +117,7 @@ function book_form($edit = array()) { $form .= form_select(t("Parent"), "parent", $edit[parent], book_toc(), t("The parent subject or category the page belongs in.")); } - $form .= form_textarea(t("Content"), "body", $edit[body], 50, 10, t("Allowed HTML tags") .": ". htmlspecialchars($allowed_html)); + $form .= form_textarea(t("Content"), "body", $edit[body], 50, 10, t("Allowed HTML tags") .": ". htmlspecialchars(variable_get("allowed_html", ""))); $form .= form_textarea(t("Log message"), "log", $edit[log], 50, 5, t("An explanation of the additions or updates being made to help the group understand your motivations.")); if (user_access($user, "book")) { @@ -218,7 +218,7 @@ function book_admin() { print book_tree(); break; case t("Preview"): - book_view(new Book($edit)); + book_view(new Book(node_preview($edit))); print book_form($edit); break; case t("Submit"): @@ -269,7 +269,7 @@ function book_user() { $theme->box($title, book_update($id)); break; case t("Preview"): - book_view(new Book($edit)); + book_view(new Book(node_preview($edit))); $theme->box($title, book_form($edit)); break; case t("Submit"): diff --git a/modules/book/book.module b/modules/book/book.module index 887f9f8f1..c46e7cd0d 100644 --- a/modules/book/book.module +++ b/modules/book/book.module @@ -101,7 +101,7 @@ function book_toc($parent = "", $indent = "", $toc = array()) { } function book_form($edit = array()) { - global $allowed_html, $REQUEST_URI, $user; + global $REQUEST_URI, $user; $form .= form_item(t("Author"), format_username(($edit[userid] ? $edit[userid] : $user->userid))); $form .= form_hidden(userid, $edit[userid]); @@ -117,7 +117,7 @@ function book_form($edit = array()) { $form .= form_select(t("Parent"), "parent", $edit[parent], book_toc(), t("The parent subject or category the page belongs in.")); } - $form .= form_textarea(t("Content"), "body", $edit[body], 50, 10, t("Allowed HTML tags") .": ". htmlspecialchars($allowed_html)); + $form .= form_textarea(t("Content"), "body", $edit[body], 50, 10, t("Allowed HTML tags") .": ". htmlspecialchars(variable_get("allowed_html", ""))); $form .= form_textarea(t("Log message"), "log", $edit[log], 50, 5, t("An explanation of the additions or updates being made to help the group understand your motivations.")); if (user_access($user, "book")) { @@ -218,7 +218,7 @@ function book_admin() { print book_tree(); break; case t("Preview"): - book_view(new Book($edit)); + book_view(new Book(node_preview($edit))); print book_form($edit); break; case t("Submit"): @@ -269,7 +269,7 @@ function book_user() { $theme->box($title, book_update($id)); break; case t("Preview"): - book_view(new Book($edit)); + book_view(new Book(node_preview($edit))); $theme->box($title, book_form($edit)); break; case t("Submit"): diff --git a/modules/box.module b/modules/box.module index 5edc748ac..5ae9aa538 100644 --- a/modules/box.module +++ b/modules/box.module @@ -104,7 +104,7 @@ function box_admin_edit($id) { $output .= "

\n"; $output .= " Subject:
\n"; - $output .= " subject) ."\">\n"; + $output .= " subject) ."\">\n"; $output .= "

\n"; $output .= "

\n"; $output .= " Content:
\n"; @@ -120,11 +120,11 @@ function box_admin_edit($id) { $output .= "

\n"; $output .= "

\n"; $output .= " Description:
\n"; - $output .= " info) ."\">\n"; + $output .= " info) ."\">\n"; $output .= "

\n"; $output .= "

\n"; $output .= " Link:
\n"; - $output .= " link) ."\">\n"; + $output .= " link) ."\">\n"; $output .= "

\n"; $output .= "

\n"; $output .= " \n"; diff --git a/modules/conf.module b/modules/conf.module new file mode 100644 index 000000000..a1d4eaaa2 --- /dev/null +++ b/modules/conf.module @@ -0,0 +1,133 @@ + +

Drupal comes with system-wide defaults but the setting-module provides control over many Drupal preferences, behaviors including visual and operational conf.

+

Cron

+

Some conf require a cron or crontab. Cron (which stands for chronograph) is a periodic command scheduler: it executes commands at intervals specified in seconds. It can be used to control the execution of daily, weekly and monthly jobs (or anything with a period of n seconds). Automating tasks is one of the best ways to keep a system running smoothly, and if most of your administration does not require your direct involvement, cron is an ideal solution.

+

Whenever cron.php is accessed, cron will run: it checks for the jobs cron controls, and their periods in seconds. If a certain task wasn't executed in the last n seconds, where n is the period of that job, it will be executed. When all the executed commands terminate, cron is done.

+

The recommended way to setup your cron system is to setup a Unix/Linux crontab that frequently visits cron.php. Note that cron does not guarantee the commands will be executed at the specified interval. However, Drupal will try his best and run the crons as close to the specified intervals as possible. The more you visit cron.php, the more accurate cron will be.

+

If your hosting company does not allow you to setup crontabs, you can always ask someone else to setup a crontab for you. After all, virtually any Unix/Linux machine with access to the internet can setup a crontab to frequently visit cron.php.

+

For the Unix/Linux crontab itself, use a browser like lynx or wget but make sure the process terminates: either use /usr/bin/lynx -source cron.php or /usr/bin/wget -O /dev/null cron.php. Take a look at the example scripts in the scripts-directory and make sure to adjust them to your needs. A good crontab-line to run the cron-script once every hour would be: 00 * * * * /home/www/drupal/scripts/cron-lynx.

+ General settings\n"; + $output .= form_textfield(t("Name"), "site_name", variable_get("site_name", "drupal"), 30, 55, t("The name of this website.")); + $output .= form_textfield(t("Slogan"), "site_slogan", variable_get("site_slogan", ""), 30, 55, t("The slogan of this website")); + $output .= form_textfield(t("E-mail address"), "site_mail", variable_get("site_mail", "root@localhost"), 30, 55, t("A valid e-mail address for this website, used by the auto-mailer to create new user accounts.")); + $output .= form_textarea(t("Footer message"), "site_footer", variable_get("site_footer", ""), 55, 3, t("This text will be displayed at the bottom of each page. Useful for adding a copyright notice to your pages.")); + $output .= form_textfield(t("Anonymous user"), "anonymous", variable_get("anonymous", "Anonymous"), 30, 55, t("The name used to indicate anonymous users.")); + $output .= "
\n"; + + // node settings: + $output .= "

Node settings

\n"; + $output .= form_select(t("Default number of nodes to display"), "default_nodes_main", variable_get("default_nodes_main", 10), array(10 => 10, 15 => 15, 20 => 20, 25 => 25, 30 => 30), t("The default maximum number of nodes to display on the main page.")); + $output .= "
\n"; + + // comment settings: + $output .= "

Comment settings

\n"; + $output .= form_select(t("Default display mode"), "default_comment_mode", $conf[default_comment_mode], $cmodes, t("The default mode in which comments are displayed.")); + $output .= form_select(t("Default display order"), "default_comment_order", $conf[default_comment_order], $corder, t("The default order in which comments are displayed.")); + for ($count = -1; $count < 6; $count++) $threshold[$count] = t("Filter") ." - $count"; + $output .= form_select(t("Default filter threshold"), "default_comment_threshold", $conf[default_comment_threshold], $threshold, t("The default threshold used to filter comments.")); + $output .= "
\n"; + + // submission settings: + $output .= "

Submission settings

\n"; + $size = array(1000 => "1.000 characters", 5000 => "5.000 characters", 10000 => "10.000 characters", 15000 => "15.000 characters", 30.000 => "30.000 characters", 50000 => "50.000 characters", 100000 => "100.000 characters"); + $output .= form_select(t("Maximum submission size"), "max_input_size", variable_get("max_input_size", 10000), $size, t("The maximum number of characters someone can enter in a form.")); + $rate = array(1 => "Maximum 1 every second", 5 => "Maximum 1 every 5 seconds", 15 => "Maximum 1 every 15 seconds", 30 => "Maximum 1 every 30 seconds", 60 => "Maximum 1 every minute", 300 => "Maximum 1 every 5 minutes", 900 => "Maximum 1 every 15 minutes", 1800 => "Maximum 1 every 30 minutes", 3600 => "Maximum 1 every hour", 21600 => "Maximum 1 every 6 hour", 43200 => "Maximum 1 every 12 hour"); + $output .= form_select(t("Maximum node rate"), "max_node_rate", variable_get("max_node_rate", 900), $rate, t("The maximum submission rate for nodes. Its purpose is to stop potential abuse or denial of service attacks.")); + $output .= form_select(t("Maximum comment rate"), "max_comment_rate", variable_get("max_comment_rate", 120), $rate, t("The maximum submission rate for comments. Its purpose is to stop potential abuse or denial of service attacks.")); + $output .= "
\n"; + + // theme settings: + $output .= "

Theme settings

\n"; + foreach ($themes as $key=>$value) $options .= "\n"; + $output .= form_item(t("Default theme"), "", t("The default theme as seen by new visitors and anonymous users.")); + $output .= "
\n"; + + // development settings: + $output .= "

Development settings

\n"; + $output .= form_select(t("Display timer information"), "dev_timer", variable_get("dev_timer", 0), array("Disabled", "Enabled"), t("Display the time it took to generate a page. For Drupal development only.")); + $output .= "
\n"; + + return $output; +} + +function conf_view_module() { + foreach (module_list() as $name) { + if (module_hook($name, "conf_options")) { + $output .= "

". ucfirst($name) ." settings

". module_invoke($name, "conf_options") ."
\n"; + } + } + return $output; +} + +function conf_view_filter() { + foreach (module_list() as $name) { + if (module_hook($name, "conf_filters")) { + $output .= module_invoke($name, "conf_filters"); + } + } + return $output; +} + +function conf_save($edit = array()) { + foreach ($edit as $name=>$value) variable_set($name, $value); + return "the configuration options have been saved."; +} + +function conf_default($edit = array()) { + foreach ($edit as $name=>$value) variable_del($name); + return "the configuration options have been reset to their default values."; +} + +function conf_view($type) { + global $REQUEST_URI; + + switch ($type) { + case "filter": + $form = conf_view_filter(); + break; + case "module": + $form = conf_view_module(); + break; + default: + $form = conf_view_system(); + } + + $form .= form_submit("Save configuration"); + $form .= form_submit("Reset to defaults"); + + return form($REQUEST_URI, $form); +} + +function conf_admin() { + global $edit, $op, $type; + + print "system settings | module settings | filters | help
\n"; + + switch ($op) { + case "help": + conf_help(); + break; + case "Reset to defaults": + print status(conf_default($edit)); + print conf_view($type); + break; + case "Save configuration": + print status(conf_save($edit)); + print conf_view($type); + break; + default: + print conf_view($type); + } +} + +?> \ No newline at end of file diff --git a/modules/cvs.module b/modules/cvs.module index f31dd2d26..1202047a6 100644 --- a/modules/cvs.module +++ b/modules/cvs.module @@ -17,7 +17,7 @@ function cvs_cron() { } } -function cvs_conf() { +function cvs_conf_options() { $period = array(43200 => format_interval(43200), 86400 => format_interval(86400), 172800 => format_interval(172800), 259200 => format_interval(259200), 604800 => format_interval(604800), 1209600 => format_interval(1209600)); $output .= form_textfield(t("Digest recepients"), "cvs_mail", variable_get("cvs_mail", "root@localhost"), 30, 55, t("The e-mail address to mail the CVS log messages to. Multiple recipients can be specified by putting a comma between each address.")); $output .= form_select(t("Digest interval"), "cvs_cron_time" , variable_get("cvs_cron_time", 86400), $period, t("The time interval at which batched CVS digests are dispatched. Requires crontab.")); diff --git a/modules/diary.module b/modules/diary.module index d003c7cc1..9cfb21c47 100644 --- a/modules/diary.module +++ b/modules/diary.module @@ -72,13 +72,13 @@ function diary_page_display($username) { } function diary_page_add() { - global $theme, $user, $allowed_html; + global $theme, $user; $output .= "
\n"; $output .= "

\n"; $output .= "
\n"; - $output .= " ". t("Allowed HTML tags") .": ". htmlspecialchars($allowed_html) .".\n"; + $output .= " ". t("Allowed HTML tags") .": ". htmlspecialchars(variable_get("allowed_html", "")) .".\n"; $output .= "

\n"; $output .= "

\n"; @@ -98,7 +98,7 @@ function diary_page_delete($id) { } function diary_page_edit($id) { - global $theme, $user, $allowed_html; + global $theme, $user; $result = db_query("SELECT * FROM diaries WHERE id = '$id'"); $diary = db_fetch_object($result); @@ -107,8 +107,8 @@ function diary_page_edit($id) { $output .= "\n"; $output .= "

\n"; - $output .= "
\n"; - $output .= " ". t("Allowed HTML tags") .": ". htmlspecialchars($allowed_html) .".\n"; + $output .= "
\n"; + $output .= " ". t("Allowed HTML tags") .": ". htmlspecialchars(variable_get("allowed_html", "")) .".\n"; $output .= "

\n"; $output .= "

\n"; $output .= " id\">\n"; @@ -123,14 +123,14 @@ function diary_page_edit($id) { } function diary_page_preview($text, $timestamp, $id = 0) { - global $theme, $user, $allowed_html; + global $theme, $user; $output .= diary_page_entry($timestamp, $text); $output .= "\n"; $output .= "

\n"; - $output .= "
\n"; - $output .= " ". t("Allowed HTML tags") .": ". htmlspecialchars($allowed_html) .".\n"; + $output .= "
\n"; + $output .= " ". t("Allowed HTML tags") .": ". htmlspecialchars(variable_get("allowed_html", "")) .".\n"; $output .= "

\n"; $output .= "

\n"; $output .= " \n"; @@ -239,7 +239,7 @@ function diary_admin_edit($id) { $output .= "

\n"; $output .= "Diary entry:
\n"; - $output .= "
\n"; + $output .= "
\n"; $output .= "

\n"; $output .= "

\n"; diff --git a/modules/headline.module b/modules/headline.module index cfb347086..1c6b41743 100644 --- a/modules/headline.module +++ b/modules/headline.module @@ -11,7 +11,7 @@ function headline_help() { format_interval(900), 1800 => format_interval(1800), 3600 => format_interval(3600), 7200 => format_interval(7200), 10800 => format_interval(10800), 21600 => format_interval(21600), 32400 => format_interval(32400), 43200 => format_interval(43200), 64800 => format_interval(64800), 86400 => format_interval(86400)); $output .= form_select(t("Update interval"), "headline_cron_time" , variable_get("headline_cron_time", 86400), $period, t("The update interval indicating how often you want to update your headline channels. Requires crontab.")); return $output; diff --git a/modules/locale.module b/modules/locale.module index deb802b29..1e2a074c8 100644 --- a/modules/locale.module +++ b/modules/locale.module @@ -3,7 +3,7 @@ function locale_help() { ?>

Normally programs are written and documented in English, and use English to interact with users. This is true for a great deal of websites. However, most people are less comfortable with English than with their own native language, and would prefer to use their mother tongue as much as possible. Many people love see their website showing a lot less of English, and far more of their own language.

-

Therefore drupal provides a framework to setup a multi-lingual website, or to overwrite the default texts in English. We explored the various alternatives to support internationalization and decided to design the framework in such a way that the impact of internationalization on drupal's sources is minimized, modular and that it doesn't require a HTML or PHP wizard to maintain translations. Maintaining translations had to be simple so it became as easy as filling out forms on the administration page. A side effect is that translation support adds significant overhead to the dynamic generation of your website. If you don't need translation support, consider to turn it off.

+

Therefore drupal provides a framework to setup a multi-lingual website, or to overwrite the default texts in English. We explored the various alternatives to support internationalization and decided to design the framework in such a way that the impact of internationalization on drupal's sources is minimized, modular and that it doesn't require a HTML or PHP wizard to maintain translations. Maintaining translations had to be simple so it became as easy as filling out forms on the administration page. A side effect is that translation support adds significant overhead to the dynamic generation of your website. If you don't need translation support, consider to turning it off from the "conf" section.

Adding a new language

@@ -24,6 +24,10 @@ function locale_help() {

Normally programs are written and documented in English, and use English to interact with users. This is true for a great deal of websites. However, most people are less comfortable with English than with their own native language, and would prefer to use their mother tongue as much as possible. Many people love see their website showing a lot less of English, and far more of their own language.

-

Therefore drupal provides a framework to setup a multi-lingual website, or to overwrite the default texts in English. We explored the various alternatives to support internationalization and decided to design the framework in such a way that the impact of internationalization on drupal's sources is minimized, modular and that it doesn't require a HTML or PHP wizard to maintain translations. Maintaining translations had to be simple so it became as easy as filling out forms on the administration page. A side effect is that translation support adds significant overhead to the dynamic generation of your website. If you don't need translation support, consider to turn it off.

+

Therefore drupal provides a framework to setup a multi-lingual website, or to overwrite the default texts in English. We explored the various alternatives to support internationalization and decided to design the framework in such a way that the impact of internationalization on drupal's sources is minimized, modular and that it doesn't require a HTML or PHP wizard to maintain translations. Maintaining translations had to be simple so it became as easy as filling out forms on the administration page. A side effect is that translation support adds significant overhead to the dynamic generation of your website. If you don't need translation support, consider to turning it off from the "conf" section.

Adding a new language

@@ -24,6 +24,10 @@ function locale_help() {