FIX: project creation prevented if PROJECTLEADER contact role renamed, de-activated or deleted

This commit is contained in:
Marc de Lima Lucio 2022-03-03 12:19:47 +01:00
parent df9fa39d34
commit 7239fa3605

View File

@ -174,10 +174,11 @@ if (empty($reshook))
if (!$error && $result > 0) if (!$error && $result > 0)
{ {
// Add myself as project leader // Add myself as project leader
$typeofcontact = 'PROJECTLEADER'; // TODO If use rename this code in dictionary, the add_contact will generate an error. $typeofcontact = 'PROJECTLEADER';
$result = $object->add_contact($user->id, $typeofcontact, 'internal'); $result = $object->add_contact($user->id, $typeofcontact, 'internal');
if ($result < 0)
{ // -3 means type not found (PROJECTLEADER renamed, de-activated or deleted), so don't prevent creation if it has been the case
if ($result < 0 && $result != -3) {
$langs->load("errors"); $langs->load("errors");
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
$error++; $error++;