Last active
August 21, 2016 16:48
-
-
Save emanuele45/6915fe4403f49952b8c6d03f1667aec1 to your computer and use it in GitHub Desktop.
My suggestion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Settings_Form | |
{ | |
public static function prepare_db(&$config_vars) | |
{ | |
... | |
// If we have inline permissions we need to prep them. | |
if (!empty($inlinePermissions) && allowedTo('manage_permissions')) | |
{ | |
// We'll need to initialize inline permissions sub-form | |
require_once(SUBSDIR . '/Permission.subs.php'); | |
// First Let's take the "global" exclusions | |
$permissions_excluded = isset($context['permissions_excluded']) ? $context['permissions_excluded'] : array(); | |
// Then, if there is any, the "local" (configuration-specific) exclusions | |
if (isset($config_var['excluded_groups'])) | |
{ | |
$permissions_excluded = array_merge($permissions_excluded, $config_var['excluded_groups']); | |
} | |
InlinePermissions_Form::init_inline_permissions($inlinePermissions, $permissions_excluded); | |
} | |
... | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$config_vars = [ | |
['permissions', 'my_var', 'excluded_groups' => [5]], | |
]; | |
$context['permissions_excluded'] = array(-1); | |
Settings_Form::prepare_db($config_vars); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// First Let's take the "global" exclusions | |
$permissions_excluded = isset($context['permissions_excluded']) ? $context['permissions_excluded'] : array(); | |
/** | |
* $permissions_excluded = array(-1); | |
*/ | |
// Then, if there is any, the "local" (configuration-specific) exclusions | |
if (isset($config_var['excluded_groups'])) | |
{ | |
$permissions_excluded = array_merge($permissions_excluded, $config_var['excluded_groups']); | |
/** | |
* $permissions_excluded = array(-1, 5); | |
*/ | |
} | |
InlinePermissions_Form::init_inline_permissions($inlinePermissions, $permissions_excluded); | |
} | |
... | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$context['my_var'] = array( | |
0 => array( | |
'id' => 0, | |
'name' => 'Regular Members', | |
'is_postgroup' => false, | |
'status' => 'off', | |
), | |
); | |
The "-1" entry is not returned because of $context['permissions_excluded']. | |
The "5" entry is not returned because of 'excluded_groups' in $config_vars. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment