Skip to content
Snippets Groups Projects
Commit bd8952eb authored by Kjartan Mannes's avatar Kjartan Mannes
Browse files

Changes

- Fixed an error in module_rehash_blocks() that didn't handle '-symbols.
- Removed some module depencies. Drupal will now run (sorta) even if there
  are no modules installed.
- Changed theme_link() to check if certain modules are installed before
  offering a link to them.

Todo
- Check all SQL queries to make sure they are addslashes'ed correctly.
- Check the effects of changing the PHP magic_quotes setting.
- Make the theme_link() function to be customizable either via the admin
  page and/or in the module itself.
parent 78def048
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
...@@ -37,6 +37,9 @@ function module_rehash_blocks($name, $module) { ...@@ -37,6 +37,9 @@ function module_rehash_blocks($name, $module) {
db_query("UPDATE blocks SET remove = '1' WHERE module = '$name'"); db_query("UPDATE blocks SET remove = '1' WHERE module = '$name'");
if ($module["block"] && $blocks = $module["block"]()) { if ($module["block"] && $blocks = $module["block"]()) {
foreach ($blocks as $offset=>$block) { foreach ($blocks as $offset=>$block) {
foreach ($block as $item=>$data) {
$block[$item] = addslashes($data);
}
if (!db_fetch_object(db_query("SELECT * FROM blocks WHERE module = '$name' AND name = '$block[info]'"))) { if (!db_fetch_object(db_query("SELECT * FROM blocks WHERE module = '$name' AND name = '$block[info]'"))) {
db_query("INSERT INTO blocks (name, module, offset) VALUES ('$block[info]', '$name', '$offset')"); db_query("INSERT INTO blocks (name, module, offset) VALUES ('$block[info]', '$name', '$offset')");
} }
...@@ -75,8 +78,10 @@ function module_rehash($name) { ...@@ -75,8 +78,10 @@ function module_rehash($name) {
// load modules into repository: // load modules into repository:
$handle = opendir("modules"); $handle = opendir("modules");
$repository = array();
while ($file = readdir($handle)) { while ($file = readdir($handle)) {
if ($filename = substr($file, 0, strpos($file, ".module"))) { if (".module" == substr($file, -7)) {
$filename = substr($file, 0, -7);
include "modules/$filename.module"; include "modules/$filename.module";
$repository[$filename] = $module; $repository[$filename] = $module;
} }
......
...@@ -13,12 +13,15 @@ function theme_init() { ...@@ -13,12 +13,15 @@ function theme_init() {
} }
function theme_link($separator = " | ") { function theme_link($separator = " | ") {
global $repository;
$links = array("<A HREF=\"index.php\">". t("home") ."</A>", $links = array("<A HREF=\"index.php\">". t("home") ."</A>",
"<A HREF=\"search.php\">". t("search") ."</A>", "<A HREF=\"search.php\">". t("search") ."</A>",
"<A HREF=\"submit.php\">". t("submit") ."</A>", "<A HREF=\"submit.php\">". t("submit") ."</A>");
"<A HREF=\"module.php?mod=diary\">". t("diary") ."</A>", if (is_array($repository[diary]))
"<A HREF=\"account.php\">". t("account") ."</A>", $links[] = "<A HREF=\"module.php?mod=diary\">". t("diary") ."</A>";
"<A HREF=\"module.php?mod=book\">". t("handbook") ."</A>"); $links[] = "<A HREF=\"account.php\">". t("account") ."</A>";
if (is_array($repository[diary]))
$links[] = "<A HREF=\"module.php?mod=book\">". t("handbook") ."</A>";
return implode($separator, $links); return implode($separator, $links);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment