mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-30 21:40:43 +02:00
Merge remote-tracking branch 'github-nickvergessen/ticket/11201' into develop
* github-nickvergessen/ticket/11201: (50 commits) [ticket/11201] Remove empty calls section from .yml [ticket/11201] Split template file into multiple files [ticket/11201] Remove dependency from types on the manager [ticket/11201] Rename profilefields class to manager [ticket/11201] Fix parameter description [ticket/11201] Use !== null, its faster [ticket/11201] Also translate profile fields in UCP and ACP [ticket/11201] Add parameters and variables to profile field class [ticket/11201] Add commas on last array entry [ticket/11201] Allow translation of profile field name and explanation [ticket/11201] Fix some variable names [ticket/11201] Add tables to constructor in tests [ticket/11201] Add a method to return the translated full name of the type [ticket/11201] Remove db depending code from field class [ticket/11201] Add variables to classes and add constructor doc blocks [ticket/11201] Update copyright in class file [ticket/11201] Add visibility and remove unused variable [ticket/11201] Add some commas at the last array entry [ticket/11201] Cast some variables to integer [ticket/11201] Inject table names rather then using constants ... Conflicts: phpBB/config/services.yml
This commit is contained in:
106
phpBB/phpbb/db/migration/data/v310/profilefield_types.php
Normal file
106
phpBB/phpbb/db/migration/data/v310/profilefield_types.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package migration
|
||||
* @copyright (c) 2014 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\db\migration\data\v310;
|
||||
|
||||
class profilefield_types extends \phpbb\db\migration\migration
|
||||
{
|
||||
|
||||
static public function depends_on()
|
||||
{
|
||||
return array(
|
||||
'\phpbb\db\migration\data\v310\alpha2',
|
||||
);
|
||||
}
|
||||
|
||||
public function update_schema()
|
||||
{
|
||||
return array(
|
||||
'change_columns' => array(
|
||||
$this->table_prefix . 'profile_fields' => array(
|
||||
'field_type' => array('VCHAR:100', ''),
|
||||
),
|
||||
$this->table_prefix . 'profile_fields_lang' => array(
|
||||
'field_type' => array('VCHAR:100', ''),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
public function update_data()
|
||||
{
|
||||
return array(
|
||||
array('custom', array(array($this, 'update_profile_fields_type'))),
|
||||
array('custom', array(array($this, 'update_profile_fields_lang_type'))),
|
||||
);
|
||||
}
|
||||
|
||||
public function update_profile_fields_type()
|
||||
{
|
||||
// Update profile field types
|
||||
$sql = 'SELECT field_type
|
||||
FROM ' . $this->table_prefix . 'profile_fields
|
||||
GROUP BY field_type';
|
||||
$result = $this->db->sql_query($sql);
|
||||
|
||||
while ($row = $this->db->sql_fetchrow($result))
|
||||
{
|
||||
$sql = 'UPDATE ' . $this->table_prefix . "profile_fields
|
||||
SET field_type = '" . $this->db->sql_escape($this->convert_phpbb30_field_type($row['field_type'])) . "'
|
||||
WHERE field_type = '" . $this->db->sql_escape($row['field_type']) . "'";
|
||||
$this->sql_query($sql);
|
||||
}
|
||||
$this->db->sql_freeresult($result);
|
||||
}
|
||||
|
||||
public function update_profile_fields_lang_type()
|
||||
{
|
||||
// Update profile field language types
|
||||
$sql = 'SELECT field_type
|
||||
FROM ' . $this->table_prefix . 'profile_fields_lang
|
||||
GROUP BY field_type';
|
||||
$result = $this->db->sql_query($sql);
|
||||
|
||||
while ($row = $this->db->sql_fetchrow($result))
|
||||
{
|
||||
$sql = 'UPDATE ' . $this->table_prefix . "profile_fields_lang
|
||||
SET field_type = '" . $this->db->sql_escape($this->convert_phpbb30_field_type($row['field_type'])) . "'
|
||||
WHERE field_type = '" . $this->db->sql_escape($row['field_type']) . "'";
|
||||
$this->sql_query($sql);
|
||||
}
|
||||
$this->db->sql_freeresult($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine the new field type for a given phpBB 3.0 field type
|
||||
*
|
||||
* @param $field_type string Field type in 3.0
|
||||
* @return string Field new type which is used since 3.1
|
||||
*/
|
||||
public function convert_phpbb30_field_type($field_type)
|
||||
{
|
||||
switch ($field_type)
|
||||
{
|
||||
case FIELD_INT:
|
||||
return 'profilefields.type.int';
|
||||
case FIELD_STRING:
|
||||
return 'profilefields.type.string';
|
||||
case FIELD_TEXT:
|
||||
return 'profilefields.type.text';
|
||||
case FIELD_BOOL:
|
||||
return 'profilefields.type.bool';
|
||||
case FIELD_DROPDOWN:
|
||||
return 'profilefields.type.dropdown';
|
||||
case FIELD_DATE:
|
||||
return 'profilefields.type.date';
|
||||
default:
|
||||
return $field_type;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user