$record->resource_size = $coursefilelist_beforesave[$resource_id]->filesize; $record->uploaded_by = $coursefilelist_beforesave[$resource_id]->author; $record->timeuploaded = $coursefilelist_beforesave[$resource_id]->timecreated; $now = new DateTime(); $record->timeidentified = $now->getTimestamp(); $record->license = $resource_values['license']; $record->cite = $resource_values['cite']; $DB->insert_record('block_course_files_license_f', $record, false); } } } } // After handling the post request (if it was a post request) // we make the query again, so the resourses already saved will not be on the list $coursefilelist = get_course_files_list(); $identifiedfileslist = get_identified_course_files_list(); $table = new html_table(); $table->attributes = array('style' => 'font-size: 80%;'); $table->head = array(get_string('timecreated', 'block_course_files_license'), get_string('filename', 'block_course_files_license'), get_string('uploaded_by', 'block_course_files_license')); foreach ($licenses as $l) { $header = '<div style="width:100%;text-align:center;">'; $header .= '(<a href="#" onclick="'; $header .= ' $(\'.' . $l->id . '\').prop(\'checked\', true);'; $header .= ' return false">'; $header .= get_string('mark_all', 'block_course_files_license'); $header .= '</a>)<br>'; $header .= $l->name; $header .= '</div>'; array_push($table->head, $header); } $operations_header = '<div style="width:100%;text-align:center;">';
* Block to show course files and usage * * @package block_course_files_licence * @copyright 2015 Adrian Rodriguez Vargas * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ require '../../config.php'; require_once $CFG->dirroot . '/blocks/course_files_license/locallib.php'; require_login(); $courseid = required_param('courseid', PARAM_INT); // If no courseid is given. $course = $DB->get_record('course', array('id' => $courseid)); $context = context_course::instance($courseid); require_capability('block/course_files_license:viewlist', $context); $coursefilelist = get_course_files_list(); $identifiedcoursefilelist = get_identified_course_files_list(); $file_instances = []; foreach ($identifiedcoursefilelist as $f_id => $f_value) { $file_instances[] = $f_value->id; } if ($_POST) { require_capability('block/course_files_license:deleteinstance', $context); if (in_array('all', array_keys($_POST))) { if ($_POST['all'] == true) { $DB->delete_records('block_course_files_license_f', array('courseid' => $_POST['courseid'])); } } elseif (in_array('id', array_keys($_POST))) { $DB->delete_records('block_course_files_license_f', array('id' => $_POST['id'])); } } $view_url = new moodle_url('/blocks/course_files_license/view.php', array('courseid' => $courseid));