summaryrefslogtreecommitdiff
path: root/modules/module.module
blob: 4c32990f4bad7d5d6a1795edb5c3f7efabbdecc6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?

$module = array("help" => "module_help",
                "admin" => "module_admin");

function module_help() {
 ?>
  The module administration page provide you a list of all available modules.  Moreover, it allows you to "rehash" modules.  Whenever you install a new module or when an existing module has been changed or updated, it requires "rehasing": when you rehash a module, the module is registered to the engine and properly initialized.
 <?
}

function module_admin_rehash() {
  global $repository;

  $result = db_query("SELECT * FROM modules");
  while ($module = db_fetch_object($result)) {
    module_rehash($module->name);
  }

  foreach ($repository as $name=>$module) {
    module_rehash($name);
  }
}

function module_admin_display() {
  global $output;

  function module_row($name, $module) {
    global $output;

    $view = ($module["page"]) ? "<A HREF=\"module.php?mod=$name\">view</A>" : "&nbsp;";
    $admin = ($module["admin"]) ? "<A HREF=\"admin.php?mod=$name\">admin</A>" : "&nbsp;";
    $output .= " <TR><TD>$name</TD><TD>$view</TD><TD>$admin</TD><TD><A HREF=\"admin.php?mod=module&op=rehash&name=$name\">rehash</A></TD></TR>\n";
  }

  $output .= "<FORM ACTION=\"admin.php?mod=module\" METHOD=\"post\">\n";
  $output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n";
  $output .= " <TR><TH>module</TH><TH COLSPAN=\"3\">operations</TH></TR>\n";

  module_iterate("module_row");

  $output .= "</TABLE>\n";
  $output .= "<INPUT NAME=\"op\" TYPE=\"submit\" VALUE=\"Rehash modules\">\n";
  $output .= "</FORM>\n";
  print $output;
}

function module_admin() {
  global $op, $name;

  print "<SMALL><A HREF=\"admin.php?mod=module\">overview</A> | <A HREF=\"admin.php?mod=module&op=help\">help</A></SMALL><HR>\n";

  switch ($op) {
    case "help":
      module_help();
      break;
    case "rehash":
      module_rehash($name);
      module_admin_display();
      break;
    case "Rehash modules":
      module_admin_rehash();
      module_admin_display();
      break;
    default:
      module_admin_display();
  }
}

?>