Commit 7f87b19e authored by Dries's avatar Dries

- Patch #42886 by chx: critical feature: allow modules to be reordered.

parent 7f083e0c
......@@ -685,7 +685,9 @@ CREATE TABLE system (
throttle tinyint(1) DEFAULT '0' NOT NULL,
bootstrap int(2) NOT NULL default '0',
schema_version smallint(2) unsigned NOT NULL default 0,
PRIMARY KEY (filename)
weight int(2) NOT NULL default '0',
PRIMARY KEY (filename),
KEY (weight)
) TYPE=MyISAM;
--
......
......@@ -680,8 +680,10 @@ CREATE TABLE system (
throttle smallint NOT NULL default '0',
bootstrap integer NOT NULL default '0',
schema_version smallint NOT NULL default 0,
weight smallint NOT NULL default 0,
PRIMARY KEY (filename)
);
CREATE INDEX system_weight_idx ON system(weight);
--
-- Table structure for term_data
......
......@@ -1397,3 +1397,19 @@ function system_update_166() {
return $ret;
}
function system_update_167() {
$ret = array();
switch ($GLOBALS['db_type']) {
case 'pgsql':
db_add_column($ret, 'system', 'weight', 'smallint', array('not null' => TRUE, 'default' => 0));
$ret[] = update_sql('CREATE INDEX {system}_weight_idx ON {system} (weight)');
break;
case 'mysql':
case 'mysqli':
$ret[] = update_sql("ALTER TABLE {system} ADD weight tinyint(3) unsigned default '0' NOT NULL, ADD KEY (weight)");
break;
}
return $ret;
}
......@@ -50,10 +50,10 @@ function module_list($refresh = FALSE, $bootstrap = TRUE) {
if (!$list) {
$list = array('filter' => 'filter', 'system' => 'system', 'user' => 'user', 'watchdog' => 'watchdog');
if ($bootstrap) {
$result = db_query("SELECT name, filename, throttle, bootstrap FROM {system} WHERE type = 'module' AND status = 1 AND bootstrap = 1");
$result = db_query("SELECT name, filename, throttle, bootstrap FROM {system} WHERE type = 'module' AND status = 1 AND bootstrap = 1 ORDER BY weight ASC, filename ASC");
}
else {
$result = db_query("SELECT name, filename, throttle, bootstrap FROM {system} WHERE type = 'module' AND status = 1");
$result = db_query("SELECT name, filename, throttle, bootstrap FROM {system} WHERE type = 'module' AND status = 1 ORDER BY weight ASC, filename ASC");
}
while ($module = db_fetch_object($result)) {
if (file_exists($module->filename)) {
......@@ -67,7 +67,6 @@ function module_list($refresh = FALSE, $bootstrap = TRUE) {
}
}
}
asort($list);
}
return $list;
}
......
......@@ -2169,7 +2169,7 @@ function node_form_alter($form_id, &$form) {
* - "delete"
* - "create"
* @param $node
* The node object (or node array) on which the operation is to be performed,
* The node object (or node array) on which the operation is to be performed,
* or node type (e.g. 'forum') for "create" operation.
* @param $uid
* The user ID on which the operation is to be performed.
......
......@@ -2169,7 +2169,7 @@ function node_form_alter($form_id, &$form) {
* - "delete"
* - "create"
* @param $node
* The node object (or node array) on which the operation is to be performed,
* The node object (or node array) on which the operation is to be performed,
* or node type (e.g. 'forum') for "create" operation.
* @param $uid
* The user ID on which the operation is to be performed.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment