Advertisement:

Navigation

Readme

This will Install the Highlight Message Backgrounds Mod v1.1 by LHVWB.
This is the install process for SMF 1.1.5. If that is not your current SMF version then the Mod may not work, although it should work for SMF 1.1.4.

This mod allows you to add colored highlighting to the background of every Post/PM made by certain membergroups.

I hope that you find this Mod useful,
LHVWB

File Edits

./Sources/Display.php

Find: [Select]
'member' => &$memberContext[$message['ID_MEMBER']],
Replace With: [Select]
'member' => &$memberContext[$message['ID_MEMBER']],
// Pass a Highlight Color, if we have a color for it.
'highlightcolor' => !empty($modSettings['HighlightMessageBackgrounds_post']) && !empty($board_info['highlight']) ? (empty($memberContext[$message['ID_MEMBER']]['id']) && !empty($modSettings['HMB_-1']) ? $modSettings['HMB_-1'] : (!empty($memberContext[$message['ID_MEMBER']]['id']) ? (!empty($modSettings['HMB_3']) && !empty($board_info['moderators'][$message['ID_MEMBER']]) && ($memberContext[$message['ID_MEMBER']]['group_id'] == 0) ? $modSettings['HMB_3'] : (!empty($modSettings['HMB_'.$memberContext[$message['ID_MEMBER']]['group_id']]) ? $modSettings['HMB_'.$memberContext[$message['ID_MEMBER']]['group_id']] : '')) : '')) : '',

Find: [Select]
// Compose the memory eat- I mean message array.
$output = array(
Replace With: [Select]
global $board_info;
// Compose the memory eat- I mean message array.
$output = array(

./Sources/PersonalMessage.php

Find: [Select]
'member' => &$memberContext[$message['ID_MEMBER_FROM']],
Replace With: [Select]
'member' => &$memberContext[$message['ID_MEMBER_FROM']],
// Pass a Highlight Color, if its not a guest and we have a color for it.
'highlightcolor' => !empty($modSettings['HighlightMessageBackgrounds_pm']) && !empty($memberContext[$message['ID_MEMBER_FROM']]['id']) && !empty($modSettings['HMB_'.$memberContext[$message['ID_MEMBER_FROM']]['group_id']]) ? $modSettings['HMB_'.$memberContext[$message['ID_MEMBER_FROM']]['group_id']] : '',

./Sources/ManagePosts.php

Find: [Select]
'topics' => array('ModifyTopicSettings', 'admin_forum'),
Replace With: [Select]
'topics' => array('ModifyTopicSettings', 'admin_forum'),
// Add the sub action for the Highlight Message Backgrounds Mod.
'highlightmessagebackgrounds' => array('HighlightMessageBackgrounds', 'admin_forum'),

Find: [Select]

if (allowedTo('admin_forum'))
$context['admin_tabs']['tabs'][] = array(
'title' => $txt['manageposts_topic_settings'],
'description' => $txt['manageposts_topic_settings_description'],
'href' => $scripturl . '?action=postsettings;sa=topics',
'is_selected' => $_REQUEST['sa'] == 'topics',
'is_last' => true,
);
Replace With: [Select]

if (allowedTo('admin_forum'))
$context['admin_tabs']['tabs'][] = array(
'title' => $txt['manageposts_topic_settings'],
'description' => $txt['manageposts_topic_settings_description'],
'href' => $scripturl . '?action=postsettings;sa=topics',
'is_selected' => $_REQUEST['sa'] == 'topics',
'is_last' => true,
);
if (allowedTo('admin_forum'))
$context['admin_tabs']['tabs'][] = array(
'title' => $txt['HighlightMessageBackgrounds_tab_heading'],
'description' => $txt['HighlightMessageBackgrounds_description'],
'href' => $scripturl . '?action=postsettings;sa=highlightmessagebackgrounds;',
'is_selected' => $_REQUEST['sa'] == 'highlightmessagebackgrounds',
'is_last' => true,
);

Find (at the end of the file): [Select]
?>
Add Before: [Select]

// Fucntion to handle the settings for the Highlight Search Keywords Mod.
function HighlightMessageBackgrounds()
{
global $txt, $scripturl, $context, $sourcedir, $db_prefix;

// Start with the general settings for this mod.
$config_vars = array(
array('check', 'HighlightMessageBackgrounds_post'),
array('check', 'HighlightMessageBackgrounds_pm'),
'',
$txt['HighlightMessageBackgrounds_colors'],
);

$temp_settings = array();

// Go through and add each membergroup to the config_vars list.
foreach(get_HighlightMessageBackgrounds_membergroups() as $group_id => $group_name)
{
$config_vars[] = array('text', 'HMB_'.$group_id, 6, $group_name);
$temp_settings[] = 'HMB_'.$group_id;
}

// Include the ManageServer.php file so that we can setup and save the settings.
require_once($sourcedir.'/ManageServer.php');

if (isset($_GET['save']))
{
// Remove any invalid values.
foreach($config_vars as $id => $setting)
{
// Remove a color if its not Hexadecimal.
if(is_array($setting)
&& (substr($setting[1], 0, 4) == 'HMB_')
&& !(empty($_REQUEST[$setting[1]])
|| preg_match('/[0-9a-fA-F]{6}/', $_REQUEST[$setting[1]])))
unset($config_vars[$id]);
}

saveDBSettings($config_vars);
redirectexit('action=postsettings;sa=highlightmessagebackgrounds;');
}

// Also delete any old settings.
db_query("
DELETE FROM {$db_prefix}settings
WHERE variable
LIKE 'HMB_%'
AND variable
NOT IN ('" . implode("', '", $temp_settings) . "')", __FILE__, __LINE__
);

// Set up some variables needed by the template.
$context['post_url'] = $scripturl . '?action=postsettings;save;sa=highlightmessagebackgrounds;';
$context['settings_title'] = $txt['HighlightMessageBackgrounds_tab_heading'];
$context['sub_template'] = 'show_settings';
$context['page_title'] = $txt['HighlightMessageBackgrounds_tab_heading'];

// Setup the config vars for the template.
prepareDBSettingContext($config_vars);
}

// Simple function to return all the non-post membergroups.
function get_HighlightMessageBackgrounds_membergroups()
{
global $db_prefix, $modSettings, $txt;

$membergroups = array();

// Fix up a few errors that occur, by adding members to the list.
loadLanguage('Admin');
$membergroups[-1] = $txt['membergroups_guests'];
$membergroups[0] = $txt['membergroups_members'];

// Get the permissions from the table, only get primary ones.
$request = db_query("
SELECT ID_GROUP, groupName
FROM {$db_prefix}membergroups
WHERE minPosts = -1", __FILE__, __LINE__
);

// Store the data in a way that is easy to use. Permission => array (id_groups)
while ($row = mysql_fetch_assoc($request))
$membergroups[$row['ID_GROUP']] = $row['groupName'];

// Don't forget to free the request!!!
mysql_free_result($request);

return $membergroups;
}

./Sources/Subs-Boards.php

Find: [Select]
// Getting all the board and category information you'd ever wanted.
$request = db_query("
SELECT
IFNULL(b.ID_BOARD, 0) AS ID_BOARD, b.ID_PARENT, b.name AS bName, b.description, b.childLevel,
b.boardOrder, b.countPosts, b.memberGroups, b.ID_THEME, b.override_theme,
Replace With: [Select]
// Getting all the board and category information you'd ever wanted.
$request = db_query("
SELECT
IFNULL(b.ID_BOARD, 0) AS ID_BOARD, b.ID_PARENT, b.name AS bName, b.description, b.childLevel,
b.boardOrder, b.countPosts, b.memberGroups, b.ID_THEME, b.override_theme, b.highlight,

Find: [Select]
'override_theme' => $row['override_theme'],
Replace With: [Select]
'override_theme' => $row['override_theme'],
'highlight' => $row['highlight'],

Find: [Select]
// Should the board theme override the user preferred theme?
if (isset($boardOptions['override_theme']))
$boardUpdates[] = 'override_theme = ' . ($boardOptions['override_theme'] ? '1' : '0');
Replace With: [Select]
// Should the board theme override the user preferred theme?
if (isset($boardOptions['override_theme']))
$boardUpdates[] = 'override_theme = ' . ($boardOptions['override_theme'] ? '1' : '0');

// Do we need message highlighting for this board?
if (isset($boardOptions['highlight']))
$boardUpdates[] = 'highlight = ' . ($boardOptions['highlight'] ? '1' : '0');

Find: [Select]
'override_theme' => false,
Replace With: [Select]
'override_theme' => false,
'highlight' => true,

./Sources/ManageBoards.php

Find: [Select]
'override_theme' => 0,
Replace With: [Select]
'highlight' => 1,
'override_theme' => 0,

Find: [Select]
$boardOptions['override_theme'] = isset($_POST['override_theme']);
Replace With: [Select]
$boardOptions['override_theme'] = isset($_POST['override_theme']);
$boardOptions['highlight'] = isset($_POST['highlight']);

./Sources/Load.php

Find: [Select]
$request = db_query("
SELECT
c.ID_CAT, b.name AS bname, b.description, b.numTopics, b.memberGroups,
Replace With: [Select]
$request = db_query("
SELECT
c.ID_CAT, b.name AS bname, b.description, b.numTopics, b.memberGroups, b.highlight,

Find: [Select]
'override_theme' => !empty($row['override_theme']),
Replace With: [Select]
'override_theme' => !empty($row['override_theme']),
'highlight' => !empty($row['highlight']),

./Themes/default/Display.template.php

Find: [Select]
// Show information about the poster of this message.
echo '
<table width="100%" cellpadding="5" cellspacing="0" style="table-layout: fixed;">
Replace With: [Select]
// Show information about the poster of this message. Also Highlight the Background if necessary.
echo '
<table width="100%" cellpadding="5" cellspacing="0" style="table-layout: fixed;', !empty($message['highlightcolor']) ? 'background-color:#'.$message['highlightcolor'].';' : '', '">

./Themes/default/PersonalMessage.template.php

Find: [Select]
<table width="100%" cellpadding="4" cellspacing="1" style="table-layout: fixed;">
Replace With: [Select]
<table width="100%" cellpadding="4" cellspacing="1" style="table-layout: fixed;', !empty($message['highlightcolor']) ? 'background-color:#'.$message['highlightcolor'].';' : '', '">

Find: [Select]
<td class="', $windowcss, '" valign="top" width="85%" height="100%">
Replace With: [Select]
<td class="', $windowcss, '" valign="top" width="85%" height="100%" ', !empty($message['highlightcolor']) ? 'style="background-color:#'.$message['highlightcolor'].';"' : '', '>

Find: [Select]
<tr class="', $windowcss, '">
<td valign="bottom" class="smalltext" width="85%">
Replace With: [Select]
<tr class="', $windowcss, '" ', !empty($message['highlightcolor']) ? 'style="background-color:#'.$message['highlightcolor'].';"' : '', '>
<td valign="bottom" class="smalltext" width="85%">

./Themes/default/ManageBoards.template.php

Find: [Select]
// Finish off the table.
echo '
<tr>
<td colspan="2" align="right">
<br />';
Replace With: [Select]
// Here the user can choose whether or not this board needs Message Highlighting or not.
echo '
<tr>
<td>
<b>', $txt['HighlightMessageBackgrounds_post'], '</b><br />
</td>
<td valign="top" align="right">
<input type="checkbox" name="highlight"', $context['board']['highlight'] ? ' checked="checked"' : '', ' class="check" />
</td>
</tr>';
// Finish off the table.
echo '
<tr>
<td colspan="2" align="right">
<br />';

./Themes/default/languages/Modifications.english.php

Find (at the end of the file): [Select]
?>
Add Before: [Select]

// Highlight Message Backgrounds Mod Text.
$txt['HighlightMessageBackgrounds_tab_heading'] = 'Highlight Message Backgrounds';
$txt['HighlightMessageBackgrounds_post'] = 'Highlight Post Backgrounds?';
$txt['HighlightMessageBackgrounds_pm'] ='Highlight PM Backgrounds?';
$txt['HighlightMessageBackgrounds_colors'] = 'MemberGroup Colors (In RGB Hexadecimal):';
$txt['HighlightMessageBackgrounds_description'] = 'These settings relate to the Highlight Message Backgrounds Mod. <br />Remember that The Highlight Message Background Color Codes must be 6 characters long in Hexadecimal with no spaces, using <a href="http://en.wikipedia.org/wiki/Web_colors">RGB Hexadecimal Web Color Codes</a>.';

./Themes/default/languages/Modifications.english-utf8.php

Find (at the end of the file): [Select]
?>
Add Before: [Select]

// Highlight Message Backgrounds Mod Text.
$txt['HighlightMessageBackgrounds_tab_heading'] = 'Highlight Message Backgrounds';
$txt['HighlightMessageBackgrounds_post'] = 'Highlight Post Backgrounds?';
$txt['HighlightMessageBackgrounds_pm'] = 'Highlight PM Backgrounds?';
$txt['HighlightMessageBackgrounds_colors'] = 'Highlight Message Background Colors (Hexadecimal):';
$txt['HighlightMessageBackgrounds_description'] = 'These settings relate to the Highlight Message Backgrounds Mod. <br />Remember that The Highlight Message Background Color Codes must be 6 characters long in Hexadecimal with no spaces, using <a href="http://en.wikipedia.org/wiki/Web_colors">RGB Hexadecimal Web Color Codes</a>.';
This operation isn't vital to the installation of this mod.

Code

install-smf1.1.5.php

This file should be able to execute standalone.