aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/cron_tasks
diff options
context:
space:
mode:
authorOleg Pudeyev <oleg@bsdpower.com>2010-04-15 10:05:47 -0400
committerOleg Pudeyev <oleg@bsdpower.com>2011-02-12 22:05:49 -0500
commit3956e9f53363171db1ccbafe4971564ff91404e9 (patch)
tree446c5573e69f4abd706c8efb81e152476de4a46a /phpBB/includes/cron_tasks
parent0532048292e056d62b7bafa5dda3d53b297bce94 (diff)
downloadforums-3956e9f53363171db1ccbafe4971564ff91404e9.tar
forums-3956e9f53363171db1ccbafe4971564ff91404e9.tar.gz
forums-3956e9f53363171db1ccbafe4971564ff91404e9.tar.bz2
forums-3956e9f53363171db1ccbafe4971564ff91404e9.tar.xz
forums-3956e9f53363171db1ccbafe4971564ff91404e9.zip
[feature/system-cron] Added implementations for run methods in prune cron tasks.
PHPBB3-9596
Diffstat (limited to 'phpBB/includes/cron_tasks')
-rw-r--r--phpBB/includes/cron_tasks/standard/prune_all_forums.php18
-rw-r--r--phpBB/includes/cron_tasks/standard/prune_forum.php49
2 files changed, 65 insertions, 2 deletions
diff --git a/phpBB/includes/cron_tasks/standard/prune_all_forums.php b/phpBB/includes/cron_tasks/standard/prune_all_forums.php
index f54f5d9ed9..569752dcb0 100644
--- a/phpBB/includes/cron_tasks/standard/prune_all_forums.php
+++ b/phpBB/includes/cron_tasks/standard/prune_all_forums.php
@@ -32,6 +32,24 @@ class prune_all_forums_cron_task extends cron_task_base
*/
public function run()
{
+ global $db;
+ $sql = 'SELECT forum_id, prune_next, enable_prune, prune_days, prune_viewed, forum_flags, prune_freq
+ FROM ' . FORUMS_TABLE . "
+ WHERE enable_prune = 1 and prune_next < " . time();
+ $result = $db->sql_query($sql);
+ while ($row = $db->sql_fetchrow($result))
+ {
+ if ($row['prune_days'])
+ {
+ auto_prune($row['forum_id'], 'posted', $row['forum_flags'], $row['prune_days'], $row['prune_freq']);
+ }
+
+ if ($row['prune_viewed'])
+ {
+ auto_prune($row['forum_id'], 'viewed', $row['forum_flags'], $row['prune_viewed'], $row['prune_freq']);
+ }
+ }
+ $db->sql_freeresult($result);
}
/**
diff --git a/phpBB/includes/cron_tasks/standard/prune_forum.php b/phpBB/includes/cron_tasks/standard/prune_forum.php
index 5ae1083677..f4ef2ea6dd 100644
--- a/phpBB/includes/cron_tasks/standard/prune_forum.php
+++ b/phpBB/includes/cron_tasks/standard/prune_forum.php
@@ -27,9 +27,42 @@ if (!defined('IN_PHPBB'))
*/
class prune_forum_cron_task extends cron_task_base implements parametrized_cron_task
{
- public function __construct($forum_data)
+ /**
+ * Constructor.
+ *
+ * If $forum_data is given, it is assumed to contain necessary information
+ * about a single forum that is to be pruned.
+ *
+ * If $forum_data is not given, forum id will be retrieved via request_var
+ * and a database query will be performed to load the necessary information
+ * about the forum.
+ */
+ public function __construct($forum_data=null)
{
- $this->forum_data = $forum_data;
+ global $db;
+ if ($forum_data)
+ {
+ $this->forum_data = $forum_data;
+ }
+ else
+ {
+ $forum_id = request_var('f', 0);
+
+ $sql = 'SELECT forum_id, prune_next, enable_prune, prune_days, prune_viewed, forum_flags, prune_freq
+ FROM ' . FORUMS_TABLE . "
+ WHERE forum_id = $forum_id";
+ $result = $db->sql_query($sql);
+ $row = $db->sql_fetchrow($result);
+ $db->sql_freeresult($result);
+
+ if (!$row)
+ {
+ // FIXME what to do?
+ break;
+ }
+
+ $this->forum_data = $row;
+ }
}
/**
@@ -37,6 +70,18 @@ class prune_forum_cron_task extends cron_task_base implements parametrized_cron_
*/
public function run()
{
+ global $phpbb_root_path, $phpEx;
+ include_once($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
+
+ if ($this->forum_data['prune_days'])
+ {
+ auto_prune($this->forum_data['forum_id'], 'posted', $this->forum_data['forum_flags'], $this->forum_data['prune_days'], $this->forum_data['prune_freq']);
+ }
+
+ if ($this->forum_data['prune_viewed'])
+ {
+ auto_prune($this->forum_data['forum_id'], 'viewed', $this->forum_data['forum_flags'], $this->forum_data['prune_viewed'], $this->forum_data['prune_freq']);
+ }
}
/**