You are here

function boxes_update_6100 in Boxes 6

Same name and namespace in other branches
  1. 7 boxes.install \boxes_update_6100()

Make boxes content pluggable, move body/format into a serialized options array, add plugin key field.

File

./boxes.install, line 76

Code

function boxes_update_6100() {
  $ret = array();
  $result = db_query("SELECT delta, body, format FROM {box}");
  while ($box = db_fetch_object($result)) {
    $body = array(
      'body' => $box->body,
      'format' => $box->format,
    );
    $box->body = serialize($body);
    drupal_write_record('box', $box, 'delta');
  }
  $spec = array(
    'type' => 'text',
    'not null' => FALSE,
    'size' => 'big',
    'serialize' => TRUE,
    'description' => 'Block content configuration.',
  );
  db_change_field($ret, 'box', 'body', 'options', $spec);
  db_drop_field($ret, 'box', 'format');
  $spec = array(
    'type' => 'varchar',
    'length' => 64,
    'not null' => TRUE,
    'description' => "The plugin responsible for this block.",
  );
  db_add_field($ret, 'box', 'plugin_key', $spec);
  db_query("UPDATE {box} SET plugin_key = 'simple'");
  return $ret;
}