Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal
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
drupal
Commits
3b24bc27
Commit
3b24bc27
authored
13 years ago
by
Dries Buytaert
Browse files
Options
Downloads
Patches
Plain Diff
- Patch
#1119158
by skwashd: Added user_role_save() doesn't implement a presave hook.
parent
03ecf2ac
No related branches found
No related tags found
2 merge requests
!7452
Issue #1797438. HTML5 validation is preventing form submit and not fully...
,
!789
Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
modules/user/user.api.php
+19
-0
19 additions, 0 deletions
modules/user/user.api.php
modules/user/user.module
+4
-0
4 additions, 0 deletions
modules/user/user.module
with
23 additions
and
0 deletions
modules/user/user.api.php
+
19
−
0
View file @
3b24bc27
...
@@ -366,6 +366,25 @@ function hook_user_view_alter(&$build) {
...
@@ -366,6 +366,25 @@ function hook_user_view_alter(&$build) {
$build
[
'#post_render'
][]
=
'my_module_user_post_render'
;
$build
[
'#post_render'
][]
=
'my_module_user_post_render'
;
}
}
/**
* Inform other modules that a user role is about to be saved.
*
* Modules implementing this hook can act on the user role object before
* it has been saved to the database.
*
* @param $role
* A user role object.
*
* @see hook_user_role_insert()
* @see hook_user_role_update()
*/
function
hook_user_role_presave
(
$role
)
{
// Set a UUID for the user role if it doesn't already exist
if
(
empty
(
$role
->
uuid
))
{
$role
->
uuid
=
uuid_uuid
();
}
}
/**
/**
* Inform other modules that a user role has been added.
* Inform other modules that a user role has been added.
*
*
...
...
This diff is collapsed.
Click to expand it.
modules/user/user.module
+
4
−
0
View file @
3b24bc27
...
@@ -2828,6 +2828,10 @@ function user_role_save($role) {
...
@@ -2828,6 +2828,10 @@ function user_role_save($role) {
$query
->
addExpression
(
'MAX(weight)'
);
$query
->
addExpression
(
'MAX(weight)'
);
$role
->
weight
=
$query
->
execute
()
->
fetchField
()
+
1
;
$role
->
weight
=
$query
->
execute
()
->
fetchField
()
+
1
;
}
}
// Let modules modify the user role before it is saved to the database.
module_invoke_all
(
'user_role_presave'
,
$role
);
if
(
!
empty
(
$role
->
rid
)
&&
$role
->
name
)
{
if
(
!
empty
(
$role
->
rid
)
&&
$role
->
name
)
{
$status
=
drupal_write_record
(
'role'
,
$role
,
'rid'
);
$status
=
drupal_write_record
(
'role'
,
$role
,
'rid'
);
module_invoke_all
(
'user_role_update'
,
$role
);
module_invoke_all
(
'user_role_update'
,
$role
);
...
...
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