feat(Nextcloud sync & optimize)
All checks were successful
Deploy Roxane to Preprod / deploy (push) Successful in 1m18s
All checks were successful
Deploy Roxane to Preprod / deploy (push) Successful in 1m18s
This commit is contained in:
@@ -2,8 +2,10 @@
|
|||||||
|
|
||||||
namespace App\Console\Commands;
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use App\Models\Member;
|
||||||
use App\Services\Dolibarr\DolibarrService;
|
use App\Services\Dolibarr\DolibarrService;
|
||||||
use App\Services\ISPConfig\ISPConfigMailService;
|
use App\Services\ISPConfig\ISPConfigMailService;
|
||||||
|
use App\Services\MemberService;
|
||||||
use App\Services\Nextcloud\NextcloudService;
|
use App\Services\Nextcloud\NextcloudService;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
use Illuminate\Http\Client\ConnectionException;
|
use Illuminate\Http\Client\ConnectionException;
|
||||||
@@ -19,7 +21,8 @@ class HandleExpiredMembersDolibarr extends Command
|
|||||||
public function __construct(
|
public function __construct(
|
||||||
protected DolibarrService $dolibarr,
|
protected DolibarrService $dolibarr,
|
||||||
protected ISPConfigMailService $mailService,
|
protected ISPConfigMailService $mailService,
|
||||||
protected NextcloudService $nextcloud
|
protected NextcloudService $nextcloud,
|
||||||
|
protected MemberService $memberService
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
@@ -112,6 +115,12 @@ class HandleExpiredMembersDolibarr extends Command
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Résilitation Roxane
|
||||||
|
$roxaneMember = Member::query()->findOrFail($member['id']);
|
||||||
|
if ($roxaneMember) {
|
||||||
|
$this->memberService->deactivateMember($roxaneMember);
|
||||||
|
}
|
||||||
|
|
||||||
// Désactivation mail
|
// Désactivation mail
|
||||||
if ($email) {
|
if ($email) {
|
||||||
$this->disableMailAccount($email, $dryRun);
|
$this->disableMailAccount($email, $dryRun);
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ use Illuminate\Console\Command;
|
|||||||
use Illuminate\Http\Client\ConnectionException;
|
use Illuminate\Http\Client\ConnectionException;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
use Symfony\Component\Console\Command\Command as CommandAlias;
|
use Symfony\Component\Console\Command\Command as CommandAlias;
|
||||||
|
use function Laravel\Prompts\progress;
|
||||||
|
|
||||||
class SyncNextcloudMembers extends Command
|
class SyncNextcloudMembers extends Command
|
||||||
{
|
{
|
||||||
@@ -38,7 +39,6 @@ class SyncNextcloudMembers extends Command
|
|||||||
: 'Synchronisation Nextcloud → Members'
|
: 'Synchronisation Nextcloud → Members'
|
||||||
);
|
);
|
||||||
|
|
||||||
/** index des membres par email */
|
|
||||||
$members = Member::query()
|
$members = Member::query()
|
||||||
->where('email', 'like', '%@retzien.fr%')
|
->where('email', 'like', '%@retzien.fr%')
|
||||||
->when($memberFilter, fn ($q) => $q->where('id', $memberFilter))
|
->when($memberFilter, fn ($q) => $q->where('id', $memberFilter))
|
||||||
@@ -46,19 +46,27 @@ class SyncNextcloudMembers extends Command
|
|||||||
->filter(fn (Member $m) => !empty($m->retzien_email))
|
->filter(fn (Member $m) => !empty($m->retzien_email))
|
||||||
->keyBy(fn (Member $m) => strtolower($m->retzien_email));
|
->keyBy(fn (Member $m) => strtolower($m->retzien_email));
|
||||||
|
|
||||||
|
|
||||||
if ($members->isEmpty()) {
|
if ($members->isEmpty()) {
|
||||||
$this->warn('Aucun membre à synchroniser');
|
$this->warn('Aucun membre à synchroniser');
|
||||||
return CommandAlias::SUCCESS;
|
return CommandAlias::SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->info("{$members->count()} membres candidats");
|
$this->info("{$members->count()} membres à synchroniser");
|
||||||
|
|
||||||
/**Récupération des users Nextcloud */
|
|
||||||
$userIds = $this->nextcloud->listUsers();
|
$userIds = $this->nextcloud->listUsers();
|
||||||
|
|
||||||
$this->info(count($userIds) . ' comptes Nextcloud trouvés');
|
$this->info(count($userIds) . ' comptes Nextcloud trouvés');
|
||||||
|
|
||||||
|
$progress = null;
|
||||||
|
|
||||||
|
if (!$dryRun) {
|
||||||
|
$progress = progress(
|
||||||
|
label: 'Synchronisation des membres',
|
||||||
|
steps: $members->count()
|
||||||
|
);
|
||||||
|
$progress->start();
|
||||||
|
}
|
||||||
|
|
||||||
$synced = 0;
|
$synced = 0;
|
||||||
|
|
||||||
foreach ($userIds as $userId) {
|
foreach ($userIds as $userId) {
|
||||||
@@ -73,19 +81,6 @@ class SyncNextcloudMembers extends Command
|
|||||||
|
|
||||||
$member = $members[$email];
|
$member = $members[$email];
|
||||||
|
|
||||||
$payload = [
|
|
||||||
'member_id' => $member->id,
|
|
||||||
'nextcloud_user_id' => $userId,
|
|
||||||
'data' => [
|
|
||||||
'email' => $email,
|
|
||||||
'quota' => $details['quota'] ?? null,
|
|
||||||
'groups' => $details['groups'] ?? [],
|
|
||||||
'enabled' => !($details['enabled'] === false),
|
|
||||||
'last_login' => $details['lastLogin'] ?? null,
|
|
||||||
'raw' => $details, // utile pour debug
|
|
||||||
],
|
|
||||||
];
|
|
||||||
|
|
||||||
if ($dryRun) {
|
if ($dryRun) {
|
||||||
$this->line("[DRY-RUN] {$member->id} ← {$userId}");
|
$this->line("[DRY-RUN] {$member->id} ← {$userId}");
|
||||||
} else {
|
} else {
|
||||||
@@ -94,12 +89,15 @@ class SyncNextcloudMembers extends Command
|
|||||||
'member_id' => $member->id,
|
'member_id' => $member->id,
|
||||||
'nextcloud_user_id' => $userId,
|
'nextcloud_user_id' => $userId,
|
||||||
],
|
],
|
||||||
$payload
|
[
|
||||||
|
'data' => json_encode($details, JSON_THROW_ON_ERROR),
|
||||||
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$progress->advance();
|
||||||
}
|
}
|
||||||
|
|
||||||
$synced++;
|
$synced++;
|
||||||
|
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
Log::error('Erreur sync Nextcloud', [
|
Log::error('Erreur sync Nextcloud', [
|
||||||
'user_id' => $userId,
|
'user_id' => $userId,
|
||||||
@@ -108,6 +106,11 @@ class SyncNextcloudMembers extends Command
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($progress) {
|
||||||
|
$progress->finish();
|
||||||
|
$this->newLine();
|
||||||
|
}
|
||||||
|
|
||||||
$this->info("Synchronisation terminée ({$synced} comptes liés)");
|
$this->info("Synchronisation terminée ({$synced} comptes liés)");
|
||||||
|
|
||||||
return CommandAlias::SUCCESS;
|
return CommandAlias::SUCCESS;
|
||||||
|
|||||||
@@ -6,17 +6,16 @@ use App\Enums\IspconfigType;
|
|||||||
use App\Models\Member;
|
use App\Models\Member;
|
||||||
use Filament\Actions\Action;
|
use Filament\Actions\Action;
|
||||||
use Filament\Forms\Components\DatePicker;
|
use Filament\Forms\Components\DatePicker;
|
||||||
use Filament\Forms\Components\Placeholder;
|
|
||||||
use Filament\Forms\Components\Select;
|
use Filament\Forms\Components\Select;
|
||||||
|
use Filament\Schemas\Components\Tabs;
|
||||||
|
use Filament\Schemas\Components\Tabs\Tab;
|
||||||
use Filament\Forms\Components\TextInput;
|
use Filament\Forms\Components\TextInput;
|
||||||
use Filament\Forms\Components\Toggle;
|
use Filament\Forms\Components\Toggle;
|
||||||
use Filament\Schemas\Components\Grid;
|
use Filament\Schemas\Components\Grid;
|
||||||
use Filament\Schemas\Components\Section;
|
use Filament\Schemas\Components\Section;
|
||||||
use Filament\Schemas\Schema;
|
use Filament\Schemas\Schema;
|
||||||
use Filament\Infolists\Components\TextEntry;
|
|
||||||
use Filament\Infolists\Components\RepeatableEntry;
|
use Filament\Infolists\Components\RepeatableEntry;
|
||||||
use Filament\Infolists\Components\Actions;
|
use Filament\Infolists\Components\TextEntry;
|
||||||
|
|
||||||
|
|
||||||
class MemberForm
|
class MemberForm
|
||||||
{
|
{
|
||||||
@@ -26,9 +25,24 @@ class MemberForm
|
|||||||
->components([
|
->components([
|
||||||
Grid::make()
|
Grid::make()
|
||||||
->schema([
|
->schema([
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Colonne principale
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
Grid::make(1)
|
Grid::make(1)
|
||||||
|
->schema([
|
||||||
|
Tabs::make('MemberTabs')
|
||||||
|
->tabs([
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| TAB : Informations générales
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
Tabs\Tab::make('Informations générales')
|
||||||
->schema([
|
->schema([
|
||||||
Section::make('Informations personnelles')
|
Section::make('Informations personnelles')
|
||||||
|
->collapsible()
|
||||||
->schema([
|
->schema([
|
||||||
TextInput::make('lastname')
|
TextInput::make('lastname')
|
||||||
->label(Member::getAttributeLabel('lastname'))
|
->label(Member::getAttributeLabel('lastname'))
|
||||||
@@ -47,6 +61,7 @@ class MemberForm
|
|||||||
->columns(2),
|
->columns(2),
|
||||||
|
|
||||||
Section::make('Informations administratives')
|
Section::make('Informations administratives')
|
||||||
|
->collapsible()
|
||||||
->schema([
|
->schema([
|
||||||
TextInput::make('keycloak_id')
|
TextInput::make('keycloak_id')
|
||||||
->label(Member::getAttributeLabel('keycloak_id')),
|
->label(Member::getAttributeLabel('keycloak_id')),
|
||||||
@@ -68,6 +83,7 @@ class MemberForm
|
|||||||
->columns(2),
|
->columns(2),
|
||||||
|
|
||||||
Section::make('Coordonnées')
|
Section::make('Coordonnées')
|
||||||
|
->collapsible()
|
||||||
->schema([
|
->schema([
|
||||||
TextInput::make('email')
|
TextInput::make('email')
|
||||||
->label(Member::getAttributeLabel('email'))
|
->label(Member::getAttributeLabel('email'))
|
||||||
@@ -95,63 +111,94 @@ class MemberForm
|
|||||||
->label(Member::getAttributeLabel('country')),
|
->label(Member::getAttributeLabel('country')),
|
||||||
])
|
])
|
||||||
->columns(2),
|
->columns(2),
|
||||||
// Mail Retzien
|
]),
|
||||||
Section::make('Messagerie ISPConfig Retzien')
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| TAB : Services/Modules
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
Tabs\Tab::make('Modules')
|
||||||
->schema([
|
->schema([
|
||||||
TextEntry::make('isp_mail_email')
|
/*
|
||||||
->label('Adresse email')
|
| Messageries ISPConfig (lecture seule)
|
||||||
->state(fn (?Member $record) =>
|
*/
|
||||||
$record?->ispconfigMail()?->email ?? '—'
|
Section::make('Messagerie ISPConfig')
|
||||||
),
|
->collapsible()
|
||||||
|
|
||||||
TextEntry::make('isp_mail_user_id')
|
|
||||||
->label('ID utilisateur ISPConfig (mailuser_id)')
|
|
||||||
->state(fn (?Member $record) =>
|
|
||||||
$record?->ispconfigMail()?->ispconfig_service_user_id ?? '—'
|
|
||||||
),
|
|
||||||
|
|
||||||
TextEntry::make('isp_mail_quota')
|
|
||||||
->label('Quota')
|
|
||||||
->state(function (?Member $record) {
|
|
||||||
$quota = $record?->ispconfigMail()?->data['mailuser']['quota'] ?? null;
|
|
||||||
|
|
||||||
return $quota
|
|
||||||
? "{$quota} Mo"
|
|
||||||
: 'Non défini';
|
|
||||||
}),
|
|
||||||
|
|
||||||
TextEntry::make('isp_mail_domain')
|
|
||||||
->label('Domaine')
|
|
||||||
->state(fn (?Member $record) =>
|
|
||||||
$record?->ispconfigMail()?->data['mailuser']['domain'] ?? 'retzien.fr'
|
|
||||||
),
|
|
||||||
])
|
|
||||||
->columns(2)
|
|
||||||
->visible(fn (?Member $record) =>
|
|
||||||
$record?->ispconfigMail() !== null
|
|
||||||
),
|
|
||||||
|
|
||||||
// Hébergement
|
|
||||||
|
|
||||||
Section::make('Hébergements Web')
|
|
||||||
->schema([
|
->schema([
|
||||||
Placeholder::make('ispconfigs_web_display')
|
RepeatableEntry::make('ispconfig_mails')
|
||||||
->label('')
|
->label('')
|
||||||
->content(fn (?Member $record) => view('filament.components.ispconfig-web-list', [
|
->state(fn(?Member $record) => $record?->ispconfigs()
|
||||||
'ispconfigs' => $record?->ispconfigs()
|
->where('type', IspconfigType::MAIL)
|
||||||
->where('type', IspconfigType::WEB)
|
->get()
|
||||||
->get() ?? collect()
|
|
||||||
]))
|
|
||||||
])
|
|
||||||
->visible(fn (?Member $record) =>
|
|
||||||
$record?->ispconfigs()->where('type', IspconfigType::WEB)->exists()
|
|
||||||
)
|
)
|
||||||
// Fin Hébergement
|
->schema([
|
||||||
|
TextEntry::make('email')
|
||||||
|
->label('Adresse email'),
|
||||||
|
|
||||||
|
TextEntry::make('ispconfig_service_user_id')
|
||||||
|
->label('ID ISPConfig'),
|
||||||
|
|
||||||
|
TextEntry::make('data.mailuser.quota')
|
||||||
|
->label('Quota')
|
||||||
|
->formatStateUsing(fn($state) => $state ? "{$state} Mo" : 'Non défini'
|
||||||
|
),
|
||||||
|
|
||||||
|
TextEntry::make('data.mailuser.domain')
|
||||||
|
->label('Domaine')
|
||||||
|
->default('retzien.fr'),
|
||||||
|
])
|
||||||
|
->columns(2),
|
||||||
|
])
|
||||||
|
->visible(fn(?Member $record) => $record?->ispconfigs()
|
||||||
|
->where('type', IspconfigType::MAIL)
|
||||||
|
->exists()
|
||||||
|
),
|
||||||
|
|
||||||
|
/*
|
||||||
|
| Hébergements web ISPConfig
|
||||||
|
*/
|
||||||
|
Section::make('Hébergements Web')
|
||||||
|
->collapsible()
|
||||||
|
->schema([
|
||||||
|
RepeatableEntry::make('ispconfigs_web')
|
||||||
|
->label('')
|
||||||
|
->state(fn(?Member $record) => $record?->ispconfigs()
|
||||||
|
->where('type', IspconfigType::WEB)
|
||||||
|
->get()
|
||||||
|
)
|
||||||
|
->schema([
|
||||||
|
TextEntry::make('data.web_domain.domain')
|
||||||
|
->label('Domaine'),
|
||||||
|
|
||||||
|
TextEntry::make('data.web_domain.ip_address')
|
||||||
|
->label('Adresse IP'),
|
||||||
|
|
||||||
|
TextEntry::make('data.web_domain.disk_quota')
|
||||||
|
->label('Quota disque')
|
||||||
|
->formatStateUsing(fn($state) => $state ? "{$state} Mo" : '—'
|
||||||
|
),
|
||||||
|
])
|
||||||
|
->columns(3),
|
||||||
|
])
|
||||||
|
->visible(fn(?Member $record) => $record?->ispconfigs()
|
||||||
|
->where('type', IspconfigType::WEB)
|
||||||
|
->exists()
|
||||||
|
),
|
||||||
|
]),
|
||||||
|
]),
|
||||||
])
|
])
|
||||||
->columnSpan(3),
|
->columnSpan(3),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Colonne latérale
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
Grid::make(1)
|
Grid::make(1)
|
||||||
->schema([
|
->schema([
|
||||||
Section::make('Statut')
|
Section::make('Statut')
|
||||||
|
->collapsible()
|
||||||
->schema([
|
->schema([
|
||||||
Select::make('status')
|
Select::make('status')
|
||||||
->label(Member::getAttributeLabel('status'))
|
->label(Member::getAttributeLabel('status'))
|
||||||
@@ -169,27 +216,26 @@ class MemberForm
|
|||||||
->label(Member::getAttributeLabel('public_membership'))
|
->label(Member::getAttributeLabel('public_membership'))
|
||||||
->required(),
|
->required(),
|
||||||
])
|
])
|
||||||
->columns(1)
|
|
||||||
->extraAttributes(['class' => 'sticky top-4 h-fit']),
|
->extraAttributes(['class' => 'sticky top-4 h-fit']),
|
||||||
|
|
||||||
Section::make('Actions')
|
Section::make('Actions')
|
||||||
|
->collapsible()
|
||||||
->schema([
|
->schema([
|
||||||
Action::make('send-payment-mail')
|
Action::make('send-payment-mail')
|
||||||
->icon('heroicon-o-envelope')
|
|
||||||
->label('Envoyer le mail de paiement')
|
->label('Envoyer le mail de paiement')
|
||||||
->action(function(){
|
|
||||||
$this->data['status'] = 'draft';
|
|
||||||
$this->create();
|
|
||||||
}),
|
|
||||||
Action::make('send-renewal-mail')
|
|
||||||
->icon('heroicon-o-envelope')
|
->icon('heroicon-o-envelope')
|
||||||
|
->action(function () {
|
||||||
|
// Mail de paiement pour nouvelle inscription (Job)
|
||||||
|
}),
|
||||||
|
|
||||||
|
Action::make('send-renewal-mail')
|
||||||
->label('Envoyer un mail de relance')
|
->label('Envoyer un mail de relance')
|
||||||
->action(function(){
|
->icon('heroicon-o-envelope')
|
||||||
$this->data['status'] = 'draft';
|
->action(function () {
|
||||||
$this->create();
|
// Mail de relance à créer (Job)
|
||||||
})
|
}),
|
||||||
])
|
])
|
||||||
->columns(1)
|
->extraAttributes(['class' => 'sticky top-4 h-fit']),
|
||||||
->extraAttributes(['class' => 'sticky top-4 h-fit'])
|
|
||||||
])
|
])
|
||||||
->columnSpan(1),
|
->columnSpan(1),
|
||||||
])
|
])
|
||||||
|
|||||||
@@ -6,6 +6,31 @@ use App\Enums\IspconfigType;
|
|||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @property int $id
|
||||||
|
* @property int $member_id
|
||||||
|
* @property string|null $ispconfig_client_id
|
||||||
|
* @property string|null $ispconfig_service_user_id
|
||||||
|
* @property string|null $email
|
||||||
|
* @property IspconfigType $type
|
||||||
|
* @property array<array-key, mixed>|null $data
|
||||||
|
* @property \Illuminate\Support\Carbon|null $created_at
|
||||||
|
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||||
|
* @property-read \App\Models\Member $member
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|IspconfigMember newModelQuery()
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|IspconfigMember newQuery()
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|IspconfigMember query()
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|IspconfigMember whereCreatedAt($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|IspconfigMember whereData($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|IspconfigMember whereEmail($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|IspconfigMember whereId($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|IspconfigMember whereIspconfigClientId($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|IspconfigMember whereIspconfigServiceUserId($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|IspconfigMember whereMemberId($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|IspconfigMember whereType($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|IspconfigMember whereUpdatedAt($value)
|
||||||
|
* @mixin \Eloquent
|
||||||
|
*/
|
||||||
class IspconfigMember extends Model
|
class IspconfigMember extends Model
|
||||||
{
|
{
|
||||||
protected $table = 'ispconfigs_members';
|
protected $table = 'ispconfigs_members';
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ use Illuminate\Notifications\Notifiable;
|
|||||||
* @property string|null $lastname
|
* @property string|null $lastname
|
||||||
* @property string|null $firstname
|
* @property string|null $firstname
|
||||||
* @property string $email
|
* @property string $email
|
||||||
* @property string|null $retzien_email
|
* @property string $retzien_email
|
||||||
* @property string|null $company
|
* @property string|null $company
|
||||||
* @property string|null $date_of_birth
|
* @property string|null $date_of_birth
|
||||||
* @property string|null $address
|
* @property string|null $address
|
||||||
@@ -37,8 +37,12 @@ use Illuminate\Notifications\Notifiable;
|
|||||||
* @property string|null $deleted_at
|
* @property string|null $deleted_at
|
||||||
* @property-read string $full_name
|
* @property-read string $full_name
|
||||||
* @property-read \App\Models\MemberGroup|null $group
|
* @property-read \App\Models\MemberGroup|null $group
|
||||||
|
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\IspconfigMember> $ispconfigs
|
||||||
|
* @property-read int|null $ispconfigs_count
|
||||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Membership> $memberships
|
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Membership> $memberships
|
||||||
* @property-read int|null $memberships_count
|
* @property-read int|null $memberships_count
|
||||||
|
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\NextCloudMember> $nextcloudAccounts
|
||||||
|
* @property-read int|null $nextcloud_accounts_count
|
||||||
* @property-read \Illuminate\Notifications\DatabaseNotificationCollection<int, \Illuminate\Notifications\DatabaseNotification> $notifications
|
* @property-read \Illuminate\Notifications\DatabaseNotificationCollection<int, \Illuminate\Notifications\DatabaseNotification> $notifications
|
||||||
* @property-read int|null $notifications_count
|
* @property-read int|null $notifications_count
|
||||||
* @property-read \App\Models\User|null $user
|
* @property-read \App\Models\User|null $user
|
||||||
|
|||||||
@@ -2,10 +2,29 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use App\Enums\IspconfigType;
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @property int $id
|
||||||
|
* @property int $member_id
|
||||||
|
* @property string|null $nextcloud_user_id
|
||||||
|
* @property array<array-key, mixed>|null $data
|
||||||
|
* @property \Illuminate\Support\Carbon|null $created_at
|
||||||
|
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||||
|
* @property-read \App\Models\Member $member
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|NextCloudMember newModelQuery()
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|NextCloudMember newQuery()
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|NextCloudMember query()
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|NextCloudMember whereCreatedAt($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|NextCloudMember whereData($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|NextCloudMember whereId($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|NextCloudMember whereMemberId($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|NextCloudMember whereNextcloudUserId($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|NextCloudMember whereUpdatedAt($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|NextCloudMember whereUsername($value)
|
||||||
|
* @mixin \Eloquent
|
||||||
|
*/
|
||||||
class NextCloudMember extends Model
|
class NextCloudMember extends Model
|
||||||
{
|
{
|
||||||
protected $table = 'nextclouds_members';
|
protected $table = 'nextclouds_members';
|
||||||
|
|||||||
@@ -9,6 +9,11 @@ use App\Models\Package;
|
|||||||
|
|
||||||
class MemberService
|
class MemberService
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Register a new member.
|
||||||
|
* @param array $data
|
||||||
|
* @return Member
|
||||||
|
*/
|
||||||
public function registerNewMember(array $data): Member
|
public function registerNewMember(array $data): Member
|
||||||
{
|
{
|
||||||
// Check if the member already exists
|
// Check if the member already exists
|
||||||
@@ -52,4 +57,15 @@ class MemberService
|
|||||||
|
|
||||||
return $member;
|
return $member;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disable a member and his subscriptions
|
||||||
|
*/
|
||||||
|
public function deactivateMember(Member $member): void
|
||||||
|
{
|
||||||
|
// todo: send email to member + admin
|
||||||
|
$member->update(['status' => 'excluded']);
|
||||||
|
$member->memberships()->update(['status' => 'expired']);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class NextcloudService
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Désactive un utilisateur Nextcloud à partir de son email
|
* Disable user by email
|
||||||
* @throws ConnectionException
|
* @throws ConnectionException
|
||||||
*/
|
*/
|
||||||
public function disableUserByEmail(string $email): void
|
public function disableUserByEmail(string $email): void
|
||||||
@@ -46,7 +46,16 @@ class NextcloudService
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Trouve le userId Nextcloud à partir de l’email
|
* Desable user by id
|
||||||
|
* @throws ConnectionException
|
||||||
|
*/
|
||||||
|
public function disableUserById(string $userId): void
|
||||||
|
{
|
||||||
|
$response = $this->http->put("/cloud/users/{$userId}/disable");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find user id by email
|
||||||
*/
|
*/
|
||||||
protected function findUserIdByEmail(string $email): ?string
|
protected function findUserIdByEmail(string $email): ?string
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -600,77 +600,3 @@ membershipForm.head = (options?: RouteQueryOptions): RouteFormDefinition<'get'>
|
|||||||
})
|
})
|
||||||
|
|
||||||
membership.form = membershipForm
|
membership.form = membershipForm
|
||||||
|
|
||||||
/**
|
|
||||||
* @see routes/dev-routes.php:5
|
|
||||||
* @route '/call-dolibarr'
|
|
||||||
*/
|
|
||||||
export const callDolibarr = (options?: RouteQueryOptions): RouteDefinition<'get'> => ({
|
|
||||||
url: callDolibarr.url(options),
|
|
||||||
method: 'get',
|
|
||||||
})
|
|
||||||
|
|
||||||
callDolibarr.definition = {
|
|
||||||
methods: ["get","head"],
|
|
||||||
url: '/call-dolibarr',
|
|
||||||
} satisfies RouteDefinition<["get","head"]>
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see routes/dev-routes.php:5
|
|
||||||
* @route '/call-dolibarr'
|
|
||||||
*/
|
|
||||||
callDolibarr.url = (options?: RouteQueryOptions) => {
|
|
||||||
return callDolibarr.definition.url + queryParams(options)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see routes/dev-routes.php:5
|
|
||||||
* @route '/call-dolibarr'
|
|
||||||
*/
|
|
||||||
callDolibarr.get = (options?: RouteQueryOptions): RouteDefinition<'get'> => ({
|
|
||||||
url: callDolibarr.url(options),
|
|
||||||
method: 'get',
|
|
||||||
})
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see routes/dev-routes.php:5
|
|
||||||
* @route '/call-dolibarr'
|
|
||||||
*/
|
|
||||||
callDolibarr.head = (options?: RouteQueryOptions): RouteDefinition<'head'> => ({
|
|
||||||
url: callDolibarr.url(options),
|
|
||||||
method: 'head',
|
|
||||||
})
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see routes/dev-routes.php:5
|
|
||||||
* @route '/call-dolibarr'
|
|
||||||
*/
|
|
||||||
const callDolibarrForm = (options?: RouteQueryOptions): RouteFormDefinition<'get'> => ({
|
|
||||||
action: callDolibarr.url(options),
|
|
||||||
method: 'get',
|
|
||||||
})
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see routes/dev-routes.php:5
|
|
||||||
* @route '/call-dolibarr'
|
|
||||||
*/
|
|
||||||
callDolibarrForm.get = (options?: RouteQueryOptions): RouteFormDefinition<'get'> => ({
|
|
||||||
action: callDolibarr.url(options),
|
|
||||||
method: 'get',
|
|
||||||
})
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see routes/dev-routes.php:5
|
|
||||||
* @route '/call-dolibarr'
|
|
||||||
*/
|
|
||||||
callDolibarrForm.head = (options?: RouteQueryOptions): RouteFormDefinition<'get'> => ({
|
|
||||||
action: callDolibarr.url({
|
|
||||||
[options?.mergeQuery ? 'mergeQuery' : 'query']: {
|
|
||||||
_method: 'HEAD',
|
|
||||||
...(options?.query ?? options?.mergeQuery ?? {}),
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
method: 'get',
|
|
||||||
})
|
|
||||||
|
|
||||||
callDolibarr.form = callDolibarrForm
|
|
||||||
|
|||||||
@@ -2,7 +2,8 @@
|
|||||||
|
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
Route::get('/call-dolibarr', function () {
|
// Test Dolibarr API
|
||||||
|
/*Route::get('/call-dolibarr', function () {
|
||||||
$call = new \App\Services\Dolibarr\DolibarrService;
|
$call = new \App\Services\Dolibarr\DolibarrService;
|
||||||
$members = $call->getAllMembers();
|
$members = $call->getAllMembers();
|
||||||
// find specific
|
// find specific
|
||||||
@@ -19,3 +20,37 @@ Route::get('/call-dolibarr', function () {
|
|||||||
dd($date1, $date2, $date3, $date4);
|
dd($date1, $date2, $date3, $date4);
|
||||||
|
|
||||||
})->name('call-dolibarr');
|
})->name('call-dolibarr');
|
||||||
|
|
||||||
|
Route::get('/test-dolibarr', function () {
|
||||||
|
$dolibarrService = new \App\Services\Dolibarr\DolibarrService();
|
||||||
|
|
||||||
|
$members = $dolibarrService->getAllMembers();
|
||||||
|
|
||||||
|
dd($members);
|
||||||
|
});
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Test ISPConfig
|
||||||
|
/*Route::get('/test/sync-ispconfig', function () {
|
||||||
|
|
||||||
|
if (!app()->isLocal()) {
|
||||||
|
abort(403);
|
||||||
|
}
|
||||||
|
|
||||||
|
Artisan::call('sync:ispconfig-web-members');
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'status' => 'ok',
|
||||||
|
'output' => Artisan::output(),
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Test ISPConfig Mail
|
||||||
|
Route::get('/test/isp-mails', function() {
|
||||||
|
$ispService = new \App\Services\ISPConfig\ISPConfigMailService;
|
||||||
|
|
||||||
|
return $ispService->getAllMailDomains();
|
||||||
|
});*/
|
||||||
|
|
||||||
|
|||||||
@@ -17,36 +17,6 @@ Route::middleware(['auth', 'verified'])->group(function () {
|
|||||||
})->name('dashboard');
|
})->name('dashboard');
|
||||||
});
|
});
|
||||||
|
|
||||||
// TEST
|
|
||||||
|
|
||||||
/*Route::get('/test/sync-ispconfig', function () {
|
|
||||||
|
|
||||||
if (!app()->isLocal()) {
|
|
||||||
abort(403);
|
|
||||||
}
|
|
||||||
|
|
||||||
Artisan::call('sync:ispconfig-web-members');
|
|
||||||
|
|
||||||
return response()->json([
|
|
||||||
'status' => 'ok',
|
|
||||||
'output' => Artisan::output(),
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
|
|
||||||
Route::get('/test/isp-mails', function() {
|
|
||||||
$ispService = new \App\Services\ISPConfig\ISPConfigMailService;
|
|
||||||
|
|
||||||
return $ispService->getAllMailDomains();
|
|
||||||
});*/
|
|
||||||
|
|
||||||
Route::get('/test-dolibarr', function () {
|
|
||||||
$dolibarrService = new \App\Services\Dolibarr\DolibarrService();
|
|
||||||
|
|
||||||
$members = $dolibarrService->getAllMembers();
|
|
||||||
|
|
||||||
dd($members);
|
|
||||||
});
|
|
||||||
|
|
||||||
require __DIR__.'/settings.php';
|
require __DIR__.'/settings.php';
|
||||||
require __DIR__.'/auth.php';
|
require __DIR__.'/auth.php';
|
||||||
require __DIR__.'/forms.php';
|
require __DIR__.'/forms.php';
|
||||||
|
|||||||
Reference in New Issue
Block a user