mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 21:22:58 +01:00
Enforce client and user limits with Company Import
This commit is contained in:
parent
4b6d17fa8d
commit
1baadd96b4
@ -159,8 +159,6 @@ class CompanyImport implements ShouldQueue
|
|||||||
|
|
||||||
// nlog($this->backup_file);
|
// nlog($this->backup_file);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(array_key_exists('import_settings', $this->request_array) && $this->request_array['import_settings'] == 'true') {
|
if(array_key_exists('import_settings', $this->request_array) && $this->request_array['import_settings'] == 'true') {
|
||||||
$this->preFlightChecks()->importSettings();
|
$this->preFlightChecks()->importSettings();
|
||||||
}
|
}
|
||||||
@ -189,7 +187,9 @@ class CompanyImport implements ShouldQueue
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
$backup_users = $this->backup_file->users;
|
$backup_users = $this->backup_file->users;
|
||||||
|
|
||||||
$company_users = $this->company->users;
|
$company_users = $this->company->users;
|
||||||
|
|
||||||
$company_owner = $this->company->owner();
|
$company_owner = $this->company->owner();
|
||||||
|
|
||||||
if(Ninja::isFreeHostedClient()){
|
if(Ninja::isFreeHostedClient()){
|
||||||
@ -203,13 +203,11 @@ class CompanyImport implements ShouldQueue
|
|||||||
}
|
}
|
||||||
|
|
||||||
$backup_users_emails = array_column($backup_users, 'email');
|
$backup_users_emails = array_column($backup_users, 'email');
|
||||||
|
|
||||||
$company_users_emails = $company_users->pluck('email')->toArray();
|
$company_users_emails = $company_users->pluck('email')->toArray();
|
||||||
|
|
||||||
$existing_user_count = count(array_intersect($backup_users_emails, $company_users_emails));
|
$existing_user_count = count(array_intersect($backup_users_emails, $company_users_emails));
|
||||||
|
|
||||||
if($existing_user_count == 1)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
if($existing_user_count > 1){
|
if($existing_user_count > 1){
|
||||||
|
|
||||||
if($this->account->plan == 'pro')
|
if($this->account->plan == 'pro')
|
||||||
@ -218,6 +216,7 @@ class CompanyImport implements ShouldQueue
|
|||||||
if($this->account->plan == 'enterprise'){
|
if($this->account->plan == 'enterprise'){
|
||||||
|
|
||||||
$total_import_users = count($backup_users_emails);
|
$total_import_users = count($backup_users_emails);
|
||||||
|
|
||||||
$account_plan_num_user = $this->account->num_users;
|
$account_plan_num_user = $this->account->num_users;
|
||||||
|
|
||||||
if($total_import_users > $account_plan_num_user){
|
if($total_import_users > $account_plan_num_user){
|
||||||
@ -232,6 +231,18 @@ class CompanyImport implements ShouldQueue
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(Ninja::isFreeHostedClient() && count($this->backup_file->clients) > config('ninja.quotas.free.clients')){
|
||||||
|
|
||||||
|
$client_count = count($this->backup_file->clients);
|
||||||
|
|
||||||
|
$client_limit = config('ninja.quotas.free.clients');
|
||||||
|
|
||||||
|
$this->message = "You are attempting to import ({$client_count}) clients, your current plan allows a total of ({$client_limit})";
|
||||||
|
|
||||||
|
return false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user