I tried to do this myself and it didn't work out (at least not in 1.2.x)
In 1.4.x how would I:
1) Make the personal pad show by default in the user CP?
2) Make subscribed threads show by default in the user CP?
It should be very simple, but my first few attempts didn't work.
Thank you
EDIT:
I think this will be a bit harder than I first expected.
Adding variables like these {$usercp_notepad} and {$usercp_subscriptions_thread} to the userCP template isn't enough.
I also need to figure out the code to retrieve the info from the database.
You can do first option by doing a simple template modification but if you want to do second option too, you should add some codes to usercp.php.
If you want, i can show how to do these 2 modifications.
(2008-11-20, 07:55 PM)DragonFever Wrote: [ -> ]You can do first option by doing a simple template modification but if you want to do second option too, you should add some codes to usercp.php.
If you want, i can show how to do these 2 modifications.
Yes, please do.
Let's assume the standard theme is being used, to keep it simple.
Can you
"just post the code changes", or is it easier if I give you temporary admin access to a test site?
Thank you very much.
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 = " ";
}
// 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&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"> </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&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.
DragonFever, it looks fantastic, thanks so much.
aha, nice thread.
should be moved on tutorial forum
(2009-12-18, 07:54 AM)FBI Wrote: [ -> ]aha, nice thread.
should be moved on tutorial forum
Good idea, I also wish DragonFever was still around (EDIT: He was back just yesterday, welcome back DragonFever
).
I will ask a mod if they will move it, since this is really useful. Thanks, for the reminder FBI, this makes the default userCP area much better, IMO.
Nice this works in 1.4.10 fine.