[ Index ]

PHP Cross Reference of phpBB-3.3.14-deutsch

title

Body

[close]

/phpbb/db/migration/data/v310/ -> dev.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\v310;
  15  
  16  class dev extends \phpbb\db\migration\container_aware_migration
  17  {
  18  	public function effectively_installed()
  19      {
  20          return version_compare($this->config['version'], '3.1.0-dev', '>=');
  21      }
  22  
  23  	static public function depends_on()
  24      {
  25          return array(
  26              '\phpbb\db\migration\data\v310\extensions',
  27              '\phpbb\db\migration\data\v310\style_update_p2',
  28              '\phpbb\db\migration\data\v310\timezone_p2',
  29              '\phpbb\db\migration\data\v310\reported_posts_display',
  30              '\phpbb\db\migration\data\v310\migrations_table',
  31          );
  32      }
  33  
  34  	public function update_schema()
  35      {
  36          return array(
  37              'add_columns'        => array(
  38                  $this->table_prefix . 'groups'        => array(
  39                      'group_teampage'    => array('UINT', 0, 'after' => 'group_legend'),
  40                  ),
  41                  $this->table_prefix . 'profile_fields'    => array(
  42                      'field_show_on_pm'        => array('BOOL', 0),
  43                  ),
  44                  $this->table_prefix . 'styles'        => array(
  45                      'style_path'            => array('VCHAR:100', ''),
  46                      'bbcode_bitfield'        => array('VCHAR:255', 'kNg='),
  47                      'style_parent_id'        => array('UINT:4', 0),
  48                      'style_parent_tree'        => array('TEXT', ''),
  49                  ),
  50                  $this->table_prefix . 'reports'        => array(
  51                      'reported_post_text'        => array('MTEXT_UNI', ''),
  52                      'reported_post_uid'            => array('VCHAR:8', ''),
  53                      'reported_post_bitfield'    => array('VCHAR:255', ''),
  54                  ),
  55              ),
  56              'change_columns'    => array(
  57                  $this->table_prefix . 'groups'        => array(
  58                      'group_legend'        => array('UINT', 0),
  59                  ),
  60              ),
  61          );
  62      }
  63  
  64  	public function revert_schema()
  65      {
  66          return array(
  67              'drop_columns'        => array(
  68                  $this->table_prefix . 'groups'        => array(
  69                      'group_teampage',
  70                  ),
  71                  $this->table_prefix . 'profile_fields'    => array(
  72                      'field_show_on_pm',
  73                  ),
  74                  $this->table_prefix . 'styles'        => array(
  75                      'style_path',
  76                      'bbcode_bitfield',
  77                      'style_parent_id',
  78                      'style_parent_tree',
  79                  ),
  80                  $this->table_prefix . 'reports'        => array(
  81                      'reported_post_text',
  82                      'reported_post_uid',
  83                      'reported_post_bitfield',
  84                  ),
  85              ),
  86          );
  87      }
  88  
  89  	public function update_data()
  90      {
  91          return array(
  92              array('if', array(
  93                  (strpos('phpbb_search_', $this->config['search_type']) !== 0),
  94                  array('config.update', array('search_type', 'phpbb_search_' . $this->config['search_type'])),
  95              )),
  96  
  97              array('config.add', array('fulltext_postgres_ts_name', 'simple')),
  98              array('config.add', array('fulltext_postgres_min_word_len', 4)),
  99              array('config.add', array('fulltext_postgres_max_word_len', 254)),
 100              array('config.add', array('fulltext_sphinx_stopwords', 0)),
 101              array('config.add', array('fulltext_sphinx_indexer_mem_limit', 512)),
 102  
 103              array('config.add', array('load_jquery_cdn', 0)),
 104              array('config.add', array('load_jquery_url', '//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js')),
 105  
 106              array('config.add', array('use_system_cron', 0)),
 107  
 108              array('config.add', array('legend_sort_groupname', 0)),
 109              array('config.add', array('teampage_forums', 1)),
 110              array('config.add', array('teampage_memberships', 1)),
 111  
 112              array('config.add', array('load_cpf_pm', 0)),
 113  
 114              array('config.add', array('display_last_subject', 1)),
 115  
 116              array('config.add', array('assets_version', 1)),
 117  
 118              array('config.add', array('site_home_url', '')),
 119              array('config.add', array('site_home_text', '')),
 120  
 121              array('permission.add', array('u_chgprofileinfo', true, 'u_sig')),
 122  
 123              array('module.add', array(
 124                  'acp',
 125                  'ACP_GROUPS',
 126                  array(
 127                      'module_basename'    => 'acp_groups',
 128                      'module_langname'    => 'ACP_GROUPS_POSITION',
 129                      'module_mode'        => 'position',
 130                      'module_auth'        => 'acl_a_group',
 131                  ),
 132              )),
 133              array('module.add', array(
 134                  'acp',
 135                  'ACP_ATTACHMENTS',
 136                  array(
 137                      'module_basename'    => 'acp_attachments',
 138                      'module_langname'    => 'ACP_MANAGE_ATTACHMENTS',
 139                      'module_mode'        => 'manage',
 140                      'module_auth'        => 'acl_a_attach',
 141                  ),
 142              )),
 143              array('module.add', array(
 144                  'acp',
 145                  'ACP_STYLE_MANAGEMENT',
 146                  array(
 147                      'module_basename'    => 'acp_styles',
 148                      'module_langname'    => 'ACP_STYLES_INSTALL',
 149                      'module_mode'        => 'install',
 150                      'module_auth'        => 'acl_a_styles',
 151                  ),
 152              )),
 153              array('module.add', array(
 154                  'acp',
 155                  'ACP_STYLE_MANAGEMENT',
 156                  array(
 157                      'module_basename'    => 'acp_styles',
 158                      'module_langname'    => 'ACP_STYLES_CACHE',
 159                      'module_mode'        => 'cache',
 160                      'module_auth'        => 'acl_a_styles',
 161                  ),
 162              )),
 163              array('module.add', array(
 164                  'ucp',
 165                  'UCP_PROFILE',
 166                  array(
 167                      'module_basename'    => 'ucp_profile',
 168                      'module_langname'    => 'UCP_PROFILE_AUTOLOGIN_KEYS',
 169                      'module_mode'        => 'autologin_keys',
 170                  ),
 171              )),
 172              // Module will be renamed later
 173              array('module.add', array(
 174                  'acp',
 175                  'ACP_CAT_STYLES',
 176                  'ACP_LANGUAGE'
 177              )),
 178  
 179              array('module.remove', array(
 180                  'acp',
 181                  false,
 182                  'ACP_TEMPLATES',
 183              )),
 184              array('module.remove', array(
 185                  'acp',
 186                  false,
 187                  'ACP_THEMES',
 188              )),
 189              array('module.remove', array(
 190                  'acp',
 191                  false,
 192                  'ACP_IMAGESETS',
 193              )),
 194  
 195              array('custom', array(array($this, 'rename_module_basenames'))),
 196              array('custom', array(array($this, 'rename_styles_module'))),
 197              array('custom', array(array($this, 'add_group_teampage'))),
 198              array('custom', array(array($this, 'update_group_legend'))),
 199              array('custom', array(array($this, 'localise_global_announcements'))),
 200              array('custom', array(array($this, 'update_ucp_pm_basename'))),
 201              array('custom', array(array($this, 'update_ucp_profile_auth'))),
 202              array('custom', array(array($this, 'move_customise_modules'))),
 203  
 204              array('config.update', array('version', '3.1.0-dev')),
 205          );
 206      }
 207  
 208  	public function move_customise_modules()
 209      {
 210          // Move language management to new location in the Customise tab
 211          // First get language module id
 212          $sql = 'SELECT module_id FROM ' . MODULES_TABLE . "
 213              WHERE module_basename = 'acp_language'";
 214          $result = $this->db->sql_query($sql);
 215          $language_module_id = $this->db->sql_fetchfield('module_id');
 216          $this->db->sql_freeresult($result);
 217          // Next get language management module id of the one just created
 218          $sql = 'SELECT module_id FROM ' . MODULES_TABLE . "
 219              WHERE module_langname = 'ACP_LANGUAGE'";
 220          $result = $this->db->sql_query($sql);
 221          $language_management_module_id = $this->db->sql_fetchfield('module_id');
 222          $this->db->sql_freeresult($result);
 223  
 224          // acp_modules calls adm_back_link, which is undefined at this point
 225          if (!function_exists('adm_back_link'))
 226          {
 227              include($this->phpbb_root_path . 'includes/functions_acp.' . $this->php_ext);
 228          }
 229          $module_manager = $this->container->get('module.manager');
 230          $module_manager->move_module($language_module_id, $language_management_module_id, 'acp');
 231      }
 232  
 233  	public function update_ucp_pm_basename()
 234      {
 235          $sql = 'SELECT module_id, module_basename
 236              FROM ' . MODULES_TABLE . "
 237              WHERE module_basename <> 'ucp_pm' AND
 238                  module_langname='UCP_PM'";
 239          $result = $this->db->sql_query_limit($sql, 1);
 240  
 241          if ($row = $this->db->sql_fetchrow($result))
 242          {
 243              // This update is still not applied. Applying it
 244  
 245              $sql = 'UPDATE ' . MODULES_TABLE . "
 246                  SET module_basename = 'ucp_pm'
 247                  WHERE  module_id = " . (int) $row['module_id'];
 248  
 249              $this->sql_query($sql);
 250          }
 251          $this->db->sql_freeresult($result);
 252      }
 253  
 254  	public function update_ucp_profile_auth()
 255      {
 256          // Update the auth setting for the module
 257          $sql = 'UPDATE ' . MODULES_TABLE . "
 258              SET module_auth = 'acl_u_chgprofileinfo'
 259              WHERE module_class = 'ucp'
 260                  AND module_basename = 'ucp_profile'
 261                  AND module_mode = 'profile_info'";
 262          $this->sql_query($sql);
 263      }
 264  
 265  	public function rename_styles_module()
 266      {
 267          // Rename styles module to Customise
 268          $sql = 'UPDATE ' . MODULES_TABLE . "
 269              SET module_langname = 'ACP_CAT_CUSTOMISE'
 270              WHERE module_langname = 'ACP_CAT_STYLES'";
 271          $this->sql_query($sql);
 272      }
 273  
 274  	public function rename_module_basenames()
 275      {
 276          // rename all module basenames to full classname
 277          $sql = 'SELECT module_id, module_basename, module_class
 278              FROM ' . MODULES_TABLE;
 279          $result = $this->db->sql_query($sql);
 280  
 281          while ($row = $this->db->sql_fetchrow($result))
 282          {
 283              $module_id = (int) $row['module_id'];
 284              unset($row['module_id']);
 285  
 286              if (!empty($row['module_basename']) && !empty($row['module_class']))
 287              {
 288                  // all the class names start with class name or with phpbb_ for auto loading
 289                  if (strpos($row['module_basename'], $row['module_class'] . '_') !== 0 &&
 290                      strpos($row['module_basename'], 'phpbb_') !== 0)
 291                  {
 292                      $row['module_basename'] = $row['module_class'] . '_' . $row['module_basename'];
 293  
 294                      $sql_update = $this->db->sql_build_array('UPDATE', $row);
 295  
 296                      $sql = 'UPDATE ' . MODULES_TABLE . '
 297                          SET ' . $sql_update . '
 298                          WHERE module_id = ' . $module_id;
 299                      $this->sql_query($sql);
 300                  }
 301              }
 302          }
 303  
 304          $this->db->sql_freeresult($result);
 305      }
 306  
 307  	public function add_group_teampage()
 308      {
 309          $sql = 'UPDATE ' . GROUPS_TABLE . '
 310              SET group_teampage = 1
 311              WHERE group_type = ' . GROUP_SPECIAL . "
 312                  AND group_name = 'ADMINISTRATORS'";
 313          $this->sql_query($sql);
 314  
 315          $sql = 'UPDATE ' . GROUPS_TABLE . '
 316              SET group_teampage = 2
 317              WHERE group_type = ' . GROUP_SPECIAL . "
 318                  AND group_name = 'GLOBAL_MODERATORS'";
 319          $this->sql_query($sql);
 320      }
 321  
 322  	public function update_group_legend()
 323      {
 324          $sql = 'SELECT group_id
 325              FROM ' . GROUPS_TABLE . '
 326              WHERE group_legend = 1
 327              ORDER BY group_name ASC';
 328          $result = $this->db->sql_query($sql);
 329  
 330          $next_legend = 1;
 331          while ($row = $this->db->sql_fetchrow($result))
 332          {
 333              $sql = 'UPDATE ' . GROUPS_TABLE . '
 334                  SET group_legend = ' . $next_legend . '
 335                  WHERE group_id = ' . (int) $row['group_id'];
 336              $this->sql_query($sql);
 337  
 338              $next_legend++;
 339          }
 340          $this->db->sql_freeresult($result);
 341      }
 342  
 343  	public function localise_global_announcements()
 344      {
 345          // Localise Global Announcements
 346          $sql = 'SELECT topic_id, topic_approved, (topic_replies + 1) AS topic_posts, topic_last_post_id, topic_last_post_subject, topic_last_post_time, topic_last_poster_id, topic_last_poster_name, topic_last_poster_colour
 347              FROM ' . TOPICS_TABLE . '
 348              WHERE forum_id = 0
 349                  AND topic_type = ' . POST_GLOBAL;
 350          $result = $this->db->sql_query($sql);
 351  
 352          $global_announcements = $update_lastpost_data = array();
 353          $update_lastpost_data['forum_last_post_time'] = 0;
 354          $update_forum_data = array(
 355              'forum_posts'        => 0,
 356              'forum_topics'        => 0,
 357              'forum_topics_real'    => 0,
 358          );
 359  
 360          while ($row = $this->db->sql_fetchrow($result))
 361          {
 362              $global_announcements[] = (int) $row['topic_id'];
 363  
 364              $update_forum_data['forum_posts'] += (int) $row['topic_posts'];
 365              $update_forum_data['forum_topics_real']++;
 366              if ($row['topic_approved'])
 367              {
 368                  $update_forum_data['forum_topics']++;
 369              }
 370  
 371              if ($update_lastpost_data['forum_last_post_time'] < $row['topic_last_post_time'])
 372              {
 373                  $update_lastpost_data = array(
 374                      'forum_last_post_id'        => (int) $row['topic_last_post_id'],
 375                      'forum_last_post_subject'    => $row['topic_last_post_subject'],
 376                      'forum_last_post_time'        => (int) $row['topic_last_post_time'],
 377                      'forum_last_poster_id'        => (int) $row['topic_last_poster_id'],
 378                      'forum_last_poster_name'    => $row['topic_last_poster_name'],
 379                      'forum_last_poster_colour'    => $row['topic_last_poster_colour'],
 380                  );
 381              }
 382          }
 383          $this->db->sql_freeresult($result);
 384  
 385          if (!empty($global_announcements))
 386          {
 387              // Update the post/topic-count for the forum and the last-post if needed
 388              $sql = 'SELECT forum_id
 389                  FROM ' . FORUMS_TABLE . '
 390                  WHERE forum_type = ' . FORUM_POST;
 391              $result = $this->db->sql_query_limit($sql, 1);
 392              $ga_forum_id = $this->db->sql_fetchfield('forum_id');
 393              $this->db->sql_freeresult($result);
 394  
 395              $sql = 'SELECT forum_last_post_time
 396                  FROM ' . FORUMS_TABLE . '
 397                  WHERE forum_id = ' . $ga_forum_id;
 398              $result = $this->db->sql_query($sql);
 399              $lastpost = (int) $this->db->sql_fetchfield('forum_last_post_time');
 400              $this->db->sql_freeresult($result);
 401  
 402              $sql_update = 'forum_posts = forum_posts + ' . $update_forum_data['forum_posts'] . ', ';
 403              $sql_update .= 'forum_topics_real = forum_topics_real + ' . $update_forum_data['forum_topics_real'] . ', ';
 404              $sql_update .= 'forum_topics = forum_topics + ' . $update_forum_data['forum_topics'];
 405              if ($lastpost < $update_lastpost_data['forum_last_post_time'])
 406              {
 407                  $sql_update .= ', ' . $this->db->sql_build_array('UPDATE', $update_lastpost_data);
 408              }
 409  
 410              $sql = 'UPDATE ' . FORUMS_TABLE . '
 411                  SET ' . $sql_update . '
 412                  WHERE forum_id = ' . $ga_forum_id;
 413              $this->sql_query($sql);
 414  
 415              // Update some forum_ids
 416              $table_ary = array(TOPICS_TABLE, POSTS_TABLE, LOG_TABLE, DRAFTS_TABLE, TOPICS_TRACK_TABLE);
 417              foreach ($table_ary as $table)
 418              {
 419                  $sql = "UPDATE $table
 420                      SET forum_id = $ga_forum_id
 421                      WHERE " . $this->db->sql_in_set('topic_id', $global_announcements);
 422                  $this->sql_query($sql);
 423              }
 424              unset($table_ary);
 425          }
 426      }
 427  }


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