You are here

function filebrowser_update_6211 in Filebrowser 7.3

Same name and namespace in other branches
  1. 6.2 filebrowser.install \filebrowser_update_6211()
  2. 7.4 filebrowser.install \filebrowser_update_6211()
  3. 7.2 filebrowser.install \filebrowser_update_6211()

File

./filebrowser.install, line 326
filbrowser installation file.

Code

function filebrowser_update_6211() {
  $ret = array();
  if (db_table_exists("node_dir_listing")) {
    db_drop_table($ret, "node_dir_listing");
  }
  $schema = filebrowser_schema();
  db_create_table($ret, 'node_dir_listing', $schema['node_dir_listing']);
  $cursor = db_query("SELECT * FROM {filebrowser}");
  while ($node = db_fetch_object($cursor)) {
    $properties = (object) array(
      'folder_rights' => (object) array(
        'explore_subdirs' => $node->explore_subdirs ? TRUE : FALSE,
        'private_downloads' => $node->private_downloads ? TRUE : FALSE,
        'forbidden_files' => $node->hidden_files ? $node->hidden_files : '',
        'filtered_files' => $node->filtered_files ? $node->filtered_files : '',
      ),
      'folder_uploads' => (object) array(
        'enabled' => $node->allow_files_upload ? TRUE : FALSE,
        'accepted_uploaded_files' => $node->allowed_uploaded_files ? $node->allowed_uploaded_files : '',
      ),
      'folder_presentation' => (object) array(
        'hide_extension' => $node->hide_extension ? TRUE : FALSE,
        'visible_columns' => $node->visible_columns ? unserialize($node->visible_columns) : array(
          'icon' => TRUE,
          'display_name' => TRUE,
        ),
      ),
    );
    $serialised = serialize($properties);
    $ret[] = filebrowser_update_sql("\n      insert into {node_dir_listing}\n      (nid,folder_path,properties)\n      values(%d,'%s','%s')", $node->nid, $node->file_path, $serialised);
  }
  return $ret;
}