imthebest
Well-known member
Hi guys,
I have the following code (just pasting the relevant parts)
That code allows me to set the value for the $days variable at the ACP. Then here is the explanation from the coder:
I want to change the behavior so threads will be locked after X days of their creation date without having in account the last reply date at all. I think I need to change:
WHERE xf_thread.last_post_date < " . $timestamp . "
To:
WHERE xf_thread.post_date < " . $timestamp . "
However I'm not sure what the second line of this code snippet does (the one that defines the $timestamp variable) and how it relates to the WHERE clause of the SQL query. My understanding is that the code is setting $timestamp to the current time minus the amount of days specified at the ACP (something like "X days ago"). But now on the query what are you evaluating? If the xf_thread.last_post_date is less than "X days ago"? It shouldn't be the contrary? I mean > instead of <?
Sorry I suck in math, I hate math.
Source: Auto Lock 1.1
Thanks.
I have the following code (just pasting the relevant parts)
Code:
$days = XenForo_Application::get('options')->autoLockDays;
$timestamp = time() - (86400 * $days);
$db = XenForo_Application::get('db');
$threads = $db->fetchAll("
SELECT xf_thread.thread_id
FROM xf_thread
INNER JOIN xf_node ON xf_node.node_id = xf_thread.node_id
WHERE xf_thread.last_post_date < " . $timestamp . "
AND xf_thread.sticky = 0
$whereclause
");
foreach ($threads AS $k => $v)
{
$db->query('
UPDATE xf_thread SET
discussion_open = "0"
WHERE thread_id = ?
', $v);
}
That code allows me to set the value for the $days variable at the ACP. Then here is the explanation from the coder:
The Days value determine when the thread will be locked. For example if the thread never gets any replies, it will be locked X days after the thread creation date. Otherwise the last reply date plus the Days determine when the thread will be locked.
I want to change the behavior so threads will be locked after X days of their creation date without having in account the last reply date at all. I think I need to change:
WHERE xf_thread.last_post_date < " . $timestamp . "
To:
WHERE xf_thread.post_date < " . $timestamp . "
However I'm not sure what the second line of this code snippet does (the one that defines the $timestamp variable) and how it relates to the WHERE clause of the SQL query. My understanding is that the code is setting $timestamp to the current time minus the amount of days specified at the ACP (something like "X days ago"). But now on the query what are you evaluating? If the xf_thread.last_post_date is less than "X days ago"? It shouldn't be the contrary? I mean > instead of <?
Sorry I suck in math, I hate math.
Source: Auto Lock 1.1
Thanks.
Last edited: