web/drupal/modules/blogapi/blogapi.install
branchdrupal
changeset 74 0ff3ba646492
equal deleted inserted replaced
73:fcf75e232c5b 74:0ff3ba646492
       
     1 <?php
       
     2 // $Id: blogapi.install,v 1.1.2.2 2009/01/06 15:46:36 goba Exp $
       
     3 
       
     4 /**
       
     5  * Implementation of hook_install().
       
     6  */
       
     7 function blogapi_install() {
       
     8   // Create tables.
       
     9   drupal_install_schema('blogapi');
       
    10 }
       
    11 
       
    12 /**
       
    13  * Implementation of hook_uninstall().
       
    14  */
       
    15 function blogapi_uninstall() {
       
    16   // Remove tables.
       
    17   drupal_uninstall_schema('blogapi');
       
    18 }
       
    19 
       
    20 
       
    21 /**
       
    22  * Implementation of hook_schema().
       
    23  */
       
    24 function blogapi_schema() {
       
    25   //This table was introduced in Drupal 6.4
       
    26   $schema['blogapi_files'] = array(
       
    27     'description' => 'Stores information for files uploaded via the blogapi.',
       
    28     'fields' => array(
       
    29       'fid' => array(
       
    30         'description' => 'Primary Key: Unique file ID.',
       
    31         'type' => 'serial',
       
    32       ),
       
    33       'uid' => array(
       
    34         'description' => 'The {users}.uid of the user who is associated with the file.',
       
    35         'type' => 'int',
       
    36         'unsigned' => TRUE,
       
    37         'not null' => TRUE,
       
    38         'default' => 0),
       
    39       'filepath' => array(
       
    40         'description' => 'Path of the file relative to Drupal root.',
       
    41         'type' => 'varchar',
       
    42         'length' => 255,
       
    43         'not null' => TRUE,
       
    44         'default' => ''),
       
    45       'filesize' => array(
       
    46         'description' => 'The size of the file in bytes.',
       
    47         'type' => 'int',
       
    48         'unsigned' => TRUE,
       
    49         'not null' => TRUE,
       
    50         'default' => 0),
       
    51     ),
       
    52     'primary key' => array('fid'),
       
    53     'indexes' => array(
       
    54       'uid' => array('uid'),
       
    55     ),
       
    56   );
       
    57 
       
    58   return $schema;
       
    59 }
       
    60 
       
    61 /**
       
    62  * @defgroup updates-5.x-to-6.x Blog API updates from 5.x to 6.x
       
    63  * @{
       
    64  */
       
    65 
       
    66 /**
       
    67  * Inform users about the new permission.
       
    68  */
       
    69 function blogapi_update_6000() {
       
    70   drupal_set_message("Blog API module does not depend on blog module's permissions anymore, but provides its own 'administer content with blog api' permission instead. Until <a href=\"". url('admin/user/permissions', array('fragment' => 'module-blogapi')) .'">this permission is assigned</a> to at least one user role, only the site administrator will be able to use Blog API features.');
       
    71   return array();
       
    72 }
       
    73 
       
    74 
       
    75 /**
       
    76  * Add blogapi_files table to enable size restriction for BlogAPI file uploads.
       
    77  *
       
    78  * This table was introduced in Drupal 6.4.
       
    79  */
       
    80 function blogapi_update_6001() {
       
    81     $schema['blogapi_files'] = array(
       
    82     'description' => 'Stores information for files uploaded via the blogapi.',
       
    83     'fields' => array(
       
    84       'fid' => array(
       
    85         'description' => 'Primary Key: Unique file ID.',
       
    86         'type' => 'serial',
       
    87       ),
       
    88       'uid' => array(
       
    89         'description' => 'The {users}.uid of the user who is associated with the file.',
       
    90         'type' => 'int',
       
    91         'unsigned' => TRUE,
       
    92         'not null' => TRUE,
       
    93         'default' => 0),
       
    94       'filepath' => array(
       
    95         'description' => 'Path of the file relative to Drupal root.',
       
    96         'type' => 'varchar',
       
    97         'length' => 255,
       
    98         'not null' => TRUE,
       
    99         'default' => ''),
       
   100       'filesize' => array(
       
   101         'description' => 'The size of the file in bytes.',
       
   102         'type' => 'int',
       
   103         'unsigned' => TRUE,
       
   104         'not null' => TRUE,
       
   105         'default' => 0),
       
   106     ),
       
   107     'primary key' => array('fid'),
       
   108     'indexes' => array(
       
   109       'uid' => array('uid'),
       
   110     ),
       
   111   );
       
   112 
       
   113   $ret = array();
       
   114 
       
   115   if (!db_table_exists('blogapi_files')) {
       
   116     db_create_table($ret, 'blogapi_files', $schema['blogapi_files']);
       
   117   }
       
   118   return $ret;
       
   119 }
       
   120 
       
   121 /**
       
   122  * @} End of "defgroup updates-5.x-to-6.x"
       
   123  * The next series of updates should start at 7000.
       
   124  */
       
   125