1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
|
<?php
/**
*
* @package phpBB3
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
namespace phpbb\profilefields;
/**
* Custom Profile Fields ACP
* @package phpBB3
*/
class admin extends profilefields
{
var $vars = array();
/**
*
*/
public function __construct($auth, $config, $db, $request, $template, $user)
{
$this->auth = $auth;
$this->config = $config;
$this->db = $db;
$this->request = $request;
$this->template = $template;
$this->user = $user;
}
/**
* Return possible validation options
*/
function validate_options()
{
$validate_ary = array('CHARS_ANY' => '.*', 'NUMBERS_ONLY' => '[0-9]+', 'ALPHA_ONLY' => '[\w]+', 'ALPHA_SPACERS' => '[\w_\+\. \-\[\]]+');
$validate_options = '';
foreach ($validate_ary as $lang => $value)
{
$selected = ($this->vars['field_validation'] == $value) ? ' selected="selected"' : '';
$validate_options .= '<option value="' . $value . '"' . $selected . '>' . $this->user->lang[$lang] . '</option>';
}
return $validate_options;
}
/**
* Get string options for second step in ACP
*/
function get_string_options($lang_defs)
{
$options = array(
0 => array('TITLE' => $this->user->lang['FIELD_LENGTH'], 'FIELD' => '<input type="number" min="0" name="field_length" size="5" value="' . $this->vars['field_length'] . '" />'),
1 => array('TITLE' => $this->user->lang['MIN_FIELD_CHARS'], 'FIELD' => '<input type="number" min="0" name="field_minlen" size="5" value="' . $this->vars['field_minlen'] . '" />'),
2 => array('TITLE' => $this->user->lang['MAX_FIELD_CHARS'], 'FIELD' => '<input type="number" min="0" size="5" value="' . $this->vars['field_maxlen'] . '" />'),
3 => array('TITLE' => $this->user->lang['FIELD_VALIDATION'], 'FIELD' => '<select name="field_validation">' . $this->validate_options() . '</select>')
);
return $options;
}
/**
* Get text options for second step in ACP
*/
function get_text_options($lang_defs)
{
$options = array(
0 => array('TITLE' => $this->user->lang['FIELD_LENGTH'], 'FIELD' => '<input type="number" min="0" max="99999" name="rows" size="5" value="' . $this->vars['rows'] . '" /> ' . $user->lang['ROWS'] . '</dd><dd><input type="number" min="0" max="99999" name="columns" size="5" value="' . $this->vars['columns'] . '" /> ' . $user->lang['COLUMNS'] . ' <input type="hidden" name="field_length" value="' . $this->vars['field_length'] . '" />'),
1 => array('TITLE' => $this->user->lang['MIN_FIELD_CHARS'], 'FIELD' => '<input type="number" min="0" max="9999999999" name="field_minlen" size="10" value="' . $this->vars['field_minlen'] . '" />'),
2 => array('TITLE' => $this->user->lang['MAX_FIELD_CHARS'], 'FIELD' => '<input type="number" min="0" max="9999999999" name="field_maxlen" size="10" value="' . $this->vars['field_maxlen'] . '" />'),
3 => array('TITLE' => $this->user->lang['FIELD_VALIDATION'], 'FIELD' => '<select name="field_validation">' . $this->validate_options() . '</select>')
);
return $options;
}
/**
* Get int options for second step in ACP
*/
function get_int_options($lang_defs)
{
$options = array(
0 => array('TITLE' => $this->user->lang['FIELD_LENGTH'], 'FIELD' => '<input type="number" min="0" max="99999" name="field_length" size="5" value="' . $this->vars['field_length'] . '" />'),
1 => array('TITLE' => $this->user->lang['MIN_FIELD_NUMBER'], 'FIELD' => '<input type="number" min="0" max="99999" name="field_minlen" size="5" value="' . $this->vars['field_minlen'] . '" />'),
2 => array('TITLE' => $this->user->lang['MAX_FIELD_NUMBER'], 'FIELD' => '<input type="number" min="0" max="99999" name="field_maxlen" size="5" value="' . $this->vars['field_maxlen'] . '" />'),
3 => array('TITLE' => $this->user->lang['DEFAULT_VALUE'], 'FIELD' => '<input type="post" name="field_default_value" value="' . $this->vars['field_default_value'] . '" />')
);
return $options;
}
/**
* Get bool options for second step in ACP
*/
function get_bool_options($lang_defs)
{
$default_lang_id = $lang_defs['iso'][$this->config['default_lang']];
$profile_row = array(
'var_name' => 'field_default_value',
'field_id' => 1,
'lang_name' => $this->vars['lang_name'],
'lang_explain' => $this->vars['lang_explain'],
'lang_id' => $default_lang_id,
'field_default_value' => $this->vars['field_default_value'],
'field_ident' => 'field_default_value',
'field_type' => FIELD_BOOL,
'field_length' => $this->vars['field_length'],
'lang_options' => $this->vars['lang_options']
);
$options = array(
0 => array('TITLE' => $this->user->lang['FIELD_TYPE'], 'EXPLAIN' => $this->user->lang['BOOL_TYPE_EXPLAIN'], 'FIELD' => '<label><input type="radio" class="radio" name="field_length" value="1"' . (($this->vars['field_length'] == 1) ? ' checked="checked"' : '') . ' onchange="document.getElementById(\'add_profile_field\').submit();" /> ' . $this->user->lang['RADIO_BUTTONS'] . '</label><label><input type="radio" class="radio" name="field_length" value="2"' . (($this->vars['field_length'] == 2) ? ' checked="checked"' : '') . ' onchange="document.getElementById(\'add_profile_field\').submit();" /> ' . $this->user->lang['CHECKBOX'] . '</label>'),
1 => array('TITLE' => $this->user->lang['DEFAULT_VALUE'], 'FIELD' => $this->process_field_row('preview', $profile_row))
);
return $options;
}
/**
* Get dropdown options for second step in ACP
*/
function get_dropdown_options($lang_defs)
{
$default_lang_id = $lang_defs['iso'][$this->config['default_lang']];
$profile_row[0] = array(
'var_name' => 'field_default_value',
'field_id' => 1,
'lang_name' => $this->vars['lang_name'],
'lang_explain' => $this->vars['lang_explain'],
'lang_id' => $default_lang_id,
'field_default_value' => $this->vars['field_default_value'],
'field_ident' => 'field_default_value',
'field_type' => FIELD_DROPDOWN,
'lang_options' => $this->vars['lang_options']
);
$profile_row[1] = $profile_row[0];
$profile_row[1]['var_name'] = 'field_novalue';
$profile_row[1]['field_ident'] = 'field_novalue';
$profile_row[1]['field_default_value'] = $this->vars['field_novalue'];
$options = array(
0 => array('TITLE' => $this->user->lang['DEFAULT_VALUE'], 'FIELD' => $this->process_field_row('preview', $profile_row[0])),
1 => array('TITLE' => $this->user->lang['NO_VALUE_OPTION'], 'EXPLAIN' => $this->user->lang['NO_VALUE_OPTION_EXPLAIN'], 'FIELD' => $this->process_field_row('preview', $profile_row[1]))
);
return $options;
}
/**
* Get date options for second step in ACP
*/
function get_date_options($lang_defs)
{
$default_lang_id = $lang_defs['iso'][$this->config['default_lang']];
$profile_row = array(
'var_name' => 'field_default_value',
'lang_name' => $this->vars['lang_name'],
'lang_explain' => $this->vars['lang_explain'],
'lang_id' => $default_lang_id,
'field_default_value' => $this->vars['field_default_value'],
'field_ident' => 'field_default_value',
'field_type' => FIELD_DATE,
'field_length' => $this->vars['field_length']
);
$always_now = request_var('always_now', -1);
if ($always_now == -1)
{
$s_checked = ($this->vars['field_default_value'] == 'now') ? true : false;
}
else
{
$s_checked = ($always_now) ? true : false;
}
$options = array(
0 => array('TITLE' => $this->user->lang['DEFAULT_VALUE'], 'FIELD' => $this->process_field_row('preview', $profile_row)),
1 => array('TITLE' => $this->user->lang['ALWAYS_TODAY'], 'FIELD' => '<label><input type="radio" class="radio" name="always_now" value="1"' . (($s_checked) ? ' checked="checked"' : '') . ' onchange="document.getElementById(\'add_profile_field\').submit();" /> ' . $this->user->lang['YES'] . '</label><label><input type="radio" class="radio" name="always_now" value="0"' . ((!$s_checked) ? ' checked="checked"' : '') . ' onchange="document.getElementById(\'add_profile_field\').submit();" /> ' . $this->user->lang['NO'] . '</label>'),
);
return $options;
}
}
|