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

remove_attachment_flash.php

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


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\v330;
15   
16  class remove_attachment_flash extends \phpbb\db\migration\migration
17  {
18      // Following constants were deprecated in 3.3
19      // and moved from constants.php to compatibility_globals.php,
20      // thus define them as class constants
21      const ATTACHMENT_CATEGORY_FLASH = 5;
22   
23      protected $cat_id = array(
24          self::ATTACHMENT_CATEGORY_FLASH,
25      );
26   
27      static public function depends_on()
28      {
29          return ['\phpbb\db\migration\data\v330\dev',];
30      }
31   
32      public function update_data()
33      {
34          return array(
35              array('custom', array(array($this, 'remove_flash_group'))),
36          );
37      }
38   
39      public function remove_flash_group()
40      {
41          // select group ids of outdated media
42          $sql = 'SELECT group_id
43              FROM ' . EXTENSION_GROUPS_TABLE . '
44              WHERE ' . $this->db->sql_in_set('cat_id', $this->cat_id);
45          $result = $this->db->sql_query($sql);
46   
47          $group_ids = array();
48          while ($group_id = (int) $this->db->sql_fetchfield('group_id'))
49          {
50              $group_ids[] = $group_id;
51          }
52          $this->db->sql_freeresult($result);
53   
54          // nothing to do, admin has removed all the outdated media extension groups
55          if (empty($group_ids))
56          {
57              return true;
58          }
59   
60          // get the group id of downloadable files
61          $sql = 'SELECT group_id
62              FROM ' . EXTENSION_GROUPS_TABLE . "
63              WHERE group_name = 'DOWNLOADABLE_FILES'";
64          $result = $this->db->sql_query($sql);
65          $download_id = (int) $this->db->sql_fetchfield('group_id');
66          $this->db->sql_freeresult($result);
67   
68          if (empty($download_id))
69          {
70              $sql = 'UPDATE ' . EXTENSIONS_TABLE . '
71                  SET group_id = 0
72                  WHERE ' . $this->db->sql_in_set('group_id', $group_ids);
73          }
74          else
75          {
76              // move outdated media extensions to downloadable files
77              $sql = 'UPDATE ' . EXTENSIONS_TABLE . "
78                  SET group_id = $download_id" . '
79                  WHERE ' . $this->db->sql_in_set('group_id', $group_ids);
80          }
81   
82          $this->db->sql_query($sql);
83   
84          // delete the now empty, outdated media extension groups
85          $sql = 'DELETE FROM ' . EXTENSION_GROUPS_TABLE . '
86              WHERE ' . $this->db->sql_in_set('group_id', $group_ids);
87          $this->db->sql_query($sql);
88      }
89  }
90