Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Placed the work behind printing out the categories and fields into a

function.
  • Loading branch information...
commit 7240a6ea653bfa97830f6a9522ebedd15f259fa2 1 parent 8b74cd2
ikawhero authored
Showing with 32 additions and 0 deletions.
  1. +32 −0 user/profile/lib.php
View
32 user/profile/lib.php
@@ -455,6 +455,38 @@ function _is_required() {
/***** 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
*/
Please sign in to comment.
Something went wrong with that request. Please try again.