function clamav_requirements in ClamAV 7
Same name and namespace in other branches
- 8 clamav.install \clamav_requirements()
- 6 clamav.install \clamav_requirements()
- 2.x clamav.install \clamav_requirements()
Implements hook_requirements().
File
- ./
clamav.install, line 10 - Hook_requirements for the ClamAV module.
Code
function clamav_requirements($phase) {
$t = get_t();
$requirements = array();
if ($phase == 'runtime') {
// Try to connect on the current settings.
$mode = variable_get('clamav_mode', CLAMAV_DEFAULT_MODE);
if ($mode == CLAMAV_USE_DAEMON) {
$settings = array(
'host' => variable_get('clamav_daemon_host', CLAMAV_DEFAULT_HOST),
'port' => variable_get('clamav_daemon_port', CLAMAV_DEFAULT_PORT),
);
$mode = $t('Daemon (over TCP/IP)');
}
elseif ($mode == CLAMAV_USE_EXECUTABLE) {
$settings = variable_get('clamav_executable_path', CLAMAV_DEFAULT_PATH);
$mode = $t('Executable');
}
elseif ($mode == CLAMAV_USE_DAEMON_UNIX_SOCKET) {
$settings = array(
'unix_socket_path' => variable_get('clamav_daemon_unix_socket', CLAMAV_DEFAULT_UNIX_SOCKET),
);
$mode = $t('Daemon (over Unix-socket)');
}
require_once dirname(__FILE__) . '/clamav.inc';
$ver = clamav_get_version($settings);
// Report success or failure.
$requirements[] = array(
'title' => $t('ClamAV'),
'value' => empty($ver) ? $t('@mode not found.', array(
'@mode' => $mode,
)) : $t('@mode: @version', array(
'@mode' => $mode,
'@version' => $ver,
)),
'severity' => empty($ver) ? REQUIREMENT_ERROR : REQUIREMENT_OK,
'description' => empty($ver) && user_access('administer site configuration') ? l(t('Configure ClamAV'), 'admin/config/media/clamav') : '',
);
}
return $requirements;
}