You are here

filebrowser.install in Filebrowser 6

File

filebrowser.install
View source
<?php

function filebrowser_schema() {
  $schema['filebrowser'] = array(
    'fields' => array(
      'path' => array(
        'type' => 'varchar',
        'length' => '255',
        'not null' => TRUE,
      ),
      'location' => array(
        'type' => 'varchar',
        'length' => '255',
        'not null' => TRUE,
      ),
      'can_explore' => array(
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'disp-width' => '1',
      ),
    ),
    'primary key' => array(
      'path',
    ),
  );
  return $schema;
}
function filebrowser_install() {
  drupal_install_schema('filebrowser');
}
function filebrowser_uninstall() {
  drupal_uninstall_schema('filebrowser');
}

// Update from 5.x-1.x to 6.x-1.x
function filebrowser_update_6100() {
  $ret = array();

  // Add the old directory listing into the new database structure given that
  // this old data exists and users haven't already upgraded manually.
  global $conf;
  if (isset($conf['filebrowser_root']) && !db_table_exists('filebrowser')) {
    db_create_table($ret, 'filebrowser', array(
      'fields' => array(
        'path' => array(
          'type' => 'varchar',
          'length' => '255',
          'not null' => TRUE,
        ),
        'location' => array(
          'type' => 'varchar',
          'length' => '255',
          'not null' => TRUE,
        ),
        'can_explore' => array(
          'type' => 'int',
          'size' => 'tiny',
          'not null' => TRUE,
          'disp-width' => '1',
        ),
      ),
      'primary key' => array(
        'path',
      ),
    ));
    $ret[] = update_sql("INSERT INTO {filebrowser} (path, location, can_explore) VALUES ('filebrowser', '{$conf['filebrowser_root']}', 1)");
  }

  // Clean up variables from 5.x branch
  variable_del('filebrowser_icons');
  variable_del('filebrowser_root');
  variable_del('filebrowser_hide_description_files');
  return $ret;
}