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
2ebaaa10
Commit
2ebaaa10
authored
16 years ago
by
Dries Buytaert
Browse files
Options
Downloads
Patches
Plain Diff
- Patch
#272900
by pwolanin: prevent concurrent modificiations of book pages.
parent
e1ef7fb3
Branches
Branches containing commit
Tags
Tags containing commit
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
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/book/book.admin.inc
+27
-5
27 additions, 5 deletions
modules/book/book.admin.inc
with
27 additions
and
5 deletions
modules/book/book.admin.inc
+
27
−
5
View file @
2ebaaa10
...
...
@@ -73,7 +73,7 @@ function book_admin_edit($form_state, $node) {
drupal_set_title
(
check_plain
(
$node
->
title
));
$form
=
array
();
$form
[
'#node'
]
=
$node
;
$form
[
'table'
]
=
_book_admin_table
(
$node
);
_book_admin_table
(
$node
,
$form
);
$form
[
'save'
]
=
array
(
'#type'
=>
'submit'
,
'#value'
=>
t
(
'Save book pages'
),
...
...
@@ -82,6 +82,18 @@ function book_admin_edit($form_state, $node) {
return
$form
;
}
/**
* Check that the book has not been changed while using the form.
*
* @see book_admin_edit()
*/
function
book_admin_edit_validate
(
$form
,
&
$form_state
)
{
if
(
$form_state
[
'values'
][
'tree_hash'
]
!=
$form_state
[
'values'
][
'tree_current_hash'
])
{
form_set_error
(
''
,
t
(
'This book has been modified by another user, the changes could not be saved.'
));
$form_state
[
'rebuild'
]
=
TRUE
;
}
}
/**
* Handle submission of the book administrative page form.
*
...
...
@@ -130,8 +142,8 @@ function book_admin_edit_submit($form, &$form_state) {
*
* @see book_admin_edit()
*/
function
_book_admin_table
(
$node
)
{
$form
=
array
(
function
_book_admin_table
(
$node
,
&
$form
)
{
$form
[
'table'
]
=
array
(
'#theme'
=>
'book_admin_table'
,
'#tree'
=>
TRUE
,
);
...
...
@@ -139,10 +151,20 @@ function _book_admin_table($node) {
$tree
=
book_menu_subtree_data
(
$node
->
book
);
$tree
=
array_shift
(
$tree
);
// Do not include the book item itself.
if
(
$tree
[
'below'
])
{
_book_admin_table_tree
(
$tree
[
'below'
],
$form
);
$hash
=
sha1
(
serialize
(
$tree
[
'below'
]));
// Store the hash value as a hidden form element so that we can detect
// if another user changed the book hierarchy.
$form
[
'tree_hash'
]
=
array
(
'#type'
=>
'hidden'
,
'#default_value'
=>
$hash
,
);
$form
[
'tree_current_hash'
]
=
array
(
'#type'
=>
'value'
,
'#value'
=>
$hash
,
);
_book_admin_table_tree
(
$tree
[
'below'
],
$form
[
'table'
]);
}
return
$form
;
}
/**
...
...
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