Skip to content

Instantly share code, notes, and snippets.

@bmbrands
Created July 11, 2013 14:55
Show Gist options
  • Save bmbrands/5976154 to your computer and use it in GitHub Desktop.
Save bmbrands/5976154 to your computer and use it in GitHub Desktop.
moodle file stuff
function get_content() {
global $DB,$USER,$OUTPUT,$CFG;
$courseid = $this->page->course->id;
//Ensure only teacher can use this block
$coursecontext = context_course::instance($courseid);
if(has_capability('moodle/course:manage', $coursecontext)){
$this->content = new stdClass;
$fs = get_file_storage();
$files = $fs->get_area_files($coursecontext->id, 'course', 'attachment', 0);
$table = new html_table();
$table->head = array('filename');
$tabledata = array();
foreach ($files as $f) {
// $f is an instance of stored_file
$f->get_filename();
array_push($tabledata,$child->get_params());
}
$table->data = $tabledata;
$this->content = html_writer::table($table);
}
return $this->content;
}
@shuai-zhang
Copy link

Hi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment