Verzeichnisstruktur phpBB-3.1.0


Veröffentlicht
27.10.2014

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.26 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\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          if (!class_exists('acp_modules'))
208          {
209              include($this->phpbb_root_path . 'includes/acp/acp_modules.' . $this->php_ext);
210          }
211          // acp_modules calls adm_back_link, which is undefined at this point
212          if (!function_exists('adm_back_link'))
213          {
214              include($this->phpbb_root_path . 'includes/functions_acp.' . $this->php_ext);
215          }
216          $module_manager = new \acp_modules();
217          $module_manager->module_class = 'acp';
218          $module_manager->move_module($language_module_id, $language_management_module_id);
219      }
220   
221      public function update_ucp_pm_basename()
222      {
223          $sql = 'SELECT module_id, module_basename
224              FROM ' . MODULES_TABLE . "
225              WHERE module_basename <> 'ucp_pm' AND
226                  module_langname='UCP_PM'";
227          $result = $this->db->sql_query_limit($sql, 1);
228   
229          if ($row = $this->db->sql_fetchrow($result))
230          {
231              // This update is still not applied. Applying it
232   
233              $sql = 'UPDATE ' . MODULES_TABLE . "
234                  SET module_basename = 'ucp_pm'
235                  WHERE  module_id = " . (int) $row['module_id'];
236   
237              $this->sql_query($sql);
238          }
239          $this->db->sql_freeresult($result);
240      }
241   
242      public function update_ucp_profile_auth()
243      {
244          // Update the auth setting for the module
245          $sql = 'UPDATE ' . MODULES_TABLE . "
246              SET module_auth = 'acl_u_chgprofileinfo'
247              WHERE module_class = 'ucp'
248                  AND module_basename = 'ucp_profile'
249                  AND module_mode = 'profile_info'";
250          $this->sql_query($sql);
251      }
252   
253      public function rename_styles_module()
254      {
255          // Rename styles module to Customise
256          $sql = 'UPDATE ' . MODULES_TABLE . "
257              SET module_langname = 'ACP_CAT_CUSTOMISE'
258              WHERE module_langname = 'ACP_CAT_STYLES'";
259          $this->sql_query($sql);
260      }
261   
262      public function rename_module_basenames()
263      {
264          // rename all module basenames to full classname
265          $sql = 'SELECT module_id, module_basename, module_class
266              FROM ' . MODULES_TABLE;
267          $result = $this->db->sql_query($sql);
268   
269          while ($row = $this->db->sql_fetchrow($result))
270          {
271              $module_id = (int) $row['module_id'];
272              unset($row['module_id']);
273   
274              if (!empty($row['module_basename']) && !empty($row['module_class']))
275              {
276                  // all the class names start with class name or with phpbb_ for auto loading
277                  if (strpos($row['module_basename'], $row['module_class'] . '_') !== 0 &&
278                      strpos($row['module_basename'], 'phpbb_') !== 0)
279                  {
280                      $row['module_basename'] = $row['module_class'] . '_' . $row['module_basename'];
281   
282                      $sql_update = $this->db->sql_build_array('UPDATE', $row);
283   
284                      $sql = 'UPDATE ' . MODULES_TABLE . '
285                          SET ' . $sql_update . '
286                          WHERE module_id = ' . $module_id;
287                      $this->sql_query($sql);
288                  }
289              }
290          }
291   
292          $this->db->sql_freeresult($result);
293      }
294   
295      public function add_group_teampage()
296      {
297          $sql = 'UPDATE ' . GROUPS_TABLE . '
298              SET group_teampage = 1
299              WHERE group_type = ' . GROUP_SPECIAL . "
300                  AND group_name = 'ADMINISTRATORS'";
301          $this->sql_query($sql);
302   
303          $sql = 'UPDATE ' . GROUPS_TABLE . '
304              SET group_teampage = 2
305              WHERE group_type = ' . GROUP_SPECIAL . "
306                  AND group_name = 'GLOBAL_MODERATORS'";
307          $this->sql_query($sql);
308      }
309   
310      public function update_group_legend()
311      {
312          $sql = 'SELECT group_id
313              FROM ' . GROUPS_TABLE . '
314              WHERE group_legend = 1
315              ORDER BY group_name ASC';
316          $result = $this->db->sql_query($sql);
317   
318          $next_legend = 1;
319          while ($row = $this->db->sql_fetchrow($result))
320          {
321              $sql = 'UPDATE ' . GROUPS_TABLE . '
322                  SET group_legend = ' . $next_legend . '
323                  WHERE group_id = ' . (int) $row['group_id'];
324              $this->sql_query($sql);
325   
326              $next_legend++;
327          }
328          $this->db->sql_freeresult($result);
329      }
330   
331      public function localise_global_announcements()
332      {
333          // Localise Global Announcements
334          $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
335              FROM ' . TOPICS_TABLE . '
336              WHERE forum_id = 0
337                  AND topic_type = ' . POST_GLOBAL;
338          $result = $this->db->sql_query($sql);
339   
340          $global_announcements = $update_lastpost_data = array();
341          $update_lastpost_data['forum_last_post_time'] = 0;
342          $update_forum_data = array(
343              'forum_posts'        => 0,
344              'forum_topics'        => 0,
345              'forum_topics_real'    => 0,
346          );
347   
348          while ($row = $this->db->sql_fetchrow($result))
349          {
350              $global_announcements[] = (int) $row['topic_id'];
351   
352              $update_forum_data['forum_posts'] += (int) $row['topic_posts'];
353              $update_forum_data['forum_topics_real']++;
354              if ($row['topic_approved'])
355              {
356                  $update_forum_data['forum_topics']++;
357              }
358   
359              if ($update_lastpost_data['forum_last_post_time'] < $row['topic_last_post_time'])
360              {
361                  $update_lastpost_data = array(
362                      'forum_last_post_id'        => (int) $row['topic_last_post_id'],
363                      'forum_last_post_subject'    => $row['topic_last_post_subject'],
364                      'forum_last_post_time'        => (int) $row['topic_last_post_time'],
365                      'forum_last_poster_id'        => (int) $row['topic_last_poster_id'],
366                      'forum_last_poster_name'    => $row['topic_last_poster_name'],
367                      'forum_last_poster_colour'    => $row['topic_last_poster_colour'],
368                  );
369              }
370          }
371          $this->db->sql_freeresult($result);
372   
373          if (!empty($global_announcements))
374          {
375              // Update the post/topic-count for the forum and the last-post if needed
376              $sql = 'SELECT forum_id
377                  FROM ' . FORUMS_TABLE . '
378                  WHERE forum_type = ' . FORUM_POST;
379              $result = $this->db->sql_query_limit($sql, 1);
380              $ga_forum_id = $this->db->sql_fetchfield('forum_id');
381              $this->db->sql_freeresult($result);
382   
383              $sql = 'SELECT forum_last_post_time
384                  FROM ' . FORUMS_TABLE . '
385                  WHERE forum_id = ' . $ga_forum_id;
386              $result = $this->db->sql_query($sql);
387              $lastpost = (int) $this->db->sql_fetchfield('forum_last_post_time');
388              $this->db->sql_freeresult($result);
389   
390              $sql_update = 'forum_posts = forum_posts + ' . $update_forum_data['forum_posts'] . ', ';
391              $sql_update .= 'forum_topics_real = forum_topics_real + ' . $update_forum_data['forum_topics_real'] . ', ';
392              $sql_update .= 'forum_topics = forum_topics + ' . $update_forum_data['forum_topics'];
393              if ($lastpost < $update_lastpost_data['forum_last_post_time'])
394              {
395                  $sql_update .= ', ' . $this->db->sql_build_array('UPDATE', $update_lastpost_data);
396              }
397   
398              $sql = 'UPDATE ' . FORUMS_TABLE . '
399                  SET ' . $sql_update . '
400                  WHERE forum_id = ' . $ga_forum_id;
401              $this->sql_query($sql);
402   
403              // Update some forum_ids
404              $table_ary = array(TOPICS_TABLE, POSTS_TABLE, LOG_TABLE, DRAFTS_TABLE, TOPICS_TRACK_TABLE);
405              foreach ($table_ary as $table)
406              {
407                  $sql = "UPDATE $table
408                      SET forum_id = $ga_forum_id
409                      WHERE " . $this->db->sql_in_set('topic_id', $global_announcements);
410                  $this->sql_query($sql);
411              }
412              unset($table_ary);
413          }
414      }
415  }
416