| 1 |
<?php |
| 2 |
|
| 3 |
namespace FluentForm\App\Http\Policies; |
| 4 |
|
| 5 |
use FluentForm\App\Modules\Acl\Acl; |
| 6 |
use FluentForm\Framework\Foundation\Policy; |
| 7 |
use FluentForm\Framework\Http\Request\Request; |
| 8 |
|
| 9 |
class GlobalIntegrationPolicy extends Policy |
| 10 |
{ |
| 11 |
public function verifyRequest(Request $request) |
| 12 |
{ |
| 13 |
return $this->canManageGlobalIntegrations(); |
| 14 |
} |
| 15 |
|
| 16 |
public function index() |
| 17 |
{ |
| 18 |
return $this->canManageGlobalIntegrations(); |
| 19 |
} |
| 20 |
|
| 21 |
public function updateIntegration() |
| 22 |
{ |
| 23 |
return $this->canManageGlobalIntegrations(); |
| 24 |
} |
| 25 |
|
| 26 |
public function updateModuleStatus() |
| 27 |
{ |
| 28 |
return $this->canManageGlobalIntegrations(); |
| 29 |
} |
| 30 |
|
| 31 |
private function canManageGlobalIntegrations() |
| 32 |
{ |
| 33 |
if ( |
| 34 |
current_user_can('manage_options') || |
| 35 |
current_user_can('fluentform_full_access') || |
| 36 |
current_user_can('fluentform_settings_manager') |
| 37 |
) { |
| 38 |
return true; |
| 39 |
} |
| 40 |
|
| 41 |
$roleCapability = Acl::getCurrentUserCapability(); |
| 42 |
|
| 43 |
// Legacy role-level Fluent Forms access stores the WP role key here. |
| 44 |
// Granular Fluent Forms permissions must not imply settings access. |
| 45 |
return $roleCapability && !in_array($roleCapability, Acl::getPermissionSet(), true); |
| 46 |
} |
| 47 |
} |
| 48 |
|