[BETA] Medal System MOD [ Latest: 0.4.6 ]

A place for MOD Authors to post and receive feedback on MODs still in development. No MODs within this forum should be used within a live environment! No new topics are allowed in this forum.
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

IMPORTANT: MOD Development Forum rules

On February 1, 2009 this forum will be set to read only as part of retiring of phpBB2.
odie3
Registered User
Posts: 145
Joined: Thu Mar 04, 2004 6:48 pm
Location: Kyle USA
Contact:

Post by odie3 »

hmm, PCP support... you get that going songdove let me know.
Odie3
{GD} Forum Admin
http://ghostdogs.net/bb/

MrDSL
Registered User
Posts: 283
Joined: Thu Jul 15, 2004 1:52 am
Contact:

Post by MrDSL »

No guarantees but I hope to have PCP integration done tonight..

odie3
Registered User
Posts: 145
Joined: Thu Mar 04, 2004 6:48 pm
Location: Kyle USA
Contact:

Post by odie3 »

Well, a bit of good news!
Odie3
{GD} Forum Admin
http://ghostdogs.net/bb/

MrDSL
Registered User
Posts: 283
Joined: Thu Jul 15, 2004 1:52 am
Contact:

Post by MrDSL »

Works for me.. It was easier to create the same install file and remove stuff that didn't need to be editted and add stuff that did so its less confusing. Hopefully ycl6 will include this with the main download :)

Code: Select all

######################################################## 
## Mod Title: Medal System
## MOD Author: ycl6 < ycl6@users.sourceforge.net > (Y.C. LIN) http://macphpbbmod.sourceforge.net/
## PCP Integration: MrDSL < naug@thehottub.net > http://www.thehottub.net 
## MOD Description: This mod is a complete Medal system for your phpBB forum. It consists:
## 			A ACP medal management panel
##			A Medal Listing page to display all medal information
##			A Medal moderator management panel for adding/removing medal from users
##			An e-mail is sent to user receiving the medal
##			Display amount of medal a user holds on viewtopic and profile page
## Mod Version: 2.2.3
## 
## Installation Level:	Intermediate
## Installation Time:	10 Minutes
##
## Files To Edit:	13
##	viewonline.php
##	viewtopic.php
##	includes/constants.php
##	includes/functions.php
##	includes/page_header.php
##	language/lang_english/lang_main.php
##	language/lang_english/lang_admin.php
##	profilcp/def/def_userfields.php
##	profilcp/def/def_usermaps.php
##      profilcp/def/def_userfuncs_custom.php
##	templates/subSilver/viewtopic_body.tpl
##	templates/subSilver/overall_header.tpl
##	templates/subSilver/subSilver.cfg
##
## Included Files: 	17 (+ 24 images)
##	root/medals.php
##	root/medalcp.php
##	root/medalcp_edit.php
##	root/admin/admin_medal.php
##	root/admin/admin_medal_cfg.php
##	root/language/lang_english/email/medal_added.tpl
##	root/templates/toggle.js
##	root/templates/subSilver/medals_body.tpl
##	root/templates/subSilver/medalcp_body.tpl
##	root/templates/subSilver/medalcp_edit_body.tpl
##	root/templates/subSilver/images/icon_mini_medal.gif
##	root/templates/subSilver/admin/medal_config_body.tpl
##	root/templates/subSilver/admin/medal_delete_body.tpl
##	root/templates/subSilver/admin/medals_edit_body.tpl
##	root/templates/subSilver/admin/medals_editcat_body.tpl
##	root/templates/subSilver/admin/medals_list_body.tpl
##	root/templates/subSilver/admin/medals_moderator_body.tpl
##	root/medals/*.gif
##
## License: http://opensource.org/licenses/gpl-license.php GNU Public License v2 
################################################################# 
## For security purposes, please check: http://www.phpbb.com/mods/
## for the latest version of this MOD. Although MODs are checked
## before being allowed in the MODs Database there is no guarantee
## that there are no security problems within the MOD. No support
## will be given for MODs not found within the MODs Database which
## can be found at http://www.phpbb.com/mods/
############################################################## 
## Author Notes:
##	
##	Please READ the "Usage Guide" found in EXTRA folder for FAQ/Tips
##
##	Toggle button only work in IE, to remove it, please see add-on/remove_toogle.txt
##
##	Special thanks to Gremlinn and other supporters of this MOD
## 
############################################################## 
## MOD History: 
##
##   2003-10-21 - Version 1.0.0
##      - Initial Release
##
##   2003-11-02 - Version 1.0.1
##      - Fix image display path in medals.php
##	- 2 small changes to medals_body.tpl
##
##   2003-11-02 - Version 1.0.2
##      - Fix sql statement in admin_medal.php
##	- A change in the lang_admin.php
##
##   2003-11-03 - Version 1.1.0
##      - Allow admin to choose showing medal images in viewtopic or not
##	- All admin to configure number of rows & column in the viewtopic display
##	- Change medal display in profile, if no medal, medal table does not appear
##
##   2003-11-07 - Version 1.1.1
##	- Upgraded to 2.0.6 competible
##	- Only 2 minor changes in medalcp.php, and 1 change in the installation guide
##		for usercp_viewprofile.php
## 
##   2004-03-24 - Version 2.0.0
##	- Major re-write of this MOD, 1.1.1 is NOT upgradable to 2.0.0
##		because of the change in database design
##	- What's New:
##	  * In ACP, Medal Configuration & Medal Management
##	  * In ACP Medal Management, Add, Delete & Edit Medal, Add & Delete Medal Moderator(s)
##	  * Medals.php for overall Medal & User Listing
##	  * Moderator(s) can enter Medal Control Panel to Award & Delete User
##	  * Moderator can edit Award Reason for each award occasion for each user
##	  * Viewtopic Medal Display with image number and size control 
##		from ACP Medal Configuration
##	  * Viewprofile Medal History for the particular user
##
##   2004-03-26 - Version 2.0.1
##	- Security updates
##	- Fix 2 bugs in medalcp.php
##
##   2004-04-03 - Version 2.0.2
##	- Bug Fixs in medalcp.php & admin_medal.php
##	- Fix Medal Count Display in Viewtopic for Guests
##	- Two Chinese language change in lang_admin.php
##
##   2004-04-08 - Version 2.1.0
##	- Bug Fixs in viewtopic.php & usercp_viewprofile.php
##	- Added image randomize feature to Viewtopic, config in ACP
##
##   2004-08-11 - Version 2.2.0
##	- Fix template Actions synthax (Thanks to silvercloud @ phpBB.com)
##	- Fix image path in Viewtopic & Usercp_viewprofile
##	- Optimize & fix admin_medal_cfg.php sql query
##	- Added Medal Category and Category Order fuction
##
##   2004-08-12 - Version 2.2.1
##	- Added the forgotten toggle.js modification step in UPGRADE guide
##
##   2004-08-14 - Version 2.2.2
##	- Fix non-admin medal moderator can't see medalcp link problem
##
##   2005-09-25 - Version 2.2.3
##	- Fix some bugs and re-wrote some bits of script
##	- Added an add-on to remove toggle button effect from viewprofile
## 
############################################################## 
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD 
##############################################################

# 
#-----[ COPY ]------------------------------------------ 
# 
copy root/medals.php to medals.php
copy root/medalcp.php to medalcp.php
copy root/medalcp_edit.php to medalcp_edit.php
copy root/language/lang_english/email/medal_added.tpl to language/lang_english/email/medal_added.tpl
copy root/admin/*.* to admin/
copy root/templates/toggle.js to templates/toggle.js
copy root/templates/subSilver/*.* to templates/subSilver/*.*
copy root/medals/*.gif to medals/*.gif

# 
#-----[ SQL ]------------------------------------------ 
#
# Remember to change the table prefix used on your database
CREATE TABLE `phpbb_medal` (
  `medal_id` mediumint(8) UNSIGNED NOT NULL auto_increment,
  `cat_id` mediumint(8) UNSIGNED NOT NULL default '1',
  `medal_name` varchar(40) NOT NULL,
  `medal_description` varchar(255) NOT NULL,
  `medal_image` varchar(40) NULL,
  PRIMARY KEY  (`medal_id`)
) TYPE=MyISAM;

CREATE TABLE `phpbb_medal_user` (
  `issue_id` mediumint(8) UNSIGNED auto_increment,
  `medal_id` mediumint(8) UNSIGNED NOT NULL,
  `user_id` mediumint(8) UNSIGNED NOT NULL,
  `issue_reason` varchar(255) NOT NULL,
  `issue_time` int(11) NOT NULL,
  PRIMARY KEY  (`issue_id`)
) TYPE=MyISAM;

CREATE TABLE `phpbb_medal_mod` (
  `mod_id` mediumint(8) UNSIGNED auto_increment,
  `medal_id` mediumint(8) UNSIGNED NOT NULL,
  `user_id` mediumint(8) UNSIGNED NOT NULL,
  PRIMARY KEY  (`mod_id`)
) TYPE=MyISAM;

CREATE TABLE `phpbb_medal_cat` (
  `cat_id` mediumint(8) UNSIGNED auto_increment,
  `cat_title` varchar(100) NOT NULL,
  `cat_order` mediumint(8) UNSIGNED NOT NULL default '0',
  PRIMARY KEY  (`cat_id`),
  KEY `cat_order` (`cat_order`)  
) TYPE=MyISAM;

INSERT INTO `phpbb_config` VALUES ('allow_medal_display', '0');
INSERT INTO `phpbb_config` VALUES ('medal_display_row', '1');
INSERT INTO `phpbb_config` VALUES ('medal_display_col', '1');
INSERT INTO `phpbb_config` VALUES ('medal_display_width', '');
INSERT INTO `phpbb_config` VALUES ('medal_display_height', '');
INSERT INTO `phpbb_config` VALUES ('medal_display_order', '');
INSERT INTO `phpbb_medal_cat` VALUES ('1', 'Default', '10');

# 
#-----[ OPEN ]------------------------------------------ 
# 
language/lang_english/lang_main.php

# 
#-----[ FIND ]------------------------------------------ 
#
?>

# 
#-----[ BEFORE, ADD ]------------------------------------------ 
#
// Medal MOD
$lang['Medal_Control_Panel'] = 'Medal Control Panel';
$lang['Medals'] = 'Medals';
$lang['View_More'] = 'View more...';
$lang['Medal_amount'] = 'Amount: ';
$lang['Medal_Information'] = 'Medal Information';
$lang['Medal_name'] = 'Medal Name';
$lang['Medal_description'] = 'Medal Description';
$lang['Medal_image'] = 'Medal Image';
$lang['Medal_details'] = 'Award Details';
$lang['Medal_reason'] = 'Awarded Reason';
$lang['Medal_reason_explain'] = 'You can give a reason to why this medal this awarded to this user at this time.<br />This is not compulsory';
$lang['Medal_no_reason'] = '<i>No Reason was given</i>';
$lang['Medal_time'] = 'Awarded Time';
$lang['Medal_moderator'] = 'Medal Moderator';
$lang['No_medal_mod'] = 'No Medal Moderator';
$lang['Medal_userlist'] = 'User Lists';
$lang['Medal_Members'] = 'Members having this medal';
$lang['Medal_Members_explain'] = 'Click on the username to edit award reason(s)';
$lang['No_medal_members'] = 'No member has this medal';
$lang['No_medals_exist'] = 'No Medals Exist';
$lang['Medal_not_exist'] = 'That medal does not exist';
$lang['No_username_specified'] = 'No username specified';
$lang['No_medal_id_specified'] = 'No Medals specified';
$lang['Medal_user_username'] = 'Award one or more specific users with this Medal';
$lang['Medal_unmedal_username'] = 'Remove this Medal from one or more specific users';
$lang['Medal_unmedal_username_explain'] = 'You can remove multiple users in one go using the appropriate combination of mouse and keyboard for your computer and browser';
$lang['Medal_added'] = 'You have been awarded this medal.'; 
$lang['Medal_update_sucessful'] = 'User and Medal information has been updated';
$lang['Could_not_anonymous_user'] = 'You cannot give Anonymous a medal.';
$lang['Not_medal_moderator'] = 'You are not a moderator of this medal';
$lang['Link_to_cp'] = 'Medal Control Panel';
$lang['Click_return_medal'] = 'Click %sHere%s to return to medal information';
$lang['No_medal'] = 'No Medal Available';

# 
#-----[ OPEN ]------------------------------------------ 
#  
language/lang_english/lang_admin.php

# 
#-----[ FIND ]------------------------------------------ 
# 
?>

# 
#-----[ BEFORE, ADD ]------------------------------------------ 
# 
// Medal MOD
$lang['Medals'] = 'Medal Admin';
$lang['Manage'] = 'Management';
$lang['Medal_Config'] = 'Medal Configuration';
$lang['Medal_Config_explain'] = 'The form below will allow you to customize all the general medal options.';
$lang['Medal_setting'] = 'Medal Setting';
$lang['Allow_medal'] = 'Allow Medal Display in Viewtopic';
$lang['Medal_rand'] = 'Allow Random Medal Image in Viewtopic';
$lang['Medal_rand_explain'] = 'Image will displayed in random order, only work if you allow medal display in viewtopic';
$lang['Medal_display'] = 'Medal table (Rows x Columns)';
$lang['Medal_display_explain'] = 'Define how many rows and columns the medal table in <b>viewtopic</b>.<br />E.g. 1 row and 1 column display 1 image, and 1 row 2 columns display 2 images. <br />Make sure you set this correctly so it does not distort or introduce extra spaces your viewtopic.';
$lang['Medal_size'] = 'Maximum Medal Dimensions in Viewtopic';
$lang['Medal_size_explain'] = '(Height x Width in pixels)<br />If blank, images will display in it\'s original size';
$lang['Click_return_medalcfg'] = 'Click %sHere%s to return to Medal Configuration.';
$lang['Medal_admin'] = 'Medal Administration';
$lang['Medal_admin_explain'] = 'From this panel you can administer all your medals. You can delete, create and edit existing medals. You may choose moderators and set the medal name and description';
$lang['Updated_medal'] = 'Medal was successfully updated';
$lang['Updated_medal_category'] = 'Medal category was successfully updated';
$lang['Added_new_medal'] = 'New medal was successfully created';
$lang['Added_new_category'] = 'New medal category was successfully created';
$lang['Deleted_medal'] = 'Medal was successfully deleted';
$lang['Deleted_medal_category'] = 'Medal category was successfully deleted';
$lang['New_medal'] = 'Create new medal';
$lang['medal_name'] = 'Medal name';
$lang['medal_description'] = 'Medal description';
$lang['medal_image'] = 'Medal Image';
$lang['medal_image_explain'] = 'Use this to define a image associated with the medal<br />(Relative to phpBB2 root path)';
$lang['No_medal_name'] = 'You must specify a name for this medal';
$lang['No_medal_description'] = 'You must specify a description for this medal';
$lang['No_medal_image'] = 'You must specify an image for this medal';
$lang['Must_select_medal'] = 'Must specify a medal';
$lang['Click_return_medaladmin'] = 'Click %sHere%s to return to Medal Administration.';
$lang['Medal_mod'] = 'Medal Moderator';
$lang['Medal_mod_admin'] = 'Medal Moderator Administration';
$lang['Medal_mod_admin_explain'] = 'From this panel you can appoint medal moderators for your medals.';
$lang['Medal_mod_username'] = 'Appoint one or more specific users to be Medal Moderator';
$lang['Medal_unmod_username'] = 'Remove one or more specific users from Medal Moderator';
$lang['Medal_unmod_username_explain'] = 'You can remove multiple users in one go using the appropriate combination of mouse and keyboard for your computer and browser';
$lang['No_medal_mod'] = 'No Medal Moderator';
$lang['No_medal_in_cat'] = 'No medal in this category';
$lang['Must_delete_medal'] = 'You need to delete all medals before you can delete this category';
$lang['Category_delete'] = 'Delete Medal Category';
$lang['Category_delete_explain'] = 'The form below will allow you to delete a category and decide where you want to put all medals it contained.';
$lang['Move_medals'] = 'Move medals to';
$lang['Category_name'] = 'Category Name';
$lang['Medal_mod_update_sucessful'] = 'Medal Moderator has been updated successfully';
$lang['Click_return_medal_mod_admin'] = 'Click %sHere%s to return to Medal Moderator Administration.';

# 
#-----[ OPEN ]------------------------------------------ 
# 
viewtopic.php

# 
#-----[ FIND ]------------------------------------------ 
#
	//
	// Again this will be handled by the templating
	// code at some point
	//

# 
#-----[ BEFORE, ADD ]------------------------------------------ 
#
	// Medal MOD
	$medal ='';
	$sql = "SELECT m.medal_id, m.medal_name
		FROM " . MEDAL_TABLE . " m, " . MEDAL_USER_TABLE . " mu
		WHERE mu.user_id = '" . $postrow[$i]['user_id'] . "'
		AND m.medal_id = mu.medal_id
		ORDER BY m.medal_name";
	
	if(!$result = $db->sql_query($sql))
		message_die(GENERAL_ERROR, "Error getting medal information", "", __LINE__, __FILE__, $sql);
		
	$medal_list = $db->sql_fetchrowset($result);
	$medal_count = count($medal_list);

	if ( $postrow[$i]['user_id'] == ANONYMOUS )
	{
		$medal_count = '';
	} 
	else
	{
		$medal_count = ($medal_count) ? $lang['Medals'] . ': <a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=" . $postrow[$i]['user_id'] . "#medal") . '" class="gensmall">' . $medal_count . '</a>' . ' (<a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=" . $postrow[$i]['user_id'] . "#medal") . '" class="gensmall">' . $lang['View_More'] . '</a>)' : $lang['Medals'] . ': ' . $lang['None'];
	}

# 
#-----[ FIND ]------------------------------------------ 
#
		'AUTHOR_PANEL'	=> $postrow[$i]['user_my_ignore'] ? $ignore_panel : $author_panel,

# 
#-----[ AFTER, ADD ]------------------------------------------ 
#
		'POSTER_MEDAL_COUNT' => $medal_count,	// Medal MOD

# 
#-----[ FIND ]------------------------------------------ 
#
		'U_POST_ID' => $postrow[$i]['post_id'])
	);

# 
#-----[ AFTER, ADD ]------------------------------------------ 
#
	//Medal MOD
	if ( $board_config['allow_medal_display'] )
	{
		$order = ( $board_config['medal_display_order'] ) ? "RAND()" : "m.medal_name";

		$template->assign_block_vars('postrow.medal', array());

		$sql = "SELECT m.medal_id, m.medal_name, m.medal_image
			FROM " . MEDAL_TABLE . " m, " . MEDAL_USER_TABLE . " mu
			WHERE mu.user_id = '" . $poster_id . "'
			AND m.medal_id = mu.medal_id
			ORDER BY " . $order;
	
		if ($result = $db->sql_query($sql))
		{
			$rowset = array();
			while ($row = $db->sql_fetchrow($result))
			{
				$rowset[$row['medal_image']]['medal_name'] = $row['medal_name'];
				if ($rowset[$row['medal_image']]['medal_name'] == $row['medal_name'])
				$rowset[$row['medal_image']]['medal_count'] += 1;
			}

			// Check Medal config in ACP
			$medal_rows = $board_config['medal_display_row'];
			$medal_cols = $board_config['medal_display_col'];
			$medal_width = ( $board_config['medal_display_width'] ) ? 'width="'.$board_config['medal_display_width'].'"' : '';
			$medal_height = ( $board_config['medal_display_height'] ) ? 'height="'.$board_config['medal_display_height'].'"' : '';
	
			if ($medal_list)
			{
				$split_row = $medal_cols - 1;

				$s_colspan = 0;
				$row = 0;
				$col = 0;

				while (list($medal_image, $medal) = @each($rowset))
				{
					if (!$col)
			       		{ 
						$template->assign_block_vars('postrow.medal.medal_row', array()); 
					}

					$template->assign_block_vars('postrow.medal.medal_row.medal_col', array(
						'MEDAL_IMAGE' => $phpbb_root_path . $medal_image,
						'MEDAL_WIDTH' => $medal_width,
						'MEDAL_HEIGHT' => $medal_height,
						'MEDAL_NAME' => $medal['medal_name'],
						'MEDAL_COUNT' => '('. $lang['Medal_amount'] . $medal['medal_count']. ')')
					);

					$s_colspan = max($s_colspan, $col + 1);

					if ($col == $split_row)
					{
						if ($row == $medal_rows - 1) 
						{ 
							break; 
						}
						$col = 0;
						$row++;
					}
					else 
					{ 
						$col++; 
					}
				}
			}
		}
	}

# 
#-----[ OPEN ]------------------------------------------ 
# 
includes/constants.php

# 
#-----[ FIND ]------------------------------------------ 
#
define('POST_GROUPS_URL', 'g');

# 
#-----[ AFTER, ADD ]------------------------------------------ 
#
define('POST_MEDAL_URL', 'm');	// Medal MOD
define('MEDAL_CAT_URL', 'mc');	// Medal MOD

# 
#-----[ FIND ]------------------------------------------ 
#
define('PAGE_GROUPCP', -11);

# 
#-----[ AFTER, ADD ]------------------------------------------ 
#
define('PAGE_MEDALS', -2115);	// Medal MOD

# 
#-----[ FIND ]------------------------------------------ 
#
define('GROUPS_TABLE', $table_prefix.'groups');

# 
#-----[ AFTER, ADD ]------------------------------------------ 
#
define('MEDAL_TABLE', $table_prefix.'medal');		// Medal MOD
define('MEDAL_MOD_TABLE', $table_prefix.'medal_mod');	// Medal MOD
define('MEDAL_USER_TABLE', $table_prefix.'medal_user');	// Medal MOD
define('MEDAL_CAT_TABLE', $table_prefix.'medal_cat');	// Medal MOD

# 
#-----[ OPEN ]------------------------------------------ 
# 
includes/functions.php

# 
#-----[ FIND ]------------------------------------------ 
#
?>

# 
#-----[ BEFORE, ADD ]------------------------------------------ 
#
function check_medal_mod($medal_id)
{
	global $db, $userdata;
	
	$sql = "SELECT *
	FROM " . MEDAL_MOD_TABLE . "  
	WHERE medal_id =" . $medal_id;
	
	if ( !($result = $db->sql_query($sql)) )
	{
		message_die(GENERAL_ERROR, 'Could not obtain user and medal information', '', __LINE__, __FILE__, $sql);
	}

	$medal_info = array();
	while ( $medal_info = $db->sql_fetchrow($result) )
	{

		$medal_moderator = $medal_info['user_id'];

		if ( $medal_moderator == $userdata['user_id'] )
		{
			return TRUE;
		}
	}

}

# 
#-----[ OPEN ]------------------------------------------ 
# 
includes/page_header.php

# 
#-----[ FIND ]------------------------------------------ 
#
	'L_USERGROUPS' => $lang['Usergroups'],

# 
#-----[ AFTER, ADD ]------------------------------------------ 
#
	'L_MEDALS' => $lang['Medals'],	// Medal MOD

# 
#-----[ FIND ]------------------------------------------ 
#
	'U_GROUP_CP' => append_sid('groupcp.'.$phpEx),

# 
#-----[ AFTER, ADD ]------------------------------------------ 
#
	'U_MEDALS' => append_sid('medals.'.$phpEx),	// Medal MOD

# 
#-----[ OPEN ]------------------------------------------ 
# 
profilcp/def/def_userfields.php

# 
#-----[ FIND ]------------------------------------------ 
# 
// messangers informations

# 
#-----[ BEFORE, ADD ]------------------------------------------ 
# 
	'user_medals' => array(
		'lang_key'     => 'Medals',
		'class'        => 'generic',
		'type'         => 'VARCHAR',
		'dsp_func'     => 'pcp_output_medals',
	),
# 
#-----[ OPEN ]------------------------------------------ 
# 
profilcp/def/def_usermaps.php

# 
#-----[ FIND ]------------------------------------------ 
# Something similiar
#
	'PCP.viewprofile.base.international' => array(
		'order'		=> 20,
		'title'		=> 'Profile_control_panel_i18n',
		'fields'	=> array(
			'user_timezone' => array(
				'img'          => true,
			),
			'user_lang' => array(
				'txt'          => true,
				'style'        => '<b>%s</b>',
			),
		),
	),
# 
#-----[ BEFORE, ADD ]------------------------------------------ 
# 
	'PCP.viewprofile.base.medals' => array(
		'order'		=> 15,
		'title'		=> 'Medals Information',
		'fields'	=> array(
			'user_medals' => array(
				'dsp_func'     => 'pcp_output_medals',
				'txt'          => true,
				'style'        => '<div align="center" class="gensmall">%s</div>',
			),
		),
	),
# 
#-----[ OPEN ]------------------------------------------ 
# 
profilcp/def/def_userfuncs_custom.php

# 
#-----[ FIND ]------------------------------------------ 
#
?>

# 
#-----[ BEFORE, ADD ]------------------------------------------ 
# 
//-----------------------------------
//
// user_medals profile output function
//
//-----------------------------------
function pcp_output_medals($field_name, $view_userdata, $map_name='')
{
	global $board_config, $phpbb_root_path, $phpEx, $lang, $images, $userdata;
	global $values_list, $tables_linked, $classes_fields, $user_maps, $user_fields;
	global $db, $template;

	$txt = '';
	$img = '';
	$res = '';

		// save template state
		$sav_tpl = $template->_tpldata;

		// template file
		$template->set_filenames(array(
			'_box_medals' => 'profilcp/profil_medals_body.tpl')
		);

$sql = "SELECT cat_id, cat_title
	FROM " . MEDAL_CAT_TABLE . "
	ORDER BY cat_order";
if( !($result = $db->sql_query($sql)) )
{
	message_die(GENERAL_ERROR, 'Could not query medal categories list', '', __LINE__, __FILE__, $sql);
}

$category_rows = array();
while ( $row = $db->sql_fetchrow($result) )
{
	$category_rows[] = $row;
}
$db->sql_freeresult($result);

$sql = "SELECT m.medal_id, mu.user_id
	FROM " . MEDAL_TABLE . " m, " . MEDAL_USER_TABLE . " mu
	WHERE mu.user_id = '" . $view_userdata['user_id'] . "'
	AND m.medal_id = mu.medal_id
	ORDER BY m.medal_name";
	
if($result = $db->sql_query($sql))
{
	$medal_list = $db->sql_fetchrowset($result);
	$medal_count = count($medal_list);

	if ( $medal_count )
	{
		$medal_count = '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=" . $view_userdata['user_id'] . "#medal") . '" class="genmed">' . $medal_count . '</a>';

		$template->assign_block_vars('switch_display_medal', array());

		$template->assign_block_vars('switch_display_medal.medal', array(
			'MEDAL_BUTTON' => '<button onclick="ToggleBox(\'toggle_medal\')">'.$lang['Medal_details'].'</button>')
		);
	}
}

for ($i = 0; $i < count($category_rows); $i++)
{
	$cat_id = $category_rows[$i]['cat_id'];

	$sql = "SELECT m.medal_id, m.medal_name,m.medal_description, m.medal_image, m.cat_id, mu.issue_reason, mu.issue_time, c.cat_id, c.cat_title
		FROM " . MEDAL_TABLE . " m, " . MEDAL_USER_TABLE . " mu, " . MEDAL_CAT_TABLE . " c
		WHERE mu.user_id = '" . $view_userdata['user_id'] . "'
		AND m.cat_id = c.cat_id
		AND m.medal_id = mu.medal_id
		ORDER BY c.cat_order, m.medal_name, mu.issue_time";

	if ($result = $db->sql_query($sql))
	{
		$row = array();
		$rowset = array();
		$medal_time = $lang['Medal_time'] . ':&nbsp;';
		$medal_reason = $lang['Medal_reason'] . ':&nbsp;';
		while ($row = $db->sql_fetchrow($result))
		{
			if (empty($rowset[$row['medal_name']]))
			{
				$rowset[$row['medal_name']]['cat_id'] = $row['cat_id'];
				$rowset[$row['medal_name']]['cat_title'] = $row['cat_title'];
				$rowset[$row['medal_name']]['medal_description'] .= $row['medal_description'];
				$rowset[$row['medal_name']]['medal_image'] = $row['medal_image'];
				$row['issue_reason'] = ( $row['issue_reason'] ) ? $row['issue_reason'] : $lang['Medal_no_reason'];
				$rowset[$row['medal_name']]['medal_issue'] = '<tr><td><span class="genmed">' . $medal_time . create_date($board_config['default_dateformat'], $row['issue_time'], $board_config['board_timezone']) . '</span></td></tr><tr><td><span class="genmed">' . $medal_reason . $row['issue_reason']  . '</span><hr></td></tr>';
				$rowset[$row['medal_name']]['medal_count'] = '1';
			}
			else
			{
				$row['issue_reason'] = ( $row['issue_reason'] ) ? $row['issue_reason'] : $lang['Medal_no_reason'];
				$rowset[$row['medal_name']]['medal_issue'] .= '<tr><td><span class="genmed">' . $medal_time . create_date($board_config['default_dateformat'], $row['issue_time'], $board_config['board_timezone']) . '</span></td></tr><tr><td><span class="genmed">' . $medal_reason . $row['issue_reason'] . '</span><hr /></td></tr>';
				$rowset[$row['medal_name']]['medal_count'] += '1';
			}
		}

		$medal_width = ( $board_config['medal_display_width'] ) ? 'width="'.$board_config['medal_display_width'].'"' : '';
		$medal_height = ( $board_config['medal_display_height'] ) ? 'height="'.$board_config['medal_display_height'].'"' : '';

		$medal_name = array();
		$data = array();

		//
		// Should we display this category/medal set?
		//
		$display_medal = 0;

		while (list($medal_name, $data) = @each($rowset))
		{
			if ( $cat_id == $data['cat_id'] ) { $display_medal = 1; }

			if ( !empty($display_medal) )
			{
				$template->assign_block_vars('switch_display_medal.details', array(
					'MEDAL_CAT' => $data['cat_title'],
					'MEDAL_NAME' => $medal_name,
					'MEDAL_DESCRIPTION' => $data['medal_description'],
					'MEDAL_IMAGE' => '<img src="'. $phpbb_root_path . $data['medal_image'] . '" border="0" alt="' . $medal_name . '" title="' . $medal_name . '" />',
					'MEDAL_IMAGE_SMALL' => '<img src="'. $phpbb_root_path . $data['medal_image'] . '" border="0" alt="' . $medal_name . '" title="' . $medal_name . '"' . $medal_width . $medal_height . ' />',
					'MEDAL_ISSUE' => $data['medal_issue'],
					'MEDAL_COUNT' => $lang['Medal_amount'] . $data['medal_count'],				
					'L_MEDAL_DESCRIPTION' => $lang['Medal_description'])
				);
				$display_medal = 0;
			}
		}
	}
}
				$template->assign_vars(array(
					'L_USER_MEDAL' =>$lang['Medals'],
					'USER_MEDAL_COUNT' => $medal_count,
					'L_MEDAL_INFORMATION' => $lang['Medal_Information'],
					'L_MEDAL_NAME' => $lang['Medal_name'],
					'L_MEDAL_DETAIL' => $lang['Medal_details'],
				));
			if ( !empty($medal_count) )
			{
		// transfert to a var
		$template->assign_var_from_handle('_box', '_box_medals');
		$txt .= $template->_tpldata['.'][0]['_box'];
	}
	else{
		$txt = '';
}

		// result
		$res = pcp_output_format($field_name, $txt, $img, $map_name);
	return $res;
}
# 
#-----[ OPEN ]------------------------------------------ 
# create a file called profil_medals_body.tpl with the contents below and upload it to templates/subSilver/profilcp/
#
<script src="templates/toggle.js"></script>
<!-- BEGIN switch_display_medal -->
<br />
<table class="forumline" width="100%" cellspacing="1" cellpadding="3" border="0" align="center">
  <tr>
	<td class="row1"  align="center" valign="middle" width="10%"><span class="gen">{L_USER_MEDAL}:&nbsp;<b>{USER_MEDAL_COUNT}</b></span>
		<!-- BEGIN medal -->
		<br /><br />{switch_display_medal.medal.MEDAL_BUTTON}
		<!-- END medal -->
	</td>
	<td class="row1" valign="middle" align="left" nowrap="nowrap" width="100%">
		<!-- BEGIN details -->
		&nbsp;{switch_display_medal.details.MEDAL_IMAGE_SMALL}&nbsp;
		<!-- END details -->
	</td>
  </tr>
</table>

<br />
<div style="width: 100%; overflow: hidden; display: none;" id="toggle_medal">
<a name="medal"></a>

<table class="forumline" width="100%" cellspacing="1" cellpadding="3" border="0" align="center">
  <tr>
	<th class="thCornerL" align="center" nowrap="nowrap">&nbsp;{L_MEDAL_NAME}&nbsp;</th>
	<th class="thCornerR" align="center" nowrap="nowrap">&nbsp;{L_MEDAL_DETAIL}&nbsp;</th>
  </tr>
<!-- BEGIN details -->
  <tr>
	<td class="row2" nowrap="nowrap">
		<table width="100%" cellspacing="1" cellpadding="3" border="0">
		<tr><td align="center"><span class="gen">{switch_display_medal.details.MEDAL_CAT}</span></td></tr>
		<tr><td align="center"><span class="genmed">{switch_display_medal.details.MEDAL_NAME}</span></td></tr>
		<tr><td align="center">{switch_display_medal.details.MEDAL_IMAGE}</td></tr>
		<tr><td align="center"><span class="gensmall">{switch_display_medal.details.MEDAL_COUNT}</span></td></tr></table></td>
	<td class="row2" valign="top">
		<table width="100%" cellspacing="1" cellpadding="3" border="0">
		<tr><td><span class="gen">{switch_display_medal.details.L_MEDAL_DESCRIPTION}: <b>{switch_display_medal.details.MEDAL_DESCRIPTION}</b></span></td></tr>
		<tr><td class="quote">
			<table width="100%" cellspacing="1" cellpadding="3" border="0">
			<tr><td><span class="genmed">{switch_display_medal.details.MEDAL_ISSUE}</span></td></tr>
			</table>
		</td></tr>
	</table></td>
  </tr>
<!-- END details -->
</table>
</a>
</div>
<!-- END switch_upload_limits -->
# 
#-----[ OPEN ]------------------------------------------ 
# 
viewonline.php

# 
#-----[ FIND ]------------------------------------------ 
#
				case PAGE_FAQ:
					$location = $lang['Viewing_FAQ'];
					$location_url = "faq.$phpEx";
					break;

# 
#-----[ AFTER, ADD ]------------------------------------------ 
#
				case PAGE_MEDALS:	// Medal MOD
					$location = $lang['Medals'];
					$location_url = "medals.$phpEx";
					break;

# 
#-----[ OPEN ]------------------------------------------ 
# 
templates/subSilver/viewtopic_body.tpl

# 
#-----[ FIND ]------------------------------------------ 
# 
{postrow.AUTHOR_PANEL}</span></table>

# 
#-----[ IN-LINE REPLACE WITH ]------------------------------------------ 
# I just took this from my .tpl so yours may be a bit different but you get the idea
#
{postrow.AUTHOR_PANEL}<br /><span class="name">{postrow.POSTER_MEDAL_COUNT}<br />
			<!-- BEGIN medal -->
	<table border="0" cellspacing="0" cellpadding="5">
		<!-- BEGIN medal_row -->
		<tr align="left" valign="middle"> 
			<!-- BEGIN medal_col -->
			<td><img src="{postrow.medal.medal_row.medal_col.MEDAL_IMAGE}" border="0" alt="{postrow.medal.medal_row.medal_col.MEDAL_NAME} {postrow.medal.medal_row.medal_col.MEDAL_COUNT}" title="{postrow.medal.medal_row.medal_col.MEDAL_NAME} {postrow.medal.medal_row.medal_col.MEDAL_COUNT}" {postrow.medal.medal_row.medal_col.MEDAL_WIDTH} {postrow.medal.medal_row.medal_col.MEDAL_HEIGHT} /></td>
			<!-- END medal_col -->
		</tr>
		<!-- END medal_row -->
	</table>
	<!-- END medal -->
	</span><br /></td>
		</table>

# 
#-----[ OPEN ]------------------------------------------ 
# 
templates/subSilver/overall_header.tpl

# 
#-----[ FIND ]------------------------------------------ 
#
<td align="center" valign="top" nowrap="nowrap"><span class="mainmenu">

# 
#-----[ IN-LINE FIND ]------------------------------------------ 
#
{L_USERGROUPS}</a>&nbsp; 

# 
#-----[ IN-LINE AFTER, ADD ]------------------------------------------ 
#
&nbsp;<a href="{U_MEDALS}" class="mainmenu"><img src="templates/subSilver/images/icon_mini_medal.gif" width="12" height="13" border="0" alt="{U_MEDALS}" hspace="3" />{L_MEDALS}</a>&nbsp; 

# 
#-----[ OPEN ]------------------------------------------ 
# 
templates/subSilver/subSilver.cfg

# 
#-----[ FIND ]------------------------------------------ 
#
?>

# 
#-----[ BEFORE, ADD ]------------------------------------------ 
#
$images['Medals'] = "$current_template_images/icon_mini_medal.gif";	// Medal MOD

# 
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------ 
# 

# EoM

ycl6
Translator
Posts: 5696
Joined: Sat Feb 15, 2003 10:35 am
Location: Taiwan
Contact:

Post by ycl6 »

MrDSL wrote: Works for me.. It was easier to create the same install file and remove stuff that didn't need to be editted and add stuff that did so its less confusing. Hopefully ycl6 will include this with the main download :)

I will, once this MOD made it to public release. :wink:

~Mac

odie3
Registered User
Posts: 145
Joined: Thu Mar 04, 2004 6:48 pm
Location: Kyle USA
Contact:

Post by odie3 »

MrDSL Damn Fine Job!


Well, got it installed. Having issues with the templates/subSilver/viewtopic_body.tpl edit [but that is my issue - I hope I can figure it out]. [FIXED]

On the viewprofile, I click on Award Details and I see my profile shift but that is all I see. I assume I should see the reason why I awarded myself this award.... [RTFM Works only in IE and No longer applies with new PCP Files.]

Also, the number next to Medals: seem to be a hyper link back to the Public Profile. Not sure if what that is about. [No longer applies with new PCP Files.]

When adding the "Awarded Reason" the text box is white and my text is Gold, so I can not read it [using subblack]. how can I change that background to black? [Fixed by changing css file]

EDIT:
Okay: so got the viewtopic corrected - just moved stuff until it worked. If Firefox is showing it correctly - then I am okay I think. Which leads me to...

My profile issue... toggle no worked in FF - should have RTFM!

[Request/Idea for MrDSL]
So, for PCP I am wondering if a independent Panel would be better than using the toggle on the Public PCP. There is another PCP Medal system I been using till this one worked in PCP [by Loki]. So, if you had an Award Panel then we would not have to worry about the toggle not working in Firefox [and other browsers]. Also, I have 8 awards and it looks some what bad on the Public Panel of PCP [to long across].

Visit http://ghostdogs.net/bbtest/ and use login: user password: user to view {GD}odie3 profile.

Now that I have taken the toggle out - it does look better but still think it would a heck of a lot better in it's PCP Panel [like Loki's Display Case].
Last edited by odie3 on Tue Sep 27, 2005 11:17 pm, edited 2 times in total.
Odie3
{GD} Forum Admin
http://ghostdogs.net/bb/

odie3
Registered User
Posts: 145
Joined: Thu Mar 04, 2004 6:48 pm
Location: Kyle USA
Contact:

Post by odie3 »

Follow up on the request for MrDSL.

Well, I pretty much did what I requested - that is I just used the PCP Admin to take your vaules for the base and placed them into Loki's Display Case. Then I delete the Medals from the Base. Then I edited the viewtopic link information to go to mode=viewprofile&sub=displaycase&u=

take a look! I am not sure how to write that in a MOD text since I mostly used PCP Admin Panel [first time it ever came in handly].
Odie3
{GD} Forum Admin
http://ghostdogs.net/bb/

MrDSL
Registered User
Posts: 283
Joined: Thu Jul 15, 2004 1:52 am
Contact:

Post by MrDSL »

You mean something like this
http://www.thehottub.net/phpBB3/profile ... ortcut&u=2

username/pass = tester/tester


I basicly took the code and then used the no_toggle addon and adapted it into a panel..It appears to be the same as your except mine is built into its own file so you basicly would only need to upload 2 files and then add 2 $lang keys..


Would you like to test it for me? Send me a PM

odie3
Registered User
Posts: 145
Joined: Thu Mar 04, 2004 6:48 pm
Location: Kyle USA
Contact:

Post by odie3 »

Yes that is the ticket and I am sure your way way better than mine. I am no coder and I just hacked up Loki Medal install to get what I wanted.

PM sent!
Odie3
{GD} Forum Admin
http://ghostdogs.net/bb/

odie3
Registered User
Posts: 145
Joined: Thu Mar 04, 2004 6:48 pm
Location: Kyle USA
Contact:

Post by odie3 »

Got the new files from MrDSL for the independent Medal Page - nice work!!

However, if someone could help me with this:
Image

The Reason for text box is a White Background with Gold Text. How do I chage that to be a Black background?
Odie3
{GD} Forum Admin
http://ghostdogs.net/bb/

songdove
Registered User
Posts: 199
Joined: Wed Jun 22, 2005 4:07 pm

Post by songdove »

I've got the toggle version working, but the details box drops down behind the timezone box in Opera. I have to figure out how to change that so it displays properly.

MrDSL, I believe those files you're offering to Odie3 are the same files I tried to use awhile ago. I'd accessed them from a link Gremlin provided. If you've updated them or made changes or if you have a list of steps I can double-check, I'd prefer the page version as opposed to this toggle version.

odie3
Registered User
Posts: 145
Joined: Thu Mar 04, 2004 6:48 pm
Location: Kyle USA
Contact:

Post by odie3 »

Okay, I fixed my Text box area.

I had to add background-color : #000000; to textarea, select { in my subBlack.css file.

Okay, now for a real request for the Author. :)

I sees that you can change the order of the Categories. Any chance to change the order of the Medals with in a Category? It seems to be in Alpha Sort at the moment. Having the medal in proper order of ranking would be version nice.

Having our Medal of Honor in the middle of the list just seems wrong. ;)
Odie3
{GD} Forum Admin
http://ghostdogs.net/bb/

Kinsman
Registered User
Posts: 207
Joined: Sun Jan 02, 2005 6:04 am
Contact:

Post by Kinsman »

i have a working Toggle for FireFox to view Award Details, if thats still a problem these days???

www.junglewraiths.net

if it is, let me know, and i will see if i can find the code, and stuff, and post how its done for you. :D

ycl6
Translator
Posts: 5696
Joined: Sat Feb 15, 2003 10:35 am
Location: Taiwan
Contact:

Post by ycl6 »

Kinsman wrote: i have a working Toggle for FireFox to view Award Details, if thats still a problem these days???

www.junglewraiths.net

if it is, let me know, and i will see if i can find the code, and stuff, and post how its done for you. :D

The toggle indeed does not work on FF, so if you can provide me the code that would be great.

~Mac

Kinsman
Registered User
Posts: 207
Joined: Sun Jan 02, 2005 6:04 am
Contact:

Post by Kinsman »

I'm away from home for a few days, so cant access my site, but i basically just stole the Topic Calendar Toggle, and used that, as it works fine in FF. :wink:

Will have a look when i get home though. :D

Post Reply

Return to “[2.0.x] MODs in Development”