| 
webmaster@1
 | 
     1 <?php | 
| 
webmaster@1
 | 
     2 // $Id: profile.install,v 1.12 2007/12/18 12:59:22 dries Exp $ | 
| 
webmaster@1
 | 
     3  | 
| 
webmaster@1
 | 
     4 /** | 
| 
webmaster@1
 | 
     5  * Implementation of hook_install(). | 
| 
webmaster@1
 | 
     6  */ | 
| 
webmaster@1
 | 
     7 function profile_install() { | 
| 
webmaster@1
 | 
     8   // Create tables. | 
| 
webmaster@1
 | 
     9   drupal_install_schema('profile'); | 
| 
webmaster@1
 | 
    10 } | 
| 
webmaster@1
 | 
    11  | 
| 
webmaster@1
 | 
    12 /** | 
| 
webmaster@1
 | 
    13  * Implementation of hook_uninstall(). | 
| 
webmaster@1
 | 
    14  */ | 
| 
webmaster@1
 | 
    15 function profile_uninstall() { | 
| 
webmaster@1
 | 
    16   // Remove tables | 
| 
webmaster@1
 | 
    17   drupal_uninstall_schema('profile'); | 
| 
webmaster@1
 | 
    18  | 
| 
webmaster@1
 | 
    19   variable_del('profile_block_author_fields'); | 
| 
webmaster@1
 | 
    20 } | 
| 
webmaster@1
 | 
    21  | 
| 
webmaster@1
 | 
    22 /** | 
| 
webmaster@1
 | 
    23  * Implementation of hook_schema(). | 
| 
webmaster@1
 | 
    24  */ | 
| 
webmaster@1
 | 
    25 function profile_schema() { | 
| 
webmaster@1
 | 
    26   $schema['profile_fields'] = array( | 
| 
webmaster@1
 | 
    27     'description' => t('Stores profile field information.'), | 
| 
webmaster@1
 | 
    28     'fields' => array( | 
| 
webmaster@1
 | 
    29       'fid' => array( | 
| 
webmaster@1
 | 
    30         'type' => 'serial', | 
| 
webmaster@1
 | 
    31         'not null' => TRUE, | 
| 
webmaster@1
 | 
    32         'description' => t('Primary Key: Unique profile field ID.'), | 
| 
webmaster@1
 | 
    33       ), | 
| 
webmaster@1
 | 
    34       'title' => array( | 
| 
webmaster@1
 | 
    35         'type' => 'varchar', | 
| 
webmaster@1
 | 
    36         'length' => 255, | 
| 
webmaster@1
 | 
    37         'not null' => FALSE, | 
| 
webmaster@1
 | 
    38         'description' => t('Title of the field shown to the end user.'), | 
| 
webmaster@1
 | 
    39       ), | 
| 
webmaster@1
 | 
    40       'name' => array( | 
| 
webmaster@1
 | 
    41         'type' => 'varchar', | 
| 
webmaster@1
 | 
    42         'length' => 128, | 
| 
webmaster@1
 | 
    43         'not null' => TRUE, | 
| 
webmaster@1
 | 
    44         'default' => '', | 
| 
webmaster@1
 | 
    45         'description' => t('Internal name of the field used in the form HTML and URLs.'), | 
| 
webmaster@1
 | 
    46       ), | 
| 
webmaster@1
 | 
    47       'explanation' => array( | 
| 
webmaster@1
 | 
    48         'type' => 'text', | 
| 
webmaster@1
 | 
    49         'not null' => FALSE, | 
| 
webmaster@1
 | 
    50         'description' => t('Explanation of the field to end users.'), | 
| 
webmaster@1
 | 
    51       ), | 
| 
webmaster@1
 | 
    52       'category' => array( | 
| 
webmaster@1
 | 
    53         'type' => 'varchar', | 
| 
webmaster@1
 | 
    54         'length' => 255, | 
| 
webmaster@1
 | 
    55         'not null' => FALSE, | 
| 
webmaster@1
 | 
    56         'description' => t('Profile category that the field will be grouped under.'), | 
| 
webmaster@1
 | 
    57       ), | 
| 
webmaster@1
 | 
    58       'page' => array( | 
| 
webmaster@1
 | 
    59         'type' => 'varchar', | 
| 
webmaster@1
 | 
    60         'length' => 255, | 
| 
webmaster@1
 | 
    61         'not null' => FALSE, | 
| 
webmaster@1
 | 
    62         'description' => t("Title of page used for browsing by the field's value"), | 
| 
webmaster@1
 | 
    63       ), | 
| 
webmaster@1
 | 
    64       'type' => array( | 
| 
webmaster@1
 | 
    65         'type' => 'varchar', | 
| 
webmaster@1
 | 
    66         'length' => 128, | 
| 
webmaster@1
 | 
    67         'not null' => FALSE, | 
| 
webmaster@1
 | 
    68         'description' => t('Type of form field.'), | 
| 
webmaster@1
 | 
    69       ), | 
| 
webmaster@1
 | 
    70       'weight' => array( | 
| 
webmaster@1
 | 
    71         'type' => 'int', | 
| 
webmaster@1
 | 
    72         'not null' => TRUE, | 
| 
webmaster@1
 | 
    73         'default' => 0, | 
| 
webmaster@1
 | 
    74         'size' => 'tiny', | 
| 
webmaster@1
 | 
    75         'description' => t('Weight of field in relation to other profile fields.'), | 
| 
webmaster@1
 | 
    76       ), | 
| 
webmaster@1
 | 
    77       'required' => array( | 
| 
webmaster@1
 | 
    78         'type' => 'int', | 
| 
webmaster@1
 | 
    79         'not null' => TRUE, | 
| 
webmaster@1
 | 
    80         'default' => 0, | 
| 
webmaster@1
 | 
    81         'size' => 'tiny', | 
| 
webmaster@1
 | 
    82         'description' => t('Whether the user is required to enter a value. (0 = no, 1 = yes)'), | 
| 
webmaster@1
 | 
    83       ), | 
| 
webmaster@1
 | 
    84       'register' => array( | 
| 
webmaster@1
 | 
    85         'type' => 'int', | 
| 
webmaster@1
 | 
    86         'not null' => TRUE, | 
| 
webmaster@1
 | 
    87         'default' => 0, | 
| 
webmaster@1
 | 
    88         'size' => 'tiny', | 
| 
webmaster@1
 | 
    89         'description' => t('Whether the field is visible in the user registration form. (1 = yes, 0 = no)'), | 
| 
webmaster@1
 | 
    90       ), | 
| 
webmaster@1
 | 
    91       'visibility' => array( | 
| 
webmaster@1
 | 
    92         'type' => 'int', | 
| 
webmaster@1
 | 
    93         'not null' => TRUE, | 
| 
webmaster@1
 | 
    94         'default' => 0, | 
| 
webmaster@1
 | 
    95         'size' => 'tiny', | 
| 
webmaster@1
 | 
    96         'description' => t('The level of visibility for the field. (0 = hidden, 1 = private, 2 = public on profile but not member list pages, 3 = public on profile and list pages)'), | 
| 
webmaster@1
 | 
    97       ), | 
| 
webmaster@1
 | 
    98       'autocomplete' => array( | 
| 
webmaster@1
 | 
    99         'type' => 'int', | 
| 
webmaster@1
 | 
   100         'not null' => TRUE, | 
| 
webmaster@1
 | 
   101         'default' => 0, | 
| 
webmaster@1
 | 
   102         'size' => 'tiny', | 
| 
webmaster@1
 | 
   103         'description' => t('Whether form auto-completion is enabled. (0 = disabled, 1 = enabled)'), | 
| 
webmaster@1
 | 
   104       ), | 
| 
webmaster@1
 | 
   105       'options' => array( | 
| 
webmaster@1
 | 
   106         'type' => 'text', | 
| 
webmaster@1
 | 
   107         'not null' => FALSE, | 
| 
webmaster@1
 | 
   108         'description' => t('List of options to be used in a list selection field.'), | 
| 
webmaster@1
 | 
   109       ), | 
| 
webmaster@1
 | 
   110     ), | 
| 
webmaster@1
 | 
   111     'indexes' => array('category' => array('category')), | 
| 
webmaster@1
 | 
   112     'unique keys' => array('name' => array('name')), | 
| 
webmaster@1
 | 
   113     'primary key' => array('fid'), | 
| 
webmaster@1
 | 
   114   ); | 
| 
webmaster@1
 | 
   115  | 
| 
webmaster@1
 | 
   116   $schema['profile_values'] = array( | 
| 
webmaster@1
 | 
   117     'description' => t('Stores values for profile fields.'), | 
| 
webmaster@1
 | 
   118     'fields' => array( | 
| 
webmaster@1
 | 
   119       'fid' => array( | 
| 
webmaster@1
 | 
   120         'type' => 'int', | 
| 
webmaster@1
 | 
   121         'unsigned' => TRUE, | 
| 
webmaster@1
 | 
   122         'not null' => TRUE, | 
| 
webmaster@1
 | 
   123         'default' => 0, | 
| 
webmaster@1
 | 
   124         'description' => t('The {profile_fields}.fid of the field.'), | 
| 
webmaster@1
 | 
   125       ), | 
| 
webmaster@1
 | 
   126       'uid' => array( | 
| 
webmaster@1
 | 
   127         'type' => 'int', | 
| 
webmaster@1
 | 
   128         'unsigned' => TRUE, | 
| 
webmaster@1
 | 
   129         'not null' => TRUE, | 
| 
webmaster@1
 | 
   130         'default' => 0, | 
| 
webmaster@1
 | 
   131         'description' => t('The {users}.uid of the profile user.'), | 
| 
webmaster@1
 | 
   132       ), | 
| 
webmaster@1
 | 
   133       'value' => array( | 
| 
webmaster@1
 | 
   134         'type' => 'text', | 
| 
webmaster@1
 | 
   135         'not null' => FALSE, | 
| 
webmaster@1
 | 
   136         'description' => t('The value for the field.'), | 
| 
webmaster@1
 | 
   137       ), | 
| 
webmaster@1
 | 
   138     ), | 
| 
webmaster@1
 | 
   139     'primary key' => array('uid', 'fid'), | 
| 
webmaster@1
 | 
   140     'indexes' => array( | 
| 
webmaster@1
 | 
   141       'fid' => array('fid'), | 
| 
webmaster@1
 | 
   142     ), | 
| 
webmaster@1
 | 
   143   ); | 
| 
webmaster@1
 | 
   144  | 
| 
webmaster@1
 | 
   145   return $schema; | 
| 
webmaster@1
 | 
   146 } | 
| 
webmaster@1
 | 
   147  |