commerce_braintree.install in Commerce Braintree 7
File
commerce_braintree.install
View source
<?php
function commerce_braintree_enable() {
$weight = db_select('system', 's')
->fields('s', array(
'weight',
))
->condition('name', 'commerce_cardonfile', '=')
->execute()
->fetchField();
db_update('system')
->fields(array(
'weight' => $weight + 1,
))
->condition('type', 'module')
->condition('name', 'commerce_braintree')
->execute();
}
function commerce_braintree_requirements($phase) {
$requirements = array();
$t = get_t();
if (version_compare(phpversion(), '5.2.1', '<')) {
$requirements['php']['description'] = $t('Your PHP installation is too old. Braintree requires at least PHP %version.', array(
'%version' => '5.2.1',
));
$requirements['php']['severity'] = REQUIREMENT_ERROR;
}
$requiredExtensions = array(
'xmlwriter',
'SimpleXML',
'openssl',
'dom',
'hash',
'curl',
);
$disabled_extensions = array();
$value = '';
foreach ($requiredExtensions as $ext) {
$ext_enabled = extension_loaded($ext) ? 'Enabled' : 'Disabled';
$value .= $ext . ': ' . $ext_enabled . ' ';
if ($ext_enabled == 'Disabled') {
$disabled_extensions[] = $ext;
}
}
$requirements['commerce_braintree_php_extensions'] = array(
'title' => $t('Braintree PHP Extensions'),
'value' => $phase == 'install' ? '' : $value,
);
if ($disabled_extensions) {
$requirements['commerce_braintree_php_extensions']['severity'] = REQUIREMENT_ERROR;
$requirements['commerce_braintree_php_extensions']['description'] = $t('The following PHP extensions must be enabled for Braintree: ' . implode(', ', $disabled_extensions));
}
return $requirements;
}