Merge branch 'MDL-61012_master' of https://github.com/troywilliams/moodle

This commit is contained in:
Jun Pataleta 2018-04-30 17:29:25 +08:00
commit 7816cac9fe

View File

@ -50,7 +50,7 @@ abstract class moodleform_mod extends moodleform {
*/
protected $_customcompletionelements;
/**
* @var string name of module
* @var string name of module.
*/
protected $_modname;
/** current context, course or module depends if already exists*/
@ -86,13 +86,15 @@ abstract class moodleform_mod extends moodleform {
require_once($CFG->dirroot . '/course/format/lib.php');
$this->courseformat = course_get_format($course);
// Guess module name
// Guess module name if not set.
if (is_null($this->_modname)) {
$matches = array();
if (!preg_match('/^mod_([^_]+)_mod_form$/', get_class($this), $matches)) {
debugging('Use $modname parameter or rename form to mod_xx_mod_form, where xx is name of your module');
debugging('Rename form to mod_xx_mod_form, where xx is name of your module');
print_error('unknownmodulename');
}
$this->_modname = $matches[1];
}
$this->init_features();
parent::__construct('modedit.php');
}