<?php
// $Id: commit_restrictions.install,v 1.6 2009/01/07 00:23:35 jpetso Exp $
/**
 * @file
 * Commit Restrictions - Restrict commits, branches and tags
 * based on item path or branch/tag name.
 *
 * Copyright 2007, 2009 by Jakob Petsovits ("jpetso", http://drupal.org/user/56020)
 */

/**
 * Implementation of hook_schema().
 */
function commit_restrictions_schema() {
  $schema = array();

  $schema['commit_restrictions'] = array(
    'description' => 'A table storing the various commit restriction settings for each repository.',
    'fields' => array(
      'repo_id' => array(
        'description' => 'The repository identifier referring to {versioncontrol_repositories}.repo_id.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'allowed_paths' => array(
        'description' => 'A space-separated list of PHP regular expressions for directories or files that will always be granted commit access to everyone, no matter what other commit restrictions are imposed.',
        'type' => 'text',
        'not null' => FALSE,
      ),
      'forbidden_paths' => array(
        'description' => 'A space-separated list of PHP regular expressions for directories or files that will be denied access to everyone, except if there is an exception that specifically allows the commit to happen.',
        'type' => 'text',
        'not null' => FALSE,
      ),
      'deny_undefined_paths' => array(
        'description' => 'An integer emulating a boolean (1 for enabled, 0 for disabled). If this is enabled, no paths other than the ones in {commit_restrictions}.allowed_paths will be granted commit access, except if there is an exception that specifically allows the commit to happen.',
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 0,
      ),
      'valid_branch_tag_paths' => array(
        'description' => 'A space-separated list of PHP regular expressions for directories or files where it will be possible to create branches and tags. If empty, branches and tags may be created anywhere in the repository.',
        'type' => 'text',
        'not null' => FALSE,
      ),
      'valid_branches' => array(
        'description' => 'A space-separated list of PHP regular expressions for allowed branch names. If empty, all branch names will be allowed.',
        'type' => 'text',
        'not null' => FALSE,
      ),
      'valid_tags' => array(
        'description' => 'A space-separated list of PHP regular expressions for allowed tag names. If empty, all tag names will be allowed.',
        'type' => 'text',
        'not null' => FALSE,
      ),
    ),
    'primary key' => array('repo_id'),
  );

  return $schema;
}

/**
 * Implementation of hook_install().
 */
function commit_restrictions_install() {
  // Create tables.
  drupal_install_schema('commit_restrictions');
}

/**
 * Implementation of hook_uninstall().
 */
function commit_restrictions_uninstall() {
  // Remove tables.
  drupal_uninstall_schema('commit_restrictions');
}
