Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NEW add hook 'addMoreObjectBlock' #32588

Merged
merged 14 commits into from
Jan 13, 2025
2 changes: 1 addition & 1 deletion htdocs/public/payment/newpayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@

if ($ws && !defined('USEDOLIBARRSERVER') && !defined('USEDOLIBARREDITOR')) { // So defined('USEEXTERNALSERVER') should be set but is not always
include_once DOL_DOCUMENT_ROOT.'/website/class/website.class.php';
$tmpwebsite = new WebSite($db);
$tmpwebsite = new Website($db);
$tmpwebsite->fetch(0, $ws);
$urlok = $tmpwebsite->virtualhost.'/public/payment/paymentok.php?';
$urlko = $tmpwebsite->virtualhost.'/public/payment/paymentko.php?';
Expand Down
1 change: 1 addition & 0 deletions htdocs/public/payment/paymentko.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@
*/

// Check if we have redirtodomain to do.
$doactionsthenredirect = 0;
if ($ws) {
$doactionsthenredirect = 1;
}
Expand Down
28 changes: 20 additions & 8 deletions htdocs/user/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -1211,7 +1211,7 @@
// 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" maxlength="128" type="text" id="password" name="password" value="'.dol_escape_htmltag($password).'" autocomplete="new-password">';
if (!empty($conf->use_javascript_ajax)) {
$valuetoshow .= img_picto($langs->trans('Generate'), 'refresh', 'id="generate_password" class="linkobject paddingleft"');
$valuetoshow .= img_picto($langs->transnoentities('Generate'), 'refresh', 'id="generate_password" class="linkobject paddingleft"');
}
}
}
Expand All @@ -1235,7 +1235,7 @@
print '<td>';
print '<input class="minwidth300 maxwidth400 widthcentpercentminusx" minlength="12" maxlength="128" type="text" id="api_key" name="api_key" value="'.GETPOST('api_key', 'alphanohtml').'" autocomplete="off">';
if (!empty($conf->use_javascript_ajax)) {
print img_picto($langs->trans('Generate'), 'refresh', 'id="generate_api_key" class="linkobject paddingleft"');
print img_picto($langs->transnoentities('Generate'), 'refresh', 'id="generate_api_key" class="linkobject paddingleft"');
}
print '</td></tr>';
} else {
Expand Down Expand Up @@ -1980,7 +1980,7 @@
print '</tr>';

// Date login validity
print '<tr class="nooddeven"><td class="titlefieldmax45">'.$langs->trans("RangeOfLoginValidity").'</td>';
print '<tr class="nooddeven"><td class="titlefieldmax45 nowraponall">'.$langs->trans("RangeOfLoginValidity").'</td>';
print '<td>';
if ($object->datestartvalidity) {
print '<span class="opacitymedium">'.$langs->trans("FromDate").'</span> ';
Expand Down Expand Up @@ -2043,9 +2043,9 @@
// Other form for user password
$parameters = array('valuetoshow' => $valuetoshow, 'caneditpasswordandsee' => $permissiontoeditpasswordandsee, 'caneditpasswordandsend' => $permissiontoeditpasswordandsend);
$reshook = $hookmanager->executeHooks('printUserPasswordField', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
if ($reshook > 0) {
if ($reshook === 1) {
hregis marked this conversation as resolved.
Show resolved Hide resolved
$valuetoshow = $hookmanager->resPrint; // to replace
} else {
} elseif (empty($reshook)) {
$valuetoshow .= $hookmanager->resPrint; // to add
}

Expand All @@ -2057,13 +2057,18 @@
print '</tr>'."\n";
}

// for compatibility with externals modules
if ($reshook > 1) {
print $hookmanager->resPrint;
}

// API key
if (isModEnabled('api') && ($user->id == $id || $user->admin || $user->hasRight("api", "apikey", "generate"))) {
print '<tr class="nooddeven"><td>'.$langs->trans("ApiKey").'</td>';
print '<td>';
if (!empty($object->api_key)) {
print '<span class="opacitymedium">';
print showValueWithClipboardCPButton($object->api_key, 1, $langs->trans("Hidden")); // TODO Add an option to also reveal the hash, not only copy paste
print showValueWithClipboardCPButton($object->api_key, 1, $langs->transnoentities("Hidden")); // TODO Add an option to also reveal the hash, not only copy paste
print '</span>';
}
print '</td></tr>';
Expand All @@ -2083,6 +2088,13 @@
print '</table>';
print '</div>';

// Add more object block
$parameters = array('caneditpasswordandsee' => $permissiontoeditpasswordandsee, 'caneditpasswordandsend' => $permissiontoeditpasswordandsend);
$reshook = $hookmanager->executeHooks('addMoreObjectBlock', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
if ($reshook > 0) {
print $hookmanager->resPrint;
}

print '</div>';

print '</div>';
Expand Down Expand Up @@ -2626,7 +2638,7 @@
if ($permissiontoeditpasswordandsee) {
$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 .= img_picto((getDolGlobalString('USER_PASSWORD_GENERATED') === 'none' ? $langs->trans('NoPasswordGenerationRuleConfigured') : $langs->trans('Generate')), 'refresh', 'id="generate_password" class="paddingleft'.(getDolGlobalString('USER_PASSWORD_GENERATED') === 'none' ? ' opacitymedium' : ' linkobject').'"');
$valuetoshow .= img_picto((getDolGlobalString('USER_PASSWORD_GENERATED') === 'none' ? $langs->transnoentities('NoPasswordGenerationRuleConfigured') : $langs->transnoentities('Generate')), 'refresh', 'id="generate_password" class="paddingleft'.(getDolGlobalString('USER_PASSWORD_GENERATED') === 'none' ? ' opacitymedium' : ' linkobject').'"');
}
} else {
$valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').preg_replace('/./i', '*', $object->pass);
Expand All @@ -2651,7 +2663,7 @@
if ($permissiontoeditpasswordandsee || $user->hasRight("api", "apikey", "generate")) {
print '<input class="minwidth300 maxwidth400 widthcentpercentminusx" minlength="12" maxlength="128" type="text" id="api_key" name="api_key" value="'.$object->api_key.'" autocomplete="off">';
if (!empty($conf->use_javascript_ajax)) {
print img_picto($langs->trans('Generate'), 'refresh', 'id="generate_api_key" class="linkobject paddingleft"');
print img_picto($langs->transnoentities('Generate'), 'refresh', 'id="generate_api_key" class="linkobject paddingleft"');
}
}
print '</td></tr>';
Expand Down
Loading