News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Member Awards (2.0 Compatible!)

Started by Spuds, September 18, 2006, 03:14:03 PM

Previous topic - Next topic

JayBachatero

In
File: Load.php
Code (find) Select

$new_loaded_ids = array();
while ($row = mysql_fetch_assoc($request))
{
$new_loaded_ids[] = $row['ID_MEMBER'];
$loaded_ids[] = $row['ID_MEMBER'];
$row['options'] = array();
$user_profile[$row['ID_MEMBER']] = $row;
}
mysql_free_result($request);


Code (Add After) Select

// Load the awards
$request = db_query("
SELECT COUNT(*) AS awards, ID_MEMBER
FROM {$db_prefix}awards_members
WHERE ID_MEMBER IN ('" . implode("', '", $loaded_ids) . "')
GROUP BY ID_MEMBER", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($request))
$user_profile[$row['ID_MEMBER']]['awards'] = $row['awards'];
mysql_free_result($request);


Code (find) Select

'group_stars' => str_repeat('<img src="' . str_replace('$language', $context['user']['language'], isset($profile['stars'][1]) ? $settings['images_url'] . '/' . $profile['stars'][1] : '') . '" alt="*" border="0" />', empty($profile['stars'][0]) || empty($profile['stars'][1]) ? 0 : $profile['stars'][0]),
'local_time' => timeformat(time() + ($profile['timeOffset'] - $user_info['time_offset']) * 3600, false),


Code (Add After) Select

'awards' => &$profile['awards'],


File: Display.template.php
Code (find) Select

// Show how many posts they have made.
echo '
', $txt[26], ': ', $message['member']['posts'], '<br />
<br />';


Code (Add After) Select

// Show number of awards
echo '
', $txt['awards'], ': ', !empty($message['member']['awards']) ? $message['member']['awards'] : 0, '<br />
<br />';
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

TechnoDragon

in the display template part...if you change:
This:
// Show number of awards
echo '
', $txt['awards'], ': ', !empty($message['member']['awards']) ? $message['member']['awards'] : 0, '<br />
<br />';


To this:
// Show number of awards
echo '
<a href="', $scripturl, '?action=profile;sa=awards;u=', $message['member']['id'], '">', $txt['awards_total'], '</a>: ', !empty($message['member']['awards']) ? $message['member']['awards'] : 0, '<br />
<br />';


You'll give a quick link for everyone to go view all of the awards of that member!
Don't tell me to get into shape...I have a shape...It is round!


JayBachatero

Oops.  Forgot that he wanted it to be a link.  Thanks for pointing it out TechnoDragon.
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

TechnoDragon

Anytime  I can offer my meager knowledge of coding!

ROFL
Don't tell me to get into shape...I have a shape...It is round!


Assistance

anyone care to share what that code does?
~playing poker~

TechnoDragon

Well, depending on which code you are talking about, one shows each members favorite award in the posts (if they have chosen one), the other shows the number of awards each member has won.
Don't tell me to get into shape...I have a shape...It is round!


Xarcell

#166
I have a question about the ability of this mod. If it is not a feature, will you consider adding it.

Is it an option that only certain membergroups that can give a user an award, can only give an award that that particular membergroup added?

For example:

"X membergroup" should only be able to add awards to a user that "X membergroup" uploaded to the selection list.

I wouldn't want "X membergroup" add awards to a user that "Y membergroup" uploaded to the selection list.

Admin's would be an exception of course....

Maybe even add the that "X membergroup" can only see awards uploaded by "X membergroup" in the selection list. This would help avoid scrolling and clutter for large forums....

If you add these permission features, this would would be perfect.

JayBachatero

It can be done with an extra permission.  Lets see what I come up with.
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

Gobo

Great mod Jay

Ill be making badges for the whole year MOTM (member of the month)
And hopefully others and post them here for people who wana use them :D

Gobo

#169
ok i was thinkin of makin PER month based badges but then i decided thats gona mess everything up and clutter the whole area with badges

so here are a few basic ones if anyone wants to use - feel free

as i make more ill post them :)

Newbie of the month:
Awarded to the best new member with regards to posting activities, behavior and overall contributions.


Most Valuable Poster of the Month
Awarded to the best poster for the month, judged on originality of work and creativity shown in post (style etc) - People copying and posting stuff directly from other sites will automatically be disqualified for this award.


Member of the Month
This is awarded to the member who has contributed the most to the website in general, from contributions in posts to gallery and uploads. Good behavior, and helpfulness towards other members also comes into account when judging for this award.

TechnoDragon

I like the most valuable poster award...that is cute!  I may use that one!
Don't tell me to get into shape...I have a shape...It is round!


OzButcher

Quote from: JayBachatero on October 31, 2006, 08:13:21 AM
OzButcher it wouldn't be too hard to do this.  I would take a different approach to this though.  I would load it with the member data so that means that it will be accesible from everywhere in the forum not just the display page.

Cool thanks JayBachatero and TechnoDragon!!! :) Sorry it took me a while to reply, I've been busy with a media PC!

I just tried the new code and its great! When people post it now says in their little info... "Award: xx"

TechnoDragon, it doesn't come up as a link though.... would be cool if it did :)

JayBachatero

The change that he provided is to show it as a link.
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

Xarcell

Could you post a snippet of what the code would be to make a link only visiable to those that have permission to manage awards?

I tried and it appeared regardless:

// the Awards
    if ($context['manage_awards'] .= allowedTo('manage_awards'))

{
HTML & action
}


Thanx...

TechnoDragon

#174
Quote from: Xarcell on November 11, 2006, 10:44:03 PM
Could you post a snippet of what the code would be to make a link only visiable to those that have permission to manage awards?

I tried and it appeared regardless:

// the Awards
    if ($context['manage_awards'] .= allowedTo('manage_awards'))

{
HTML & action
}



Thanx...

If you click on the link and you are the owner or the admin you will get the manage awards link...if you are not the owner or admin you will only get the list of awards they have.
Don't tell me to get into shape...I have a shape...It is round!


JayBachatero

Use if (allowedTo('manage_awards'))
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

Xarcell

I got the link to work.

However, after trying to figure how to add an award to a member, I clicked on "awards" in a profile and get this error: Unable to load the 'awards' template.

Any suggestions?

JayBachatero

You'r theme might have a custom profile.template.php file.  The template changes for that file are missing.
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

Xarcell

#178
I was thinking that is what it was. So I checked the file first. It was missing the template code.

In the XML it instructs that the snippet be added before:

<li>', $txt['profile_error_' . $error], '.</li>';

echo '
</ul>
</div>';


However, doing so causes parse error, because the code is placed after the "echo '", but before the line as instucted. So I placed the snippet before the echo to avoid parse error. The page loads, however it still doesn't seem to be working I guess since it cannot load template.

Here's what the last part of the file looks like before modifcation:

// Small template for showing an error message upon a save problem in the profile.
function template_error_message()
{
global $context, $txt;

echo '
<div class="windowbg" style="margin: 1ex; padding: 1ex 2ex; border: 1px dashed red; color: red;">
<span style="text-decoration: underline;">', $txt['profile_errors_occurred'], ':</span>
<ul>';

// Cycle through each error and display an error message.
foreach ($context['post_errors'] as $error)
//if (isset($txt['profile_error_' . $error]))
echo '
<li>', $txt['profile_error_' . $error], '.</li>';

echo '
</ul>
</div>';
}



Any input you can give me? I added the snippet before all that and it works, but is it proper?

Xarcell

BTW, how do I add an award to a member? Not just the whole membergroup?

Advertisement: