Member Awards (2.0 Compatible!)

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

Previous topic - Next topic

Mari-chi

Love this mod. :) Using it on my forum for future awards. :D

<333

Mari-chi

#2181
AnonymousHelper:

In Subs.php:
Code (Find:) Select
if (allowedTo('manage_bans'))
if (allowedTo('admin_forum'))
$context['admin_areas']['members']['areas']['paid_subscriptions'] = '<a href="' . $scripturl . '?action=paidsubscribe">' . $txt['paid_subscriptions'] . '</a>';


Code (Add After:) Select


if (allowedTo('manage_awards'))
$context['admin_areas']['layout']['areas']['manage_awards'] = '<a href="' . $scripturl . '?action=awards">' . $txt['awards'] . '</a>';


Code (Find:) Select
'manage_bans', 'manage_permissions', 'admin_forum'

Code (Add After:) Select
, 'manage_awards'

Code (Find:) Select
'manage_attachments', 'manage_smileys'

Code (Add After:) Select
, 'manage_awards'




In Profile.php:

Code (Find:) Select
'showPermissions' => array(array('manage_permissions'), array('manage_permissions')),

Code (Add After:) Select

'showAwards' => array(array('profile_view_any', 'profile_view_own'), array('profile_view_any')),
'awardsMembers' => array(array('profile_view_any', 'profile_view_own'), array('profile_view_any')),


Code (Find:) Select
$context['profile_areas']['info']['areas']['showPosts'] = '<a href="' . $scripturl . '?action=profile;u=' . $memID . ';sa=showPosts">' . $txt['showPosts'] . '</a>';

Code (Add After:) Select

$context['profile_areas']['info']['areas']['showAwards'] = '<a href="' . $scripturl . '?action=profile;u=' . $memID . ';sa=showAwards">' . $txt['awards'] . '</a>';


Code (Find (at the end of the file):) Select
?>

Code (Add Before:) Select

function showAwards($memID){
global $context, $db_prefix, $txt, $scripturl, $modSettings, $settings;

// Do they want to make a favorite?
if (isset($_GET['makeFavorite']) && allowedTo(array('profile_extra_any', 'profile_extra_own'))){
checkSession('get');

$award = (int) $_GET['id'];
$favorite = ($_GET['makeFavorite'] > 0) ? 1 : 0;

// Do they only allow one fav?
if (empty($modSettings['awards_favorite']))
db_query("
UPDATE {$db_prefix}awards_members
SET favorite = 0
WHERE ID_MEMBER = " . $memID, __FILE__, __LINE__);

// Now make this one a fav.
db_query("
UPDATE {$db_prefix}awards_members
SET favorite = {$favorite}
WHERE id_award = {$award}
AND ID_MEMBER = {$memID}
LIMIT 1", __FILE__, __LINE__);

// To make changes appear redirect back to that page
redirectexit('action=profile;sa=showAwards;u=' . $memID);
}

// Load language
loadLanguage('ManageAwards');

// 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 ($context['count_awards']) = mysql_fetch_row($request);
mysql_free_result($request);

// Calculate the number of results to pull up.
$max_awards = 25;

// Construct the page index
$context['page_index'] = constructPageIndex($scripturl . '?action=profile;sa=showAwards;u=' . $memID, $_REQUEST['start'], $context['count_awards'], $max_awards);
$context['start'] = isset($_REQUEST['start']) ? (int) $_REQUEST['start'] : 0;

// Load the awards
$request = db_query("
SELECT
aw.id_award, aw.award_name, aw.description, aw.filename, aw.minifile,
am.ID_MEMBER, am.date_received, am.favorite,
c.category_name, c.id_category
FROM {$db_prefix}awards AS aw
LEFT JOIN {$db_prefix}awards_members AS am ON (am.id_award = aw.id_award)
LEFT JOIN {$db_prefix}awards_categories AS c ON (c.id_category = aw.id_category)
WHERE am.ID_MEMBER = {$memID}
ORDER BY am.favorite DESC, c.category_name DESC, aw.award_name DESC
LIMIT {$context['start']}, {$max_awards}", __FILE__, __LINE__);

$context['categories'] = array();

// Fetch the award info just once
while ($row = mysql_fetch_assoc($request)){
if(!isset($context['categories'][$row['id_category']]['name']))
$context['categories'][$row['id_category']] = array(
'name' => $row['category_name'],
'awards' => array(),
);

$context['categories'][$row['id_category']]['awards'][$row['id_award']] = array(
'id' => $row['id_award'],
'award_name' => $row['award_name'],
'description' => $row['description'],
'more' => $scripturl . '?action=profile;sa=awardsMembers;id=' . $row['id_award'],
'favorite' => array(
'fav' => $row['favorite'],
'href' => $scripturl . '?action=profile;sa=showAwards;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['awards_favorite'] . '" title="' . $txt['awards_favorite'] . '" />',
),
'filename' => $row['filename'],
'time' => list ($year, $month, $day) = sscanf($row['date_received'], '%d-%d-%d'),
'img' => dirname($scripturl) . '/' . $modSettings['awards_dir'] . '/' . $row['filename'],
'mini' => dirname($scripturl) . '/' . $modSettings['awards_dir'] . '/' . $row['minifile'],
);
}
mysql_free_result($request);

$context['page_title'] = $txt[79] . ' - ' . $txt['awards_title'];
$context['sub_template'] = 'awards';
$context['allowed_fav'] = ($context['user']['is_owner'] && allowedTo('profile_view_own')) || allowedTo('profile_extra_any');
}

function awardsMembers(){
global $context, $db_prefix, $modSettings, $scripturl, $txt;

// Load language
loadLanguage('ManageAwards');

$id = (int) $_REQUEST['id'];

// An award must be selected.
if (empty($id) || $id <= 0)
fatal_lang_error('awards_error_no_award');

// Load the award info separately
$request = db_query("
SELECT *
FROM {$db_prefix}awards
WHERE id_award = {$id}", __FILE__, __LINE__);

// Check if ths award actually exists
if (mysql_num_rows($request) < 1)
fatal_lang_error('awards_error_no_award');

$context['award'] = array();

// Fetch the award info just once
$row = mysql_fetch_assoc($request);
$context['award'] = array(
'id' => $row['id_award'],
'name' => $row['award_name'],
'description' => $row['description'],
'filename' => $row['filename'],
'img' => dirname($scripturl) . '/' . $modSettings['awards_dir'] . '/' . $row['filename'],
'mini' => dirname($scripturl) . '/' . $modSettings['awards_dir'] . '/' . $row['minifile'],
'members' => array(),
);
mysql_free_result($request);

// Now load the info.
$request = db_query("
SELECT
m.realName, a.id_member, a.date_received
FROM {$db_prefix}awards_members AS a
LEFT JOIN {$db_prefix}members AS m ON (m.ID_MEMBER = a.id_member)
WHERE a.id_award = {$id}
ORDER BY m.realName DESC", __FILE__, __LINE__);

while ($row = mysql_fetch_assoc($request))
$context['award']['members'][] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['realName'] . '</a>';

mysql_free_result($request);

// Set the context values
$context['page_title'] = $txt['awards'] . ' - ' . $context['award']['name'];
$context['sub_template'] = 'awards_members';
$context['columns'] = 3;

}

An0nymousHelper

#2182
Thanks a lot for that help, unfortunately when I go to a post and then I see under the users name and stuff a little box called awards when i click it links me to http://mysite.com/forums/profile/?sa=showAwards;u=1  and i get this error...

Fatal error: Cannot redeclare showawards() (previously declared in /home/content/a/n/0/an0nymoushelp/html/forums/Sources/Profile.php:3573) in /home/content/a/n/0/an0nymoushelp/html/forums/Sources/Profile.php on line 3814

Any ideas on how i could fix this? I will upload my modified Profile.php and maybe you could take a look at it?

Thanks a lot in advance if anyone could help me it is much appreciated!!!


EDIT: Never mind i managed to fix it on my own, Thanks a tun though!

Stigmartyr

Quote from: Stigmartyr on February 11, 2011, 04:23:49 PM
Hello!  Just installed this mod on a new SMF RC4 forum.  There were a couple issues with installing which were resolved by manually making the code edits, however some issues remain.  In setting up the first award I got all the way to the "assign" step only to be stopped.

When I type in the member name field, nothing ever comes up to select the name.  If I type it out and hit "Save" it tells me: You must select a member and/or award in order to continue!

I've attached a screen of what I see.  I am using a custom theme and made sure that I copied the scripts files to the theme's /scripts folder.

Can you help?  I am thinking it's a simple thing I'm missing here.

Thanks!!!

Hai :D *waves*

Mari-chi

What errors did you get when first installing the mod?

Stigmartyr

Quote from: Mari-chi on February 13, 2011, 06:28:58 PM
What errors did you get when first installing the mod?

To be perfectly honest I cannot recall which .php files errored.  I did find where the parser couldn't complete the edits and finished them carefully.

If it would help I can uninstall and reinstall again.

Mari-chi

Before you do that, one question: In your screenshot, it looks like you just left the username in the textbox. Did you get a dropdown below the textbox? It's the auto-complete form that pops up when you enter a member's name. You need to select that so it appears like this:



If you have done that and it still gives you an error, then you might want to try uninstalling and reinstalling again.

Stigmartyr

Quote from: Mari-chi on February 13, 2011, 08:44:38 PM
Before you do that, one question: In your screenshot, it looks like you just left the username in the textbox. Did you get a dropdown below the textbox? It's the auto-complete form that pops up when you enter a member's name. You need to select that so it appears like this:



If you have done that and it still gives you an error, then you might want to try uninstalling and reinstalling again.

Ok I will try it again.  I actually did it twice that night trying to sort it out. 

I do NOT get the autocomplete function to work.  Infact it doesn't work anywhere on the site anymore.  Not even in PM's

Mari-chi

Hm, then it's probably not the Member Awards mod at all. Did you recently install any other mods before the Member Awards? Are there any errors in your error log?

Stigmartyr

Quote from: Mari-chi on February 13, 2011, 09:18:01 PM
Hm, then it's probably not the Member Awards mod at all. Did you recently install any other mods before the Member Awards? Are there any errors in your error log?

Yes - I installed about 20 mods on http://blacksungameschicago.com/

It's possible that another mod did it, but I'm kinda anal with the package manager.  I will check each file to make sure it actually did what it said it was gonna do.  Prior experience with this :P

I could probably give you an account to poke around with it that helps.  I turned error logging off because there always seem to be errors in it that make no ryhme or reason.

Mari-chi

No, I'm not experienced enough to be given an account to poke around with. o.o Who knows what damage I will do. XD

If it's a problem with the forum itself (or so it seems at this point), then you should make a new topic in 2.x support. :D

reinner

Can anyone help me with my problem please? :(
My post on page before this. I appreciate any help.

Good day to all

Mari-chi

For the missing WYSIWYG editor, try:

Admin > Configuration > Themes & Layout > Your Theme > Change current options for all members using this theme

Look for "Show WYSIWYG editor on post page by default.", choose "Change" from the dropdown menu and make sure the checkbox beside it is checked. If it still doesn't bring up the WYSIWYG editor, then you're better off asking someone in the Support board (whichever version of SMF you have), and not here. This thread is a support thread for the Member Awards mod. :)

As for the Member Awards error... What version of SMF are you using? Have you altered ManageAwards.php in any way? Can you reproduce the problem? You should be more specific for someone to be able to help you. :D

Stigmartyr

Quote from: Mari-chi on February 14, 2011, 12:40:55 PM

As for the Member Awards error... What version of SMF are you using? Have you altered ManageAwards.php in any way? Can you reproduce the problem? You should be more specific for someone to be able to help you. :D

Version: SMF2 RC4
Site: www.blacksungameschicago.com

I have not altered the mod or its files in any way.  I had posted a screenshot, and somehow think it's related to the name not autopopulating however I'm not sure what that feature is called so I can search or report on it.

Mari-chi

Sorry Stig, that post was meant for reinner. But I think it might have something to do with that auto complete feature. :/ I can't say for sure since I don't have a lot of experience with SMF, but hopefully someone else will be able to solve the problem for you. :)

reinner

Quote from: Mari-chi on February 14, 2011, 12:40:55 PM
For the missing WYSIWYG editor, try:

Admin > Configuration > Themes & Layout > Your Theme > Change current options for all members using this theme

Look for "Show WYSIWYG editor on post page by default.", choose "Change" from the dropdown menu and make sure the checkbox beside it is checked. If it still doesn't bring up the WYSIWYG editor, then you're better off asking someone in the Support board (whichever version of SMF you have), and not here. This thread is a support thread for the Member Awards mod. :)

As for the Member Awards error... What version of SMF are you using? Have you altered ManageAwards.php in any way? Can you reproduce the problem? You should be more specific for someone to be able to help you. :D

Sorry I really didn't include the details in my last post since I posted them twice in here.. :)
anyways, here is the details and the errors that I got.

I still need help. hfswesker was helping me but I think he's busy ATM
If somebody could help me please.

Problem:
1. Can't assign award.
2. No smileys, bbcode, text, color, size option at my reply both message and post replies.

Installed mods:
1. Member Awards    2.2.3
2. Aeva ~ Auto-Embed Video & Audio    7.1

Error logs:
Quote
2: Invalid argument supplied for foreach()
Apply Filter: Only show the errors from this file
File: /home/ourbabyb/public_html/Sources/ManageAwards.php
Line: 451

Quote
8: Undefined index: recipient_to
Apply Filter: Only show the errors from this file
File: /home/ourbabyb/public_html/Sources/ManageAwards.php
Line: 451

Mari-chi

Yep, I already looked back and read that post. Could you do what I suggested? Also, please answer the questions from my post. :D I wont' say I'm a whiz at this, but I'll try and help. XD

reinner

Quote from: Mari-chi on February 14, 2011, 03:51:48 PM
Yep, I already looked back and read that post. Could you do what I suggested? Also, please answer the questions from my post. :D I wont' say I'm a whiz at this, but I'll try and help. XD

hi mari-chi,

yes I did what you've suggested
QuoteAdmin > Configuration > Themes & Layout > Your Theme > Change current options for all members using this theme

also, I am not sure if hfseeker modify something on the ManageAwards.php

I am current version is 2.0 RC 5
current theme fuzzy theme

let me know if you need more details or if you want to see my forum. ;)

hcfwesker

#2198
Quote from: reinner on February 15, 2011, 05:02:57 AMalso, I am not sure if hfseeker modify something on the ManageAwards.php

the only changes I made were in Admin.php ... was fixed the manual install errors you made when adding the Awards menus to the Admin panel.  ;)

Sorry I haven't been able to help; as I explained my internet went into a coma, and couldn't mess with cPanels in fear of slow uploading that would cause only half the file to upload, and leaving your forum with a template parse error.  Just got it fixed today, so once I get caught up with my forum stuff I've had to put off, I'll try and take another look.

You will notice now when you goto admin>awards>Main  you have more options.  but it's still not bringing up the drop down box when I type in a members name.  I'm 'almost' tempted to just copy my Awards php folders and over write yours, since mine has the fixes, but just can't remember what I did long ago, lol.


reinner

hey hcfwesker,

I am now thinking to re-install a fresh SMF copy to my forum may be it will solve all my problems.. I am not just sure if it will though...
btw, I am thinking that maybe the problem is from the myphpadmin...

Cheers

Advertisement: