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

remove_outdated_media.php

Zuletzt modifiziert: 09.10.2024, 12:57 - Dateigröße: 2.24 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\v320;
15   
16  class remove_outdated_media extends \phpbb\db\migration\migration
17  {
18      protected $cat_id = array(
19              ATTACHMENT_CATEGORY_WM,
20              ATTACHMENT_CATEGORY_RM,
21              ATTACHMENT_CATEGORY_QUICKTIME,
22          );
23   
24      static public function depends_on()
25      {
26          return array(
27              '\phpbb\db\migration\data\v320\dev',
28          );
29      }
30   
31      public function update_data()
32      {
33          return array(
34              array('custom', array(array($this, 'change_extension_group'))),
35          );
36      }
37   
38      public function change_extension_group()
39      {
40          // select group ids of outdated media
41          $sql = 'SELECT group_id
42              FROM ' . EXTENSION_GROUPS_TABLE . '
43              WHERE ' . $this->db->sql_in_set('cat_id', $this->cat_id);
44          $result = $this->db->sql_query($sql);
45   
46          $group_ids = array();
47          while ($group_id = (int) $this->db->sql_fetchfield('group_id'))
48          {
49              $group_ids[] = $group_id;
50          }
51          $this->db->sql_freeresult($result);
52   
53          // nothing to do, admin has removed all the outdated media extension groups
54          if (empty($group_ids))
55          {
56              return true;
57          }
58   
59          // get the group id of downloadable files
60          $sql = 'SELECT group_id
61              FROM ' . EXTENSION_GROUPS_TABLE . "
62              WHERE group_name = 'DOWNLOADABLE_FILES'";
63          $result = $this->db->sql_query($sql);
64          $download_id = (int) $this->db->sql_fetchfield('group_id');
65          $this->db->sql_freeresult($result);
66   
67          if (empty($download_id))
68          {
69              $sql = 'UPDATE ' . EXTENSIONS_TABLE . '
70                  SET group_id = 0
71                  WHERE ' . $this->db->sql_in_set('group_id', $group_ids);
72          }
73          else
74          {
75              // move outdated media extensions to downloadable files
76              $sql = 'UPDATE ' . EXTENSIONS_TABLE . "
77                  SET group_id = $download_id" . '
78                  WHERE ' . $this->db->sql_in_set('group_id', $group_ids);
79          }
80   
81          $result = $this->db->sql_query($sql);
82          $this->db->sql_freeresult($result);
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          $result = $this->db->sql_query($sql);
88          $this->db->sql_freeresult($result);
89      }
90  }
91