2 // $Id: install.inc 144 2007-03-28 07:52:20Z thierry $
4 define('SCHEMA_UNINSTALLED', -1);
5 define('SCHEMA_INSTALLED', 0);
8 // The system module (Drupal core) is currently a special case
9 include_once './database/updates.inc';
11 // Include install files for each module
12 foreach (module_list() as $module) {
13 $install_file = './'. drupal_get_path('module', $module) .'/'. $module .'.install';
14 if (is_file($install_file)) {
15 include_once $install_file;
21 * Returns an array of available schema versions for a module.
26 * If the module has updates, an array of available updates. Otherwise,
29 function drupal_get_schema_versions($module) {
30 $functions = get_defined_functions();
31 foreach ($functions['user'] as $function) {
32 if (strpos($function, $module .'_update_') === 0) {
33 $version = substr($function, strlen($module .'_update_'));
34 if (is_numeric($version)) {
35 $updates[] = $version;
39 if (count($updates) == 0) {
46 * Returns the currently installed schema version for a module.
51 * The currently installed schema version.
53 function drupal_get_installed_schema_version($module, $reset = FALSE) {
62 $result = db_query("SELECT name, schema_version FROM {system} WHERE type = 'module'");
63 while ($row = db_fetch_object($result)) {
64 $versions[$row->name] = $row->schema_version;
68 return $versions[$module];
72 * Update the installed version information for a module.
77 * The new schema version.
79 function drupal_set_installed_schema_version($module, $version) {
80 db_query("UPDATE {system} SET schema_version = %d WHERE name = '%s'", $version, $module);