function _forena_revert_reports in Forena Reports 8
Same name and namespace in other branches
- 7.5 forena.module \_forena_revert_reports()
- 7.4 forena.module \_forena_revert_reports()
Recursively , all report files from the source directory to the destination directory
Parameters
$src_dir Source directory to copy files from:
Return value
int Number of reports reverted.
1 call to _forena_revert_reports()
- forena_sync_reports in ./
forena.module - Enter description here ...
File
- ./
forena.module, line 572
Code
function _forena_revert_reports($subdir = '') {
static $cnt = 0;
$cnt++;
if ($cnt > 100) {
return 0;
}
$i = 0;
$src_dir = rtrim(FrxAPI::File()->dir, '/');
if ($subdir) {
$src_dir .= '/' . $subdir;
}
$d = dir($src_dir);
while ($d && false !== ($rpt_file = $d
->read())) {
$src_file = $d->path . '/' . $rpt_file;
if (strpos($rpt_file, '.') !== 0 && is_file($src_file)) {
$filename = $subdir ? "{$subdir}/{$rpt_file}" : $rpt_file;
$i += FrxAPI::File()
->revert($filename);
}
else {
if (strpos($rpt_file, '.') !== 0) {
// Recurse into sub directory
$dir = $subdir ? $subdir . '/' . $rpt_file : $rpt_file;
$i += _forena_revert_reports($dir);
}
}
}
if ($d) {
$d
->close();
}
return $i;
}