use same method to update custom profile fields in UCP and ACP (and then i am able to debug what is wrong with the oracle code)

git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9582 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Meik Sievertsen 2009-06-13 14:23:04 +00:00
parent 11dc410633
commit 2d30e88089
3 changed files with 62 additions and 68 deletions

View file

@ -1136,54 +1136,7 @@ class acp_users
$db->sql_query($sql);
// Update Custom Fields
if (sizeof($cp_data))
{
switch ($db->sql_layer)
{
case 'oracle':
case 'firebird':
case 'postgres':
$right_delim = $left_delim = '"';
break;
case 'sqlite':
case 'mssql':
case 'mssql_odbc':
$right_delim = ']';
$left_delim = '[';
break;
case 'mysql':
case 'mysql4':
case 'mysqli':
$right_delim = $left_delim = '`';
break;
}
foreach ($cp_data as $key => $value)
{
// Firebird is case sensitive with delimiter
$cp_data[$left_delim . (($db->sql_layer == 'firebird') ? strtoupper($key) : $key) . $right_delim] = $value;
unset($cp_data[$key]);
}
$sql = 'UPDATE ' . PROFILE_FIELDS_DATA_TABLE . '
SET ' . $db->sql_build_array('UPDATE', $cp_data) . "
WHERE user_id = $user_id";
$db->sql_query($sql);
if (!$db->sql_affectedrows())
{
$cp_data['user_id'] = (int) $user_id;
$db->sql_return_on_error(true);
$sql = 'INSERT INTO ' . PROFILE_FIELDS_DATA_TABLE . ' ' . $db->sql_build_array('INSERT', $cp_data);
$db->sql_query($sql);
$db->sql_return_on_error(false);
}
}
$cp->update_profile_field_data($user_id, $cp_data);
trigger_error($user->lang['USER_PROFILE_UPDATED'] . adm_back_link($this->u_action . '&u=' . $user_id));
}

View file

@ -259,7 +259,7 @@ class custom_profile
}
/**
* Submit profile field
* Submit profile field for validation
* @access public
*/
function submit_cp_field($mode, $lang_id, &$cp_data, &$cp_error)
@ -349,6 +349,65 @@ class custom_profile
$db->sql_freeresult($result);
}
/**
* Update profile field data directly
*/
function update_profile_field_data($user_id, &$cp_data)
{
global $db;
if (!sizeof($cp_data))
{
return;
}
switch ($db->sql_layer)
{
case 'oracle':
case 'firebird':
case 'postgres':
$right_delim = $left_delim = '"';
break;
case 'sqlite':
case 'mssql':
case 'mssql_odbc':
$right_delim = ']';
$left_delim = '[';
break;
case 'mysql':
case 'mysql4':
case 'mysqli':
$right_delim = $left_delim = '`';
break;
}
foreach ($cp_data as $key => $value)
{
// Firebird is case sensitive with delimiter
$cp_data[$left_delim . (($db->sql_layer == 'firebird') ? strtoupper($key) : $key) . $right_delim] = $value;
unset($cp_data[$key]);
}
$sql = 'UPDATE ' . PROFILE_FIELDS_DATA_TABLE . '
SET ' . $db->sql_build_array('UPDATE', $cp_data) . "
WHERE user_id = $user_id";
$db->sql_query($sql);
if (!$db->sql_affectedrows())
{
$cp_data['user_id'] = (int) $user_id;
$db->sql_return_on_error(true);
$sql = 'INSERT INTO ' . PROFILE_FIELDS_DATA_TABLE . ' ' . $db->sql_build_array('INSERT', $cp_data);
$db->sql_query($sql);
$db->sql_return_on_error(false);
}
}
/**
* Assign fields to template, used for viewprofile, viewtopic and memberlist (if load setting is enabled)
* 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

View file

@ -380,25 +380,7 @@ class ucp_profile
$db->sql_query($sql);
// Update Custom Fields
if (sizeof($cp_data))
{
$sql = 'UPDATE ' . PROFILE_FIELDS_DATA_TABLE . '
SET ' . $db->sql_build_array('UPDATE', $cp_data) . '
WHERE user_id = ' . $user->data['user_id'];
$db->sql_query($sql);
if (!$db->sql_affectedrows())
{
$cp_data['user_id'] = (int) $user->data['user_id'];
$db->sql_return_on_error(true);
$sql = 'INSERT INTO ' . PROFILE_FIELDS_DATA_TABLE . ' ' . $db->sql_build_array('INSERT', $cp_data);
$db->sql_query($sql);
$db->sql_return_on_error(false);
}
}
$cp->update_profile_field_data($user->data['user_id'], $cp_data);
meta_refresh(3, $this->u_action);
$message = $user->lang['PROFILE_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>');