| 1 |
<?php
|
| 2 |
// $Id: dav.install,v 1.2 2008/05/08 09:52:46 arto Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* @file
|
| 6 |
* DAV module installation and upgrade code.
|
| 7 |
*/
|
| 8 |
|
| 9 |
//////////////////////////////////////////////////////////////////////////////
|
| 10 |
// Core API hooks
|
| 11 |
|
| 12 |
/**
|
| 13 |
* Implementation of hook_enable().
|
| 14 |
*/
|
| 15 |
function dav_enable() {
|
| 16 |
drupal_set_message(t('DAV API successfully installed. Please review the available <a href="@settings">configuration settings</a>.', array('@settings' => url('admin/settings/dav'))));
|
| 17 |
}
|
| 18 |
|
| 19 |
/**
|
| 20 |
* Implementation of hook_install().
|
| 21 |
*/
|
| 22 |
function dav_install() {
|
| 23 |
drupal_install_schema('dav');
|
| 24 |
}
|
| 25 |
|
| 26 |
/**
|
| 27 |
* Implementation of hook_uninstall().
|
| 28 |
*/
|
| 29 |
function dav_uninstall() {
|
| 30 |
drupal_uninstall_schema('dav');
|
| 31 |
}
|
| 32 |
|
| 33 |
/**
|
| 34 |
* Implementation of hook_requirements().
|
| 35 |
*/
|
| 36 |
function dav_requirements($phase) {
|
| 37 |
$requirements = array();
|
| 38 |
$t = get_t(); // Ensure translations don't break at install time
|
| 39 |
|
| 40 |
if ($phase == 'install') {
|
| 41 |
module_load_include('module', 'dav');
|
| 42 |
|
| 43 |
if (!_dav_load_server()) {
|
| 44 |
$requirements['dav_server'] = array(
|
| 45 |
'title' => '',
|
| 46 |
'value' => '',
|
| 47 |
'description' => $t('The <a href="@pear">PEAR HTTP_WebDAV_Server</a> library is not installed. You must install this library in order to enable the DAV API. To install, <a href="@download">download</a> the latest version of the library and unzip it to %path under the Drupal directory. For more information please refer to INSTALL.txt.', array('@pear' => 'http://pear.php.net/package/HTTP_WebDAV_Server', '@download' => 'http://pear.php.net/package/HTTP_WebDAV_Server/download', '%path' => drupal_get_path('module', 'dav') . '/vendor/')),
|
| 48 |
'severity' => REQUIREMENT_ERROR,
|
| 49 |
);
|
| 50 |
}
|
| 51 |
}
|
| 52 |
|
| 53 |
return $requirements;
|
| 54 |
}
|
| 55 |
|
| 56 |
//////////////////////////////////////////////////////////////////////////////
|
| 57 |
// Schema API hooks
|
| 58 |
|
| 59 |
/**
|
| 60 |
* Implementation of hook_schema().
|
| 61 |
*/
|
| 62 |
function dav_schema() {
|
| 63 |
return array(
|
| 64 |
'dav_resources' => array(
|
| 65 |
'description' => t(''),
|
| 66 |
'fields' => array(
|
| 67 |
'id' => array( // `id` int(10) unsigned NOT NULL default '0',
|
| 68 |
'description' => t(''),
|
| 69 |
'type' => 'int',
|
| 70 |
'unsigned' => TRUE,
|
| 71 |
'not null' => TRUE,
|
| 72 |
'default' => 0,
|
| 73 |
),
|
| 74 |
'type' => array( // `type` varchar(64) NOT NULL default '',
|
| 75 |
'description' => t(''),
|
| 76 |
'type' => 'varchar',
|
| 77 |
'length' => 64,
|
| 78 |
'not null' => TRUE,
|
| 79 |
'default' => '',
|
| 80 |
),
|
| 81 |
'key' => array( // `key` varchar(255) NOT NULL default '',
|
| 82 |
'description' => t(''),
|
| 83 |
'type' => 'varchar',
|
| 84 |
'length' => 255,
|
| 85 |
'not null' => TRUE,
|
| 86 |
'default' => '',
|
| 87 |
),
|
| 88 |
'module' => array( // `module` varchar(64) NOT NULL default '',
|
| 89 |
'description' => t(''),
|
| 90 |
'type' => 'varchar',
|
| 91 |
'length' => 64,
|
| 92 |
'not null' => TRUE,
|
| 93 |
'default' => '',
|
| 94 |
),
|
| 95 |
),
|
| 96 |
'primary key' => array('id'),
|
| 97 |
'unique keys' => array('type_key' => array('type', '`key`')), // HACK: these column names are not quoted, so 'key' causes an error in MySQL
|
| 98 |
),
|
| 99 |
'dav_blobs' => array(
|
| 100 |
'description' => t(''),
|
| 101 |
'fields' => array(
|
| 102 |
'resource_id' => array( // `resource_id` int(10) unsigned NOT NULL default '0',
|
| 103 |
'description' => t(''),
|
| 104 |
'type' => 'int',
|
| 105 |
'unsigned' => TRUE,
|
| 106 |
'not null' => TRUE,
|
| 107 |
'default' => 0,
|
| 108 |
),
|
| 109 |
'user_id' => array( // `user_id` int(10) unsigned NOT NULL default '0',
|
| 110 |
'description' => t(''),
|
| 111 |
'type' => 'int',
|
| 112 |
'unsigned' => TRUE,
|
| 113 |
'not null' => TRUE,
|
| 114 |
'default' => 0,
|
| 115 |
),
|
| 116 |
'content_type' => array( // `content_type` varchar(64) default NULL,
|
| 117 |
'description' => t(''),
|
| 118 |
'type' => 'varchar',
|
| 119 |
'length' => 64,
|
| 120 |
'default' => NULL,
|
| 121 |
),
|
| 122 |
'content_length' => array( // `content_length` int(10) unsigned NOT NULL default '0',
|
| 123 |
'description' => t(''),
|
| 124 |
'type' => 'int',
|
| 125 |
'unsigned' => TRUE,
|
| 126 |
'not null' => TRUE,
|
| 127 |
'default' => 0,
|
| 128 |
),
|
| 129 |
'content' => array( // `content` longblob,
|
| 130 |
'description' => t(''),
|
| 131 |
'type' => 'blob',
|
| 132 |
'size' => 'big',
|
| 133 |
),
|
| 134 |
),
|
| 135 |
'primary key' => array('resource_id', 'user_id'),
|
| 136 |
),
|
| 137 |
'dav_locks' => array(
|
| 138 |
'description' => t(''),
|
| 139 |
'fields' => array(
|
| 140 |
'id' => array( // `id` int(10) unsigned NOT NULL default '0',
|
| 141 |
'description' => t(''),
|
| 142 |
'type' => 'int',
|
| 143 |
'unsigned' => TRUE,
|
| 144 |
'not null' => TRUE,
|
| 145 |
'default' => 0,
|
| 146 |
),
|
| 147 |
'resource_id' => array( // `resource_id` int(10) unsigned NOT NULL default '0',
|
| 148 |
'description' => t(''),
|
| 149 |
'type' => 'int',
|
| 150 |
'unsigned' => TRUE,
|
| 151 |
'not null' => TRUE,
|
| 152 |
'default' => 0,
|
| 153 |
),
|
| 154 |
'user_id' => array( // `user_id` int(10) unsigned NOT NULL default '0',
|
| 155 |
'description' => t(''),
|
| 156 |
'type' => 'int',
|
| 157 |
'unsigned' => TRUE,
|
| 158 |
'not null' => TRUE,
|
| 159 |
'default' => 0,
|
| 160 |
),
|
| 161 |
'token' => array( // `token` varchar(255) NOT NULL default '',
|
| 162 |
'description' => t(''),
|
| 163 |
'type' => 'varchar',
|
| 164 |
'length' => 255,
|
| 165 |
'not null' => TRUE,
|
| 166 |
'default' => '',
|
| 167 |
),
|
| 168 |
'depth' => array( // `depth` int(10) NOT NULL default '0',
|
| 169 |
'description' => t(''),
|
| 170 |
'type' => 'int',
|
| 171 |
'not null' => TRUE,
|
| 172 |
'default' => 0,
|
| 173 |
),
|
| 174 |
'is_writelock' => array( // `is_writelock` tinyint(1) unsigned NOT NULL default '0',
|
| 175 |
'description' => t(''),
|
| 176 |
'type' => 'int',
|
| 177 |
'size' => 'tiny',
|
| 178 |
'unsigned' => TRUE,
|
| 179 |
'not null' => TRUE,
|
| 180 |
'default' => 0,
|
| 181 |
),
|
| 182 |
'is_exclusive' => array( // `is_exclusive` tinyint(1) unsigned NOT NULL default '0',
|
| 183 |
'description' => t(''),
|
| 184 |
'type' => 'int',
|
| 185 |
'size' => 'tiny',
|
| 186 |
'unsigned' => TRUE,
|
| 187 |
'not null' => TRUE,
|
| 188 |
'default' => 0,
|
| 189 |
),
|
| 190 |
'created_at' => array( // `created_at` int(10) unsigned NOT NULL default '0',
|
| 191 |
'description' => t(''),
|
| 192 |
'type' => 'int',
|
| 193 |
'unsigned' => TRUE,
|
| 194 |
'not null' => TRUE,
|
| 195 |
'default' => 0,
|
| 196 |
),
|
| 197 |
'updated_at' => array( // `updated_at` int(10) unsigned NOT NULL default '0',
|
| 198 |
'description' => t(''),
|
| 199 |
'type' => 'int',
|
| 200 |
'unsigned' => TRUE,
|
| 201 |
'not null' => TRUE,
|
| 202 |
'default' => 0,
|
| 203 |
),
|
| 204 |
'expires_at' => array( // `expires_at` int(10) unsigned NOT NULL default '0',
|
| 205 |
'description' => t(''),
|
| 206 |
'type' => 'int',
|
| 207 |
'unsigned' => TRUE,
|
| 208 |
'not null' => TRUE,
|
| 209 |
'default' => 0,
|
| 210 |
),
|
| 211 |
),
|
| 212 |
'primary key' => array('id'),
|
| 213 |
'unique keys' => array('token' => array('token')),
|
| 214 |
),
|
| 215 |
'dav_properties' => array(
|
| 216 |
'description' => t(''),
|
| 217 |
'fields' => array(
|
| 218 |
'resource_id' => array( // `resource_id` int(10) unsigned NOT NULL default '0',
|
| 219 |
'description' => t(''),
|
| 220 |
'type' => 'int',
|
| 221 |
'unsigned' => TRUE,
|
| 222 |
'not null' => TRUE,
|
| 223 |
'default' => 0,
|
| 224 |
),
|
| 225 |
'namespace' => array( // `namespace` varchar(128) NOT NULL default '',
|
| 226 |
'description' => t(''),
|
| 227 |
'type' => 'varchar',
|
| 228 |
'length' => 128,
|
| 229 |
'not null' => TRUE,
|
| 230 |
'default' => '',
|
| 231 |
),
|
| 232 |
'name' => array( // `name` varchar(128) NOT NULL default '',
|
| 233 |
'description' => t(''),
|
| 234 |
'type' => 'varchar',
|
| 235 |
'length' => 128,
|
| 236 |
'not null' => TRUE,
|
| 237 |
'default' => '',
|
| 238 |
),
|
| 239 |
'value' => array( // `value` text,
|
| 240 |
'description' => t(''),
|
| 241 |
'type' => 'text',
|
| 242 |
),
|
| 243 |
),
|
| 244 |
'primary key' => array('resource_id', 'namespace', 'name'),
|
| 245 |
),
|
| 246 |
);
|
| 247 |
}
|