Skip to content

Commit ffe2148

Browse files
authored
Merge pull request #55 from BrickOzp/subdirs
Auto find attachment subdirs in repair_settings
2 parents 31135de + dc1846f commit ffe2148

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

repair_settings.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -932,6 +932,17 @@ function guess_attachments_directories($id, $array_setting)
932932
if (strrpos($array_setting, $dirname) == (strlen($array_setting) - strlen($dirname)))
933933
return array(dirname(__FILE__) . '/' . $dirname);
934934

935+
// 3rd guess: sub directory names
936+
if (!empty($availableDirs))
937+
foreach ($availableDirs as $dirname)
938+
if (strrpos($array_setting, DIRECTORY_SEPARATOR . $dirname . DIRECTORY_SEPARATOR) > 0)
939+
{
940+
$subdir = opendir(dirname(__FILE__) . DIRECTORY_SEPARATOR . $dirname);
941+
while (false !== ($file = readdir($subdir)))
942+
if (strrpos($array_setting, $dirname . DIRECTORY_SEPARATOR . $file) == (strlen($array_setting) - strlen($dirname . DIRECTORY_SEPARATOR . $file)))
943+
return array(dirname(__FILE__) . DIRECTORY_SEPARATOR . $dirname . DIRECTORY_SEPARATOR . $file);
944+
}
945+
935946
// Doing it later saves in case the attached files have been deleted from the file system
936947
if (empty($usedDirs) && empty($availableDirs))
937948
return false;

0 commit comments

Comments
 (0)