#127: InstallController now sets default options and permissions for new installations
This commit is contained in:
parent
0519a4ecc5
commit
806d0696f0
@ -2,10 +2,12 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\AlbumDefaultAnonymousPermission;
|
||||
use App\Configuration;
|
||||
use App\Facade\UserConfig;
|
||||
use App\Helpers\MiscHelper;
|
||||
use App\Http\Requests\StoreUserRequest;
|
||||
use App\Permission;
|
||||
use App\Storage;
|
||||
use App\User;
|
||||
use Illuminate\Http\Request;
|
||||
@ -156,6 +158,9 @@ class InstallController extends Controller
|
||||
$versionNumber->value = config('app.version');
|
||||
$versionNumber->save();
|
||||
|
||||
// Default settings
|
||||
$this->setConfigurationForNewSystems();
|
||||
|
||||
$request->session()->put('install_stage', 3);
|
||||
return redirect(route('install.administrator'));
|
||||
}
|
||||
@ -210,4 +215,47 @@ class InstallController extends Controller
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function setDefaultAnonymousPermission($section, $permission)
|
||||
{
|
||||
$permission = Permission::where([
|
||||
['section', $section],
|
||||
['description', $permission]
|
||||
])->first();
|
||||
|
||||
if (is_null($permission))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$adap = new AlbumDefaultAnonymousPermission();
|
||||
$adap->permission_id = $permission->id;
|
||||
$adap->save();
|
||||
}
|
||||
|
||||
private function setConfigurationForNewSystems()
|
||||
{
|
||||
/** @var Configuration $socialFeeds */
|
||||
$socialFeeds = UserConfig::getOrCreateModel('social_user_feeds');
|
||||
$socialFeeds->value = true;
|
||||
$socialFeeds->save();
|
||||
|
||||
/** @var Configuration $socialProfiles */
|
||||
$socialProfiles = UserConfig::getOrCreateModel('social_user_profiles');
|
||||
$socialProfiles->value = true;
|
||||
$socialProfiles->save();
|
||||
|
||||
/** @var Configuration $photoComments */
|
||||
$photoComments = UserConfig::getOrCreateModel('allow_photo_comments');
|
||||
$photoComments->value = true;
|
||||
$photoComments->save();
|
||||
|
||||
$defaultPermissions = ['album.list', 'album.view', 'album.post-comment'];
|
||||
foreach ($defaultPermissions as $defaultPermission)
|
||||
{
|
||||
$permissionParts = explode('.', $defaultPermission);
|
||||
|
||||
$this->setDefaultAnonymousPermission($permissionParts[0], $permissionParts[1]);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user