Skip to content

Commit

Permalink
Merge branch 'develop' into patch30347
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy authored Jul 16, 2024
2 parents bf892f8 + a3edc5d commit 8176977
Show file tree
Hide file tree
Showing 2,861 changed files with 86,820 additions and 75,769 deletions.
3 changes: 3 additions & 0 deletions dev/tools/codespell/codespell-ignore.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,6 @@ fonction
espace
methode
datee

# other
blacklists
4 changes: 2 additions & 2 deletions htdocs/admin/dict.php
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@
$tabsql[DICT_LEAD_STATUS] = "SELECT t.rowid as rowid, t.code, t.label, percent, t.position, t.active FROM ".MAIN_DB_PREFIX."c_lead_status as t";
$tabsql[DICT_FORMAT_CARDS] = "SELECT t.rowid, t.code, t.name, t.paper_size, t.orientation, t.metric, t.leftmargin, t.topmargin, t.nx, t.ny, t.spacex, t.spacey, t.width, t.height, t.font_size, t.custom_x, t.custom_y, t.active FROM ".MAIN_DB_PREFIX."c_format_cards as t";
$tabsql[DICT_INVOICE_SUBTYPE] = "SELECT t.rowid, t.code, t.label, c.label as country, c.code as country_code, t.fk_country as country_id, t.active FROM ".MAIN_DB_PREFIX."c_invoice_subtype as t, ".MAIN_DB_PREFIX."c_country as c WHERE t.fk_country = c.rowid";
$tabsql[DICT_HRM_PUBLIC_HOLIDAY] = "SELECT a.id as rowid, a.entity, a.code, a.fk_country as country_id, c.code as country_code, c.label as country, a.dayrule, a.day, a.month, a.year, a.active FROM ".MAIN_DB_PREFIX."c_hrm_public_holiday as a LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON a.fk_country=c.rowid AND c.active=1";
$tabsql[DICT_HRM_PUBLIC_HOLIDAY] = "SELECT a.id as rowid, a.entity, a.code, a.fk_country as country_id, c.code as country_code, c.label as country, a.dayrule, a.day, a.month, a.year, a.active FROM ".MAIN_DB_PREFIX."c_hrm_public_holiday as a LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON a.fk_country=c.rowid AND c.active=1 WHERE a.entity IN (".getEntity($tabname[DICT_HRM_PUBLIC_HOLIDAY]).")";
$tabsql[DICT_HRM_DEPARTMENT] = "SELECT t.rowid, t.pos, t.code, t.label, t.active FROM ".MAIN_DB_PREFIX."c_hrm_department as t";
$tabsql[DICT_HRM_FUNCTION] = "SELECT t.rowid, t.pos, t.code, t.label, t.c_level, t.active FROM ".MAIN_DB_PREFIX."c_hrm_function as t";
$tabsql[DICT_EXP_TAX_CAT] = "SELECT c.rowid, c.label, c.active, c.entity FROM ".MAIN_DB_PREFIX."c_exp_tax_cat as c";
Expand Down Expand Up @@ -474,7 +474,7 @@
$tabfieldinsert[DICT_LEAD_STATUS] = "code,label,percent,position";
$tabfieldinsert[DICT_FORMAT_CARDS] = "code,name,paper_size,orientation,metric,leftmargin,topmargin,nx,ny,spacex,spacey,width,height,font_size,custom_x,custom_y";
$tabfieldinsert[DICT_INVOICE_SUBTYPE] = "fk_country,code,label";
$tabfieldinsert[DICT_HRM_PUBLIC_HOLIDAY] = "code,dayrule,day,month,year,fk_country";
$tabfieldinsert[DICT_HRM_PUBLIC_HOLIDAY] = "code,dayrule,day,month,year,fk_country,entity";
$tabfieldinsert[DICT_HRM_DEPARTMENT] = "code,label";
$tabfieldinsert[DICT_HRM_FUNCTION] = "code,label";
$tabfieldinsert[DICT_EXP_TAX_CAT] = "label";
Expand Down
2 changes: 1 addition & 1 deletion htdocs/admin/ihm.php
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@

// Display checkboxes and fields menu left / right
print '<tr class="oddeven"><td>' . $langs->trans("MAIN_CHECKBOX_LEFT_COLUMN") . '</td><td>';
print ajax_constantonoff("MAIN_CHECKBOX_LEFT_COLUMN", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '', 'other');
print ajax_constantonoff("MAIN_CHECKBOX_LEFT_COLUMN", array(), $conf->entity, 0, 0, 1, 0, 0, 1, '', 'other');
print '</td>';
print '</tr>';

Expand Down
24 changes: 13 additions & 11 deletions htdocs/admin/system/security.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,12 @@
if ($i > 0) {
$todisabletext .= ', ';
}
$todisabletext .= img_picto($langs->trans("YouShouldSetThisToOff"), 'warning').' <span class="opacitymedium">'.$functiontodisable.'</span>';
$todisabletext .= ' <span class="opacitymedium">'.$functiontodisable.'</span>';
$i++;
}
}
if ($todisabletext) {
print $langs->trans("YouShouldDisablePHPFunctions").': '.$todisabletext;
print img_picto('', 'warning', 'class="pictofixedwidth"').$langs->trans("YouShouldDisablePHPFunctions").': '.$todisabletext;
print '<br>';
}
$todisabletext = '';
Expand All @@ -168,19 +168,21 @@
if ($i > 0) {
$todisabletext .= ', ';
}
$todisabletext .= img_picto($langs->trans("YouShouldSetThisToOff"), 'warning').' <span class="opacitymedium">'.$functiontodisable.'</span>';
$todisabletext .= ' <span class="opacitymedium">'.$functiontodisable.'</span>';
$i++;
}
}
if ($todisabletext) {
print $langs->trans("IfCLINotRequiredYouShouldDisablePHPFunctions").': '.$todisabletext;
print img_picto('', 'warning', 'class="pictofixedwidth"').$langs->trans("IfCLINotRequiredYouShouldDisablePHPFunctions").': '.$todisabletext;
print '<br>';
}

print $langs->trans("PHPFunctionsRequiredForCLI").': ';
if (in_array($functiontokeep, $arrayoffunctionsdisabled)) {
print img_picto($langs->trans("PHPFunctionsRequiredForCLI"), 'warning');
print img_picto($langs->trans("PHPFunctionsRequiredForCLI"), 'warning', 'class="pictofixedwidth"');
} else {
print img_picto('', 'tick', 'class="pictofixedwidth"');
}
print $langs->trans("PHPFunctionsRequiredForCLI").': ';
print '<span class="opacitymedium">'.$functiontokeep.'</span>';
print '<br>';

Expand Down Expand Up @@ -332,8 +334,8 @@

print '<strong>$dolibarr_main_restrict_ip</strong>: ';
if (empty($dolibarr_main_restrict_ip)) {
print '<span class="opacitymedium">'.$langs->trans("None").'</span>';
//print ' <span class="opacitymedium">('.$langs->trans("RecommendedValueIs", $langs->transnoentitiesnoconv("IPsOfUsers")).')</span>';
print $langs->trans("None");
print ' &nbsp; &nbsp; <span class="opacitymedium">('.$langs->trans("RecommendedValueIs", $langs->transnoentitiesnoconv("StaticIPsOfUsers")).')</span>';
} else {
print $dolibarr_main_restrict_ip;
}
Expand Down Expand Up @@ -371,7 +373,7 @@
$arrayofstreams = stream_get_wrappers();
if (!empty($arrayofstreams)) {
sort($arrayofstreams);
print(implode(',', $arrayofstreams)).' &nbsp; &nbsp; <span class="opacitymedium">('.$langs->trans("Recommended").': '.$langs->trans("TryToKeepOnly", 'file,http,https,php').')</span>'."\n";
print(implode(',', $arrayofstreams)).' &nbsp; &nbsp; <span class="opacitymedium">('.$langs->trans("Recommended").': '.$langs->trans("TryToKeepOnly", 'file,http,https,php,zip').')</span>'."\n";
}
print '</div>';

Expand Down Expand Up @@ -645,7 +647,7 @@
//print '<strong>'.$langs->trans("PasswordEncryption").'</strong>: ';
print '<strong>MAIN_SECURITY_HASH_ALGO</strong> = '.getDolGlobalString('MAIN_SECURITY_HASH_ALGO', '<span class="opacitymedium">'.$langs->trans("Undefined").'</span>')." &nbsp; ";
if (!getDolGlobalString('MAIN_SECURITY_HASH_ALGO')) {
print '<span class="opacitymedium"> &nbsp; &nbsp; If unset: \'md5\'</span>';
print '<span class="opacitymedium"> &nbsp; &nbsp; (If unset: \'md5\')</span>';
}
if (getDolGlobalString('MAIN_SECURITY_HASH_ALGO') != 'password_hash') {
print '<br><strong>MAIN_SECURITY_SALT</strong> = '.getDolGlobalString('MAIN_SECURITY_SALT', '<span class="opacitymedium">'.$langs->trans("Undefined").'</span>').'<br>';
Expand All @@ -659,7 +661,7 @@
print '- Go on home - setup - other and add constant MAIN_SECURITY_HASH_ALGO to value \'password_hash\'<br>';
print '- In same session, WITHOUT LOGGING OUT, go into your admin user record and set a new password<br>';
print '- You can now logout and login with this new password. You must now reset password of all other users.<br>';
print '</div><br>';
print '</div>';
}
print '<br>';

Expand Down
19 changes: 15 additions & 4 deletions htdocs/admin/translation.php
Original file line number Diff line number Diff line change
Expand Up @@ -569,10 +569,21 @@
if ($limit && $i > ($offset + $limit)) {
break;
}
print '<tr class="oddeven"><td>'.$langcode.'</td><td>'.$key.'</td><td class="small">';
$titleforvalue = $langs->trans("Translation").' en_US for key '.$key.':<br>'.(!empty($langsenfileonly->tab_translate[$key]) ? $langsenfileonly->trans($key) : '<span class="opacitymedium">'.$langs->trans("None").'</span>');
print '<span title="'.dol_escape_htmltag($titleforvalue).'" class="classfortooltip">';
print dol_escape_htmltag($val);
print '<tr class="oddeven"><td>'.$langcode.'</td><td>'.$key.'</td>';
print '<td class="small">';
$titleforvalue = $langs->trans("Translation").' en_US for key '.$key.':<br>';
if (!empty($langsenfileonly->tab_translate[$key])) {
if (substr_count($langsenfileonly->tab_translate[$key], '%s') <= 4) { // To avoid errors when more than 4 %s.
$titleforvalue .= $langsenfileonly->trans($key);
}
} else {
$titleforvalue .= '<span class="opacitymedium">'.$langs->trans("None").'</span>';
}
print '<span title="'.dolPrintHTMLForAttribute($titleforvalue).'" class="classfortooltip">';
print dolPrintHTML($val);
if (substr_count($langsenfileonly->tab_translate[$key], '%s') > 4) {
print '<br><div class="warning">Error, more than 4 %s in the source</div>';
}
print '</span>';
print '</td>';
print '<td class="right nowraponall">';
Expand Down
65 changes: 50 additions & 15 deletions htdocs/ai/admin/custom_prompt.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@
'textgeneration' => array('label' => $langs->trans('TextGeneration').' ('.$langs->trans("Other").')', 'picto'=>'', 'status'=>'notused'),
'imagegeneration' => array('label' => 'ImageGeneration', 'picto'=>'', 'status'=>'notused'),
'videogeneration' => array('label' => 'VideoGeneration', 'picto'=>'', 'status'=>'notused'),
'audiogeneration' => array('label' => 'AudioGeneration', 'picto'=>'', 'status'=>'notused'),
'transcription' => array('label' => 'Transcription', 'picto'=>'', 'status'=>'notused'),
'translation' => array('label' => 'Translation', 'picto'=>'', 'status'=>'notused'),
'audiotext' => array('label' => 'AudioText', 'picto'=>'', 'status'=>'notused')
'translation' => array('label' => 'Translation', 'picto'=>'', 'status'=>'notused')
);


Expand All @@ -86,6 +86,7 @@
$functioncode = GETPOST('functioncode', 'alpha');
$pre_prompt = GETPOST('prePrompt');
$post_prompt = GETPOST('postPrompt');
$blacklists = GETPOST('blacklists');
// get all configs in const AI

$currentConfigurationsJson = getDolGlobalString('AI_CONFIGURATIONS_PROMPT');
Expand All @@ -94,6 +95,7 @@
if ($action == 'update' && GETPOST('cancel')) {
$action = 'edit';
}

if ($action == 'update' && !GETPOST('cancel')) {
$error = 0;
if (empty($functioncode)) {
Expand All @@ -104,14 +106,17 @@
$currentConfigurations = [];
}

if (empty($functioncode) || (empty($pre_prompt) && empty($post_prompt))) {
$blacklistArray = array_filter(array_map('trim', explode(',', $blacklists)));

if (empty($functioncode) || (empty($pre_prompt) && empty($post_prompt) && empty($blacklists))) {
if (isset($currentConfigurations[$functioncode])) {
unset($currentConfigurations[$functioncode]);
}
} else {
$currentConfigurations[$functioncode] = [
'prePrompt' => $pre_prompt,
'postPrompt' => $post_prompt,
'blacklists' => $blacklistArray,
];
}

Expand All @@ -133,9 +138,12 @@
if ($action == 'updatePrompts') {
$key = GETPOST('key', 'alpha');

$blacklistArray = array_filter(array_map('trim', explode(',', $blacklists)));

$currentConfigurations[$key] = [
'prePrompt' => $pre_prompt,
'postPrompt' => $post_prompt,
'blacklists' => $blacklistArray,
];

$newConfigurationsJson = json_encode($currentConfigurations, JSON_UNESCAPED_UNICODE);
Expand Down Expand Up @@ -222,9 +230,10 @@
$out .= '<td></td>';
$out .= '</tr>';
$out .= '</thead>';

$out .= '<tbody>';
$out .= '<tr class="oddeven">';
$out .= '<td class="col-setup-title">';
$out .= '<td class="col-setup-title titlefield">';
$out .= '<span id="module" class="spanforparamtooltip">'.$langs->trans("Feature").'</span>';
$out .= '</td>';
$out .= '<td>';
Expand Down Expand Up @@ -270,6 +279,14 @@
$out .= '<textarea class="flat minwidth500 quatrevingtpercent" id="postPromptInput" name="postPrompt" rows="3"></textarea>';
$out .= '</td>';
$out .= '</tr>';
$out .= '<tr class="oddeven">';
$out .= '<td class="col-setup-title">';
$out .= '<span id="blacklists" class="spanforparamtooltip">'.$langs->trans("BlackListWords").' '.img_help(1, 'Words must be separated by a coma (",")').'</span>';
$out .= '</td>';
$out .= '<td>';
$out .= '<textarea class="flat minwidth500 quatrevingtpercent" id="blacklistsInput" name="blacklists" rows="3"></textarea>';
$out .= '</td>';
$out .= '</tr>';
$out .= '</tbody>';
$out .= '</table>';

Expand All @@ -285,15 +302,20 @@
$out = '';

if (!empty($currentConfigurations)) {
$out = '<table class="noborder centpercent">';
foreach ($currentConfigurations as $key => $config) {
if (!empty($key) && !preg_match('/^[a-z]+$/i', $key)) { // Ignore empty saved setup
continue;
}

$out .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
$out .= '<input type="hidden" name="token" value="'.newToken().'">';
$out .= '<input type="hidden" name="key" value="'.$key.'" />';
$out .= '<input type="hidden" name="action" value="updatePrompts">';

$out .= '<table class="noborder centpercent">';
$out .= '<thead>';
$out .= '<tr class="liste_titre">';
$out .= '<td>'.$arrayofaifeatures[$key]['picto'].' '.$langs->trans($arrayofaifeatures[$key]['label']);
$out .= '<td class="titlefield">'.$arrayofaifeatures[$key]['picto'].' '.$langs->trans($arrayofaifeatures[$key]['label']);
$out .= '<a class="viewfielda reposition marginleftonly marginrighttonly showInputBtn" href="#" data-index="'.$key.'" data-state="edit" data-icon-edit="'.dol_escape_htmltag(img_edit()).'" data-icon-cancel="'.dol_escape_htmltag(img_view()).'">'.img_edit().'</a>';
$out .= '<a class="deletefielda reposition marginleftonly right" href="'.$_SERVER["PHP_SELF"].'?action=deleteproperty&token='.newToken().'&key='.urlencode($key).'">'.img_delete().'</a>';
$out .= '</td>';
Expand All @@ -302,10 +324,6 @@
$out .= '</thead>';
$out .= '<tbody>';

$out .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
$out .= '<input type="hidden" name="token" value="'.newToken().'">';
$out .= '<input type="hidden" name="key" value="'.$key.'" />';
$out .= '<input type="hidden" name="action" value="updatePrompts">';
$out .= '<tr class="oddeven">';
$out .= '<td class="col-setup-title">';
$out .= '<span id="prePrompt" class="spanforparamtooltip">'.$langs->trans("Pre-Prompt").'</span>';
Expand All @@ -314,20 +332,35 @@
$out .= '<textarea class="flat minwidth500" id="prePromptInput_'.$key.'" name="prePrompt" rows="2" disabled>'.$config['prePrompt'].'</textarea>';
$out .= '</td>';
$out .= '</tr>';

$out .= '<tr class="oddeven">';
$out .= '<td class="col-setup-title">';
$out .= '<span id="postPrompt" class="spanforparamtooltip">'.$langs->trans("Post-Prompt").'</span>';
$out .= '</td>';
$out .= '<td>';
$out .= '<textarea class="flat minwidth500" id="postPromptInput_'.$key.'" name="postPrompt" rows="2" disabled>'.$config['postPrompt'].'</textarea>';
$out .= '<br><input type="submit" class="button small submitBtn" name="modify" data-index="'.$key.'" style="display: none;" value="'.dol_escape_htmltag($langs->trans("Modify")).'"/>';
$out .= '</td>';
$out .= '</tr>';

$out .= '<tr id="fichetwothirdright-'.$key.'" class="oddeven">';
$out .= '<td>'.$langs->trans("BlackListWords").'</td>';
$out .= '<td>';
$out .= '<textarea class="flat minwidth500" id="blacklist_'.$key.'" name="blacklists" rows="6" disabled>'.(isset($config['blacklists']) ? implode(', ', (array) $config['blacklists']) : '').'</textarea>';
$out .= '</td>';
$out .= '</tr>';

$out .= '<tr>';
$out .= '<td></td>';
$out .= '<td>';
$out .= '<input type="submit" class="button small submitBtn" name="modify" data-index="'.$key.'" style="display: none;" value="'.dol_escape_htmltag($langs->trans("Modify")).'"/>';
$out .= '</td>';
$out .= '</tr>';

$out .= '</tbody>';
$out .= '</table>';

$out .= '</form>';
}
$out .= '</tbody>';
$out .= '</table>';
}


Expand All @@ -341,9 +374,11 @@
if (moduleConfig) {
$('#prePromptInput').val(moduleConfig.prePrompt || '');
$('#postPromptInput').val(moduleConfig.postPrompt || '');
$('#blacklistsInput').val(moduleConfig.blacklists ? moduleConfig.blacklists.join(', ') : '');
} else {
$('#prePromptInput').val('');
$('#postPromptInput').val('');
$('#blacklistsInput').val('');
}
});
Expand All @@ -355,6 +390,7 @@
if(state === 'edit') {
$('#prePromptInput_'+index).removeAttr('disabled').focus();
$('#postPromptInput_'+index).removeAttr('disabled');
$('#blacklist_'+index).removeAttr('disabled');
$('.submitBtn[data-index=' + index + ']').show();
$(this).html($(this).data('icon-cancel'));
$(this).data('state', 'cancel');
Expand All @@ -363,14 +399,13 @@
$('#prePromptInput_'+index).attr('disabled', 'disabled');
$('#postPromptInput_'+index).attr('disabled', 'disabled');
$('#blacklist_'+index).attr('disabled', 'disabled');
$('.submitBtn[data-index=' + index + ']').hide();
$(this).html($(this).data('icon-edit'));
$(this).data('state', 'edit');
}
});
});
</script>";

print $out;
Expand Down
4 changes: 2 additions & 2 deletions htdocs/ai/class/ai.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function __construct($db)
*
* @param string $instructions Instruction to generate content
* @param string $model Model name ('gpt-3.5-turbo', 'gpt-4-turbo', 'dall-e-3', ...)
* @param string $function Code of the feature we want to use ('textgeneration', 'transcription', 'audiotext', 'imagegeneration', 'translation')
* @param string $function Code of the feature we want to use ('textgeneration', 'transcription', 'audiogeneration', 'imagegeneration', 'translation')
* @param string $format Format for output ('', 'html', ...)
* @return mixed $response
*/
Expand All @@ -91,7 +91,7 @@ public function generateContent($instructions, $model = 'auto', $function = 'tex
$model = getDolGlobalString('AI_API_CHATGPT_MODEL_IMAGE', 'dall-e-3');
}
}
} elseif ($function == 'audiotext') {
} elseif ($function == 'audiogeneration') {
if ($this->apiService == 'chatgpt') {
$this->apiEndpoint = 'https://api.openai.com/v1/audio/speech';
if ($model == 'auto') {
Expand Down
2 changes: 1 addition & 1 deletion htdocs/comm/action/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
$actioncode = '0';
}
} else {
$actioncode = GETPOST("search_actioncode", "alpha", 3) ? GETPOST("search_actioncode", "alpha", 3) : (GETPOST("search_actioncode") == '0' ? '0' : ((!getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE') || $disabledefaultvalues) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE));
$actioncode = GETPOST("search_actioncode", "alpha", 3) ? GETPOST("search_actioncode", "alpha", 3) : (GETPOST("search_actioncode") == '0' ? '0' : ((!getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE') || $disabledefaultvalues) ? '' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE')));
}

if ($status == '' && !GETPOSTISSET('search_status')) {
Expand Down
Loading

0 comments on commit 8176977

Please sign in to comment.