Commit 6f4876b3 authored by JonBob's avatar JonBob

http://drupal.org/node/53999

Added default values for DB fields.
parent 7c275066
......@@ -11,15 +11,15 @@ function content_install() {
db_query("CREATE TABLE {node_type} (
type_name varchar(32) NOT NULL default '',
label varchar(255) NOT NULL default '',
description mediumtext NOT NULL,
help mediumtext NOT NULL,
description mediumtext NOT NULL default '',
help mediumtext NOT NULL default '',
title_label varchar(255) NOT NULL default '',
PRIMARY KEY (type_name)
) TYPE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */;");
db_query("CREATE TABLE {node_field} (
field_name varchar(32) NOT NULL default '',
type varchar(127) NOT NULL default '',
global_settings mediumtext NOT NULL,
global_settings mediumtext NOT NULL default '',
required int NOT NULL default '0',
multiple int NOT NULL default '0',
PRIMARY KEY (field_name)
......@@ -30,7 +30,7 @@ function content_install() {
weight int NOT NULL default '0',
label varchar(255) NOT NULL default '',
widget_type varchar(32) NOT NULL default '',
widget_settings mediumtext NOT NULL,
widget_settings mediumtext NOT NULL default '',
PRIMARY KEY (field_name,type_name)
) TYPE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */;");
break;
......@@ -39,15 +39,15 @@ function content_install() {
db_query("CREATE TABLE {node_type} (
type_name varchar(32) NOT NULL default '',
label varchar(255) NOT NULL default '',
description text NOT NULL,
help text NOT NULL,
description text NOT NULL default '',
help text NOT NULL default '',
title_label varchar(255) NOT NULL default '',
PRIMARY KEY (type_name)
)");
db_query("CREATE TABLE {node_field} (
field_name varchar(32) NOT NULL default '',
type varchar(127) NOT NULL default '',
global_settings text NOT NULL,
global_settings text NOT NULL default '',
required integer NOT NULL default '0',
multiple integer NOT NULL default '0',
PRIMARY KEY (field_name)
......@@ -58,11 +58,35 @@ function content_install() {
weight integer NOT NULL default '0',
label varchar(255) NOT NULL default '',
widget_type varchar(32) NOT NULL default '',
widget_settings text NOT NULL,
widget_settings text NOT NULL default '',
PRIMARY KEY (field_name,type_name)
)");
break;
}
}
/**
* Implementation of hook_update_N(). Add default values for fields.
*/
function content_update_1() {
$ret = array();
switch ($GLOBALS['db_type']) {
case 'pgsql':
$ret[] = update_sql("ALTER TABLE {node_type} CHANGE description description text NOT NULL default ''");
$ret[] = update_sql("ALTER TABLE {node_type} CHANGE help help text NOT NULL default ''");
$ret[] = update_sql("ALTER TABLE {node_field} CHANGE global_settings global_settings text NOT NULL default ''");
$ret[] = update_sql("ALTER TABLE {node_field_instance} CHANGE widget_settings widget_settings text NOT NULL default ''");
break;
case 'mysql':
case 'mysqli':
$ret[] = update_sql("ALTER TABLE {node_type} CHANGE description description mediumtext NOT NULL default ''");
$ret[] = update_sql("ALTER TABLE {node_type} CHANGE help help mediumtext NOT NULL default ''");
$ret[] = update_sql("ALTER TABLE {node_field} CHANGE global_settings global_settings mediumtext NOT NULL default ''");
$ret[] = update_sql("ALTER TABLE {node_field_instance} CHANGE widget_settings widget_settings mediumtext NOT NULL default ''");
break;
}
return $ret;
}
\ No newline at end of file
......@@ -827,12 +827,16 @@ function _content_admin_field_submit($form_id, $form_values) {
$widget_type = $widget_types[$form_values['widget_type']];
$widget_settings = array();
foreach (module_invoke($widget_type['module'], 'widget_settings', 'save', $field) as $setting) {
$widget_settings[$setting] = $form_values[$setting];
if (is_array($setting_names = module_invoke($widget_type['module'], 'widget_settings', 'save', $field))) {
foreach ($setting_names as $setting) {
$widget_settings[$setting] = $form_values[$setting];
}
}
$field_settings = array();
foreach (module_invoke($field_type['module'], 'field_settings', 'save', $field) as $setting) {
$field_settings[$setting] = $form_values[$setting];
if (is_array($setting_names = module_invoke($field_type['module'], 'field_settings', 'save', $field))) {
foreach ($setting_names as $setting) {
$field_settings[$setting] = $form_values[$setting];
}
}
db_query("UPDATE {node_field_instance} SET weight = %d, label = '%s', widget_type = '%s', widget_settings = '%s' WHERE type_name = '%s' AND field_name = '%s'", $form_values['weight'], $form_values['label'], $form_values['widget_type'], serialize($widget_settings), $form_values['type_name'], $form_values['field_name']);
......
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