[ Index ]

PHP Cross Reference of phpBB-3.2.11-deutsch

title

Body

[close]

/phpbb/cron/task/core/ -> prune_all_forums.php (source)

   1  <?php
   2  /**
   3  *
   4  * This file is part of the phpBB Forum Software package.
   5  *
   6  * @copyright (c) phpBB Limited <https://www.phpbb.com>
   7  * @license GNU General Public License, version 2 (GPL-2.0)
   8  *
   9  * For full copyright and license information, please see
  10  * the docs/CREDITS.txt file.
  11  *
  12  */
  13  
  14  namespace phpbb\cron\task\core;
  15  
  16  /**
  17  * Prune all forums cron task.
  18  *
  19  * It is intended to be invoked from system cron.
  20  * This task will find all forums for which pruning is enabled, and will
  21  * prune all forums as necessary.
  22  */
  23  class prune_all_forums extends \phpbb\cron\task\base
  24  {
  25      protected $phpbb_root_path;
  26      protected $php_ext;
  27      protected $config;
  28      protected $db;
  29  
  30      /**
  31      * Constructor.
  32      *
  33      * @param string $phpbb_root_path The root path
  34      * @param string $php_ext The PHP file extension
  35      * @param \phpbb\config\config $config The config
  36      * @param \phpbb\db\driver\driver_interface $db The db connection
  37      */
  38  	public function __construct($phpbb_root_path, $php_ext, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db)
  39      {
  40          $this->phpbb_root_path = $phpbb_root_path;
  41          $this->php_ext = $php_ext;
  42          $this->config = $config;
  43          $this->db = $db;
  44      }
  45  
  46      /**
  47      * Runs this cron task.
  48      *
  49      * @return null
  50      */
  51  	public function run()
  52      {
  53          if (!function_exists('auto_prune'))
  54          {
  55              include($this->phpbb_root_path . 'includes/functions_admin.' . $this->php_ext);
  56          }
  57  
  58          $sql = 'SELECT forum_id, prune_next, enable_prune, prune_days, prune_viewed, enable_shadow_prune, prune_shadow_days, prune_shadow_freq, prune_shadow_next, forum_flags, prune_freq
  59              FROM ' . FORUMS_TABLE;
  60          $result = $this->db->sql_query($sql);
  61          while ($row = $this->db->sql_fetchrow($result))
  62          {
  63              $log_prune = true;
  64  
  65              if ($row['enable_prune'] && $row['prune_next'] < time())
  66              {
  67                  if ($row['prune_days'])
  68                  {
  69                      auto_prune($row['forum_id'], 'posted', $row['forum_flags'], $row['prune_days'], $row['prune_freq'], $log_prune);
  70                      $log_prune = false;
  71                  }
  72  
  73                  if ($row['prune_viewed'])
  74                  {
  75                      auto_prune($row['forum_id'], 'viewed', $row['forum_flags'], $row['prune_viewed'], $row['prune_freq'], $log_prune);
  76                      $log_prune = false;
  77                  }
  78              }
  79  
  80              if ($row['enable_shadow_prune'] && $row['prune_shadow_next'] < time() && $row['prune_shadow_days'])
  81              {
  82                  auto_prune($row['forum_id'], 'shadow', $row['forum_flags'], $row['prune_shadow_days'], $row['prune_shadow_freq'], $log_prune);
  83              }
  84          }
  85          $this->db->sql_freeresult($result);
  86      }
  87  
  88      /**
  89      * Returns whether this cron task can run, given current board configuration.
  90      *
  91      * This cron task will only run when system cron is utilised.
  92      *
  93      * @return bool
  94      */
  95  	public function is_runnable()
  96      {
  97          return (bool) $this->config['use_system_cron'];
  98      }
  99  }


Generated: Wed Nov 11 20:33:01 2020 Cross-referenced by PHPXref 0.7.1