diff --git a/app-modules/alert/src/Policies/AlertStatusPolicy.php b/app-modules/alert/src/Policies/AlertStatusPolicy.php index d8cd86f9b..da9f44221 100644 --- a/app-modules/alert/src/Policies/AlertStatusPolicy.php +++ b/app-modules/alert/src/Policies/AlertStatusPolicy.php @@ -37,11 +37,22 @@ namespace AdvisingApp\Alert\Policies; use AdvisingApp\Alert\Models\AlertStatus; +use AdvisingApp\Prospect\Models\Prospect; +use AdvisingApp\StudentDataModel\Models\Student; use App\Models\Authenticatable; use Illuminate\Auth\Access\Response; class AlertStatusPolicy { + public function before(Authenticatable $authenticatable): ?Response + { + if (! $authenticatable->hasAnyLicense([Student::getLicenseType(), Prospect::getLicenseType()])) { + return Response::deny('You are not licensed for the Retention or Recruitment CRM.'); + } + + return null; + } + public function viewAny(Authenticatable $authenticatable): Response { return $authenticatable->canOrElse( diff --git a/app-modules/basic-needs/src/Policies/BasicNeedsCategoryPolicy.php b/app-modules/basic-needs/src/Policies/BasicNeedsCategoryPolicy.php index 11ecf8bd9..f65b0b246 100644 --- a/app-modules/basic-needs/src/Policies/BasicNeedsCategoryPolicy.php +++ b/app-modules/basic-needs/src/Policies/BasicNeedsCategoryPolicy.php @@ -37,6 +37,7 @@ namespace AdvisingApp\BasicNeeds\Policies; use AdvisingApp\BasicNeeds\Models\BasicNeedsCategory; +use AdvisingApp\Prospect\Models\Prospect; use AdvisingApp\StudentDataModel\Models\Student; use App\Models\Authenticatable; use Illuminate\Auth\Access\Response; @@ -45,8 +46,8 @@ class BasicNeedsCategoryPolicy { public function before(Authenticatable $authenticatable): ?Response { - if (! $authenticatable->hasLicense(Student::getLicenseType())) { - return Response::deny('You are not licensed for the Retention CRM.'); + if (! $authenticatable->hasAnyLicense([Student::getLicenseType(), Prospect::getLicenseType()])) { + return Response::deny('You are not licensed for the Retention or Recruitment CRM.'); } return null; diff --git a/app-modules/basic-needs/src/Policies/BasicNeedsProgramPolicy.php b/app-modules/basic-needs/src/Policies/BasicNeedsProgramPolicy.php index bb9dfac91..645a0e806 100644 --- a/app-modules/basic-needs/src/Policies/BasicNeedsProgramPolicy.php +++ b/app-modules/basic-needs/src/Policies/BasicNeedsProgramPolicy.php @@ -37,6 +37,7 @@ namespace AdvisingApp\BasicNeeds\Policies; use AdvisingApp\BasicNeeds\Models\BasicNeedsProgram; +use AdvisingApp\Prospect\Models\Prospect; use AdvisingApp\StudentDataModel\Models\Student; use App\Models\Authenticatable; use Illuminate\Auth\Access\Response; @@ -45,8 +46,8 @@ class BasicNeedsProgramPolicy { public function before(Authenticatable $authenticatable): ?Response { - if (! $authenticatable->hasLicense(Student::getLicenseType())) { - return Response::deny('You are not licensed for the Retention CRM.'); + if (! $authenticatable->hasAnyLicense([Student::getLicenseType(), Prospect::getLicenseType()])) { + return Response::deny('You are not licensed for the Retention or Recruitment CRM.'); } return null; diff --git a/app-modules/engagement/src/Filament/Resources/EmailTemplateResource.php b/app-modules/engagement/src/Filament/Resources/EmailTemplateResource.php index 84141243e..6352152bb 100644 --- a/app-modules/engagement/src/Filament/Resources/EmailTemplateResource.php +++ b/app-modules/engagement/src/Filament/Resources/EmailTemplateResource.php @@ -36,6 +36,7 @@ namespace AdvisingApp\Engagement\Filament\Resources; +use AdvisingApp\Authorization\Enums\LicenseType; use AdvisingApp\Engagement\Filament\Resources\EmailTemplateResource\Pages\CreateEmailTemplate; use AdvisingApp\Engagement\Filament\Resources\EmailTemplateResource\Pages\EditEmailTemplate; use AdvisingApp\Engagement\Filament\Resources\EmailTemplateResource\Pages\ListEmailTemplates; @@ -53,6 +54,14 @@ class EmailTemplateResource extends Resource protected static ?string $cluster = Communication::class; + public static function canAccess(): bool + { + /** @var User $user */ + $user = auth()->user(); + + return $user->hasAnyLicense([LicenseType::RetentionCrm, LicenseType::RecruitmentCrm]); + } + public static function getPages(): array { return [ diff --git a/app-modules/engagement/src/Filament/Resources/SmsTemplateResource.php b/app-modules/engagement/src/Filament/Resources/SmsTemplateResource.php index a80287d35..ddaa6e2d6 100644 --- a/app-modules/engagement/src/Filament/Resources/SmsTemplateResource.php +++ b/app-modules/engagement/src/Filament/Resources/SmsTemplateResource.php @@ -36,6 +36,7 @@ namespace AdvisingApp\Engagement\Filament\Resources; +use AdvisingApp\Authorization\Enums\LicenseType; use AdvisingApp\Engagement\Filament\Resources\SmsTemplateResource\Pages\CreateSmsTemplate; use AdvisingApp\Engagement\Filament\Resources\SmsTemplateResource\Pages\EditSmsTemplate; use AdvisingApp\Engagement\Filament\Resources\SmsTemplateResource\Pages\ListSmsTemplates; @@ -57,6 +58,14 @@ class SmsTemplateResource extends Resource protected static ?string $cluster = Communication::class; + public static function canAccess(): bool + { + /** @var User $user */ + $user = auth()->user(); + + return $user->hasAnyLicense([LicenseType::RetentionCrm, LicenseType::RecruitmentCrm]); + } + public static function getPages(): array { return [ diff --git a/app-modules/prospect/src/Filament/Pages/ManageProspectConversionSettings.php b/app-modules/prospect/src/Filament/Pages/ManageProspectConversionSettings.php index b425799de..9a72dccd1 100644 --- a/app-modules/prospect/src/Filament/Pages/ManageProspectConversionSettings.php +++ b/app-modules/prospect/src/Filament/Pages/ManageProspectConversionSettings.php @@ -36,6 +36,7 @@ namespace AdvisingApp\Prospect\Filament\Pages; +use AdvisingApp\Prospect\Models\Prospect; use App\Filament\Clusters\ConstituentManagement; use App\Filament\Forms\Components\Heading; use App\Filament\Forms\Components\Paragraph; @@ -67,6 +68,10 @@ public static function canAccess(): bool /** @var User $user */ $user = auth()->user(); + if (! $user->hasLicense(Prospect::getLicenseType())) { + return false; + } + return $user->can(['product_admin.view-any']); } diff --git a/app-modules/prospect/src/Filament/Pages/ManageProspectPipelineSettings.php b/app-modules/prospect/src/Filament/Pages/ManageProspectPipelineSettings.php index 9b655b691..32ea397d8 100644 --- a/app-modules/prospect/src/Filament/Pages/ManageProspectPipelineSettings.php +++ b/app-modules/prospect/src/Filament/Pages/ManageProspectPipelineSettings.php @@ -37,6 +37,7 @@ namespace AdvisingApp\Prospect\Filament\Pages; use AdvisingApp\Prospect\Filament\Resources\ProspectResource; +use AdvisingApp\Prospect\Models\Prospect; use AdvisingApp\Prospect\Settings\ProspectPipelineSettings; use App\Features\PipelineFlag; use App\Filament\Clusters\ConstituentManagement; @@ -53,7 +54,7 @@ class ManageProspectPipelineSettings extends SettingsPage protected static ?string $cluster = ConstituentManagement::class; - protected static ?string $navigationGroup = 'Prospect Management'; + protected static ?string $navigationGroup = 'Prospects'; protected static string $settings = ProspectPipelineSettings::class; @@ -66,6 +67,10 @@ public static function canAccess(): bool /** @var User $user */ $user = auth()->user(); + if (! $user->hasLicense(Prospect::getLicenseType())) { + return false; + } + return PipelineFlag::active() && $user->can(['product_admin.view-any']); } diff --git a/app-modules/prospect/src/Filament/Resources/ProspectTagResource.php b/app-modules/prospect/src/Filament/Resources/ProspectTagResource.php index 1f644b083..91aa2ec38 100644 --- a/app-modules/prospect/src/Filament/Resources/ProspectTagResource.php +++ b/app-modules/prospect/src/Filament/Resources/ProspectTagResource.php @@ -40,6 +40,7 @@ use AdvisingApp\Prospect\Filament\Resources\ProspectTagResource\Pages\EditProspectTag; use AdvisingApp\Prospect\Filament\Resources\ProspectTagResource\Pages\ListProspectTags; use AdvisingApp\Prospect\Filament\Resources\ProspectTagResource\Pages\ViewProspectTag; +use AdvisingApp\Prospect\Models\Prospect; use App\Enums\TagType; use App\Filament\Clusters\ConstituentManagement; use App\Models\Tag; @@ -60,6 +61,14 @@ class ProspectTagResource extends Resource protected static ?string $navigationGroup = 'Prospects'; + public static function canAccess(): bool + { + /** @var User $user */ + $user = auth()->user(); + + return $user->hasLicense(Prospect::getLicenseType()); + } + public static function getPages(): array { return [ diff --git a/app-modules/student-data-model/src/Filament/Pages/ManageStudentConfiguration.php b/app-modules/student-data-model/src/Filament/Pages/ManageStudentConfiguration.php index 7259186b7..91db17461 100644 --- a/app-modules/student-data-model/src/Filament/Pages/ManageStudentConfiguration.php +++ b/app-modules/student-data-model/src/Filament/Pages/ManageStudentConfiguration.php @@ -36,6 +36,7 @@ namespace AdvisingApp\StudentDataModel\Filament\Pages; +use AdvisingApp\StudentDataModel\Models\Student; use AdvisingApp\StudentDataModel\Settings\ManageStudentConfigurationSettings; use App\Filament\Clusters\ConstituentManagement; use App\Models\User; @@ -60,6 +61,10 @@ public static function canAccess(): bool /** @var User $user */ $user = auth()->user(); + if (! $user->hasLicense(Student::getLicenseType())) { + return false; + } + return $user->can(['product_admin.view-any']); } diff --git a/app-modules/student-data-model/src/Filament/Resources/StudentTagResource.php b/app-modules/student-data-model/src/Filament/Resources/StudentTagResource.php index 7a5dc9a54..1ef443281 100644 --- a/app-modules/student-data-model/src/Filament/Resources/StudentTagResource.php +++ b/app-modules/student-data-model/src/Filament/Resources/StudentTagResource.php @@ -40,6 +40,7 @@ use AdvisingApp\StudentDataModel\Filament\Resources\StudentTagResource\Pages\EditStudentTag; use AdvisingApp\StudentDataModel\Filament\Resources\StudentTagResource\Pages\ListStudentTags; use AdvisingApp\StudentDataModel\Filament\Resources\StudentTagResource\Pages\ViewStudentTag; +use AdvisingApp\StudentDataModel\Models\Student; use App\Enums\TagType; use App\Filament\Clusters\ConstituentManagement; use App\Models\Tag; @@ -60,6 +61,14 @@ class StudentTagResource extends Resource protected static ?string $navigationGroup = 'Students'; + public static function canAccess(): bool + { + /** @var User $user */ + $user = auth()->user(); + + return $user->hasLicense(Student::getLicenseType()); + } + public static function getPages(): array { return [