diff options
author | Neil Drumm <drumm@3064.no-reply.drupal.org> | 2006-08-06 23:00:42 +0000 |
---|---|---|
committer | Neil Drumm <drumm@3064.no-reply.drupal.org> | 2006-08-06 23:00:42 +0000 |
commit | 129c8eb18c47bf7b0e0fe35ac6bc1b7ee38d177f (patch) | |
tree | 6ff2bc019570712eabe871cd5d6c0c5b1c7194b8 /modules/system/system.install | |
parent | 0299beb05ee4af647fbb25ae113018e05aeb39ba (diff) | |
download | brdo-129c8eb18c47bf7b0e0fe35ac6bc1b7ee38d177f.tar.gz brdo-129c8eb18c47bf7b0e0fe35ac6bc1b7ee38d177f.tar.bz2 |
#62340 by chx, webchick, Jaza, Eaton, mathieu, and myself. Configurable node types.
Diffstat (limited to 'modules/system/system.install')
-rw-r--r-- | modules/system/system.install | 117 |
1 files changed, 117 insertions, 0 deletions
diff --git a/modules/system/system.install b/modules/system/system.install index 7ff587f53..c5b165833 100644 --- a/modules/system/system.install +++ b/modules/system/system.install @@ -198,6 +198,24 @@ function system_install() { KEY uid (uid) ) /*!40100 DEFAULT CHARACTER SET UTF8 */ "); + db_query("CREATE TABLE {node_type} ( + type varchar(32) NOT NULL, + name varchar(255) NOT NULL default '', + module varchar(255) NOT NULL, + description mediumtext NOT NULL, + help mediumtext NOT NULL, + has_title tinyint(3) unsigned NOT NULL, + title_label varchar(255) NOT NULL default '', + has_body tinyint(3) unsigned NOT NULL, + body_label varchar(255) NOT NULL default '', + min_word_count smallint(4) unsigned NOT NULL, + custom tinyint(1) NOT NULL DEFAULT '0', + modified tinyint(1) NOT NULL DEFAULT '0', + locked tinyint(1) NOT NULL DEFAULT '0', + orig_type varchar(255) NOT NULL default '', + PRIMARY KEY (type) + ) /*!40100 DEFAULT CHARACTER SET UTF8 */ "); + db_query("CREATE TABLE {url_alias} ( pid int(10) unsigned NOT NULL auto_increment, src varchar(128) NOT NULL default '', @@ -789,6 +807,9 @@ function system_install() { db_query("INSERT INTO {node_access} VALUES (0, 0, 'all', 1, 0, 0)"); + db_query("INSERT INTO {node_type} (type, name, module, description, help, has_title, title_label, has_body, body_label, min_word_count, custom, modified, locked, orig_type) VALUES ('page', 'page', 'node', 'If you want to add a static page, like a contact page or an about page, use a page.', '', 1, 'Title', 1, 'Body', 0, 1, 1, 0, 'page')"); + db_query("INSERT INTO {node_type} (type, name, module, description, help, has_title, title_label, has_body, body_label, min_word_count, custom, modified, locked, orig_type) VALUES ('story', 'story', 'node', 'Stories are articles in their simplest form: they have a title, a teaser and a body, but can be extended by other modules. The teaser is part of the body too. Stories may be used as a personal blog or for news articles.', '', 1, 'Title', 1, 'Body', 0, 1, 1, 0, 'story')"); + db_query("INSERT INTO {filter_formats} (name, roles, cache) VALUES ('Filtered HTML',',1,2,',1)"); db_query("INSERT INTO {filter_formats} (name, roles, cache) VALUES ('PHP code','',0)"); db_query("INSERT INTO {filter_formats} (name, roles, cache) VALUES ('Full HTML','',1)"); @@ -2908,3 +2929,99 @@ function system_update_187() { } return $ret; } + +function system_update_188() { + // Add ability to create dynamic node types like the CCK module + $ret = array(); + + switch ($GLOBALS['db_type']) { + case 'mysqli': + case 'mysql': + // Create node_type table + $ret[] = update_sql("CREATE TABLE {node_type} ( + type varchar(32) NOT NULL, + name varchar(255) NOT NULL, + module varchar(255) NOT NULL, + description mediumtext NOT NULL, + help mediumtext NOT NULL, + has_title tinyint(3) unsigned NOT NULL, + title_label varchar(255) NOT NULL default '', + has_body tinyint(3) unsigned NOT NULL, + body_label varchar(255) NOT NULL default '', + min_word_count smallint(4) unsigned NOT NULL, + custom tinyint(1) NOT NULL DEFAULT '0', + modified tinyint(1) NOT NULL DEFAULT '0', + locked tinyint(1) NOT NULL DEFAULT '0', + orig_type varchar(255) NOT NULL default '', + PRIMARY KEY (type) + ) /*!40100 DEFAULT CHARACTER SET utf8 */;"); + break; + + case 'pgsql': + $ret[] = update_sql("CREATE TABLE {node_type} ( + type varchar(32) NOT NULL, + name varchar(255) NOT NULL, + module varchar(255) NOT NULL, + description text NOT NULL, + help text NOT NULL, + has_title integer unsigned NOT NULL, + title_label varchar(255) NOT NULL default '', + has_body integer unsigned NOT NULL, + body_label varchar(255) NOT NULL default '', + min_word_count integer unsigned NOT NULL, + custom smallint NOT NULL DEFAULT '0', + modified smallint NOT NULL DEFAULT '0', + locked smallint NOT NULL DEFAULT '0', + orig_type varchar(255) NOT NULL default '', + PRIMARY KEY (type) + );"); + break; + } + + // Insert default user-defined node types into the database. + $types = array( + array( + 'type' => 'page', + 'name' => t('page'), + 'module' => 'node', + 'description' => t('If you want to add a static page, like a contact page or an about page, use a page.'), + 'custom' => TRUE, + 'modified' => TRUE, + 'locked' => FALSE, + ), + array( + 'type' => 'story', + 'name' => t('story'), + 'module' => 'node', + 'description' => t('Stories are articles in their simplest form: they have a title, a teaser and a body, but can be extendd by other modules. The teaser is part of the body too. Stories may be used as a personal blog or for news articles.'), + 'custom' => TRUE, + 'modified' => TRUE, + 'locked' => FALSE, + ) + ); + + foreach ($types as $type) { + $type = (object) _node_type_set_defaults($type); + node_type_save($type); + } + + cache_clear_all(); + system_modules(); + menu_rebuild(); + node_types_rebuild(); + + // Migrate old values for 'minimum_x_size' variables to the node_type table. + $query = db_query('SELECT type FROM {node_type}'); + while ($result = db_fetch_object($query)) { + $variable_name = 'minimum_'. $result->type .'_size'; + if ($value = db_fetch_object(db_query("SELECT value FROM {variable} WHERE name = '%s'", $variable_name))) { + $value = (int) unserialize($value->value); + db_query("UPDATE {node_type} SET min_word_count = %d, modified = %d WHERE type = '%s'", $value, 1, $result->type); + variable_del($variable_name); + } + } + + node_types_rebuild(); + + return $ret; +} |