Skip to content

Commit

Permalink
MDL-71051 core_user: move edit profile category form to classes
Browse files Browse the repository at this point in the history
  • Loading branch information
marinaglancy committed Apr 28, 2021
1 parent ef3d6a3 commit 880aff7
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
Expand Up @@ -22,6 +22,10 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

namespace core_user\form;

use moodleform;

if (!defined('MOODLE_INTERNAL')) {
die('Direct access to this script is forbidden.'); // It must be included from a Moodle page.
}
Expand All @@ -34,7 +38,7 @@
* @copyright 2007 onwards Shane Elliot {@link http://pukunui.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class category_form extends moodleform {
class profile_category_form extends moodleform {

/**
* Define the form.
Expand Down Expand Up @@ -92,4 +96,3 @@ public function validation($data, $files) {
}
}


5 changes: 2 additions & 3 deletions user/profile/definelib.php
Expand Up @@ -492,10 +492,9 @@ function profile_list_categories() {
* @param string $redirect
*/
function profile_edit_category($id, $redirect) {
global $DB, $OUTPUT, $CFG;
global $DB, $OUTPUT;

require_once($CFG->dirroot.'/user/profile/index_category_form.php');
$categoryform = new category_form();
$categoryform = new \core_user\form\profile_category_form();

if ($category = $DB->get_record('user_info_category', array('id' => $id))) {
$categoryform->set_data($category);
Expand Down
6 changes: 3 additions & 3 deletions user/profile/field/social/tests/privacy_test.php
Expand Up @@ -290,9 +290,9 @@ private function add_profile_category() {
private function add_profile_field($categoryid, $datatype) {
$data = $this->getDataGenerator()->create_custom_profile_field([
'datatype' => $datatype,
'shortname' => 'tstField',
'name' => 'Test field',
'description' => 'This is a test.',
'shortname' => 'icq',
'name' => 'icq',
'description' => '',
'categoryid' => $categoryid,
]);
return $data->id;
Expand Down
2 changes: 1 addition & 1 deletion user/tests/profilelib_test.php
Expand Up @@ -222,7 +222,7 @@ public function test_profile_fields_in_generator() {

// Add a required, visible, unlocked custom field.
$this->getDataGenerator()->create_custom_profile_field(['shortname' => 'house', 'name' => 'House', 'required' => 1,
'visible' => 1, 'locked' => 0, 'datatype' => 'text', 'default' => null]);
'visible' => 1, 'locked' => 0, 'datatype' => 'text', 'defaultdata' => null]);

// Create some student accounts.
$hermione = $this->getDataGenerator()->create_user(['profile_field_house' => 'Gryffindor']);
Expand Down

0 comments on commit 880aff7

Please sign in to comment.