News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Mod that displays Member Groups for users under their names / Avatars on posts

Started by GJSchaller, March 06, 2008, 11:08:13 PM

Previous topic - Next topic

GJSchaller

Getting closer...

http://www.knightrealms.com/Components/Forums/Themes/Knight_Realms/Display.template.txt

It displays ALL users as being in the same 4 groups... is it possible it's reading the viewer's groups, and not the poster's?

(I have it disabled for now - I can rename the .txt to .php to enable it, it's running off the default for now.)
Geoffrey J. Schaller
Knight Realms - Technical Officer
http://www.knightrealms.com/

GJSchaller

I think this is what I am looking for:

// Show what groups they are members of.
if( in_array(2, $message['member']['groups'] ) ) { echo 'Staff<br />'; }
if( in_array(16, $message['member']['groups'] ) ) { echo 'Deputy<br />'; }
if( in_array(7, $message['member']['groups'] ) ) { echo 'Rules Marshal<br />'; }
if( in_array(14, $message['member']['groups'] ) ) { echo 'Monster Marshal<br />'; }
if( in_array(8, $message['member']['groups'] ) ) { echo 'RP Marshal<br />'; }
if( in_array(9, $message['member']['groups'] ) ) { echo 'Storyteller<br />'; }
if( in_array(13, $message['member']['groups'] ) ) { echo 'In-Game: Noble<br />'; }
echo '<br />';


I want it to show the groups of the POSTER, not the USER.

I added this to my Display.template.php, but it did not seem to work - what do I need to tweak?

My current one is here:

http://www.knightrealms.com/Components/Forums/Themes/Knight_Realms/Display.template.txt
Geoffrey J. Schaller
Knight Realms - Technical Officer
http://www.knightrealms.com/

ccbtimewiz

Hmmm....

$message['member']['group'] returns a single value-- their prime group. I don't believe that it returns any information about secondary groups.

$user_info['groups'] returns all the information into an array of data-- which is filtered using the in_array() function. However since it's currently being looped with $message, the $user_info is undefined regardless of putting it into the global statements-- and it outputs the reader's information.

The only other alternative is to loop additional groups into the array for $context['member'] and sort it using $user_info array checks. This is possible but may be a bit time consuming to actually get working. I'll see what I can do to do it. :)

GJSchaller

Geoffrey J. Schaller
Knight Realms - Technical Officer
http://www.knightrealms.com/

ccbtimewiz

Display.php

$request = db_query("
SELECT
lo.ID_MEMBER, lo.logTime, mem.realName, mem.memberName, mem.showOnline,
mg.onlineColor, mg.ID_GROUP, mg.groupName
FROM {$db_prefix}log_online AS lo
LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = lo.ID_MEMBER)
LEFT JOIN {$db_prefix}membergroups AS mg ON (mg.ID_GROUP = IF(mem.ID_GROUP = 0, mem.ID_POST_GROUP, mem.ID_GROUP))
WHERE INSTR(lo.url, 's:5:\"topic\";i:$topic;') OR lo.session = '" . ($user_info['is_guest'] ? 'ip' . $user_info['ip'] : session_id()) . "'", __FILE__, __LINE__);


Selecting the information, then eventually sorting it into a variable:

// Add them both to the list and to the more detailed list.
if (!empty($row['showOnline']) || allowedTo('moderate_forum'))
$context['view_members_list'][$row['logTime'] . $row['memberName']] = empty($row['showOnline']) ? '<i>' . $link . '</i>' : $link;
$context['view_members'][$row['logTime'] . $row['memberName']] = array(
'id' => $row['ID_MEMBER'],
'username' => $row['memberName'],
'name' => $row['realName'],
'group' => $row['ID_GROUP'],
'href' => $scripturl . '?action=profile;u=' . $row['ID_MEMBER'],
'link' => $link,
'is_buddy' => $is_buddy,
'hidden' => empty($row['showOnline']),
);


See the 'group' part? This means $member['group'] returns the constant value of $row['ID_GROUP']

I am only trying to make sense of these attributes and I haven't tested any of them-- so bear with me.

Alter the code I showed above as follows:

SELECT
lo.ID_MEMBER, lo.logTime, mem.realName, mem.memberName, mem.showOnline, mem.additionalGroups
mg.onlineColor, mg.ID_GROUP, mg.groupName


$context['view_members'][$row['logTime'] . $row['memberName']] = array(
'id' => $row['ID_MEMBER'],
'username' => $row['memberName'],
'name' => $row['realName'],
'add_groups' => array($row['additionalGroups']),
'group' => $row['ID_GROUP'],
'href' => $scripturl . '?action=profile;u=' . $row['ID_MEMBER'],
'link' => $link,
'is_buddy' => $is_buddy,
'hidden' => empty($row['showOnline']),
);


Call the information using if( in_array($x, $message['member']['add_groups'] ) ) while you have $x equal to $x = array(#, #, #) with each number as the group in question.

Bulakbol

My way. Sources/Load.php (around line 844), function loadMemberData()
Code (find) Select
mem.buddy_list, mg.onlineColor AS member_group_color, IFNULL(mg.groupName, '') AS member_group,
Code (replace) Select
mem.buddy_list, mg.onlineColor AS member_group_color, IFNULL(mg.groupName, '') AS member_group, mem.additionalGroups,
In function loadMemberContext()
Code (find) Select
return true;
}

// Load a theme, by ID.

Code (replace) Select
$groups = $profile['additionalGroups'];
// additional groups
if (!empty($groups))
{
$result = db_query("
SELECT groupName
FROM {$db_prefix}membergroups
WHERE ID_GROUP IN (" . $groups . ')
', __FILE__, __LINE__);

while ($row = mysql_fetch_assoc($result))
$memberContext[$user]['additional_groups']['name'][] = $row['groupName'];
mysql_free_result($result);
}


return true;
}

// Load a theme, by ID.


default/Display.template.php
Code (find) Select
', $message['member']['group'], '<br />';
Code (replace) Select
', $message['member']['group'], '<br />';

if (!empty($message['member']['additional_groups']))
echo implode('<br />', $message['member']['additional_groups']['name']), '<br />';




Please do not PM me for support · My Mods and Theme · SMF Coding Guidelines · Modifications Approval Guidelines

GJSchaller

I'm getting the following error after modifying Load.php:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'In function loadMemberContext()
pg.onlineColor AS post_group_color, IFNULL(pg' at line 7
File: /home/kradmin/public_html/Components/Forums/Sources/Load.php
Line: 897


File is at: http://www.knightrealms.com/Components/Forums/Sources/Load.php.txt
Geoffrey J. Schaller
Knight Realms - Technical Officer
http://www.knightrealms.com/

Bulakbol

heh you pasted everything.
Quotemem.buddy_list, mem.latitude, mem.longitude, mg.onlineColor AS member_group_color, IFNULL(mg.groupName, '') AS member_group, mem.additionalGroups,In function loadMemberContext()

The red one should not be in there. Take it out.
Please do not PM me for support · My Mods and Theme · SMF Coding Guidelines · Modifications Approval Guidelines

GJSchaller

Oh, whoops.  I was reading from the email notification, which threw off the formatting a bit.

Let me go try again...
Geoffrey J. Schaller
Knight Realms - Technical Officer
http://www.knightrealms.com/

GJSchaller

Wah-FRIKKIN-Hoo!  It works!

http://www.knightrealms.com/Components/Forums/index.php?topic=1498.msg12388

Thank you SO much!  I obviously rearranged a lot of the code to suit my own needs, but... wow.  This REALLY does the trick.

All I could ask for now is to make it a package, so that others can use it, too.
Geoffrey J. Schaller
Knight Realms - Technical Officer
http://www.knightrealms.com/

ccbtimewiz

Thanks for that, Johny. :)

I knew I was on the right track somewhere. :P

Bulakbol

My pleasure ccbtimewiz. You can add the membergroup color and package it. :)
Please do not PM me for support · My Mods and Theme · SMF Coding Guidelines · Modifications Approval Guidelines

ccbtimewiz

That seems like a plan. I guess you don't want to make it a package because of all the mods you have to support already. :P

I'll make this into a nice package with options in later versions, perhaps. :)

GJSchaller

Two options I can think of, for later:

1) Add the groups to the user's Profile, as well.

2) The ability to choose which groups are displayed, in case you don't want to reveal some of them (but do want to reveal others).  I realize this is a BIG change, but would be great to have.

cc, Johnny, can I help in any way?  You've done a lot to assist here, how can I contribute?
Geoffrey J. Schaller
Knight Realms - Technical Officer
http://www.knightrealms.com/

ccbtimewiz

Profile wise is a piece of cake, literally.

The second part might be a bit more difficult; but one solution in doing such would be to make a "exempt" list in the Features and options panel, that will disclude groups that you define, such as; 1, 2, 3 would hide any those add. groups.

ke4obt

Hi All,

This realy sounds like what i've been looking for, but would it be possable to get the final codeing and how and where to put the changes e.g. (file names, look for and do this).
As it is I need to try to fix my members list, oh boy did I ever mess it up.
So you get my point, plus being blind and just starting up in this stuff I am realy DANGERis, and don't want to try tracking any mor boo boos down.

      Thanks Lotts 
      Flip - KE4OBT
      The blind ham
Thanks Much

Flip - KE4OBT
     The Blind Ham
Helping other blind hams
get on the air!


Yes I am really a BLIND user!

So, if a mod doesn't install properly, and I can't get help from your part of the forum,
I will come begging for YOUR help since you wrote it and know how it works
um, uh, well,
At least I would really, really hope you do!
HEE-HEE-HEE

GJSchaller

The post you are looking for is above, by JohnnyB:

http://www.simplemachines.org/community/index.php?topic=226827.msg1676636#msg1676636

That has the exact steps needed.  I followed them, and other than one mis-click (which was my fault, not the code) they worked perfectly.
Geoffrey J. Schaller
Knight Realms - Technical Officer
http://www.knightrealms.com/

ke4obt

Thanks GJSchaller,

That sounds great, i'll grab the code and work on it this week-end.

     Flip - KE4OBT
Thanks Much

Flip - KE4OBT
     The Blind Ham
Helping other blind hams
get on the air!


Yes I am really a BLIND user!

So, if a mod doesn't install properly, and I can't get help from your part of the forum,
I will come begging for YOUR help since you wrote it and know how it works
um, uh, well,
At least I would really, really hope you do!
HEE-HEE-HEE

ke4obt

Thanks Much

Flip - KE4OBT
     The Blind Ham
Helping other blind hams
get on the air!


Yes I am really a BLIND user!

So, if a mod doesn't install properly, and I can't get help from your part of the forum,
I will come begging for YOUR help since you wrote it and know how it works
um, uh, well,
At least I would really, really hope you do!
HEE-HEE-HEE


Advertisement: