News:

Wondering if this will always be free?  See why free is better.

Main Menu

Most Valueable Poster (MVP) modification

Started by Spht, July 21, 2006, 10:06:25 PM

Previous topic - Next topic

Spht

Hello

Could someone try out this modification for me as I have no access to a forum to try it

This SMF modification uses member groups for managing MVPs.  The naming
convention for MVP groups is MVP##.# where ##.# is the number of the board
a user is MVP in.  This will allow you to have per-board MVPs, and single
users can be MVPs of multiple boards.  Additionally, if a user is in group
MVP (with no board id) they are board-wide MVP (MVP on every board).

Recognition is MVP title and 5 special stars.  The stars location is
/Themes/classic/images/starmvp.gif

http://www.spht.net/mvp001.zip

Also, how do I determine what versions of SMF my modification is compatible with?  I made it following the SMF Package Software Development Kit.

Edit:  The reason I'm posting this is because I'd like to know about any bugs, or even if it works at all, before putting it on the SMF Mod Site.

Bigguy

So you haven`t tested this AT ALL with any version of smf ???

Spht

Quote from: Bigguy on July 24, 2006, 07:59:16 PM
So you haven`t tested this AT ALL with any version of smf ???

Right, but it's a fairly basic modification.  The only thing that can really go wrong is:

if (in_array("MVP" . $context['current_board'] . '.0', $user_info['groups']) || in_array("MVP", $user_info['groups']))
echo '
MVP<br />
', str_repeat('<img src="/Themes/classic/images/starmvp.gif" alt="*" border="0" />', 5), '<br />';


(which basically checks if the user is in group MVP or MVP##.# where ##.# is the number of the board the post is in, then show MVP title and stars)

From reviewing the default display template, and my little knowledge of PHP, I am pretty sure this is the correct way to do it, but I am not positive


Bigguy

Installed on smf 1.1 rc2. No problems with install but as my forum (the one I tested on, not a live one) is not that busy I don`t see a change anywhere.

Bigguy

Here are the error log reports, nothing shows anywhere:

in_array() [<a href='function.in-array'>function.in-array</a>]: Wrong datatype for second argument
File: /var/www/virtual/ec.byethost32.com/htdocs/forum/Themes/default/Display.template.php (main sub template - eval?)
Line: 300


Undefined variable: user_info
File: /var/www/virtual/ec.byethost32.com/htdocs/forum/Themes/default/Display.template.php (eval?)
Line: 300



Spht

#5
Quote from: Bigguy on July 24, 2006, 09:57:28 PM
Here are the error log reports, nothing shows anywhere:

in_array() [<a href='function.in-array'>function.in-array</a>]: Wrong datatype for second argument
File: /var/www/virtual/ec.byethost32.com/htdocs/forum/Themes/default/Display.template.php (main sub template - eval?)
Line: 300


Undefined variable: user_info
File: /var/www/virtual/ec.byethost32.com/htdocs/forum/Themes/default/Display.template.php (eval?)
Line: 300




Alright, it looks like you can't use $user_info['groups'] in Display.template.  What I need here is an array of the groups a user is in, so I can check if they're in group MVP or MVP##.#.

Do I have to construct this array myself or is there already a variable for it?

Edit:  In Load.php, when $themeUser[$user] is constructed, could I add:

'groups' => array_merge(array($profile['ID_GROUP']), explode(',', $profile['additionalGroups'])),

Which will make $message['member']['groups'] an array of all the groups a user is in.  Then in Display.template, use $message['member']['groups'] instead of $user_info['groups']?  Is that the best way to do this?

Edit2:  Made the change

Added this to modification.xml and made appropriate reference to new variable in Display.template section:

<file name="$sourcedir/Load.php">
<operation>
<search position="add"><![CDATA[
'group_id' => $profile['ID_GROUP'],
]]></search>
<add><![CDATA[
'groups' => array_merge(array($profile['ID_GROUP']), explode(',', $profile['additionalGroups'])),
]]></add>
</operation>
</file>


Let me know if it works out, thanks!

By the way, to test it, just add someone to group MVP##.# where ##.# is a board id (ie, MVP60.0 for SMF Coding Discussion) then check a post by them in that forum--they should have MVP title and stars (if starmvp.gif is available).

Spht

Updated mvp001_debug to include starmvp.gif.

Here's an example of what it should look like when it works (which I'm not sure if it does yet--the screen shot was forged).

Bigguy

The other one uninstalled fine, this one installed fine, but still get an error and nothing shows:

QuoteUndefined index: additionalGroups
File: /var/www/virtual/ec.byethost32.com/htdocs/forum/Sources/Load.php
Line: 994

Spht

Quote from: Bigguy on July 25, 2006, 10:57:04 AM
The other one uninstalled fine, this one installed fine, but still get an error and nothing shows:

QuoteUndefined index: additionalGroups
File: /var/www/virtual/ec.byethost32.com/htdocs/forum/Sources/Load.php
Line: 994

Oh, I forgot to define additionalGroups.

Try this

Added:

<operation>
<search position="replace"><![CDATA[
IFNULL(lo.logTime, 0) AS isOnline, IFNULL(a.ID_ATTACH, 0) AS ID_ATTACH, a.filename, mem.signature,
]]></search>
<add><![CDATA[
IFNULL(lo.logTime, 0) AS isOnline, IFNULL(a.ID_ATTACH, 0) AS ID_ATTACH, a.filename, mem.signature, mem.additionalGroups,
]]></add>
</operation>


Thanks

Bigguy

This one has an error when installing in:

./Sources/Load.php

Spht

Quote from: Bigguy on July 25, 2006, 11:16:02 AM
This one has an error when installing in:

./Sources/Load.php

Strange... what's the error?

Bigguy

This is all it says upon install:

Execute Modification     ./Sources/Load.php     Test failed

Spht

Quote from: Bigguy on July 25, 2006, 11:42:17 AM
This is all it says upon install:

Execute Modification     ./Sources/Load.php     Test failed

It was a 1.1 rc2 / 1.0.7 compatibility issue.  Try this

Change:

<operation>
<search position="replace"><![CDATA[IFNULL(lo.logTime, 0) AS isOnline, IFNULL(a.ID_ATTACH, 0) AS ID_ATTACH, a.filename,]]></search>
<add><![CDATA[IFNULL(lo.logTime, 0) AS isOnline, IFNULL(a.ID_ATTACH, 0) AS ID_ATTACH, a.filename, mem.additionalGroups,]]></add>
</operation>

Bigguy


Spht

Quote from: Bigguy on July 25, 2006, 12:33:20 PM
No errors but nothing shows up either.

What do you mean?  The forum doesn't work at all?  Nothing at all shows up in a poster's userbox?  Putting someone in MVP group doesn't change their userbox at all?

Try adding someone to group MVP (board-wide MVP) and see if their userbox changes at all.

If anyone else out there wants to help out, this is the code I'm using to check if user if MVP of current board or board-wide MVP:

if (in_array("MVP" . $context['current_board'] . '.0', $message['member']['groups']) || in_array("MVP", $message['member']['groups']))
echo '
MVP<br />
', str_repeat('<img src="/Themes/classic/images/starmvp.gif" alt="*" border="0" />', 5), '<br />';


$message['member']['groups'] is an array of every group the user is a member of, and is defined as shown in my previous posts.

Bigguy

There is no MVP group I can find anywhere, also the forum works just no MVP beside anyones name.

Spht

#16
Quote from: Bigguy on July 25, 2006, 01:28:48 PM
There is no MVP group I can find anywhere, also the forum works just no MVP beside anyones name.

I don't know how the group system works from an administrative perspective, but doesn't SMF have an option to create a group, and select which groups a user is a member of?

Edit:  Yeah:

Quote(SMF feature list)

Membergroups

    * Create membergroups to group members on permissions, access rights, and/or appearance.
    * Assign several membergroups to a single member, with one membergroup as the primary group.


Bigguy

So I have to make the group and then asign a user to it. ??? Shouldn`t this mod make that group and then add the user to that group ???

Spht

#18
Quote from: Bigguy on July 25, 2006, 01:48:56 PM
So I have to make the group and then asign a user to it. ??? Shouldn`t this mod make that group and then add the user to that group ???

Yeah.  I might make a form just for making MVPs in the future, but for now,

QuoteThis SMF modification uses member groups for managing MVPs.  The naming
convention for MVP groups is MVP##.# where ##.# is the number of the board
a user is MVP in.  This will allow you to have per-board MVPs, and single
users can be MVPs of multiple boards.  Additionally, if a user is in group
MVP (with no board id) they are board-wide MVP (MVP on every board).

So, for example, if you were administrator of this board, and you wanted to make me a board-wide MVP (MVP on every board), you would create the group MVP and assign the user Spht to it.  Now, in every post I make on every board, I will have MVP title & 5 stars.

If you wanted me to only be MVP in Feature Requests and SMF Coding Discussion, then you would create groups MVP3.0 and MVP60.0 and assign the user Spht to them, and I will only have MVP title & 5 stars there.

Let me know how it works out, thanks

Bigguy

I take it this would be a post based group that I am creating ???

Advertisement: