You are here

function bueditor_update_6000 in BUEditor 6.2

Same name and namespace in other branches
  1. 6 bueditor.install \bueditor_update_6000()

Update from 4|5.x to 6.x Add new fields: {bueditor_editors}.iconpath, {bueditor_editors}.librarypath. Change {bueditor_buttons}.accesskey field type from char to varchar. Update {bueditor_buttons}.content field values. Delete needless cron variable.

File

./bueditor.install, line 167
Installs, updates, and uninstalls BUEditor.

Code

function bueditor_update_6000() {
  $ret = array();
  $iconpath = array(
    'type' => 'varchar',
    'length' => 255,
    'not null' => TRUE,
    'default' => '%BUEDITOR/icons',
  );
  $librarypath = array(
    'type' => 'varchar',
    'length' => 255,
    'not null' => TRUE,
    'default' => '%BUEDITOR/library',
  );
  $accesskey = array(
    'type' => 'varchar',
    'length' => 1,
    'not null' => TRUE,
    'default' => '',
  );
  db_add_field($ret, 'bueditor_editors', 'iconpath', $iconpath);
  db_add_field($ret, 'bueditor_editors', 'librarypath', $librarypath);
  db_change_field($ret, 'bueditor_buttons', 'accesskey', 'accesskey', $accesskey);
  variable_del('bueditor_cron_last');

  //update button contents
  $result = db_query("SELECT bid, content FROM {bueditor_buttons} WHERE content LIKE '%%%s%%' OR content LIKE '%%%s%%' OR content LIKE '%%%s%%'", 'editor.', 'imce', 'eDefSelP');
  $tr = array(
    'editor.' => 'BUE.',
    "user_access('access imce')" => 'imce_access()',
    'imce/browse' => 'imce',
    'eDefSelProcessLines' => 'eDefTagLines',
  );
  while ($button = db_fetch_object($result)) {
    $button->content = strtr($button->content, $tr);
    db_query("UPDATE {bueditor_buttons} SET content = '%s' WHERE bid = %d", $button->content, $button->bid);
  }

  // Update bueditor_roles variable
  $roles = variable_get('bueditor_roles', array());
  foreach ($roles as $rid => $role) {
    $roles[$rid]['alt'] = 0;
  }
  variable_set('bueditor_roles', $roles);
  return $ret;
}