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 |
soft_delete_mod_convert.php
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 use phpbb\db\migration\container_aware_migration;
017
018 /**
019 * Migration to convert the Soft Delete MOD for 3.0
020 *
021 * https://www.phpbb.com/customise/db/mod/soft_delete/
022 */
023 class soft_delete_mod_convert extends container_aware_migration
024 {
025 static public function depends_on()
026 {
027 return array(
028 '\phpbb\db\migration\data\v310\alpha3',
029 );
030 }
031
032 public function effectively_installed()
033 {
034 return !$this->db_tools->sql_column_exists($this->table_prefix . 'posts', 'post_deleted');
035 }
036
037 public function update_data()
038 {
039 return array(
040 array('permission.remove', array('m_harddelete', true)),
041 array('permission.remove', array('m_harddelete', false)),
042
043 array('custom', array(array($this, 'convert_posts'))),
044 array('custom', array(array($this, 'convert_topics'))),
045 );
046 }
047
048 public function convert_posts($start)
049 {
050 $content_visibility = $this->get_content_visibility();
051
052 $limit = 250;
053 $i = 0;
054
055 $sql = 'SELECT p.*, t.topic_first_post_id, t.topic_last_post_id
056 FROM ' . $this->table_prefix . 'posts p, ' . $this->table_prefix . 'topics t
057 WHERE p.post_deleted > 0
058 AND t.topic_id = p.topic_id';
059 $result = $this->db->sql_query_limit($sql, $limit, $start);
060
061 while ($row = $this->db->sql_fetchrow($result))
062 {
063 $content_visibility->set_post_visibility(
064 ITEM_DELETED,
065 $row['post_id'],
066 $row['topic_id'],
067 $row['forum_id'],
068 $row['post_deleted'],
069 $row['post_deleted_time'],
070 '',
071 ($row['post_id'] == $row['topic_first_post_id']) ? true : false,
072 ($row['post_id'] == $row['topic_last_post_id']) ? true : false
073 );
074
075 $i++;
076 }
077
078 $this->db->sql_freeresult($result);
079
080 if ($i == $limit)
081 {
082 return $start + $i;
083 }
084 }
085
086 public function convert_topics($start)
087 {
088 $content_visibility = $this->get_content_visibility();
089
090 $limit = 100;
091 $i = 0;
092
093 $sql = 'SELECT *
094 FROM ' . $this->table_prefix . 'topics
095 WHERE topic_deleted > 0';
096 $result = $this->db->sql_query_limit($sql, $limit, $start);
097
098 while ($row = $this->db->sql_fetchrow($result))
099 {
100 $content_visibility->set_topic_visibility(
101 ITEM_DELETED,
102 $row['topic_id'],
103 $row['forum_id'],
104 $row['topic_deleted'],
105 $row['topic_deleted_time'],
106 ''
107 );
108
109 $i++;
110 }
111
112 $this->db->sql_freeresult($result);
113
114 if ($i == $limit)
115 {
116 return $start + $i;
117 }
118 }
119
120 /**
121 * @return \phpbb\content_visibility
122 */
123 protected function get_content_visibility()
124 {
125 return $this->container->get('content.visibility');
126 }
127 }
128