| 1 |
<?php
|
| 2 |
// $Id: user_quota.install,v 1.6 2008/12/19 23:28:40 greggles Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* @file
|
| 6 |
* Installer for the user_quota module to create database tables.
|
| 7 |
*/
|
| 8 |
|
| 9 |
/**
|
| 10 |
* Implementation of hook_schema().
|
| 11 |
*/
|
| 12 |
function user_quota_schema() {
|
| 13 |
$schema['user_quota'] = array(
|
| 14 |
'description' => t('Current information about uids and the number of nodes they are allowed to create.'),
|
| 15 |
'fields' => array(
|
| 16 |
'uid' => array(
|
| 17 |
'type' => 'int',
|
| 18 |
'not null' => TRUE,
|
| 19 |
'default' => 0,
|
| 20 |
'description' => t("User's {users}.uid."),
|
| 21 |
),
|
| 22 |
'current_limit' => array(
|
| 23 |
'type' => 'int',
|
| 24 |
'not null' => TRUE,
|
| 25 |
'default' => 0,
|
| 26 |
'description' => t('Rather than storing the quota here we store the remaining limit See {user_quota_history} for the quota(s) for a user/type.'),
|
| 27 |
),
|
| 28 |
'type' => array(
|
| 29 |
'type' => 'varchar',
|
| 30 |
'length' => 64,
|
| 31 |
'not null' => TRUE,
|
| 32 |
'default' => '',
|
| 33 |
'description' => t('Node type being limited.'),
|
| 34 |
),
|
| 35 |
),
|
| 36 |
);
|
| 37 |
$schema['user_quota_history'] = array(
|
| 38 |
'description' => t('Historial information about users alterations to their quota.'),
|
| 39 |
'fields' => array(
|
| 40 |
'uid' => array(
|
| 41 |
'type' => 'int',
|
| 42 |
'not null' => TRUE,
|
| 43 |
'default' => 0,
|
| 44 |
'description' => t("User's {users}.uid."),
|
| 45 |
),
|
| 46 |
'quota' => array(
|
| 47 |
'type' => 'int',
|
| 48 |
'not null' => TRUE,
|
| 49 |
'default' => 0,
|
| 50 |
'description' => t('Store id ({node}.nid) for the store.'),
|
| 51 |
),
|
| 52 |
'type' => array(
|
| 53 |
'type' => 'varchar',
|
| 54 |
'length' => 64,
|
| 55 |
'not null' => TRUE,
|
| 56 |
'default' => '',
|
| 57 |
'description' => t('Node type being limited.'),
|
| 58 |
),
|
| 59 |
'created' => array(
|
| 60 |
'description' => t('The Unix timestamp when the alteration was made.'),
|
| 61 |
'type' => 'int',
|
| 62 |
'not null' => TRUE,
|
| 63 |
'default' => 0
|
| 64 |
),
|
| 65 |
'message' => array(
|
| 66 |
'type' => 'text',
|
| 67 |
'size' => 'big',
|
| 68 |
'not null' => TRUE,
|
| 69 |
'default' => '',
|
| 70 |
'description' => t('Any relevant message about this change.'),
|
| 71 |
),
|
| 72 |
'altering_uid' => array(
|
| 73 |
'type' => 'int',
|
| 74 |
'description' => t("The {users}.uid that corresponds to the user performing the action that creates this record."),
|
| 75 |
),
|
| 76 |
),
|
| 77 |
'indexes' => array(
|
| 78 |
'uqh_uid' => array('uid'),
|
| 79 |
'uqh_altering_uid' => array('altering_uid'),
|
| 80 |
),
|
| 81 |
);
|
| 82 |
|
| 83 |
return $schema;
|
| 84 |
}
|
| 85 |
|
| 86 |
/**
|
| 87 |
* Implementation of hook_install().
|
| 88 |
*/
|
| 89 |
function user_quota_install() {
|
| 90 |
drupal_install_schema('user_quota');
|
| 91 |
}
|
| 92 |
|
| 93 |
/**
|
| 94 |
* Implementation of hook_uninstall().
|
| 95 |
*/
|
| 96 |
function user_quota_uninstall() {
|
| 97 |
drupal_uninstall_schema('user_quota');
|
| 98 |
}
|
| 99 |
|
| 100 |
|
| 101 |
/**
|
| 102 |
* Implementation of hook_update().
|
| 103 |
*
|
| 104 |
* Add some columns for auditing information.
|
| 105 |
*/
|
| 106 |
function user_quota_update_1() {
|
| 107 |
$ret = array();
|
| 108 |
db_add_field($ret, 'user_quota_history', 'message', array('type' => 'text', 'size' => 'big', 'not null' => TRUE, 'default' => ''));
|
| 109 |
db_add_field($ret, 'user_quota_history', 'altering_uid', array('type' => 'int'), array('uqh_uid'));
|
| 110 |
|
| 111 |
return $ret;
|
| 112 |
}
|