aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB')
-rw-r--r--phpBB/includes/ucp/ucp_pm_viewmessage.php4
-rw-r--r--phpBB/memberlist.php8
-rw-r--r--phpBB/phpbb/profilefields/manager.php192
-rw-r--r--phpBB/viewtopic.php4
4 files changed, 104 insertions, 104 deletions
diff --git a/phpBB/includes/ucp/ucp_pm_viewmessage.php b/phpBB/includes/ucp/ucp_pm_viewmessage.php
index e4bc4629ac..feea01dbfa 100644
--- a/phpBB/includes/ucp/ucp_pm_viewmessage.php
+++ b/phpBB/includes/ucp/ucp_pm_viewmessage.php
@@ -63,7 +63,7 @@ function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row)
{
$cp = $phpbb_container->get('profilefields.manager');
- $profile_fields = $cp->generate_profile_fields_template('grab', $author_id);
+ $profile_fields = $cp->grab_profile_fields_data($author_id);
}
// Assign TO/BCC Addresses to template
@@ -173,7 +173,7 @@ function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row)
if (isset($profile_fields[$author_id]))
{
- $cp_row = $cp->generate_profile_fields_template('show', false, $profile_fields[$author_id]);
+ $cp_row = $cp->generate_profile_fields_template_data($profile_fields[$author_id]);
}
}
diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php
index f1ee622445..a05a0999dc 100644
--- a/phpBB/memberlist.php
+++ b/phpBB/memberlist.php
@@ -618,8 +618,8 @@ switch ($mode)
if ($config['load_cpf_viewprofile'])
{
$cp = $phpbb_container->get('profilefields.manager');
- $profile_fields = $cp->generate_profile_fields_template('grab', $user_id);
- $profile_fields = (isset($profile_fields[$user_id])) ? $cp->generate_profile_fields_template('show', false, $profile_fields[$user_id]) : array();
+ $profile_fields = $cp->grab_profile_fields_data($user_id);
+ $profile_fields = (isset($profile_fields[$user_id])) ? $cp->generate_profile_fields_template_data($profile_fields[$user_id]) : array();
}
// If the user has m_approve permission or a_user permission, then list then display unapproved posts
@@ -1560,7 +1560,7 @@ switch ($mode)
if ($config['load_cpf_memberlist'])
{
// Grab all profile fields from users in id cache for later use - similar to the poster cache
- $profile_fields_cache = $cp->generate_profile_fields_template('grab', $user_list);
+ $profile_fields_cache = $cp->grab_profile_fields_data($user_list);
// Filter the fields we don't want to show
foreach ($profile_fields_cache as $user_id => $user_profile_fields)
@@ -1592,7 +1592,7 @@ switch ($mode)
$cp_row = array();
if ($config['load_cpf_memberlist'])
{
- $cp_row = (isset($profile_fields_cache[$user_id])) ? $cp->generate_profile_fields_template('show', false, $profile_fields_cache[$user_id]) : array();
+ $cp_row = (isset($profile_fields_cache[$user_id])) ? $cp->generate_profile_fields_template_data($profile_fields_cache[$user_id]) : array();
}
$memberrow = array_merge(show_profile($row), array(
diff --git a/phpBB/phpbb/profilefields/manager.php b/phpBB/phpbb/profilefields/manager.php
index 874d0a21e0..8b4a3917f2 100644
--- a/phpBB/phpbb/profilefields/manager.php
+++ b/phpBB/phpbb/profilefields/manager.php
@@ -278,125 +278,125 @@ class manager
}
/**
- * 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
+ * Grab the user specific profile fields data
+ *
+ * @param int|array $user_ids Single user id or an array of ids
+ * @return array Users profile fields data
*/
- public function generate_profile_fields_template($mode, $user_id = 0, $profile_row = false)
+ public function grab_profile_fields_data($user_ids = 0)
{
- if ($mode == 'grab')
+ if (!is_array($user_ids))
{
- if (!is_array($user_id))
- {
- $user_id = array($user_id);
- }
+ $user_ids = array($user_ids);
+ }
- if (!sizeof($this->profile_cache))
- {
- $this->build_cache();
- }
+ if (!sizeof($this->profile_cache))
+ {
+ $this->build_cache();
+ }
- if (!sizeof($user_id))
- {
- return array();
- }
+ if (!sizeof($user_ids))
+ {
+ return array();
+ }
- $sql = 'SELECT *
- FROM ' . $this->fields_data_table . '
- WHERE ' . $this->db->sql_in_set('user_id', array_map('intval', $user_id));
- $result = $this->db->sql_query($sql);
+ $sql = 'SELECT *
+ FROM ' . $this->fields_data_table . '
+ WHERE ' . $this->db->sql_in_set('user_id', array_map('intval', $user_ids));
+ $result = $this->db->sql_query($sql);
- $field_data = array();
- while ($row = $this->db->sql_fetchrow($result))
- {
- $field_data[$row['user_id']] = $row;
- }
- $this->db->sql_freeresult($result);
+ $field_data = array();
+ while ($row = $this->db->sql_fetchrow($result))
+ {
+ $field_data[$row['user_id']] = $row;
+ }
+ $this->db->sql_freeresult($result);
- $user_fields = array();
+ $user_fields = array();
- $user_ids = $user_id;
+ // Go through the fields in correct order
+ foreach (array_keys($this->profile_cache) as $used_ident)
+ {
+ foreach ($field_data as $user_id => $row)
+ {
+ $user_fields[$user_id][$used_ident]['value'] = $row['pf_' . $used_ident];
+ $user_fields[$user_id][$used_ident]['data'] = $this->profile_cache[$used_ident];
+ }
- // Go through the fields in correct order
- foreach (array_keys($this->profile_cache) as $used_ident)
+ foreach ($user_ids as $user_id)
{
- foreach ($field_data as $user_id => $row)
+ if (!isset($user_fields[$user_id][$used_ident]) && $this->profile_cache[$used_ident]['field_show_novalue'])
{
- $user_fields[$user_id][$used_ident]['value'] = $row['pf_' . $used_ident];
+ $user_fields[$user_id][$used_ident]['value'] = '';
$user_fields[$user_id][$used_ident]['data'] = $this->profile_cache[$used_ident];
}
-
- foreach ($user_ids as $user_id)
- {
- if (!isset($user_fields[$user_id][$used_ident]) && $this->profile_cache[$used_ident]['field_show_novalue'])
- {
- $user_fields[$user_id][$used_ident]['value'] = '';
- $user_fields[$user_id][$used_ident]['data'] = $this->profile_cache[$used_ident];
- }
- }
}
-
- return $user_fields;
}
- else if ($mode == 'show')
- {
- // $profile_row == $user_fields[$row['user_id']];
- $tpl_fields = array();
- $tpl_fields['row'] = $tpl_fields['blockrow'] = array();
- foreach ($profile_row as $ident => $ident_ary)
- {
- $profile_field = $this->type_collection[$ident_ary['data']['field_type']];
- $value = $profile_field->get_profile_value($ident_ary['value'], $ident_ary['data']);
+ return $user_fields;
+ }
- if ($value === null)
- {
- continue;
- }
+ /**
+ * Assign the user's profile fields data to the template
+ *
+ * @param array $profile_row Array with users profile field data
+ * @return array
+ */
+ public function generate_profile_fields_template_data($profile_row)
+ {
+ // $profile_row == $user_fields[$row['user_id']];
+ $tpl_fields = array();
+ $tpl_fields['row'] = $tpl_fields['blockrow'] = array();
- $field_desc = $this->user->lang($ident_ary['data']['field_contact_desc']);
- if (strpos($field_desc, '%s') !== false)
- {
- $field_desc = sprintf($field_desc, $value);
- }
- $contact_url = '';
- if (strpos($ident_ary['data']['field_contact_url'], '%s') !== false)
- {
- $contact_url = sprintf($ident_ary['data']['field_contact_url'], $value);
- }
+ foreach ($profile_row as $ident => $ident_ary)
+ {
+ $profile_field = $this->type_collection[$ident_ary['data']['field_type']];
+ $value = $profile_field->get_profile_value($ident_ary['value'], $ident_ary['data']);
- $tpl_fields['row'] += array(
- 'PROFILE_' . strtoupper($ident) . '_IDENT' => $ident,
- 'PROFILE_' . strtoupper($ident) . '_VALUE' => $value,
- 'PROFILE_' . strtoupper($ident) . '_CONTACT'=> $contact_url,
- 'PROFILE_' . strtoupper($ident) . '_DESC' => $field_desc,
- 'PROFILE_' . strtoupper($ident) . '_TYPE' => $ident_ary['data']['field_type'],
- 'PROFILE_' . strtoupper($ident) . '_NAME' => $this->user->lang($ident_ary['data']['lang_name']),
- 'PROFILE_' . strtoupper($ident) . '_EXPLAIN'=> $this->user->lang($ident_ary['data']['lang_explain']),
-
- 'S_PROFILE_' . strtoupper($ident) . '_CONTACT' => $ident_ary['data']['field_is_contact'],
- 'S_PROFILE_' . strtoupper($ident) => true,
- );
-
- $tpl_fields['blockrow'][] = array(
- 'PROFILE_FIELD_IDENT' => $ident,
- 'PROFILE_FIELD_VALUE' => $value,
- 'PROFILE_FIELD_CONTACT' => $contact_url,
- 'PROFILE_FIELD_DESC' => $field_desc,
- 'PROFILE_FIELD_TYPE' => $ident_ary['data']['field_type'],
- 'PROFILE_FIELD_NAME' => $this->user->lang($ident_ary['data']['lang_name']),
- 'PROFILE_FIELD_EXPLAIN' => $this->user->lang($ident_ary['data']['lang_explain']),
-
- 'S_PROFILE_CONTACT' => $ident_ary['data']['field_is_contact'],
- 'S_PROFILE_' . strtoupper($ident) => true,
- );
+ if ($value === null)
+ {
+ continue;
}
- return $tpl_fields;
- }
- else
- {
- trigger_error('Wrong mode for custom profile', E_USER_ERROR);
+ $field_desc = $this->user->lang($ident_ary['data']['field_contact_desc']);
+ if (strpos($field_desc, '%s') !== false)
+ {
+ $field_desc = sprintf($field_desc, $value);
+ }
+ $contact_url = '';
+ if (strpos($ident_ary['data']['field_contact_url'], '%s') !== false)
+ {
+ $contact_url = sprintf($ident_ary['data']['field_contact_url'], $value);
+ }
+
+ $tpl_fields['row'] += array(
+ 'PROFILE_' . strtoupper($ident) . '_IDENT' => $ident,
+ 'PROFILE_' . strtoupper($ident) . '_VALUE' => $value,
+ 'PROFILE_' . strtoupper($ident) . '_CONTACT'=> $contact_url,
+ 'PROFILE_' . strtoupper($ident) . '_DESC' => $field_desc,
+ 'PROFILE_' . strtoupper($ident) . '_TYPE' => $ident_ary['data']['field_type'],
+ 'PROFILE_' . strtoupper($ident) . '_NAME' => $this->user->lang($ident_ary['data']['lang_name']),
+ 'PROFILE_' . strtoupper($ident) . '_EXPLAIN'=> $this->user->lang($ident_ary['data']['lang_explain']),
+
+ 'S_PROFILE_' . strtoupper($ident) . '_CONTACT' => $ident_ary['data']['field_is_contact'],
+ 'S_PROFILE_' . strtoupper($ident) => true,
+ );
+
+ $tpl_fields['blockrow'][] = array(
+ 'PROFILE_FIELD_IDENT' => $ident,
+ 'PROFILE_FIELD_VALUE' => $value,
+ 'PROFILE_FIELD_CONTACT' => $contact_url,
+ 'PROFILE_FIELD_DESC' => $field_desc,
+ 'PROFILE_FIELD_TYPE' => $ident_ary['data']['field_type'],
+ 'PROFILE_FIELD_NAME' => $this->user->lang($ident_ary['data']['lang_name']),
+ 'PROFILE_FIELD_EXPLAIN' => $this->user->lang($ident_ary['data']['lang_explain']),
+
+ 'S_PROFILE_CONTACT' => $ident_ary['data']['field_is_contact'],
+ 'S_PROFILE_' . strtoupper($ident) => true,
+ );
}
+
+ return $tpl_fields;
}
/**
diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php
index 422227f172..25f577937e 100644
--- a/phpBB/viewtopic.php
+++ b/phpBB/viewtopic.php
@@ -1248,7 +1248,7 @@ if ($config['load_cpf_viewtopic'])
$cp = $phpbb_container->get('profilefields.manager');
// Grab all profile fields from users in id cache for later use - similar to the poster cache
- $profile_fields_tmp = $cp->generate_profile_fields_template('grab', $id_cache);
+ $profile_fields_tmp = $cp->grab_profile_fields_data($id_cache);
// filter out fields not to be displayed on viewtopic. Yes, it's a hack, but this shouldn't break any MODs.
$profile_fields_cache = array();
@@ -1558,7 +1558,7 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i)
//
if ($config['load_cpf_viewtopic'])
{
- $cp_row = (isset($profile_fields_cache[$poster_id])) ? $cp->generate_profile_fields_template('show', false, $profile_fields_cache[$poster_id]) : array();
+ $cp_row = (isset($profile_fields_cache[$poster_id])) ? $cp->generate_profile_fields_template_data($profile_fields_cache[$poster_id]) : array();
}
$post_unread = (isset($topic_tracking_info[$topic_id]) && $row['post_time'] > $topic_tracking_info[$topic_id]) ? true : false;