Post: #1 [MyBB 1.6] prefixes on forum index [Last post]]
Walkman 5.0 Offline
Junior Member
**
Posts: 11
Joined: Mar 2010
Post: #1
Post: #1 [MyBB 1.6] prefixes on forum index [Last post]]
i tri to creathe this plugin
http://mybbhacks.zingaburga.com/showthread.php?tid=410

but i don have exit

any idea??

PHP Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
// Disallow direct access to this file for security reasons
if(!defined("IN_MYBB"))
{
	die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}


$plugins->add_hook("build_forumbits_forum", "prefixesonindex_start");
$plugins->add_hook("thread_prefixes_start", "prefixesonindex_start");


function prefixesonindex_info()
{
	
	return array(
		"name" => "POI",
		"description" => "Put the t prefix on the forum index.",
		"website" => "",
		"author" => "Solstice",
		"authorsite" => "",
		"version" => "1.0.5",
		"guid" => "*",
		"compatibility" => "16*"
	);
}


function prefixesonindex_activate()
{
	require_once MYBB_ROOT."/inc/adminfunctions_templates.php";
  find_replace_templatesets("forumbit_depth2_forum", "#".preg_quote("<td class=\"{\$bgcolor}\" valign=\"top\" align=\"right\" style=\"white-space: nowrap\">{\$lastpost}</td>")."#i", "<td class=\"{\$bgcolor}\" valign=\"top\" align=\"left\" style=\"white-space: nowrap\">{\$lastpost}</td>");
  find_replace_templatesets("forumbit_depth2_forum_lastpost", "#".preg_quote("<a href=\"{\$lastpost_link}\" title=\"{\$full_lastpost_subject}\"><strong>{\$lastpost_subject}</strong></a>")."#i", "{\$forum['lastpost_prefix']} <a href=\"{\$lastpost_link}\" title=\"{\$full_lastpost_subject}\"><strong>{\$lastpost_subject}</strong></a>");
  find_replace_templatesets("forumbit_depth2_forum_lastpost", "#<br(.*?)</span>#ism", "<br />{\$lang->by} <strong>{\$lastpost_profilelink}</strong><br />{\$lastpost_date} {\$lastpost_time}</span>");
}

function prefixesonindex_deactivate()
{
	require_once MYBB_ROOT."/inc/adminfunctions_templates.php";
  find_replace_templatesets("forumbit_depth2_forum", "#".preg_quote("<td class=\"{\$bgcolor}\" valign=\"top\" align=\"left\" style=\"white-space: nowrap\">{\$lastpost}</td>")."#i", "<td class=\"{\$bgcolor}\" valign=\"top\" align=\"right\" style=\"white-space: nowrap\">{\$lastpost}</td>", 0);
  find_replace_templatesets("forumbit_depth2_forum_lastpost", "#".preg_quote("{\$forum['lastpost_prefix']} <a href=\"{\$lastpost_link}\" title=\"{\$full_lastpost_subject}\"><strong>{\$lastpost_subject}</strong></a>")."#i", "<a href=\"{\$lastpost_link}\" title=\"{\$full_lastpost_subject}\"><strong>{\$lastpost_subject}</strong></a>", 0);
  find_replace_templatesets("forumbit_depth2_forum_lastpost", "#<br(.*?)</span>#ism", "<br />{\$lastpost_date} {\$lastpost_time}<br />{\$lang->by} {\$lastpost_profilelink}</span>", 0);

}


function prefixesonindex_start(&$forum) {

global $cache,$prefixes;
// GET THREAD PREFIX
$lastpost_prefix = "";
$thread = get_thread($forum['lastposttid']);
$prefix_cache = $cache->read("prefixes");
if($thread['prefix'] > 0 && $prefix_cache[$thread['prefix']])
{
$prefix = $prefix_cache[$thread['prefix']];
$forum['lastpost_prefix'] = "{$thread['prefix']}";
}
}

?>

(This post was last modified: 08-17-2010 01:33 PM by Walkman 5.0.)
08-17-2010 01:33 PM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #2
RE: Post: #1 [MyBB 1.6] prefixes on forum index [Last post]]
I don't think a "prefixes" cache exists, you need to query the DB for that.
Not that I like the idea, along with the fact you're using get_thread() in there, because it means there's potentially two queries being run in a loop, but as far as getting it to work, it's not an issue.

Also, your logic seems to be a bit whacky here:

PHP Code:
$prefix = $prefix_cache[$thread['prefix']];
$forum['lastpost_prefix'] = "{$thread['prefix']}";


A few other things:

PHP Code:
$plugins->add_hook("thread_prefixes_start", "prefixesonindex_start");

Hook doesn't exist.  Closest thing I found was admin_config_thread_prefixes_start, which obviously won't work with the same processing function.

PHP Code:
$thread = get_thread($forum['lastposttid']);

lastposttid isn't guaranteed to be set (ie forum with no posts) - it might be a good idea to check that in your code.


Hope that helps.


My Blog
08-17-2010 06:56 PM
Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

 Standard Tools
Forum Jump: