method optionsUpdateAll documentation in bbn\User\Permissions
Updates all the permission for the options.
function()
{
$cf = $this->opt->getClassCfg();
$of =& $cf['arch']['options'];
$num = 0;
$tmp = $this->db->getColumnValues(
[
'table' => $cf['table'],
'fields' => [$of['id']],
'join' => [
[
'table' => $cf['table'],
'alias' => 'parent_option',
'type' => 'left',
'on' => [
[
'field' => 'parent_option.'.$of['id'],
'exp' => $cf['table'].'.'.$of['id_parent']
], [
'field' => 'parent_option.'.$of['cfg'],
'operator' => 'contains',
'value' => '"permissions":'
]
]
]
],
'where' => [
[
'field' => $cf['table'].'.'.$of['cfg'],
'operator' => 'contains',
'value' => '"permissions":'
], [
'field' => $cf['table'].'.'.$of['id'],
'operator' => '!=',
'value' => $this->opt->getRoot()
], [
'field' => $cf['table'].'.'.$of['id'],
'operator' => '!=',
'value' => $this->opt->fromCode('appui')
], [
'field' => $cf['table'].'.'.$of['id'],
'operator' => '!=',
'value' => $this->opt->fromCode('plugins')
], [
'field' => 'parent_option.'.$of['id'],
'operator' => 'isnull'
]
]
]
);
if ($tmp) {
$permissions = [];
foreach ($tmp as $id) {
/** @var array The option's config */
$cfg = $this->opt->getCfg($id) ?: [];
if (!empty($cfg['permissions'])) {
$permissions[$id] = $cfg['permissions'];
foreach ($this->opt->getAliasItems($id) as $alias) {
$permissions[$alias] = $cfg['permissions'];
}
}
/*
if (isset($cfg['scfg']) && !empty($cfg['scfg']['permissions'])) {
foreach ($this->opt->items($id) as $ido) {
$permissions[$ido] = $cfg['scfg']['permissions'];
}
}
*/
}
foreach ($permissions as $id => $mode) {
$all = [];
/** @var array The parents, starting from root */
if (!($root = $this->optionPermissionRoot($id, true))) {
continue;
}
$it = false;
switch ($mode) {
case 'single':
if ($tmp = $this->opt->option($id)) {
$it = $tmp;
}
break;
case 'cascade':
case 'all':
if ($tmp = $this->opt->fullTree($id)) {
$it = $tmp;
}
break;
case 'children':
case 1:
case '1':
if ($tmp = $this->opt->fullOptions($id)) {
$it = $this->opt->option($id);
$it['items'] = $tmp;
}
break;
}
if ($it) {
$all = X::rmap(
function ($a) {
$tmp = [
'text' => '',
'code' => null,
'id_alias' => $a['id']
];
if (!empty($a['items'])) {
$tmp['items'] = $a['items'];
}
return $tmp;
},
[$it],
'items'
);
$all[0]['id_parent'] = $root;
$num += $this->createOptionPermission($all[0]);
}
}
}
return $num;
}
Updates all the permission for the options. BBN is a suite of PHP and JS libraries and VueJS components - all open-source! bbn.io, build applications, the quick way
This website uses cookies to ensure you get the best experience on our website.
© 2011-2025
BBN Solutions