Member Awards (2.0 Compatible!)

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

Previous topic - Next topic

tk2012

The same thing is happening for me.  I uploaded an award.  Then, I tried to assign the award to a member.  When I did, I got an error stating I needed to select an award and a member even though I already had.  I back stepped and had the same thing "member_name" was listed instead of the actual member's name. 

attachments below

Fustrate

I'll have to look at the coding for this mod and Beta 4, since it's technically only good up until Beta 3.1 Public.
Steven Hoffman
Former Team Member, 2009-2012

tk2012

If you want to take a look at anything, let me know or need anything from me.. You've helped me so much, I'll give you my TESTaccount info if you need to take a look

khamseen

#943
Well I have actually made some progress, hope you don't mind but I've been "playing" with the code to see if I can figure out why it was doing what it was doing and considering my only actual experience so far is from adding things I'm not that well versed, however...

themes/default/ManageAwards.template.php

On line 571 you have

<a href="', $scripturl, '?action=profile;u={MEMBER_ID}" id="recipient_link_to_{MEMBER_ID}" class="extern" onclick="window.open(this.href, \'_blank\'); return false;">{MEMBER_NAME}</a>


Which I changed to by replacing the {} around member_id and member_name to :: ::

<a href="', $scripturl, '?action=profile;u=::MEMBER_ID::" id="recipient_link_to_::MEMBER_ID::" class="extern" onclick="window.open(this.href, \'_blank\'); return false;">::MEMBER_NAME::</a>


By doing that, when I input a name in the box and press add, it now successfully adds the correct name to the list, which also now links to that persons profile.

However, when I click assign, it acts like it has worked and displays the award with a list of "assigned members" which is just an empty line with a check box, and if I visit the profile of the person I assigned it to, it says they don't have an award assigned.

Don't know if that helps and sorry if it doesn't and it's just pointless, just thought I should let you know what I've found.


*EDIT*
Also, I just thought, the delete function wasn't working either for if you had a member listed to give the award to but wanted to remove them from the list. I have solved that by changing {DELETE_MEMBER_URL} to ::DELETE_MEMBER_URL:: on line 573

**EDIT2**

SUCCESS!
I had not realised that on line 569 there was another {MEMBER_ID} which needed changed to ::MEMBER_ID:: now that I have done that, the system is working fully and seems to be stable. I have attached my themes/default/ManageAwards.template.php for you to have a look at.
"In hope we find despair and in despair we find truth." - Myself

Fustrate

Aha, that must be new in Beta 4... nice catch!
Steven Hoffman
Former Team Member, 2009-2012

khamseen

Thank you, just glad that I could give you that info to save you searching through, especially after all the help you've given me.

Maybe there is hope for me yet :P
"In hope we find despair and in despair we find truth." - Myself

tk2012

I'm going to try that tonight after I get done some other edits.  GREAT NEWS.  Thanks to both!

welshdog

Quote from: Mother Goose on September 17, 2008, 06:31:42 PMNot a stupid question at all! I make them just for this mod!

Many thanks. Please accept my apologies for not saying so earlier - both the response *and* the awards are very much appreciated!!

tk2012

Working here now.  Haven't noticed any errors, yet!

buzinator

Hi,

Thanks Yoda - this mod, and your active support in this thread, are Brilliant!

I know there are users out there converting from phpBB to SMF who are looking for an equivalent to the phpBB Medals Mod. I've been in this boat and am finding that this system seems to be the one to go for...the vast majority of the features are there, or instructions to make equivalents are in this thread.

The only things remaining on my mind now are ...

1. Would be useful (to me anyway) to be able to manually specify the display order of awards. I imagine this will require DB changes, but damn it'd be nice for an admin to have that kind of control, get things nice and neat.

2. A new membergroup permission, "Assign Awards" or something like that. The current "Manage Awards" gives rather more power than i really want a junior admin user to have. I just need them to ease my burden by assigning/unassigning awards to members - i don't want them messing with creating new ones or changing the awards dir on me etc.

Sorry if either point has been discussed before, I tried searching the thread and couldn't find anything that quite matched.


Fustrate

The permission one sounds like a good idea, I'll look into that. Ordering the awards is another issue though... but one that I might be able to solve quite easily.

Thanks :D
Steven Hoffman
Former Team Member, 2009-2012

buzinator

Quote from: YodaOfSpookness on October 22, 2008, 12:28:36 PM
The permission one sounds like a good idea, I'll look into that. Ordering the awards is another issue though... but one that I might be able to solve quite easily.

Thanks :D

Yeah, I figured neither of them would be done in the blink of an eye, but hey, the squeaky wheel gets the grease right? ;)

Thanks again.

TechPrince

8: Undefined variable: badge
File: /Themes/default/ManageAwards.template.php

Fustrate

Steven Hoffman
Former Team Member, 2009-2012

TechPrince


-Scarface-

You post them to me the File "ManageAwards.template.php"? ???

Thanks Thousand
Partecipate su Questo Fantastico Forum!!

Lordmiller

#956
Got this award mod working, and showing multiple awards on the user box. . .thanks for the help, and kudos on creating a great Mod.

Deadfire

Quote from: YodaOfDarkness on June 29, 2007, 11:25:59 PM
EDIT: I just figured it out :) Here's how to display (#) awards under a person's avatar. It's a modification of code found in... whichever file has the awards() function :D

All in Display.template.php (it all works the same anyways...)
find:
function template_main()
and add before (this is right at the top):
function show_awards_in_message($memID)
{
global $context, $db_prefix, $txt, $scripturl, $modSettings, $settings;

// How many awards to pull up?
$maxAwards = 4;

// Count the number of items in the database for create index
$request = db_query("
SELECT COUNT(*)
FROM {$db_prefix}awards_members
WHERE ID_MEMBER = $memID", __FILE__, __LINE__);
list ($countAM) = mysql_fetch_row($request);
mysql_free_result($request);

// The count of awards per member
$context['countAwards'] = $countAM;

// Load the awards
$awardsSelect = db_query("
SELECT
aw.ID_AWARD, aw.awardName, aw.gameName, aw.filename, aw.width, aw.height,
am.ID_MEMBER, am.dateReceived, am.favorite
FROM {$db_prefix}awards AS aw
LEFT JOIN {$db_prefix}awards_members AS am ON (am.ID_AWARD = aw.ID_AWARD)
WHERE am.ID_MEMBER = $memID
ORDER BY am.favorite DESC, am.dateReceived DESC
LIMIT 0, $maxAwards", __FILE__, __LINE__);

// Set the $context['awards'] var
$context['awards'] = array();

// Fetch the award info just once
while ($row = mysql_fetch_assoc($awardsSelect))
{
$context['awards'][$row['ID_AWARD']] = array(
'id' => $row['ID_AWARD'],
'awardName' => $row['awardName'],
'gameName' => $row['gameName'],
'more' => $scripturl . '?action=profile;sa=awardsMembers;id=' . $row['ID_AWARD'],
'favorite' => array(
'fav' => $row['favorite'],
'href' => $scripturl . '?action=profile;sa=awards;id=' . $row['ID_AWARD'] . ';makeFavorite=' . ($row['favorite'] == 1 ? '0' : '1') . (isset($_REQUEST['u']) ? ';u=' . $_REQUEST['u'] : ''),
'img' => '<img src="' . $settings['images_url'] . '/' . ($row['favorite'] == 1 ? 'collapse' : 'expand') . '.gif" alt="' . $txt['pa_favorite'] . '" />',
),
'filename' => $row['filename'],
'width' => $row['width'],
'height' => $row['height'],
'time' => list ($year, $month, $day) = sscanf($row['dateReceived'], '%d-%d-%d'),
'img' => dirname($scripturl) . '/' . $modSettings['pa_awardsDir'] . '/' . $row['filename'],
);
}
mysql_free_result($awardsSelect);

if (!empty($context['awards'])){
foreach ($context['awards'] as $award){
echo '<a href="', $award['more'], '"><img src="', $award['img'], '" width="', $award['width'], '" height="', $award['height'], '" alt="', $award['awardName'], '" title="', $award['awardName'], '" /></a> ';
}
echo '<br />
<br />';
}
}


then go down a bit farther, find:
// Show their personal text?
if (!empty($settings['show_blurb']) && $message['member']['blurb'] != '')
echo '
', $message['member']['blurb'], '<br />
<br />';

add after:
show_awards_in_message($message['member']['id']);

You can actually put the second part wherever you like, but I personally like how the personal text seperates the avatar from the awards. It's also possible to make them stand out using a fieldset and a legend, which is what I did with mine.

This is why I love SMF... I get to learn while I tinker with things :D

EDIT: Fixed the error I was having with second/third/etc. pages - it was using $context['start'] when it should have used 0, and I condensed the code :)

Using this is it possible to display them in order that you put the awards into the system? and/or create a ordering system where I get to pick the order these medals appear

buzinator

Quote from: Deadfire
Using this is it possible to display them in order that you put the awards into the system? and/or create a ordering system where I get to pick the order these medals appear

I use that code to show awards in users' sigs, they seem to display in the order they were received by that user, newer ones first, older ones last.

I guess that could be manipulated  to get things to display the way you want, but tweaking things at later dates sounds like a nightmare.

Fedaykin

What about support all options in SMF 1.1.6?

Advertisement: