function optimizedb_requirements in OptimizeDB 7
Same name and namespace in other branches
- 8 optimizedb.install \optimizedb_requirements()
- 6 optimizedb.install \optimizedb_requirements()
Implements hook_requirements().
File
- ./
optimizedb.install, line 34 - Installation file for Database Optimization.
Code
function optimizedb_requirements($phase) {
$requirements = array();
// Ensure translations don't break during installation.
$t = get_t();
if ($phase == 'runtime') {
// Check, if necessary optimization.
$notify_optimize = variable_get('optimizedb_notify_optimize', FALSE);
if ($notify_optimize) {
// The last time optimization in Unix format.
$last_optimization = variable_get('optimizedb_last_optimization', 0);
// If optimization is not carried out earlier
// must display an appropriate message.
if ((bool) $last_optimization !== FALSE) {
$time_optimization = $t('Last run: @date ago.', array(
'@date' => _optimizedb_date($last_optimization),
));
}
else {
$time_optimization = $t('Optimization yet was not run.');
}
$requirements['optimizedb'] = array(
'title' => $t('Database Optimization'),
'description' => $t('You must perform <a href="@optimize_link">database optimization</a>. <a href="@hide_link">Hide notification</a>', array(
'@optimize_link' => url('admin/config/development/optimizedb'),
'@hide_link' => url('admin/config/development/optimizedb/hide'),
)),
'severity' => REQUIREMENT_ERROR,
'value' => $time_optimization,
);
}
}
if ($phase == 'install') {
// Need to verify the database connection, hook is called when
// install installation profile, if the module is added to the dependencies.
if (Database::isActiveConnection()) {
module_load_include('module', 'optimizedb', 'optimizedb');
if ($message = optimizedb_check_works()) {
$requirements['optimizedb'] = array(
'title' => $t('Database Optimization'),
'description' => $message,
'severity' => REQUIREMENT_ERROR,
);
}
}
}
return $requirements;
}