mirror of
https://github.com/flarum/core.git
synced 2025-06-08 15:44:57 +02:00
Hardcode primary keys during installation
This avoids misleading assumptions about automatically generated primary keys in some cases. Fixes #566.
This commit is contained in:
parent
ad2bbdd115
commit
c842fa0184
@ -29,6 +29,8 @@ use Exception;
|
|||||||
|
|
||||||
class InstallCommand extends AbstractCommand
|
class InstallCommand extends AbstractCommand
|
||||||
{
|
{
|
||||||
|
const MOD_GROUP_ID = 4;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var DataProviderInterface
|
* @var DataProviderInterface
|
||||||
*/
|
*/
|
||||||
@ -262,18 +264,19 @@ class InstallCommand extends AbstractCommand
|
|||||||
Group::unguard();
|
Group::unguard();
|
||||||
|
|
||||||
$groups = [
|
$groups = [
|
||||||
['Admin', 'Admins', '#B72A2A', 'wrench'],
|
[Group::ADMINISTRATOR_ID, 'Admin', 'Admins', '#B72A2A', 'wrench'],
|
||||||
['Guest', 'Guests', null, null],
|
[Group::GUEST_ID, 'Guest', 'Guests', null, null],
|
||||||
['Member', 'Members', null, null],
|
[Group::MEMBER_ID, 'Member', 'Members', null, null],
|
||||||
['Mod', 'Mods', '#80349E', 'bolt']
|
[static::MOD_GROUP_ID, 'Mod', 'Mods', '#80349E', 'bolt']
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach ($groups as $group) {
|
foreach ($groups as $group) {
|
||||||
Group::create([
|
Group::create([
|
||||||
'name_singular' => $group[0],
|
'id' => $group[0],
|
||||||
'name_plural' => $group[1],
|
'name_singular' => $group[1],
|
||||||
'color' => $group[2],
|
'name_plural' => $group[2],
|
||||||
'icon' => $group[3]
|
'color' => $group[3],
|
||||||
|
'icon' => $group[4],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -282,17 +285,17 @@ class InstallCommand extends AbstractCommand
|
|||||||
{
|
{
|
||||||
$permissions = [
|
$permissions = [
|
||||||
// Guests can view the forum
|
// Guests can view the forum
|
||||||
[2, 'viewDiscussions'],
|
[Group::GUEST_ID, 'viewDiscussions'],
|
||||||
|
|
||||||
// Members can create and reply to discussions
|
// Members can create and reply to discussions
|
||||||
[3, 'startDiscussion'],
|
[Group::MEMBER_ID, 'startDiscussion'],
|
||||||
[3, 'discussion.reply'],
|
[Group::MEMBER_ID, 'discussion.reply'],
|
||||||
|
|
||||||
// Moderators can edit + delete stuff
|
// Moderators can edit + delete stuff
|
||||||
[4, 'discussion.delete'],
|
[static::MOD_GROUP_ID, 'discussion.delete'],
|
||||||
[4, 'discussion.deletePosts'],
|
[static::MOD_GROUP_ID, 'discussion.deletePosts'],
|
||||||
[4, 'discussion.editPosts'],
|
[static::MOD_GROUP_ID, 'discussion.editPosts'],
|
||||||
[4, 'discussion.rename'],
|
[static::MOD_GROUP_ID, 'discussion.rename'],
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach ($permissions as &$permission) {
|
foreach ($permissions as &$permission) {
|
||||||
@ -324,7 +327,7 @@ class InstallCommand extends AbstractCommand
|
|||||||
$user->is_activated = 1;
|
$user->is_activated = 1;
|
||||||
$user->save();
|
$user->save();
|
||||||
|
|
||||||
$user->groups()->sync([1]);
|
$user->groups()->sync([Group::ADMINISTRATOR_ID]);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function enableBundledExtensions()
|
protected function enableBundledExtensions()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user