method createPermByReal documentation in bbn\Ide\Directories
Creates a permission option from a real file/dir's path
function($file, $type = 'file')
{
is_dir(\bbn\Mvc::getAppPath()) &&
file_exists($file) &&
// It must be a controller
(strpos($file, '/mvc/public/') !== false)
){
$is_file = $type === 'file';
// Check if it's an external route
foreach ( $this->routes as $i => $r ){
if ( strpos($file, $r) === 0 ){
// Remove route
$f = substr($file, \strlen($r), \strlen($file));
// Remove /mvc/public
$f = substr($f, \strlen('/mvc/public'), \strlen($f));
// Add the route's name to path
$f = $i . $f;
}
}
// Internal route
if ( empty($f) ){
$root_path = \bbn\Mvc::getAppPath().'mvc/public/';
if ( strpos($file, $root_path) === 0 ){
// Remove root path
$f = substr($file, \strlen($root_path), \strlen($file));
}
}
if ( !empty($f) ){
$bits = bbn\X::removeEmpty(explode('/', $f));
$code = $is_file ? bbn\Str::fileExt(array_pop($bits), 1)[0] : array_pop($bits).'/';
$id_parent = $this->options->fromCode('page', 'bbn_permissions');
foreach ( $bits as $b ){
if ( !$this->options->fromCode($b.'/', $id_parent) ){
$this->options->add([
'id_parent' => $id_parent,
'code' => $b.'/',
'text' => $b
]);
}
$id_parent = $this->options->fromCode($b.'/', $id_parent);
}
if ( !$this->options->fromCode($code, $id_parent) ){
$this->options->add([
'id_parent' => $id_parent,
'code' => $code,
'text' => $code
]);
}
return $this->options->fromCode($code, $id_parent);
}
else if ( !$is_file ){
return $this->options->fromCode('page', 'bbn_permissions');
}
return true;
}
return false;
}
Creates a permission option from a real file/dir's path 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