Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into

develop
This commit is contained in:
Laurent Destailleur 2022-01-26 11:29:50 +01:00
commit 2dda4f5924
12 changed files with 448 additions and 71 deletions

View File

@ -1,35 +0,0 @@
---
name: Bug report
about: Create a report to help us fix something that is broken
title: ''
labels: Bug
assignees: ''
---
# Instructions
*This is a template to help you report good issues. You may use [Github Markdown](https://help.github.com/articles/getting-started-with-writing-and-formatting-on-github/) syntax to format your issue report.*
*Please:*
- *replace the bracket enclosed texts with meaningful information*
- *remove any unused sub-section*
# Bug
[*Short description*]
## Environment
- **Version**: [*Affected Dolibarr version(s)*]
- **OS**: [*Server OS type and version*]
- **Web server**: [*Webserver type and version*]
- **PHP**: [*PHP version*]
- **Database**: [*Database type and version*]
- **URL(s)**: [*Affected URL(s)*]
## Expected and actual behavior
[*Verbose description*]
## Steps to reproduce the behavior
[*Verbose description*]
## [Attached files](https://help.github.com/articles/issue-attachments) (Screenshots, screencasts, dolibarr.log, debugging informations…)
[*Files*]

80
.github/ISSUE_TEMPLATE/bug_report.yml vendored Normal file
View File

@ -0,0 +1,80 @@
name: Bug report
description: Create a report to help us fix something that is broken
labels: ["Bug"]
body:
- type: markdown
attributes:
value: |
This is a template to help you report good issues. You may use [Github Markdown](https://help.github.com/articles/getting-started-with-writing-and-formatting-on-github/) syntax to format your issue report.
- type: textarea
id: bug
attributes:
label: Bug
description: Please give a short description of the bug
validations:
required: true
- type: input
id: environment-version
attributes:
label: Environment Version
description: Affected Dolibarr version(s)
- type: input
id: environment-os
attributes:
label: Environment OS
description: Server OS type and version
- type: input
id: environment-webserver
attributes:
label: Environment Web server
description: Webserver type and version
- type: input
id: environment-php
attributes:
label: Environment PHP
description: PHP version
- type: input
id: environment-database
attributes:
label: Environment Database
description: Database type and version
- type: input
id: environment-urls
attributes:
label: Environment URL(s)
description: Affected URL(s)
- type: textarea
id: expected-behaviour
attributes:
label: Expected and actual behavior
description: Verbose description
- type: textarea
id: reproduce
attributes:
label: Steps to reproduce the behavior
description: Verbose description
- type: textarea
id: files
attributes:
label: Attached files
description: Screenshots, screencasts, dolibarr.log, debugging informations
- type: checkboxes
id: terms
attributes:
label: Code of Conduct
description: By submitting this issue, you agree to follow our [Code of Conduct](https://github.com/Dolibarr/dolibarr/blob/develop/.github/CODE_OF_CONDUCT.md)
options:
- label: I agree to follow this project's Code of Conduct
required: true

View File

@ -1,27 +0,0 @@
---
name: Feature request
about: Suggest a new idea for this project
title: ''
labels: Feature request
assignees: ''
---
# Instructions
*This is a template to help you report good issues. You may use [Github Markdown](https://help.github.com/articles/getting-started-with-writing-and-formatting-on-github/) syntax to format your issue report.*
*Please:*
- *replace the bracket enclosed texts with meaningful information*
- *remove any unused sub-section*
# Feature Request
[*Short description*]
## Use case
[*Verbose description*]
## Suggested implementation
[*Verbose description*]
## Suggested steps
[*List of tasks to achieve goal*]

View File

@ -0,0 +1,44 @@
name: Feature request
description: Suggest a new idea for this project
labels: ["Feature request"]
body:
- type: markdown
attributes:
value: |
This is a template to help you report good issues. You may use [Github Markdown](https://help.github.com/articles/getting-started-with-writing-and-formatting-on-github/) syntax to format your issue report.
- type: textarea
id: feature-request
attributes:
label: Feature Request
description: Short description
validations:
required: true
- type: textarea
id: use-case
attributes:
label: Use case
description: Verbose description
- type: textarea
id: suggested-implementation
attributes:
label: Suggested implementation
description: Verbose description
- type: textarea
id: suggested-steps
attributes:
label: Suggested steps
description: List of tasks to achieve goal
- type: checkboxes
id: terms
attributes:
label: Code of Conduct
description: By submitting this issue, you agree to follow our [Code of Conduct](https://github.com/Dolibarr/dolibarr/blob/develop/.github/CODE_OF_CONDUCT.md)
options:
- label: I agree to follow this project's Code of Conduct
required: true

117
htdocs/contact/project.php Normal file
View File

@ -0,0 +1,117 @@
<?php
/*
* Copyright (C) 2021 VIAL--GOUTEYRON Quentin <quentin.vial-gouteyron@atm-consulting.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/contact/project.php
* \ingroup contact
* \brief Page of third party projects
*/
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
$langs->loadLangs(array("contacts", "companies", "projects"));
// Security check
$id = GETPOST('id', 'int');
$result = restrictedArea($user, 'contact', $id, 'socpeople&societe');
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('projectcontact'));
/*
* Actions
*/
$parameters = array('id' => $id);
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
/*
* View
*/
$form = new Form($db);
if ($id) {
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/contact.lib.php';
$object = new Contact($db);
$result = $object->fetch($id);
if (empty($object->thirdparty)) {
$object->fetch_thirdparty();
}
$socid = $object->thirdparty->id;
$title = $langs->trans("Projects");
if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
$title = $object->name." - ".$title;
}
llxHeader('', $title);
if (! empty($conf->notification->enabled)) {
$langs->load("mails");
}
$head = contact_prepare_head($object);
print dol_get_fiche_head($head, 'project', $langs->trans("Contact"), -1, 'contact');
$linkback = '<a href="'.DOL_URL_ROOT.'/contact/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
$morehtmlref = '<div class="refidno">';
if (empty($conf->global->SOCIETE_DISABLE_CONTACTS) && !empty($socid)) {
$object->thirdparty->fetch($socid);
// Thirdparty
$morehtmlref .= $langs->trans('ThirdParty').' : ';
if ($object->thirdparty->id > 0) {
$morehtmlref .= $object->thirdparty->getNomUrl(1, 'contact');
} else {
$morehtmlref .= $langs->trans("ContactNotLinkedToCompany");
}
}
$morehtmlref .= '</div>';
dol_banner_tab($object, 'id', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom', $morehtmlref);
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border centpercent tableforfield">';
// Civility
print '<tr><td class="titlefield">'.$langs->trans("UserTitle").'</td><td>';
print $object->getCivilityLabel();
print '</td></tr>';
print '</table>';
print '</div>';
print dol_get_fiche_end();
print '<br>';
// Projects list
$result = show_contacts_projects($conf, $langs, $db, $object, $_SERVER["PHP_SELF"].'?id='.$object->id, 1);
}
// End of page
llxFooter();
$db->close();

View File

@ -1690,11 +1690,17 @@ class Form
$out .= '<select class="flat'.($moreclass ? ' '.$moreclass : '').'" id="'.$htmlid.'" name="'.$htmlname.(($num || empty($disableifempty)) ? '' : ' disabled').($multiple ? '[]' : '').'" '.($multiple ? 'multiple' : '').' '.(!empty($moreparam) ? $moreparam : '').'>';
}
if (($showempty == 1 || ($showempty == 3 && $num > 1)) && !$multiple) {
$out .= '<option value="0"'.(in_array(0, $selected) ? ' selected' : '').'>&nbsp;</option>';
if ($showempty && ! is_numeric($showempty)) {
$textforempty = $showempty;
$out .= '<option class="optiongrey" value="-1"'.(in_array(-1, $selected) ? ' selected' : '').'>'.$textforempty.'</option>';
}
if ($showempty == 2) {
$out .= '<option value="0"'.(in_array(0, $selected) ? ' selected' : '').'>-- '.$langs->trans("Internal").' --</option>';
else {
if (($showempty == 1 || ($showempty == 3 && $num > 1)) && ! $multiple) {
$out .= '<option value="0"'.(in_array(0, $selected) ? ' selected' : '').'>&nbsp;</option>';
}
if ($showempty == 2) {
$out .= '<option value="0"'.(in_array(0, $selected) ? ' selected' : '').'>-- '.$langs->trans("Internal").' --</option>';
}
}
$i = 0;

View File

@ -57,6 +57,40 @@ function contact_prepare_head(Contact $object)
$head[$tab][2] = 'perso';
$tab++;
if (!empty($conf->projet->enabled) && (!empty($user->rights->projet->lire))) {
$nbProject = 0;
// Enable caching of thirdrparty count projects
require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
$cachekey = 'count_projects_contact_'.$object->id;
$dataretrieved = dol_getcache($cachekey);
if (!is_null($dataretrieved)) {
$nbProject = $dataretrieved;
} else {
$sql = 'SELECT COUNT(n.rowid) as nb';
$sql .= ' FROM '.MAIN_DB_PREFIX.'projet as n';
$sql .= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact as cc ON (n.rowid = cc.element_id)';
$sql .= ' WHERE cc.fk_socpeople = '.((int) $object->id);
$sql .= ' AND cc.fk_c_type_contact IN (SELECT rowid FROM '.MAIN_DB_PREFIX.'c_type_contact WHERE element="project" AND source="external")';
$sql .= ' AND n.entity IN ('.getEntity('project').')';
$resql = $db->query($sql);
if ($resql) {
$obj = $db->fetch_object($resql);
$nbProject = $obj->nb;
} else {
dol_print_error($db);
}
dol_setcache($cachekey, $nbProject, 120); // If setting cache fails, this is not a problem, so we do not test result.
}
$head[$tab][0] = DOL_URL_ROOT.'/contact/project.php?id='.$object->id;
$head[$tab][1] = $langs->trans("Projects");
if ($nbProject > 0) {
$head[$tab][1] .= '<span class="badge marginleftonlyshort">'.$nbProject.'</span>';
}
$head[$tab][2] = 'project';
$tab++;
}
// Related items
if (!empty($conf->commande->enabled) || !empty($conf->propal->enabled) || !empty($conf->facture->enabled) || !empty($conf->ficheinter->enabled) || (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) {
$head[$tab][0] = DOL_URL_ROOT.'/contact/consumption.php?id='.$object->id;
@ -117,3 +151,131 @@ function contact_prepare_head(Contact $object)
return $head;
}
/**
* Show html area for list of projects
*
* @param Conf $conf Object conf
* @param Translate $langs Object langs
* @param DoliDB $db Database handler
* @param Object $object Third party object
* @param string $backtopage Url to go once contact is created
* @param int $nocreatelink 1=Hide create project link
* @param string $morehtmlright More html on right of title
* @return int
*/
function show_contacts_projects($conf, $langs, $db, $object, $backtopage = '', $nocreatelink = 0, $morehtmlright = '')
{
global $user;
$i = -1;
if (!empty($conf->projet->enabled) && $user->rights->projet->lire) {
$langs->load("projects");
$newcardbutton = '';
if (!empty($conf->projet->enabled) && $user->rights->projet->creer && empty($nocreatelink)) {
$newcardbutton .= dolGetButtonTitle($langs->trans('AddProject'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/projet/card.php?socid='.$object->id.'&amp;action=create&amp;backtopage='.urlencode($backtopage));
}
print "\n";
print load_fiche_titre($langs->trans("ProjectsHavingThisContact"), $newcardbutton.$morehtmlright, '');
print '<div class="div-table-responsive">';
print "\n".'<table class="noborder" width=100%>';
$sql = 'SELECT p.rowid as id, p.entity, p.title, p.ref, p.public, p.dateo as do, p.datee as de, p.fk_statut as status, p.fk_opp_status, p.opp_amount, p.opp_percent, p.tms as date_update, p.budget_amount';
$sql .= ', cls.code as opp_status_code, ctc.libelle';
$sql .= ' FROM '.MAIN_DB_PREFIX.'projet as p';
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_lead_status as cls on p.fk_opp_status = cls.rowid';
$sql .= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact as cc ON (p.rowid = cc.element_id)';
$sql .= ' INNER JOIN '.MAIN_DB_PREFIX.'c_type_contact as ctc ON (ctc.rowid = cc.fk_c_type_contact)';
$sql .= ' WHERE cc.fk_socpeople = '.((int) $object->id);
$sql .= ' AND ctc.element="project" AND ctc.source="external"';
$sql .= ' AND p.entity IN ('.getEntity('project').')';
$sql .= ' ORDER BY p.dateo DESC';
$result = $db->query($sql);
if ($result) {
$num = $db->num_rows($result);
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Ref").'</td>';
print '<td>'.$langs->trans("Name").'</td>';
print '<td>'.$langs->trans("ContactType").'</td>';
print '<td class="center">'.$langs->trans("DateStart").'</td>';
print '<td class="center">'.$langs->trans("DateEnd").'</td>';
print '<td class="right">'.$langs->trans("OpportunityAmountShort").'</td>';
print '<td class="center">'.$langs->trans("OpportunityStatusShort").'</td>';
print '<td class="right">'.$langs->trans("OpportunityProbabilityShort").'</td>';
print '<td class="right">'.$langs->trans("Status").'</td>';
print '</tr>';
if ($num > 0) {
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
$projecttmp = new Project($db);
$i = 0;
while ($i < $num) {
$obj = $db->fetch_object($result);
$projecttmp->fetch($obj->id);
// To verify role of users
$userAccess = $projecttmp->restrictedProjectArea($user);
if ($user->rights->projet->lire && $userAccess > 0) {
print '<tr class="oddeven">';
// Ref
print '<td>';
print $projecttmp->getNomUrl(1);
print '</td>';
// Label
print '<td>'.$obj->title.'</td>';
print '<td>'.$obj->libelle.'</td>';
// Date start
print '<td class="center">'.dol_print_date($db->jdate($obj->do), "day").'</td>';
// Date end
print '<td class="center">'.dol_print_date($db->jdate($obj->de), "day").'</td>';
// Opp amount
print '<td class="right">';
if ($obj->opp_status_code) {
print price($obj->opp_amount, 1, '', 1, -1, -1, '');
}
print '</td>';
// Opp status
print '<td class="center">';
if ($obj->opp_status_code) {
print $langs->trans("OppStatus".$obj->opp_status_code);
}
print '</td>';
// Opp percent
print '<td class="right">';
if ($obj->opp_percent) {
print price($obj->opp_percent, 1, '', 1, 0).'%';
}
print '</td>';
// Status
print '<td class="right">'.$projecttmp->getLibStatut(5).'</td>';
print '</tr>';
}
$i++;
}
} else {
print '<tr class="oddeven"><td colspan="8"><span class="opacitymedium">'.$langs->trans("None").'</span></td></tr>';
}
$db->free($result);
} else {
dol_print_error($db);
}
print "</table>";
print '</div>';
print "<br>\n";
}
return $i;
}

View File

@ -197,6 +197,7 @@ InputPerMonth=Input per month
InputDetail=Input detail
TimeAlreadyRecorded=This is time spent already recorded for this task/day and user %s
ProjectsWithThisUserAsContact=Projects with this user as contact
ProjectsWithThisContact=Projects with this contact
TasksWithThisUserAsContact=Tasks assigned to this user
ResourceNotAssignedToProject=Not assigned to project
ResourceNotAssignedToTheTask=Not assigned to the task
@ -284,4 +285,5 @@ PROJECT_CLASSIFY_CLOSED_WHEN_ALL_TASKS_DONE_help=Note: existing projects with al
SelectLinesOfTimeSpentToInvoice=Select lines of time spent that are unbilled, then bulk action "Generate Invoice" to bill them
ProjectTasksWithoutTimeSpent=Project tasks without time spent
FormForNewLeadDesc=Thanks to fill the following form to contact us. You can also send us an email directly to <b>%s</b>.
ProjectsHavingThisContact=Projects having this contact
StartDateCannotBeAfterEndDate=End date cannot be before start date

View File

@ -197,6 +197,7 @@ InputPerMonth=Saisie par mois
InputDetail=Saisir le détail
TimeAlreadyRecorded=C'est le temps passé déjà enregistré pour cette tâche/jour et pour l'utilisateur %s
ProjectsWithThisUserAsContact=Projets avec cet utilisateur comme contact
ProjectsWithThisContact=Projets avec ce contact
TasksWithThisUserAsContact=Tâches assignées à cet utilisateur
ResourceNotAssignedToProject=Non assigné au projet
ResourceNotAssignedToTheTask=Non assigné à la tache
@ -284,4 +285,5 @@ PROJECT_CLASSIFY_CLOSED_WHEN_ALL_TASKS_DONE_help=Remarque : les projets existant
SelectLinesOfTimeSpentToInvoice=Sélectionnez les lignes de temps passé non facturées, puis l'action groupée "Générer la facture" pour les facturer
ProjectTasksWithoutTimeSpent=Tâches de projet sans temps consommé
FormForNewLeadDesc=Veuillez remplir ce formulaire de contact ou écrivez un e-mail à <b>%s</b>.
ProjectsHavingThisContact=Projets ayant ce contact associé
StartDateCannotBeAfterEndDate=La date de fin ne peux être avant la date de début

View File

@ -98,6 +98,7 @@ $search_opp_amount = GETPOST("search_opp_amount", 'alpha');
$search_budget_amount = GETPOST("search_budget_amount", 'alpha');
$search_public = GETPOST("search_public", 'int');
$search_project_user = GETPOST('search_project_user', 'int');
$search_project_contact = GETPOST('search_project_contact', 'int');
$search_sale = GETPOST('search_sale', 'int');
$search_usage_opportunity = GETPOST('search_usage_opportunity', 'int');
$search_usage_task = GETPOST('search_usage_task', 'int');
@ -253,6 +254,7 @@ if (empty($reshook)) {
$search_public = "";
$search_sale = "";
$search_project_user = '';
$search_project_contact = '';
$search_sday = "";
$search_smonth = "";
$search_syear = "";
@ -364,13 +366,14 @@ if (empty($user->rights->projet->all->lire)) {
// Get id of types of contacts for projects (This list never contains a lot of elements)
$listofprojectcontacttype = array();
$sql = "SELECT ctc.rowid, ctc.code FROM ".MAIN_DB_PREFIX."c_type_contact as ctc";
$listofprojectcontacttypeexternal = array();
$sql = "SELECT ctc.rowid, ctc.code, ctc.source FROM ".MAIN_DB_PREFIX."c_type_contact as ctc";
$sql .= " WHERE ctc.element = '".$db->escape($object->element)."'";
$sql .= " AND ctc.source = 'internal'";
$resql = $db->query($sql);
if ($resql) {
while ($obj = $db->fetch_object($resql)) {
$listofprojectcontacttype[$obj->rowid] = $obj->code;
if ($obj->source == 'internal') $listofprojectcontacttype[$obj->rowid] = $obj->code;
else $listofprojectcontacttypeexternal[$obj->rowid] = $obj->code;
}
} else {
dol_print_error($db);
@ -378,6 +381,9 @@ if ($resql) {
if (count($listofprojectcontacttype) == 0) {
$listofprojectcontacttype[0] = '0'; // To avoid sql syntax error if not found
}
if (count($listofprojectcontacttypeexternal) == 0) {
$listofprojectcontacttypeexternal[0] = '0'; // To avoid sql syntax error if not found
}
$distinct = 'DISTINCT'; // We add distinct until we are added a protection to be sure a contact of a project and task is only once.
$sql = "SELECT ".$distinct." p.rowid as id, p.ref, p.title, p.fk_statut as status, p.fk_opp_status, p.public, p.fk_user_creat,";
@ -418,6 +424,9 @@ if ($search_sale > 0) {
if ($search_project_user > 0) {
$sql .= ", ".MAIN_DB_PREFIX."element_contact as ecp";
}
if ($search_project_contact > 0) {
$sql .= ", ".MAIN_DB_PREFIX."element_contact as ecp_contact";
}
$sql .= " WHERE p.entity IN (".getEntity('project').')';
if (!empty($conf->categorie->enabled)) {
$sql .= Categorie::getFilterSelectQuery(Categorie::TYPE_PROJECT, "p.rowid", $search_category_array);
@ -502,6 +511,9 @@ if ($search_sale > 0) {
if ($search_project_user > 0) {
$sql .= " AND ecp.fk_c_type_contact IN (".$db->sanitize(join(',', array_keys($listofprojectcontacttype))).") AND ecp.element_id = p.rowid AND ecp.fk_socpeople = ".((int) $search_project_user);
}
if ($search_project_contact > 0) {
$sql .= " AND ecp_contact.fk_c_type_contact IN (".$db->sanitize(join(',', array_keys($listofprojectcontacttypeexternal))).") AND ecp_contact.element_id = p.rowid AND ecp_contact.fk_socpeople = ".((int) $search_project_contact);
}
if ($search_opp_amount != '') {
$sql .= natural_search('p.opp_amount', $search_opp_amount, 1);
}
@ -690,6 +702,9 @@ if ($search_public != '') {
if ($search_project_user != '') {
$param .= '&search_project_user='.urlencode($search_project_user);
}
if ($search_project_contact != '') {
$param .= '&search_project_user='.urlencode($search_project_contact);
}
if ($search_sale > 0) {
$param .= '&search_sale='.urlencode($search_sale);
}
@ -809,6 +824,11 @@ if (empty($user->rights->user->user->lire)) {
$moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->select_dolusers($search_project_user ? $search_project_user : '', 'search_project_user', $tmptitle, '', 0, $includeonly, '', 0, 0, 0, '', 0, '', 'maxwidth250');
$moreforfilter .= '</div>';
$moreforfilter .= '<div class="divsearchfield">';
$tmptitle = $langs->trans('ProjectsWithThisContact');
$moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->selectcontacts(0, $search_project_contact ? $search_project_contact : '', 'search_project_contact', $tmptitle);
$moreforfilter .= '</div>';
// If the user can view thirdparties other than his'
if ($user->rights->societe->client->voir || $socid) {
$langs->load("commercial");

View File

@ -157,6 +157,8 @@ $arrayfields = dol_sort_array($arrayfields, 'position');
if (!$user->rights->ticket->read) {
accessforbidden();
}
// restrict view to current user's company
if ($user->socid > 0) $socid = $user->socid;
// Store current page url
$url_page_current = DOL_URL_ROOT.'/ticket/list.php';

View File

@ -1397,6 +1397,8 @@ class User extends CommonObject
dol_syslog(get_class($this)."::create login=".$this->login.", user=".(is_object($user) ? $user->id : ''), LOG_DEBUG);
$badCharUnauthorizedIntoLoginName = getDolGlobalString('MAIN_LOGIN_BADCHARUNAUTHORIZED', ',@<>"\'');
// Check parameters
if (!empty($conf->global->USER_MAIL_REQUIRED) && !isValidEMail($this->email)) {
$langs->load("errors");
@ -1407,7 +1409,7 @@ class User extends CommonObject
$langs->load("errors");
$this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Login"));
return -1;
} elseif (preg_match('/[,@<>"\']/', $this->login)) {
} elseif (preg_match('/['.preg_quote($badCharUnauthorizedIntoLoginName, '/').']/', $this->login)) {
$langs->load("errors");
$this->error = $langs->trans("ErrorBadCharIntoLoginName");
return -1;
@ -1791,6 +1793,8 @@ class User extends CommonObject
$this->fk_warehouse = (int) $this->fk_warehouse;
// Check parameters
$badCharUnauthorizedIntoLoginName = getDolGlobalString('MAIN_LOGIN_BADCHARUNAUTHORIZED', ',@<>"\'');
if (!empty($conf->global->USER_MAIL_REQUIRED) && !isValidEMail($this->email)) {
$langs->load("errors");
$this->error = $langs->trans("ErrorBadEMail", $this->email);
@ -1800,7 +1804,7 @@ class User extends CommonObject
$langs->load("errors");
$this->error = $langs->trans("ErrorFieldRequired", 'Login');
return -1;
} elseif (preg_match('/[,@<>"\']/', $this->login)) {
} elseif (preg_match('/['.preg_quote($badCharUnauthorizedIntoLoginName, '/').']/', $this->login)) {
$langs->load("errors");
$this->error = $langs->trans("ErrorBadCharIntoLoginName");
return -1;