##############################################################
## :  / Bookmarks
## : DanielT < daniel@danielt.com > (Daniel Taylor) http://www.danielt.com
##		  TorrentPier II: TorrentPier.me
## :       
##
## : 1.0.2 / 0.1.0b  TorrentPier II
##
## C : 
##
## ,   : ~ 5 
##
##  : ajax/manage_user.php,
##      viewtopic.php,
##      includes/init_bb.php,
##      includes/page_header.php,
##	templates/default/page_header.tpl,
##	templates/default/viewtopic.tpl,
##	language/lang_russian/lang_main.php
##
##  : bookmarks.php, book_body.tpl
##############################################################
##    ,       ,    
##############################################################

#
#-----[ SQL ]------------------------------------------
#
CREATE TABLE `bb_bookmarks` ( 
`book_id` int(11) NOT NULL auto_increment, 
`user_id` int(11) NOT NULL default '0', 
`topic_id` int(11) NOT NULL default '0',
`forum_id` int(11) NOT NULL default '0', 
PRIMARY KEY (`book_id`)) 
#
#-----[   ]------------------------------------------
#

 root/bookmarks.php to bookmarks.php
 root/templates/default/book_body.tpl to templates/default/book_body.tpl

#
#-----[  ]------------------------------------------
#

ajax/manage_user.php

#
#-----[  ]------------------------------------------
# 
				user_delete($user_id);
#
#-----[   ]------------------------------------------
# 
				// Bookmarks
				$sql = "DELETE FROM " . BB_BOOKMARKS . "
					WHERE user_id = $user_id";
				if ( !DB()->sql_query($sql) )
				{
					message_die(GENERAL_ERROR, 'Could not delete user from bookmarks table', '', __LINE__, __FILE__, $sql);
				}
				// Bookmarks [END]
				
#
#-----[  ]------------------------------------------
#

includes/init_bb.php

#
#-----[  ]------------------------------------------
# 
define('BB_VOTE_USERS',           'bb_vote_voters');
#
#-----[   ]------------------------------------------
# 
// Bookmarks
define('BB_BOOKMARKS',            'bb_bookmarks');
// Bookmarks [END]

#
#-----[  ]------------------------------------------
#

includes/page_header.php

#
#-----[  ]------------------------------------------
# 
	'U_TRACKER'          => "tracker.php",
#
#-----[   ]------------------------------------------
# 
	// Bookmarks
	'L_BOOK' => $lang['BOOKMARKS'],
	'U_BOOK' => append_sid('bookmarks.php'),
	// Bookmarks [END]
			
#
#-----[  ]------------------------------------------
#

viewtopic.php

#
#-----[  ]------------------------------------------
#
//
// Send vars to template
//
#
#-----[   ]------------------------------------------
# 
// Bookmarks
if ($userdata['session_logged_in']) {
	
	$sql = "SELECT *
		FROM " . BB_BOOKMARKS . "
		WHERE user_id = '" . $userdata['user_id'] . "' AND topic_id = '" . intval($topic_id) ."'";

	$result = DB()->sql_query($sql);

	$num_row = DB()->num_rows($result);
	
	if (intval($num_row) == 0) {
		$template->assign_vars(array(
			'U_BOOKMARK' => "<a href=\"". append_sid("bookmarks.php?t=" . $topic_id . "&amp;f=" . $forum_id . "&amp;mode=add" . "\">" . $lang['ADD_BOOK'] . "</a>")) 
		);
	}
	else {
		$template->assign_vars(array(
			'U_BOOKMARK' => "<a href=\"". append_sid("bookmarks.php?t=" . $topic_id . "&amp;f=" . $forum_id . "&amp;mode=remove" . "\">" . $lang['REMOVE_BOOK'] . "</a>")) 
		);
	}

}
// Bookmarks [END]

#
#-----[  ]------------------------------------------
#

templates/default/page_header.tpl

#
#-----[  ]------------------------------------------
#
			<a href="{U_MEMBERLIST}"><b>{L_MEMBERLIST}</b></a>
#
#-----[   ]------------------------------------------
#
			<!-- Bookmarks -->
			<a href="{U_BOOK}"><b>{L_BOOK}</b></a>&#0183;
			<!-- Bookmarks [END] -->

#
#-----[  ]------------------------------------------
#

templates/default/viewtopic.tpl

#
#-----[  ]------------------------------------------
#
<tr>
	<td valign="bottom">
		<a href="{U_POST_REPLY_TOPIC}"><img src="{REPLY_IMG}" alt="{T_POST_REPLY}" /></a>
	</td>
	<td class="nav w100" style="padding-left: 8px;">
		<a href="{U_INDEX}">{T_INDEX}</a>
		<!-- IF HAS_PARENT_FORUM --> <em>&raquo;</em>&nbsp;<a href="{PARENT_FORUM_HREF}">{PARENT_FORUM_NAME}</a><!-- ENDIF -->
		<em>&raquo;</em>&nbsp;<a href="{U_VIEW_FORUM}">{FORUM_NAME}</a>
	</td>
#
#-----[   ]------------------------------------------
#
	<!-- Bookmarks -->
	<td class="nav w100 nowrap tRight">
		{U_BOOKMARK}
	</td>
	<!-- Bookmarks [END] -->

#
#-----[  ]------------------------------------------
#

language/lang_russian/lang_main.php

#
#-----[  ]------------------------------------------
#
?>
#
#-----[   ]------------------------------------------
# 
//
// Bookmarks
//
$lang['REMOVE_BOOK_DATA'] = '     ';
$lang['INSERT_BOOK_DATA'] = '     ';
$lang['NO_BOOK_TOPIC'] = '     !';
$lang['BOOKMARKS'] = '';
$lang['ADD_BOOK'] = '  ';
$lang['REMOVE_BOOK'] = ' ';
$lang['BOOKMARK_ADDED'] = " ";
$lang['BOOKMARK_REMOVED'] = " ";
$lang['CLICK_RETURN_BOOKMARKS'] = "%s%s    ";
$lang['EXIST_BOOK'] = "     !";
$lang['NO_BOOKMARKS'] = "   !";
//
// Bookmarks [END]
//
#
#-----[  ]------------------------------------------
#

language/lang_english/lang_main.php

#
#-----[  ]------------------------------------------
#
?>
#
#-----[   ]------------------------------------------
# 
//
// Bookmarks
//
$lang['REMOVE_BOOK_DATA'] = 'Could not remove data from bookmarks table';
$lang['INSERT_BOOK_DATA'] = 'Could not insert data into bookmarks table';
$lang['NO_BOOK_TOPIC'] = 'No topic was selected!';
$lang['BOOKMARKS'] = 'Bookmarks';
$lang['ADD_BOOK'] = 'Bookmark topic';
$lang['REMOVE_BOOK'] = 'Remove Bookmark';
$lang['BOOKMARK_ADDED'] = "Topic has been added to bookmarks";
$lang['BOOKMARK_REMOVED'] = "Topic has been removed from bookmarks";
$lang['CLICK_RETURN_BOOKMARKS'] = "Click %sHere%s to return to bookmarks";
$lang['EXIST_BOOK'] = "This topic is already in your bookmarks!";
$lang['NO_BOOKMARKS'] = "You have no bookmarks!";
//
// Bookmarks [END]
//
#
#-----[ /   ]------------------------------------------
#
# !