MDL-66269 mod_forum: the export form to use automatic class loading
Part of MDL-66075.
This commit is contained in:
committed by
Simey Lameze
parent
fbdef95112
commit
a0185ef7b3
@@ -21,6 +21,9 @@
|
||||
* @copyright 2019 Simey Lameze <simey@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace mod_forum\form;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
|
||||
|
||||
require_once($CFG->dirroot.'/mod/forum/lib.php');
|
||||
@@ -33,7 +36,7 @@ require_once($CFG->libdir.'/formslib.php');
|
||||
* @copyright 2019 Simey Lameze <simey@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL Juv3 or later
|
||||
*/
|
||||
class export extends moodleform {
|
||||
class export_form extends \moodleform {
|
||||
|
||||
/**
|
||||
* Define the form - called by parent constructor
|
||||
@@ -51,7 +54,7 @@ class export extends moodleform {
|
||||
$mform->setDefault('id', $forum->get_id());
|
||||
|
||||
// Export formats.
|
||||
$formats = core_plugin_manager::instance()->get_plugins_of_type('dataformat');
|
||||
$formats = \core_plugin_manager::instance()->get_plugins_of_type('dataformat');
|
||||
$options = [];
|
||||
foreach ($formats as $format) {
|
||||
$options[$format->name] = $format->displayname;
|
||||
@@ -26,7 +26,6 @@ define('NO_OUTPUT_BUFFERING', true);
|
||||
require_once(__DIR__ . '/../../config.php');
|
||||
require_once($CFG->libdir . '/adminlib.php');
|
||||
require_once($CFG->libdir . '/dataformatlib.php');
|
||||
require_once($CFG->dirroot . '/mod/forum/export_form.php');
|
||||
|
||||
$forumid = optional_param('id', 0, PARAM_INT);
|
||||
$doexport = optional_param('export', false, PARAM_BOOL);
|
||||
@@ -39,7 +38,7 @@ $forumvault = $vaultfactory->get_forum_vault();
|
||||
|
||||
$forum = $forumvault->get_from_id($forumid);
|
||||
if (empty($forum)) {
|
||||
throw new \moodle_exception('Unable to find forum with id ' . $forumid);
|
||||
throw new moodle_exception('Unable to find forum with id ' . $forumid);
|
||||
}
|
||||
|
||||
$capabilitymanager = $managerfactory->get_capability_manager($forum);
|
||||
@@ -49,7 +48,7 @@ if (!$capabilitymanager->can_export_forum($USER)) {
|
||||
|
||||
$course = $forum->get_course_record();
|
||||
$coursemodule = $forum->get_course_module_record();
|
||||
$cm = \cm_info::create($coursemodule);
|
||||
$cm = cm_info::create($coursemodule);
|
||||
|
||||
require_course_login($course, true, $cm);
|
||||
|
||||
@@ -65,7 +64,7 @@ if ($doexport == false) {
|
||||
$PAGE->set_heading($pagetitle);
|
||||
}
|
||||
|
||||
$form = new export($url->out(false), [
|
||||
$form = new mod_forum\form\export_form($url->out(false), [
|
||||
'forum' => $forum
|
||||
]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user