Verzeichnisstruktur phpBB-3.2.0


Veröffentlicht
06.01.2017

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: 09.10.2024, 12:57 - Dateigröße: 12.14 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                      'modes'                => array('position'),
129                  ),
130              )),
131              array('module.add', array(
132                  'acp',
133                  'ACP_ATTACHMENTS',
134                  array(
135                      'module_basename'    => 'acp_attachments',
136                      'modes'                => array('manage'),
137                  ),
138              )),
139              array('module.add', array(
140                  'acp',
141                  'ACP_STYLE_MANAGEMENT',
142                  array(
143                      'module_basename'    => 'acp_styles',
144                      'modes'                => array('install', 'cache'),
145                  ),
146              )),
147              array('module.add', array(
148                  'ucp',
149                  'UCP_PROFILE',
150                  array(
151                      'module_basename'    => 'ucp_profile',
152                      'modes'                => array('autologin_keys'),
153                  ),
154              )),
155              // Module will be renamed later
156              array('module.add', array(
157                  'acp',
158                  'ACP_CAT_STYLES',
159                  'ACP_LANGUAGE'
160              )),
161   
162              array('module.remove', array(
163                  'acp',
164                  false,
165                  'ACP_TEMPLATES',
166              )),
167              array('module.remove', array(
168                  'acp',
169                  false,
170                  'ACP_THEMES',
171              )),
172              array('module.remove', array(
173                  'acp',
174                  false,
175                  'ACP_IMAGESETS',
176              )),
177   
178              array('custom', array(array($this, 'rename_module_basenames'))),
179              array('custom', array(array($this, 'rename_styles_module'))),
180              array('custom', array(array($this, 'add_group_teampage'))),
181              array('custom', array(array($this, 'update_group_legend'))),
182              array('custom', array(array($this, 'localise_global_announcements'))),
183              array('custom', array(array($this, 'update_ucp_pm_basename'))),
184              array('custom', array(array($this, 'update_ucp_profile_auth'))),
185              array('custom', array(array($this, 'move_customise_modules'))),
186   
187              array('config.update', array('version', '3.1.0-dev')),
188          );
189      }
190   
191      public function move_customise_modules()
192      {
193          // Move language management to new location in the Customise tab
194          // First get language module id
195          $sql = 'SELECT module_id FROM ' . MODULES_TABLE . "
196              WHERE module_basename = 'acp_language'";
197          $result = $this->db->sql_query($sql);
198          $language_module_id = $this->db->sql_fetchfield('module_id');
199          $this->db->sql_freeresult($result);
200          // Next get language management module id of the one just created
201          $sql = 'SELECT module_id FROM ' . MODULES_TABLE . "
202              WHERE module_langname = 'ACP_LANGUAGE'";
203          $result = $this->db->sql_query($sql);
204          $language_management_module_id = $this->db->sql_fetchfield('module_id');
205          $this->db->sql_freeresult($result);
206   
207          // acp_modules calls adm_back_link, which is undefined at this point
208          if (!function_exists('adm_back_link'))
209          {
210              include($this->phpbb_root_path . 'includes/functions_acp.' . $this->php_ext);
211          }
212          $module_manager = $this->container->get('module.manager');
213          $module_manager->move_module($language_module_id, $language_management_module_id, 'acp');
214      }
215   
216      public function update_ucp_pm_basename()
217      {
218          $sql = 'SELECT module_id, module_basename
219              FROM ' . MODULES_TABLE . "
220              WHERE module_basename <> 'ucp_pm' AND
221                  module_langname='UCP_PM'";
222          $result = $this->db->sql_query_limit($sql, 1);
223   
224          if ($row = $this->db->sql_fetchrow($result))
225          {
226              // This update is still not applied. Applying it
227   
228              $sql = 'UPDATE ' . MODULES_TABLE . "
229                  SET module_basename = 'ucp_pm'
230                  WHERE  module_id = " . (int) $row['module_id'];
231   
232              $this->sql_query($sql);
233          }
234          $this->db->sql_freeresult($result);
235      }
236   
237      public function update_ucp_profile_auth()
238      {
239          // Update the auth setting for the module
240          $sql = 'UPDATE ' . MODULES_TABLE . "
241              SET module_auth = 'acl_u_chgprofileinfo'
242              WHERE module_class = 'ucp'
243                  AND module_basename = 'ucp_profile'
244                  AND module_mode = 'profile_info'";
245          $this->sql_query($sql);
246      }
247   
248      public function rename_styles_module()
249      {
250          // Rename styles module to Customise
251          $sql = 'UPDATE ' . MODULES_TABLE . "
252              SET module_langname = 'ACP_CAT_CUSTOMISE'
253              WHERE module_langname = 'ACP_CAT_STYLES'";
254          $this->sql_query($sql);
255      }
256   
257      public function rename_module_basenames()
258      {
259          // rename all module basenames to full classname
260          $sql = 'SELECT module_id, module_basename, module_class
261              FROM ' . MODULES_TABLE;
262          $result = $this->db->sql_query($sql);
263   
264          while ($row = $this->db->sql_fetchrow($result))
265          {
266              $module_id = (int) $row['module_id'];
267              unset($row['module_id']);
268   
269              if (!empty($row['module_basename']) && !empty($row['module_class']))
270              {
271                  // all the class names start with class name or with phpbb_ for auto loading
272                  if (strpos($row['module_basename'], $row['module_class'] . '_') !== 0 &&
273                      strpos($row['module_basename'], 'phpbb_') !== 0)
274                  {
275                      $row['module_basename'] = $row['module_class'] . '_' . $row['module_basename'];
276   
277                      $sql_update = $this->db->sql_build_array('UPDATE', $row);
278   
279                      $sql = 'UPDATE ' . MODULES_TABLE . '
280                          SET ' . $sql_update . '
281                          WHERE module_id = ' . $module_id;
282                      $this->sql_query($sql);
283                  }
284              }
285          }
286   
287          $this->db->sql_freeresult($result);
288      }
289   
290      public function add_group_teampage()
291      {
292          $sql = 'UPDATE ' . GROUPS_TABLE . '
293              SET group_teampage = 1
294              WHERE group_type = ' . GROUP_SPECIAL . "
295                  AND group_name = 'ADMINISTRATORS'";
296          $this->sql_query($sql);
297   
298          $sql = 'UPDATE ' . GROUPS_TABLE . '
299              SET group_teampage = 2
300              WHERE group_type = ' . GROUP_SPECIAL . "
301                  AND group_name = 'GLOBAL_MODERATORS'";
302          $this->sql_query($sql);
303      }
304   
305      public function update_group_legend()
306      {
307          $sql = 'SELECT group_id
308              FROM ' . GROUPS_TABLE . '
309              WHERE group_legend = 1
310              ORDER BY group_name ASC';
311          $result = $this->db->sql_query($sql);
312   
313          $next_legend = 1;
314          while ($row = $this->db->sql_fetchrow($result))
315          {
316              $sql = 'UPDATE ' . GROUPS_TABLE . '
317                  SET group_legend = ' . $next_legend . '
318                  WHERE group_id = ' . (int) $row['group_id'];
319              $this->sql_query($sql);
320   
321              $next_legend++;
322          }
323          $this->db->sql_freeresult($result);
324      }
325   
326      public function localise_global_announcements()
327      {
328          // Localise Global Announcements
329          $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
330              FROM ' . TOPICS_TABLE . '
331              WHERE forum_id = 0
332                  AND topic_type = ' . POST_GLOBAL;
333          $result = $this->db->sql_query($sql);
334   
335          $global_announcements = $update_lastpost_data = array();
336          $update_lastpost_data['forum_last_post_time'] = 0;
337          $update_forum_data = array(
338              'forum_posts'        => 0,
339              'forum_topics'        => 0,
340              'forum_topics_real'    => 0,
341          );
342   
343          while ($row = $this->db->sql_fetchrow($result))
344          {
345              $global_announcements[] = (int) $row['topic_id'];
346   
347              $update_forum_data['forum_posts'] += (int) $row['topic_posts'];
348              $update_forum_data['forum_topics_real']++;
349              if ($row['topic_approved'])
350              {
351                  $update_forum_data['forum_topics']++;
352              }
353   
354              if ($update_lastpost_data['forum_last_post_time'] < $row['topic_last_post_time'])
355              {
356                  $update_lastpost_data = array(
357                      'forum_last_post_id'        => (int) $row['topic_last_post_id'],
358                      'forum_last_post_subject'    => $row['topic_last_post_subject'],
359                      'forum_last_post_time'        => (int) $row['topic_last_post_time'],
360                      'forum_last_poster_id'        => (int) $row['topic_last_poster_id'],
361                      'forum_last_poster_name'    => $row['topic_last_poster_name'],
362                      'forum_last_poster_colour'    => $row['topic_last_poster_colour'],
363                  );
364              }
365          }
366          $this->db->sql_freeresult($result);
367   
368          if (!empty($global_announcements))
369          {
370              // Update the post/topic-count for the forum and the last-post if needed
371              $sql = 'SELECT forum_id
372                  FROM ' . FORUMS_TABLE . '
373                  WHERE forum_type = ' . FORUM_POST;
374              $result = $this->db->sql_query_limit($sql, 1);
375              $ga_forum_id = $this->db->sql_fetchfield('forum_id');
376              $this->db->sql_freeresult($result);
377   
378              $sql = 'SELECT forum_last_post_time
379                  FROM ' . FORUMS_TABLE . '
380                  WHERE forum_id = ' . $ga_forum_id;
381              $result = $this->db->sql_query($sql);
382              $lastpost = (int) $this->db->sql_fetchfield('forum_last_post_time');
383              $this->db->sql_freeresult($result);
384   
385              $sql_update = 'forum_posts = forum_posts + ' . $update_forum_data['forum_posts'] . ', ';
386              $sql_update .= 'forum_topics_real = forum_topics_real + ' . $update_forum_data['forum_topics_real'] . ', ';
387              $sql_update .= 'forum_topics = forum_topics + ' . $update_forum_data['forum_topics'];
388              if ($lastpost < $update_lastpost_data['forum_last_post_time'])
389              {
390                  $sql_update .= ', ' . $this->db->sql_build_array('UPDATE', $update_lastpost_data);
391              }
392   
393              $sql = 'UPDATE ' . FORUMS_TABLE . '
394                  SET ' . $sql_update . '
395                  WHERE forum_id = ' . $ga_forum_id;
396              $this->sql_query($sql);
397   
398              // Update some forum_ids
399              $table_ary = array(TOPICS_TABLE, POSTS_TABLE, LOG_TABLE, DRAFTS_TABLE, TOPICS_TRACK_TABLE);
400              foreach ($table_ary as $table)
401              {
402                  $sql = "UPDATE $table
403                      SET forum_id = $ga_forum_id
404                      WHERE " . $this->db->sql_in_set('topic_id', $global_announcements);
405                  $this->sql_query($sql);
406              }
407              unset($table_ary);
408          }
409      }
410  }
411