You are here

filebrowser.install in Filebrowser 8.2

Install, update and uninstall functions for the Filebrowser module.

File

filebrowser.install
View source
<?php

/* This file is part of "filebrowser".
 *    Copyright 2016, YagoSoft
 *    Author : Joop Sint Jago
 *    eMail  : j.sintjago@bad_xs4all.nl (remove bad_ before sending an email)
 *    Site   : http://yagosoft.com
 *
 * "filebrowser" is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * "filebrowser" is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public
 * License along with "filebrowser"; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */

/**
 * @file
 * Install, update and uninstall functions for the Filebrowser module.
 */

/**
 * Implements hook_install()
 */
function filebrowser_install() {

  // Do not allow to delete the dir_listing node type.
  $locked = Drupal::state()
    ->get('node.type.locked');
  $locked['dir_listing'] = 'dir_listing';
  Drupal::state()
    ->set('node.type.locked', $locked);
}

/**
 * Implements hook_uninstall().
 */
function filebrowser_uninstall() {

  // Clear filebrowser data out of the cache.
  \Drupal::cache('data')
    ->deleteAll();
}
function filebrowser_schema() {
  $schema['filebrowser_nodes'] = [
    'description' => 'Stores filebrowser specific data for each node',
    'fields' => [
      'nid' => [
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'description' => 'nid of the node holding this filebrowser',
      ],
      'folder_path' => [
        'type' => 'varchar',
        'length' => '255',
        'not null' => TRUE,
        'description' => 'uri to the exposed directory',
      ],
      'properties' => [
        'type' => 'text',
        'not null' => TRUE,
        'size' => 'big',
        'description' => 'serialised data containing the filebrowser settings for this node',
      ],
    ],
    'primary key' => [
      'nid',
    ],
  ];
  $schema['filebrowser_content'] = [
    'description' => 'contains information about the file. one row per file',
    'fields' => [
      'nid' => [
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'description' => 'nid of the node holding this file',
      ],
      'fid' => [
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'description' => 'id of this file',
      ],
      'root' => [
        'type' => 'varchar',
        'length' => '255',
        'not null' => TRUE,
        'description' => 'relative root of this file',
      ],
      'path' => [
        'type' => 'varchar',
        'length' => '255',
        'not null' => TRUE,
        'description' => 'path to the file',
      ],
      'file_data' => [
        'type' => 'text',
        'not null' => TRUE,
        'size' => 'big',
        'description' => 'serialised field containing file data',
      ],
    ],
    'primary key' => [
      'fid',
    ],
    'unique keys' => [
      'nid_fid' => [
        'nid',
        'fid',
      ],
      'fid' => [
        'fid',
      ],
    ],
  ];
  return $schema;
}