Commit a8397343 authored by KarenS's avatar KarenS
Browse files

Fix fatal errors when enabling cck and fieldgroup by removing install schema....

Fix fatal errors when enabling cck and fieldgroup by removing install schema. Add entity_type to cck table.
parent 16a70701
; $Id$
name = CCK
description = Miscellaneous functions not handled by core.
description = Miscellaneous field functions not handled by core.
package = CCK
core = 7.x
files[] = cck.module
files[] = cck.install
\ No newline at end of file
files[] = cck.install
dependencies[] = field_ui
\ No newline at end of file
......@@ -4,15 +4,13 @@
* Implementation of hook_install().
*/
function cck_install() {
drupal_install_schema('cck');
}
/**
* Implementation of hook_uninstall().
*/
function cck_uninstall() {
drupal_uninstall_schema('cck');
db_query("DELETE FROM {variable} WHERE name LIKE 'cck_extra_weights_%'");
}
......@@ -24,6 +22,7 @@ function cck_uninstall() {
* don't want in core.
*/
function cck_schema() {
$schema['cck_field_settings'] = array(
'fields' => array(
'field_name' => array(
......@@ -32,6 +31,12 @@ function cck_schema() {
'not null' => TRUE,
'description' => 'The name of the field.',
),
'entity_type' => array(
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'default' => ''
),
'bundle' => array(
'type' => 'varchar',
'length' => 32,
......@@ -61,31 +66,3 @@ function cck_schema() {
return $schema;
}
/*
// TODO need to make the following changes to update existing data:
// Set up and move to content module to handle upgrade path:
function content_update_7000() {
- Add new columns for:
- deleted: defaults to 0
- data: contains serialized array of complete $instance.
- Module-defined field settings are now at $field['settings'][...]
- Module-defined widget settings are now at $instance['widget']['settings']
- Module-defined instance settings are at $instance['settings']
- Field settings should be limited to settings that affect the schema,
all others should be instance settings.
- Display is now $instance['display'] instead of $instance['display_settings']
- Display format now adds label to every context instead of one label at the top level, for a more consistent structure.
- Rename display options, formatter names are now prefixed with field name.
- No more content type: $field['widget']['type_name'] becomes $instance['bundle']
- Required is now $instance['required'] instead of $field['required']
- Label is now $instance['label'] instead of $field['widget']['label']
- Description is now $instance['description'] instead of $field['widget']['description']
- Weight is now $instance['weight'] instead of $field['widget']['weight']
- Text module textareas are now a separate field type so the db schema won't change.
- Text module format columns are always set and don't change by field settings so the db schema won't change.
- Text and Number with allowed values are now made into List field types.
- Default values are moved out of the field settings into the cck_field_settings table maintained by CCK
}
*/
\ No newline at end of file
......@@ -92,6 +92,7 @@ function cck_field_get_setting($setting, $setting_type, $field, $instance = NULL
function cck_field_set_setting($setting, $setting_type, $value, $field, $instance = NULL) {
// Delete any prior values.
$bundle = ($setting_type == 'field' || empty($instance)) ? NULL : $instance['bundle'];
$entity_type = ($setting_type == 'field' || empty($instance)) ? NULL : $instance['entity_type'];
if ($setting_type == 'field' || empty($instance)) {
db_delete('cck_field_settings')
->condition('field_name', $field['field_name'])
......@@ -102,6 +103,7 @@ function cck_field_set_setting($setting, $setting_type, $value, $field, $instanc
else {
db_delete('cck_field_settings')
->condition('field_name', $field['field_name'])
->condition('entity_type', $entity_type)
->condition('bundle', $bundle)
->condition('setting', $setting)
->condition('setting_type', $setting_type)
......@@ -113,6 +115,7 @@ function cck_field_set_setting($setting, $setting_type, $value, $field, $instanc
}
$record = array(
'field_name' => $field['field_name'],
'entity_type' => $entity_type,
'bundle' => $bundle,
'setting' => $setting,
'setting_option' => $value,
......
......@@ -7,14 +7,12 @@
*/
function fieldgroup_install() {
db_query("UPDATE {system} SET weight = 9 WHERE name = 'fieldgroup'");
drupal_install_schema('fieldgroup');
}
/**
* Implementation of hook_uninstall().
*/
function fieldgroup_uninstall() {
drupal_uninstall_schema('fieldgroup');
}
/**
......
......@@ -24,28 +24,29 @@ function fieldgroup_init() {
*/
function fieldgroup_menu() {
$items = array();
// Make sure this doesn't fire until field_info_fieldable_types() is working,
// needed to avoid errors on initial installation.
if (!defined('MAINTENANCE_MODE')) {
// Create tabs for all possible bundles.
$bundles = field_info_bundles();
foreach ($bundles as $bundle_name => $bundle_label) {
$admin_path = _cck_bundle_admin_path($bundle_name);
$items[$admin_path .'/groups/%'] = array(
'title' => 'Edit group',
'page callback' => 'drupal_get_form',
'page arguments' => array('fieldgroup_group_edit_form', $bundle_name, 5),
'access arguments' => array('administer content types'),
'type' => MENU_CALLBACK,
);
$items[$admin_path .'/groups/%/remove'] = array(
'title' => 'Edit group',
'page callback' => 'drupal_get_form',
'page arguments' => array('fieldgroup_remove_group', $bundle_name, 5),
'access arguments' => array('administer content types'),
'type' => MENU_CALLBACK,
);
foreach ($bundles as $entity_type => $info) {
foreach ($info as $bundle_name => $bundle) {
$admin_path = _field_ui_bundle_admin_path($entity_type, $bundle_name);
$items[$admin_path .'/groups/%'] = array(
'title' => 'Edit group',
'page callback' => 'drupal_get_form',
'page arguments' => array('fieldgroup_group_edit_form', $bundle_name, 5),
'access arguments' => array('administer content types'),
'type' => MENU_CALLBACK,
);
$items[$admin_path .'/groups/%/remove'] = array(
'title' => 'Edit group',
'page callback' => 'drupal_get_form',
'page arguments' => array('fieldgroup_remove_group', $bundle_name, 5),
'access arguments' => array('administer content types'),
'type' => MENU_CALLBACK,
);
}
}
}
return $items;
......
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