From 12c030db2cc61f6f0d40aef585a2523cd19384ae Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Tue, 16 Jul 2024 18:54:37 +0200 Subject: [PATCH] wait #6297 @1 --- src/app/Models/Company.php | 5 +++++ src/app/Models/User.php | 8 ++++++-- src/app/Traits/OtherEmails.php | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 src/app/Traits/OtherEmails.php diff --git a/src/app/Models/Company.php b/src/app/Models/Company.php index b7a856d..4aa7f76 100644 --- a/src/app/Models/Company.php +++ b/src/app/Models/Company.php @@ -7,6 +7,7 @@ use Cubedesigners\UserDatabase\Jobs\ApplyPermissionsToUsers; use Cubedesigners\UserDatabase\Permissions; use Cubedesigners\UserDatabase\SubForms\Address; use Cubedesigners\UserDatabase\SubForms\AddressAndCompanyName; +use Cubedesigners\UserDatabase\Traits\OtherEmails; use Cubist\Backpack\Magic\Fields\Checkbox; use Cubist\Backpack\Magic\Fields\Date; use Cubist\Backpack\Magic\Fields\Hidden; @@ -18,6 +19,8 @@ use Illuminate\Database\Eloquent\Builder; class Company extends CubistMagicAbstractModel { + use OtherEmails; + protected $connection = 'extranet_users'; protected $table = 'company'; protected $_options = ['name' => 'company', @@ -141,6 +144,8 @@ class Company extends CubistMagicAbstractModel 'form' => 'update', ]); + $this->addOtherEmailsField(__('Contacts')); + $this->addField(['name' => 'website', 'type' => 'URL', 'label' => __('Site web'), diff --git a/src/app/Models/User.php b/src/app/Models/User.php index 1d5d57e..bc53c82 100644 --- a/src/app/Models/User.php +++ b/src/app/Models/User.php @@ -8,6 +8,7 @@ use Cubedesigners\UserDatabase\Operations\FilesOperation; use Cubedesigners\UserDatabase\Operations\LoginasOperation; use Cubedesigners\UserDatabase\Permissions; use Cubedesigners\UserDatabase\SubForms\Address; +use Cubedesigners\UserDatabase\Traits\OtherEmails; use Cubist\Backpack\Magic\Fields\Checkbox; use Cubist\Backpack\Magic\Fields\Color; use Cubist\Backpack\Magic\Fields\Hidden; @@ -20,6 +21,8 @@ use Illuminate\Support\Arr; class User extends CubistMagicAuthenticatable implements HasLocalePreference { + use OtherEmails; + protected $connection = 'extranet_users'; protected $table = 'user'; protected $_options = ['name' => 'users', @@ -82,6 +85,8 @@ class User extends CubistMagicAuthenticatable implements HasLocalePreference 'type' => 'Phone', 'tab' => __('Contact')]); + $this->addOtherEmailsField(__('Contact')); + $this->addField(['name' => 'marketing', 'label' => __('Reçoit les communications marketing'), 'type' => Checkbox::class, @@ -151,8 +156,6 @@ class User extends CubistMagicAuthenticatable implements HasLocalePreference $p = $this->getField('rolesandperms'); $p->setAttribute('tab', __('Equipe Cubedesigners')); - - } public function getNameAttribute() @@ -274,6 +277,7 @@ class User extends CubistMagicAuthenticatable implements HasLocalePreference return $this->_managedUsers; } + public function getManagedCompanies() { if (null === $this->_managedCompanies) { diff --git a/src/app/Traits/OtherEmails.php b/src/app/Traits/OtherEmails.php new file mode 100644 index 0000000..f026925 --- /dev/null +++ b/src/app/Traits/OtherEmails.php @@ -0,0 +1,34 @@ +email)); + } + if (!$this->emails_other) { + return $res; + } + + foreach (\Cubist\Util\Text::explodeNewLines($this->emails_other) as $e) { + $e = trim(mb_strtolower($e)); + if (\Cubist\Util\Text::isEmail($e)) { + $res[] = $e; + } + + } + return $res; + } + + public function addOtherEmailsField($tab) + { + $this->addField('emails_other', Textarea::class, __('Autres emails'), + ['hint' => __('Ces emails sont ajoutés à la liste blanche des SPAM. Une adresse par ligne.'), 'tab' => $tab]); + } +} -- 2.39.5