Mercurial > hg > drupalISMI
view openmindattribute/openmindattribute.install @ 48:6625019a0c96
old model2neo4j renamed to model2neo4j_restclient. new model2neo4j_client and model2neo4j_import. fixed ismixml2model and compare_models.
author | casties |
---|---|
date | Tue, 07 Feb 2017 21:06:13 +0100 |
parents | 124ef8f3b22d |
children |
line wrap: on
line source
<?php /** * @file * Install file for the openmindattribute module. */ /** * Upgrade notes: * Things we need to make sure work when upgrading from Drupal 6 to Drupal 7: */ /** * Implements hook_field_schema(). */ function openmindattribute_field_schema($field) { return array( 'columns' => array( 'name' => array( 'type' => 'varchar', // Maximum URLs length. 'length' => 2048, 'not null' => FALSE, 'sortable' => TRUE, ), 'ov' => array( 'type' => 'text', 'not null' => FALSE, 'sortable' => TRUE, ), 'nov' => array( 'type' => 'text', 'not null' => FALSE, 'sortable' => TRUE, ), 'romanization' => array( 'type' => 'text', 'not null' => FALSE, 'sortable' => TRUE, ), ), ); } /** * Implements hook_update_last_removed(). */ function openmindattribute_update_last_removed() { return 6001; } //* add field romanization *// function openmindattribute_update_7230(&$sandbox) { $fields = field_info_fields(); foreach ($fields as $field_name => $field) { dpm($field['type']); dpm($field_name); dpm("---"); if (($field['type'] == 'openmindattribute_fields' || $field['type'] == 'openmindattribute_field') && $field['storage']['type'] == 'field_sql_storage') { $schema = openmindattribute_field_schema($field); foreach ($field['storage']['details']['sql'] as $type => $table_info) { foreach ($table_info as $table_name => $columns) { try { $column_name = _field_sql_storage_columnname($field_name, 'romanization'); dpm($field_name); dpm($column_name); db_add_field($table_name, $column_name, $schema['columns']['name']); db_add_index($table_name, $column_name, array($column_name)); } catch (Exception $e) { dpm("error"); dpm($table_name); } } } } } field_cache_clear(); } /** * Handles moving settings data from field_config.data to field_config_instance.data. */ function openmindattribute_update_7010() { // For each field that is a openmindattribute field, we need to copy the settings from the general field level down to the instance. //$field_data = array(); $result = db_query("SELECT id, field_name, data FROM {field_config} WHERE module = 'openmindattribute' AND type = 'openmindattribute_field'"); foreach ($result as $field) { $field_id = $field->id; $name = $field->field_name; $field_data = unserialize($field->data); $instances = db_query("SELECT id, data FROM {field_config_instance} WHERE field_id = :field_id", array(':field_id' => $field_id)); foreach ($instances as $instance) { // If this field has been updated already, we want to skip it. $instance_data = unserialize($instance->data); $update_instance = FALSE; if (!isset($instance_data['settings']['title'])) { foreach ($field_data['settings'] as $key => $value) { if (!isset($instance_data['settings'][$key])) { $instance_data['settings'][$key] = $value; $update_instance = TRUE; } } if ($update_instance) { // update the database. $num_updated = db_update('field_config_instance') ->fields(array('data' => serialize($instance_data))) ->condition('id', $instance->id) ->execute(); } } } } return t("Instance settings have been set with the data from the field settings."); } /** * Renames all displays from foobar to openmindattribute_foobar */ function openmindattribute_update_7001() { // Update the display type for each openmindattribute field type. $result = db_query("SELECT id, field_name, data FROM {field_config} WHERE module = 'openmindattribute' AND type = 'openmindattribute_field'"); foreach ($result as $field) { $field_id = $field->id; $name = $field->field_name; $field_data = unserialize($field->data); $instances = db_query("SELECT id, data FROM {field_config_instance} WHERE field_id = :field_id", array(':field_id' => $field_id)); foreach ($instances as $instance) { // If this field has been updated already, we want to skip it. $instance_data = unserialize($instance->data); $update_instance = FALSE; foreach ($instance_data['display'] as $display_name => $display_data) { if ($display_data['type'] && (0 !== strpos($display_data['type'], 'openmindattribute_'))) { $instance_data['display'][$display_name]['type'] = 'openmindattribute_' . $display_data['type']; $update_instance = TRUE; } } if ($update_instance) { db_update('field_config_instance') ->fields(array('data' => serialize($instance_data))) ->condition('id', $instance->id) ->execute(); } } } }