function check_assignment_file($assignmentid, $file) { global $CFG, $USER; $fileinfo = new stdClass(); if (!($assignment = get_record_sql('SELECT s.id, s.assignment, a.course AS courseid FROM ' . $CFG->prefix . 'assignment_submissions s JOIN ' . $CFG->prefix . 'assignment a ON s.assignment=a.id WHERE s.userid=\'' . $USER->id . '\' AND s.id=\'' . $assignmentid . '\''))) { print_error("invalidassignmentid", "block_exabis_eportfolio"); } $basedir = block_exabis_eportfolio_moodleimport_file_area_name($USER->id, $assignment->assignment, $assignment->courseid); if ($files = get_directory_list($CFG->dataroot . '/' . $basedir)) { foreach ($files as $key => $actFile) { if ($actFile == $file) { $fileinfo->filename = $file; $fileinfo->basedir = $basedir; $fileinfo->fullpath = $basedir . '/' . $actFile; return $fileinfo; } } } return false; }
block_exabis_eportfolio_print_header("exportimportmoodleimport"); $assignments = get_records_sql("SELECT s.id, s.assignment, s.timemodified, a.name, a.course, c.fullname AS coursename\r\n\t\t\t\t\t\t\t\tFROM {$CFG->prefix}assignment_submissions s\r\n\t\t\t\t\t\t\t\tJOIN {$CFG->prefix}assignment a ON s.assignment=a.id\r\n\t\t\t\t\t\t\t\tLEFT JOIN {$CFG->prefix}course c on a.course = c.id\r\n\t\t\t\t\t\t\t\tWHERE s.userid='{$USER->id}'"); if (right_to_left()) { // rtl table alignment support (nadavkav patch) $alignment = "left"; } else { $alignment = "right"; } $table = new stdClass(); $table->head = array(get_string("modulename", "assignment"), get_string("time"), get_string("file"), get_string("course", "block_exabis_eportfolio"), get_string("action")); $table->align = array($alignment, $alignment, $alignment, $alignment, $alignment); $table->size = array("20%", "20%", "25%", "20%", "15%"); $table->width = "85%"; if ($assignments) { foreach ($assignments as $assignment) { $basedir = block_exabis_eportfolio_moodleimport_file_area_name($USER->id, $assignment->assignment, $assignment->course); if ($files = get_directory_list($CFG->dataroot . '/' . $basedir)) { unset($table->data); unset($icons); $icons = ''; require_once $CFG->libdir . '/filelib.php'; foreach ($files as $key => $file) { $icon = mimeinfo('icon', $file); if ($CFG->slasharguments) { $ffurl = $CFG->wwwroot . '/file.php/' . $basedir . '/' . $file; } else { $ffurl = $CFG->wwwroot . '/file.php?file=/' . $basedir . '/' . $file; } $icons .= '<a href="' . $CFG->wwwroot . '/blocks/exabis_eportfolio/import_moodle_add_file.php?courseid=' . $courseid . '&assignmentid=' . $assignment->id . '&filename=' . $file . '&sesskey=' . sesskey() . '">' . get_string("add_this_file", "block_exabis_eportfolio") . '</a>'; $table->data[] = array($assignment->name, userdate($assignment->timemodified), '<img src="' . $CFG->pixpath . '/f/' . $icon . '" class="icon" alt="' . $icon . '" />' . '<a href="' . $ffurl . '" >' . $file . '</a><br />', $assignment->coursename, $icons); }