| 1 |
<?php |
<?php |
| 2 |
// $Id: mmedia.install,v 1.2 2008/11/06 13:00:30 rhys Exp $ |
// $Id: mmedia.install,v 1.1.2.4 2008/11/19 03:10:32 rhys Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* Implementation of hook_schema(). |
* mplementation of hook_schema(). |
| 6 |
*/ |
*/ |
| 7 |
function mmedia_schema() { |
function mmedia_schema() { |
| 8 |
// media details including necessary metadata |
// media details including necessary metadata |
| 9 |
$schema['media'] = array( |
$schema['media'] = array( |
| 10 |
'fields' => array( |
'fields' => array( |
| 11 |
'mid' => array('type' => 'serial', 'unsigned' => true, 'not null' => true), |
'mid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE), |
| 12 |
'fid' => array('type' => 'int', 'unsigned' => true, 'not null' => true, 'default' => 0), |
'fid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0), |
| 13 |
'uid' => array('type' => 'int', 'unsigned' => true, 'not null' => true, 'default' => 0), |
'uid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0), |
| 14 |
|
|
| 15 |
// path details |
// path details |
| 16 |
'name' => array('type' => 'varchar', 'length' => 255, 'not null' => true, 'default' => ''), |
'name' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''), |
| 17 |
'mime' => array('type' => 'varchar', 'length' => 64, 'not null' => true, 'default' => ''), |
'mime' => array('type' => 'varchar', 'length' => 64, 'not null' => TRUE, 'default' => ''), |
| 18 |
'type' => array('type' => 'varchar', 'length' => 64, 'not null' => true, 'default' => ''), |
'type' => array('type' => 'varchar', 'length' => 64, 'not null' => TRUE, 'default' => ''), |
| 19 |
'ext' => array('type' => 'varchar', 'length' => 10, 'not null' => true, 'default' => ''), |
'ext' => array('type' => 'varchar', 'length' => 10, 'not null' => TRUE, 'default' => ''), |
| 20 |
'hash' => array('type' => 'varchar', 'length' => 32, 'not null' => true, 'default' => ''), |
'hash' => array('type' => 'varchar', 'length' => 32, 'not null' => TRUE, 'default' => ''), |
| 21 |
'path' => array('type' => 'text', 'not null' => true), |
'path' => array('type' => 'text', 'not null' => TRUE), |
| 22 |
'local' => array('type' => 'int', 'size' => 'tiny', 'not null' => true, 'default' => 1), |
'local' => array('type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => 1), |
| 23 |
'public' => array('type' => 'int', 'size' => 'tiny', 'not null' => true, 'default' => 1), |
'public' => array('type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => 1), |
| 24 |
|
|
| 25 |
// some important metadata |
// some important metadata |
| 26 |
'title' => array('type' => 'varchar', 'length' => 255, 'not null' => true, 'default' => ''), |
'title' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''), |
| 27 |
'summary' => array('type' => 'varchar', 'length' => 255, 'not null' => true, 'default' => ''), |
'summary' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''), |
| 28 |
'expire' => array('type' => 'int', 'unsigned' => true, 'not null' => true, 'default' => 0), |
'expire' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0), |
| 29 |
'dimensions' => array('type' => 'text', 'not null' => true), |
'dimensions' => array('type' => 'text', 'not null' => TRUE), |
| 30 |
'source' => array('type' => 'varchar', 'length' => 255, 'not null' => true, 'default' => ''), |
'source' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''), |
| 31 |
'reference' => array('type' => 'varchar', 'length' => 255, 'not null' => true, 'default' => ''), |
'reference' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''), |
| 32 |
|
|
| 33 |
// details for creation/modification |
// details for creation/modification |
| 34 |
'created' => array('type' => 'int', 'unsigned' => true, 'not null' => true, 'default' => 0), |
'created' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0), |
| 35 |
'changed' => array('type' => 'int', 'unsigned' => true, 'not null' => true, 'default' => 0), |
'changed' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0), |
| 36 |
|
|
| 37 |
), |
), |
| 38 |
'primary key' => array('mid'), |
'primary key' => array('mid'), |
| 50 |
// listing of folders that exist on the system |
// listing of folders that exist on the system |
| 51 |
$schema['media_folders'] = array( |
$schema['media_folders'] = array( |
| 52 |
'fields' => array( |
'fields' => array( |
| 53 |
'fid' => array('type' => 'serial', 'unsigned' => true, 'not null' => true), |
'fid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE), |
| 54 |
'parent' => array('type' => 'int', 'unsigned' => true, 'not null' => true, 'default' => 0), |
'parent' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0), |
| 55 |
'uid' => array('type' => 'int', 'unsigned' => true, 'not null' => true, 'default' => 0), |
'uid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0), |
| 56 |
|
|
| 57 |
// path details |
// path details |
| 58 |
'name' => array('type' => 'varchar', 'length' => 255, 'not null' => true, 'default' => ''), |
'name' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''), |
| 59 |
'depth' => array('type' => 'int', 'unsigned' => true, 'not null' => true, 'default' => 0), |
'depth' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0), |
| 60 |
'lineage' => array('type' => 'varchar', 'length' => 255, 'not null' => true, 'default' => ''), |
'lineage' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''), |
| 61 |
'path' => array('type' => 'text', 'not null' => true), |
'path' => array('type' => 'text', 'not null' => TRUE), |
| 62 |
), |
), |
| 63 |
'primary key' => array('fid'), |
'primary key' => array('fid'), |
| 64 |
'indexes' => array( |
'indexes' => array( |
| 71 |
// commonly used metadata information |
// commonly used metadata information |
| 72 |
$schema['media_extras'] = array( |
$schema['media_extras'] = array( |
| 73 |
'fields' => array( |
'fields' => array( |
| 74 |
'eid' => array('type' => 'serial', 'unsigned' => true, 'not null' => true), |
'eid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE), |
| 75 |
'mid' => array('type' => 'int', 'unsigned' => true, 'not null' => true, 'default' => 0), |
'mid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0), |
| 76 |
'licence' => array('type' => 'text'), |
'licence' => array('type' => 'text'), |
| 77 |
'description' => array('type' => 'text'), |
'description' => array('type' => 'text'), |
| 78 |
'bitrate' => array('type' => 'varchar', 'length' => 255), |
'bitrate' => array('type' => 'varchar', 'length' => 255), |
| 89 |
// extra metadata that doesn't fit the generally used |
// extra metadata that doesn't fit the generally used |
| 90 |
$schema['media_metadata'] = array( |
$schema['media_metadata'] = array( |
| 91 |
'fields' => array( |
'fields' => array( |
| 92 |
'metaid' => array('type' => 'serial', 'unsigned' => true, 'not null' => true), |
'metaid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE), |
| 93 |
'mid' => array('type' => 'int', 'unsigned' => true, 'not null' => true, 'default' => 0), |
'mid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0), |
| 94 |
'type' => array('type' => 'varchar', 'length' => 255), |
'type' => array('type' => 'varchar', 'length' => 255), |
| 95 |
'value' => array('type' => 'text', 'not null' => true), |
'value' => array('type' => 'text', 'not null' => TRUE), |
| 96 |
), |
), |
| 97 |
'primary key' => array('metaid'), |
'primary key' => array('metaid'), |
| 98 |
'indexes' => array( |
'indexes' => array( |
| 104 |
// for caching the media folders for users |
// for caching the media folders for users |
| 105 |
$schema['cache_media'] = array( |
$schema['cache_media'] = array( |
| 106 |
'fields' => array( |
'fields' => array( |
| 107 |
'cid' => array('type' => 'varchar', 'length' => 255, 'not null' => true, 'default' => ''), |
'cid' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''), |
| 108 |
'data' => array('type' => 'blob', 'size' => 'big'), |
'data' => array('type' => 'blob', 'size' => 'big'), |
| 109 |
'expire' => array('type' => 'int', 'unsigned' => true, 'not null' => true, 'default' => 0), |
'expire' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0), |
| 110 |
'created' => array('type' => 'int', 'unsigned' => true, 'not null' => true, 'default' => 0), |
'created' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0), |
| 111 |
'headers' => array('type' => 'text'), |
'headers' => array('type' => 'text'), |
| 112 |
'serialized' => array('type' => 'int', 'length' => 1, 'not null' => true, 'default' => 0), |
'serialized' => array('type' => 'int', 'length' => 1, 'not null' => TRUE, 'default' => 0), |
| 113 |
), |
), |
| 114 |
'primary key' => array('cid'), |
'primary key' => array('cid'), |
| 115 |
'indexes' => array( |
'indexes' => array( |
| 121 |
} |
} |
| 122 |
|
|
| 123 |
/** |
/** |
| 124 |
* Implementation of hook_install(). |
* Implementation of hook_install(). |
| 125 |
*/ |
*/ |
| 126 |
function mmedia_install() { |
function mmedia_install() { |
| 127 |
drupal_install_schema('mmedia'); |
drupal_install_schema('mmedia'); |
| 128 |
} |
} |
| 129 |
|
|
| 130 |
/** |
/** |
| 131 |
* Implementation of hook_uninstall(). |
* Implementation of hook_uninstall(). |
| 132 |
*/ |
*/ |
| 133 |
function mmedia_uninstall() { |
function mmedia_uninstall() { |
|
// these need to be installed in order to remove them correctly. |
|
|
$path = drupal_get_path('module', 'mmedia'); |
|
|
// require_once($path .'/API/hooks.inc'); |
|
|
// require_once($path .'/API/item.inc'); |
|
|
// require_once($path .'/API/folder.inc'); |
|
|
// require_once($path .'/API/file.inc'); |
|
|
|
|
| 134 |
// delete all of the media that exist on the system |
// delete all of the media that exist on the system |
| 135 |
$results = db_query("SELECT mid FROM {media}"); |
$results = db_query("SELECT mid FROM {media}"); |
| 136 |
while ($obj = db_fetch_object($results)) { |
while ($obj = db_fetch_object($results)) { |
| 140 |
// delete all of the folders that exist on the system |
// delete all of the folders that exist on the system |
| 141 |
$results = db_query("SELECT fid FROM {media_folders}"); |
$results = db_query("SELECT fid FROM {media_folders}"); |
| 142 |
while ($obj = db_fetch_object($results)) { |
while ($obj = db_fetch_object($results)) { |
| 143 |
mmedia_folder_delete($obj->fid, true, 'media'); |
mmedia_folder_delete($obj->fid, TRUE, 'media'); |
| 144 |
} |
} |
| 145 |
|
|
| 146 |
drupal_uninstall_schema('mmedia'); |
drupal_uninstall_schema('mmedia'); |