session_cache_file.install in Session Cache API 7
File
session_cache_file/session_cache_file.install
View source
<?php
function session_cache_file_requirements($phase) {
if ($phase != 'runtime') {
return;
}
$t = get_t();
$requirements['session_cache_file']['title'] = $t('Session Cache File cache');
$session_cache_root = session_cache_file_directory();
if ($session_cache_root) {
$requirements['session_cache_file']['value'] = $t('Installed at %path', array(
'%path' => $session_cache_root,
));
$requirements['session_cache_file']['severity'] = REQUIREMENT_OK;
}
else {
$requirements['session_cache_file']['value'] = $t('Not set or could not be created. Check directory permissions or re-configure <a href="@url">here</a>.', array(
'@url' => url('admin/config/media/file-system'),
));
$requirements['session_cache_file']['severity'] = REQUIREMENT_ERROR;
}
return $requirements;
}
function session_cache_file_uninstall() {
require_once 'session_cache_file.module';
$session_cache_root = session_cache_file_directory();
if ($session_cache_root) {
session_cache_file_rrmdir($session_cache_root);
}
}
function session_cache_file_rrmdir($dir) {
if (is_dir($dir)) {
$files = scandir($dir);
foreach ($files as $file) {
if ($file != '.' && $file != '..') {
if (is_dir("{$dir}/{$file}")) {
session_cache_file_rrmdir("{$dir}/{$file}");
}
else {
unlink("{$dir}/{$file}");
}
}
}
return rmdir($dir);
}
return FALSE;
}