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

profilefield_types.php

Zuletzt modifiziert: 09.10.2024, 12:57 - Dateigröße: 2.84 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 profilefield_types extends \phpbb\db\migration\migration
 017  {
 018   
 019      static public function depends_on()
 020      {
 021          return array(
 022              '\phpbb\db\migration\data\v310\alpha2',
 023          );
 024      }
 025   
 026      public function update_schema()
 027      {
 028          return array(
 029              'change_columns'    => array(
 030                  $this->table_prefix . 'profile_fields'            => array(
 031                      'field_type'        => array('VCHAR:100', ''),
 032                  ),
 033                  $this->table_prefix . 'profile_fields_lang'        => array(
 034                      'field_type'        => array('VCHAR:100', ''),
 035                  ),
 036              ),
 037          );
 038      }
 039   
 040      public function update_data()
 041      {
 042          return array(
 043              array('custom', array(array($this, 'update_profile_fields_type'))),
 044              array('custom', array(array($this, 'update_profile_fields_lang_type'))),
 045          );
 046      }
 047   
 048      public function update_profile_fields_type()
 049      {
 050          // Update profile field types
 051          $sql = 'SELECT field_type
 052              FROM ' . $this->table_prefix . 'profile_fields
 053              GROUP BY field_type';
 054          $result = $this->db->sql_query($sql);
 055   
 056          while ($row = $this->db->sql_fetchrow($result))
 057          {
 058              $sql = 'UPDATE ' . $this->table_prefix . "profile_fields
 059                  SET field_type = '" . $this->db->sql_escape($this->convert_phpbb30_field_type($row['field_type'])) . "'
 060                  WHERE field_type = '" . $this->db->sql_escape($row['field_type']) . "'";
 061              $this->sql_query($sql);
 062          }
 063          $this->db->sql_freeresult($result);
 064      }
 065   
 066      public function update_profile_fields_lang_type()
 067      {
 068          // Update profile field language types
 069          $sql = 'SELECT field_type
 070              FROM ' . $this->table_prefix . 'profile_fields_lang
 071              GROUP BY field_type';
 072          $result = $this->db->sql_query($sql);
 073   
 074          while ($row = $this->db->sql_fetchrow($result))
 075          {
 076              $sql = 'UPDATE ' . $this->table_prefix . "profile_fields_lang
 077                  SET field_type = '" . $this->db->sql_escape($this->convert_phpbb30_field_type($row['field_type'])) . "'
 078                  WHERE field_type = '" . $this->db->sql_escape($row['field_type']) . "'";
 079              $this->sql_query($sql);
 080          }
 081          $this->db->sql_freeresult($result);
 082      }
 083   
 084      /**
 085      * Determine the new field type for a given phpBB 3.0 field type
 086      *
 087      *    @param    $field_type    string        Field type in 3.0
 088      *    @return        string        Field new type which is used since 3.1
 089      */
 090      public function convert_phpbb30_field_type($field_type)
 091      {
 092          switch ($field_type)
 093          {
 094              case FIELD_INT:
 095                  return 'profilefields.type.int';
 096              case FIELD_STRING:
 097                  return 'profilefields.type.string';
 098              case FIELD_TEXT:
 099                  return 'profilefields.type.text';
 100              case FIELD_BOOL:
 101                  return 'profilefields.type.bool';
 102              case FIELD_DROPDOWN:
 103                  return 'profilefields.type.dropdown';
 104              case FIELD_DATE:
 105                  return 'profilefields.type.date';
 106              default:
 107                  return $field_type;
 108          }
 109      }
 110  }
 111