| 1 |
<?php
|
| 2 |
// $Id: openid_ax.install,v 1.5 2008/07/12 13:18:12 anshuprateek Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* @file Install for openid_ax module
|
| 6 |
*/
|
| 7 |
|
| 8 |
/**
|
| 9 |
* Implementation of hook_install()
|
| 10 |
*/
|
| 11 |
function openid_ax_install() {
|
| 12 |
// Create tables.
|
| 13 |
drupal_install_schema('openid_ax');
|
| 14 |
// Insert values into table openid_ax_attributes
|
| 15 |
_openid_ax_attributes_fill();
|
| 16 |
}
|
| 17 |
|
| 18 |
/**
|
| 19 |
* Implementation of hook_uninstall().
|
| 20 |
*/
|
| 21 |
function openid_ax_uninstall() {
|
| 22 |
// Remove tables.
|
| 23 |
drupal_uninstall_schema('openid_ax');
|
| 24 |
}
|
| 25 |
|
| 26 |
/**
|
| 27 |
* Implementation of hook_schema().
|
| 28 |
*/
|
| 29 |
function openid_ax_schema() {
|
| 30 |
$schema['openid_ax_attributes'] = array(
|
| 31 |
'description' => t('A list of attributes served by the Attribute Exchange'),
|
| 32 |
'fields' => array(
|
| 33 |
'ax_id' => array(
|
| 34 |
'type' => 'serial',
|
| 35 |
'unsigned' => TRUE,
|
| 36 |
'not null' => TRUE,
|
| 37 |
'description' => t('Id number for the attribute identifier.')
|
| 38 |
),
|
| 39 |
'identifier' => array(
|
| 40 |
'type' => 'varchar',
|
| 41 |
'length' => 255,
|
| 42 |
'not null' => TRUE,
|
| 43 |
'default' => '',
|
| 44 |
'description' => t('URI placeholder of the attribute identifier.')
|
| 45 |
),
|
| 46 |
),
|
| 47 |
'indexes' => array('ax_id' => array('ax_id')),
|
| 48 |
'primary key' => array('identifier')
|
| 49 |
);
|
| 50 |
|
| 51 |
$schema['openid_ax_persona'] = array(
|
| 52 |
'description' => t('A list of personas saved by the Attribute Exchange User'),
|
| 53 |
'fields' => array(
|
| 54 |
'uid' => array(
|
| 55 |
'type' => 'int',
|
| 56 |
'size'=>'normal',
|
| 57 |
'unsigned' => TRUE,
|
| 58 |
'not null' => TRUE,
|
| 59 |
'description' => t('{users}.uid')
|
| 60 |
),
|
| 61 |
'persona_id' => array(
|
| 62 |
'type' => 'int',
|
| 63 |
'size'=>'normal',
|
| 64 |
'unsigned' => TRUE,
|
| 65 |
'not null' => TRUE,
|
| 66 |
'default'=>0,
|
| 67 |
'description' => t('Id of the persona')
|
| 68 |
),
|
| 69 |
'persona_name' => array(
|
| 70 |
'type' => 'varchar',
|
| 71 |
'length' => 255,
|
| 72 |
'not null' => TRUE,
|
| 73 |
'default' => 'Default',
|
| 74 |
'description' => t('Name of the persona.')
|
| 75 |
),
|
| 76 |
),
|
| 77 |
'indexes' => array('uid' => array('uid')),
|
| 78 |
'primary key' => array('uid','persona_name')
|
| 79 |
);
|
| 80 |
|
| 81 |
$schema['openid_ax_values'] = array(
|
| 82 |
'description' => t('Stores values of the attributes associated with users.'),
|
| 83 |
'fields' => array(
|
| 84 |
'vid' => array(
|
| 85 |
'type' => 'serial',
|
| 86 |
'unsigned' => TRUE,
|
| 87 |
'not null' => TRUE,
|
| 88 |
'description' => t('Primary key: Unique value id')
|
| 89 |
),
|
| 90 |
'ax_id' => array(
|
| 91 |
'type' => 'int',
|
| 92 |
'size'=>'normal',
|
| 93 |
'unsigned' => TRUE,
|
| 94 |
'not null' => TRUE,
|
| 95 |
'description' => t('ax_id from {openid_ax_attributes}.ax_id')
|
| 96 |
),
|
| 97 |
'uid' => array(
|
| 98 |
'type' => 'int',
|
| 99 |
'size'=>'normal',
|
| 100 |
'unsigned' => TRUE,
|
| 101 |
'not null' => TRUE,
|
| 102 |
'description' => t('uid from {users}.uid')
|
| 103 |
),
|
| 104 |
'persona_id' => array(
|
| 105 |
'type' => 'int',
|
| 106 |
'size'=>'normal',
|
| 107 |
'unsigned' => TRUE,
|
| 108 |
'not null' => TRUE,
|
| 109 |
'default'=>0,
|
| 110 |
'description' => t('persona_id from {openid_ax_persona}.persona_id')
|
| 111 |
),
|
| 112 |
'ax_values' => array(
|
| 113 |
'type' => 'varchar',
|
| 114 |
'length' => 255,
|
| 115 |
'not null' => TRUE,
|
| 116 |
'default' => ''
|
| 117 |
),
|
| 118 |
'server' => array(
|
| 119 |
'type' => 'int',
|
| 120 |
'size'=>'tiny',
|
| 121 |
'length'=>1,
|
| 122 |
'not null' => TRUE,
|
| 123 |
'default' => 1
|
| 124 |
)
|
| 125 |
),
|
| 126 |
'indexes' => array('uid' => array('uid')),
|
| 127 |
'primary key' => array('vid')
|
| 128 |
);
|
| 129 |
|
| 130 |
return $schema;
|
| 131 |
}
|
| 132 |
/**
|
| 133 |
* Insert values into table openid_ax_attributes
|
| 134 |
*/
|
| 135 |
function _openid_ax_attributes_fill() {
|
| 136 |
$identifiers = _openid_ax_attributes_identifiers();
|
| 137 |
$identifiers_string = implode("'),('",$identifiers);
|
| 138 |
$query = "INSERT INTO {openid_ax_attributes} (identifier) VALUES ('$identifiers_string') ";
|
| 139 |
db_query($query);
|
| 140 |
return;
|
| 141 |
}
|
| 142 |
|
| 143 |
/**
|
| 144 |
* Create an array containing the identifiers as listed in
|
| 145 |
* http://openid.net/specs/openid-attribute-properties-list-1_0-01.html
|
| 146 |
* @return array
|
| 147 |
* Array containing the identifiers
|
| 148 |
*/
|
| 149 |
function _openid_ax_attributes_identifiers() {
|
| 150 |
$identifiers = array(
|
| 151 |
'http://openid.net/schema/namePerson/prefix',
|
| 152 |
'http://openid.net/schema/namePerson/first',
|
| 153 |
'http://openid.net/schema/namePerson/last',
|
| 154 |
'http://openid.net/schema/namePerson/middle',
|
| 155 |
'http://openid.net/schema/namePerson/suffix',
|
| 156 |
'http://openid.net/schema/namePerson/friendly',
|
| 157 |
'http://openid.net/schema/person/guid',
|
| 158 |
'http://openid.net/schema/birthDate/birthYear',
|
| 159 |
'http://openid.net/schema/birthDate/birthMonth',
|
| 160 |
'http://openid.net/schema/birthDate/birthday',
|
| 161 |
'http://openid.net/schema/gender',
|
| 162 |
'http://openid.net/schema/language/pref',
|
| 163 |
'http://openid.net/schema/contact/phone/default',
|
| 164 |
'http://openid.net/schema/contact/phone/home',
|
| 165 |
'http://openid.net/schema/contact/phone/business',
|
| 166 |
'http://openid.net/schema/contact/phone/cell',
|
| 167 |
'http://openid.net/schema/contact/phone/fax',
|
| 168 |
'http://openid.net/schema/contact/postaladdress/home',
|
| 169 |
'http://openid.net/schema/contact/postaladdressadditional/home',
|
| 170 |
'http://openid.net/schema/contact/city/home',
|
| 171 |
'http://openid.net/schema/contact/state/home',
|
| 172 |
'http://openid.net/schema/contact/country/home',
|
| 173 |
'http://openid.net/schema/contact/postalcode/home',
|
| 174 |
'http://openid.net/schema/contact/postaladdress/business',
|
| 175 |
'http://openid.net/schema/contact/postaladdressadditional/business',
|
| 176 |
'http://openid.net/schema/contact/city/business',
|
| 177 |
'http://openid.net/schema/contact/state/business',
|
| 178 |
'http://openid.net/schema/contact/country/business',
|
| 179 |
'http://openid.net/schema/contact/postalcode/business',
|
| 180 |
'http://openid.net/schema/contact/IM/default',
|
| 181 |
'http://openid.net/schema/contact/IM/AIM',
|
| 182 |
'http://openid.net/schema/contact/IM/ICQ',
|
| 183 |
'http://openid.net/schema/contact/IM/MSN',
|
| 184 |
'http://openid.net/schema/contact/IM/Yahoo',
|
| 185 |
'http://openid.net/schema/contact/IM/Jabber',
|
| 186 |
'http://openid.net/schema/contact/IM/Skype',
|
| 187 |
'http://openid.net/schema/contact/internet/email',
|
| 188 |
'http://openid.net/schema/contact/web/default',
|
| 189 |
'http://openid.net/schema/contact/web/blog',
|
| 190 |
'http://openid.net/schema/contact/web/Linkedin',
|
| 191 |
'http://openid.net/schema/contact/web/Amazon',
|
| 192 |
'http://openid.net/schema/contact/web/Flickr',
|
| 193 |
'http://openid.net/schema/contact/web/Delicious',
|
| 194 |
'http://openid.net/schema/company/name',
|
| 195 |
'http://openid.net/schema/company/title',
|
| 196 |
'http://openid.net/schema/media/spokenname',
|
| 197 |
'http://openid.net/schema/media/greeting/audio',
|
| 198 |
'http://openid.net/schema/media/greeting/video',
|
| 199 |
'http://openid.net/schema/media/biography',
|
| 200 |
'http://openid.net/schema/media/image',
|
| 201 |
'http://openid.net/schema/media/image/16x16',
|
| 202 |
'http://openid.net/schema/media/image/32x32',
|
| 203 |
'http://openid.net/schema/media/image/48x48',
|
| 204 |
'http://openid.net/schema/media/image/64x64',
|
| 205 |
'http://openid.net/schema/media/image/80x80',
|
| 206 |
'http://openid.net/schema/media/image/128x128',
|
| 207 |
'http://openid.net/schema/media/image/160x120',
|
| 208 |
'http://openid.net/schema/media/image/320x240',
|
| 209 |
'http://openid.net/schema/media/image/640x480',
|
| 210 |
'http://openid.net/schema/media/image/120x160',
|
| 211 |
'http://openid.net/schema/media/image/240x320',
|
| 212 |
'http://openid.net/schema/media/image/480x640',
|
| 213 |
'http://openid.net/schema/media/image/favicon',
|
| 214 |
'http://openid.net/schema/timezone'
|
| 215 |
);
|
| 216 |
return $identifiers;
|
| 217 |
}
|