Merge remote-tracking branch 'upstream/develop' into customerordertooltip

This commit is contained in:
Frédéric FRANCE 2023-03-13 18:09:48 +01:00
commit 428b56a253
7 changed files with 35 additions and 12 deletions

View File

@ -36,7 +36,7 @@ if (!defined('NOREQUIREAJAX')) {
if (!defined('NOREQUIRESOC')) {
define('NOREQUIRESOC', '1');
}
// We need langs because the getRandomPassword may use user language to define some rules of pass generation
// We need langs because the getRandomPassword may use the user language to define some rules of pass generation
/*if (!defined('NOREQUIRETRAN')) {
define('NOREQUIRETRAN', '1');
}*/

View File

@ -581,6 +581,9 @@ function dolJSToSetRandomPassword($htmlname, $htmlnameofbutton = 'generate_token
token: \''.dol_escape_js(newToken()).'\'
},
function(result) {
if ($("input#'.dol_escape_js($htmlname).'").attr("type") == "password") {
$("input#'.dol_escape_js($htmlname).'").attr("type", "text");
}
$("#'.dol_escape_js($htmlname).'").val(result);
});
});

View File

@ -1821,7 +1821,6 @@ class Task extends CommonObjectLine
}
if (!$error) {
$timespent = new TimeSpent($this->db);
$timespent->fetch($this->timespent_id);

View File

@ -205,7 +205,7 @@ $arrayofjs = array();
$arrayofcss = array();
$replacemainarea = (empty($conf->dol_hide_leftmenu) ? '<div>' : '').'<div>';
llxHeader($head, $object->getFullName($langs).' - '.$langs->trans("PublicVirtualCard"), '', '', 0, 0, '', '', '', 'onlinepaymentbody'.(GETPOST('mode')=='preview' ? ' scalepreview nopointervent' : ''), $replacemainarea, 1, 1);
llxHeader($head, $object->getFullName($langs).' - '.$langs->trans("PublicVirtualCard"), '', '', 0, 0, '', '', '', 'onlinepaymentbody'.(GETPOST('mode')=='preview' ? ' scalepreview cursorpointer virtualcardpreview' : ''), $replacemainarea, 1, 1);
print '<span id="dolpaymentspan"></span>'."\n";
print '<div class="center">'."\n";
@ -463,6 +463,19 @@ print '</div>';
//print '</div>';
print '</div>';
$fullexternaleurltovirtualcard = $object->getOnlineVirtualCardUrl('', 'external');
$fullinternalurltovirtualcard = $object->getOnlineVirtualCardUrl('', 'internal');
print '<script>';
print 'jQuery(document).ready(function() {
jQuery(".virtualcardpreview").click(function(event) {
event.preventDefault();
console.log("We click on the card");
window.open("'.$fullexternaleurltovirtualcard.'");
});
});';
print '</script>';
llxFooter('', 'public');
$db->close();

View File

@ -1046,13 +1046,13 @@ if ($action == 'create' || $action == 'adduserldap') {
if (preg_match('/http/', $dolibarr_main_authentication)) {
$valuetoshow .= ($valuetoshow ? ' + ' : '').$langs->trans("HTTPBasicPassword");
}
if (preg_match('/dolibarr/', $dolibarr_main_authentication)) {
if (preg_match('/dolibarr/', $dolibarr_main_authentication) || preg_match('/forceuser/', $dolibarr_main_authentication)) {
if (!empty($ldap_pass)) { // For very old system comaptibilty. Now clear password can't be viewed from LDAP read
$valuetoshow .= ($valuetoshow ? ' + ' : '').'<input type="hidden" name="password" value="'.dol_escape_htmltag($ldap_pass).'">'; // Dolibarr password is preffiled with LDAP known password
$valuetoshow .= preg_replace('/./i', '*', $ldap_pass);
} else {
// We do not use a field password but a field text to show new password to use.
$valuetoshow .= ($valuetoshow ? ' + '.$langs->trans("DolibarrPassword") : '').'<input class="minwidth300 maxwidth400 widthcentpercentminusx" maxsize="32" type="text" id="password" name="password" value="'.dol_escape_htmltag($password).'" autocomplete="new-password">';
$valuetoshow .= ($valuetoshow ? ' + '.$langs->trans("DolibarrPassword") : '').'<input class="minwidth300 maxwidth400 widthcentpercentminusx" maxlength="128" type="text" id="password" name="password" value="'.dol_escape_htmltag($password).'" autocomplete="new-password">';
if (!empty($conf->use_javascript_ajax)) {
$valuetoshow .= '&nbsp;'.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_password" class="linkobject"');
}
@ -1076,7 +1076,7 @@ if ($action == 'create' || $action == 'adduserldap') {
//$generated_password = getRandomPassword(false);
print '<tr><td>'.$langs->trans("ApiKey").'</td>';
print '<td>';
print '<input class="minwidth300 maxwidth400 widthcentpercentminusx" maxsize="32" type="text" id="api_key" name="api_key" value="'.GETPOST('api_key', 'alphanohtml').'" autocomplete="off">';
print '<input class="minwidth300 maxwidth400 widthcentpercentminusx" maxlength="128" type="text" id="api_key" name="api_key" value="'.GETPOST('api_key', 'alphanohtml').'" autocomplete="off">';
if (!empty($conf->use_javascript_ajax)) {
print '&nbsp;'.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_api_key" class="linkobject"');
}
@ -2423,14 +2423,16 @@ if ($action == 'create' || $action == 'adduserldap') {
if (preg_match('/http/', $dolibarr_main_authentication)) {
$valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').$form->textwithpicto($text, $langs->trans("DolibarrInHttpAuthenticationSoPasswordUseless", $dolibarr_main_authentication), 1, 'warning');
}
if (preg_match('/dolibarr/', $dolibarr_main_authentication)) {
if (preg_match('/dolibarr/', $dolibarr_main_authentication) || preg_match('/forceuser/', $dolibarr_main_authentication)) {
if ($caneditpassword) {
$valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').'<input maxlength="128" type="password" class="flat" id="password" name="password" value="'.dol_escape_htmltag($object->pass).'" autocomplete="new-password">';
if (!empty($conf->use_javascript_ajax)) {
$valuetoshow .= '&nbsp;'.img_picto((getDolGlobalString('USER_PASSWORD_GENERATED') === 'none' ? $langs->trans('NoPasswordGenerationRuleConfigured') : $langs->trans('Generate')), 'refresh', 'id="generate_password" class="'.(getDolGlobalString('USER_PASSWORD_GENERATED') === 'none' ? ' opacitymedium' : ' linkobject').'"');
}
} else {
$valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').preg_replace('/./i', '*', $object->pass);
}
}
// Other form for user password
$parameters = array('valuetoshow' => $valuetoshow, 'caneditpassword' => $caneditpassword);
$reshook = $hookmanager->executeHooks('printUserPasswordField', $parameters, $object, $action); // Note that $action and $object may have been modified by hook

View File

@ -3869,9 +3869,10 @@ class User extends CommonObject
* Return string with full Url to virtual card
*
* @param string $mode Mode for link
* @param string $typeofurl 'external' or 'internal'
* @return string Url string link
*/
public function getOnlineVirtualCardUrl($mode = '')
public function getOnlineVirtualCardUrl($mode = '', $typeofurl = 'external')
{
global $dolibarr_main_instance_unique_id, $dolibarr_main_url_root;
global $conf;
@ -3887,6 +3888,10 @@ class User extends CommonObject
$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
if ($typeofurl == 'internal') {
$urlwithroot = DOL_URL_ROOT;
}
return $urlwithroot.'/public/users/view.php?id='.$this->id.'&securekey='.$encodedsecurekey.$entity_qr.($mode ? '&mode='.urlencode($mode) : '');
}

View File

@ -165,7 +165,8 @@ if (getDolUserInt('USER_ENABLE_PUBLIC', 0, $object)) {
//print $langs->trans('FollowingLinksArePublic').'<br>';
print img_picto('', 'globe').' <span class="opacitymedium">'.$langs->trans('PublicVirtualCardUrl').'</span><br>';
$fullexternaleurltovirtualcard = $object->getOnlineVirtualCardUrl();
$fullexternaleurltovirtualcard = $object->getOnlineVirtualCardUrl('', 'external');
$fullinternalurltovirtualcard = $object->getOnlineVirtualCardUrl('', 'internal');
print '<div class="urllink">';
print '<input type="text" id="publicurluser" class="quatrevingtpercentminusx" value="'.$fullexternaleurltovirtualcard.'">';
@ -310,8 +311,8 @@ if (getDolUserInt('USER_ENABLE_PUBLIC', 0, $object)) {
print '<div class="center">';
print '<span class="opacitymedium">'.$langs->trans("Preview").'</span><br>';
print '<div class="virtualcard-div">';
print '<a target="_blank" rel="noopener noreferrer" href="'.$fullexternaleurltovirtualcard.'">';
print '<iframe id="virtualcard-iframe" title="" class="center" src="'.$fullexternaleurltovirtualcard.'&mode=preview">';
print '<a target="_blank" rel="noopener noreferrer cursorpointer" href="'.$fullexternaleurltovirtualcard.'">'."\n";
print '<iframe id="virtualcard-iframe" title="" class="center" src="'.$fullinternalurltovirtualcard.'&mode=preview">';
print '</iframe>';
print '</a>';
print '</div>';