Thanks for pointing me in sort of the right direction Gareth. Unfortunately, I haven't been 100% successful with it. Nowhere on that page does it talk about getting the base information for the queries on that page. Thankfully I found this post that had some hints at what I wanted.
https://moodle.org/mod/forum/discuss.php?d=259458
From that page, I built my query.
$sql = "SELECT f.id, f.contextid, f.component, f.filearea, f.itemid, f.filepath, f.filename
FROM mdl_context cx
JOIN mdl_course c ON cx.instanceid=c.id
JOIN mdl_files f ON cx.id=f.contextid
WHERE f.filename <> '.'
AND f.component = 'course'
AND c.id = $cid ";
$result = $DB->get_records_sql($sql);
When that runs I get this.
array (size=1)
29669 =>
object(stdClass)[264]
public 'id' => '29669' (length=5)
public 'contextid' => '96' (length=2)
public 'component' => 'course' (length=6)
public 'filearea' => 'overviewfiles' (length=13)
public 'itemid' => '0' (length=1)
public 'filepath' => '/' (length=1)
public 'filename' => 'CoursePhoto.jpg' (length=15)
Which is great because it is all of the information needed for some of the FileAPI scripts. The problem is I don't know how to build the link to display the file to users when they load a page. According to the warnings for the FileAPI Read section I should be using the File Browser instead. Here is my code showing use of file storage and file browser.
if(count($result) == 0){
return "images/centrifugal%20pump%2011.png";
}else{
$fs = get_file_storage();
$fb = new file_browser();
foreach($result as $key=>$value){
$url = $fs->get_file($value->contextid, $value->component, $value->filearea, $value->itemid, $value->filepath, $value->filename);
$context = context::instance_by_id($value->contextid);
$url2 = $fb->get_file_info($context, $value->component, $value->filearea, $value->itemid, $value->filepath, $value->filename);
}
$url var_dumps to this.
object(stored_file)[262]
private 'fs' =>
object(file_storage)[253]
private 'filedir' => 'D:\ABC\wamp\moodledata2/filedir' (length=31)
private 'trashdir' => 'D:\ABC\wamp\moodledata2/trashdir' (length=32)
private 'tempdir' => 'D:\ABC\wamp\moodledata2/temp/filestorage' (length=40)
private 'dirpermissions' => '511' (length=3)
private 'filepermissions' => '438' (length=3)
private 'file_record' =>
object(stdClass)[266]
public 'id' => '29669' (length=5)
public 'contenthash' => 'c99973ab39ab64550229ad896bcb31b07a4136d5' (length=40)
public 'pathnamehash' => '6090dd889624ac111dfa4027bc218cbbbd339218' (length=40)
public 'contextid' => '96' (length=2)
public 'component' => 'course' (length=6)
public 'filearea' => 'overviewfiles' (length=13)
public 'itemid' => '0' (length=1)
public 'filepath' => '/' (length=1)
public 'filename' => 'CoursePhoto.jpg' (length=15)
public 'userid' => '6' (length=1)
public 'filesize' => '16385' (length=5)
public 'mimetype' => 'image/jpeg' (length=10)
public 'status' => '0' (length=1)
public 'source' => 'centrifugal-pump-11b.jpg' (length=24)
public 'author' => 'Willy Wonka' (length=15)
public 'license' => 'allrightsreserved' (length=17)
public 'timecreated' => '1511229957' (length=10)
public 'timemodified' => '1511229964' (length=10)
public 'sortorder' => '0' (length=1)
public 'referencefileid' => null
public 'repositoryid' => null
public 'reference' => null
public 'referencelastsync' => null
private 'filedir' => 'D:\ABC\wamp\moodledata2/filedir' (length=31)
private 'repository' => null
$url2 var_dumps to null.
So my main problem right now is I am not getting a URL that I can use to show the image stored in the course overviewfiles area. Any additional help with this would be greatly appreciated.