Merge pull request #1998 from dicarlosystems/1994-allow-toggle-custom-modules-in-settings

Adds toggle custom modules on/off, fixes nav issue for disabled modules
This commit is contained in:
Hillel Coren 2018-03-29 20:32:31 +03:00 committed by GitHub
commit df57974c1b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 1 deletions

View File

@ -30,6 +30,7 @@ use App\Ninja\Repositories\ReferralRepository;
use App\Services\AuthService; use App\Services\AuthService;
use App\Services\PaymentService; use App\Services\PaymentService;
use App\Services\TemplateService; use App\Services\TemplateService;
use Nwidart\Modules\Facades\Module;
use Auth; use Auth;
use Cache; use Cache;
use File; use File;
@ -758,6 +759,20 @@ class AccountController extends BaseController
$account = $user->account; $account = $user->account;
$modules = Input::get('modules'); $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();
}
});
(Module::toCollection()->diff($custom_modules))->each(function ($item, $key) {
if ($item->enabled()) {
$item->disable();
}
});
$user->force_pdfjs = Input::get('force_pdfjs') ? true : false; $user->force_pdfjs = Input::get('force_pdfjs') ? true : false;
$user->save(); $user->save();

View File

@ -189,6 +189,14 @@
</label> </label>
</div> </div>
@endforeach @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
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">

View File

@ -392,7 +392,7 @@
@endif @endif
@endforeach @endforeach
@if ( ! Utils::isNinjaProd()) @if ( ! Utils::isNinjaProd())
@foreach (Module::all() as $module) @foreach (Module::collections() as $module)
@include('partials.navigation_option', [ @include('partials.navigation_option', [
'option' => $module->getAlias(), 'option' => $module->getAlias(),
'icon' => $module->get('icon', 'th-large'), 'icon' => $module->get('icon', 'th-large'),