Advertisement:

Author Topic: Custom profiles showing in members profile improperly  (Read 4921 times)

Offline mrhope

  • Semi-Newbie
  • *
  • Posts: 87
    • Computer Hope
Custom profiles showing in members profile improperly
« on: September 25, 2010, 09:09:19 AM »
I have SMF 2.0RC3 custom profiles feature enabled with the ability for users to add icons to their profiles by checking a box in their profile. This works great when viewing the users profile in a thread, however, when opening that users profile it shows all icons regardless if they're checked or not. I also noticed that even if these fields are empty that the <li></li> will also be printed. Probably because of the || in the below code.

default\Profile.template.php
Code: [Select]
// Are there any custom profile fields for the summary?
if (!empty($context['custom_fields']))
{
foreach ($context['custom_fields'] as $field)
if ($field['placement'] == 1 || empty($field['output_html']))
echo '
<li>', $field['output_html'], '</li>';
}

I tried comparing the above code with what is in the display.template.php and noticed that it's $context['member']['custom_fields'] but changing the code to how it is in the display.template.php doesn't seem to work, just shows no icons even if they're checked.

This is an Example page, on this users profile it should not be showing any of the last four icons as they're all unchecked in the users profile.

« Last Edit: October 04, 2010, 04:24:19 PM by Kindred »

Offline mrhope

  • Semi-Newbie
  • *
  • Posts: 87
    • Computer Hope
Re: Custom profiles showing in members profile improperly
« Reply #1 on: September 27, 2010, 05:45:49 PM »
Since I haven't got a reply spent some time debugging this and found the fix. Here is how I fixed this.

I looked at the array using print_r ($context['custom_fields']) which showed me arrays like the one shown below.

Code: [Select]
[0] => Array
(
    [name] => F@H
    [desc] => Folding @ Home user
    [type] => check
    [input_html] => <input type="checkbox" name="customfield[cust_f]"  class="input_check" />
    [output_html] => <a href="URL"><img src="folding.gif" alt="F@H member" /></a>

    [placement] => 1
    [colname] => cust_f
    [value] => 0
)

As can be seen I have HTML data, but the value is 0 (e.g. box is not checked). So even though this isn't checked it's still going to show using the original SMF code. To fix this I changed it so if the value is not 0 (checked) AND is not empty then echo the data.

Code: [Select]
// Are there any custom profile fields for the summary?
if (!empty($context['custom_fields']))
foreach ($context['custom_fields'] as $field)
if ($field['placement'] == 1 && !$field['value'] == 0 && !empty($field['value']))
echo '
<li>', $field['output_html'], '</li>';


Hope this helps, if this isn't already fixed in RC4 would highly recommend it.

« Last Edit: September 27, 2010, 05:50:01 PM by mrhope »

Offline Norv

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 18,313
  • Blue Wolf
Re: Custom profiles showing in members profile improperly
« Reply #2 on: October 17, 2010, 11:25:42 PM »
Sorry for the delay, mrhope, and thank you very much for the report.
To-do lists are for deferral. The more things you write down the later they're done… until you have 100s of lists of things you don't do.
File a security report | Developers' Blog | Bug Tracker

Also known as Norv on D* | Norv N. on G+ | Norv on Github

Offline emanuele

  • SMF Super Hero
  • *******
  • Posts: 14,156
  • Gender: Male
  • THERE'S JUST ME
Re: Custom profiles showing in members profile improperly
« Reply #3 on: May 28, 2011, 03:58:37 PM »
Last minute bump program! :P (sorry for the late bump, but I completely forgot about them... :-[)

Updated fix:
Code: (find) [Select]
// Are there any custom profile fields for the summary?
if (!empty($context['custom_fields']))
{
foreach ($context['custom_fields'] as $field)
if ($field['placement'] == 1 || empty($field['output_html']))

Code: (replace with) [Select]
// Are there any custom profile fields for the summary?
if (!empty($context['custom_fields']))
{
foreach ($context['custom_fields'] as $field)
if (($field['placement'] == 1 || empty($field['output_html'])) && !empty($field['value']))
« Last Edit: May 28, 2011, 04:02:27 PM by emanuele »


Take a peek at what I'm doing! ;D



Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

Offline Antechinus

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 24,136
  • Master of BBC Abuse
Re: Custom profiles showing in members profile improperly
« Reply #4 on: May 28, 2011, 06:59:08 PM »
These last minute bumps should have been tracked to Mantis.

* Antechinus grumbes about hiding reports in obscure places.............

ETA: Sorted it.
« Last Edit: May 28, 2011, 07:48:47 PM by Antechinus »

Offline emanuele

  • SMF Super Hero
  • *******
  • Posts: 14,156
  • Gender: Male
  • THERE'S JUST ME
Re: Custom profiles showing in members profile improperly
« Reply #5 on: May 29, 2011, 03:08:52 AM »
Sorry for not tracking it... :-[


Take a peek at what I'm doing! ;D



Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.