Member Awards (2.0 Compatible!)

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

Previous topic - Next topic

sanax

#260
Hi... nice mod and just what I needed! One question though ( I saw someone mentioned it earlier) Will it be possible to 'bypass' the 'Upload' file function in the 'Add Award' section? After you've entered the Award Name and Game Name > Submit > It forced you to upload a file! If we can pass this function won't it be possible to use the same file (award image) for different users each week? - In other words it'll leave the option to you if you want to upload a file / image or not!

At this point i have to upload the same image every time which causes a duplication of the same image? Thanks in advance!

cloudee1

Great work here so far. I am so close to having everything working but not quite. Like so many others, I am trying to stick the awards in the signature. I don't want just the favorites, but all the trophies an individual has. I edited the display.php and I removed the limit 1 line, or at least the only one I saw but I can still only get one award to show up.

I changed the code a bit to add the award name and game name to the imgs title link, but I don't know why only one award shows up.

Code (Display.php) Select
/*******************************/
/* Load the members awards     */
/*******************************/
// removed line following WHERE, should show all trophies owned, not just favorite: fails
// AND pam.favorite = 1

$awards_request = db_query("
SELECT pab.gameName,pab.awardName,pab.filename, pam.ID_MEMBER
FROM {$db_prefix}awards_members AS pam
LEFT JOIN {$db_prefix}awards AS pab ON (pab.ID_AWARD = pam.ID_AWARD)
WHERE pam.ID_MEMBER IN (" . implode(', ', $posters) . ")
GROUP BY pam.ID_MEMBER", __FILE__, __LINE__);

            $context['awards'] = array();
while ($row = mysql_fetch_assoc($awards_request))
$context['awards'][$row['ID_MEMBER']] = '<img src="' . dirname($scripturl) . '/' . (empty($modSettings['pa_awardsDir']) ? '' : $modSettings['pa_awardsDir'] . '/') . $row['filename'] . '" alt="' . $row['filename'] . '"
title="'.$row['awardName'].' in '.$row['gameName'].'" />';

mysql_free_result($awards_request);



Just for posterity sake this is what I've added to my custom theme
Code (Display.template.php) Select
// Show the fav award
if (isset($context['awards'][$message['member']['id']]))
echo '
<hr width="100%" size="1" class="hrcolor" />
                <div align="center">', $context['awards'][$message['member']['id']], '</div>';

Anyway, any help would be greatly appreciated.
Visit my SCI programmers community [nofollow].
Where we make adventure games using the Sierra Creative Interpreter.
Just like Space Quest, King's Quest, and Leisure Suit Larry!

JayBachatero

Try removing the GROU BY line.
Follow me on Twitter

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

cloudee1

Quote from: JayBachatero on January 04, 2007, 12:29:27 AM
Try removing the GROU BY line.
I removed the group by part, I am still only seeing one award however. This time instead of displaying the first trophy they got it is the last trophy instead. So there was at least change :D

Code (Display.php) Select
...
$awards_request = db_query("
SELECT pab.gameName,pab.awardName,pab.filename, pam.ID_MEMBER
FROM {$db_prefix}awards_members AS pam
LEFT JOIN {$db_prefix}awards AS pab ON (pab.ID_AWARD = pam.ID_AWARD)
WHERE pam.ID_MEMBER IN (" . implode(', ', $posters) . ")
", __FILE__, __LINE__);
...
Visit my SCI programmers community [nofollow].
Where we make adventure games using the Sierra Creative Interpreter.
Just like Space Quest, King's Quest, and Leisure Suit Larry!

shadmego

Quote from: cloudee1 on January 04, 2007, 12:13:30 AM

...

I edited the display.php and I removed the limit 1 line, or at least the only one I saw but I can still only get one award to show up.

...


Please forgive my ignorance. I've been looking for that LIMIT 1 line for about 2 weeks now and can't seem to find it in relation to the awards code. From what you said here, I assume it's in the Display.php file, but mine at least has a bunch of LIMIT 1 lines and none of them have to do with the awards mod.

If it isn't too much trouble, could you point me in the right direction?

Thanks!

~regards,
Shadmego

cloudee1

It's in the award code that you added to display.php, my first code post shows the award code without the limit line  "AND pam.favorite = 1" It came right ofter the WHERE statement that is still present. Unfortunately it doesn't matter, as it isn't sufficient to get multiple awards to display.
Visit my SCI programmers community [nofollow].
Where we make adventure games using the Sierra Creative Interpreter.
Just like Space Quest, King's Quest, and Leisure Suit Larry!

shadmego

Ok. That's why it confused me. The code I put in my Display.php file never had the LIMIT 1 line in there.

I've taken out the GROUP BY and the pam.favorite line. I'm very interested in the successful modification of this to show multiple awards in the boards, though I also like the modification you did on your board to put a link to the award section for each member.

If I can't get this to work, would you mind showing me what you did to get your version of this?


Thanks for the prompt response!

~regards,
Shadmego

cloudee1

#267
In you custom themes display.template.php you just need to find


// Since we know this person isn't a guest, you *can* message them.
if ($context['can_send_pm'])
echo '
                    <a href="', $scripturl, '?action=pm;sa=send;u=', $message['member']['id'], '"
                    title="', $message['member']['online']['label'], '">', $settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/im_' . ($message['member']['online']['is_online'] ? 'on' : 'off') . '.gif"
                    alt="' . $message['member']['online']['label'] . '" border="0" />' : $message['member']['online']['label'], '</a>';


And right below that add in the part that displays the award shortcut.


// Display the link to the users trophies

echo '
        <br />
        <a href="', $scripturl, '?action=profile;sa=awards;u=', $message['member']['id'], '">
        ', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/award.gif"
                alt="' . $txt['awards'] . '"
                title="' . $txt['awards'] . '"
                border="0" />' : $txt['awards']), '</a>';


Now if you are in the right place, the next bit of code should look like
}
}
// Otherwise, show the guest's email.
elseif (empty($message['member']['hide_email']))
echo '
<br />


That's it, I think it's just a copy and paste of where it changed the default themes file. I just found it and added it to my custom themes file. Once we get multiple awards displaying, I will probably remove that bit, since afterall why go to another page when the awards are all right there, but for now...

Just for reference, I don't mean to sound like I'm repeating myself.
Here is a link [nofollow] to the only person with any trophies, thewife, currently has two but as you can see from the signature area, only one is displayed, clicking on the awards image takes you to the badge page where two are owned.
Visit my SCI programmers community [nofollow].
Where we make adventure games using the Sierra Creative Interpreter.
Just like Space Quest, King's Quest, and Leisure Suit Larry!

JayBachatero

Ill write something for ya when I get on my pc.
Follow me on Twitter

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

Chris™

Quote from: JayBachatero on January 05, 2007, 12:40:40 AM
Ill write something for ya when I get on my pc.
Could you write something so where it shows it in posts?

JayBachatero

Follow me on Twitter

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

sanax

Hi... nice mod and just what I needed! One question though ( I saw someone mentioned it earlier) Will it be possible to 'bypass' the 'Upload' file function in the 'Add Award' section? After you've entered the Award Name and Game Name > Submit > It forced you to upload a file! If we can pass this function won't it be possible to use the same file (award image) for different users each week? - In other words it'll leave the option to you if you want to upload a file / image or not!

At this point i have to upload the same image every time which causes a duplication of the same image? Thanks in advance!

littleone

Quote from: sanax on January 05, 2007, 02:06:03 AM
Hi... nice mod and just what I needed! One question though ( I saw someone mentioned it earlier) Will it be possible to 'bypass' the 'Upload' file function in the 'Add Award' section? After you've entered the Award Name and Game Name > Submit > It forced you to upload a file! If we can pass this function won't it be possible to use the same file (award image) for different users each week? - In other words it'll leave the option to you if you want to upload a file / image or not!

At this point i have to upload the same image every time which causes a duplication of the same image? Thanks in advance!

You could upload a dummy image and then just delete the dummy image for your directory and go to the database and replace the reference to the dummy image with the image u do wanna use. That should work i think.

sanax

Thanks littleone... that's a mouthful!! lol

I'll try it and report back!

cloudee1

Quote from: JayBachatero on January 05, 2007, 12:40:40 AM
Ill write something for ya when I get on my pc.
I now admit defeat. I spent twelve hours yesterday staring at and changing those two small groups of code. the closest I came was when I got the word array to show up instead of the trophies, At the end of the day, all I actually accomplished was turning the single trophy into a link to the badge page. I'm glad I posted all of that code a page back, it's where I went to get everything working right again.

I was wondering how the idea factory was running over there Jay, mine shut down.
Visit my SCI programmers community [nofollow].
Where we make adventure games using the Sierra Creative Interpreter.
Just like Space Quest, King's Quest, and Leisure Suit Larry!

JayBachatero

#275
Ok in Display.php find

mysql_free_result($request);
$posters = array_unique($posters);


Add after

// Load the members awards
$awards_request = db_query("
SELECT pab.filename, pam.ID_MEMBER
FROM {$db_prefix}awards_members AS pam
LEFT JOIN {$db_prefix}awards AS pab ON (pab.ID_AWARD = pam.ID_AWARD)
WHERE pam.ID_MEMBER IN (" . implode(', ', $posters) . ")", __FILE__, __LINE__);

$context['awards'] = array();
$context['awards'][$row['ID_MEMBER']] = array();
while ($row = mysql_fetch_assoc($awards_request))
$context['awards'][$row['ID_MEMBER']][] = '<img src="' . dirname($scripturl) . '/' . (empty($modSettings['pa_awardsDir']) ? '' : $modSettings['pa_awardsDir'] . '/') . $row['filename'] . '" alt="' . $row['filename'] . '" />';

mysql_free_result($awards_request);



In Display.template.php find

// Show avatars, images, etc.?
if (!empty($settings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image']))
echo '
<div style="overflow: auto; width: 100%;">', $message['member']['avatar']['image'], '</div><br />';



Add after

// Show the fav award
if (isset($context['awards'][$message['member']['id']]))
{
echo '
<div style="overflow: auto; width: 100%;">';
foreach ($context['awards'][$message['member']['id']] as $badge)
echo '
', $badge;
echo '
</div><br />';
}


I didn't test this out so not sure if it's going to fully work.  It should work though.
Follow me on Twitter

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

cloudee1

 8)

I stuck the code in, and I got scared for a moment when only one award showed up. Then I removed the GROUP BY pam.ID [nofollow]_MEMBER from the sql statement and hit refresh and there they were all lined up. Thanks a bunch Jay.
Visit my SCI programmers community [nofollow].
Where we make adventure games using the Sierra Creative Interpreter.
Just like Space Quest, King's Quest, and Leisure Suit Larry!

Lamarck

I love this MOD,very good work.Will you keep update it in the future (for 1.1.1 and next versions)?.

JayBachatero

Yes I will continue to support this mod for a long time.  This is one of the best mods that I've written so far ;).
Follow me on Twitter

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

sanax

I got it to work so that the awards show up in the signature section with a link to the awards page but I still have a slight problem and that is I can't use the same image over and over.

If we can get that to work I think it'll be great for this mod!

Advertisement: