| 
webmaster@1
 | 
     1 <?php | 
| 
franck@19
 | 
     2 // $Id: upload.install,v 1.6.2.2 2009/01/06 15:46:38 goba Exp $ | 
| 
webmaster@1
 | 
     3  | 
| 
webmaster@1
 | 
     4 /** | 
| 
webmaster@1
 | 
     5  * Implementation of hook_install(). | 
| 
webmaster@1
 | 
     6  */ | 
| 
webmaster@1
 | 
     7 function upload_install() { | 
| 
webmaster@1
 | 
     8   // Create table. The upload table might have been created in the Drupal 5 | 
| 
webmaster@1
 | 
     9   // to Drupal 6 upgrade, and was migrated from the file_revisions table. So | 
| 
webmaster@1
 | 
    10   // in this case, there is no need to create the table, it is already there. | 
| 
webmaster@1
 | 
    11   if (!db_table_exists('upload')) { | 
| 
webmaster@1
 | 
    12     drupal_install_schema('upload'); | 
| 
webmaster@1
 | 
    13   } | 
| 
webmaster@1
 | 
    14 } | 
| 
webmaster@1
 | 
    15  | 
| 
webmaster@1
 | 
    16 /** | 
| 
webmaster@1
 | 
    17  * Implementation of hook_uninstall(). | 
| 
webmaster@1
 | 
    18  */ | 
| 
webmaster@1
 | 
    19 function upload_uninstall() { | 
| 
webmaster@1
 | 
    20   // Remove tables. | 
| 
webmaster@1
 | 
    21   drupal_uninstall_schema('upload'); | 
| 
webmaster@1
 | 
    22 } | 
| 
webmaster@1
 | 
    23  | 
| 
webmaster@1
 | 
    24 /** | 
| 
webmaster@1
 | 
    25  * Implementation of hook_schema(). | 
| 
webmaster@1
 | 
    26  */ | 
| 
webmaster@1
 | 
    27 function upload_schema() { | 
| 
webmaster@1
 | 
    28   $schema['upload'] = array( | 
| 
franck@19
 | 
    29     'description' => 'Stores uploaded file information and table associations.', | 
| 
webmaster@1
 | 
    30     'fields' => array( | 
| 
webmaster@1
 | 
    31       'fid' => array( | 
| 
webmaster@1
 | 
    32         'type' => 'int', | 
| 
webmaster@1
 | 
    33         'unsigned' => TRUE, | 
| 
webmaster@1
 | 
    34         'not null' => TRUE, | 
| 
webmaster@1
 | 
    35         'default' => 0, | 
| 
franck@19
 | 
    36         'description' => 'Primary Key: The {files}.fid.', | 
| 
webmaster@1
 | 
    37       ), | 
| 
webmaster@1
 | 
    38       'nid' => array( | 
| 
webmaster@1
 | 
    39         'type' => 'int', | 
| 
webmaster@1
 | 
    40         'unsigned' => TRUE, | 
| 
webmaster@1
 | 
    41         'not null' => TRUE, | 
| 
webmaster@1
 | 
    42         'default' => 0, | 
| 
franck@19
 | 
    43         'description' => 'The {node}.nid associated with the uploaded file.', | 
| 
webmaster@1
 | 
    44       ), | 
| 
webmaster@1
 | 
    45       'vid' => array( | 
| 
webmaster@1
 | 
    46         'type' => 'int', | 
| 
webmaster@1
 | 
    47         'unsigned' => TRUE, | 
| 
webmaster@1
 | 
    48         'not null' => TRUE, | 
| 
webmaster@1
 | 
    49         'default' => 0, | 
| 
franck@19
 | 
    50         'description' => 'Primary Key: The {node}.vid associated with the uploaded file.', | 
| 
webmaster@1
 | 
    51       ), | 
| 
webmaster@1
 | 
    52       'description' => array( | 
| 
webmaster@1
 | 
    53         'type' => 'varchar', | 
| 
webmaster@1
 | 
    54         'length' => 255, | 
| 
webmaster@1
 | 
    55         'not null' => TRUE, | 
| 
webmaster@1
 | 
    56         'default' => '', | 
| 
franck@19
 | 
    57         'description' => 'Description of the uploaded file.', | 
| 
webmaster@1
 | 
    58       ), | 
| 
webmaster@1
 | 
    59       'list' => array( | 
| 
webmaster@1
 | 
    60         'type' => 'int', | 
| 
webmaster@1
 | 
    61         'unsigned' => TRUE, | 
| 
webmaster@1
 | 
    62         'not null' => TRUE, | 
| 
webmaster@1
 | 
    63         'default' => 0, | 
| 
webmaster@1
 | 
    64         'size' => 'tiny', | 
| 
franck@19
 | 
    65         'description' => 'Whether the file should be visibly listed on the node: yes(1) or no(0).', | 
| 
webmaster@1
 | 
    66       ), | 
| 
webmaster@1
 | 
    67       'weight' => array( | 
| 
webmaster@1
 | 
    68         'type' => 'int', | 
| 
webmaster@1
 | 
    69         'not null' => TRUE, | 
| 
webmaster@1
 | 
    70         'default' => 0, | 
| 
webmaster@1
 | 
    71         'size' => 'tiny', | 
| 
franck@19
 | 
    72         'description' => 'Weight of this upload in relation to other uploads in this node.', | 
| 
webmaster@1
 | 
    73       ), | 
| 
webmaster@1
 | 
    74     ), | 
| 
webmaster@1
 | 
    75     'primary key' => array('vid', 'fid'), | 
| 
webmaster@1
 | 
    76     'indexes' => array( | 
| 
webmaster@1
 | 
    77       'fid' => array('fid'), | 
| 
webmaster@1
 | 
    78       'nid' => array('nid'), | 
| 
webmaster@1
 | 
    79     ), | 
| 
webmaster@1
 | 
    80   ); | 
| 
webmaster@1
 | 
    81  | 
| 
webmaster@1
 | 
    82   return $schema; | 
| 
webmaster@1
 | 
    83 } | 
| 
webmaster@1
 | 
    84  | 
| 
webmaster@1
 | 
    85  |