protected function ActionCommonTrait::actionUser in Content Access 8
Process Rule's param, and grant by the passed operation.
2 calls to ActionCommonTrait::actionUser()
- ActionUserGrant::execute in src/
Plugin/ RulesAction/ ActionUserGrant.php - Executes the plugin.
- ActionUserRevoke::execute in src/
Plugin/ RulesAction/ ActionUserRevoke.php - Executes the plugin.
File
- src/
Plugin/ RulesAction/ ActionCommonTrait.php, line 57
Class
- ActionCommonTrait
- Provides common functionality for Content Access Rules actions.
Namespace
Drupal\content_access\Plugin\RulesActionCode
protected function actionUser(array $params, $type) {
$ops = [
'view',
'update',
'delete',
];
$settings = [];
$node = $params['node'];
foreach ($ops as $op) {
if ($params['content_access_user_' . $op]) {
$settings[$op] = $params['content_access_user_' . $op]
->id();
}
}
foreach ($settings as $op => $uid) {
$acl_id = content_access_get_acl_id($node, $op);
acl_node_add_acl($node
->id(), $acl_id, (int) ($op == 'view'), (int) ($op == 'update'), (int) ($op == 'delete'), content_access_get_settings('priority', $node
->getType()));
$this->database
->delete('acl_user')
->condition('acl_id', $acl_id)
->condition('uid', $uid)
->execute();
if ($type == 'grant') {
$this->database
->insert('acl_user')
->fields([
'acl_id' => $acl_id,
'uid' => $uid,
])
->execute();
}
}
$this
->aquireGrants($node);
}