Verzeichnisstruktur phpBB-3.3.15


Veröffentlicht
28.08.2024

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

dev.php

Zuletzt modifiziert: 02.04.2025, 15:03 - Dateigröße: 12.68 KiB


001  <?php
002  /**
003  *
004  * This file is part of the phpBB Forum Software package.
005  *
006  * @copyright (c) phpBB Limited <https://www.phpbb.com>
007  * @license GNU General Public License, version 2 (GPL-2.0)
008  *
009  * For full copyright and license information, please see
010  * the docs/CREDITS.txt file.
011  *
012  */
013   
014  namespace phpbb\db\migration\data\v310;
015   
016  class dev extends \phpbb\db\migration\container_aware_migration
017  {
018      public function effectively_installed()
019      {
020          return version_compare($this->config['version'], '3.1.0-dev', '>=');
021      }
022   
023      static public function depends_on()
024      {
025          return array(
026              '\phpbb\db\migration\data\v310\extensions',
027              '\phpbb\db\migration\data\v310\style_update_p2',
028              '\phpbb\db\migration\data\v310\timezone_p2',
029              '\phpbb\db\migration\data\v310\reported_posts_display',
030              '\phpbb\db\migration\data\v310\migrations_table',
031          );
032      }
033   
034      public function update_schema()
035      {
036          return array(
037              'add_columns'        => array(
038                  $this->table_prefix . 'groups'        => array(
039                      'group_teampage'    => array('UINT', 0, 'after' => 'group_legend'),
040                  ),
041                  $this->table_prefix . 'profile_fields'    => array(
042                      'field_show_on_pm'        => array('BOOL', 0),
043                  ),
044                  $this->table_prefix . 'styles'        => array(
045                      'style_path'            => array('VCHAR:100', ''),
046                      'bbcode_bitfield'        => array('VCHAR:255', 'kNg='),
047                      'style_parent_id'        => array('UINT:4', 0),
048                      'style_parent_tree'        => array('TEXT', ''),
049                  ),
050                  $this->table_prefix . 'reports'        => array(
051                      'reported_post_text'        => array('MTEXT_UNI', ''),
052                      'reported_post_uid'            => array('VCHAR:8', ''),
053                      'reported_post_bitfield'    => array('VCHAR:255', ''),
054                  ),
055              ),
056              'change_columns'    => array(
057                  $this->table_prefix . 'groups'        => array(
058                      'group_legend'        => array('UINT', 0),
059                  ),
060              ),
061          );
062      }
063   
064      public function revert_schema()
065      {
066          return array(
067              'drop_columns'        => array(
068                  $this->table_prefix . 'groups'        => array(
069                      'group_teampage',
070                  ),
071                  $this->table_prefix . 'profile_fields'    => array(
072                      'field_show_on_pm',
073                  ),
074                  $this->table_prefix . 'styles'        => array(
075                      'style_path',
076                      'bbcode_bitfield',
077                      'style_parent_id',
078                      'style_parent_tree',
079                  ),
080                  $this->table_prefix . 'reports'        => array(
081                      'reported_post_text',
082                      'reported_post_uid',
083                      'reported_post_bitfield',
084                  ),
085              ),
086          );
087      }
088   
089      public function update_data()
090      {
091          return array(
092              array('if', array(
093                  (strpos('phpbb_search_', $this->config['search_type']) !== 0),
094                  array('config.update', array('search_type', 'phpbb_search_' . $this->config['search_type'])),
095              )),
096   
097              array('config.add', array('fulltext_postgres_ts_name', 'simple')),
098              array('config.add', array('fulltext_postgres_min_word_len', 4)),
099              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  }
428