1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-17 06:04:10 +02:00

Merge pull request #2089 from nickvergessen/ticket/12251

[ticket/12251] Clean up and Enhancement of Custom Profile Fields
This commit is contained in:
Nathan Guse
2014-03-09 17:26:22 -05:00
10 changed files with 62 additions and 28 deletions

View File

@@ -0,0 +1,30 @@
<?php
/**
*
* @package migration
* @copyright (c) 2014 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
namespace phpbb\db\migration\data\v310;
class profilefield_change_load_settings extends \phpbb\db\migration\migration
{
static public function depends_on()
{
return array(
'\phpbb\db\migration\data\v310\profilefield_aol_cleanup',
);
}
public function update_data()
{
return array(
array('config.update', array('load_cpf_memberlist', '1')),
array('config.update', array('load_cpf_pm', '1')),
array('config.update', array('load_cpf_viewprofile', '1')),
array('config.update', array('load_cpf_viewtopic', '1')),
);
}
}

View File

@@ -3,7 +3,7 @@
*
* @package migration
* @copyright (c) 2014 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/

View File

@@ -3,7 +3,7 @@
*
* @package migration
* @copyright (c) 2014 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/

View File

@@ -3,7 +3,7 @@
*
* @package migration
* @copyright (c) 2014 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/

View File

@@ -3,7 +3,7 @@
*
* @package migration
* @copyright (c) 2014 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/

View File

@@ -3,7 +3,7 @@
*
* @package migration
* @copyright (c) 2014 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/

View File

@@ -11,15 +11,21 @@ namespace phpbb\profilefields\type;
abstract class type_string_common extends type_base
{
protected $validation_options = array(
'CHARS_ANY' => '.*',
'NUMBERS_ONLY' => '[0-9]+',
'ALPHA_ONLY' => '[\w]+',
'ALPHA_UNDERSCORE' => '[\w_]+',
'ALPHA_SPACERS' => '[\w_\+\. \-\[\]]+',
);
/**
* Return possible validation options
*/
function validate_options($field_data)
public function validate_options($field_data)
{
$validate_ary = array('CHARS_ANY' => '.*', 'NUMBERS_ONLY' => '[0-9]+', 'ALPHA_ONLY' => '[\w]+', 'ALPHA_SPACERS' => '[\w_\+\. \-\[\]]+');
$validate_options = '';
foreach ($validate_ary as $lang => $value)
foreach ($this->validation_options as $lang => $value)
{
$selected = ($field_data['field_validation'] == $value) ? ' selected="selected"' : '';
$validate_options .= '<option value="' . $value . '"' . $selected . '>' . $this->user->lang[$lang] . '</option>';
@@ -69,17 +75,12 @@ abstract class type_string_common extends type_base
$field_validate = ($field_type != 'text') ? $field_value : bbcode_nl2br($field_value);
if (!preg_match('#^' . str_replace('\\\\', '\\', $field_data['field_validation']) . '$#i', $field_validate))
{
switch ($field_data['field_validation'])
$validation = array_search($field_data['field_validation'], $this->validation_options);
if ($validation)
{
case '[0-9]+':
return $this->user->lang('FIELD_INVALID_CHARS_NUMBERS_ONLY', $this->get_field_name($field_data['lang_name']));
case '[\w]+':
return $this->user->lang('FIELD_INVALID_CHARS_ALPHA_ONLY', $this->get_field_name($field_data['lang_name']));
case '[\w_\+\. \-\[\]]+':
return $this->user->lang('FIELD_INVALID_CHARS_SPACERS_ONLY', $this->get_field_name($field_data['lang_name']));
return $this->user->lang('FIELD_INVALID_CHARS_' . $validation, $this->get_field_name($field_data['lang_name']));
}
return $this->user->lang('FIELD_INVALID_CHARS_INVALID', $this->get_field_name($field_data['lang_name']));
}
}