summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2010-09-03 19:49:56 +0000
committerDries Buytaert <dries@buytaert.net>2010-09-03 19:49:56 +0000
commit5d810f73e73e8dc2359f6aff0c61562567c7a859 (patch)
treeeb98b309db1ccf337f395b0dcd5bf8d49025804a /modules
parent9427ec09f82febc09617013bb39a1ac30c1d7d19 (diff)
downloadbrdo-5d810f73e73e8dc2359f6aff0c61562567c7a859.tar.gz
brdo-5d810f73e73e8dc2359f6aff0c61562567c7a859.tar.bz2
- Patch #887870 by sun, David_Rothstein: make system_list() return full module records.
Diffstat (limited to 'modules')
-rw-r--r--modules/system/system.install12
-rw-r--r--modules/system/system.module27
2 files changed, 31 insertions, 8 deletions
diff --git a/modules/system/system.install b/modules/system/system.install
index 4c8dcb9fa..1e110d880 100644
--- a/modules/system/system.install
+++ b/modules/system/system.install
@@ -1573,8 +1573,7 @@ function system_schema() {
),
'primary key' => array('filename'),
'indexes' => array(
- 'bootstrap' => array('status', 'bootstrap', 'type', 'weight', 'name'),
- 'system_list' => array('weight', 'name'),
+ 'system_list' => array('status', 'bootstrap', 'type', 'weight', 'name'),
'type_name' => array('type', 'name'),
),
);
@@ -2885,6 +2884,15 @@ function system_update_7060(&$sandbox) {
}
/**
+ * Replace 'system_list' index with 'bootstrap' index on {system}.
+ */
+function system_update_7061() {
+ db_drop_index('system', 'bootstrap');
+ db_drop_index('system', 'system_list');
+ db_add_index('system', 'system_list', array('status', 'bootstrap', 'type', 'weight', 'name'));
+}
+
+/**
* @} End of "defgroup updates-6.x-to-7.x"
* The next series of updates should start at 8000.
*/
diff --git a/modules/system/system.module b/modules/system/system.module
index be167a888..33f232f74 100644
--- a/modules/system/system.module
+++ b/modules/system/system.module
@@ -2217,25 +2217,40 @@ function system_update_files_database(&$files, $type) {
}
/**
- * Returns an array of information about active modules or themes.
+ * Returns an array of information about enabled modules or themes.
*
* This function returns the information from the {system} table corresponding
* to the cached contents of the .info file for each active module or theme.
*
* @param $type
* Either 'module' or 'theme'.
+ * @param $name
+ * (optional) The name of a module or theme whose information shall be
+ * returned. If omitted, all records for the provided $type will be returned.
+ * If $name does not exist in the provided $type or is not enabled, an empty
+ * array will be returned.
*
* @return
- * An associative array of module or theme information keyed by name.
+ * An associative array of module or theme information keyed by name, or only
+ * information for $name, if given. If no records are available, an empty
+ * array is returned.
*
* @see system_rebuild_module_data()
* @see system_rebuild_theme_data()
*/
-function system_get_info($type) {
+function system_get_info($type, $name = NULL) {
$info = array();
- $result = db_query('SELECT name, info FROM {system} WHERE type = :type AND status = 1', array(':type' => $type));
- foreach ($result as $item) {
- $info[$item->name] = unserialize($item->info);
+ if ($type == 'module') {
+ $type = 'module_enabled';
+ }
+ $list = system_list($type);
+ foreach ($list as $shortname => $item) {
+ if (!empty($item->status)) {
+ $info[$shortname] = $item->info;
+ }
+ }
+ if (isset($name)) {
+ return isset($info[$name]) ? $info[$name] : array();
}
return $info;
}