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. |
|
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
remove_outdated_media.php
01 <?php
02 /**
03 *
04 * This file is part of the phpBB Forum Software package.
05 *
06 * @copyright (c) phpBB Limited <https://www.phpbb.com>
07 * @license GNU General Public License, version 2 (GPL-2.0)
08 *
09 * For full copyright and license information, please see
10 * the docs/CREDITS.txt file.
11 *
12 */
13
14 namespace phpbb\db\migration\data\v320;
15
16 class remove_outdated_media extends \phpbb\db\migration\migration
17 {
18 // Following constants were deprecated in 3.2
19 // and moved from constants.php to compatibility_globals.php,
20 // thus define them as class constants
21 const ATTACHMENT_CATEGORY_WM = 2;
22 const ATTACHMENT_CATEGORY_RM = 3;
23 const ATTACHMENT_CATEGORY_QUICKTIME = 6;
24
25 protected $cat_id = array(
26 self::ATTACHMENT_CATEGORY_WM,
27 self::ATTACHMENT_CATEGORY_RM,
28 self::ATTACHMENT_CATEGORY_QUICKTIME,
29 );
30
31 static public function depends_on()
32 {
33 return array(
34 '\phpbb\db\migration\data\v320\dev',
35 );
36 }
37
38 public function update_data()
39 {
40 return array(
41 array('custom', array(array($this, 'change_extension_group'))),
42 );
43 }
44
45 public function change_extension_group()
46 {
47 // select group ids of outdated media
48 $sql = 'SELECT group_id
49 FROM ' . EXTENSION_GROUPS_TABLE . '
50 WHERE ' . $this->db->sql_in_set('cat_id', $this->cat_id);
51 $result = $this->db->sql_query($sql);
52
53 $group_ids = array();
54 while ($group_id = (int) $this->db->sql_fetchfield('group_id'))
55 {
56 $group_ids[] = $group_id;
57 }
58 $this->db->sql_freeresult($result);
59
60 // nothing to do, admin has removed all the outdated media extension groups
61 if (empty($group_ids))
62 {
63 return true;
64 }
65
66 // get the group id of downloadable files
67 $sql = 'SELECT group_id
68 FROM ' . EXTENSION_GROUPS_TABLE . "
69 WHERE group_name = 'DOWNLOADABLE_FILES'";
70 $result = $this->db->sql_query($sql);
71 $download_id = (int) $this->db->sql_fetchfield('group_id');
72 $this->db->sql_freeresult($result);
73
74 if (empty($download_id))
75 {
76 $sql = 'UPDATE ' . EXTENSIONS_TABLE . '
77 SET group_id = 0
78 WHERE ' . $this->db->sql_in_set('group_id', $group_ids);
79 }
80 else
81 {
82 // move outdated media extensions to downloadable files
83 $sql = 'UPDATE ' . EXTENSIONS_TABLE . "
84 SET group_id = $download_id" . '
85 WHERE ' . $this->db->sql_in_set('group_id', $group_ids);
86 }
87
88 $this->db->sql_query($sql);
89
90 // delete the now empty, outdated media extension groups
91 $sql = 'DELETE FROM ' . EXTENSION_GROUPS_TABLE . '
92 WHERE ' . $this->db->sql_in_set('group_id', $group_ids);
93 $this->db->sql_query($sql);
94 }
95 }
96