2006-07-13 13:14:25 +00:00
<?php
2006-07-14 01:05:10 +00:00
// $Id$
2006-07-13 13:14:25 +00:00
2009-05-13 19:42:18 +00:00
/**
* @file
* Install, update and uninstall functions for the profile module.
*/
2006-09-01 07:40:08 +00:00
/**
2009-05-27 18:34:03 +00:00
* Implement hook_uninstall().
2006-09-01 07:40:08 +00:00
*/
function profile_uninstall() {
variable_del('profile_block_author_fields');
}
2007-10-05 14:43:26 +00:00
/**
2009-05-27 18:34:03 +00:00
* Implement hook_schema().
2007-10-05 14:43:26 +00:00
*/
function profile_schema() {
2008-12-05 12:50:28 +00:00
$schema['profile_field'] = array(
2008-11-15 13:01:11 +00:00
'description' => 'Stores profile field information.',
2007-10-05 14:43:26 +00:00
'fields' => array(
2007-10-10 11:39:35 +00:00
'fid' => array(
'type' => 'serial',
'not null' => TRUE,
2008-11-15 13:01:11 +00:00
'description' => 'Primary Key: Unique profile field ID.',
2007-10-10 11:39:35 +00:00
),
'title' => array(
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
2008-11-15 13:01:11 +00:00
'description' => 'Title of the field shown to the end user.',
2007-10-10 11:39:35 +00:00
),
'name' => array(
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
'default' => '',
2008-11-15 13:01:11 +00:00
'description' => 'Internal name of the field used in the form HTML and URLs.',
2007-10-10 11:39:35 +00:00
),
'explanation' => array(
'type' => 'text',
'not null' => FALSE,
2008-11-15 13:01:11 +00:00
'description' => 'Explanation of the field to end users.',
2007-10-10 11:39:35 +00:00
),
'category' => array(
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
2008-11-15 13:01:11 +00:00
'description' => 'Profile category that the field will be grouped under.',
2007-10-10 11:39:35 +00:00
),
'page' => array(
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
2008-11-15 13:01:11 +00:00
'description' => "Title of page used for browsing by the field's value",
2007-10-10 11:39:35 +00:00
),
'type' => array(
'type' => 'varchar',
'length' => 128,
'not null' => FALSE,
2008-11-15 13:01:11 +00:00
'description' => 'Type of form field.',
2007-10-10 11:39:35 +00:00
),
'weight' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'size' => 'tiny',
2008-11-15 13:01:11 +00:00
'description' => 'Weight of field in relation to other profile fields.',
2007-10-10 11:39:35 +00:00
),
'required' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'size' => 'tiny',
2008-11-15 13:01:11 +00:00
'description' => 'Whether the user is required to enter a value. (0 = no, 1 = yes)',
2007-10-10 11:39:35 +00:00
),
'register' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'size' => 'tiny',
2008-11-15 13:01:11 +00:00
'description' => 'Whether the field is visible in the user registration form. (1 = yes, 0 = no)',
2007-10-10 11:39:35 +00:00
),
'visibility' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'size' => 'tiny',
2008-11-15 13:01:11 +00:00
'description' => '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)',
2007-10-10 11:39:35 +00:00
),
'autocomplete' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'size' => 'tiny',
2008-11-15 13:01:11 +00:00
'description' => 'Whether form auto-completion is enabled. (0 = disabled, 1 = enabled)',
2007-10-10 11:39:35 +00:00
),
'options' => array(
'type' => 'text',
'not null' => FALSE,
2008-11-15 13:01:11 +00:00
'description' => 'List of options to be used in a list selection field.',
2007-10-10 11:39:35 +00:00
),
2007-10-05 14:43:26 +00:00
),
2008-03-15 12:31:29 +00:00
'indexes' => array(
'category' => array('category'),
),
'unique keys' => array(
'name' => array('name'),
),
2007-10-05 14:43:26 +00:00
'primary key' => array('fid'),
);
2008-12-05 12:50:28 +00:00
$schema['profile_value'] = array(
2008-11-15 13:01:11 +00:00
'description' => 'Stores values for profile fields.',
2007-10-05 14:43:26 +00:00
'fields' => array(
2007-10-10 11:39:35 +00:00
'fid' => array(
'type' => 'int',
'unsigned' => TRUE,
2007-12-18 12:59:22 +00:00
'not null' => TRUE,
2007-10-10 11:39:35 +00:00
'default' => 0,
2008-12-05 12:50:28 +00:00
'description' => 'The {profile_field}.fid of the field.',
2007-10-10 11:39:35 +00:00
),
'uid' => array(
'type' => 'int',
'unsigned' => TRUE,
2007-12-18 12:59:22 +00:00
'not null' => TRUE,
2007-10-10 11:39:35 +00:00
'default' => 0,
2009-02-26 07:30:29 +00:00
'description' => 'The {users}.uid of the profile user.',
2007-10-10 11:39:35 +00:00
),
'value' => array(
'type' => 'text',
'not null' => FALSE,
2008-11-15 13:01:11 +00:00
'description' => 'The value for the field.',
2007-10-10 11:39:35 +00:00
),
2007-10-05 14:43:26 +00:00
),
2007-12-18 12:59:22 +00:00
'primary key' => array('uid', 'fid'),
2007-10-05 14:43:26 +00:00
'indexes' => array(
'fid' => array('fid'),
),
2009-06-01 22:07:10 +00:00
'foreign keys' => array(
'fid' => array('profile_field' => 'fid'),
'uid' => array('users' => 'uid'),
),
2007-10-05 14:43:26 +00:00
);
return $schema;
}
2008-12-05 12:50:28 +00:00
/**
* Rename {profile_fields} table to {profile_field} and {profile_values} to {profile_value}.
*/
function profile_update_7001() {
$ret = array();
db_rename_table($ret, 'profile_fields', 'profile_field');
db_rename_table($ret, 'profile_values', 'profile_value');
return $ret;
}