Blame Identity/Webenv/phpBB/3.0.4/includes/functions_profile_fields.php

ef5584
ef5584
/**
ef5584
*
ef5584
* @package phpBB3
ef5584
* @version $Id: functions_profile_fields.php 9127 2008-11-26 19:58:35Z acydburn $
ef5584
* @copyright (c) 2005 phpBB Group
ef5584
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
ef5584
*
ef5584
*/
ef5584
ef5584
/**
ef5584
* @ignore
ef5584
*/
ef5584
if (!defined('IN_PHPBB'))
ef5584
{
ef5584
	exit;
ef5584
}
ef5584
ef5584
/**
ef5584
* Custom Profile Fields
ef5584
* @package phpBB3
ef5584
*/
ef5584
class custom_profile
ef5584
{
ef5584
	var $profile_types = array(FIELD_INT => 'int', FIELD_STRING => 'string', FIELD_TEXT => 'text', FIELD_BOOL => 'bool', FIELD_DROPDOWN => 'dropdown', FIELD_DATE => 'date');
ef5584
	var $profile_cache = array();
ef5584
	var $options_lang = array();
ef5584
ef5584
	/**
ef5584
	* Assign editable fields to template, mode can be profile (for profile change) or register (for registration)
ef5584
	* Called by ucp_profile and ucp_register
ef5584
	* @access public
ef5584
	*/
ef5584
	function generate_profile_fields($mode, $lang_id)
ef5584
	{
ef5584
		global $db, $template, $auth;
ef5584
ef5584
		$sql_where = '';
ef5584
		switch ($mode)
ef5584
		{
ef5584
			case 'register':
ef5584
				// If the field is required we show it on the registration page and do not show hidden fields
ef5584
				$sql_where .= ' AND f.field_show_on_reg = 1 AND f.field_no_view = 0';
ef5584
			break;
ef5584
ef5584
			case 'profile':
ef5584
				// Show hidden fields to moderators/admins
ef5584
				if (!$auth->acl_gets('a_', 'm_') && !$auth->acl_getf_global('m_'))
ef5584
				{
ef5584
					$sql_where .= ' AND f.field_show_profile = 1';
ef5584
				}
ef5584
			break;
ef5584
ef5584
			default:
ef5584
				trigger_error('Wrong profile mode specified', E_USER_ERROR);
ef5584
			break;
ef5584
		}
ef5584
ef5584
		$sql = 'SELECT l.*, f.*
ef5584
			FROM ' . PROFILE_LANG_TABLE . ' l, ' . PROFILE_FIELDS_TABLE . " f
ef5584
			WHERE f.field_active = 1
ef5584
				$sql_where
ef5584
				AND l.lang_id = $lang_id
ef5584
				AND l.field_id = f.field_id
ef5584
			ORDER BY f.field_order";
ef5584
		$result = $db->sql_query($sql);
ef5584
ef5584
		while ($row = $db->sql_fetchrow($result))
ef5584
		{
ef5584
			// Return templated field
ef5584
			$tpl_snippet = $this->process_field_row('change', $row);
ef5584
ef5584
			// Some types are multivalue, we can't give them a field_id as we would not know which to pick
ef5584
			$type = (int) $row['field_type'];
ef5584
ef5584
			$template->assign_block_vars('profile_fields', array(
ef5584
				'LANG_NAME'		=> $row['lang_name'],
ef5584
				'LANG_EXPLAIN'	=> $row['lang_explain'],
ef5584
				'FIELD'			=> $tpl_snippet,
ef5584
				'FIELD_ID'		=> ($type == FIELD_DATE || ($type == FIELD_BOOL && $row['field_length'] == '1')) ? '' : 'pf_' . $row['field_ident'],
ef5584
				'S_REQUIRED'	=> ($row['field_required']) ? true : false)
ef5584
			);
ef5584
		}
ef5584
		$db->sql_freeresult($result);
ef5584
	}
ef5584
ef5584
	/**
ef5584
	* Validate entered profile field data
ef5584
	* @access public
ef5584
	*/
ef5584
	function validate_profile_field($field_type, &$field_value, $field_data)
ef5584
	{
ef5584
		switch ($field_type)
ef5584
		{
ef5584
			case FIELD_INT:
ef5584
			case FIELD_DROPDOWN:
ef5584
				$field_value = (int) $field_value;
ef5584
			break;
ef5584
ef5584
			case FIELD_BOOL:
ef5584
				$field_value = (bool) $field_value;
ef5584
			break;
ef5584
		}
ef5584
ef5584
		switch ($field_type)
ef5584
		{
ef5584
			case FIELD_DATE:
ef5584
				$field_validate = explode('-', $field_value);
ef5584
ef5584
				$day = (isset($field_validate[0])) ? (int) $field_validate[0] : 0;
ef5584
				$month = (isset($field_validate[1])) ? (int) $field_validate[1] : 0;
ef5584
				$year = (isset($field_validate[2])) ? (int) $field_validate[2] : 0;
ef5584
ef5584
				if ((!$day || !$month || !$year) && !$field_data['field_required'])
ef5584
				{
ef5584
					return false;
ef5584
				}
ef5584
ef5584
				if ((!$day || !$month || !$year) && $field_data['field_required'])
ef5584
				{
ef5584
					return 'FIELD_REQUIRED';
ef5584
				}
ef5584
ef5584
				if ($day < 0 || $day > 31 || $month < 0 || $month > 12 || ($year < 1901 && $year > 0) || $year > gmdate('Y', time()) + 50)
ef5584
				{
ef5584
					return 'FIELD_INVALID_DATE';
ef5584
				}
ef5584
ef5584
				if (checkdate($month, $day, $year) === false)
ef5584
				{
ef5584
					return 'FIELD_INVALID_DATE';
ef5584
				}
ef5584
			break;
ef5584
ef5584
			case FIELD_BOOL:
ef5584
				if (!$field_value && $field_data['field_required'])
ef5584
				{
ef5584
					return 'FIELD_REQUIRED';
ef5584
				}
ef5584
			break;
ef5584
ef5584
			case FIELD_INT:
ef5584
				if (empty($field_value) && !$field_data['field_required'])
ef5584
				{
ef5584
					return false;
ef5584
				}
ef5584
ef5584
				if ($field_value < $field_data['field_minlen'])
ef5584
				{
ef5584
					return 'FIELD_TOO_SMALL';
ef5584
				}
ef5584
				else if ($field_value > $field_data['field_maxlen'])
ef5584
				{
ef5584
					return 'FIELD_TOO_LARGE';
ef5584
				}
ef5584
			break;
ef5584
ef5584
			case FIELD_DROPDOWN:
ef5584
				if ($field_value == $field_data['field_novalue'] && $field_data['field_required'])
ef5584
				{
ef5584
					return 'FIELD_REQUIRED';
ef5584
				}
ef5584
			break;
ef5584
ef5584
			case FIELD_STRING:
ef5584
			case FIELD_TEXT:
ef5584
				if (empty($field_value) && !$field_data['field_required'])
ef5584
				{
ef5584
					return false;
ef5584
				}
ef5584
				else if (empty($field_value) && $field_data['field_required'])
ef5584
				{
ef5584
					return 'FIELD_REQUIRED';
ef5584
				}
ef5584
ef5584
				if ($field_data['field_minlen'] && utf8_strlen($field_value) < $field_data['field_minlen'])
ef5584
				{
ef5584
					return 'FIELD_TOO_SHORT';
ef5584
				}
ef5584
				else if ($field_data['field_maxlen'] && utf8_strlen($field_value) > $field_data['field_maxlen'])
ef5584
				{
ef5584
					return 'FIELD_TOO_LONG';
ef5584
				}
ef5584
ef5584
				if (!empty($field_data['field_validation']) && $field_data['field_validation'] != '.*')
ef5584
				{
ef5584
					$field_validate = ($field_type == FIELD_STRING) ? $field_value : bbcode_nl2br($field_value);
ef5584
					if (!preg_match('#^' . str_replace('\\\\', '\\', $field_data['field_validation']) . '$#i', $field_validate))
ef5584
					{
ef5584
						return 'FIELD_INVALID_CHARS';
ef5584
					}
ef5584
				}
ef5584
			break;
ef5584
		}
ef5584
ef5584
		return false;
ef5584
	}
ef5584
ef5584
	/**
ef5584
	* Build profile cache, used for display
ef5584
	* @access private
ef5584
	*/
ef5584
	function build_cache()
ef5584
	{
ef5584
		global $db, $user, $auth;
ef5584
ef5584
		$this->profile_cache = array();
ef5584
ef5584
		// Display hidden/no_view fields for admin/moderator
ef5584
		$sql = 'SELECT l.*, f.*
ef5584
			FROM ' . PROFILE_LANG_TABLE . ' l, ' . PROFILE_FIELDS_TABLE . ' f
ef5584
			WHERE l.lang_id = ' . $user->get_iso_lang_id() . '
ef5584
				AND f.field_active = 1 ' .
ef5584
				((!$auth->acl_gets('a_', 'm_') && !$auth->acl_getf_global('m_')) ? '	AND f.field_hide = 0 ' : '') . '
ef5584
				AND f.field_no_view = 0
ef5584
				AND l.field_id = f.field_id
ef5584
			ORDER BY f.field_order';
ef5584
		$result = $db->sql_query($sql);
ef5584
ef5584
		while ($row = $db->sql_fetchrow($result))
ef5584
		{
ef5584
			$this->profile_cache[$row['field_ident']] = $row;
ef5584
		}
ef5584
		$db->sql_freeresult($result);
ef5584
	}
ef5584
ef5584
	/**
ef5584
	* Get language entries for options and store them here for later use
ef5584
	*/
ef5584
	function get_option_lang($field_id, $lang_id, $field_type, $preview)
ef5584
	{
ef5584
		global $db;
ef5584
ef5584
		if ($preview)
ef5584
		{
ef5584
			$lang_options = (!is_array($this->vars['lang_options'])) ? explode("\n", $this->vars['lang_options']) : $this->vars['lang_options'];
ef5584
ef5584
			foreach ($lang_options as $num => $var)
ef5584
			{
ef5584
				$this->options_lang[$field_id][$lang_id][($num + 1)] = $var;
ef5584
			}
ef5584
		}
ef5584
		else
ef5584
		{
ef5584
			$sql = 'SELECT option_id, lang_value
ef5584
				FROM ' . PROFILE_FIELDS_LANG_TABLE . "
ef5584
					WHERE field_id = $field_id
ef5584
					AND lang_id = $lang_id
ef5584
					AND field_type = $field_type
ef5584
				ORDER BY option_id";
ef5584
			$result = $db->sql_query($sql);
ef5584
ef5584
			while ($row = $db->sql_fetchrow($result))
ef5584
			{
ef5584
				$this->options_lang[$field_id][$lang_id][($row['option_id'] + 1)] = $row['lang_value'];
ef5584
			}
ef5584
			$db->sql_freeresult($result);
ef5584
		}
ef5584
	}
ef5584
ef5584
	/**
ef5584
	* Submit profile field
ef5584
	* @access public
ef5584
	*/
ef5584
	function submit_cp_field($mode, $lang_id, &$cp_data, &$cp_error)
ef5584
	{
ef5584
		global $auth, $db, $user;
ef5584
ef5584
		$sql_where = '';
ef5584
		switch ($mode)
ef5584
		{
ef5584
			case 'register':
ef5584
				// If the field is required we show it on the registration page and do not show hidden fields
ef5584
				$sql_where .= ' AND f.field_show_on_reg = 1 AND f.field_no_view = 0';
ef5584
			break;
ef5584
ef5584
			case 'profile':
ef5584
				// Show hidden fields to moderators/admins
ef5584
				if (!$auth->acl_gets('a_', 'm_') && !$auth->acl_getf_global('m_'))
ef5584
				{
ef5584
					$sql_where .= ' AND f.field_show_profile = 1';
ef5584
				}
ef5584
			break;
ef5584
ef5584
			default:
ef5584
				trigger_error('Wrong profile mode specified', E_USER_ERROR);
ef5584
			break;
ef5584
		}
ef5584
ef5584
		$sql = 'SELECT l.*, f.*
ef5584
			FROM ' . PROFILE_LANG_TABLE . ' l, ' . PROFILE_FIELDS_TABLE . " f
ef5584
			WHERE l.lang_id = $lang_id
ef5584
				AND f.field_active = 1
ef5584
				$sql_where
ef5584
				AND l.field_id = f.field_id
ef5584
			ORDER BY f.field_order";
ef5584
		$result = $db->sql_query($sql);
ef5584
ef5584
		while ($row = $db->sql_fetchrow($result))
ef5584
		{
ef5584
			$cp_data['pf_' . $row['field_ident']] = $this->get_profile_field($row);
ef5584
			$check_value = $cp_data['pf_' . $row['field_ident']];
ef5584
ef5584
			if (($cp_result = $this->validate_profile_field($row['field_type'], $check_value, $row)) !== false)
ef5584
			{
ef5584
				// If not and only showing common error messages, use this one
ef5584
				$error = '';
ef5584
				switch ($cp_result)
ef5584
				{
ef5584
					case 'FIELD_INVALID_DATE':
ef5584
					case 'FIELD_REQUIRED':
ef5584
						$error = sprintf($user->lang[$cp_result], $row['lang_name']);
ef5584
					break;
ef5584
ef5584
					case 'FIELD_TOO_SHORT':
ef5584
					case 'FIELD_TOO_SMALL':
ef5584
						$error = sprintf($user->lang[$cp_result], $row['lang_name'], $row['field_minlen']);
ef5584
					break;
ef5584
ef5584
					case 'FIELD_TOO_LONG':
ef5584
					case 'FIELD_TOO_LARGE':
ef5584
						$error = sprintf($user->lang[$cp_result], $row['lang_name'], $row['field_maxlen']);
ef5584
					break;
ef5584
ef5584
					case 'FIELD_INVALID_CHARS':
ef5584
						switch ($row['field_validation'])
ef5584
						{
ef5584
							case '[0-9]+':
ef5584
								$error = sprintf($user->lang[$cp_result . '_NUMBERS_ONLY'], $row['lang_name']);
ef5584
							break;
ef5584
ef5584
							case '[\w]+':
ef5584
								$error = sprintf($user->lang[$cp_result . '_ALPHA_ONLY'], $row['lang_name']);
ef5584
							break;
ef5584
ef5584
							case '[\w_\+\. \-\[\]]+':
ef5584
								$error = sprintf($user->lang[$cp_result . '_SPACERS_ONLY'], $row['lang_name']);
ef5584
							break;
ef5584
						}
ef5584
					break;
ef5584
				}
ef5584
ef5584
				if ($error != '')
ef5584
				{
ef5584
					$cp_error[] = $error;
ef5584
				}
ef5584
			}
ef5584
		}
ef5584
		$db->sql_freeresult($result);
ef5584
	}
ef5584
ef5584
	/**
ef5584
	* Assign fields to template, used for viewprofile, viewtopic and memberlist (if load setting is enabled)
ef5584
	* This is directly connected to the user -> mode == grab is to grab the user specific fields, mode == show is for assigning the row to the template
ef5584
	* @access public
ef5584
	*/
ef5584
	function generate_profile_fields_template($mode, $user_id = 0, $profile_row = false)
ef5584
	{
ef5584
		global $db;
ef5584
ef5584
		if ($mode == 'grab')
ef5584
		{
ef5584
			if (!is_array($user_id))
ef5584
			{
ef5584
				$user_id = array($user_id);
ef5584
			}
ef5584
ef5584
			if (!sizeof($this->profile_cache))
ef5584
			{
ef5584
				$this->build_cache();
ef5584
			}
ef5584
ef5584
			if (!sizeof($user_id))
ef5584
			{
ef5584
				return array();
ef5584
			}
ef5584
ef5584
			$sql = 'SELECT *
ef5584
				FROM ' . PROFILE_FIELDS_DATA_TABLE . '
ef5584
				WHERE ' . $db->sql_in_set('user_id', array_map('intval', $user_id));
ef5584
			$result = $db->sql_query($sql);
ef5584
ef5584
			$field_data = array();
ef5584
			while ($row = $db->sql_fetchrow($result))
ef5584
			{
ef5584
				$field_data[$row['user_id']] = $row;
ef5584
			}
ef5584
			$db->sql_freeresult($result);
ef5584
ef5584
			$user_fields = array();
ef5584
ef5584
			// Go through the fields in correct order
ef5584
			foreach (array_keys($this->profile_cache) as $used_ident)
ef5584
			{
ef5584
				foreach ($field_data as $user_id => $row)
ef5584
				{
ef5584
					$user_fields[$user_id][$used_ident]['value'] = $row['pf_' . $used_ident];
ef5584
					$user_fields[$user_id][$used_ident]['data'] = $this->profile_cache[$used_ident];
ef5584
				}
ef5584
			}
ef5584
ef5584
			return $user_fields;
ef5584
		}
ef5584
		else if ($mode == 'show')
ef5584
		{
ef5584
			// $profile_row == $user_fields[$row['user_id']];
ef5584
			$tpl_fields = array();
ef5584
			$tpl_fields['row'] = $tpl_fields['blockrow'] = array();
ef5584
ef5584
			foreach ($profile_row as $ident => $ident_ary)
ef5584
			{
ef5584
				$value = $this->get_profile_value($ident_ary);
ef5584
ef5584
				if ($value === NULL)
ef5584
				{
ef5584
					continue;
ef5584
				}
ef5584
ef5584
				$tpl_fields['row'] += array(
ef5584
					'PROFILE_' . strtoupper($ident) . '_VALUE'	=> $value,
ef5584
					'PROFILE_' . strtoupper($ident) . '_TYPE'	=> $ident_ary['data']['field_type'],
ef5584
					'PROFILE_' . strtoupper($ident) . '_NAME'	=> $ident_ary['data']['lang_name'],
ef5584
					'PROFILE_' . strtoupper($ident) . '_EXPLAIN'=> $ident_ary['data']['lang_explain'],
ef5584
ef5584
					'S_PROFILE_' . strtoupper($ident)			=> true
ef5584
				);
ef5584
ef5584
				$tpl_fields['blockrow'][] = array(
ef5584
					'PROFILE_FIELD_VALUE'	=> $value,
ef5584
					'PROFILE_FIELD_TYPE'	=> $ident_ary['data']['field_type'],
ef5584
					'PROFILE_FIELD_NAME'	=> $ident_ary['data']['lang_name'],
ef5584
					'PROFILE_FIELD_EXPLAIN'	=> $ident_ary['data']['lang_explain'],
ef5584
ef5584
					'S_PROFILE_' . strtoupper($ident)		=> true
ef5584
				);
ef5584
			}
ef5584
ef5584
			return $tpl_fields;
ef5584
		}
ef5584
		else
ef5584
		{
ef5584
			trigger_error('Wrong mode for custom profile', E_USER_ERROR);
ef5584
		}
ef5584
	}
ef5584
ef5584
	/**
ef5584
	* Get Profile Value for display
ef5584
	*/
ef5584
	function get_profile_value($ident_ary)
ef5584
	{
ef5584
		$value = $ident_ary['value'];
ef5584
		$field_type = $ident_ary['data']['field_type'];
ef5584
ef5584
		switch ($this->profile_types[$field_type])
ef5584
		{
ef5584
			case 'int':
ef5584
				if ($value == '')
ef5584
				{
ef5584
					return NULL;
ef5584
				}
ef5584
				return (int) $value;
ef5584
			break;
ef5584
ef5584
			case 'string':
ef5584
			case 'text':
ef5584
				if (!$value)
ef5584
				{
ef5584
					return NULL;
ef5584
				}
ef5584
ef5584
				$value = make_clickable($value);
ef5584
				$value = censor_text($value);
ef5584
				$value = bbcode_nl2br($value);
ef5584
				return $value;
ef5584
			break;
ef5584
ef5584
			// case 'datetime':
ef5584
			case 'date':
ef5584
				$date = explode('-', $value);
ef5584
				$day = (isset($date[0])) ? (int) $date[0] : 0;
ef5584
				$month = (isset($date[1])) ? (int) $date[1] : 0;
ef5584
				$year = (isset($date[2])) ? (int) $date[2] : 0;
ef5584
ef5584
				if (!$day && !$month && !$year)
ef5584
				{
ef5584
					return NULL;
ef5584
				}
ef5584
				else if ($day && $month && $year)
ef5584
				{
ef5584
					global $user;
ef5584
					// d/m/y 00:00 GMT isn't necessarily on the same d/m/y in the user's timezone, so add the timezone seconds
ef5584
					return $user->format_date(gmmktime(0, 0, 0, $month, $day, $year) + $user->timezone + $user->dst, $user->lang['DATE_FORMAT'], true);
ef5584
				}
ef5584
ef5584
				return $value;
ef5584
			break;
ef5584
ef5584
			case 'dropdown':
ef5584
				$field_id = $ident_ary['data']['field_id'];
ef5584
				$lang_id = $ident_ary['data']['lang_id'];
ef5584
				if (!isset($this->options_lang[$field_id][$lang_id]))
ef5584
				{
ef5584
					$this->get_option_lang($field_id, $lang_id, FIELD_DROPDOWN, false);
ef5584
				}
ef5584
ef5584
				if ($value == $ident_ary['data']['field_novalue'])
ef5584
				{
ef5584
					return NULL;
ef5584
				}
ef5584
ef5584
				$value = (int) $value;
ef5584
ef5584
				// User not having a value assigned
ef5584
				if (!isset($this->options_lang[$field_id][$lang_id][$value]))
ef5584
				{
ef5584
					return NULL;
ef5584
				}
ef5584
ef5584
				return $this->options_lang[$field_id][$lang_id][$value];
ef5584
			break;
ef5584
ef5584
			case 'bool':
ef5584
				$field_id = $ident_ary['data']['field_id'];
ef5584
				$lang_id = $ident_ary['data']['lang_id'];
ef5584
				if (!isset($this->options_lang[$field_id][$lang_id]))
ef5584
				{
ef5584
					$this->get_option_lang($field_id, $lang_id, FIELD_BOOL, false);
ef5584
				}
ef5584
ef5584
				if ($ident_ary['data']['field_length'] == 1)
ef5584
				{
ef5584
					return (isset($this->options_lang[$field_id][$lang_id][(int) $value])) ? $this->options_lang[$field_id][$lang_id][(int) $value] : NULL;
ef5584
				}
ef5584
				else if (!$value)
ef5584
				{
ef5584
					return NULL;
ef5584
				}
ef5584
				else
ef5584
				{
ef5584
					return $this->options_lang[$field_id][$lang_id][(int) ($value) + 1];
ef5584
				}
ef5584
			break;
ef5584
ef5584
			default:
ef5584
				trigger_error('Unknown profile type', E_USER_ERROR);
ef5584
			break;
ef5584
		}
ef5584
	}
ef5584
ef5584
	/**
ef5584
	* Get field value for registration/profile
ef5584
	* @access private
ef5584
	*/
ef5584
	function get_var($field_validation, &$profile_row, $default_value, $preview)
ef5584
	{
ef5584
		global $user;
ef5584
ef5584
		$profile_row['field_ident'] = (isset($profile_row['var_name'])) ? $profile_row['var_name'] : 'pf_' . $profile_row['field_ident'];
ef5584
		$user_ident = $profile_row['field_ident'];
ef5584
		// checkbox - only testing for isset
ef5584
		if ($profile_row['field_type'] == FIELD_BOOL && $profile_row['field_length'] == 2)
ef5584
		{
ef5584
			$value = (isset($_REQUEST[$profile_row['field_ident']])) ? true : ((!isset($user->profile_fields[$user_ident]) || $preview) ? $default_value : $user->profile_fields[$user_ident]);
ef5584
		}
ef5584
		else if ($profile_row['field_type'] == FIELD_INT)
ef5584
		{
ef5584
			if (isset($_REQUEST[$profile_row['field_ident']]))
ef5584
			{
ef5584
				$value = ($_REQUEST[$profile_row['field_ident']] === '') ? NULL : request_var($profile_row['field_ident'], $default_value);
ef5584
			}
ef5584
			else
ef5584
			{
ef5584
				if (!$preview && isset($user->profile_fields[$user_ident]) && is_null($user->profile_fields[$user_ident]))
ef5584
				{
ef5584
					$value = NULL;
ef5584
				}
ef5584
				else if (!isset($user->profile_fields[$user_ident]) || $preview)
ef5584
				{
ef5584
					$value = $default_value;
ef5584
				}
ef5584
				else
ef5584
				{
ef5584
					$value = $user->profile_fields[$user_ident];
ef5584
				}
ef5584
			}
ef5584
ef5584
			return (is_null($value)) ? '' : (int) $value;
ef5584
		}
ef5584
		else
ef5584
		{
ef5584
			$value = (isset($_REQUEST[$profile_row['field_ident']])) ? request_var($profile_row['field_ident'], $default_value, true) : ((!isset($user->profile_fields[$user_ident]) || $preview) ? $default_value : $user->profile_fields[$user_ident]);
ef5584
ef5584
			if (gettype($value) == 'string')
ef5584
			{
ef5584
				$value = utf8_normalize_nfc($value);
ef5584
			}
ef5584
		}
ef5584
ef5584
		switch ($field_validation)
ef5584
		{
ef5584
			case 'int':
ef5584
				return (int) $value;
ef5584
			break;
ef5584
		}
ef5584
ef5584
		return $value;
ef5584
	}
ef5584
ef5584
	/**
ef5584
	* Process int-type
ef5584
	* @access private
ef5584
	*/
ef5584
	function generate_int($profile_row, $preview = false)
ef5584
	{
ef5584
		global $template;
ef5584
ef5584
		$profile_row['field_value'] = $this->get_var('int', $profile_row, $profile_row['field_default_value'], $preview);
ef5584
		$template->assign_block_vars($this->profile_types[$profile_row['field_type']], array_change_key_case($profile_row, CASE_UPPER));
ef5584
	}
ef5584
ef5584
	/**
ef5584
	* Process date-type
ef5584
	* @access private
ef5584
	*/
ef5584
	function generate_date($profile_row, $preview = false)
ef5584
	{
ef5584
		global $user, $template;
ef5584
ef5584
		$profile_row['field_ident'] = (isset($profile_row['var_name'])) ? $profile_row['var_name'] : 'pf_' . $profile_row['field_ident'];
ef5584
		$user_ident = $profile_row['field_ident'];
ef5584
ef5584
		$now = getdate();
ef5584
ef5584
		if (!isset($_REQUEST[$profile_row['field_ident'] . '_day']))
ef5584
		{
ef5584
			if ($profile_row['field_default_value'] == 'now')
ef5584
			{
ef5584
				$profile_row['field_default_value'] = sprintf('%2d-%2d-%4d', $now['mday'], $now['mon'], $now['year']);
ef5584
			}
ef5584
			list($day, $month, $year) = explode('-', ((!isset($user->profile_fields[$user_ident]) || $preview) ? $profile_row['field_default_value'] : $user->profile_fields[$user_ident]));
ef5584
		}
ef5584
		else
ef5584
		{
ef5584
			if ($preview && $profile_row['field_default_value'] == 'now')
ef5584
			{
ef5584
				$profile_row['field_default_value'] = sprintf('%2d-%2d-%4d', $now['mday'], $now['mon'], $now['year']);
ef5584
				list($day, $month, $year) = explode('-', ((!isset($user->profile_fields[$user_ident]) || $preview) ? $profile_row['field_default_value'] : $user->profile_fields[$user_ident]));
ef5584
			}
ef5584
			else
ef5584
			{
ef5584
				$day = request_var($profile_row['field_ident'] . '_day', 0);
ef5584
				$month = request_var($profile_row['field_ident'] . '_month', 0);
ef5584
				$year = request_var($profile_row['field_ident'] . '_year', 0);
ef5584
			}
ef5584
		}
ef5584
ef5584
		$profile_row['s_day_options'] = '<option value="0"' . ((!$day) ? ' selected="selected"' : '') . '>--</option>';
ef5584
		for ($i = 1; $i < 32; $i++)
ef5584
		{
ef5584
			$profile_row['s_day_options'] .= '<option value="' . $i . '"' . (($i == $day) ? ' selected="selected"' : '') . ">$i</option>";
ef5584
		}
ef5584
ef5584
		$profile_row['s_month_options'] = '<option value="0"' . ((!$month) ? ' selected="selected"' : '') . '>--</option>';
ef5584
		for ($i = 1; $i < 13; $i++)
ef5584
		{
ef5584
			$profile_row['s_month_options'] .= '<option value="' . $i . '"' . (($i == $month) ? ' selected="selected"' : '') . ">$i</option>";
ef5584
		}
ef5584
ef5584
		$profile_row['s_year_options'] = '<option value="0"' . ((!$year) ? ' selected="selected"' : '') . '>--</option>';
ef5584
		for ($i = $now['year'] - 100; $i <= $now['year'] + 100; $i++)
ef5584
		{
ef5584
			$profile_row['s_year_options'] .= '<option value="' . $i . '"' . (($i == $year) ? ' selected="selected"' : '') . ">$i</option>";
ef5584
		}
ef5584
		unset($now);
ef5584
ef5584
		$profile_row['field_value'] = 0;
ef5584
		$template->assign_block_vars($this->profile_types[$profile_row['field_type']], array_change_key_case($profile_row, CASE_UPPER));
ef5584
	}
ef5584
ef5584
	/**
ef5584
	* Process bool-type
ef5584
	* @access private
ef5584
	*/
ef5584
	function generate_bool($profile_row, $preview = false)
ef5584
	{
ef5584
		global $template;
ef5584
ef5584
		$value = $this->get_var('int', $profile_row, $profile_row['field_default_value'], $preview);
ef5584
ef5584
		$profile_row['field_value'] = $value;
ef5584
		$template->assign_block_vars($this->profile_types[$profile_row['field_type']], array_change_key_case($profile_row, CASE_UPPER));
ef5584
ef5584
		if ($profile_row['field_length'] == 1)
ef5584
		{
ef5584
			if (!isset($this->options_lang[$profile_row['field_id']][$profile_row['lang_id']]) || !sizeof($this->options_lang[$profile_row['field_id']][$profile_row['lang_id']]))
ef5584
			{
ef5584
				$this->get_option_lang($profile_row['field_id'], $profile_row['lang_id'], FIELD_BOOL, $preview);
ef5584
			}
ef5584
ef5584
			foreach ($this->options_lang[$profile_row['field_id']][$profile_row['lang_id']] as $option_id => $option_value)
ef5584
			{
ef5584
				$template->assign_block_vars('bool.options', array(
ef5584
					'OPTION_ID'	=> $option_id,
ef5584
					'CHECKED'	=> ($value == $option_id) ? ' checked="checked"' : '',
ef5584
					'VALUE'		=> $option_value)
ef5584
				);
ef5584
			}
ef5584
		}
ef5584
	}
ef5584
ef5584
	/**
ef5584
	* Process string-type
ef5584
	* @access private
ef5584
	*/
ef5584
	function generate_string($profile_row, $preview = false)
ef5584
	{
ef5584
		global $template;
ef5584
ef5584
		$profile_row['field_value'] = $this->get_var('string', $profile_row, $profile_row['lang_default_value'], $preview);
ef5584
		$template->assign_block_vars($this->profile_types[$profile_row['field_type']], array_change_key_case($profile_row, CASE_UPPER));
ef5584
	}
ef5584
ef5584
	/**
ef5584
	* Process text-type
ef5584
	* @access private
ef5584
	*/
ef5584
	function generate_text($profile_row, $preview = false)
ef5584
	{
ef5584
		global $template;
ef5584
		global $user, $phpEx, $phpbb_root_path;
ef5584
ef5584
		$field_length = explode('|', $profile_row['field_length']);
ef5584
		$profile_row['field_rows'] = $field_length[0];
ef5584
		$profile_row['field_cols'] = $field_length[1];
ef5584
ef5584
		$profile_row['field_value'] = $this->get_var('string', $profile_row, $profile_row['lang_default_value'], $preview);
ef5584
		$template->assign_block_vars($this->profile_types[$profile_row['field_type']], array_change_key_case($profile_row, CASE_UPPER));
ef5584
	}
ef5584
ef5584
	/**
ef5584
	* Process dropdown-type
ef5584
	* @access private
ef5584
	*/
ef5584
	function generate_dropdown($profile_row, $preview = false)
ef5584
	{
ef5584
		global $user, $template;
ef5584
ef5584
		$value = $this->get_var('int', $profile_row, $profile_row['field_default_value'], $preview);
ef5584
ef5584
		if (!isset($this->options_lang[$profile_row['field_id']]) || !isset($this->options_lang[$profile_row['field_id']][$profile_row['lang_id']]) || !sizeof($this->options_lang[$profile_row['field_id']][$profile_row['lang_id']]))
ef5584
		{
ef5584
			$this->get_option_lang($profile_row['field_id'], $profile_row['lang_id'], FIELD_DROPDOWN, $preview);
ef5584
		}
ef5584
ef5584
		$profile_row['field_value'] = $value;
ef5584
		$template->assign_block_vars($this->profile_types[$profile_row['field_type']], array_change_key_case($profile_row, CASE_UPPER));
ef5584
ef5584
		foreach ($this->options_lang[$profile_row['field_id']][$profile_row['lang_id']] as $option_id => $option_value)
ef5584
		{
ef5584
			$template->assign_block_vars('dropdown.options', array(
ef5584
				'OPTION_ID'	=> $option_id,
ef5584
				'SELECTED'	=> ($value == $option_id) ? ' selected="selected"' : '',
ef5584
				'VALUE'		=> $option_value)
ef5584
			);
ef5584
		}
ef5584
	}
ef5584
ef5584
	/**
ef5584
	* Return Templated value/field. Possible values for $mode are:
ef5584
	* change == user is able to set/enter profile values; preview == just show the value
ef5584
	* @access private
ef5584
	*/
ef5584
	function process_field_row($mode, $profile_row)
ef5584
	{
ef5584
		global $template;
ef5584
ef5584
		$preview = ($mode == 'preview') ? true : false;
ef5584
ef5584
		// set template filename
ef5584
		$template->set_filenames(array(
ef5584
			'cp_body'		=> 'custom_profile_fields.html')
ef5584
		);
ef5584
ef5584
		// empty previously filled blockvars
ef5584
		foreach ($this->profile_types as $field_case => $field_type)
ef5584
		{
ef5584
			$template->destroy_block_vars($field_type);
ef5584
		}
ef5584
ef5584
		// Assign template variables
ef5584
		$type_func = 'generate_' . $this->profile_types[$profile_row['field_type']];
ef5584
		$this->$type_func($profile_row, $preview);
ef5584
ef5584
		// Return templated data
ef5584
		return $template->assign_display('cp_body');
ef5584
	}
ef5584
ef5584
	/**
ef5584
	* Build Array for user insertion into custom profile fields table
ef5584
	*/
ef5584
	function build_insert_sql_array($cp_data)
ef5584
	{
ef5584
		global $db, $user, $auth;
ef5584
ef5584
		$sql_not_in = array();
ef5584
		foreach ($cp_data as $key => $null)
ef5584
		{
ef5584
			$sql_not_in[] = (strncmp($key, 'pf_', 3) === 0) ? substr($key, 3) : $key;
ef5584
		}
ef5584
ef5584
		$sql = 'SELECT f.field_type, f.field_ident, f.field_default_value, l.lang_default_value
ef5584
			FROM ' . PROFILE_LANG_TABLE . ' l, ' . PROFILE_FIELDS_TABLE . ' f
ef5584
			WHERE l.lang_id = ' . $user->get_iso_lang_id() . '
ef5584
				' . ((sizeof($sql_not_in)) ? ' AND ' . $db->sql_in_set('f.field_ident', $sql_not_in, true) : '') . '
ef5584
				AND l.field_id = f.field_id';
ef5584
		$result = $db->sql_query($sql);
ef5584
ef5584
		while ($row = $db->sql_fetchrow($result))
ef5584
		{
ef5584
			if ($row['field_default_value'] == 'now' && $row['field_type'] == FIELD_DATE)
ef5584
			{
ef5584
				$now = getdate();
ef5584
				$row['field_default_value'] = sprintf('%2d-%2d-%4d', $now['mday'], $now['mon'], $now['year']);
ef5584
			}
ef5584
ef5584
			$cp_data['pf_' . $row['field_ident']] = (in_array($row['field_type'], array(FIELD_TEXT, FIELD_STRING))) ? $row['lang_default_value'] : $row['field_default_value'];
ef5584
		}
ef5584
		$db->sql_freeresult($result);
ef5584
ef5584
		return $cp_data;
ef5584
	}
ef5584
ef5584
	/**
ef5584
	* Get profile field value on submit
ef5584
	* @access private
ef5584
	*/
ef5584
	function get_profile_field($profile_row)
ef5584
	{
ef5584
		global $phpbb_root_path, $phpEx;
ef5584
		global $config;
ef5584
ef5584
		$var_name = 'pf_' . $profile_row['field_ident'];
ef5584
ef5584
		switch ($profile_row['field_type'])
ef5584
		{
ef5584
			case FIELD_DATE:
ef5584
ef5584
				if (!isset($_REQUEST[$var_name . '_day']))
ef5584
				{
ef5584
					if ($profile_row['field_default_value'] == 'now')
ef5584
					{
ef5584
						$now = getdate();
ef5584
						$profile_row['field_default_value'] = sprintf('%2d-%2d-%4d', $now['mday'], $now['mon'], $now['year']);
ef5584
					}
ef5584
					list($day, $month, $year) = explode('-', $profile_row['field_default_value']);
ef5584
				}
ef5584
				else
ef5584
				{
ef5584
					$day = request_var($var_name . '_day', 0);
ef5584
					$month = request_var($var_name . '_month', 0);
ef5584
					$year = request_var($var_name . '_year', 0);
ef5584
				}
ef5584
ef5584
				$var = sprintf('%2d-%2d-%4d', $day, $month, $year);
ef5584
			break;
ef5584
ef5584
			case FIELD_BOOL:
ef5584
				// Checkbox
ef5584
				if ($profile_row['field_length'] == 2)
ef5584
				{
ef5584
					$var = (isset($_REQUEST[$var_name])) ? 1 : 0;
ef5584
				}
ef5584
				else
ef5584
				{
ef5584
					$var = request_var($var_name, (int) $profile_row['field_default_value']);
ef5584
				}
ef5584
			break;
ef5584
ef5584
			case FIELD_STRING:
ef5584
			case FIELD_TEXT:
ef5584
				$var = utf8_normalize_nfc(request_var($var_name, (string) $profile_row['field_default_value'], true));
ef5584
			break;
ef5584
ef5584
			case FIELD_INT:
ef5584
				if (isset($_REQUEST[$var_name]) && $_REQUEST[$var_name] === '')
ef5584
				{
ef5584
					$var = NULL;
ef5584
				}
ef5584
				else
ef5584
				{
ef5584
					$var = request_var($var_name, (int) $profile_row['field_default_value']);
ef5584
				}
ef5584
			break;
ef5584
ef5584
			case FIELD_DROPDOWN:
ef5584
				$var = request_var($var_name, (int) $profile_row['field_default_value']);
ef5584
			break;
ef5584
ef5584
			default:
ef5584
				$var = request_var($var_name, $profile_row['field_default_value']);
ef5584
			break;
ef5584
		}
ef5584
ef5584
		return $var;
ef5584
	}
ef5584
}
ef5584
ef5584
/**
ef5584
* Custom Profile Fields ACP
ef5584
* @package phpBB3
ef5584
*/
ef5584
class custom_profile_admin extends custom_profile
ef5584
{
ef5584
	var $vars = array();
ef5584
ef5584
	/**
ef5584
	* Return possible validation options
ef5584
	*/
ef5584
	function validate_options()
ef5584
	{
ef5584
		global $user;
ef5584
ef5584
		$validate_ary = array('CHARS_ANY' => '.*', 'NUMBERS_ONLY' => '[0-9]+', 'ALPHA_ONLY' => '[\w]+', 'ALPHA_SPACERS' => '[\w_\+\. \-\[\]]+');
ef5584
ef5584
		$validate_options = '';
ef5584
		foreach ($validate_ary as $lang => $value)
ef5584
		{
ef5584
			$selected = ($this->vars['field_validation'] == $value) ? ' selected="selected"' : '';
ef5584
			$validate_options .= '<option value="' . $value . '"' . $selected . '>' . $user->lang[$lang] . '</option>';
ef5584
		}
ef5584
ef5584
		return $validate_options;
ef5584
	}
ef5584
ef5584
	/**
ef5584
	* Get string options for second step in ACP
ef5584
	*/
ef5584
	function get_string_options()
ef5584
	{
ef5584
		global $user;
ef5584
ef5584
		$options = array(
ef5584
			0 => array('TITLE' => $user->lang['FIELD_LENGTH'],		'FIELD' => '<input type="text" name="field_length" size="5" value="' . $this->vars['field_length'] . '" />'),
ef5584
			1 => array('TITLE' => $user->lang['MIN_FIELD_CHARS'],	'FIELD' => '<input type="text" name="field_minlen" size="5" value="' . $this->vars['field_minlen'] . '" />'),
ef5584
			2 => array('TITLE' => $user->lang['MAX_FIELD_CHARS'],	'FIELD' => '<input type="text" name="field_maxlen" size="5" value="' . $this->vars['field_maxlen'] . '" />'),
ef5584
			3 => array('TITLE' => $user->lang['FIELD_VALIDATION'],	'FIELD' => '<select name="field_validation">' . $this->validate_options() . '</select>')
ef5584
		);
ef5584
ef5584
		return $options;
ef5584
	}
ef5584
ef5584
	/**
ef5584
	* Get text options for second step in ACP
ef5584
	*/
ef5584
	function get_text_options()
ef5584
	{
ef5584
		global $user;
ef5584
ef5584
		$options = array(
ef5584
			0 => array('TITLE' => $user->lang['FIELD_LENGTH'],		'FIELD' => '<input name="rows" size="5" value="' . $this->vars['rows'] . '" /> ' . $user->lang['ROWS'] . '
<input name="columns" size="5" value="' . $this->vars['columns'] . '" /> ' . $user->lang['COLUMNS'] . ' <input type="hidden" name="field_length" value="' . $this->vars['field_length'] . '" />'),
ef5584
			1 => array('TITLE' => $user->lang['MIN_FIELD_CHARS'],	'FIELD' => '<input type="text" name="field_minlen" size="10" value="' . $this->vars['field_minlen'] . '" />'),
ef5584
			2 => array('TITLE' => $user->lang['MAX_FIELD_CHARS'],	'FIELD' => '<input type="text" name="field_maxlen" size="10" value="' . $this->vars['field_maxlen'] . '" />'),
ef5584
			3 => array('TITLE' => $user->lang['FIELD_VALIDATION'],	'FIELD' => '<select name="field_validation">' . $this->validate_options() . '</select>')
ef5584
		);
ef5584
ef5584
		return $options;
ef5584
	}
ef5584
ef5584
	/**
ef5584
	* Get int options for second step in ACP
ef5584
	*/
ef5584
	function get_int_options()
ef5584
	{
ef5584
		global $user;
ef5584
ef5584
		$options = array(
ef5584
			0 => array('TITLE' => $user->lang['FIELD_LENGTH'],		'FIELD' => '<input type="text" name="field_length" size="5" value="' . $this->vars['field_length'] . '" />'),
ef5584
			1 => array('TITLE' => $user->lang['MIN_FIELD_NUMBER'],	'FIELD' => '<input type="text" name="field_minlen" size="5" value="' . $this->vars['field_minlen'] . '" />'),
ef5584
			2 => array('TITLE' => $user->lang['MAX_FIELD_NUMBER'],	'FIELD' => '<input type="text" name="field_maxlen" size="5" value="' . $this->vars['field_maxlen'] . '" />'),
ef5584
			3 => array('TITLE' => $user->lang['DEFAULT_VALUE'],		'FIELD' => '<input type="post" name="field_default_value" value="' . $this->vars['field_default_value'] . '" />')
ef5584
		);
ef5584
ef5584
		return $options;
ef5584
	}
ef5584
ef5584
	/**
ef5584
	* Get bool options for second step in ACP
ef5584
	*/
ef5584
	function get_bool_options()
ef5584
	{
ef5584
		global $user, $config, $lang_defs;
ef5584
ef5584
		$default_lang_id = $lang_defs['iso'][$config['default_lang']];
ef5584
ef5584
		$profile_row = array(
ef5584
			'var_name'				=> 'field_default_value',
ef5584
			'field_id'				=> 1,
ef5584
			'lang_name'				=> $this->vars['lang_name'],
ef5584
			'lang_explain'			=> $this->vars['lang_explain'],
ef5584
			'lang_id'				=> $default_lang_id,
ef5584
			'field_default_value'	=> $this->vars['field_default_value'],
ef5584
			'field_ident'			=> 'field_default_value',
ef5584
			'field_type'			=> FIELD_BOOL,
ef5584
			'field_length'			=> $this->vars['field_length'],
ef5584
			'lang_options'			=> $this->vars['lang_options']
ef5584
		);
ef5584
ef5584
		$options = array(
ef5584
			0 => array('TITLE' => $user->lang['FIELD_TYPE'], 'EXPLAIN' => $user->lang['BOOL_TYPE_EXPLAIN'], 'FIELD' => '<label><input type="radio" class="radio" name="field_length" value="1"' . (($this->vars['field_length'] == 1) ? ' checked="checked"' : '') . ' onchange="document.getElementById(\'add_profile_field\').submit();" /> ' . $user->lang['RADIO_BUTTONS'] . '</label><label><input type="radio" class="radio" name="field_length" value="2"' . (($this->vars['field_length'] == 2) ? ' checked="checked"' : '') . ' onchange="document.getElementById(\'add_profile_field\').submit();" /> ' . $user->lang['CHECKBOX'] . '</label>'),
ef5584
			1 => array('TITLE' => $user->lang['DEFAULT_VALUE'], 'FIELD' => $this->process_field_row('preview', $profile_row))
ef5584
		);
ef5584
ef5584
		return $options;
ef5584
	}
ef5584
ef5584
	/**
ef5584
	* Get dropdown options for second step in ACP
ef5584
	*/
ef5584
	function get_dropdown_options()
ef5584
	{
ef5584
		global $user, $config, $lang_defs;
ef5584
ef5584
		$default_lang_id = $lang_defs['iso'][$config['default_lang']];
ef5584
ef5584
		$profile_row[0] = array(
ef5584
			'var_name'				=> 'field_default_value',
ef5584
			'field_id'				=> 1,
ef5584
			'lang_name'				=> $this->vars['lang_name'],
ef5584
			'lang_explain'			=> $this->vars['lang_explain'],
ef5584
			'lang_id'				=> $default_lang_id,
ef5584
			'field_default_value'	=> $this->vars['field_default_value'],
ef5584
			'field_ident'			=> 'field_default_value',
ef5584
			'field_type'			=> FIELD_DROPDOWN,
ef5584
			'lang_options'			=> $this->vars['lang_options']
ef5584
		);
ef5584
ef5584
		$profile_row[1] = $profile_row[0];
ef5584
		$profile_row[1]['var_name'] = 'field_novalue';
ef5584
		$profile_row[1]['field_ident'] = 'field_novalue';
ef5584
		$profile_row[1]['field_default_value']	= $this->vars['field_novalue'];
ef5584
ef5584
		$options = array(
ef5584
			0 => array('TITLE' => $user->lang['DEFAULT_VALUE'], 'FIELD' => $this->process_field_row('preview', $profile_row[0])),
ef5584
			1 => array('TITLE' => $user->lang['NO_VALUE_OPTION'], 'EXPLAIN' => $user->lang['NO_VALUE_OPTION_EXPLAIN'], 'FIELD' => $this->process_field_row('preview', $profile_row[1]))
ef5584
		);
ef5584
ef5584
		return $options;
ef5584
	}
ef5584
ef5584
	/**
ef5584
	* Get date options for second step in ACP
ef5584
	*/
ef5584
	function get_date_options()
ef5584
	{
ef5584
		global $user, $config, $lang_defs;
ef5584
ef5584
		$default_lang_id = $lang_defs['iso'][$config['default_lang']];
ef5584
ef5584
		$profile_row = array(
ef5584
			'var_name'				=> 'field_default_value',
ef5584
			'lang_name'				=> $this->vars['lang_name'],
ef5584
			'lang_explain'			=> $this->vars['lang_explain'],
ef5584
			'lang_id'				=> $default_lang_id,
ef5584
			'field_default_value'	=> $this->vars['field_default_value'],
ef5584
			'field_ident'			=> 'field_default_value',
ef5584
			'field_type'			=> FIELD_DATE,
ef5584
			'field_length'			=> $this->vars['field_length']
ef5584
		);
ef5584
ef5584
		$always_now = request_var('always_now', -1);
ef5584
		if ($always_now == -1)
ef5584
		{
ef5584
			$s_checked = ($this->vars['field_default_value'] == 'now') ? true : false;
ef5584
		}
ef5584
		else
ef5584
		{
ef5584
			$s_checked = ($always_now) ? true : false;
ef5584
		}
ef5584
ef5584
		$options = array(
ef5584
			0 => array('TITLE' => $user->lang['DEFAULT_VALUE'],	'FIELD' => $this->process_field_row('preview', $profile_row)),
ef5584
			1 => array('TITLE' => $user->lang['ALWAYS_TODAY'],	'FIELD' => '<label><input type="radio" class="radio" name="always_now" value="1"' . (($s_checked) ? ' checked="checked"' : '') . ' onchange="document.getElementById(\'add_profile_field\').submit();" /> ' . $user->lang['YES'] . '</label><label><input type="radio" class="radio" name="always_now" value="0"' . ((!$s_checked) ? ' checked="checked"' : '') . ' onchange="document.getElementById(\'add_profile_field\').submit();" /> ' . $user->lang['NO'] . '</label>'),
ef5584
		);
ef5584
ef5584
		return $options;
ef5584
	}
ef5584
}
ef5584
ef5584
?>