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

soft_delete_mod_convert.php

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