Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
nodeaccess
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
nodeaccess
Commits
78da0c89
Commit
78da0c89
authored
2 years ago
by
Qiangjun Ran
Committed by
Qiangjun Ran
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3317718
by jungle: Implement hook_update_N() to update realms and...
Issue
#3317718
by jungle: Implement hook_update_N() to update realms and migrate nodeaccess.settings
parent
ef8cd85e
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!11
Issue #3408893 by BenStallings: Explain how to find which gids go with which user roles.
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
nodeaccess.install
+86
-0
86 additions, 0 deletions
nodeaccess.install
with
86 additions
and
0 deletions
nodeaccess.install
+
86
−
0
View file @
78da0c89
...
...
@@ -125,3 +125,89 @@ function nodeaccess_update_8101() {
$config
->
set
(
'role_alias'
,
$role_alias
);
$config
->
save
();
}
/**
* Updates realms.
*/
function
nodeaccess_update_9001
(
&
$sandbox
)
{
$database
=
\Drupal
::
database
();
$database
->
update
(
'nodeaccess'
)
->
fields
([
'realm'
=>
'nodeaccess_user'
,
])
->
condition
(
'realm'
,
'nodeaccess_uid'
)
->
execute
();
$database
->
update
(
'nodeaccess'
)
->
fields
([
'realm'
=>
'nodeaccess_role'
,
])
->
condition
(
'realm'
,
'nodeaccess_rid'
)
->
execute
();
}
/**
* Migrates nodeaccess.settings.
*/
function
nodeaccess_update_9002
(
&
$sandbox
)
{
$config
=
\Drupal
::
configFactory
()
->
getEditable
(
'nodeaccess.settings'
);
// From grants to allowed_grant_operations.
$old_grants
=
$config
->
get
(
'grants'
);
$config
->
set
(
'allowed_grant_operations'
,
[
'grant_view'
=>
(
boolean
)
$old_grants
[
'view'
],
'grant_update'
=>
(
boolean
)
$old_grants
[
'edit'
],
'grant_delete'
=>
(
boolean
)
$old_grants
[
'delete'
],
])
->
clear
(
'grants'
);
// From allowed_types to grants_tab_availability.
$old_allowed_types
=
$config
->
get
(
'allowed_types'
);
$grants_tab_availability
=
[];
foreach
(
$old_allowed_types
as
$bundle
=>
$value
)
{
$grants_tab_availability
[
$bundle
]
=
(
boolean
)
$value
;
}
$config
->
set
(
'grants_tab_availability'
,
$grants_tab_availability
)
->
clear
(
'allowed_types'
);
// From role_map to map_rid_gid.
$old_role_map
=
$config
->
get
(
'role_map'
);
$config
->
set
(
'map_rid_gid'
,
$old_role_map
)
->
clear
(
'role_map'
);
// From role_alias to roles_settings.
$old_role_alias
=
$config
->
get
(
'role_alias'
);
$roles_settings
=
[];
foreach
(
$old_role_alias
as
$role_id
=>
$value
)
{
$roles_settings
[
$role_id
]
=
[
'display_name'
=>
$value
[
'alias'
],
'name'
=>
$value
[
'name'
],
'weight'
=>
(
int
)
$value
[
'weight'
],
'selected'
=>
(
boolean
)
$value
[
'allow'
],
];
}
$config
->
set
(
'roles_settings'
,
$roles_settings
)
->
clear
(
'role_alias'
);
$bundles
=
array_keys
(
$old_allowed_types
);
$bundles_roles_grants
=
[];
foreach
(
$bundles
as
$bundle
)
{
$old_bundle_settings
=
$config
->
get
(
$bundle
);
foreach
(
$old_bundle_settings
as
$role_id
=>
$grant
)
{
$bundles_roles_grants
[
$bundle
][
$role_id
]
=
[
'grant_view'
=>
(
int
)
$grant
[
'grant_view'
],
'grant_update'
=>
(
int
)
$grant
[
'grant_update'
],
'grant_delete'
=>
(
int
)
$grant
[
'grant_delete'
],
];
}
$config
->
clear
(
$bundle
);
}
$config
->
set
(
'bundles_roles_grants'
,
$bundles_roles_grants
)
->
clear
(
'priority'
)
->
clear
(
'preserve'
)
->
save
();
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment