[ Index ]

PHP Cross Reference of phpBB-3.1.12-deutsch

title

Body

[close]

/phpbb/db/migration/data/v30x/ -> release_3_0_4_rc1.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\v30x;
  15  
  16  class release_3_0_4_rc1 extends \phpbb\db\migration\migration
  17  {
  18  	public function effectively_installed()
  19      {
  20          return phpbb_version_compare($this->config['version'], '3.0.4-RC1', '>=');
  21      }
  22  
  23  	static public function depends_on()
  24      {
  25          return array('\phpbb\db\migration\data\v30x\release_3_0_3');
  26      }
  27  
  28  	public function update_schema()
  29      {
  30          return array(
  31              'add_columns' => array(
  32                  $this->table_prefix . 'profile_fields' => array(
  33                      'field_show_profile' => array('BOOL', 0),
  34                  ),
  35              ),
  36              'change_columns' => array(
  37                  $this->table_prefix . 'styles' => array(
  38                      'style_id' => array('UINT', NULL, 'auto_increment'),
  39                      'template_id' => array('UINT', 0),
  40                      'theme_id' => array('UINT', 0),
  41                      'imageset_id' => array('UINT', 0),
  42                  ),
  43                  $this->table_prefix . 'styles_imageset' => array(
  44                      'imageset_id' => array('UINT', NULL, 'auto_increment'),
  45                  ),
  46                  $this->table_prefix . 'styles_imageset_data' => array(
  47                      'image_id' => array('UINT', NULL, 'auto_increment'),
  48                      'imageset_id' => array('UINT', 0),
  49                  ),
  50                  $this->table_prefix . 'styles_theme' => array(
  51                      'theme_id' => array('UINT', NULL, 'auto_increment'),
  52                  ),
  53                  $this->table_prefix . 'styles_template' => array(
  54                      'template_id' => array('UINT', NULL, 'auto_increment'),
  55                  ),
  56                  $this->table_prefix . 'styles_template_data' => array(
  57                      'template_id' => array('UINT', 0),
  58                  ),
  59                  $this->table_prefix . 'forums' => array(
  60                      'forum_style' => array('UINT', 0),
  61                  ),
  62                  $this->table_prefix . 'users' => array(
  63                      'user_style' => array('UINT', 0),
  64                  ),
  65              ),
  66          );
  67      }
  68  
  69  	public function revert_schema()
  70      {
  71          return array(
  72              'drop_columns' => array(
  73                  $this->table_prefix . 'profile_fields' => array(
  74                      'field_show_profile',
  75                  ),
  76              ),
  77          );
  78      }
  79  
  80  	public function update_data()
  81      {
  82          return array(
  83              array('custom', array(array(&$this, 'update_custom_profile_fields'))),
  84  
  85              array('config.update', array('version', '3.0.4-RC1')),
  86          );
  87      }
  88  
  89  	public function update_custom_profile_fields()
  90      {
  91          // Update the Custom Profile Fields based on previous settings to the new \format
  92          $sql = 'SELECT field_id, field_required, field_show_on_reg, field_hide
  93                  FROM ' . PROFILE_FIELDS_TABLE;
  94          $result = $this->db->sql_query($sql);
  95  
  96          while ($row = $this->db->sql_fetchrow($result))
  97          {
  98              $sql_ary = array(
  99                  'field_required'    => 0,
 100                  'field_show_on_reg'    => 0,
 101                  'field_hide'        => 0,
 102                  'field_show_profile'=> 0,
 103              );
 104  
 105              if ($row['field_required'])
 106              {
 107                  $sql_ary['field_required'] = $sql_ary['field_show_on_reg'] = $sql_ary['field_show_profile'] = 1;
 108              }
 109              else if ($row['field_show_on_reg'])
 110              {
 111                  $sql_ary['field_show_on_reg'] = $sql_ary['field_show_profile'] = 1;
 112              }
 113              else if ($row['field_hide'])
 114              {
 115                  // Only administrators and moderators can see this CPF, if the view is enabled, they can see it, otherwise just admins in the acp_users module
 116                  $sql_ary['field_hide'] = 1;
 117              }
 118              else
 119              {
 120                  // equivelant to "none", which is the "Display in user control panel" option
 121                  $sql_ary['field_show_profile'] = 1;
 122              }
 123  
 124              $this->sql_query('UPDATE ' . $this->table_prefix . 'profile_fields SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' WHERE field_id = ' . $row['field_id'], $errored, $error_ary);
 125          }
 126  
 127          $this->db->sql_freeresult($result);
 128      }
 129  }


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