\XF\Install\InstallHelperTrait, namely applyGlobalPermission, applyGlobalPermissionInt, applyContentPermission, and applyAdminPermission. They take a permission and apply it to groups which have an existing permission. $this->applyGlobalPermission(
    'yourGroup',
    'yourPermission',
    'forum',
    'postThread'
);
// ...
// only necessary on upgrade
$this->app()->jobManager()->enqueueUnique(
    'permissionRebuild',
    \XF\Job\PermissionRebuild::class,
    [],
    false
);Setup.php. You can also use the Standard Library by @Xon to save some writing. 
					
				 xenforo.com
						
					
					xenforo.com
				SV\StandardLib\InstallerHelper::applyGlobalPermissionByGroup 
public function installStep1337()
{
   $permission = \XF::em()->create('XF:PermissionEntry');
   $permission->set('user_group_id', 3); // 3 for admin
   $permission->set('permission_group_id', 'asppbfoo');
   $permission->set('permission_id', 'manageFoo');
   $permission->set('permission_value', 'allow');
   $permission->set('permission_value_int', 0);
   $permission->save();
   $this->rebuildPermissions();
}
protected function rebuildPermissions()
{
    /** @var \XF\Service\UpdatePermissions $permissionUpdater */
    $permissionUpdater = \XF::service('XF:UpdatePermissions');
    $permissionUpdater->updatePermissions([]);
    /** @var \XF\Repository\PermissionCombination $permComboRepo */
    $permComboRepo = \XF::repository('XF:PermissionCombination');
    $missing = $permComboRepo->insertGuestCombinationIfMissing();
    if ($missing)
    {
        $this->app->jobManager()->enqueueUnique('permissionRebuild', 'XF:PermissionRebuild');
    }
    /** @var \XF\Repository\PermissionEntry $permEntryRepo */
    $permEntryRepo = \XF::repository('XF:PermissionEntry');
    $permEntryRepo->deleteOrphanedGlobalUserPermissionEntries();
    $permEntryRepo->deleteOrphanedContentUserPermissionEntries();
    $permComboRepo->deleteUnusedPermissionCombinations();
}Well, this seems much easier...You can also use the Standard Library by @Xon to save some writing.
public function installStep3(): void
{
    $this->applyDefaultPermissions(0);
}
public function postUpgrade($previousVersion, array &$stateChanges): void
{
    $previousVersion = (int)$previousVersion;
    if ($this->applyDefaultPermissions($previousVersion))
    {
        \XF::app()->jobManager()->enqueueUnique('permissionRebuild', \XF\Job\PermissionRebuild::class, [], true);
    }
}
protected function applyDefaultPermissions(int $previousVersion): bool
{
    $applied = false;
    if ($previousVersion < 1695694020)
    {
        $this->applyGlobalPermissionByGroup('general', 'svCustomizeAdvAlertPrefs', [
            \XF\Entity\User::GROUP_REG,
            \XF\Entity\User::GROUP_MOD,
            \XF\Entity\User::GROUP_ADMIN,
        ]);
        $applied = true;
    }
    return $applied;
}I would rather not have any dependency with other add-ons.Look atSV\StandardLib\InstallerHelper::applyGlobalPermissionByGroup
Is theHave a look at how postUpgrade/applyDefaultPermissions are implemented in: https://github.com/Xon/XenForo2-Ale...oad/src/addons/SV/AlertImprovements/Setup.php
applyGlobalPermissionByGroup() function native to XF or is it a part of SV's addon? I'm guessing it's the latter since I do not find that function in XF\AddOn\AbstractSetup classYep, I'm aware of that. Like I mentioned in the title, I'm aiming to do this in the Setup.php file itself.As far as I know this is not possible by permission definitions
It is part of the Standard Library by Xon:Is theapplyGlobalPermissionByGroup()function native to XF or is it a part of SV's addon?
I'll try this out and let you know. Thanks.Something quick (didn't test tho):
Oh okay. Then it's not something I would prefer to do.It is part of the Standard Library by Xon
\XF\Install\InstallHelperTrait, namely applyGlobalPermission, applyGlobalPermissionInt, applyContentPermission, and applyAdminPermission. They take a permission and apply it to groups which have an existing permission. $this->applyGlobalPermission(
    'yourGroup',
    'yourPermission',
    'forum',
    'postThread'
);
// ...
// only necessary on upgrade
$this->app()->jobManager()->enqueueUnique(
    'permissionRebuild',
    \XF\Job\PermissionRebuild::class,
    [],
    false
);postUpgrade (the latter guarded by a $previousVersion check).We use essential cookies to make this site work, and optional cookies to enhance your experience.