Created
November 4, 2023 14:56
-
-
Save caiovncius/c06bd05fe4d3efd8588f3b6be54776e6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// This file is part of Moodle - http://moodle.org/ | |
// | |
// Moodle is free software: you can redistribute it and/or modify | |
// it under the terms of the GNU General Public License as published by | |
// the Free Software Foundation, either version 3 of the License, or | |
// (at your option) any later version. | |
// | |
// Moodle is distributed in the hope that it will be useful, | |
// but WITHOUT ANY WARRANTY; without even the implied warranty of | |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
// GNU General Public License for more details. | |
// | |
// You should have received a copy of the GNU General Public License | |
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. | |
class user_custom_fields_helper { | |
/** | |
* @param mixed $name | |
* | |
* @return mixed | |
*/ | |
public static function get_user_custom_fields_category($name) | |
{ | |
global $DB; | |
return $DB->get_record('user_info_category', ['name'=> $name]); | |
} | |
/** | |
* @param mixed $name | |
* | |
* @return bool|int | |
*/ | |
public static function create_user_custom_fields_category($name) { | |
global $DB; | |
return $DB->insert_record('user_info_category', ['name' => $name, 'sortorder' => 1]); | |
} | |
/** | |
* @param mixed $shortname | |
* | |
* @return mixed | |
*/ | |
public static function get_user_custom_field($shortname) { | |
global $DB; | |
return $DB->get_record('user_info_field', ["shortname" => "user_cpf"]); | |
} | |
/** | |
* @param mixed $shortname | |
* @param mixed $name | |
* @param mixed $description | |
* @param mixed $category | |
* | |
* @return bool|int | |
*/ | |
public static function create_user_text_custom_field($shortname, $name, $description, $category) { | |
global $DB; | |
return $DB->insert_record( | |
'user_info_field', | |
[ | |
"shortname" => $shortname, | |
"name" => $name, | |
"datatype" => 'text', | |
"description" => $description, | |
"descriptionformat" => 1, | |
"categoryid" => $category, | |
"sortorder" => 1, | |
"required" => 1, | |
"locked" => 0, | |
"visible" => 2, | |
"forceunique" => 1, | |
"signup" => 1, | |
"defaultdata" => "", | |
"defaultdataformat" => 0, | |
"param1" => "30", | |
"param2" => "11", | |
"param3" => "0", | |
"param4" => "", | |
"param5" => "" | |
] | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment