diff --git a/core/Controllers/ContactController.php b/core/Controllers/ContactController.php index dcbe124e0339c216ab0c9ee580457c2fbadb7bac..91d4e6ebbeb78b4305fda447b2e736df359eee41 100644 --- a/core/Controllers/ContactController.php +++ b/core/Controllers/ContactController.php @@ -44,7 +44,12 @@ class ContactController } if ($data['isCorporatePerson'] != 'Y') { $data['isCorporatePerson'] = 'N'; + } else { + $data['addressFirstname'] = $data['firstname']; + $data['addressLastname'] = $data['lastname']; + unset($data['firstname'], $data['lastname']); } + if (empty($data['isPrivate'])) { $data['isPrivate'] = 'N'; } elseif ($data['isPrivate'] != 'N') { diff --git a/core/Controllers/ResController.php b/core/Controllers/ResController.php index ffe0ba77fa0953dff58a269ea65c4411a721180e..b2cda358e308599eaa7c2408e65e7b2eaed68bbd 100755 --- a/core/Controllers/ResController.php +++ b/core/Controllers/ResController.php @@ -15,6 +15,7 @@ namespace Core\Controllers; +use Core\Models\StatusModel; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; use Respect\Validation\Validator; @@ -95,6 +96,9 @@ class ResController if (empty($data['status'])) { $data['status'] = 'COU'; } + if (empty(StatusModel::getById(['id' => $data['status']]))) { + return $response->withStatus(400)->withJson(['errors' => 'Status not found']); + } if (empty($data['historyMessage'])) { $data['historyMessage'] = _UPDATE_STATUS; } diff --git a/core/Models/ContactModelAbstract.php b/core/Models/ContactModelAbstract.php index 0bcd3a41c5a809f300fcf6b7cc51061c1249f085..f0710798c94879b3c203fc7bcbc2aa433222d3ee 100644 --- a/core/Models/ContactModelAbstract.php +++ b/core/Models/ContactModelAbstract.php @@ -39,10 +39,10 @@ class ContactModelAbstract public static function create(array $aArgs) { - ValidatorModel::notEmpty($aArgs, ['firstname', 'lastname', 'contactType', 'isCorporatePerson', 'email', 'userId', 'entityId']); + ValidatorModel::notEmpty($aArgs, ['firstname', 'lastname', 'contactType', 'isCorporatePerson', 'userId', 'entityId']); ValidatorModel::intVal($aArgs, ['contactType']); ValidatorModel::stringType($aArgs, [ - 'firstname', 'lastname', 'isCorporatePerson', 'email', 'society', + 'firstname', 'lastname', 'isCorporatePerson', 'society', 'societyShort', 'title', 'function', 'otherData', 'userId', 'entityId' ]); @@ -74,11 +74,11 @@ class ContactModelAbstract public static function createAddress(array $aArgs) { - ValidatorModel::notEmpty($aArgs, ['contactId', 'contactPurposeId', 'userId', 'entityId', 'isPrivate']); + ValidatorModel::notEmpty($aArgs, ['contactId', 'contactPurposeId', 'userId', 'entityId', 'isPrivate', 'email']); ValidatorModel::intVal($aArgs, ['contactId', 'contactPurposeId']); ValidatorModel::stringType($aArgs, [ 'departement', 'addressFirstname', 'addressLastname', 'addressTitle', 'addressFunction', 'occupancy', 'addressNum', 'addressStreet', 'addressComplement', - 'addressTown', 'addressZip', 'addressCountry', 'phone', 'addressEmail', 'website', 'salutationHeader', 'salutationFooter', 'addressOtherData', + 'addressTown', 'addressZip', 'addressCountry', 'phone', 'email', 'website', 'salutationHeader', 'salutationFooter', 'addressOtherData', 'userId', 'entityId', 'isPrivate' ]); @@ -103,7 +103,7 @@ class ContactModelAbstract 'address_postal_code' => $aArgs['addressZip'], 'address_country' => $aArgs['addressCountry'], 'phone' => $aArgs['phone'], - 'email' => $aArgs['addressEmail'], + 'email' => $aArgs['email'], 'website' => $aArgs['website'], 'salutation_header' => $aArgs['salutationHeader'], 'salutation_footer' => $aArgs['salutationFooter'],