Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
new_project
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Jobs
Commits
Open sidebar
Telenkov Ruslan
new_project
Commits
225992c2
Commit
225992c2
authored
Jun 07, 2022
by
Telenkov Ruslan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
this is role task
parent
6558fd45
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
2 deletions
+24
-2
role.info.yml
app/docroot/modules/custom/role/role.info.yml
+1
-2
role.module
app/docroot/modules/custom/role/role.module
+23
-0
No files found.
app/docroot/modules/custom/
twig/twig
.info.yml
→
app/docroot/modules/custom/
role/role
.info.yml
View file @
225992c2
name
:
TestBf
description
:
Creates a page showing "Bootcamp".
name
:
Role Task
package
:
Custom
type
:
module
core_version_requirement
:
^8.8 || ^9
app/docroot/modules/custom/role/role.module
0 → 100644
View file @
225992c2
<?php
use
Drupal\Core\Access\AccessResult
;
use
Drupal\Core\Session\AccountInterface
;
use
Drupal\node\NodeInterface
;
/**
* Implements hook_node_access().
*/
function
role_node_access
(
\Drupal\node\NodeInterface
$node
,
$op
,
\Drupal\Core\Session\AccountInterface
$account
)
{
$type
=
$node
->
bundle
();
if
(
$account
->
id
()
!=
'1'
)
{
if
(
$type
==
'editor'
&&
$op
==
'update'
)
{
//Узнать uid в поле ноды
$uid_role
=
$node
->
get
(
'field_role'
)
->
target_id
;
// id текущего пользователя
$uid_now
=
$account
->
id
();
if
(
$uid_now
==
$uid_role
)
{
return
AccessResult
::
allowed
();
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment