$record->resource_url = $resource_url; $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); }
function get_content() { global $CFG, $DB, $OUTPUT, $COURSE; if ($this->content !== null) { return $this->content; } $this->content = new stdClass(); $this->content->text = ''; $this->content->footer = ''; if (empty($this->instance)) { return $this->content; } if (!has_capability('block/course_files_license:viewlist', context_course::instance($COURSE->id))) { return $this->content; } $context = context_course::instance($COURSE->id); $contextcheck = $context->path . '/%'; // Get the top file files used on the course by size. $filelist = get_course_files_list(); if ($filelist) { if (!isset($CFG->block_course_files_license_popup)) { $CFG->block_course_files_license_popup = false; } if ($CFG->block_course_files_license_popup == true) { $this->content->text .= '<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>'; $this->content->text .= '<script type="text/javascript">'; $this->content->text .= ' $(document).ready(function() {'; $this->content->text .= ' $("#modal-msg").modal("show");'; $this->content->text .= ' });'; $this->content->text .= '</script>'; $this->content->text .= '<div class="modal fade" id="modal-msg" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" data-backdrop="static">'; $this->content->text .= ' <div class="modal-dialog" role="document">'; $this->content->text .= ' <div class="modal-content">'; $this->content->text .= ' <div class="modal-header">'; $this->content->text .= ' <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>'; $this->content->text .= ' <h4 class="modal-title" id="myModalLabel">' . get_string('modaltitle', 'block_course_files_license') . '</h4>'; $this->content->text .= ' </div>'; $this->content->text .= ' <div class="modal-body">'; $this->content->text .= get_string('files_to_idenfity_modal', 'block_course_files_license'); $this->content->text .= ' </div>'; $this->content->text .= ' <div class="modal-footer">'; $this->content->text .= ' <a href="' . new moodle_url('/blocks/course_files_license/view.php', array('courseid' => $COURSE->id)) . '" '; $this->content->text .= 'class="btn btn-default">' . get_string('filelist', 'block_course_files_license') . '</a>'; $this->content->text .= ' <button type="button" class="btn btn-primary" data-dismiss="modal">' . get_string('close', 'block_course_files_license') . '</button>'; $this->content->text .= ' </div>'; $this->content->text .= ' </div>'; $this->content->text .= ' </div>'; $this->content->text .= '</div>'; } $this->content->text .= '<p class="justify">' . get_string('files_to_idenfity', 'block_course_files_license') . '</p>'; $this->content->text .= '<a class="btn btn-block btn-danger btn-sm" href="'; $this->content->text .= new moodle_url('/blocks/course_files_license/view.php', array('courseid' => $COURSE->id)) . '">'; $this->content->text .= '<i class="fa fa-exclamation-triangle"></i> '; $this->content->text .= get_string('filelist', 'block_course_files_license') . '</a>'; } else { $this->content->text .= '<p class="justify">' . get_string('all_files_identified', 'block_course_files_license') . '</p>'; $this->content->text .= '<a class="btn btn-block btn-success btn-sm" href="'; $this->content->text .= new moodle_url('/blocks/course_files_license/view.php', array('courseid' => $COURSE->id)) . '">'; $this->content->text .= '<i class="fa fa-info-circle"></i> '; $this->content->text .= get_string('filelist', 'block_course_files_license') . '</a>'; } return $this->content; }