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

avatars.php

Zuletzt modifiziert: 09.10.2024, 12:57 - Dateigröße: 2.39 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\v310;
 15   
 16  class avatars extends \phpbb\db\migration\migration
 17  {
 18      public function effectively_installed()
 19      {
 20          // Get current avatar type of guest user
 21          $sql = 'SELECT user_avatar_type
 22              FROM ' . $this->table_prefix . 'users
 23              WHERE user_id = ' . ANONYMOUS;
 24          $result = $this->db->sql_query($sql);
 25          $backup_type = $this->db->sql_fetchfield('user_avatar_type');
 26          $this->db->sql_freeresult($result);
 27   
 28          // Try to set avatar type to string
 29          $sql = 'UPDATE ' . $this->table_prefix . "users
 30              SET user_avatar_type = 'avatar.driver.upload'
 31              WHERE user_id = " . ANONYMOUS;
 32          $this->db->sql_return_on_error(true);
 33          $effectively_installed = $this->db->sql_query($sql);
 34          $this->db->sql_return_on_error();
 35   
 36          // Restore avatar type of guest user to previous state
 37          $sql = 'UPDATE ' . $this->table_prefix . "users
 38              SET user_avatar_type = '{$backup_type}'
 39              WHERE user_id = " . ANONYMOUS;
 40          $this->db->sql_query($sql);
 41   
 42          return $effectively_installed !== false;
 43      }
 44   
 45      static public function depends_on()
 46      {
 47          return array('\phpbb\db\migration\data\v30x\release_3_0_11');
 48      }
 49   
 50      public function update_schema()
 51      {
 52          return array(
 53              'change_columns'    => array(
 54                  $this->table_prefix . 'users'            => array(
 55                      'user_avatar_type'        => array('VCHAR:255', ''),
 56                  ),
 57                  $this->table_prefix . 'groups'            => array(
 58                      'group_avatar_type'        => array('VCHAR:255', ''),
 59                  ),
 60              ),
 61          );
 62      }
 63   
 64      public function revert_schema()
 65      {
 66          return array(
 67              'change_columns'    => array(
 68                  $this->table_prefix . 'users'            => array(
 69                      'user_avatar_type'        => array('TINT:2', ''),
 70                  ),
 71                  $this->table_prefix . 'groups'            => array(
 72                      'group_avatar_type'        => array('TINT:2', ''),
 73                  ),
 74              ),
 75          );
 76      }
 77   
 78      public function update_data()
 79      {
 80          return array(
 81              array('config.add', array('allow_avatar_gravatar', 0)),
 82              array('custom', array(array($this, 'update_module_auth'))),
 83          );
 84      }
 85   
 86      public function update_module_auth()
 87      {
 88          $sql = 'UPDATE ' . $this->table_prefix . "modules
 89              SET module_auth = 'cfg_allow_avatar'
 90              WHERE module_class = 'ucp'
 91                  AND module_basename = 'ucp_profile'
 92                  AND module_mode = 'avatar'";
 93          $this->db->sql_query($sql);
 94      }
 95  }
 96