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 = block_course_files_license_get_coursefilelist(); if ($filelist) { $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_idenfitied', '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; }
// You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. /** * Block to show course files and usage * * @package block_course_files_license * @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 = block_course_files_license_get_coursefilelist(); $identifiedcoursefilelist = block_course_files_license_get_identifiedcoursefilelist(); $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('id', array_keys($_POST))) { $DB->delete_records('block_course_files_license', array('id' => $_POST['id'])); } } $view_url = new moodle_url('/blocks/course_files_license/view.php', array('courseid' => $courseid)); redirect($view_url);