phpBB

Code Changes

File: includes/acp/acp_profile.php

  Unmodified   Added   Modified   Removed
Line 25Line 25

var $edit_lang_id;
var $lang_defs;


var $edit_lang_id;
var $lang_defs;

 

/**
* @var \phpbb\di\service_collection
*/

	protected $type_collection;

function main($id, $mode)
{

	protected $type_collection;

function main($id, $mode)
{

		global $config, $db, $user, $auth, $template, $cache;
global $phpbb_root_path, $phpbb_admin_path, $phpEx, $table_prefix;
global $request, $phpbb_container, $phpbb_dispatcher;

		global $config, $db, $user, $template;
global $phpbb_root_path, $phpEx;
global $request, $phpbb_container, $phpbb_log, $phpbb_dispatcher;


if (!function_exists('generate_smilies'))
{


if (!function_exists('generate_smilies'))
{

Line 48Line 52
		$this->page_title = 'ACP_CUSTOM_PROFILE_FIELDS';

$field_id = $request->variable('field_id', 0);

		$this->page_title = 'ACP_CUSTOM_PROFILE_FIELDS';

$field_id = $request->variable('field_id', 0);

		$action = (isset($_POST['create'])) ? 'create' : request_var('action', '');

		$action = (isset($_POST['create'])) ? 'create' : $request->variable('action', '');


$error = array();


$error = array();

		$s_hidden_fields = '';

 

$form_key = 'acp_profile';
add_form_key($form_key);


$form_key = 'acp_profile';
add_form_key($form_key);

Line 61Line 64
			trigger_error($user->lang['NO_FIELD_ID'] . adm_back_link($this->u_action), E_USER_WARNING);
}


			trigger_error($user->lang['NO_FIELD_ID'] . adm_back_link($this->u_action), E_USER_WARNING);
}


 
		/* @var $cp \phpbb\profilefields\manager */

		$cp = $phpbb_container->get('profilefields.manager');
$this->type_collection = $phpbb_container->get('profilefields.type_collection');


		$cp = $phpbb_container->get('profilefields.manager');
$this->type_collection = $phpbb_container->get('profilefields.type_collection');


Line 122Line 126
					$db->sql_query('DELETE FROM ' . PROFILE_FIELDS_LANG_TABLE . " WHERE field_id = $field_id");
$db->sql_query('DELETE FROM ' . PROFILE_LANG_TABLE . " WHERE field_id = $field_id");


					$db->sql_query('DELETE FROM ' . PROFILE_FIELDS_LANG_TABLE . " WHERE field_id = $field_id");
$db->sql_query('DELETE FROM ' . PROFILE_LANG_TABLE . " WHERE field_id = $field_id");


 
					/* @var $db_tools \phpbb\db\tools\tools_interface */

					$db_tools = $phpbb_container->get('dbal.tools');
$db_tools->sql_column_remove(PROFILE_FIELDS_DATA_TABLE, 'pf_' . $field_ident);


					$db_tools = $phpbb_container->get('dbal.tools');
$db_tools->sql_column_remove(PROFILE_FIELDS_DATA_TABLE, 'pf_' . $field_ident);


Line 147Line 152

$db->sql_transaction('commit');



$db->sql_transaction('commit');


					add_log('admin', 'LOG_PROFILE_FIELD_REMOVED', $field_ident);

					$phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_PROFILE_FIELD_REMOVED', false, array($field_ident));

					trigger_error($user->lang['REMOVED_PROFILE_FIELD'] . adm_back_link($this->u_action));
}
else

					trigger_error($user->lang['REMOVED_PROFILE_FIELD'] . adm_back_link($this->u_action));
}
else

Line 193Line 198
				$field_ident = (string) $db->sql_fetchfield('field_ident');
$db->sql_freeresult($result);


				$field_ident = (string) $db->sql_fetchfield('field_ident');
$db->sql_freeresult($result);


				add_log('admin', 'LOG_PROFILE_FIELD_ACTIVATE', $field_ident);

				$phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_PROFILE_FIELD_ACTIVATE', false, array($field_ident));


if ($request->is_ajax())
{


if ($request->is_ajax())
{

Line 234Line 239
					));
}


					));
}


				add_log('admin', 'LOG_PROFILE_FIELD_DEACTIVATE', $field_ident);

				$phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_PROFILE_FIELD_DEACTIVATE', false, array($field_ident));


trigger_error($user->lang['PROFILE_FIELD_DEACTIVATED'] . adm_back_link($this->u_action));



trigger_error($user->lang['PROFILE_FIELD_DEACTIVATED'] . adm_back_link($this->u_action));


Line 280Line 285
			case 'create':
case 'edit':


			case 'create':
case 'edit':


				$step = request_var('step', 1);

				$step = $request->variable('step', 1);


$submit = (isset($_REQUEST['next']) || isset($_REQUEST['prev'])) ? true : false;
$save = (isset($_REQUEST['save'])) ? true : false;


$submit = (isset($_REQUEST['next']) || isset($_REQUEST['prev'])) ? true : false;
$save = (isset($_REQUEST['save'])) ? true : false;

Line 344Line 349
					// We are adding a new field, define basic params
$lang_options = $field_row = array();


					// We are adding a new field, define basic params
$lang_options = $field_row = array();


					$field_type = request_var('field_type', '');

					$field_type = $request->variable('field_type', '');


if (!isset($this->type_collection[$field_type]))
{


if (!isset($this->type_collection[$field_type]))
{

Line 353Line 358

$profile_field = $this->type_collection[$field_type];
$field_row = array_merge($profile_field->get_default_option_values(), array(


$profile_field = $this->type_collection[$field_type];
$field_row = array_merge($profile_field->get_default_option_values(), array(

						'field_ident'		=> str_replace(' ', '_', utf8_clean_string(request_var('field_ident', '', true))),

						'field_ident'		=> str_replace(' ', '_', utf8_clean_string($request->variable('field_ident', '', true))),

						'field_required'	=> 0,
'field_show_novalue'=> 0,
'field_hide' => 0,

						'field_required'	=> 0,
'field_show_novalue'=> 0,
'field_hide' => 0,

Line 366Line 371
						'field_is_contact'	=> 0,
'field_contact_desc'=> '',
'field_contact_url' => '',

						'field_is_contact'	=> 0,
'field_contact_desc'=> '',
'field_contact_url' => '',

						'lang_name'			=> utf8_normalize_nfc(request_var('field_ident', '', true)),

						'lang_name'			=> $request->variable('field_ident', '', true),

						'lang_explain'		=> '',
'lang_default_value'=> '')
);

						'lang_explain'		=> '',
'lang_default_value'=> '')
);

Line 422Line 427

$options = $profile_field->prepare_options_form($exclude, $visibility_ary);



$options = $profile_field->prepare_options_form($exclude, $visibility_ary);


				$cp->vars['field_ident']		= ($action == 'create' && $step == 1) ? utf8_clean_string(request_var('field_ident', $field_row['field_ident'], true)) : request_var('field_ident', $field_row['field_ident']);

				$cp->vars['field_ident']		= ($action == 'create' && $step == 1) ? utf8_clean_string($request->variable('field_ident', $field_row['field_ident'], true)) : $request->variable('field_ident', $field_row['field_ident']);

				$cp->vars['lang_name']			= $request->variable('lang_name', $field_row['lang_name'], true);
$cp->vars['lang_explain'] = $request->variable('lang_explain', $field_row['lang_explain'], true);
$cp->vars['lang_default_value'] = $request->variable('lang_default_value', $field_row['lang_default_value'], true);

				$cp->vars['lang_name']			= $request->variable('lang_name', $field_row['lang_name'], true);
$cp->vars['lang_explain'] = $request->variable('lang_explain', $field_row['lang_explain'], true);
$cp->vars['lang_default_value'] = $request->variable('lang_default_value', $field_row['lang_default_value'], true);

Line 461Line 466
				// step 2
foreach ($exclude[2] as $key)
{

				// step 2
foreach ($exclude[2] as $key)
{

					$var = utf8_normalize_nfc(request_var($key, $field_row[$key], true));

					$var = $request->variable($key, $field_row[$key], true);


$field_data = $cp->vars;
$var = $profile_field->get_excluded_options($key, $action, $var, $field_data, 2);


$field_data = $cp->vars;
$var = $profile_field->get_excluded_options($key, $action, $var, $field_data, 2);

Line 507Line 512

foreach ($exclude[3] as $key)
{


foreach ($exclude[3] as $key)
{

					$cp->vars[$key] = utf8_normalize_nfc(request_var($key, array(0 => ''), true));

					$cp->vars[$key] = $request->variable($key, array(0 => ''), true);


if (!$cp->vars[$key] && $action == 'edit')
{


if (!$cp->vars[$key] && $action == 'edit')
{

Line 596Line 601
				}

if (!sizeof($error))

				}

if (!sizeof($error))

 
				{
if (($step == 3 && (sizeof($this->lang_defs['iso']) == 1 || $save)) || ($action == 'edit' && $save))

				{
if (!check_form_key($form_key))
{
trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING);
}


				{
if (!check_form_key($form_key))
{
trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING);
}


					if (($step == 3 && (sizeof($this->lang_defs['iso']) == 1 || $save)) || ($action == 'edit' && $save))
{

 
						$this->save_profile_field($cp, $field_type, $action);
}
}

						$this->save_profile_field($cp, $field_type, $action);
}
}

Line 752Line 757
				$s_one_need_edit = true;
}


				$s_one_need_edit = true;
}


 
			if (!isset($this->type_collection[$row['field_type']]))
{
continue;
}

			$profile_field = $this->type_collection[$row['field_type']];
$template->assign_block_vars('fields', array(
'FIELD_IDENT' => $row['field_ident'],

			$profile_field = $this->type_collection[$row['field_type']];
$template->assign_block_vars('fields', array(
'FIELD_IDENT' => $row['field_ident'],

Line 793Line 802
	*/
function build_language_options(&$cp, $field_type, $action = 'create')
{

	*/
function build_language_options(&$cp, $field_type, $action = 'create')
{

		global $user, $config, $db, $phpbb_container;

		global $user, $config, $db, $request;


$default_lang_id = (!empty($this->edit_lang_id)) ? $this->edit_lang_id : $this->lang_defs['iso'][$config['default_lang']];



$default_lang_id = (!empty($this->edit_lang_id)) ? $this->edit_lang_id : $this->lang_defs['iso'][$config['default_lang']];


Line 834Line 843
			$lang_options[$lang_id]['lang_iso'] = $lang_iso;
foreach ($options as $field => $field_type)
{

			$lang_options[$lang_id]['lang_iso'] = $lang_iso;
foreach ($options as $field => $field_type)
{

				$value = ($action == 'create') ? utf8_normalize_nfc(request_var('l_' . $field, array(0 => ''), true)) : $cp->vars['l_' . $field];

				$value = ($action == 'create') ? $request->variable('l_' . $field, array(0 => ''), true) : $cp->vars['l_' . $field];

				if ($field == 'lang_options')
{
$var = (!isset($cp->vars['l_lang_options'][$lang_id]) || !is_array($cp->vars['l_lang_options'][$lang_id])) ? $cp->vars['lang_options'] : $cp->vars['l_lang_options'][$lang_id];

				if ($field == 'lang_options')
{
$var = (!isset($cp->vars['l_lang_options'][$lang_id]) || !is_array($cp->vars['l_lang_options'][$lang_id])) ? $cp->vars['lang_options'] : $cp->vars['l_lang_options'][$lang_id];

Line 890Line 899
	*/
function save_profile_field(&$cp, $field_type, $action = 'create')
{

	*/
function save_profile_field(&$cp, $field_type, $action = 'create')
{

		global $db, $config, $user, $phpbb_container, $phpbb_dispatcher;

		global $db, $config, $user, $phpbb_container, $phpbb_log, $request, $phpbb_dispatcher;





		$field_id = request_var('field_id', 0);

		$field_id = $request->variable('field_id', 0);


// Collect all information, if something is going wrong, abort the operation
$profile_sql = $profile_lang = $empty_lang = $profile_lang_fields = array();


// Collect all information, if something is going wrong, abort the operation
$profile_sql = $profile_lang = $empty_lang = $profile_lang_fields = array();

Line 979Line 988
		if ($action == 'create')
{
$field_ident = 'pf_' . $field_ident;

		if ($action == 'create')
{
$field_ident = 'pf_' . $field_ident;



			/* @var $db_tools \phpbb\db\tools\tools_interface */

			$db_tools = $phpbb_container->get('dbal.tools');
$db_tools->sql_column_add(PROFILE_FIELDS_DATA_TABLE, $field_ident, array($profile_field->get_database_column_type(), null));
}

			$db_tools = $phpbb_container->get('dbal.tools');
$db_tools->sql_column_add(PROFILE_FIELDS_DATA_TABLE, $field_ident, array($profile_field->get_database_column_type(), null));
}

Line 1178Line 1187

if ($action == 'edit')
{


if ($action == 'edit')
{

			add_log('admin', 'LOG_PROFILE_FIELD_EDIT', $cp->vars['field_ident'] . ':' . $cp->vars['lang_name']);

			$phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_PROFILE_FIELD_EDIT', false, array($cp->vars['field_ident'] . ':' . $cp->vars['lang_name']));

			trigger_error($user->lang['CHANGED_PROFILE_FIELD'] . adm_back_link($this->u_action));
}
else
{

			trigger_error($user->lang['CHANGED_PROFILE_FIELD'] . adm_back_link($this->u_action));
}
else
{

			add_log('admin', 'LOG_PROFILE_FIELD_CREATE', substr($field_ident, 3) . ':' . $cp->vars['lang_name']);

			$phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_PROFILE_FIELD_CREATE', false, array(substr($field_ident, 3) . ':' . $cp->vars['lang_name']));

			trigger_error($user->lang['ADDED_PROFILE_FIELD'] . adm_back_link($this->u_action));
}
}

			trigger_error($user->lang['ADDED_PROFILE_FIELD'] . adm_back_link($this->u_action));
}
}