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
cb07e913
Commit
cb07e913
authored
Jun 15, 2013
by
alexpott
Browse files
Issue
#1999444
by chertzog: Use Symfony Request for translation module.
parent
fa9c197e
Changes
1
Hide whitespace changes
Inline
Side-by-side
core/modules/translation/translation.module
View file @
cb07e913
...
...
@@ -122,9 +122,12 @@ function translation_permission() {
* Implements hook_node_access().
*/
function
translation_node_access
(
$node
,
$op
,
$account
,
$langcode
)
{
$request_has_translation_arg
=
isset
(
$_GET
[
'translation'
])
&&
isset
(
$_GET
[
'target'
])
&&
is_numeric
(
$_GET
[
'translation'
]);
$query
=
Drupal
::
request
()
->
query
;
$translation
=
$query
->
get
(
'translation'
);
$target
=
$query
->
get
(
'target'
);
$request_has_translation_arg
=
!
empty
(
$translation
)
&&
!
empty
(
$target
)
&&
is_numeric
(
$translation
);
if
(
$op
==
'create'
&&
$request_has_translation_arg
)
{
$source_node
=
node_load
(
$
_GET
[
'
translation
'
]
);
$source_node
=
node_load
(
$translation
);
if
(
empty
(
$source_node
)
||
!
translation_user_can_translate_node
(
$source_node
,
$account
)){
return
NODE_ACCESS_DENY
;
}
...
...
@@ -304,19 +307,22 @@ function translation_node_view(EntityInterface $node, EntityDisplay $display, $v
* Implements hook_node_prepare().
*/
function
translation_node_prepare
(
EntityInterface
$node
)
{
$query
=
Drupal
::
request
()
->
query
;
$translation
=
$query
->
get
(
'translation'
);
$target
=
$query
->
get
(
'target'
);
// Only act if we are dealing with a content type supporting translations.
if
(
translation_supported_type
(
$node
->
type
)
&&
// And it's a new node.
empty
(
$node
->
nid
)
&&
// And the
$_GET
variables are set properly.
isset
(
$_GET
[
'
translation
'
]
)
&&
isset
(
$_GET
[
'
target
'
]
)
&&
is_numeric
(
$
_GET
[
'
translation
'
]
))
{
// And the
request
variables are set properly.
!
empty
(
$
translation
)
&&
!
empty
(
$
target
)
&&
is_numeric
(
$translation
))
{
$source_node
=
node_load
(
$
_GET
[
'
translation
'
]
);
$source_node
=
node_load
(
$translation
);
$language_list
=
language_list
();
$langcode
=
$
_GET
[
'
target
'
]
;
$langcode
=
$target
;
if
(
!
isset
(
$language_list
[
$langcode
])
||
(
$source_node
->
langcode
==
$langcode
))
{
// If not supported language, or same language as source node, break.
return
;
...
...
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