paypal_donations.install in PayPal Donations 7
Sets up the base table for our entity and a table to store information about the entity types.
File
paypal_donations.installView source
<?php
/**
* @file
* Sets up the base table for our entity and a table to store information about
* the entity types.
*/
/**
* Implements hook_schema().
*/
function paypal_donations_schema() {
$schema = array();
$schema['paypal_donations_item'] = array(
'description' => 'The base table for paypal_donations_item entities.',
'fields' => array(
'donation_id' => array(
'description' => 'Primary Key: Identifier for a donation.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'created' => array(
'description' => 'A timestamp to indicate if or when the item was added',
'type' => 'int',
'size' => 'big',
'not null' => TRUE,
'default' => 1,
),
),
'primary key' => array(
'donation_id',
),
'indexes' => array(
'created' => array(
'created',
),
),
);
return $schema;
}
/**
* Implements hook_install().
*/
function paypal_donations_install() {
$t = get_t();
if (!field_info_field('field_paypal_transaction_id')) {
$field = array(
'field_name' => 'field_paypal_transaction_id',
'type' => 'text',
);
field_create_field($field);
$instance = array(
'field_name' => 'field_paypal_transaction_id',
'entity_type' => 'paypal_donations_item',
'label' => 'PayPal transaction id',
'bundle' => 'paypal_donations_item',
'required' => TRUE,
'settings' => array(),
'widget' => array(
'type' => 'textfield',
),
);
field_create_instance($instance);
}
if (!field_info_field('field_paypal_donator_email')) {
$field = array(
'field_name' => 'field_paypal_donator_email',
'type' => 'text',
);
field_create_field($field);
$instance = array(
'field_name' => 'field_paypal_donator_email',
'entity_type' => 'paypal_donations_item',
'label' => 'PayPal donation e-mail',
'bundle' => 'paypal_donations_item',
'required' => TRUE,
'settings' => array(),
'widget' => array(
'type' => 'textfield',
),
);
field_create_instance($instance);
}
if (!field_info_field('field_paypal_donations_amount')) {
$field = array(
'field_name' => 'field_paypal_donations_amount',
'type' => 'number_float',
);
field_create_field($field);
$instance = array(
'field_name' => 'field_paypal_donations_amount',
'entity_type' => 'paypal_donations_item',
'label' => 'PayPal donation amount',
'bundle' => 'paypal_donations_item',
'required' => TRUE,
'settings' => array(),
'widget' => array(
'type' => 'textfield',
),
);
field_create_instance($instance);
}
if (!field_info_field('field_paypal_donator_name')) {
$field = array(
'field_name' => 'field_paypal_donator_name',
'type' => 'text',
);
field_create_field($field);
$instance = array(
'field_name' => 'field_paypal_donator_name',
'entity_type' => 'paypal_donations_item',
'label' => 'PayPal donator name',
'bundle' => 'paypal_donations_item',
'required' => TRUE,
'settings' => array(),
'widget' => array(
'type' => 'textfield',
),
);
field_create_instance($instance);
}
if (!field_info_field('field_paypal_donator_country')) {
$field = array(
'field_name' => 'field_paypal_donator_country',
'type' => 'text',
);
field_create_field($field);
$instance = array(
'field_name' => 'field_paypal_donator_country',
'entity_type' => 'paypal_donations_item',
'label' => 'PayPal donator country',
'bundle' => 'paypal_donations_item',
'required' => TRUE,
'settings' => array(),
'widget' => array(
'type' => 'textfield',
),
);
field_create_instance($instance);
}
if (!field_info_field('field_paypal_donations_type')) {
$field = array(
'field_name' => 'field_paypal_donations_type',
'type' => 'list_text',
'cardinality' => 1,
'settings' => array(
'allowed_values' => array(
'one_time' => $t('One time donation'),
'recurring' => $t('Recurring donation'),
),
'allowed_values_function' => '',
),
);
field_create_field($field);
$instance = array(
'field_name' => 'field_paypal_donations_type',
'entity_type' => 'paypal_donations_item',
'label' => 'PayPal donation type',
'bundle' => 'paypal_donations_item',
'required' => TRUE,
'settings' => array(),
'widget' => array(
'type' => 'options_select',
),
);
field_create_instance($instance);
}
}
/**
* Implements hook_uninstall().
*/
function paypal_donations_uninstall() {
$fields_to_be_deleted = array(
'field_paypal_transaction_id',
'field_paypal_donator_email',
'field_paypal_donations_amount',
'field_paypal_donator_name',
'field_paypal_donator_country',
'field_paypal_donations_type',
);
foreach ($fields_to_be_deleted as $field) {
$instance = array(
'field_name' => $field,
'entity_type' => 'paypal_donations_item',
'bundle' => 'paypal_donations_item',
);
field_delete_instance($instance);
}
require_once drupal_get_path("module", "paypal_donations") . "/includes/paypal_donations.variable.inc";
$variables = array_keys(paypal_donations_variable_info(array()));
foreach ($variables as $var) {
variable_del($var);
}
}
Functions
Name![]() |
Description |
---|---|
paypal_donations_install | Implements hook_install(). |
paypal_donations_schema | Implements hook_schema(). |
paypal_donations_uninstall | Implements hook_uninstall(). |