diff --git a/extensions/package-manager/extend.php b/extensions/package-manager/extend.php index 7b6986c89d..e245bde6e4 100755 --- a/extensions/package-manager/extend.php +++ b/extensions/package-manager/extend.php @@ -46,6 +46,11 @@ && is_writable($paths->base.'/composer.lock'); $document->payload['flarum-extension-manager.using_sync_queue'] = resolve(Queue::class) instanceof SyncQueue; + + $document->payload['flarum-extension-manager.missing_functions'] = array_values(array_filter( + ['proc_open', 'escapeshellarg'], + fn (string $function): bool => ! function_exists($function) + )); }), new Extend\Locales(__DIR__.'/locale'), diff --git a/extensions/package-manager/js/src/admin/components/ControlSection.tsx b/extensions/package-manager/js/src/admin/components/ControlSection.tsx index 33ac417bc5..dc59deb363 100644 --- a/extensions/package-manager/js/src/admin/components/ControlSection.tsx +++ b/extensions/package-manager/js/src/admin/components/ControlSection.tsx @@ -1,6 +1,4 @@ -import app from 'flarum/admin/app'; import Component from 'flarum/common/Component'; -import Alert from 'flarum/common/components/Alert'; import { ComponentAttrs } from 'flarum/common/Component'; import Installer from './Installer'; @@ -17,18 +15,10 @@ export default class ControlSection extends Component { return (
- {app.data['flarum-extension-manager.writable_dirs'] ? ( -
- - - - ) : ( -
- - {app.translator.trans('flarum-extension-manager.admin.file_permissions')} - -
- )} +
+ + +
); diff --git a/extensions/package-manager/js/src/admin/components/SettingsPage.tsx b/extensions/package-manager/js/src/admin/components/SettingsPage.tsx index ec33446058..3331387ec2 100644 --- a/extensions/package-manager/js/src/admin/components/SettingsPage.tsx +++ b/extensions/package-manager/js/src/admin/components/SettingsPage.tsx @@ -8,6 +8,7 @@ import ControlSection from './ControlSection'; import ConfigureComposer from './ConfigureComposer'; import ConfigureAuth from './ConfigureAuth'; import DiscoverSection from './DiscoverSection'; +import Alert from 'flarum/common/components/Alert'; export default class SettingsPage extends ExtensionPage { content() { @@ -43,9 +44,33 @@ export default class SettingsPage extends ExtensionPage { sections(vnode: Mithril.VnodeDOM): ItemList { const items = super.sections(vnode); - items.add('discover', , 15); + const writableDirs = app.data['flarum-extension-manager.writable_dirs']; + const missingFunctions = app.data['flarum-extension-manager.missing_functions'] as string[] | undefined; + const usable = writableDirs && (!missingFunctions || missingFunctions.length === 0); - items.add('control', , 10); + if (usable) { + items.add('discover', , 15); + + items.add('control', , 10); + } else { + items.add( + 'warning', +
+
+
+ + {!app.data['flarum-extension-manager.writable_dirs'] + ? app.translator.trans('flarum-extension-manager.admin.file_permissions') + : app.translator.trans('flarum-extension-manager.admin.required_php_functions', { + functions: (app.data['flarum-extension-manager.missing_functions'] as string[]).join(', '), + })} + +
+
+
, + 10 + ); + } items.setPriority('content', 8); diff --git a/extensions/package-manager/locale/en.yml b/extensions/package-manager/locale/en.yml index ee7949a6cd..132185cd85 100755 --- a/extensions/package-manager/locale/en.yml +++ b/extensions/package-manager/locale/en.yml @@ -99,6 +99,10 @@ flarum-extension-manager: minor_update_confirmation: content: This will also update any other extensions/packages with available updates. + required_php_functions: > + The extension manager requires the following PHP functions to be enabled: {functions}. + If you do not have access to the PHP configuration, please contact your hosting provider. + sections: discover: description: Add new features and integrations to your Flarum forum with extensions.