25require_once DOL_DOCUMENT_ROOT .
'/core/class/fields/commonfield.class.php';
36 public $emptyValues = array(
'');
51 public function printInputSearchField($fieldInfos, $key, $value, $keyPrefix =
'', $keySuffix =
'', $moreCss =
'', $moreAttrib =
'')
53 $moreCss = $this->
getInputCss($fieldInfos, $moreCss);
54 $htmlName = $keyPrefix . $key . $keySuffix;
56 return self::$form->inputType(
'text', $htmlName, (
string) $value, $htmlName, $moreCss, $moreAttrib);
71 public function printInputField($fieldInfos, $key, $value, $keyPrefix =
'', $keySuffix =
'', $moreCss =
'', $moreAttrib =
'')
73 $moreCss = $this->
getInputCss($fieldInfos, $moreCss);
74 $moreAttrib = trim((
string) $moreAttrib);
75 if (empty($moreAttrib)) $moreAttrib =
' ' . $moreAttrib;
76 $autoFocus = $fieldInfos->inputAutofocus ?
' autofocus' :
'';
77 $htmlName = $keyPrefix . $key . $keySuffix;
79 $out =
'<input style="display:none" type="text" name="fakeusernameremembered">';
80 if ($htmlName ==
'pass_crypted') {
81 $out .= self::$form->inputType(
'password',
'pass',
'',
'pass', $moreCss,
' autocomplete="new-password"' . $moreAttrib . $autoFocus);
82 $out .= self::$form->inputType(
'hidden',
'pass_crypted', (
string) $value,
'pass_crypted', $moreCss, $moreAttrib);
84 $out .= self::$form->inputType(
'password', $htmlName, (
string) $value, $htmlName, $moreCss,
' autocomplete="new-password"' . $moreAttrib . $autoFocus);
102 public function printOutputField($fieldInfos, $key, $value, $keyPrefix =
'', $keySuffix =
'', $moreCss =
'', $moreAttrib =
'')
106 return !$this->
isEmptyValue($fieldInfos, $value) ?
'<span class="opacitymedium">' . $langs->trans(
"Encrypted") .
'</span>' :
'';
118 public function getInputCss($fieldInfos, $moreCss =
'', $defaultCss =
'')
120 return parent::getInputCss($fieldInfos, $moreCss, $defaultCss ? $defaultCss :
'maxwidth100');
134 global
$conf, $langs, $user;
136 $result = parent::verifyFieldValue($fieldInfos, $key, $value);
137 if ($result && !$this->
isEmptyValue($fieldInfos, $value)) {
141 require_once DOL_DOCUMENT_ROOT .
'/core/modules/security/generate/modules_genpassword.php';
143 if ($modGeneratePass) {
144 '@phan-var-force ModeleGenPassword $modGeneratePass';
147 $modGeneratePass->WithoutAmbi = 0;
150 $testpassword = $modGeneratePass->validatePassword($value);
151 if (!$testpassword) {
152 self::$validator->error = $langs->trans(
'RequireValidValue');
176 return parent::verifyPostFieldValue($fieldInfos, $key, $keyPrefix, $keySuffix);
190 public function getPostFieldValue($fieldInfos, $key, $defaultValue =
null, $keyPrefix =
'', $keySuffix =
'')
192 $htmlName = $keyPrefix . $key . $keySuffix;
194 if (GETPOSTISSET($htmlName)) {
195 $value =
GETPOST($htmlName,
'password');
197 $value = $defaultValue;
217 $htmlName = $keyPrefix . $key . $keySuffix;
219 if (GETPOSTISSET($htmlName)) {
220 $value =
GETPOST($htmlName,
'alpha');
222 $value = $defaultValue;
240 $alias = $fieldInfos->sqlAlias ??
't.';
243 return natural_search($alias . ($fieldInfos->nameInTable ?? $key), $value, 0);
isEmptyValue($fieldInfos, $value, $emptyValues=null)
Check if the value is deemed as empty.
static loadAndInstantiate($id, $db, $conf, $langs, $user)
Locate, load and instantiate a password generator/validator model by its id (the value stored in USER...
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, $nodefault=0)
Return value of a param into GET or POST supervariable.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.