From eb8c1fce6637bfc45f90fec5b7c2cb0450de427e Mon Sep 17 00:00:00 2001 From: Sara Arjona Date: Thu, 18 Mar 2021 12:40:32 +0100 Subject: [PATCH] MDL-67999 core_contentbank: Add namespace to upload form The form to upload/replace files has been moved to classes/form (it's where it should have been added when it was created). Besides, this class has been renamed because now, with the namespace, contentbank and form don't need to be in the name ;-) --- .../form/upload_files.php} | 16 +++------------- contentbank/upload.php | 4 ++-- 2 files changed, 5 insertions(+), 15 deletions(-) rename contentbank/{files_form.php => classes/form/upload_files.php} (86%) diff --git a/contentbank/files_form.php b/contentbank/classes/form/upload_files.php similarity index 86% rename from contentbank/files_form.php rename to contentbank/classes/form/upload_files.php index 6a001f05675..bcb37d4fa9f 100644 --- a/contentbank/files_form.php +++ b/contentbank/classes/form/upload_files.php @@ -14,6 +14,8 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +namespace core_contentbank\form; + /** * Upload files to content bank form * @@ -21,19 +23,7 @@ * @copyright 2020 Amaia Anabitarte * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ - -defined('MOODLE_INTERNAL') || die(); - -require_once("$CFG->libdir/formslib.php"); - -/** - * Class contentbank_files_form - * - * @package core_contentbank - * @copyright 2020 Amaia Anabitarte - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -class contentbank_files_form extends moodleform { +class upload_files extends \moodleform { /** * Add elements to this form. diff --git a/contentbank/upload.php b/contentbank/upload.php index 81a7870d044..d4892a344b2 100644 --- a/contentbank/upload.php +++ b/contentbank/upload.php @@ -23,7 +23,6 @@ */ require('../config.php'); -require_once("$CFG->dirroot/contentbank/files_form.php"); use core\output\notification; @@ -86,7 +85,8 @@ $options = array( ); file_prepare_standard_filemanager($data, 'files', $options, $context, 'contentbank', 'public', 0); -$mform = new contentbank_files_form(null, ['contextid' => $contextid, 'data' => $data, 'options' => $options, 'id' => $id]); +$customdata = ['contextid' => $contextid, 'data' => $data, 'options' => $options, 'id' => $id]; +$mform = new \core_contentbank\form\upload_files(null, $customdata); $error = '';