Verzeichnisstruktur phpBB-3.3.16


Veröffentlicht
27.04.2026

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

notification_options_reconvert.php

Zuletzt modifiziert: 01.05.2026, 11:27 - Dateigröße: 3.29 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  class notification_options_reconvert extends \phpbb\db\migration\migration
 017  {
 018      static public function depends_on()
 019      {
 020          return array('\phpbb\db\migration\data\v310\notifications_schema_fix');
 021      }
 022   
 023      public function update_data()
 024      {
 025          return array(
 026              array('custom', array(array($this, 'purge_notifications'))),
 027              array('custom', array(array($this, 'convert_notifications'))),
 028          );
 029      }
 030   
 031      public function purge_notifications()
 032      {
 033          $sql = 'DELETE FROM ' . $this->table_prefix . 'user_notifications';
 034          $this->sql_query($sql);
 035      }
 036   
 037      public function convert_notifications($start)
 038      {
 039          $insert_buffer = new \phpbb\db\sql_insert_buffer($this->db, $this->table_prefix . 'user_notifications');
 040   
 041          return $this->perform_conversion($insert_buffer, $start);
 042      }
 043   
 044      /**
 045      * Perform the conversion (separate for testability)
 046      *
 047      * @param \phpbb\db\sql_insert_buffer        $insert_buffer
 048      * @param int            $start        Start of staggering step
 049      * @return        mixed        int start of the next step, null if the end was reached
 050      */
 051      public function perform_conversion(\phpbb\db\sql_insert_buffer $insert_buffer, $start)
 052      {
 053          $limit = 250;
 054          $converted_users = 0;
 055          $start = $start ?: 0;
 056   
 057          $sql = 'SELECT user_id, user_notify_type, user_notify_pm
 058              FROM ' . $this->table_prefix . 'users
 059              ORDER BY user_id';
 060          $result = $this->db->sql_query_limit($sql, $limit, $start);
 061   
 062          while ($row = $this->db->sql_fetchrow($result))
 063          {
 064              $converted_users++;
 065              $notification_methods = array();
 066   
 067              // In-board notification
 068              $notification_methods[] = '';
 069   
 070              if ($row['user_notify_type'] == NOTIFY_EMAIL || $row['user_notify_type'] == NOTIFY_BOTH)
 071              {
 072                  $notification_methods[] = 'email';
 073              }
 074   
 075              if ($row['user_notify_type'] == NOTIFY_IM || $row['user_notify_type'] == NOTIFY_BOTH)
 076              {
 077                  $notification_methods[] = 'jabber';
 078              }
 079   
 080              // Notifications for posts
 081              foreach (array('post', 'topic') as $item_type)
 082              {
 083                  $this->add_method_rows(
 084                      $insert_buffer,
 085                      $item_type,
 086                      0,
 087                      $row['user_id'],
 088                      $notification_methods
 089                  );
 090              }
 091   
 092              if ($row['user_notify_pm'])
 093              {
 094                  // Notifications for private messages
 095                  // User either gets all methods or no method
 096                  $this->add_method_rows(
 097                      $insert_buffer,
 098                      'pm',
 099                      0,
 100                      $row['user_id'],
 101                      $notification_methods
 102                  );
 103              }
 104          }
 105          $this->db->sql_freeresult($result);
 106   
 107          $insert_buffer->flush();
 108   
 109          if ($converted_users < $limit)
 110          {
 111              // No more users left, we are done...
 112              return;
 113          }
 114   
 115          return $start + $limit;
 116      }
 117   
 118      /**
 119      * Insert method rows to DB
 120      *
 121      * @param \phpbb\db\sql_insert_buffer $insert_buffer
 122      * @param string $item_type
 123      * @param int $item_id
 124      * @param int $user_id
 125      * @param string $methods
 126      */
 127      protected function add_method_rows(\phpbb\db\sql_insert_buffer $insert_buffer, $item_type, $item_id, $user_id, array $methods)
 128      {
 129          $row_base = array(
 130              'item_type'        => $item_type,
 131              'item_id'        => (int) $item_id,
 132              'user_id'        => (int) $user_id,
 133              'notify'        => 1
 134          );
 135   
 136          foreach ($methods as $method)
 137          {
 138              $row_base['method'] = $method;
 139              $insert_buffer->insert($row_base);
 140          }
 141      }
 142  }
 143