diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index d8fac5e8e41..23924814d04 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1054,7 +1054,6 @@ abstract class CommonObject { $this->error = $this->db->errno(); $this->db->rollback(); - echo 'err rollback'; return -2; } else { $this->error = $this->db->error(); diff --git a/htdocs/projet/tasks/contact.php b/htdocs/projet/tasks/contact.php index 253c2c787e4..eff772dfce9 100644 --- a/htdocs/projet/tasks/contact.php +++ b/htdocs/projet/tasks/contact.php @@ -57,11 +57,22 @@ $projectstatic = new Project($db); // Add new contact if ($action == 'addcontact' && $user->rights->projet->creer) { + $source = 'internal'; + if (GETPOST("addsourceexternal")) { + $source ='external'; + } + $result = $object->fetch($id, $ref); if ($result > 0 && $id > 0) { - $idfortaskuser = (GETPOST("contactid") != 0) ?GETPOST("contactid") : GETPOST("userid"); // GETPOST('contactid') may val -1 to mean empty or -2 to means "everybody" + if ($source == 'internal') { + $idfortaskuser = ((GETPOST("userid") != 0 && GETPOST('userid') != -1) ? GETPOST("userid") : 0); // GETPOST('contactid') may val -1 to mean empty or -2 to means "everybody" + $typeid = GETPOST('type'); + } else { + $idfortaskuser = ((GETPOST("contactid") > 0) ? GETPOST("contactid", 'int') : 0); // GETPOST('contactid') may val -1 to mean empty or -2 to means "everybody" + $typeid = GETPOST('typecontact'); + } if ($idfortaskuser == -2) { $result = $projectstatic->fetch($object->fk_project); @@ -72,13 +83,11 @@ if ($action == 'addcontact' && $user->rights->projet->creer) $contactsofproject = $projectstatic->getListContactId('internal'); foreach ($contactsofproject as $key => $val) { - $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); - $result = $object->add_contact($val, $type, GETPOST("source", 'aZ09')); + $result = $object->add_contact($val, $typeid, $source); } } } else { - $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); - $result = $object->add_contact($idfortaskuser, $typeid, GETPOST("source", 'aZ09')); + $result = $object->add_contact($idfortaskuser, $typeid, $source); } } @@ -353,6 +362,12 @@ if ($id > 0 || !empty($ref)) /* * Add a new contact line */ + print '
"; + } else { print "ErrorRecordNotFound"; }