Skip to content
Snippets Groups Projects
Select Git revision
  • 2c0f3c9457b1de508b52b46c2a7bfadd364d0f03
  • 11.x default protected
  • 11.2.x protected
  • 10.6.x protected
  • 10.5.x protected
  • 11.1.x protected
  • 10.4.x protected
  • 11.0.x protected
  • 10.3.x protected
  • 7.x protected
  • 10.2.x protected
  • 10.1.x protected
  • 9.5.x protected
  • 10.0.x protected
  • 9.4.x protected
  • 9.3.x protected
  • 9.2.x protected
  • 9.1.x protected
  • 8.9.x protected
  • 9.0.x protected
  • 8.8.x protected
  • 10.5.4 protected
  • 11.2.5 protected
  • 10.5.3 protected
  • 11.2.4 protected
  • 10.5.2 protected
  • 11.2.3 protected
  • 10.5.1 protected
  • 11.2.2 protected
  • 11.2.1 protected
  • 11.2.0 protected
  • 10.5.0 protected
  • 11.2.0-rc2 protected
  • 10.5.0-rc1 protected
  • 11.2.0-rc1 protected
  • 10.4.8 protected
  • 11.1.8 protected
  • 10.5.0-beta1 protected
  • 11.2.0-beta1 protected
  • 11.2.0-alpha1 protected
  • 10.4.7 protected
41 results

module.inc

Blame
  • Dries Buytaert's avatar
    Dries Buytaert authored
    - Eliminated system_init(), the session stuff, and made it possible to
      rebuild the menu.
    4ad174c4
    History
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    module.inc 2.02 KiB
    <?php
    // $Id$
    
    // initialize modules:
    function module_init() {
      // Note: changing this also requires changing system_admin() @ modules/system.module.
      require_once "modules/admin.module";
      require_once "modules/user.module";
      require_once "modules/system.module";
      require_once "modules/watchdog.module";
      module_list();
      module_invoke_all("init");
    }
    
    // apply function $function to every known module:
    function module_iterate($function, $argument = "") {
      foreach (module_list() as $name) {
        $function($name, $argument);
      }
    }
    
    // invoke hook $hook of module $name with optional arguments:
    function module_invoke($name, $hook, $a1 = NULL, $a2 = NULL, $a3 = NULL, $a4 = NULL) {
      $function = $name ."_". $hook;
      if (function_exists($function)) {
        return $function($a1, $a2, $a3, $a4);
      }
    }
    
    // invoke $hook for all appropriate modules:
    function module_invoke_all($hook, $a1 = NULL, $a2 = NULL, $a3 = NULL, $a4 = NULL) {
      $return = array();
      foreach (module_list() as $name) {
        $result = module_invoke($name, $hook, $a1, $a2, $a3, $a4);
        if (isset($result)) {
          $return = array_merge($return, $result);
        }
      }
    
      return $return;
    }
    
    // return array of module names (includes lazy module loading):
    function module_list($refresh = 0) {
      static $list;
    
      if ($refresh) {
        unset($list);
      }
    
      if (!$list) {
        $list = array("system" => "system", "user" => "user", "watchdog" => "watchdog");
        $result = db_query("SELECT name, filename FROM system WHERE type = 'module' AND status = '1' ORDER BY name");
        while ($module = db_fetch_object($result)) {
          if (file_exists($module->filename)) {
            $list[$module->name] = $module->name;
            include_once $module->filename;
          }
        }
        natcasesort($list);
      }
    
      return $list;
    }
    
    // return 1 if module $name exists, 0 otherwise:
    function module_exist($name) {
      $list = module_list();
      return ($list[$name]) ? 1 : 0;
    }
    
    // return 1 if module $name implements hook $hook, 0 otherwise:
    function module_hook($name, $hook) {
      return function_exists($name ."_". $hook);
    }
    
    ?>