MDL-18910 full support for module intro editor with embedded images
This commit is contained in:
+36
-3
@@ -53,6 +53,12 @@
|
||||
$form->add = $add;
|
||||
$form->return = 0; //must be false if this is an add, go back to course view on cancel
|
||||
|
||||
if (plugin_supports('mod', $form->modulename, FEATURE_MOD_INTRO, true)) {
|
||||
$draftid_editor = file_get_submitted_draft_itemid('introeditor');
|
||||
file_prepare_draft_area($draftid_editor, null, null, null);
|
||||
$form->introeditor = array('text'=>'', 'format'=>FORMAT_HTML, 'itemid'=>$draftid_editor); // TODO: add better default
|
||||
}
|
||||
|
||||
// Turn off default grouping for modules that don't provide group mode
|
||||
if ($add=='resource' || $add=='glossary' || $add=='label') {
|
||||
$form->groupingid = 0;
|
||||
@@ -130,6 +136,12 @@
|
||||
$form->showavailability = $cm->showavailability;
|
||||
}
|
||||
|
||||
if (plugin_supports('mod', $form->modulename, FEATURE_MOD_INTRO, true)) {
|
||||
$draftid_editor = file_get_submitted_draft_itemid('introeditor');
|
||||
$currentintro = file_prepare_draft_area($draftid_editor, $context->id, $form->modulename.'_intro', 0, true, $form->intro);
|
||||
$form->introeditor = array('text'=>$currentintro, 'format'=>$form->introformat, 'itemid'=>$draftid_editor);
|
||||
}
|
||||
|
||||
if ($items = grade_item::fetch_all(array('itemtype'=>'mod', 'itemmodule'=>$form->modulename,
|
||||
'iteminstance'=>$form->instance, 'courseid'=>$course->id))) {
|
||||
// add existing outcomes
|
||||
@@ -306,6 +318,17 @@
|
||||
|
||||
$DB->update_record('course_modules', $cm);
|
||||
|
||||
$modcontext = get_context_instance(CONTEXT_MODULE, $fromform->coursemodule);
|
||||
|
||||
// update embedded links and save files
|
||||
if (plugin_supports('mod', $fromform->modulename, FEATURE_MOD_INTRO, true)) {
|
||||
$fromform->intro = file_save_draft_area_files($fromform->introeditor['itemid'], $modcontext->id,
|
||||
$fromform->modulename.'_intro', 0,
|
||||
true, $fromform->introeditor['text']);
|
||||
$fromform->introformat = $fromform->introeditor['format'];
|
||||
unset($fromform->introeditor);
|
||||
}
|
||||
|
||||
if (!$updateinstancefunction($fromform, $mform)) {
|
||||
print_error('cannotupdatemod', '', 'view.php?id=$course->id', $fromform->modulename);
|
||||
}
|
||||
@@ -367,6 +390,17 @@
|
||||
print_error('cannotaddcoursemodule');
|
||||
}
|
||||
|
||||
$modcontext = get_context_instance(CONTEXT_MODULE, $fromform->coursemodule);
|
||||
|
||||
// update embedded links and save files
|
||||
if (plugin_supports('mod', $fromform->modulename, FEATURE_MOD_INTRO, true)) {
|
||||
$fromform->intro = file_save_draft_area_files($fromform->introeditor['itemid'], $modcontext->id,
|
||||
$fromform->modulename.'_intro', 0,
|
||||
true, $fromform->introeditor['text']);
|
||||
$fromform->introformat = $fromform->introeditor['format'];
|
||||
unset($fromform->introeditor);
|
||||
}
|
||||
|
||||
$returnfromfunc = $addinstancefunction($fromform, $mform);
|
||||
|
||||
if (!$returnfromfunc or !is_number($returnfromfunc)) {
|
||||
@@ -409,9 +443,8 @@
|
||||
}
|
||||
|
||||
// Set up conditions
|
||||
if($CFG->enableavailability) {
|
||||
condition_info::update_cm_from_form(
|
||||
(object)array('id'=>$fromform->coursemodule),$fromform,false);
|
||||
if ($CFG->enableavailability) {
|
||||
condition_info::update_cm_from_form((object)array('id'=>$fromform->coursemodule), $fromform, false);
|
||||
}
|
||||
|
||||
add_to_log($course->id, "course", "add mod",
|
||||
|
||||
@@ -70,7 +70,7 @@ class moodleform_mod extends moodleform {
|
||||
$this->_features->outcomes = (!empty($CFG->enableoutcomes) and plugin_supports('mod', $this->_modname, FEATURE_GRADE_OUTCOMES, true));
|
||||
$this->_features->hasgrades = plugin_supports('mod', $this->_modname, FEATURE_GRADE_HAS_GRADE, false);
|
||||
$this->_features->idnumber = plugin_supports('mod', $this->_modname, FEATURE_IDNUMBER, true);
|
||||
$this->_features->introeditor = plugin_supports('mod', $this->_modname, FEATURE_MODEDIT_INTRO_EDITOR, true);
|
||||
$this->_features->introeditor = plugin_supports('mod', $this->_modname, FEATURE_MOD_INTRO, true);
|
||||
$this->_features->defaultcompletion = plugin_supports('mod', $this->_modname, FEATURE_MODEDIT_DEFAULT_COMPLETION, true);
|
||||
|
||||
$this->_features->gradecat = ($this->_features->outcomes or $this->_features->hasgrades);
|
||||
@@ -572,6 +572,22 @@ class moodleform_mod extends moodleform {
|
||||
$mform->setType('return', PARAM_BOOL);
|
||||
}
|
||||
|
||||
function add_intro_editor($required=false, $customlabel=null) {
|
||||
if (!$this->_features->introeditor) {
|
||||
// intro editor not supported in this module
|
||||
return;
|
||||
}
|
||||
|
||||
$mform = $this->_form;
|
||||
$label = is_null($customlabel) ? get_string('moduleintro') : $customlabel;
|
||||
|
||||
$mform->addElement('editor', 'introeditor', $label, array('maxfiles'=>EDITOR_UNLIMITED_FILES));
|
||||
$mform->setType('introeditor', PARAM_RAW); // no XSS prevention here, users must be trusted
|
||||
if ($required) {
|
||||
$mform->addRule('introeditor', get_string('required'), 'required', null, 'client');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Overriding formslib's add_action_buttons() method, to add an extra submit "save changes and return" button.
|
||||
*
|
||||
@@ -589,7 +605,7 @@ class moodleform_mod extends moodleform {
|
||||
$submit2label = get_string('savechangesandreturntocourse');
|
||||
}
|
||||
|
||||
$mform =& $this->_form;
|
||||
$mform = $this->_form;
|
||||
|
||||
// elements in a row need a group
|
||||
$buttonarray = array();
|
||||
|
||||
@@ -1010,6 +1010,7 @@ $string['missingusername'] = 'Missing username';
|
||||
$string['modified'] = 'Modified';
|
||||
$string['moduledeleteconfirm'] = 'You are about to completely delete the module \'$a\'. This will completely delete everything in the database associated with this activity module. Are you SURE you want to continue?';
|
||||
$string['moduledeletefiles'] = 'All data associated with the module \'$a->module\' has been deleted from the database. To complete the deletion (and prevent the module re-installing itself), you should now delete this directory from your server: $a->directory';
|
||||
$string['moduleintro'] = 'Description';
|
||||
$string['modulesetup'] = 'Setting up module tables';
|
||||
$string['modulesuccess'] = '$a tables have been set up correctly';
|
||||
$string['moodledocs'] = 'Moodle Docs';
|
||||
|
||||
+1
-1
@@ -318,7 +318,7 @@ define('FEATURE_GROUPINGS', 'groupings');
|
||||
define('FEATURE_GROUPMEMBERSONLY', 'groupmembersonly');
|
||||
|
||||
/** True if module supports intro editor */
|
||||
define('FEATURE_MODEDIT_INTRO_EDITOR', 'modedit_intro_editor');
|
||||
define('FEATURE_MOD_INTRO', 'mod_intro');
|
||||
/** True if module has default completion */
|
||||
define('FEATURE_MODEDIT_DEFAULT_COMPLETION', 'modedit_default_completion');
|
||||
|
||||
|
||||
@@ -1550,6 +1550,19 @@ function filter_text($text, $courseid=NULL) {
|
||||
|
||||
return filter_manager::instance()->filter_text($text, $context, $courseid);
|
||||
}
|
||||
/**
|
||||
* Formats activity intro text
|
||||
* @param string $module name of module
|
||||
* @param object $activity instance of activity
|
||||
* @param int $cmid course module id
|
||||
* @return text
|
||||
*/
|
||||
function format_module_intro($module, $activity, $cmid) {
|
||||
$options = (object)array('noclean'=>true);
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cmid);
|
||||
$intro = file_rewrite_pluginfile_urls($activity->intro, 'pluginfile.php', $context->id, $module.'_intro', 0);
|
||||
return format_text($intro, $activity->introformat, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Legacy function, used for cleaning of old forum and glossary text only.
|
||||
|
||||
@@ -160,9 +160,7 @@ class assignment_base {
|
||||
*/
|
||||
function view_intro() {
|
||||
print_simple_box_start('center', '', '', 0, 'generalbox', 'intro');
|
||||
$formatoptions = new stdClass;
|
||||
$formatoptions->noclean = true;
|
||||
echo format_text($this->assignment->intro, $this->assignment->introformat, $formatoptions);
|
||||
echo format_module_intro('assignment', $this->assignment, $this->cm->id);
|
||||
print_simple_box_end();
|
||||
}
|
||||
|
||||
@@ -358,7 +356,7 @@ class assignment_base {
|
||||
if ($assignment->timedue) {
|
||||
$event = new object();
|
||||
$event->name = $assignment->name;
|
||||
$event->description = $assignment->intro;
|
||||
$event->description = format_module_intro('assignment', $assignment, $assignment->coursemodule);
|
||||
$event->courseid = $assignment->course;
|
||||
$event->groupid = 0;
|
||||
$event->userid = 0;
|
||||
@@ -447,14 +445,14 @@ class assignment_base {
|
||||
if ($event->id = $DB->get_field('event', 'id', array('modulename'=>'assignment', 'instance'=>$assignment->id))) {
|
||||
|
||||
$event->name = $assignment->name;
|
||||
$event->description = $assignment->intro;
|
||||
$event->description = format_module_intro('assignment', $assignment, $assignment->coursemodule);
|
||||
$event->timestart = $assignment->timedue;
|
||||
|
||||
update_event($event);
|
||||
} else {
|
||||
$event = new object();
|
||||
$event->name = $assignment->name;
|
||||
$event->description = $assignment->intro;
|
||||
$event->description = format_module_intro('assignment', $assignment, $assignment->coursemodule);
|
||||
$event->courseid = $assignment->course;
|
||||
$event->groupid = 0;
|
||||
$event->userid = 0;
|
||||
@@ -2429,9 +2427,10 @@ function assignment_refresh_events($courseid = 0) {
|
||||
$moduleid = $DB->get_field('modules', 'id', array('name'=>'assignment'));
|
||||
|
||||
foreach ($assignments as $assignment) {
|
||||
$cm = get_coursemodule_from_id('assignment', $assignment->id);
|
||||
$event = NULL;
|
||||
$event->name = $assignment->name;
|
||||
$event->description = $assignment->intro;
|
||||
$event->description = format_module_intro('assignment', $assignment, $cm->id);
|
||||
$event->timestart = $assignment->timedue;
|
||||
|
||||
if ($event->id = $DB->get_field('event', 'id', array('modulename'=>'assignment', 'instance'=>$assignment->id))) {
|
||||
@@ -3241,7 +3240,7 @@ function assignment_supports($feature) {
|
||||
case FEATURE_GROUPS: return true;
|
||||
case FEATURE_GROUPINGS: return true;
|
||||
case FEATURE_GROUPMEMBERSONLY: return true;
|
||||
case FEATURE_MODEDIT_INTRO_EDITOR: return true;
|
||||
case FEATURE_MOD_INTRO: return true;
|
||||
case FEATURE_COMPLETION_TRACKS_VIEWS: return true;
|
||||
case FEATURE_GRADE_HAS_GRADE: return true;
|
||||
case FEATURE_GRADE_OUTCOMES: return true;
|
||||
|
||||
@@ -39,10 +39,7 @@ class mod_assignment_mod_form extends moodleform_mod {
|
||||
}
|
||||
$mform->addRule('name', null, 'required', null, 'client');
|
||||
|
||||
$mform->addElement('htmleditor', 'intro', get_string('description', 'assignment'));
|
||||
$mform->setType('intro', PARAM_RAW);
|
||||
$mform->setHelpButton('intro', array('writing', 'questions', 'richtext2'), false, 'editorhelpbutton');
|
||||
$mform->addRule('intro', get_string('required'), 'required', null, 'client');
|
||||
$this->add_intro_editor(true, get_string('description', 'assignment'));
|
||||
|
||||
$mform->addElement('modgrade', 'grade', get_string('grade'));
|
||||
$mform->setDefault('grade', 100);
|
||||
|
||||
+1
-1
@@ -980,7 +980,7 @@ function chat_supports($feature) {
|
||||
case FEATURE_GROUPS: return true;
|
||||
case FEATURE_GROUPINGS: return true;
|
||||
case FEATURE_GROUPMEMBERSONLY: return true;
|
||||
case FEATURE_MODEDIT_INTRO_EDITOR: return true;
|
||||
case FEATURE_MOD_INTRO: return true;
|
||||
case FEATURE_COMPLETION_TRACKS_VIEWS: return false;
|
||||
case FEATURE_GRADE_HAS_GRADE: return false;
|
||||
case FEATURE_GRADE_OUTCOMES: return true;
|
||||
|
||||
+1
-1
@@ -765,7 +765,7 @@ function choice_supports($feature) {
|
||||
case FEATURE_GROUPS: return true;
|
||||
case FEATURE_GROUPINGS: return true;
|
||||
case FEATURE_GROUPMEMBERSONLY: return true;
|
||||
case FEATURE_MODEDIT_INTRO_EDITOR: return true;
|
||||
case FEATURE_MOD_INTRO: return true;
|
||||
case FEATURE_COMPLETION_TRACKS_VIEWS: return true;
|
||||
case FEATURE_GRADE_HAS_GRADE: return false;
|
||||
case FEATURE_GRADE_OUTCOMES: return false;
|
||||
|
||||
+1
-1
@@ -2328,7 +2328,7 @@ function data_supports($feature) {
|
||||
case FEATURE_GROUPS: return true;
|
||||
case FEATURE_GROUPINGS: return true;
|
||||
case FEATURE_GROUPMEMBERSONLY: return true;
|
||||
case FEATURE_MODEDIT_INTRO_EDITOR: return true;
|
||||
case FEATURE_MOD_INTRO: return true;
|
||||
case FEATURE_COMPLETION_TRACKS_VIEWS: return true;
|
||||
case FEATURE_GRADE_HAS_GRADE: return true;
|
||||
case FEATURE_GRADE_OUTCOMES: return true;
|
||||
|
||||
@@ -38,7 +38,7 @@ function feedback_supports($feature) {
|
||||
case FEATURE_GROUPS: return true;
|
||||
case FEATURE_GROUPINGS: return true;
|
||||
case FEATURE_GROUPMEMBERSONLY: return true;
|
||||
case FEATURE_MODEDIT_INTRO_EDITOR: return true;
|
||||
case FEATURE_MOD_INTRO: return true;
|
||||
case FEATURE_COMPLETION_TRACKS_VIEWS: return true;
|
||||
case FEATURE_GRADE_HAS_GRADE: return false;
|
||||
case FEATURE_GRADE_OUTCOMES: return false;
|
||||
|
||||
+1
-17
@@ -240,7 +240,7 @@ function forum_supports($feature) {
|
||||
case FEATURE_GROUPS: return true;
|
||||
case FEATURE_GROUPINGS: return true;
|
||||
case FEATURE_GROUPMEMBERSONLY: return true;
|
||||
case FEATURE_MODEDIT_INTRO_EDITOR: return true;
|
||||
case FEATURE_MOD_INTRO: return true;
|
||||
case FEATURE_COMPLETION_TRACKS_VIEWS: return true;
|
||||
case FEATURE_COMPLETION_HAS_RULES: return true;
|
||||
case FEATURE_GRADE_HAS_GRADE: return true;
|
||||
@@ -4064,22 +4064,6 @@ function forum_pluginfile($course, $cminfo, $context, $filearea, $args) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($filearea === 'forum_intro') {
|
||||
// all users may access it
|
||||
$relativepath = '/'.implode('/', $args);
|
||||
$fullpath = $context->id.'forum_intro0'.$relativepath;
|
||||
|
||||
$fs = get_file_storage();
|
||||
if (!$file = $fs->get_file_by_hash(sha1($fullpath)) or $file->is_directory()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$lifetime = isset($CFG->filelifetime) ? $CFG->filelifetime : 86400;
|
||||
|
||||
// finally send the file
|
||||
send_stored_file($file, $lifetime, 0);
|
||||
}
|
||||
|
||||
$fileareas = array('forum_attachment', 'forum_post');
|
||||
if (!in_array($filearea, $fileareas)) {
|
||||
return false;
|
||||
|
||||
@@ -23,8 +23,7 @@ class mod_forum_post_form extends moodleform {
|
||||
$mform->addRule('subject', get_string('required'), 'required', null, 'client');
|
||||
$mform->addRule('subject', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
|
||||
|
||||
$mform->addElement('editor', 'message', get_string('message', 'forum'),
|
||||
array('maxfiles' => EDITOR_UNLIMITED_FILES, 'filearea' => 'forum_post'));
|
||||
$mform->addElement('editor', 'message', get_string('message', 'forum'), array('maxfiles' => EDITOR_UNLIMITED_FILES));
|
||||
$mform->setType('message', PARAM_RAW);
|
||||
$mform->addRule('message', get_string('required'), 'required', null, 'client');
|
||||
$mform->setHelpButton('message', array('reading', 'writing', 'questions', 'richtext2'), false, 'editorhelpbutton');
|
||||
|
||||
@@ -17,8 +17,7 @@ class mod_glossary_entry_form extends moodleform {
|
||||
$mform->setType('concept', PARAM_TEXT);
|
||||
$mform->addRule('concept', null, 'required', null, 'client');
|
||||
|
||||
$mform->addElement('editor', 'entry', get_string('definition', 'glossary'),
|
||||
array('maxfiles' => EDITOR_UNLIMITED_FILES, 'filearea' => 'glossary_entry'));
|
||||
$mform->addElement('editor', 'entry', get_string('definition', 'glossary'), array('maxfiles' => EDITOR_UNLIMITED_FILES));
|
||||
$mform->setType('entry', PARAM_RAW);
|
||||
$mform->addRule('entry', get_string('required'), 'required', null, 'client');
|
||||
$mform->setHelpButton('entry', array('reading', 'writing', 'questions', 'richtext2'), false, 'editorhelpbutton');
|
||||
|
||||
+2
-17
@@ -1084,22 +1084,7 @@ function glossary_pluginfile($course, $cminfo, $context, $filearea, $args) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($filearea === 'glossary_intro') {
|
||||
// all users may access it
|
||||
$relativepath = '/'.implode('/', $args);
|
||||
$fullpath = $context->id.'glossary_intro0'.$relativepath;
|
||||
|
||||
$fs = get_file_storage();
|
||||
if (!$file = $fs->get_file_by_hash(sha1($fullpath)) or $file->is_directory()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$lifetime = isset($CFG->filelifetime) ? $CFG->filelifetime : 86400;
|
||||
|
||||
// finally send the file
|
||||
send_stored_file($file, $lifetime, 0);
|
||||
|
||||
} else if ($filearea === 'glossary_attachment' or $filearea === 'glossary_entry') {
|
||||
if ($filearea === 'glossary_attachment' or $filearea === 'glossary_entry') {
|
||||
$entryid = (int)array_shift($args);
|
||||
|
||||
if (!$entry = $DB->get_record('glossary_entries', array('id'=>$entryid))) {
|
||||
@@ -2277,7 +2262,7 @@ function glossary_supports($feature) {
|
||||
case FEATURE_GROUPS: return false;
|
||||
case FEATURE_GROUPINGS: return false;
|
||||
case FEATURE_GROUPMEMBERSONLY: return true;
|
||||
case FEATURE_MODEDIT_INTRO_EDITOR: return true;
|
||||
case FEATURE_MOD_INTRO: return true;
|
||||
case FEATURE_COMPLETION_TRACKS_VIEWS: return true;
|
||||
case FEATURE_GRADE_HAS_GRADE: return true;
|
||||
case FEATURE_GRADE_OUTCOMES: return true;
|
||||
|
||||
+1
-1
@@ -145,7 +145,7 @@ function label_supports($feature) {
|
||||
case FEATURE_GROUPS: return false;
|
||||
case FEATURE_GROUPINGS: return false;
|
||||
case FEATURE_GROUPMEMBERSONLY: return true;
|
||||
case FEATURE_MODEDIT_INTRO_EDITOR: return false;
|
||||
case FEATURE_MOD_INTRO: return false;
|
||||
case FEATURE_COMPLETION_TRACKS_VIEWS: return false;
|
||||
case FEATURE_GRADE_HAS_GRADE: return false;
|
||||
case FEATURE_GRADE_OUTCOMES: return false;
|
||||
|
||||
+1
-1
@@ -720,7 +720,7 @@ function lesson_supports($feature) {
|
||||
case FEATURE_GROUPS: return false;
|
||||
case FEATURE_GROUPINGS: return false;
|
||||
case FEATURE_GROUPMEMBERSONLY: return true;
|
||||
case FEATURE_MODEDIT_INTRO_EDITOR: return true;
|
||||
case FEATURE_MOD_INTRO: return true;
|
||||
case FEATURE_COMPLETION_TRACKS_VIEWS: return true;
|
||||
case FEATURE_GRADE_HAS_GRADE: return true;
|
||||
case FEATURE_GRADE_OUTCOMES: return true;
|
||||
|
||||
+1
-1
@@ -1255,7 +1255,7 @@ function quiz_supports($feature) {
|
||||
case FEATURE_GROUPS: return true;
|
||||
case FEATURE_GROUPINGS: return true;
|
||||
case FEATURE_GROUPMEMBERSONLY: return true;
|
||||
case FEATURE_MODEDIT_INTRO_EDITOR: return true;
|
||||
case FEATURE_MOD_INTRO: return true;
|
||||
case FEATURE_COMPLETION_TRACKS_VIEWS: return true;
|
||||
case FEATURE_GRADE_HAS_GRADE: return true;
|
||||
case FEATURE_GRADE_OUTCOMES: return true;
|
||||
|
||||
@@ -764,7 +764,7 @@ function resource_supports($feature) {
|
||||
case FEATURE_GROUPS: return false;
|
||||
case FEATURE_GROUPINGS: return false;
|
||||
case FEATURE_GROUPMEMBERSONLY: return true;
|
||||
case FEATURE_MODEDIT_INTRO_EDITOR: return true;
|
||||
case FEATURE_MOD_INTRO: return true;
|
||||
case FEATURE_COMPLETION_TRACKS_VIEWS: return true;
|
||||
case FEATURE_GRADE_HAS_GRADE: return false;
|
||||
case FEATURE_GRADE_OUTCOMES: return false;
|
||||
|
||||
+1
-1
@@ -820,7 +820,7 @@ function scorm_supports($feature) {
|
||||
case FEATURE_GROUPS: return false;
|
||||
case FEATURE_GROUPINGS: return false;
|
||||
case FEATURE_GROUPMEMBERSONLY: return true;
|
||||
case FEATURE_MODEDIT_INTRO_EDITOR: return true;
|
||||
case FEATURE_MOD_INTRO: return true;
|
||||
case FEATURE_COMPLETION_TRACKS_VIEWS: return true;
|
||||
case FEATURE_GRADE_HAS_GRADE: return true;
|
||||
case FEATURE_GRADE_OUTCOMES: return true;
|
||||
|
||||
+1
-1
@@ -597,7 +597,7 @@ function survey_supports($feature) {
|
||||
case FEATURE_GROUPS: return true;
|
||||
case FEATURE_GROUPINGS: return true;
|
||||
case FEATURE_GROUPMEMBERSONLY: return true;
|
||||
case FEATURE_MODEDIT_INTRO_EDITOR: return true;
|
||||
case FEATURE_MOD_INTRO: return true;
|
||||
case FEATURE_COMPLETION_TRACKS_VIEWS: return true;
|
||||
case FEATURE_GRADE_HAS_GRADE: return true;
|
||||
case FEATURE_GRADE_OUTCOMES: return true;
|
||||
|
||||
+1
-1
@@ -1777,7 +1777,7 @@ function wiki_supports($feature) {
|
||||
case FEATURE_GROUPS: return true;
|
||||
case FEATURE_GROUPINGS: return true;
|
||||
case FEATURE_GROUPMEMBERSONLY: return true;
|
||||
case FEATURE_MODEDIT_INTRO_EDITOR: return true;
|
||||
case FEATURE_MOD_INTRO: return true;
|
||||
case FEATURE_COMPLETION_TRACKS_VIEWS: return true;
|
||||
case FEATURE_GRADE_HAS_GRADE: return false;
|
||||
case FEATURE_GRADE_OUTCOMES: return true;
|
||||
|
||||
+32
-8
@@ -226,16 +226,40 @@
|
||||
$cminfo = $modinfo->cms[$context->instanceid];
|
||||
$modname = $cminfo->modname;
|
||||
$libfile = "$CFG->dirroot/mod/$modname/lib.php";
|
||||
if (file_exists($libfile)) {
|
||||
require_once($libfile);
|
||||
$filefunction = $modname.'_pluginfile';
|
||||
if (function_exists($filefunction)) {
|
||||
if ($filefunction($course, $cminfo, $context, $filearea, $args) !== false) {
|
||||
die;
|
||||
}
|
||||
if (!file_exists($libfile)) {
|
||||
send_file_not_found();
|
||||
}
|
||||
|
||||
require_once($libfile);
|
||||
if ($filearea === $modname.'_intro') {
|
||||
if (!plugin_supports('mod', $modname, FEATURE_MOD_INTRO, true)) {
|
||||
send_file_not_found();
|
||||
}
|
||||
if (!$cminfo->uservisible) {
|
||||
send_file_not_found();
|
||||
}
|
||||
// all users may access it
|
||||
$itemid = (int)array_shift($args);
|
||||
$relativepath = '/'.implode('/', $args);
|
||||
$fullpath = $context->id.$filearea.'0'.$relativepath;
|
||||
|
||||
$fs = get_file_storage();
|
||||
if (!$file = $fs->get_file_by_hash(sha1($fullpath)) or $file->is_directory()) {
|
||||
send_file_not_found();
|
||||
}
|
||||
|
||||
$lifetime = isset($CFG->filelifetime) ? $CFG->filelifetime : 86400;
|
||||
|
||||
// finally send the file
|
||||
send_stored_file($file, $lifetime, 0);
|
||||
}
|
||||
|
||||
$filefunction = $modname.'_pluginfile';
|
||||
if (function_exists($filefunction)) {
|
||||
if ($filefunction($course, $cminfo, $context, $filearea, $args) !== false) {
|
||||
die;
|
||||
}
|
||||
}
|
||||
send_file_not_found();
|
||||
|
||||
} else if ($context->contextlevel == CONTEXT_BLOCK) {
|
||||
//not supported yet
|
||||
|
||||
Reference in New Issue
Block a user