24require_once DOL_DOCUMENT_ROOT .
'/core/class/fields/commonfield.class.php';
35 public $emptyValues = array(
'');
50 public function printInputSearchField($fieldInfos, $key, $value, $keyPrefix =
'', $keySuffix =
'', $moreCss =
'', $moreAttrib =
'')
52 $moreCss = $this->
getInputCss($fieldInfos, $moreCss);
53 $htmlName = $keyPrefix . $key . $keySuffix;
55 return self::$form->inputType(
'text', $htmlName, (
string) $value, $htmlName, $moreCss, $moreAttrib);
70 public function printInputField($fieldInfos, $key, $value, $keyPrefix =
'', $keySuffix =
'', $moreCss =
'', $moreAttrib =
'')
72 $moreCss = $this->
getInputCss($fieldInfos, $moreCss);
73 $moreAttrib = trim((
string) $moreAttrib);
74 if (empty($moreAttrib)) $moreAttrib =
' ' . $moreAttrib;
75 $autoFocus = $fieldInfos->inputAutofocus ?
' autofocus' :
'';
76 $htmlName = $keyPrefix . $key . $keySuffix;
78 $out =
'<input style="display:none" type="text" name="fakeusernameremembered">';
79 if ($htmlName ==
'pass_crypted') {
80 $out .= self::$form->inputType(
'password',
'pass',
'',
'pass', $moreCss,
' autocomplete="new-password"' . $moreAttrib . $autoFocus);
81 $out .= self::$form->inputType(
'hidden',
'pass_crypted', (
string) $value,
'pass_crypted', $moreCss, $moreAttrib);
83 $out .= self::$form->inputType(
'password', $htmlName, (
string) $value, $htmlName, $moreCss,
' autocomplete="new-password"' . $moreAttrib . $autoFocus);
101 public function printOutputField($fieldInfos, $key, $value, $keyPrefix =
'', $keySuffix =
'', $moreCss =
'', $moreAttrib =
'')
105 return !$this->
isEmptyValue($fieldInfos, $value) ?
'<span class="opacitymedium">' . $langs->trans(
"Encrypted") .
'</span>' :
'';
117 public function getInputCss($fieldInfos, $moreCss =
'', $defaultCss =
'')
119 return parent::getInputCss($fieldInfos, $moreCss, $defaultCss ? $defaultCss :
'maxwidth100');
133 global $conf, $langs, $user;
135 $result = parent::verifyFieldValue($fieldInfos, $key, $value);
136 if ($result && !$this->
isEmptyValue($fieldInfos, $value)) {
140 $modGeneratePassClass =
'modGeneratePass' . ucfirst(
getDolGlobalString(
'USER_PASSWORD_GENERATED'));
142 include_once DOL_DOCUMENT_ROOT .
'/core/modules/security/generate/' . $modGeneratePassClass .
'.class.php';
143 if (class_exists($modGeneratePassClass)) {
144 $modGeneratePass =
new $modGeneratePassClass($this->db, $conf, $langs, $user);
145 '@phan-var-force ModeleGenPassword $modGeneratePass';
148 $modGeneratePass->WithoutAmbi = 0;
151 $testpassword = $modGeneratePass->validatePassword($value);
152 if (!$testpassword) {
153 self::$validator->error = $langs->trans(
'RequireValidValue');
177 return parent::verifyPostFieldValue($fieldInfos, $key, $keyPrefix, $keySuffix);
191 public function getPostFieldValue($fieldInfos, $key, $defaultValue =
null, $keyPrefix =
'', $keySuffix =
'')
193 $htmlName = $keyPrefix . $key . $keySuffix;
195 if (GETPOSTISSET($htmlName)) {
196 $value =
GETPOST($htmlName,
'password');
198 $value = $defaultValue;
218 $htmlName = $keyPrefix . $key . $keySuffix;
220 if (GETPOSTISSET($htmlName)) {
221 $value =
GETPOST($htmlName,
'alpha');
223 $value = $defaultValue;
241 $alias = $fieldInfos->sqlAlias ??
't.';
244 return natural_search($alias . ($fieldInfos->nameInTable ?? $key), $value, 0);
isEmptyValue($fieldInfos, $value, $emptyValues=null)
Check if the value is deemed as empty.
printInputField($fieldInfos, $key, $value, $keyPrefix='', $keySuffix='', $moreCss='', $moreAttrib='')
Return HTML string to put an input field into a page.
getInputCss($fieldInfos, $moreCss='', $defaultCss='')
Get input CSS.
verifyPostFieldValue($fieldInfos, $key, $keyPrefix='', $keySuffix='')
Verify if the field value from GET/POST is valid.
verifyFieldValue($fieldInfos, $key, $value)
Verify if the field value is valid.
sqlFilterSearchField($fieldInfos, $key, $value)
Get sql filter for search field.
getPostSearchFieldValue($fieldInfos, $key, $defaultValue=null, $keyPrefix='', $keySuffix='')
Get search field value from GET/POST.
getPostFieldValue($fieldInfos, $key, $defaultValue=null, $keyPrefix='', $keySuffix='')
Get field value from GET/POST.
printOutputField($fieldInfos, $key, $value, $keyPrefix='', $keySuffix='', $moreCss='', $moreAttrib='')
Return HTML string to show a field into a page.
printInputSearchField($fieldInfos, $key, $value, $keyPrefix='', $keySuffix='', $moreCss='', $moreAttrib='')
Return HTML string to put an input search field into a page.
natural_search($fields, $value, $mode=0, $nofirstand=0, $sqltoadd='')
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.