### Eclipse Workspace Patch 1.0 #P moodlesf Index: help.php =================================================================== RCS file: /cvsroot/moodle/moodle/help.php,v retrieving revision 1.34 diff -u -r1.34 help.php --- help.php 22 Aug 2006 22:12:17 -0000 1.34 +++ help.php 10 Nov 2006 10:26:31 -0000 @@ -44,28 +44,53 @@ continue; } - // Work out which directory the help files live in. - if ($lang == 'en_utf8') { - $helpdir = $CFG->dirroot; - } else { - $helpdir = $CFG->dataroot; + // Work out/locate which directory the help files may live in. + // Then which file in there we should be serving. + // Set module/file subpath (set to $file for $module == 'moodle' + $modfile = $file; + if ($module != 'moodle') { + $modfile = $module.'/'.$file; } - $helpdir .= "/lang/$lang/help"; - // Then which file in there we should be serving. - if ($module == 'moodle') { - $filepath = "$helpdir/$file"; - } else { - $filepath = "$helpdir/$module/$file"; + // Check for moodle source help directory + $fileexists = false; + if (is_dir($CFG->dirroot.'/lang/'.$lang.'/help')) { + + // Check if file exists (and readable) in _local directory + $filepath = $CFG->dirroot.'/lang/'.$lang.'_local/help/'.$modfile; + $fileexists = file_exists_and_readable($filepath); + + // Check source help directory if no _local help directory or file does not exist + if (!$fileexists) { + + // Get file exists (and readable) flag + $filepath = $CFG->dirroot.'/lang/'.$lang.'/help/'.$modfile; + $fileexists = file_exists_and_readable($filepath); + } + } - // If that does not exist, try a fallback into the module code folder. - if (!file_exists($filepath)) { - $filepath = "$CFG->dirroot/mod/$module/lang/$lang/help/$module/$file"; + // Check data help directory if no source help directories or file does not exist + if (!$fileexists && is_dir($CFG->dataroot.'/lang/'.$lang.'/help')) { + + // Check if file exists (and readable) in _local directory + $filepath = $CFG->dataroot.'/lang/'.$lang.'_local/help/'.$modfile; + $fileexists = file_exists_and_readable($filepath); + + // Check data help directory if no _local help directory or file does not exist + if (!$fileexists) { + $filepath = $CFG->dataroot.'/lang/'.$lang.'/help/'.$modfile; + $fileexists = file_exists_and_readable($filepath); } } + // Last chance, if all else fails, try a fallback into the module code folder. + if (!$fileexists && $module != 'moodle') { + $filepath = $CFG->dirroot.'/mod/'.$module.'/lang/'.$lang.'/help/'.$modfile; + $fileexists = file_exists_and_readable($filepath); + } + // Now, try to include the help text from this file, if we can. - if (file_exists_and_readable($filepath)) { + if ($fileexists) { $helpfound = true; @include($filepath); // The actual helpfile