24require_once DOL_DOCUMENT_ROOT.
'/modulebuilder/class/AccessRuleExpression.class.php';
31 const TYPE =
'predicate';
33 const IS_ADMIN =
'isAdmin';
34 const IS_INTERNAL_USER =
'isInternalUser';
35 const CAN_READ_OBJECT =
'canReadObject';
36 const CAN_WRITE_OBJECT =
'canWriteObject';
37 const CAN_DELETE_OBJECT =
'canDeleteObject';
44 self::IS_ADMIN =>
'!empty($user->admin)',
45 self::IS_INTERNAL_USER =>
'empty($user->socid)',
46 self::CAN_READ_OBJECT =>
"\$user->hasRight('mymodule', 'myobject', 'read')",
47 self::CAN_WRITE_OBJECT =>
"\$user->hasRight('mymodule', 'myobject', 'write')",
48 self::CAN_DELETE_OBJECT =>
"\$user->hasRight('mymodule', 'myobject', 'delete')",
60 if (!array_key_exists($name, self::PREDICATES)) {
61 throw new \InvalidArgumentException(
'Unknown access rule predicate: '.$name);
81 return self::PREDICATES[$this->name];
89 return array(
'type' => self::TYPE,
'name' => $this->
name);
Leaf of the access rule tree: one whitelisted condition on the user.
__construct(string $name)
toPhp()
Render the predicate as a PHP boolean expression.
const PREDICATES
PHP rendered for each predicate.
Node of the access rule tree of the pages generated by ModuleBuilder.
$conf db name
Only used if Module[ID]Name translation string is not found.