function opigno_tincan_api_requirements in Opigno TinCan API 7
Same name and namespace in other branches
- 8 opigno_tincan_api.install \opigno_tincan_api_requirements()
- 3.x opigno_tincan_api.install \opigno_tincan_api_requirements()
Implements hook_requirements().
File
- ./
opigno_tincan_api.module, line 40
Code
function opigno_tincan_api_requirements($phase) {
$requirements = array();
// Ensure translations do not break
$t = get_t();
// Check if the TinCanPHP library is installed
$libraries = libraries_get_libraries();
if (isset($libraries['TinCanPHP'])) {
$library_is_installed = true;
}
else {
$library_is_installed = false;
}
// Check if the module parameters are set.
$endpoint = variable_get('opigno_tincan_api_endpoint', '');
$username = variable_get('opigno_tincan_api_username', '');
$password = variable_get('opigno_tincan_api_password', '');
$requirements['opigno_tincan_api']['title'] = 'Opigno TinCan API';
if (empty($endpoint) || empty($username) || empty($password)) {
$is_configured = false;
}
else {
$is_configured = true;
}
// If the site is in runtime, put in status page these information
if ($phase == 'runtime') {
// Check if the TinCanPHP library is installed.
$requirements['TinCanPHP']['title'] = 'TinCanPHP';
if ($library_is_installed) {
$requirements['TinCanPHP']['value'] = $t('Installed');
$requirements['TinCanPHP']['severity'] = REQUIREMENT_OK;
}
else {
$requirements['TinCanPHP']['value'] = $t('Not Installed');
$requirements['TinCanPHP']['severity'] = REQUIREMENT_ERROR;
$requirements['TinCanPHP']['description'] = $t('Please install the !tincanphp_library in the <em>sites/all/library/TinCanPHP</em> folder.', array(
'!tincanphp_library' => l($t('TinCanPHP library'), 'https://github.com/RusticiSoftware/TinCanPHP/releases'),
));
}
// Check if the module parameters are set.
if ($is_configured) {
$requirements['opigno_tincan_api']['value'] = $t('Configured');
$requirements['opigno_tincan_api']['severity'] = REQUIREMENT_OK;
}
else {
$requirements['opigno_tincan_api']['value'] = $t('Not set');
$requirements['opigno_tincan_api']['severity'] = REQUIREMENT_WARNING;
$requirements['opigno_tincan_api']['description'] = $t('Please configure the LRS connection in the !setting_page.', array(
'!setting_page' => l('settings page', 'admin/opigno/system/tincan'),
));
}
}
// If during install or update, put the information in drupal message
if ($phase == 'install' || $phase == 'update') {
if (!$library_is_installed) {
drupal_set_message($t('Please install the !tincanphp_library in the <em>sites/all/library/TinCanPHP</em> folder.', array(
'!tincanphp_library' => l($t('TinCanPHP library'), 'https://github.com/RusticiSoftware/TinCanPHP/releases'),
)), 'warning', false);
}
if (!$is_configured) {
drupal_set_message($t('Please configure the LRS connection in the !setting_page.', array(
'!setting_page' => l('settings page', 'admin/opigno/system/tincan'),
)), 'warning', false);
}
}
return $requirements;
}