Global Announcement Posts
This core hack will allow you to have one post, be posted globally on every forum. (useful for forum rules, important announcements, etc.)
Installing this hack:
as with any core hack, it is a good idea to make a backup just in case you mess up.
1. Run this sql code
:
ysql]ALTER TABLE sed_forum_topics ADD COLUMN global smallint(5) unsigned NOT NULL default '0';
2. /system/core/forums/forums.topics.inc.php Find
Kod:
case 'announcement':
sed_check_xg();
$sql = sed_sql_query("UPDATE $db_forum_topics SET ft_sticky=1, ft_state=1 WHERE ft_id='$q'");
sed_log("Announcement topic #".$q, 'for');
header("Location: forums.phpşm=topics&s=$s");
exit;
break;
]
After, ADD:
Kod:
case 'global':
sed_check_xg();
$sql = sed_sql_query("UPDATE $db_forum_topics SET global=1, ft_sticky=1, ft_state=1 WHERE ft_id='$q'");
sed_log("Global Announcement topic #".$q, 'for');
header("Location: forums.phpşm=topics&s=$s");
exit;
break;
]
3. /system/core/forums/forums.topics.inc.php Find
Kod:
$mskin = sed_skinfile(array('forums', 'topics', $fs_category, $s));
$t = new XTemplate($mskin);
After, ADD:
Kod:
$sql4 = sed_sql_query("SELECT * FROM $db_forum_topics WHERE global='1' $cond
ORDER by global DESC, ft_".$o." ".$w."
LIMIT $d, ".$cfg['maxtopicsperpage']);
while ($row4 = sed_sql_fetcharray($sql4))
{
$row4['ft_icon'] = 'posts';
$row4['ft_postisnew'] = FALSE;
$row4['ft_pages'] = '';
$ft_num++;
if ($row4['ft_mode']==1)
{ $row4['ft_title'] = "# ".$row4['ft_title']; }
if ($row4['ft_movedto']>0)
{
$row4['ft_url'] = "forums.phpşm=posts&q=".$row4['ft_movedto'];
$row4['ft_icon'] = "<img src=\"skins/$skin/img/system/posts_moved.gif\" alt=\"\" />";
$row4['ft_title']= $L['Moved'].": ".$row4['ft_title'];
$row4['ft_lastpostername'] = " ";
$row4['ft_postcount'] = " ";
$row4['ft_replycount'] = " ";
$row4['ft_viewcount'] = " ";
$row4['ft_lastpostername'] = " ";
$row4['ft_lastposturl'] = "<a href=\"forums.phpşm=posts&q=".$row4['ft_movedto']."&n=last#bottom\"><img src=\"skins/$skin/img/system/arrow-follow.gif\" alt=\"\" /></a> ".$L['Moved'];
$row4['ft_timago'] = sed_build_timegap($row4['ft_updated'],$sys['now_offset']);
}
else
{
$row4['ft_title']= "Announcement: ".$row4['ft_title'];
$row4['ft_url'] = "forums.phpşm=posts&q=".$row4['ft_id'];
$row4['ft_lastposturl'] = ($usr['id']>0 && $row4['ft_updated'] > $usr['lastvisit']) ş "<a href=\"forums.phpşm=posts&q=".$row4['ft_id']."&n=unread#unread\"><img src=\"skins/$skin/img/system/arrow-unread.gif\" alt=\"\" /></a>" : "<a href=\"forums.phpşm=posts&q=".$row4['ft_id']."&n=last#bottom\"><img src=\"skins/$skin/img/system/arrow-follow.gif\" alt=\"\" /></a>";
$row4['ft_lastposturl'] .= @date($cfg['formatmonthdayhourmin'], $row4['ft_updated'] + $usr['timezone'] * 3600);
$row4['ft_timago'] = sed_build_timegap($row4['ft_updated'],$sys['now_offset']);
$row4['ft_replycount'] = $row4['ft_postcount'] - 1;
if ($row4['ft_updated']>$usr['lastvisit'] && $usr['id']>0)
{
$row4['ft_icon'] .= '_new';
$row4['ft_postisnew'] = TRUE;
}
if ($row4['ft_postcount']>=$cfg['hottopictrigger'] && !$row4['ft_state'] && !$row4['ft_sticky'])
{ $row4['ft_icon'] = ($row4['ft_postisnew']) ş 'posts_new_hot' : 'posts_hot'; }
else
{
if ($row4['ft_sticky'])
{ $row4['ft_icon'] .= '_sticky'; }
if ($row4['ft_state'])
{ $row4['ft_icon'] .= '_locked'; }
}
$row4['ft_icon'] = "<img src=\"skins/$skin/img/system/".$row4['ft_icon'].".gif\" alt=\"\" />";
$row4['ft_lastpostername'] = sed_build_user($row4['ft_lastposterid'], sed_cc($row4['ft_lastpostername']));
}
$row4['ft_firstpostername'] = sed_build_user($row4['ft_firstposterid'], sed_cc($row4['ft_firstpostername']));
if ($row4['ft_poll']>0)
{ $row4['ft_title'] = $L['Poll'].": ".$row4['ft_title']; }
if ($row4['ft_postcount']>$cfg['maxtopicsperpage'])
{
$row4['ft_maxpages'] = ceil($row4['ft_postcount'] / $cfg['maxtopicsperpage']);
$row4['ft_pages'] = $L['Pages'].":";
for ($a = 1; $a <= $row4['ft_maxpages']; $a++)
{
$row4['ft_pages'] .= (is_int($a/5) || $a<10 || $a==$row4['ft_maxpages']) ş " <a href=\"".$row4['ft_url']."&d=".($a-1) * $cfg['maxtopicsperpage']."\">".$a."</a>" : '';
}
}
$t-> assign(array(
"FORUMS_TOPICS_GLOBAL_ROW_ID" => $row4['ft_id'],
"FORUMS_TOPICS_GLOBAL_ROW_STATE" => $row4['ft_state'],
"FORUMS_TOPICS_GLOBAL_ROW_ICON" => $row4['ft_icon'],
"FORUMS_TOPICS_GLOBAL_ROW_TITLE" => sed_cc($row4['ft_title']),
"FORUMS_TOPICS_GLOBAL_ROW_CREATIONDATE" => @date($cfg['formatmonthdayhourmin'], $row4['ft_creationdate'] + $usr['timezone'] * 3600),
"FORUMS_TOPICS_GLOBAL_ROW_UPDATED" => $row4['ft_lastposturl'],
"FORUMS_TOPICS_GLOBAL_ROW_TIMEAGO" => $row4['ft_timago'],
"FORUMS_TOPICS_GLOBAL_ROW_POSTCOUNT" => $row4['ft_postcount'],
"FORUMS_TOPICS_GLOBAL_ROW_REPLYCOUNT" => $row4['ft_replycount'],
"FORUMS_TOPICS_GLOBAL_ROW_VIEWCOUNT" => $row4['ft_viewcount'],
"FORUMS_TOPICS_GLOBAL_ROW_FIRSTPOSTER" => $row4['ft_firstpostername'],
"FORUMS_TOPICS_GLOBAL_ROW_LASTPOSTER" => $row4['ft_lastpostername'],
"FORUMS_TOPICS_GLOBAL_ROW_URL" => $row4['ft_url'],
"FORUMS_TOPICS_GLOBAL_ROW_PAGES" => $row4['ft_pages'],
"FORUMS_TOPICS_GLOBAL_ROW_MAXPAGES" => $row4['ft_maxpages'],
"FORUMS_TOPICS_GLOBAL_ROW_ODDEVEN" => sed_build_oddeven($ft_num),
"FORUMS_TOPICS_GLOBAL_ROW" => $row,
));
$t->parse("MAIN.FORUMS_GLOBAL.FORUMS_TOPICS_GLOBAL_ROW");
}
$t->parse("MAIN.FORUMS_GLOBAL");
;[/code]
4. /system/core/forums/forums.topics.inc.php Find
[code]case 'clear':
sed_check_xg();
sed_log("Resetted topic #".$q, 'for');
$sql = sed_sql_query("UPDATE $db_forum_topics SET ft_sticky=0, ft_state=0, ft_mode=0 WHERE ft_id='$q'");
header("Location: forums.phpşm=topics&s=$s");
exit;
break;[/code]
REPLACE WITH:
[code]case 'clear':
sed_check_xg();
sed_log("Resetted topic #".$q, 'for');
$sql = sed_sql_query("UPDATE $db_forum_topics SET ft_sticky=0, ft_state=0, global=0, ft_mode=0 WHERE ft_id='$q'");
header("Location: forums.phpşm=topics&s=$s");
exit;
break;[/code]
5. /system/core/forums/forums.posts.inc.php Find (Notice: file has changed)
[code]if ($usr['isadmin'])
{
$adminoptions = "<form id=\"movetopic\" action=\"forums.phpşm=topics&a=move&".sed_xg()."&s=".$s."&q=".$q."\" method=\"post\">";
$adminoptions .= $L['Topicoptions']." : <a href=\"forums.phpşm=topics&a=bump&".sed_xg()."&q=".$q."&s=".$s."\">".$L['Bump'];
$adminoptions .= "</a> <a href=\"forums.phpşm=topics&a=lock&".sed_xg()."&q=".$q."&s=".$s."\">".$L['Lock'];
$adminoptions .= "</a> <a href=\"forums.phpşm=topics&a=sticky&".sed_xg()."&q=".$q."&s=".$s."\">".$L['Makesticky'];
$adminoptions .= "</a> <a href=\"forums.phpşm=topics&a=announcement&".sed_xg()."&q=".$q."&s=".$s."\">".$L['Announcement'];
$adminoptions .= "</a> <a href=\"forums.phpşm=topics&a=private&".sed_xg()."&q=".$q."&s=".$s."\">".$L['Private']." (#)";
$adminoptions .= "</a> <a href=\"forums.phpşm=topics&a=clear&".sed_xg()."&q=".$q."&s=".$s."\">".$L['Default'];
$adminoptions .= "</a> ".$L['Delete'].":[<a href=\"forums.phpşm=topics&a=delete&".sed_xg()."&s=".$s."&q=".$q."\">x</a>] ".$movebox."</form>";
}[/code]
REPLACE WITH:
[code]if ($usr['isadmin'])
{
$adminoptions = "<form id=\"movetopic\" action=\"forums.phpşm=topics&a=move&".sed_xg()."&s=".$s."&q=".$q."\" method=\"post\">";
$adminoptions .= $L['Topicoptions']." : <a href=\"forums.phpşm=topics&a=bump&".sed_xg()."&q=".$q."&s=".$s."\">".$L['Bump'];
$adminoptions .= "</a> <a href=\"forums.phpşm=topics&a=lock&".sed_xg()."&q=".$q."&s=".$s."\">".$L['Lock'];
$adminoptions .= "</a> <a href=\"forums.phpşm=topics&a=sticky&".sed_xg()."&q=".$q."&s=".$s."\">".$L['Makesticky'];
$adminoptions .= "</a> <a href=\"forums.phpşm=topics&a=announcement&".sed_xg()."&q=".$q."&s=".$s."\">".$L['Announcement'];
$adminoptions .= "</a> <a href=\"forums.phpşm=topics&a=global&".sed_xg()."&q=".$q."&s=".$s."\">Global Announcement";
$adminoptions .= "</a> <a href=\"forums.phpşm=topics&a=private&".sed_xg()."&q=".$q."&s=".$s."\">".$L['Private']." (#)";
$adminoptions .= "</a> <a href=\"forums.phpşm=topics&a=clear&".sed_xg()."&q=".$q."&s=".$s."\">".$L['Default'];
$adminoptions .= "</a> ".$L['Delete'].":[<a href=\"forums.phpşm=topics&a=delete&".sed_xg()."&s=".$s."&q=".$q."\">x</a>] ".$movebox."</form>";
}[/code]
Ok now that all of the file editing is finished, you now have to implement it into your tpl file.
6. /skins/YOURSKIN/forums.topics.tpl ADD
[code]<!-- BEGIN: FORUMS_GLOBAL -->
<table class="cells">
<tr>
<td colspan="2" class="coltop">
{FORUMS_TOPICS_TITLE_TOPICS} / {FORUMS_TOPICS_TITLE_STARTED}</td>
<td class="coltop" style="width:176px;">
{FORUMS_TOPICS_TITLE_LASTPOST}</td>
<td class="coltop" style="width:56px;">
{FORUMS_TOPICS_TITLE_POSTS}</td>
<td class="coltop" style="width:56px;">
{FORUMS_TOPICS_TITLE_VIEWS}</td>
</tr>
<!-- BEGIN: FORUMS_TOPICS_GLOBAL_ROW -->
<tr>
<td style="width:32px;" class="centerall {FORUMS_TOPICS_GLOBAL_ROW_ODDEVEN}">
{FORUMS_TOPICS_GLOBAL_ROW_ICON}
</td>
<td class="{FORUMS_TOPICS_GLOBAL_ROW_ODDEVEN}">
<strong><a href="{FORUMS_TOPICS_GLOBAL_ROW_URL}">{FORUMS_TOPICS_GLOBAL_ROW_TITLE}</a></strong><br />
{FORUMS_TOPICS_GLOBAL_ROW_PAGES} {FORUMS_TOPICS_GLOBAL_ROW_CREATIONDATE} : {FORUMS_TOPICS_GLOBAL_ROW_FIRSTPOSTER}
</td>
<td class="centerall {FORUMS_TOPICS_GLOBAL_ROW_ODDEVEN}">
{FORUMS_TOPICS_GLOBAL_ROW_UPDATED} {FORUMS_TOPICS_GLOBAL_ROW_LASTPOSTER}<br />
{FORUMS_TOPICS_GLOBAL_ROW_TIMEAGO}</span>
</td>
<td class="centerall {FORUMS_TOPICS_GLOBAL_ROW_ODDEVEN}">
{FORUMS_TOPICS_GLOBAL_ROW_POSTCOUNT}
</td>
<td class="centerall {FORUMS_TOPICS_GLOBAL_ROW_ODDEVEN}">
{FORUMS_TOPICS_GLOBAL_ROW_VIEWCOUNT}
</td>
</tr>
<!-- END: FORUMS_TOPICS_GLOBAL_ROW -->
</table>
<!-- END: FORUMS_GLOBAL -->[/code]
Now all is in place, and it is up to you to make it work. All you have to do is open up a topic that you would like to be announced globally, and click
Global Announcement. ta-da, you have an announcement that will be shown in every forum.