mirror of
https://github.com/moodle/moodle.git
synced 2025-03-14 12:40:01 +01:00
Placed the work behind printing out the categories and fields into a
function.
This commit is contained in:
parent
8b74cd23f4
commit
7240a6ea65
@ -454,6 +454,38 @@ class profile_field_base {
|
||||
|
||||
/***** General purpose functions for customisable user profiles *****/
|
||||
|
||||
/**
|
||||
* Print out the customisable categories and fields for a users profile
|
||||
* @param object instance of the moodleform class
|
||||
* @param integer id of the user
|
||||
* @return nothing
|
||||
*/
|
||||
function profile_print_custom_fields(&$form, $userid=0) {
|
||||
global $USER, $CFG;
|
||||
|
||||
if ($userid == 0) $userid = $USER->id;
|
||||
|
||||
if ($categories = get_records_select('user_info_category', '', 'sortorder ASC')) {
|
||||
foreach ($categories as $category) {
|
||||
if ($fields = get_records_select('user_info_field', "categoryid=$category->id", 'sortorder ASC')) {
|
||||
|
||||
$form->addElement('header', 'category_'.$category->id, $category->name);
|
||||
|
||||
foreach ($fields as $field) {
|
||||
|
||||
require_once($CFG->dirroot.'/user/profile/field/'.$field->datatype.'/field.class.php');
|
||||
$newfield = 'profile_field_'.$field->datatype;
|
||||
$formfield = new $newfield($field->id,$user->id);
|
||||
$formfield->display_field($form);
|
||||
unset($formfield);
|
||||
|
||||
}
|
||||
} /// End of $fields if
|
||||
} /// End of $categories foreach
|
||||
} /// End of $categories if
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve a list of all the available data types
|
||||
* @return array a list of the datatypes suitable to use in a select statement
|
||||
|
Loading…
x
Reference in New Issue
Block a user