[ Index ]

PHP Cross Reference of phpBB-3.1.12-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, forum_flags, prune_freq
  59              FROM ' . FORUMS_TABLE . "
  60              WHERE enable_prune = 1
  61                  AND prune_next < " . time();
  62          $result = $this->db->sql_query($sql);
  63          while ($row = $this->db->sql_fetchrow($result))
  64          {
  65              if ($row['prune_days'])
  66              {
  67                  auto_prune($row['forum_id'], 'posted', $row['forum_flags'], $row['prune_days'], $row['prune_freq']);
  68              }
  69  
  70              if ($row['prune_viewed'])
  71              {
  72                  auto_prune($row['forum_id'], 'viewed', $row['forum_flags'], $row['prune_viewed'], $row['prune_freq']);
  73              }
  74          }
  75          $this->db->sql_freeresult($result);
  76      }
  77  
  78      /**
  79      * Returns whether this cron task can run, given current board configuration.
  80      *
  81      * This cron task will only run when system cron is utilised.
  82      *
  83      * @return bool
  84      */
  85  	public function is_runnable()
  86      {
  87          return (bool) $this->config['use_system_cron'];
  88      }
  89  }


Generated: Thu Jan 11 00:25:41 2018 Cross-referenced by PHPXref 0.7.1