Mod Name:Favourite (Favorite) Boards
http://custom.simplemachines.org/mods/index.php?mod=2163File Edits./index.phpFind:
'findmember' => array('Subs-Auth.php', 'JSMembers'),
Add Before:
'favourite' => array('Favourite.php', 'SetFavourite'),
./Sources/Subs-BoardIndex.phpFind:
// Find all boards
Add Before:
// Get the user's favourite boards
$context['fav_boards'] = array();
$query = $smcFunc['db_query']('', '
SELECT f.id_board FROM {db_prefix}boards b INNER JOIN {db_prefix}favourite_boards f ON (f.id_board = b.id_board) WHERE {query_see_board} AND f.id_member = {int:id_member}
',
array(
'id_member' => $user_info['id'],
)
);
while($row = $smcFunc['db_fetch_row']($query)) {
$context['fav_boards'][] = $row[0];
}
$smcFunc['db_free_result']($query);
Find:
// Run through the categories
Add Before:
if ($boardIndexOptions['include_categories'] && !$context['user']['is_guest'])
$categories[0] = array(
'id' => 0,
'name' => $txt['my_fav'],
'is_collapsed' => false,
'can_collapse' => false,
'collapse_href' => '',
'collapse_image' => '',
'href' => $scripturl . '#c0',
'boards' => array(),
'new' => false,
'link' => '<a name="c0" href="' . $scripturl . '#c0">' . $txt['my_fav'] . '</a>',
);
Find:
// This is a parent board.
Add Before:
// Add favourite boards to our magic category
if ($boardIndexOptions['include_categories'] && !$context['user']['is_guest']) {
if (!isset($categories[0]['boards'][$row_board['id_board']]) && in_array($row_board['id_board'], $context['fav_boards'])) {
$categories[0]['boards'][$row_board['id_board']] = array(
'new' => empty($row_board['is_read']),
'id' => $row_board['id_board'],
'name' => $row_board['board_name'],
'description' => $row_board['description'],
'moderators' => array(),
'link_moderators' => array(),
'children' => array(),
'link_children' => array(),
'children_new' => false,
'topics' => $row_board['num_topics'],
'posts' => $row_board['num_posts'],
'is_redirect' => $row_board['is_redirect'],
'unapproved_topics' => $row_board['unapproved_topics'],
'unapproved_posts' => $row_board['unapproved_posts'] - $row_board['unapproved_topics'],
'can_approve_posts' => !empty($user_info['mod_cache']['ap']) && ($user_info['mod_cache']['ap'] == array(0) || in_array($row_board['id_board'], $user_info['mod_cache']['ap'])),
'href' => $scripturl . '?board=' . $row_board['id_board'] . '.0',
'link' => '<a href="' . $scripturl . '?board=' . $row_board['id_board'] . '.0">' . $row_board['board_name'] . '</a>' . fav_links($row_board['id_board'])
);
censorText($row_board['subject']);
$row_board['short_subject'] = shorten_subject($row_board['subject'], 24);
$this_last_post = array(
'id' => $row_board['id_msg'],
'time' => $row_board['poster_time'] > 0 ? timeformat($row_board['poster_time']) : $txt['not_applicable'],
'timestamp' => forum_time(true, $row_board['poster_time']),
'subject' => $row_board['short_subject'],
'member' => array(
'id' => $row_board['id_member'],
'username' => $row_board['poster_name'] != '' ? $row_board['poster_name'] : $txt['not_applicable'],
'name' => $row_board['real_name'],
'href' => $row_board['poster_name'] != '' && !empty($row_board['id_member']) ? $scripturl . '?action=profile;u=' . $row_board['id_member'] : '',
'link' => $row_board['poster_name'] != '' ? (!empty($row_board['id_member']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row_board['id_member'] . '">' . $row_board['real_name'] . '</a>' : $row_board['real_name']) : $txt['not_applicable'],
),
'start' => 'msg' . $row_board['new_from'],
'topic' => $row_board['id_topic']
);
// Provide the href and link.
if ($row_board['subject'] != '')
{
$this_last_post['href'] = $scripturl . '?topic=' . $row_board['id_topic'] . '.msg' . ($user_info['is_guest'] ? $row_board['id_msg'] : $row_board['new_from']) . (empty($row_board['is_read']) ? ';boardseen' : '') . '#new';
$this_last_post['link'] = '<a href="' . $this_last_post['href'] . '" title="' . $row_board['subject'] . '">' . $row_board['short_subject'] . '</a>';
}
else
{
$this_last_post['href'] = '';
$this_last_post['link'] = $txt['not_applicable'];
}
$categories[0]['boards'][$row_board['id_board']]['last_post'] = $this_last_post;
}
}
Find:
$row_board['board_name'] . '</a>'
Replace With:
$row_board['board_name'] . '</a>' . fav_links($row_board['id_board'])
Find:
$row_board['board_name'] . '</a>'
Replace With:
$row_board['board_name'] . '</a>' . fav_links($row_board['id_board'])
Find (at the end of the file):
?>
Add Before:
function fav_links($board_id, $return_to = 0) {
global $context, $txt, $scripturl, $settings;
if($context['user']['is_guest'])
return '';
$redirect = $return_to != 0 ? ';return=' . $return_to : '';
if(in_array($board_id, $context['fav_boards'])) {
return ' <a href="' . $scripturl . '?action=favourite;sa=remove;board=' . $board_id . $redirect . '" title="' . $txt['rem_fav'] . '"><img src="' . $settings['images_url'] . '/fav_remove.gif" width="14" height="14" border="0"></a>';
} else {
return ' <a href="' . $scripturl . '?action=favourite;sa=add;board=' . $board_id . $redirect . '" title="' . $txt['add_fav'] . '"><img src="' . $settings['images_url'] . '/fav_add.gif" width="14" height="14" border="0"></a>';
}
}
./Themes/default/BoardIndex.template.phpFind:
$board['name'], '</a>';
Replace With:
$board['name'], '</a>', fav_links($board['id']);
Find:
// Has it posts awaiting approval?
Add Before:
$child['link'] .= fav_links($child['id']);
Find:
if (!$context['user']['is_guest'] && !empty($category['show_unread']))
echo '
<a class="unreadlink" href="', $scripturl, '?action=unread;c=', $category['id'], '">', $txt['view_unread_category'], '</a>';
Replace With:
if (!$context['user']['is_guest'] && (($category['id'] == 0 && count($context['fav_boards']) > 0) || (!empty($category['show_unread']))))
echo '
<a class="unreadlink" href="', $scripturl, '?action=unread;c=', ($category['id'] != 0 ? $category['id'] : implode(',', $context['fav_boards'])), '">', $txt['view_unread_category'], '</a>';
./Themes/default/MessageIndex.template.phpFind:
$board['name'], '</a>';
Replace With:
$board['name'], '</a>', fav_links($board['id'], $context['current_board']);
./Themes/default/languages/Modifications.english.phpFind (at the end of the file):
?>
Add Before:
$txt['my_fav'] = 'My Favorite Boards';
$txt['add_fav'] = 'Add Favorite';
$txt['rem_fav'] = 'Remove Favorite';
./Themes/default/languages/Modifications.english-utf8.phpFind (at the end of the file):
?>
Add Before:
$txt['my_fav'] = 'My Favorite Boards';
$txt['add_fav'] = 'Add Favorite';
$txt['rem_fav'] = 'Remove Favorite';
This operation isn't vital to the installation of this mod.
Codesmf2rc2/install20.php
This file should be able to execute standalone.
File OperationsMove the included file "smf2/Favourite.php" to "./Sources".
Move the included file "fav_add.gif" to "./Themes/default/images".
Move the included file "fav_remove.gif" to "./Themes/default/images".