diff --git a/ajax/backend/customer/passwordMail.php b/ajax/backend/customer/passwordMail.php index 19702f0c8c3cc7943e51f6ce1b6d01af9bd47b5c..c93e0c6d2e9b323e69eecf66db1400aa45b7b91c 100644 --- a/ajax/backend/customer/passwordMail.php +++ b/ajax/backend/customer/passwordMail.php @@ -12,9 +12,11 @@ 'package_quiqqer_customer_ajax_backend_customer_passwordMail', function ($userId) { $User = QUI::getUsers()->get($userId); - $Handler = QUI\Users\Auth\Handler::getInstance(); - $Handler->sendPasswordResetVerificationMail($User); + + if ($User instanceof QUI\Users\User) { + $Handler->sendPasswordResetVerificationMail($User); + } QUI::getMessagesHandler()->addSuccess( QUI::getLocale()->get('quiqqer/customer', 'message.customer.password.mail.send') diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index a2480f2b38bc0182387d66c7e66c0f08cda2a4a4..f02d6167f5104e194f10472f57893a758a3c52e2 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -15,11 +15,6 @@ parameters: count: 1 path: ajax/backend/customer/getPagination.php - - - message: "#^Parameter \\#1 \\$User of method QUI\\\\Users\\\\Auth\\\\Handler\\:\\:sendPasswordResetVerificationMail\\(\\) expects QUI\\\\Users\\\\User, QUI\\\\Interfaces\\\\Users\\\\User given\\.$#" - count: 1 - path: ajax/backend/customer/passwordMail.php - - message: "#^Call to method addUrl\\(\\) on an unknown class QUI\\\\UserDownloads\\\\DownloadEntry\\.$#" count: 1 @@ -75,26 +70,6 @@ parameters: count: 1 path: src/QUI/ERP/Customer/CustomerFiles.php - - - message: "#^Parameter \\#1 \\$code of method QUI\\\\Interfaces\\\\Users\\\\User\\:\\:activate\\(\\) expects string, false given\\.$#" - count: 2 - path: src/QUI/ERP/Customer/Customers.php - - - - message: "#^Result of && is always false\\.$#" - count: 1 - path: src/QUI/ERP/Customer/Customers.php - - - - message: "#^Strict comparison using \\=\\=\\= between mixed and '' will always evaluate to false\\.$#" - count: 2 - path: src/QUI/ERP/Customer/Customers.php - - - - message: "#^Strict comparison using \\=\\=\\= between mixed and null will always evaluate to false\\.$#" - count: 1 - path: src/QUI/ERP/Customer/Customers.php - - message: "#^Call to method getOrder\\(\\) on an unknown class QUI\\\\ERP\\\\Order\\\\Controls\\\\OrderProcess\\\\CustomerData\\.$#" count: 1 @@ -319,8 +294,3 @@ parameters: message: "#^Parameter \\$Order of method QUI\\\\ERP\\\\Customer\\\\OpenItemsList\\\\Handler\\:\\:parseOrderToOpenItem\\(\\) has invalid type QUI\\\\ERP\\\\Order\\\\Order\\.$#" count: 2 path: src/QUI/ERP/Customer/OpenItemsList/Handler.php - - - - message: "#^Strict comparison using \\=\\=\\= between 'ad\\.firstname'\\|'ad\\.lastname'\\|'company'\\|'customerId'\\|'email'\\|'firstname'\\|'lastname'\\|'usergroup'\\|'userId'\\|'username' and 'users\\.customerId' will always evaluate to false\\.$#" - count: 1 - path: src/QUI/ERP/Customer/Search.php diff --git a/src/QUI/ERP/Customer/Customers.php b/src/QUI/ERP/Customer/Customers.php index 04398f7b8d6f19f929f61b7f9878be83a7539ce8..8d8f2bddb686565d1c3ab36cb5f94a0494cacd7d 100644 --- a/src/QUI/ERP/Customer/Customers.php +++ b/src/QUI/ERP/Customer/Customers.php @@ -104,11 +104,11 @@ public function createCustomer($customerId, array $address = [], array $groupIds $Address->save(); - if (!$User->getAttribute('firstname') || $User->getAttribute('firstname') === '') { + if (empty($User->getAttribute('firstname'))) { $User->setAttribute('firstname', $address['firstname']); } - if (!$User->getAttribute('lastname') || $User->getAttribute('lastname') === '') { + if (empty($User->getAttribute('lastname'))) { $User->setAttribute('lastname', $address['lastname']); } } @@ -221,8 +221,8 @@ public function getCustomerGroup(): ?QUI\Groups\Group * @throws QUI\Users\Exception */ public function addUserToCustomerGroup( - bool|int|string $userId, - QUI\Interfaces\Users\User $PermissionUser = null + bool | int | string $userId, + null | QUI\Interfaces\Users\User $PermissionUser = null ): void { if (!$userId) { return; @@ -258,7 +258,7 @@ public function addUserToCustomerGroup( * @throws QUI\Exception * @throws QUI\Users\Exception */ - public function removeUserFromCustomerGroup(bool|int|string $userId): void + public function removeUserFromCustomerGroup(bool | int | string $userId): void { $customerGroup = null; @@ -287,7 +287,7 @@ public function removeUserFromCustomerGroup(bool|int|string $userId): void * @throws QUI\Permissions\Exception * @throws QUI\Users\Exception */ - public function setAttributesToCustomer(bool|int|string $userId, array $attributes): void + public function setAttributesToCustomer(bool | int | string $userId, array $attributes): void { $User = QUI::getUsers()->get($userId); @@ -343,8 +343,6 @@ public function setAttributesToCustomer(bool|int|string $userId, array $attribut if (isset($attributes['group'])) { $groups[] = $attributes['group']; $User->setAttribute('mainGroup', $attributes['group']); - } elseif (isset($attributes['group']) && $attributes['group'] === null) { - $User->setAttribute('mainGroup', false); } if (!empty($attributes['groups'])) { @@ -385,7 +383,7 @@ public function setAttributesToCustomer(bool|int|string $userId, array $attribut $SystemUser = QUI::getUsers()->getSystemUser(); try { - $User->activate(false, $SystemUser); + $User->activate('', $SystemUser); } catch (QUI\Exception $Exception) { // if no password, set a password $userAttr = $User->getAttributes(); @@ -396,7 +394,7 @@ public function setAttributesToCustomer(bool|int|string $userId, array $attribut $SystemUser ); - $User->activate(false, $SystemUser); + $User->activate('', $SystemUser); } else { throw $Exception; } diff --git a/src/QUI/ERP/Customer/OpenItemsList/OutputProvider.php b/src/QUI/ERP/Customer/OpenItemsList/OutputProvider.php index 8a78f318b1f3360a2599a809c72e38cf97ff9e06..0966f0d311bc39cfaf6be2e465b3581de6bb0322 100644 --- a/src/QUI/ERP/Customer/OpenItemsList/OutputProvider.php +++ b/src/QUI/ERP/Customer/OpenItemsList/OutputProvider.php @@ -37,7 +37,7 @@ public static function getEntityType(): string * @param Locale|null $Locale $Locale (optional) - If ommitted use \QUI::getLocale() * @return string */ - public static function getEntityTypeTitle(Locale $Locale = null): string + public static function getEntityTypeTitle(null | Locale $Locale = null): string { if (empty($Locale)) { $Locale = QUI::getLocale(); diff --git a/src/QUI/ERP/Customer/Search.php b/src/QUI/ERP/Customer/Search.php index 5c507cabbf46a91eb1a23aed5b1ca7062d0c375b..7e8950f058add5a87d6a6f4c3fe38780c5ffddb8 100644 --- a/src/QUI/ERP/Customer/Search.php +++ b/src/QUI/ERP/Customer/Search.php @@ -332,7 +332,8 @@ protected function getQuery(bool $count = false): array 'company', 'customerId', 'ad.firstname', - 'ad.lastname' + 'ad.lastname', + 'users.customerId' ]; $searchFilters = []; @@ -687,7 +688,7 @@ public function order(string $col, string $direction = 'ASC'): void * @param integer|string $from - start * @param integer|string $count - count of entries */ - public function limit(int|string $from, int|string $count): void + public function limit(int | string $from, int | string $count): void { $this->limit = [(int)$from, (int)$count]; } @@ -702,7 +703,7 @@ public function limit(int|string $from, int|string $count): void * @param string $filter * @param array|string $value */ - public function setFilter(string $filter, array|string $value): void + public function setFilter(string $filter, array | string $value): void { if ($filter === 'search') { $this->search = $value;