Skip to content

Commit

Permalink
Merge pull request SimpleMachines#7410 from Sesquipedalian/buddy_list…
Browse files Browse the repository at this point in the history
…_custom_fields
  • Loading branch information
Sesquipedalian authored Apr 8, 2022
2 parents ae0ab6f + 8958cbe commit 0a1830b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
24 changes: 16 additions & 8 deletions Sources/Profile-Modify.php
Original file line number Diff line number Diff line change
Expand Up @@ -1528,7 +1528,7 @@ function editBuddies($memID)

// Gotta load the custom profile fields names.
$request = $smcFunc['db_query']('', '
SELECT col_name, field_name, field_desc, field_type, bbc, enclose
SELECT col_name, field_name, field_desc, field_type, field_options, show_mlist, bbc, enclose
FROM {db_prefix}custom_fields
WHERE active = {int:active}
AND private < {int:private_level}',
Expand All @@ -1541,18 +1541,15 @@ function editBuddies($memID)
$context['custom_pf'] = array();
$disabled_fields = isset($modSettings['disabled_profile_fields']) ? array_flip(explode(',', $modSettings['disabled_profile_fields'])) : array();
while ($row = $smcFunc['db_fetch_assoc']($request))
if (!isset($disabled_fields[$row['col_name']]))
if (!isset($disabled_fields[$row['col_name']]) && !empty($row['show_mlist']))
$context['custom_pf'][$row['col_name']] = array(
'label' => $row['field_name'],
'label' => tokenTxtReplace($row['field_name']),
'type' => $row['field_type'],
'options' => !empty($row['field_options']) ? explode(',', $row['field_options']) : array(),
'bbc' => !empty($row['bbc']),
'enclose' => $row['enclose'],
);

// Gotta disable the gender option.
if (isset($context['custom_pf']['cust_gender']) && $context['custom_pf']['cust_gender'] == 'None')
unset($context['custom_pf']['cust_gender']);

$smcFunc['db_free_result']($request);

if (!empty($buddiesArray))
Expand Down Expand Up @@ -1597,6 +1594,16 @@ function editBuddies($memID)
continue;
}

$currentKey = 0;
if (!empty($column['options']))
{
foreach ($column['options'] as $k => $v)
{
if (empty($currentKey))
$currentKey = $v == $context['buddies'][$buddy]['options'][$key] ? $k : 0;
}
}

if ($column['bbc'] && !empty($context['buddies'][$buddy]['options'][$key]))
$context['buddies'][$buddy]['options'][$key] = strip_tags(parse_bbc($context['buddies'][$buddy]['options'][$key]));

Expand All @@ -1609,7 +1616,8 @@ function editBuddies($memID)
'{SCRIPTURL}' => $scripturl,
'{IMAGES_URL}' => $settings['images_url'],
'{DEFAULT_IMAGES_URL}' => $settings['default_images_url'],
'{INPUT}' => $context['buddies'][$buddy]['options'][$key],
'{KEY}' => $currentKey,
'{INPUT}' => tokenTxtReplace($context['buddies'][$buddy]['options'][$key]),
));
}
}
Expand Down
2 changes: 1 addition & 1 deletion Themes/default/Profile.template.php
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,7 @@ function template_editBuddies()
if (!empty($context['custom_pf']))
foreach ($context['custom_pf'] as $key => $column)
echo '
<td class="lefttext buddy_custom_fields">', $buddy['options'][$key], '</td>';
<td class="centertext buddy_custom_fields">', $buddy['options'][$key], '</td>';

echo '
<td class="centertext buddy_remove">
Expand Down

0 comments on commit 0a1830b

Please sign in to comment.