* Contructor
* @param string $filedir full path to pool directory
*/
- public function __construct() {
- global $CFG;
- if (isset($CFG->filedir)) {
- $this->filedir = $CFG->filedir;
- } else {
- $this->filedir = $CFG->dataroot.'/filedir';
- }
+ public function __construct($filedir) {
+ $this->filedir = $filedir;
// make sure the file pool directory exists
if (!is_dir($this->filedir)) {
}
}
+ /**
+ * Returns location of filedir (file pool)
+ * @return string pathname
+ */
+ public function get_filedir() {
+ return $this->filedir;
+ }
+
/**
* Calculates sha1 hash of unique full path name information
* @param int $contextid
* @return ful path to pool file with file content
**/
protected function get_content_file_location() {
- global $CFG;
- if (isset($CFG->filedir)) {
- $filedir = $CFG->filedir;
- } else {
- $filedir = $CFG->dataroot.'/filedir';
- }
+ $filedir = $this->fs->get_filedir();
$contenthash = $this->file_record->contenthash;
$l1 = $contenthash[0].$contenthash[1];
$l2 = $contenthash[2].$contenthash[3];
require_once("$CFG->libdir/filelib.php");
- $fs = new file_storage();
+ if (isset($CFG->filedir)) {
+ $filedir = $CFG->filedir;
+ } else {
+ $filedir = $CFG->dataroot.'/filedir';
+ }
+
+ $fs = new file_storage($filedir);
return $fs;
}