######################################
[> Title: Sticky Threads Function
[> Author: Cybermaster
[> Scripted for: Gesior's Simple forum script
[> Coding: PHP+XHTML
[> Revision: 0.1
\________________________________________________/
Well, I think this was missing^_^ AchTung requested it.
Thanks to Absolute Mango for the help
Description
This new function allows moderators to stick or unstick threads in Gesior's Simple Forum Script.
Works like OTland's. Stickied threads will appear on top of the section.
Preview
Moderator's Vision
Player's Vision
Setup
STEP 1 (SQL QUERY)
Execute the next SQL Query, depending of your database class.
MySQL:
SQlite:
STEP 2 (SOME PHP CHANGE STUFF)
Search for
It has this long variable inside
Change it to this one:
Some lines below, there is this:
You change that to this:
STEP 3 (ADD MY FUNCTION)
Before
you add:
###########################################
Tested with Gesior Account Maker, with TibiaCom Layout. TFS 0.3.6
[> Title: Sticky Threads Function
[> Author: Cybermaster
[> Scripted for: Gesior's Simple forum script
[> Coding: PHP+XHTML
[> Revision: 0.1
\________________________________________________/
Well, I think this was missing^_^ AchTung requested it.
Thanks to Absolute Mango for the help
Description
This new function allows moderators to stick or unstick threads in Gesior's Simple Forum Script.
Works like OTland's. Stickied threads will appear on top of the section.
Preview
Moderator's Vision
Player's Vision
Setup
STEP 1 (SQL QUERY)
Execute the next SQL Query, depending of your database class.
MySQL:
Code:
ALTER TABLE `z_forum` ADD `sticky` INT( 11 ) NOT NULL DEFAULT '0' AFTER `id`;
Code:
ALTER TABLE "z_forum" ADD "sticky" INT( 11 ) NOT NULL DEFAULT "0" AFTER `id`;
Search for
PHP:
if($action == 'show_board')
PHP:
$last_threads = $SQL->query("SELECT `players`.`name`, `z_forum`.`post_text`, `z_forum`.`post_topic`, `z_forum`.`id`, `z_forum`.`last_post`, `z_forum`.`replies`, `z_forum`.`views`, `z_forum`.`post_date` FROM `players`, `z_forum` WHERE `players`.`id` = `z_forum`.`author_guid` AND `z_forum`.`section` = ".(int) $section_id." AND `z_forum`.`first_post` = `z_forum`.`id` ORDER BY `z_forum`.`last_post` DESC LIMIT ".$threads_per_page." OFFSET ".($page * $threads_per_page))->fetchAll();
PHP:
$last_threads = $SQL->query("SELECT * FROM `players`, `z_forum` WHERE `players`.`id` = `z_forum`.`author_guid` AND `z_forum`.`section` = ".(int) $section_id." AND `z_forum`.`first_post` = `z_forum`.`id` ORDER BY `sticky` DESC, `post_date` DESC LIMIT ".$threads_per_page." OFFSET ".($page * $threads_per_page))->fetchAll();
Some lines below, there is this:
Code:
if($logged && $group_id_of_acc_logged >= $group_not_blocked)
$main_content .= '<a href="?subtopic=forum&action=remove_post&id='.$thread['id'].'" onclick="return confirm(\'Are you sure you want remove thread > '.$thread['post_topic'].' <?\')"><font color="red">[REMOVE]</font></a> ';
$main_content .= '<a href="?subtopic=forum&action=show_thread&id='.$thread['id'].'">'.htmlspecialchars($thread['post_topic']).'</a><br /><small>'.htmlspecialchars(substr($thread['post_text'], 0, 50)).'...</small></td><td><a href="?subtopic=characters&name='.urlencode($thread['name']).'">'.$thread['name'].'</a></td><td>'.(int) $thread['replies'].'</td><td>'.(int) $thread['views'].'</td><td>';
You change that to this:
Code:
$stick = ""; $stix = '<span style="color:blue">[STICK]</span>'; if ( $thread['sticky'] == 1 ) { $stick = '<strong>STICKY: </strong>'; $stix = '<span style="color:orange">[UNSTICK]</span>'; }
if($logged && $group_id_of_acc_logged >= $group_not_blocked)
$main_content .= '<a href="?subtopic=forum&action=remove_post&id='.$thread['id'].'" onclick="return confirm(\'Are you sure you want remove thread > '.$thread['post_topic'].' <?\')"><span style="color:red">[REMOVE]</span></a> <a href="?subtopic=forum&action=stick_post&id='.$thread['id'].'" onclick="return confirm(\'Are you sure you want stick or unstick thread > '.$thread['post_topic'].' <?\')">'.$stix.'</a><br/>';
$main_content .= '<b>'.$stick.'<a STYLE="text-decoration:none" href="?subtopic=forum&action=show_thread&id='.$thread['id'].'">'.htmlspecialchars($thread['post_topic']).'</a></b><br /><small>'.htmlspecialchars(substr($thread['post_text'], 0, 50)).'...</small></td><td><a href="?subtopic=characters&name='.urlencode($thread['name']).'">'.$thread['name'].'</a></td><td>'.(int) $thread['replies'].'</td><td>'.(int) $thread['views'].'</td><td>';
STEP 3 (ADD MY FUNCTION)
Before
PHP:
if($action == 'remove_post')
PHP:
########################################
//Sticky Threads Function. Scripted by Cybermaster
if($action == 'stick_post')
{
if($logged && $group_id_of_acc_logged >= $group_not_blocked)
{
$id = (int) $_REQUEST['id'];
$post = $SQL->query("SELECT `id`, `sticky`, `first_post`, `section` FROM `z_forum` WHERE `id` = ".$id." LIMIT 1")->fetch();
if($post['id'] == $id)
{
if($post['id'] == $post['first_post'])
{
if($post['sticky'] == 0)
{
$SQL->query("UPDATE `z_forum` SET `sticky` = 1 WHERE `id` = ".$post['id']." ");
header('Location: ?subtopic=forum&action=show_board&id='.$post['section']);
}
else
$SQL->query("UPDATE `z_forum` SET `sticky` = 0 WHERE `id` = ".$post['id']." ");
header('Location: ?subtopic=forum&action=show_board&id='.$post['section']);
}
}
else
$main_content .= 'Post with ID '.$id.' does not exist.';
}
else
$main_content .= 'You are not logged in or you are not moderator.';
}
########################################
###########################################
Tested with Gesior Account Maker, with TibiaCom Layout. TFS 0.3.6
Last edited: