Restrict modules to selfhost installs

This commit is contained in:
Hillel Coren 2018-03-29 22:26:44 +03:00
parent 24e4d2d418
commit 90289fc018
2 changed files with 24 additions and 20 deletions

View File

@ -759,19 +759,21 @@ class AccountController extends BaseController
$account = $user->account;
$modules = Input::get('modules');
// get all custom modules, including disabled
$custom_modules = collect(Input::get('custom_modules'))->each(function ($item, $key) {
$module = Module::find($item);
if ($module && $module->disabled()) {
$module->enable();
}
});
if (Utils::isSelfHost()) {
// get all custom modules, including disabled
$custom_modules = collect(Input::get('custom_modules'))->each(function ($item, $key) {
$module = Module::find($item);
if ($module && $module->disabled()) {
$module->enable();
}
});
(Module::toCollection()->diff($custom_modules))->each(function ($item, $key) {
if ($item->enabled()) {
$item->disable();
}
});
(Module::toCollection()->diff($custom_modules))->each(function ($item, $key) {
if ($item->enabled()) {
$item->disable();
}
});
}
$user->force_pdfjs = Input::get('force_pdfjs') ? true : false;
$user->save();

View File

@ -189,14 +189,16 @@
</label>
</div>
@endforeach
@foreach (Module::all() as $value)
{{ ($value->boot()) }}
<div class="checkbox">
<label for="custom_modules_{{ $value }}">
<input name="custom_modules[]" id="custom_modules_{{ $value }}" type="checkbox" {{ $value->enabled() ? 'checked="checked"' : '' }} value="{{ $value }}">{{ mtrans($value, $value->getLowerName()) }}
</label>
</div>
@endforeach
@if (Utils::isSelfHost())
@foreach (Module::all() as $value)
{{ ($value->boot()) }}
<div class="checkbox">
<label for="custom_modules_{{ $value }}">
<input name="custom_modules[]" id="custom_modules_{{ $value }}" type="checkbox" {{ $value->enabled() ? 'checked="checked"' : '' }} value="{{ $value }}">{{ mtrans($value, $value->getLowerName()) }}
</label>
</div>
@endforeach
@endif
</div>
</div>
<div class="form-group">