Invision Board 1.3 Final Badge Mod Instructions Written by Justin Aquadro The following mod will add badges beneath the user title of members in their posts. Badges can then be assigned from the Admin CP and the Mod CP. Badge editing is done within conf_badges.php ------------------------------------------------------ Go to your IPB Admin CP and open the MySQL Toolbox. In the text field, run the following query: ALTER TABLE members ADD badges VARCHAR(128); Replace with your own table prefix, which is usually "ibf_", so then you would have ibf_members. ------------------------------------------------------ Create a file called conf_badges.php in your base IPB directory. This is the same directory that has conf_global.php. This is the file where you will add your badges. Add the following text to this new file: array(image, alt tag, title tag), // // Follow this template for adding new badges. Always increment the id number for each new badge. // To re-order the badges, simply change the order of the lines. It's OK for the id numbers to be // out of order. It is very important that an id number always be associated with the same badge. $BADGES = array(1 => array('admin.gif', '[A]', 'Administrator Badge'), 2 => array('mod.gif', '[M]', 'Moderator Badge'), 3 => array('bighelp.gif', '[*]', 'Big Help Badge'), ); ?> Three lines have been provided as a template for managing badges. All the images should be stored in the badges directory which you will create next. Create a new directory inside the html directory called "badges". This is where your badge images will be stored. ------------------------------------------------------ Open sources/functions.php ------------------------------------------------------ Find the following piece of code near line 2778 in the load_member function: $DB->query("SELECT moderator.mid as is_mod, moderator.allow_warn, m.id, m.name, m.mgroup, m.password, m.email, m.restrict_post, m.view_sigs, m.view_avs, m.view_pop, m.view_img, m.auto_track, m.mod_posts, m.language, m.skin, m.new_msg, m.show_popup, m.msg_total, m.time_offset, m.posts, m.joined, m.last_post, m.last_visit, m.last_activity, m.dst_in_use, m.view_prefs, m.org_perm_id, m.temp_ban, m.sub_end, g.* FROM ibf_members m LEFT JOIN ibf_groups g ON (g.g_id=m.mgroup) LEFT JOIN ibf_moderators moderator ON (moderator.member_id=m.id OR moderator.group_id=m.mgroup ) WHERE m.id=$member_id"); Replace: m.sub_end, g.* With: m.sub_end, m.badges, g.* ------------------------------------------------------ Open sources/Topics.php ------------------------------------------------------ Find the following piece of code near line 74 in the Topics function: require ROOT_PATH."sources/lib/post_parser.php"; Immediately below that, add the following piece of code: require ROOT_PATH."conf_badges.php"; ------------------------------------------------------ Find the following piece of code near line 534 in the Topics function: $DB->query( "SELECT p.*, m.id,m.name,m.mgroup,m.email,m.joined,m.avatar,m.avatar_size,m.posts,m.aim_name,m.icq_number, m.signature, m.website,m.yahoo,m.integ_msg,m.title,m.hide_email,m.msnname, m.warn_level, m.warn_lastwarn, g.g_id, g.g_title, g.g_icon, g.g_dohtml $join_get_fields FROM ibf_posts p LEFT JOIN ibf_members m ON (p.author_id=m.id) LEFT JOIN ibf_groups g ON (g.g_id=m.mgroup) $join_profile_query WHERE p.topic_id=".$this->topic['tid']." and p.queued != 1 ORDER BY p.{$ibforums->vars['post_order_column']} {$ibforums->vars['post_order_sort']} LIMIT $first, ".$ibforums->vars['display_max_posts']); Replace: m.warn_lastwarn, With: m.warn_lastwarn, m.badges, ------------------------------------------------------ Find the following piece of code near line 806 in the Topics function: //-------------------------------------------------------------- // Fix up the membername so it links to the members profile //-------------------------------------------------------------- if ($poster['id']) { $poster['name'] = "{$poster['name']}"; } Immediately below that, add the following piece of code: // *** Section Written by Justin Aquadro *** // //-------------------------------------------------------------- // Generate Member Badges //-------------------------------------------------------------- if ($poster['badges']) { $poster['badges'] = $this->parser->badges($poster['badges'], $BADGES); } // *** END SECTION *** // ------------------------------------------------------- Open sources/lib/post_parser.php ------------------------------------------------------- Find the following piece of code near line 568, not within a function: /**************************************************/ // unconvert: // Parses the HTML back into plain text /**************************************************/ function unconvert($txt="", $code=1, $html=0) { Immediately above that, add the following piece of code: // *** Section Written by Justin Aquadro *** // //-------------------------------------------------------------- // Badges: // Converts badge IDs to image tags //-------------------------------------------------------------- function badges($badges='', &$BADGES) { global $INFO; $badge_html = ''; $bcnt = 0; if ($badges != '') { $badges = split(',', $badges); foreach ($badges as $badge) { $bcnt++; $be = $BADGES[$badge]; $badge_html .= "{$be[1]}"; if ($bcnt >= 5) { $badge_html .= "
"; $bcnt = 0; } } } return $badge_html; } // *** END SECTION *** // ------------------------------------------------------- Open sources/Admin/ad_member.php ------------------------------------------------------- Find the following piece of code near line 2945 in function do_edit_form: //+-------------------------------+ $ADMIN->html .= $SKIN->start_table( "Other Information" ); //+------------------------------- Immedidately below that, add the following piece of code: //------ Badge HTML -------------- require "conf_badges.php"; $membadges = explode(',', $mem['badges']); $badge_html = ''; $bcnt = 0; while (list($key,$val) = each ($BADGES)) { $bcnt++; if (in_array($key, $membadges)) $badge_ticked = "checked"; else $badge_ticked = ""; $badge_html .= "".$val[1].""; $badge_html .= "   "; if ($bcnt >= 7) { $badge_html .= "
"; $bcnt = 0; } } //------ End Badge HTML ---------- ------------------------------------------------------- Find the following piece of code near line 2993 in function do_edit_form: $ADMIN->html .= $SKIN->add_td_row( array( "Location" , $SKIN->form_input("location", $mem['location']) ) ); Immediately below that, add the following piece of code: $ADMIN->html .= $SKIN->add_td_row( array( "Badges" , $badge_html ) ); ------------------------------------------------------- Find the following piece of code near line 3094 in function do_edit: if ( $IN['post_indef'] == 1 ) { $restrict_post = 1; } elseif ( $IN['post_timespan'] > 0 ) { $restrict_post = $std->hdl_ban_line( array( 'timespan' => intval($IN['post_timespan']), 'unit' => $IN['post_units'] ) ); } Immediately below that, add the following piece of code: // ------- Convert badges ---------- $badge_set = ''; if (isset ($IN['badges'] )) { foreach ($IN['badges'] as $badge_id) { if ($badge_set == '') $badge_set .= $badge_id; else $badge_set .= ','.$badge_id; } } // -------- End Convert Badges ------ ------------------------------------------------------- Find the following piece of code near line 3126 in function do_edit: $db_string = $DB->compile_db_update_string( array ( 'restrict_post' => $restrict_post, 'restrict_html' => $restrict_html, 'mgroup' => $IN['mgroup'], 'title' => $IN['title'], 'language' => $IN['language'], 'skin' => $IN['skin'], 'hide_email' => $IN['hide_email'], 'email_pm' => $IN['email_pm'], 'email' => $IN['email'], 'aim_name' => $IN['aim_name'], 'icq_number' => $IN['icq_number'], 'yahoo' => $IN['yahoo'], 'msnname' => $IN['msnname'], 'website' => $IN['website'], 'avatar' => $IN['avatar'], 'avatar_size' => $IN['avatar_size'], 'posts' => $IN['posts'], 'location' => $IN['location'], 'interests' => $IN['interests'], 'signature' => $IN['signature'], 'mod_posts' => $mod_queue, 'org_perm_id' => $permid, 'warn_level' => $IN['warn_level'], 'integ_msg' => $IN['integ_msg'], ) ); Replace: 'integ_msg' => $IN['integ_msg'], With: 'integ_msg' => $IN['integ_msg'], 'badges' => $badge_set, ------------------------------------------------------- Open sources/mod_cp.php ------------------------------------------------------- Find the following piece of code near line 2392 in function edit_user: //-------------------------------------------------- $DB->query("SELECT m.*, g.* FROM ibf_members m, ibf_groups g WHERE m.id='".$ibforums->input['memberid']."' AND m.mgroup=g.g_id"); if (! $member = $DB->fetch_row() ) { $this->mod_error('cp_no_matches'); return; } Immediately below that, add the following piece of code: //------ Badge HTML -------------- require "conf_badges.php"; $membadges = explode(',', $member['badges']); $badge_html = ''; $bcnt = 0; while (list($key,$val) = each ($BADGES)) { $bcnt++; if (in_array($key, $membadges)) $badge_ticked = "checked"; else $badge_ticked = ""; $badge_html .= "".$val[1].""; $badge_html .= "   "; if ($bcnt >= 7) { $badge_html .= "
"; $bcnt = 0; } } //------ End Badge HTML ---------- ------------------------------------------------------- Find the following piece of code near line 2442 in function edit_user: require ROOT_PATH."sources/lib/post_parser.php"; $parser = new post_parser(); $editable['signature'] = $parser->unconvert($member['signature']); $editable['location'] = $member['location']; $editable['interests'] = $member['interests']; $editable['website'] = $member['website']; $editable['id'] = $member['id']; $editable['name'] = $member['name']; Replace: $editable['name'] = $member['name']; With: $editable['name'] = $member['name']; $editable['badges'] = $badge_html; ------------------------------------------------------- Find the following piece of code near line 2517 in function complete_user_edit: $ibforums->input['signature'] = $parser->convert( array( 'TEXT' => $ibforums->input['signature'], 'SMILIES' => 0, 'CODE' => $ibforums->vars['sig_allow_ibc'], 'HTML' => 0, 'SIGNATURE' => 1 ) ); if ($parser->error != "") { $std->Error( array( 'LEVEL' => 1, 'MSG' => $parser->error) ); } Immediately below that, add the following piece of code: // ------- Convert badges ---------- $badge_set = ''; if (isset ($ibforums->input['badges'] )) { foreach ($ibforums->input['badges'] as $badge_id) { if ($badge_set == '') $badge_set .= $badge_id; else $badge_set .= ','.$badge_id; } } // -------- End Convert Badges ------ ------------------------------------------------------- Find the following piece of code near line 2543 in function complete_user_edit: $profile = array ( 'signature' => $ibforums->input['signature'], 'location' => $ibforums->input['location'], 'interests' => $ibforums->input['interests'], 'website' => $ibforums->input['website'], ); Replace: 'website' => $ibforums->input['website'], With: 'website' => $ibforums->input['website'], 'badges' => $badge_set ------------------------------------------------------- Now the code modification is done, and the only thing left to do is modify your Skin to display the badges. Go to your IPB Admin CP and go to Manage HTML Templates. Click Manage HTML, then expand Topic View Section. Click Edit Single next to Post Entry. Scroll down until your find this block: {$author['title']}
{$author['member_rank_img']}
{$author['member_group']}
{$author['member_posts']}
{$author['member_number']}
{$author['member_joined']}

{$author['warn_text']} Add: {$author['badges']}

After: {$author['member_rank_img']}
The block should look like: {$author['title']}
{$author['member_rank_img']}
{$author['badges']}

{$author['member_group']}
{$author['member_posts']}
{$author['member_number']}
{$author['member_joined']}

{$author['warn_text']} For optimal results. You can play around with this to suit your tastes. The mod is now complete.