30 $extrasize =
GETPOST(
'size',
'intcomma');
31 $type =
GETPOST(
'type',
'alpha');
32 $param =
GETPOST(
'param',
'alpha');
34 if ($type ==
'double' && strpos($extrasize,
',') ===
false) $extrasize =
'24,8';
35 if ($type ==
'date') $extrasize =
'';
36 if ($type ==
'datetime') $extrasize =
'';
37 if ($type ==
'select') $extrasize =
'';
43 if (
GETPOST(
"button") != $langs->trans(
"Cancel"))
49 $langs->load(
"errors");
50 $mesg[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type"));
53 if ($type ==
'varchar' && $extrasize <= 0)
56 $langs->load(
"errors");
57 $mesg[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Size"));
60 if ($type ==
'varchar' && $extrasize > $maxsizestring)
63 $langs->load(
"errors");
64 $mesg[] = $langs->trans(
"ErrorSizeTooLongForVarcharType", $maxsizestring);
67 if ($type ==
'int' && $extrasize > $maxsizeint)
70 $langs->load(
"errors");
71 $mesg[] = $langs->trans(
"ErrorSizeTooLongForIntType", $maxsizeint);
74 if ($type ==
'select' && !$param)
77 $langs->load(
"errors");
78 $mesg[] = $langs->trans(
"ErrorNoValueForSelectType");
81 if ($type ==
'sellist' && !$param)
84 $langs->load(
"errors");
85 $mesg[] = $langs->trans(
"ErrorNoValueForSelectListType");
88 if ($type ==
'checkbox' && !$param)
91 $langs->load(
"errors");
92 $mesg[] = $langs->trans(
"ErrorNoValueForCheckBoxType");
95 if ($type ==
'link' && !$param)
98 $langs->load(
"errors");
99 $mesg[] = $langs->trans(
"ErrorNoValueForLinkType");
102 if ($type ==
'radio' && !$param)
105 $langs->load(
"errors");
106 $mesg[] = $langs->trans(
"ErrorNoValueForRadioType");
109 if ((($type ==
'radio') || ($type ==
'checkbox')) && $param)
112 $parameters = $param;
113 $parameters_array = explode(
"\r\n", $parameters);
114 foreach ($parameters_array as $param_ligne)
116 if (!empty($param_ligne)) {
117 if (preg_match_all(
'/,/', $param_ligne, $matches))
119 if (count($matches[0]) > 1) {
121 $langs->load(
"errors");
122 $mesg[] = $langs->trans(
"ErrorBadFormatValueList", $param_ligne);
127 $langs->load(
"errors");
128 $mesg[] = $langs->trans(
"ErrorBadFormatValueList", $param_ligne);
136 if (strlen(
GETPOST(
'attrname',
'aZ09')) < 3) {
138 $langs->load(
"errors");
139 $mesg[] = $langs->trans(
"ErrorValueLength", $langs->transnoentitiesnoconv(
"AttributeCode"), 3);
146 if (in_array(
GETPOST(
'attrname',
'aZ09'), array(
'and',
'keyword',
'table',
'index',
'integer',
'float',
'double',
'position'))) {
148 $langs->load(
"errors");
149 $mesg[] = $langs->trans(
"ErrorReservedKeyword",
GETPOST(
'attrname',
'aZ09'));
156 if (
GETPOSTISSET(
"attrname") && preg_match(
"/^[a-z0-9-_]+$/",
GETPOST(
'attrname',
'aZ09')) && !is_numeric(
GETPOST(
'attrname',
'aZ09'))) {
158 $default_value =
GETPOST(
'default_value',
'alpha');
159 $parameters = $param;
160 $parameters_array = explode(
"\r\n", $parameters);
162 if ($type ==
'sellist' || $type ==
'chkbxlst') {
163 foreach ($parameters_array as $param_ligne)
165 $params[
'options'] = array($parameters=>null);
169 foreach ($parameters_array as $param_ligne)
171 list($key, $value) = explode(
',', $param_ligne);
172 $params[
'options'][$key] = $value;
177 $visibility =
GETPOST(
'list',
'alpha');
178 if ($type ==
'separate') $visibility = 3;
180 $result = $extrafields->addExtraField(
187 (
GETPOST(
'unique',
'alpha') ? 1 : 0),
188 (
GETPOST(
'required',
'alpha') ? 1 : 0),
191 (
GETPOST(
'alwayseditable',
'alpha') ? 1 : 0),
195 GETPOST(
'computed_value',
'alpha'),
196 (
GETPOST(
'entitycurrentorall',
'alpha') ? 0 :
''),
199 (
GETPOST(
'totalizable',
'alpha') ? 1 : 0),
205 header(
"Location: ".
$_SERVER[
"PHP_SELF"]);
209 $mesg = $extrafields->error;
214 $langs->load(
"errors");
215 $mesg = $langs->trans(
"ErrorFieldCanNotContainSpecialNorUpperCharacters", $langs->transnoentities(
"AttributeCode"));
226 if ($action ==
'update')
228 if (
GETPOST(
"button") != $langs->trans(
"Cancel"))
234 $langs->load(
"errors");
235 $mesg[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type"));
238 if ($type ==
'varchar' && $extrasize <= 0)
241 $langs->load(
"errors");
242 $mesg[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Size"));
245 if ($type ==
'varchar' && $extrasize > $maxsizestring)
248 $langs->load(
"errors");
249 $mesg[] = $langs->trans(
"ErrorSizeTooLongForVarcharType", $maxsizestring);
252 if ($type ==
'int' && $extrasize > $maxsizeint)
255 $langs->load(
"errors");
256 $mesg[] = $langs->trans(
"ErrorSizeTooLongForIntType", $maxsizeint);
259 if ($type ==
'select' && !$param)
262 $langs->load(
"errors");
263 $mesg[] = $langs->trans(
"ErrorNoValueForSelectType");
266 if ($type ==
'sellist' && !$param)
269 $langs->load(
"errors");
270 $mesg[] = $langs->trans(
"ErrorNoValueForSelectListType");
273 if ($type ==
'checkbox' && !$param)
276 $langs->load(
"errors");
277 $mesg[] = $langs->trans(
"ErrorNoValueForCheckBoxType");
280 if ($type ==
'radio' && !$param)
283 $langs->load(
"errors");
284 $mesg[] = $langs->trans(
"ErrorNoValueForRadioType");
287 if ((($type ==
'radio') || ($type ==
'checkbox')) && $param)
290 $parameters = $param;
291 $parameters_array = explode(
"\r\n", $parameters);
292 foreach ($parameters_array as $param_ligne)
294 if (!empty($param_ligne)) {
295 if (preg_match_all(
'/,/', $param_ligne, $matches))
297 if (count($matches[0]) > 1) {
299 $langs->load(
"errors");
300 $mesg[] = $langs->trans(
"ErrorBadFormatValueList", $param_ligne);
305 $langs->load(
"errors");
306 $mesg[] = $langs->trans(
"ErrorBadFormatValueList", $param_ligne);
314 if (strlen(
GETPOST(
'attrname',
'aZ09')) < 3 && empty($conf->global->MAIN_DISABLE_EXTRAFIELDS_CHECK_FOR_UPDATE)) {
316 $langs->load(
"errors");
317 $mesg[] = $langs->trans(
"ErrorValueLength", $langs->transnoentitiesnoconv(
"AttributeCode"), 3);
324 if (in_array(
GETPOST(
'attrname',
'aZ09'), array(
'and',
'keyword',
'table',
'index',
'integer',
'float',
'double',
'position')) && empty($conf->global->MAIN_DISABLE_EXTRAFIELDS_CHECK_FOR_UPDATE)) {
326 $langs->load(
"errors");
327 $mesg[] = $langs->trans(
"ErrorReservedKeyword",
GETPOST(
'attrname',
'aZ09'));
334 if (
GETPOSTISSET(
"attrname") && preg_match(
"/^\w[a-zA-Z0-9-_]*$/",
GETPOST(
'attrname',
'aZ09')) && !is_numeric(
GETPOST(
'attrname',
'aZ09')))
338 $parameters = $param;
339 $parameters_array = explode(
"\r\n", $parameters);
341 if ($type ==
'sellist' || $type ==
'chkbxlst') {
342 foreach ($parameters_array as $param_ligne)
344 $params[
'options'] = array($parameters=>null);
348 foreach ($parameters_array as $param_ligne)
350 list($key, $value) = explode(
',', $param_ligne);
351 $params[
'options'][$key] = $value;
356 $visibility =
GETPOST(
'list',
'alpha');
357 if ($type ==
'separate') $visibility = 3;
360 $computedvalue =
GETPOST(
'computed_value',
'nohtml');
362 $result = $extrafields->update(
368 (
GETPOST(
'unique',
'alpha') ? 1 : 0),
369 (
GETPOST(
'required',
'alpha') ? 1 : 0),
372 (
GETPOST(
'alwayseditable',
'alpha') ? 1 : 0),
376 GETPOST(
'default_value',
'alpha'),
378 (
GETPOST(
'entitycurrentorall',
'alpha') ? 0 :
''),
381 (
GETPOST(
'totalizable',
'alpha') ? 1 : 0),
386 header(
"Location: ".
$_SERVER[
"PHP_SELF"]);
390 $mesg = $extrafields->error;
395 $langs->load(
"errors");
396 $mesg = $langs->trans(
"ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities(
"AttributeCode"));
406 if ($action ==
'delete') {
407 if (
GETPOSTISSET(
"attrname") && preg_match(
"/^\w[a-zA-Z0-9-_]*$/",
GETPOST(
"attrname",
'aZ09'))) {
408 $result = $extrafields->delete(
GETPOST(
"attrname",
'aZ09'), $elementtype);
410 header(
"Location: ".
$_SERVER[
"PHP_SELF"]);
412 }
else $mesg = $extrafields->error;
415 $langs->load(
"errors");
416 $mesg = $langs->trans(
"ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities(
"AttributeCode"));
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
print $_SERVER["PHP_SELF"]
Edit parameters.