[ Index ]

PHP Cross Reference of phpBB-3.3.14-deutsch

title

Body

[close]

/phpbb/db/migration/data/v32x/ -> fix_user_styles.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\db\migration\data\v32x;
  15  
  16  class fix_user_styles extends \phpbb\db\migration\migration
  17  {
  18  
  19  	static public function depends_on()
  20      {
  21          return array(
  22              '\phpbb\db\migration\data\v320\v320',
  23          );
  24      }
  25  
  26  	public function update_data()
  27      {
  28          return array(
  29              array('custom', array(array($this, 'styles_fix'))),
  30          );
  31      }
  32  
  33  	public function styles_fix()
  34      {
  35          $default_style = (int) $this->config['default_style'];
  36          $enabled_styles = array();
  37  
  38          // Get enabled styles
  39          $sql = 'SELECT style_id
  40              FROM ' . STYLES_TABLE . '
  41              WHERE style_active = 1';
  42          $result = $this->db->sql_query($sql);
  43          while ($row = $this->db->sql_fetchrow($result))
  44          {
  45              $enabled_styles[] = (int) $row['style_id'];
  46          }
  47          $this->db->sql_freeresult($result);
  48  
  49          // Set the default style to users who have an invalid style
  50          $this->sql_query('UPDATE ' . USERS_TABLE . '
  51              SET user_style = ' . (int) $default_style . '
  52              WHERE ' . $this->db->sql_in_set('user_style', $enabled_styles, true));
  53      }
  54  }


Generated: Mon Nov 25 19:05:08 2024 Cross-referenced by PHPXref 0.7.1