How to add Subscribed Threads & Notepad to the UserCP
#11
(2009-12-20, 01:21 AM)Air The Star Wrote: hack works 50/100 why?

help?

If you use the original "subscribed threads" link, then does your (1) thread show up OK?
Generally, this hack does work 100%, I had minor trouble just once, and can't remember all the details.

(2009-12-19, 05:11 PM)cscomputing Wrote: Nice this works in 1.4.10 fine.

Yes, this is one of my favorite modifications to use, glad you like it.
#
MyBB is the best forum software! Exclamation

Reply
#12
Well I edit my templates and set "auto subscribed threads" as default...

some tip for do it work 100%?
Reply
#13
Did you try the original, standard "subscribed threads" link & is that working OK?

(2009-12-20, 03:24 AM)Air The Star Wrote: ...some tip for do it work 100%?
There is always a way to make things work:
(Here is one example)

Since I know for certain the hack works:
First, I would start over with a fresh file and a reverted template (be careful to check if you, or any plugins, made other changes to your template)

Then, I'd carefully follow the two steps again, expecting it will work this time.
I hope you can get it working.
#
MyBB is the best forum software! Exclamation

Reply
#14
(2008-11-22, 02:42 PM)DragonFever Wrote: Open your usercp.php

Find following line:
// Format username

Add above:
// Do Multi Pages
	$query = $db->simple_select("threadsubscriptions", "COUNT(tid) AS threads", "uid='".$mybb->user['uid']."'");
	$threadcount = $db->fetch_field($query, "threads");

	if(!$mybb->settings['threadsperpage'])
	{
		$mybb->settings['threadsperpage'] = 20;
	}

	$perpage = $mybb->settings['threadsperpage'];
	$page = intval($mybb->input['page']);
	if($page > 0)
	{
		$start = ($page-1) *$perpage;
	}
	else
	{
		$start = 0;
		$page = 1;
	}
	$end = $start + $perpage;
	$lower = $start+1;
	$upper = $end;
	if($upper > $threadcount)
	{
		$upper = $threadcount;
	}
	$multipage = multipage($threadcount, $perpage, $page, "usercp.php?action=subscriptions");
	$fpermissions = forum_permissions();

	// Fetch subscriptions
	$query = $db->query("
		SELECT s.*, t.*, t.username AS threadusername, u.username
		FROM ".TABLE_PREFIX."threadsubscriptions s
		LEFT JOIN ".TABLE_PREFIX."threads t ON (s.tid=t.tid)
		LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid = t.uid)
		WHERE s.uid='".$mybb->user['uid']."'
		ORDER BY t.lastpost DESC
		LIMIT $start, $perpage
	");
	while($subscription = $db->fetch_array($query))
	{
		$forumpermissions = $fpermissions[$subscription['fid']];
		// Only keep if we're allowed to view them
		if($forumpermissions['canview'] != 0 || $forumpermissions['canviewthreads'] != 0)
		{
			$subscriptions[$subscription['tid']] = $subscription;
		}
		// Hmm, you don't have permission to view - unsubscribe!
		else if($subscription['tid'])
		{
			$del_subscriptions[] = $subscription['tid'];
		}
	}

	if(is_array($del_subscriptions))
	{
		$tids = implode(',', $del_subscriptions);
		if($tids)
		{
			$db->delete_query("threadsubscriptions", "tid IN ({$tids}) AND uid='{$mybb->user['uid']}'");
		}
	}

	if(is_array($subscriptions))
	{
		$tids = implode(",", array_keys($subscriptions));
		
		if($mybb->user['uid'] == 0)
		{
			// Build a forum cache.
			$query = $db->query("
				SELECT fid
				FROM ".TABLE_PREFIX."forums
				WHERE active != 0
				ORDER BY pid, disporder
			");
			
			$forumsread = unserialize($mybb->cookies['mybb']['forumread']);
		}
		else
		{
			// Build a forum cache.
			$query = $db->query("
				SELECT f.fid, fr.dateline AS lastread
				FROM ".TABLE_PREFIX."forums f
				LEFT JOIN ".TABLE_PREFIX."forumsread fr ON (fr.fid=f.fid AND fr.uid='{$mybb->user['uid']}')
				WHERE f.active != 0
				ORDER BY pid, disporder
			");
		}
		while($forum = $db->fetch_array($query))
		{
			if($mybb->user['uid'] == 0)
			{
				if($forumsread[$forum['fid']])
				{
					$forum['lastread'] = $forumsread[$forum['fid']];
				}
			}
			$readforums[$forum['fid']] = $forum['lastread'];
		}

		// Check participation by the current user in any of these threads - for 'dot' folder icons
		if($mybb->settings['dotfolders'] != 0)
		{
			$query = $db->simple_select("posts", "tid,uid", "uid='{$mybb->user['uid']}' AND tid IN ({$tids})");
			while($post = $db->fetch_array($query))
			{
				$subscriptions[$post['tid']]['doticon'] = 1;
			}
		}

		// Read threads
		if($mybb->settings['threadreadcut'] > 0)
		{
			$query = $db->simple_select("threadsread", "*", "uid='{$mybb->user['uid']}' AND tid IN ({$tids})");
			while($readthread = $db->fetch_array($query))
			{
				$subscriptions[$readthread['tid']]['lastread'] = $readthread['dateline'];
			}
		}

		// Now we can build our subscription list
		foreach($subscriptions as $thread)
		{
			$bgcolor = alt_trow();

			$folder = '';
			$prefix = '';

			// Sanitize
			$thread['subject'] = $parser->parse_badwords($thread['subject']);
			$thread['subject'] = htmlspecialchars_uni($thread['subject']);

			// Build our links
			$thread['threadlink'] = get_thread_link($thread['tid']);
			$thread['lastpostlink'] = get_thread_link($thread['tid'], 0, "lastpost");

			// Fetch the thread icon if we have one
			if($thread['icon'] > 0 && $icon_cache[$thread['icon']])
			{
				$icon = $icon_cache[$thread['icon']];
				$icon = "<img src=\"{$icon['path']}\" alt=\"{$icon['name']}\" />";
			}
			else
			{
				$icon = "&nbsp;";
			}

			// Determine the folder
			$folder = '';
			$folder_label = '';

			if($thread['doticon'])
			{
				$folder = "dot_";
				$folder_label .= $lang->icon_dot;
			}

			$gotounread = '';
			$isnew = 0;
			$donenew = 0;
			$lastread = 0;

			if($mybb->settings['threadreadcut'] > 0 && $mybb->user['uid'])
			{
				$forum_read = $readforums[$thread['fid']];
			
				$read_cutoff = TIME_NOW-$mybb->settings['threadreadcut']*60*60*24;
				if($forum_read == 0 || $forum_read < $read_cutoff)
				{
					$forum_read = $read_cutoff;
				}
			}
			else
			{
				$forum_read = $forumsread[$thread['fid']];
			}

			if($mybb->settings['threadreadcut'] > 0 && $thread['lastpost'] > $forum_read)
			{
				$cutoff = TIME_NOW-$mybb->settings['threadreadcut']*60*60*24;
			}

			if($thread['lastpost'] > $cutoff)
			{
				if($thread['lastpost'] > $cutoff)
				{
					if($thread['lastread'])
					{
						$lastread = $thread['lastread'];
					}
					else
					{
						$lastread = 1;
					}
				}
			}

			if(!$lastread)
			{
				$readcookie = $threadread = my_get_array_cookie("threadread", $thread['tid']);
				if($readcookie > $forum_read)
				{
					$lastread = $readcookie;
				}
				else
				{
					$lastread = $forum_read;
				}
			}

			if($thread['lastpost'] > $lastread && $lastread)
			{
				$folder .= "new";
				$folder_label .= $lang->icon_new;
				$new_class = "subject_new";
				$thread['newpostlink'] = get_thread_link($thread['tid'], 0, "newpost");
				eval("\$gotounread = \"".$templates->get("forumdisplay_thread_gotounread")."\";");
				$unreadpost = 1;
			}
			else
			{
				$folder_label .= $lang->icon_no_new;
				$new_class = "";
			}

			if($thread['replies'] >= $mybb->settings['hottopic'] || $thread['views'] >= $mybb->settings['hottopicviews'])
			{
				$folder .= "hot";
				$folder_label .= $lang->icon_hot;
			}

			if($thread['closed'] == 1)
			{
				$folder .= "lock";
				$folder_label .= $lang->icon_lock;
			}

			$folder .= "folder";

			// Build last post info

			$lastpostdate = my_date($mybb->settings['dateformat'], $thread['lastpost']);
			$lastposttime = my_date($mybb->settings['timeformat'], $thread['lastpost']);
			$lastposter = $thread['lastposter'];
			$lastposteruid = $thread['lastposteruid'];

			// Don't link to guest's profiles (they have no profile).
			if($lastposteruid == 0)
			{
				$lastposterlink = $lastposter;
			}
			else
			{
				$lastposterlink = build_profile_link($lastposter, $lastposteruid);
			}

			$thread['replies'] = my_number_format($thread['replies']);
			$thread['views'] = my_number_format($thread['views']);

			// What kind of notification type do we have here?
			switch($thread['notification'])
			{
				case "1": // Instant
					$notification_type = $lang->instant_notification;
					break;
				default: // No notification
					$notification_type = $lang->no_notification;
			}

			eval("\$threads .= \"".$templates->get("usercp_subscriptions_thread")."\";");
		}
	}
	else
	{
		eval("\$threads = \"".$templates->get("usercp_subscriptions_none")."\";");
	}
	eval("\$subscriptions = \"".$templates->get("usercp_subscriptions")."\";");

Save the file and upload.

Go to your AdminCP => Templates => Your Theme => User Control Panel Templates => usercp

Replace whole content with following code:
<html>
<head>
<title>{$lang->user_cp}</title>
{$headerinclude}
</head>
<body>
{$header}
<table width="100%" border="0" align="center">
<tr>
{$usercpnav}
<td valign="top">
<table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder">
<tr>
<td class="thead" colspan="{$colspan}"><strong>{$lang->brief_summary}</strong></td>
</tr>
<tr>
{$avatar}
<td class="trow1" width="50%"><strong>{$lang->username}</strong></td>
<td class="trow1" width="50%">{$username}</td>
</tr>
<tr>
<td class="trow2" width="50%"><strong>{$lang->primary_usergroup}</strong></td>
<td class="trow2" width="50%">{$usergroup}</td>
</tr>
<tr>
<td class="trow1" width="50%"><strong>{$lang->registration_date}</strong></td>
<td class="trow1" width="50%">{$regdate}</td>
</tr>
<tr>
<td class="trow2" width="50%"><strong>{$lang->postnum}</strong></td>
<td class="trow2" width="50%"><a href="search.php?action=finduser&amp;uid={$mybb->user['uid']}">{$mybb->user['postnum']}</a> {$lang->posts_day}</td>
</tr>
<tr>
<td class="trow1" width="50%"><strong>{$lang->email}</strong></td>
<td class="trow1" width="50%">{$mybb->user['email']}</td>
</tr>
{$reputation}
</table>
{$latest_warnings}
<br />
{$multipage}
<form action="usercp.php" method="post" name="input">
<input type="hidden" name="my_post_key" value="{$mybb->post_code}" />
<input type="hidden" name="action" value="do_subscriptions" />
<table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder">
	<tr>
		<td class="thead" colspan="7"><strong>{$lang->subscriptions} ({$threadcount})</strong></td>
	</tr>
	<tr>
		<td class="tcat" align="center" colspan="2">&nbsp;</td>
		<td class="tcat" align="center"><span class="smalltext"><strong>{$lang->thread}</strong></span></td>
		<td class="tcat" align="center" width="7%"><span class="smalltext"><strong>{$lang->replies}</strong></span></td>
		<td class="tcat" align="center" width="7%"><span class="smalltext"><strong>{$lang->views}</strong></span></td>
		<td class="tcat" align="center" width="200"><span class="smalltext"><strong>{$lang->lastpost}</strong></span></td>
		<td class="tcat" align="center" width="1"><input name="allbox" title="Select All" type="checkbox" class="checkbox checkall" value="1" /></td>
	</tr>
	{$threads}
	<tr>
		<td class="tfoot" colspan="7">
			<div class="float_right"><strong>{$lang->with_selected}</strong>
				<select name="do">
					<option value="delete">{$lang->delete_subscriptions}</option>
					<option value="no_notification">{$lang->update_no_notification}</option>
					<option value="instant_notification">{$lang->instant_notification}</option>
				</select>
				{$gobutton}
			</div>
			<div>
				<strong><a href="usercp2.php?action=removesubscriptions&amp;my_post_key={$mybb->post_code}">{$lang->remove_all_subscriptions}</a></strong>
			</div>
		</td>
	</tr>
</table>
</form>
{$multipage}
<br />
<form action="usercp.php" method="post">
<input type="hidden" name="my_post_key" value="{$mybb->post_code}" />
<table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder">
<tr>
<td class="thead" colspan="2"><strong>{$lang->personal_notepad}</strong></td>
</tr>
<tr>
<td align="center" class="trow1" width="100%">
<textarea name="notepad" cols="80" rows="15">{$mybb->user['notepad']}</textarea>
</td>
</tr>
</table>
<br />
<div align="center">
<input type="hidden" name="action" value="do_notepad" />
<input type="submit" class="button" name="submit" value="{$lang->update_notepad}" />
</div>
</td>
</tr>
</table>
</form>
{$footer}
</body>
</html>

That's all.
Regards.

Thank you.
Worked like a charm.
[Image: 468x602b.png]
Reply
#15
You're welcome guysSmile
I'm seriously thinking about integrating this into my existing plugin: http://mods.mybboard.net/view/last-threa...-on-usercp-
ProPortal: A More Functional Portal.
Click here for detailed information.
Reply
#16
(2010-01-07, 11:59 AM)DragonFever Wrote: You're welcome guysSmile
I'm seriously thinking about integrating this into my existing plugin: http://mods.mybboard.net/view/last-threa...-on-usercp-
This would be great.
[Image: 468x602b.png]
Reply
#17
(2010-01-07, 12:26 PM)Skiilz Wrote:
(2010-01-07, 11:59 AM)DragonFever Wrote: You're welcome guysSmile
I'm seriously thinking about integrating this into my existing plugin: http://mods.mybboard.net/view/last-threa...-on-usercp-
This would be great.

Yes! I'll be waiting for it. Post here when it's done please XD

However, the subscribed threads may be too much.. I would go for the notepad only Wink
Reply
#18
Both notepad and subscribed threads make a great combo, IMO (not sure what it would look like with the rest of the plugin)
#
This is the only core file I ever edit, since the payoff is well worth the effort. Smile
#
MyBB is the best forum software! Exclamation

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)