/** * This function prepares help section for settings page. * * @param array $data Result of mcae_prepare_profile_data function * @param string $prefix String prefix * @param array $result Variable to store result */ function mcae_print_profile_data($data, $prefix = '', &$result) { if (is_array($data)) { foreach ($data as $key => $val) { if (is_array($val)) { $field = $prefix == '' ? "{$key}" : "{$prefix}.{$key}"; mcae_print_profile_data($val, $field, $result); } else { $field = $prefix == '' ? "{$key}" : "{$prefix}.{$key}"; $title = format_string($val); $result[] = "<span title=\"{$title}\">{{ {$field} }}</span>"; } } } else { $title = format_string($data); $result[] = "<span title=\"{$title}\">{{ {$prefix} }}</span>"; } }
if ($ADMIN->fulltree) { $settings->add(new admin_setting_configtextarea('auth_mcae/mainrule_fld', get_string('auth_mainrule_fld', 'auth_mcae'), '', '')); // Profile field helper $fldlist = array(); $usr_helper = $DB->get_record('user', array('id' => 2)); profile_load_data($usr_helper); profile_load_custom_fields($usr_helper); $fldlist = mcae_prepare_profile_data($usr_helper); // Additional values for email list($email_username, $email_domain) = explode("@", $fldlist['email']); // Email root domain $email_domain_array = explode('.', $email_domain); if (count($email_domain_array) > 2) { $email_rootdomain = $email_domain_array[count($email_domain_array) - 2] . '.' . $email_domain_array[count($email_domain_array) - 1]; } else { $email_rootdomain = $email_domain; } $fldlist['email'] = array('full' => $fldlist['email'], 'username' => $email_username, 'domain' => $email_domain, 'rootdomain' => $email_rootdomain); //print_r($fldlist); $help_array = array(); mcae_print_profile_data($fldlist, '', $help_array); //print_r($usr_helper); //print_r($help_array); $help_text = implode(', ', $help_array); $settings->add(new admin_setting_heading('auth_mcae_profile_help', get_string('auth_profile_help', 'auth_mcae'), $help_text)); $settings->add(new admin_setting_configselect('auth_mcae/delim', get_string('auth_delim', 'auth_mcae'), get_string('auth_delim_help', 'auth_mcae'), 'CR+LF', array('CR+LF' => 'CR+LF', 'CR' => 'CR', 'LF' => 'LF'))); $settings->add(new admin_setting_configtext('auth_mcae/secondrule_fld', get_string('auth_secondrule_fld', 'auth_mcae'), '', 'n/a')); $settings->add(new admin_setting_configtextarea('auth_mcae/replace_arr', get_string('auth_replace_arr', 'auth_mcae'), '', '')); $settings->add(new admin_setting_configtextarea('auth_mcae/donttouchusers', get_string('auth_donttouchusers', 'auth_mcae'), '', '')); $settings->add(new admin_setting_configcheckbox('auth_mcae/enableunenrol', get_string('auth_enableunenrol', 'auth_mcae'), '', 0)); }