Modify mlist to include custom field

Started by thunderchld, January 31, 2018, 11:31:55 AM

Previous topic - Next topic

thunderchld

We have custom profile fields enable to include "real name" and "character name". My end-goal is to modify the View Members list (http://SITE/index.php?action=mlist) to include those fields on display.

I did a quick search and have not found a mod for this (there are a lot to look through), but I'm fairly comfortable (and I have a test forum) with modifying the view on the page to include this (I keep a change-log post with all changes made in the event we need to un-do or re-do for updates).

Has anyone done this successfully?  I am not far enough along yet to post code snippets. I just did not want to reinvent the wheel if I did not have to.  I plan on making another attempt at code changes tonight.

Pipke

"If something is wrong, fix it if you can. But train yourself not to worry: Worry never fixes anything."

Click here to view my mods for SMF

Hey 👋 Did i helped... you like what i do. You can now buy me a coffee! ☕

pepa

The old mod is here.   No-one, who has posted, has been able to get it working on 2.0.15.  If you get your code up and running I'd be interested in having a look.  What I'm interested in is having those fields show in search results of the member list.

thunderchld

Just FYI to keep everything in the correct place: https://www.simplemachines.org/community/index.php?topic=481160.new#new

I'm going to mark this resolved and put my notes in that thread.

thunderchld

I was incorrect in posting on the other thread. I've re-opened this topic, if that is allowed, to track.If this is not the correct location - please tell me exactly where you want me to post.

Notes:

I've updated the changes to account for 2.0.15. However, I'm running into the install issue:

Error:
Table 'SCHEME.custom_fields' doesn't exist
File: /PATH/Packages/temp/install.php
Line: 16


Line 16 of install.php:
$columns = $smcFunc['db_list_columns']('custom_fields');

First, I feel we are missing the database prefix.  My table should be SCHEME.testing_custom_fields.  Okay, I can fix that.

Second, and this is a dumb question I am sure. Are we -looking- for or -adding- "custom_fields".  If we are looking for - I believe it should be "cf_" or "cust_"  Or, I'm not understanding what this line should be doing.

pepa

Hi thunderchild

Thanks for your work on this so far.  A lot of people have been asking for custom fields to be included in the member list and various permutations of this.  Doesn't seem to be an area where others are really enthusiastic to help though, perhaps it's more difficult than it seems?  Regardless my experience here is that the community is very helpful and generous in giving time, so I'm hopeful about this one.

Thanks again : )

thunderchld

#6
Got this working in a bastardized format -but it works. Someone with more time and better programming skills could probably clean this up.

On "install.php"
Line 16 and Line 19 need to have the table prefix added.
(I manually added my table prefix)


On "modification.xml"
Line 22/23 changes from;

<search position="replace"><![CDATA['can_search' => 'int', 'bbc' => 'int', 'mask' => 'string',]]></search>
<add><![CDATA['can_search' => 'int', 'bbc' => 'int', 'mask' => 'string', 'show_mlist' => 'int',]]></add>

to:

<search position="replace"><![CDATA['bbc' => 'int', 'mask' => 'string', 'enclose' => 'string', 'placement' => 'int',]]></search>
<add><![CDATA['bbc' => 'int', 'mask' => 'string', 'enclose' => 'string', 'show_mlist' => 'int', 'placement' => 'int',]]></add>


Line 26/27 changes from:

<search position="replace"><![CDATA[$can_search, $bbc, $mask,]]></search>
<add><![CDATA[$can_search, $bbc, $mask, $show_mlist,]]></add>

to:

<search position="replace"><![CDATA[$bbc, $mask, $enclose, $placement,]]></search>
<add><![CDATA[$bbc, $mask, $show_mlist, $enclose, $placement,]]></add>


Line 40/41 changes from:

<search position="replace"><![CDATA[can_search, bbc, mask]]></search>
<add><![CDATA[can_search, bbc, mask, show_mlist]]></add>

to:

<search position="replace"><![CDATA[bbc, mask, enclose, placement]]></search>
<add><![CDATA[bbc, mask, show_mlist, enclose, placement]]></add>



Line 157-168 changes from:

<search position="replace"><![CDATA[ <input type="checkbox" name="display" id="display" ', $context['field']['display'] ? 'checked="checked"' : '', ' class="check" />
</td>]]></search>
<add><![CDATA[ <input type="checkbox" name="display" id="display" ', $context['field']['display'] ? 'checked="checked"' : '', ' class="check" />
</td>
</tr><tr class="windowbg2">
<td width="50%">
<b>', $txt['custom_edit_mod_mlist'], ':</b>
<div class="smalltext">', $txt['custom_edit_mod_mlist_desc'], '</div>
</td>
<td width="50%">
<input type="checkbox" name="mlist" ', $context['field']['mlist'] ? 'checked="checked"' : '', ' class="check" />
</td>]]></add>

to:

<search position="replace"><![CDATA[ <input type="checkbox" name="display" id="display" ', $context['field']['display'] ? 'checked="checked"' : '', ' class="check" />]]></search>
<add><![CDATA[ <input type="checkbox" name="display" id="display" ', $context['field']['display'] ? 'checked="checked"' : '', ' class="check" />
</dd>
<dt>
<strong>', $txt['custom_edit_mod_mlist'], ':</strong><br />
<span class="smalltext">', $txt['custom_edit_mod_mlist_desc'], '</span>
</dt>
<dd>
<input type="checkbox" name="mlist" ', $context['field']['mlist'] ? 'checked="checked"' : '', ' class="check" />
</dd>]]></add>



Line 173-190 changes from:

<search position="replace"><![CDATA[ echo '
</tr>';
}
}
// No members?]]></search>
<add><![CDATA[ // Any custom fields to show?
if (!empty($context['custom_profile_fields']['columns']))
{
foreach ($context['custom_profile_fields']['columns'] as $key => $column)
echo '
<td class="windowbg" align="left">', $member['options'][substr($key, 5)], '</td>';
}

echo '
</tr>';
}
}
// No members?]]></add>

to:

</tr>';
}
}
// No members?]]></search>
<add><![CDATA[ // Any custom fields to show?
if (!empty($context['custom_profile_fields']['columns']))
{
foreach ($context['custom_profile_fields']['columns'] as $key => $column)
echo '
<td class="windowbg" align="left">', $member['options'][substr($key, 5)], '</td>';
}

echo '
</tr>';
}
}
// No members?]]></add>



I've packed it up if someone wants to give it a try - Assuming I'm asking for help in the correct manner.

I've used this package on my test forum and my production one.  I did have to modify a theme file on my test site but not my production. It was the same changes made to line 156-166 above.

Kindred

attachment removed.

the existing mod license does not allow for modification/redistribution.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

pepa

Hi Kindred

What is the process for modifying a SMF rule under exceptional circumstances?

There have been numerous requests over time for this mod to be upgraded.  I do appreciate the effort thunderchild has gone to in this instance.  I needed this functionality so badly that I have made several topic posts asking for 'versions' of it.  Several months ago (actually I think it was last year) I sent a PM to the mods author offering to pay for an upgrade, I checked and he was around at the time, there was no reply to my PM.

So just wondering if there is a process in the SMF rules to handle circumstances such as these?

thunderchld

I was not trying to viloate any license, just trying to get the mod to work in the latest version. I agree with Pepe...how should we handle these situations?

(My phone autocorrected Pepe's name, edit was to fix that)

GigaWatt

Hint: You could post it on any other site ;).
"This is really a generic concept about human thinking - when faced with large tasks we're naturally inclined to try to break them down into a bunch of smaller tasks that together make up the whole."

"A 500 error loosely translates to the webserver saying, "WTF?"..."

Sir Osis of Liver

Think I did this for someone not long ago, wasn't that difficult.  You just want to add a couple of columns to memberlist for custom profile fields?
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

pepa

Quote from: Sir Osis of Liver on May 01, 2018, 07:25:16 PM
Think I did this for someone not long ago, wasn't that difficult.  You just want to add a couple of columns to memberlist for custom profile fields?

Yes, but to also have them display in search results on the membership list.

Kindred

Quote from: pepa on May 01, 2018, 06:48:35 PM
Hi Kindred

What is the process for modifying a SMF rule under exceptional circumstances?

There have been numerous requests over time for this mod to be upgraded.  I do appreciate the effort thunderchild has gone to in this instance.  I needed this functionality so badly that I have made several topic posts asking for 'versions' of it.  Several months ago (actually I think it was last year) I sent a PM to the mods author offering to pay for an upgrade, I checked and he was around at the time, there was no reply to my PM.

So just wondering if there is a process in the SMF rules to handle circumstances such as these?


Unfortunately, there is nothing we (SMF) can do about it.
The license is restrictive -- no redistribution.
therefore, you can give instructions on how to modify the mod, but you can not package it up.

although there may be many people asking for it, this does not change the basic IP rights/requirements.

Quote from: GigaWatt on May 01, 2018, 07:12:06 PM
Hint: You could post it on any other site ;).

No, actually, posting on another site would STILL be a violation of the IP rights of the original author, based on the license of the mod.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

pepa

Quote from: Kindred on May 02, 2018, 07:17:40 AM

Unfortunately, there is nothing we (SMF) can do about it.
The license is restrictive -- no redistribution.
therefore, you can give instructions on how to modify the mod, but you can not package it up.

although there may be many people asking for it, this does not change the basic IP rights/requirements.

Perhaps contacting the author, explaining that the mod is now unsupported and not working on current SMF versions ... asking if under these circumstances he/she would consider relaxing the IP restrictions.

Also considering making more flexible arrangements like this a more standard practice in future?

Additionally consider having this flexibility in original IP agreements?

There must be ways to make these types of situations more generally helpful for the entire community.

Illori

take a look at https://www.simplemachines.org/community/index.php?topic=461016.0, we are following the law. we cannot just relax or change this without the author changing the license.

pepa

Quote from: Illori on May 02, 2018, 08:36:19 AM
take a look at https://www.simplemachines.org/community/index.php?topic=461016.0, we are following the law. we cannot just relax or change this without the author changing the license.

Yep, that's one of the things I was suggesting ... asking the author to change the license.  People and circumstances change over time, even though an author may select an exclusive IP license at some time they may agree to change it later when circumstances are different ... can't hurt to ask.

Kindred

but that is not the responsibility of SMF.  If any user wants to take up modification and support of a mod, then they are free to attempt to contact the original author.

as for flexibility...   we do ask the authors is a clear license.
Some do release with BSD, MIT or other license that allows modification and redistribution. Some don't. The choice is up to each author, and is, again, not SMF's responsibility (except to enforce said license, especially on our site).

Mods which were released before a clear license was required fall into the "most restrictive license" category - because that's how IP law works.


So -- TL;DR
If you want to change the license or modify the mod, then it is up to you to contact the author
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Pipke

"If something is wrong, fix it if you can. But train yourself not to worry: Worry never fixes anything."

Click here to view my mods for SMF

Hey 👋 Did i helped... you like what i do. You can now buy me a coffee! ☕

thunderchld

I'll refrain from making my own new mod and package it as I'm sure I'll violate something else at the rate I'm going.   I'll leave what i have up and just try and work with in the confines of core SMF going forward.

Advertisement: