Ironically .. I 'm bumping this older post lol
I'm trying to impliment this on my forum
Using the
Code: Select all
//Check topic last post time and lock if last post is older than 30 days - moderators and posters above 100 post counts are not affected
if ($user->data['user_id'] != ANONYMOUS && ($mode == 'reply' || $mode == 'quote') && !$auth->acl_gets('a_', 'm_') && !$auth->acl_getf_global('m_') && $user->data['user_posts'] < 100)
{
// Learn the last post time
$sql = 'SELECT topic_last_post_time, topic_type, topic_title
FROM ' . TOPICS_TABLE . '
WHERE topic_id = ' . $topic_id;
$result = $db->sql_query_limit($sql, 1);
if ($row = $db->sql_fetchrow($result))
{
$topic_age = $row['topic_last_post_time'];
$topic_type = $row['topic_type'];
$topic_title = $row['topic_title'];
}
$db->sql_freeresult($result);
if ((time() - $topic_age) > 2592000 && $topic_type == POST_NORMAL)//The last topic post 30 days old topics, are locked
{
//Lock topic and give error warning
$sql = 'UPDATE ' . TOPICS_TABLE . "
SET topic_status = 1
WHERE topic_id = $topic_id";
$db->sql_query($sql);
add_log('mod', $forum_id, $topic_id, 'LOG_' . 'LOCK', $topic_title);
trigger_error('This topic is too old to reply, so, it\'s locked now. Thanks.');
}
}
//End of lock topic
Works ok for reply - but when the quote button is used on recent (IE today) posts - it displays the 'This topic is too old to reply, so, it\'s locked now. Thanks. message
using the below code - which "which also works with the quote button in version 3" generates a few sql errors when trying to reply or quote
Code: Select all
//Check topic last post time and lock if last post is older than 360 days
$current_time = time();
if ($user->data['user_id'] != ANONYMOUS && ($mode == 'reply' || $mode == 'quote'))
{
// Learn the last post time
$sql = 'SELECT topic_last_post_time, topic_type, topic_title
FROM ' . TOPICS_TABLE . '
WHERE topic_id = ' . $topic_id;
$sql = "
SELECT DATEDIFF( (
SELECT FROM_UNIXTIME( UNIX_TIMESTAMP( NOW( ) ) ) ) , (
SELECT FROM_UNIXTIME( topic_last_post_time )
FROM `phpBB3_topics`
WHERE `topic_id` = $topic_id
)
) AS topic_last_post_time, topic_type, topic_title
FROM `phpBB3_topics`
WHERE `topic_id` = $topic_id
";
$result = $db->sql_query_limit($sql, 1);
if ($row = $db->sql_fetchrow($result))
{
$topic_age = $row['topic_last_post_time'];
$topic_type = $row['topic_type'];
$topic_title = $row['topic_title'];
}
$db->sql_freeresult($result);
// Determine if the topic age is older than 360 days
if ($topic_age >= 360)
{
//Lock topic and give error warning
$sql = 'UPDATE ' . TOPICS_TABLE . "
SET topic_status = 1
WHERE topic_id = $topic_id";
$db->sql_query($sql);
add_log('mod', $forum_id, $topic_id, 'LOG_' . 'LOCK', $topic_title);
trigger_error('This topic is too old to reply, so, it\'s locked now. Thanks.');
}
}
//End of lock topic
Any Guru's out there who can help ? I would like the mod to work if there is a reply or quoting of a topic which is older than a set time... using the first code the quote function doesn't work...