You are here

function iframe_update_1 in Iframe 6

Removed iframe.module created tables, move data to content.module tables attributes will contain width,heigth,...

File

./iframe.install, line 68
Defines simple iframe field types. based on the cck-module "link" by quicksketch Functions for install and uninstall AND Migrations

Code

function iframe_update_1() {
  $ret = array();
  include_once drupal_get_path('module', 'content') . '/content.module';
  include_once drupal_get_path('module', 'content') . '/includes/content.admin.inc';
  $fields = content_fields();
  if (FALSE) {
    foreach ($fields as $field) {
      switch ($field['type']) {
        case 'iframe':
          $columns = array(
            'url' => array(
              'type' => 'varchar',
              'length' => 255,
              'not null' => TRUE,
              'default' => "''",
            ),
            'title' => array(
              'type' => 'varchar',
              'length' => 255,
              'not null' => TRUE,
              'default' => "''",
            ),
            'attributes' => array(
              'type' => 'mediumtext',
              'not null' => FALSE,
            ),
            'width' => array(
              'type' => 'mediumtext',
              'not null' => FALSE,
            ),
            'height' => array(
              'type' => 'mediumtext',
              'not null' => FALSE,
            ),
          );

          // content_alter_db_field(array(), array(), $field, $columns);
          content_alter_db($columns['url'], $columns['url']);
          content_alter_db($columns['title'], $columns['title']);
          content_alter_db($columns['attributes'], $columns['attributes']);
          content_alter_db($columns['width'], '');
          content_alter_db($columns['height'], '');
          $db_info = content_database_info($field);
          if ($field['multiple']) {
            $ret[] = update_sql('INSERT INTO {' . $db_info['table'] . '} (vid, delta, nid, ' . $field['field_name'] . '_url, ' . $field['field_name'] . '_title, ' . $field['field_name'] . '_attributes) ' . 'SELECT vid, delta, nid, ' . 'field_url, ' . 'field_title, ' . 'attributes FROM {node_field_iframe_data} ' . 'WHERE field_name = "' . $field['field_name'] . '"');
          }
          else {
            $ret[] = update_sql('UPDATE {' . $db_info['table'] . '} c, {node_field_iframe_data} l SET ' . 'c.' . $field['field_name'] . '_url = l.field_url, ' . 'c.' . $field['field_name'] . '_title = l.field_title, ' . 'c.' . $field['field_name'] . '_attributes = l.attributes ' . 'WHERE l.field_name = "' . $field['field_name'] . '" AND c.vid = l.vid AND c.nid = l.nid');
          }
      }
    }
  }

  //$ret[] = update_sql('DROP TABLE {node_field_iframe_data}');
  $ret[] = update_sql('DELETE FROM {cache}');
  return $ret;
}