Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
3b24bc27
Commit
3b24bc27
authored
May 14, 2011
by
Dries
Browse files
- Patch
#1119158
by skwashd: Added user_role_save() doesn't implement a presave hook.
parent
03ecf2ac
Changes
2
Hide whitespace changes
Inline
Side-by-side
modules/user/user.api.php
View file @
3b24bc27
...
...
@@ -366,6 +366,25 @@ function hook_user_view_alter(&$build) {
$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.
*
...
...
modules/user/user.module
View file @
3b24bc27
...
...
@@ -2828,6 +2828,10 @@ function user_role_save($role) {
$query
->
addExpression
(
'MAX(weight)'
);
$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
)
{
$status
=
drupal_write_record
(
'role'
,
$role
,
'rid'
);
module_invoke_all
(
'user_role_update'
,
$role
);
...
...
Write
Preview
Supports
Markdown
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