mollie_payment.install in Mollie Payment 7
File
mollie_payment.install
View source
<?php
function mollie_payment_schema() {
$schema['mollie_payment_payment_method_configurations'] = array(
'description' => 'Configuration data for Mollie Payment payment methods.',
'fields' => array(
'pmid' => array(
'description' => 'The pmid of the payment method within Payment.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'configuration' => array(
'description' => 'Serialized representation of the configuration.',
'type' => 'text',
'not null' => TRUE,
),
),
'primary key' => array(
'pmid',
),
);
return $schema;
}
function mollie_payment_update_7101() {
global $conf;
$schema = drupal_get_schema_unprocessed('mollie_payment');
db_create_table('mollie_payment_payment_method_configurations', $schema['mollie_payment_payment_method_configurations']);
foreach ($conf as $name => $value) {
if (strpos($name, 'mollie_payment_') === 0 && strpos($name, '_controller_data') !== FALSE) {
$info = explode('_', $name);
$pmid = $info[2];
mollie_payment_payment_method_configuration_save($pmid, $value);
variable_del($name);
}
}
}
function mollie_payment_update_7102() {
$records = db_select('mollie_payment_payment_method_configurations', 'c')
->fields('c', array(
'pmid',
'configuration',
))
->execute()
->fetchAllKeyed();
foreach ($records as $pmid => $configuration) {
$config = unserialize($configuration);
$config['mollie_api_key'] = $config['mollie_id'];
unset($config['mollie_id']);
mollie_payment_payment_method_configuration_save($pmid, $config);
}
variable_del('mollie_payment_test_message');
}