Skip to content

Commit

Permalink
EZP-29033: [Legacy] Do not remove links user has no access to (ezsyst…
Browse files Browse the repository at this point in the history
  • Loading branch information
pkamps authored Jul 1, 2018
1 parent 3298b53 commit 50bfaf9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ function initHandlerHeader( $element, &$attributes, &$siblingParams, &$parentPar
function initHandlerLink( $element, &$attributes, &$siblingParams, &$parentParams )
{
$ret = array();
$ezxmlIni = eZINI::instance('ezxml.ini');

// Set link parameters for rendering children of link tag
$href='';
Expand All @@ -203,16 +204,16 @@ function initHandlerLink( $element, &$attributes, &$siblingParams, &$parentParam

if ( $node != null )
{
if ( !$node->object()->canRead() )
$view = $element->getAttribute( 'view' );
if ( $view )
$href = 'content/view/' . $view . '/' . $nodeID;
else if ( !$node->object()->canRead() &&
$ezxmlIni->variable( 'ezxhtml', 'ShowURLAliasForProtectedLinks' ) !== 'enabled' )
{
eZDebug::writeWarning( "Current user does not have read access to the object of node #$nodeID",
'XML output handler: link' );
return $ret;
$href = 'content/view/full/' . $nodeID;
}

$view = $element->getAttribute( 'view' );
if ( $view )
$href = 'content/view/' . $view . '/' . $nodeID;
else
$href = $node->attribute( 'url_alias' );
}
Expand All @@ -227,13 +228,6 @@ function initHandlerLink( $element, &$attributes, &$siblingParams, &$parentParam
if ( isset( $this->ObjectArray["$objectID"] ) )
{
$object = $this->ObjectArray["$objectID"];
if ( !$object->canRead() )
{
eZDebug::writeWarning( "Current user does not have read access to the object #$objectID",
'XML output handler: link' );
return $ret;
}

$node = $object->attribute( 'main_node' );
if ( $node )
{
Expand All @@ -242,6 +236,13 @@ function initHandlerLink( $element, &$attributes, &$siblingParams, &$parentParam
$view = $element->getAttribute( 'view' );
if ( $view )
$href = 'content/view/' . $view . '/' . $nodeID;
else if ( !$object->canRead() &&
$ezxmlIni->variable( 'ezxhtml', 'ShowURLAliasForProtectedLinks' ) !== 'enabled' )
{
eZDebug::writeWarning( "Current user does not have read access to the object #$objectID",
'XML output handler: link' );
$href = 'content/view/full/' . $nodeID;
}
else
$href = $node->attribute( 'url_alias' );
}
Expand Down
3 changes: 3 additions & 0 deletions settings/ezxml.ini
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,6 @@ TagPresets[]
# Determines to insert <p> tag inside a table cell in the output or not
# if there is only one <paragraph> tag inside a cell.
RenderParagraphInTableCells=enabled
# Show URL alias for links the current user does not have read access to.
# If disabled (recommended) the link will be /content/view/full/[nodeID] instead.
ShowURLAliasForProtectedLinks=disabled

0 comments on commit 50bfaf9

Please sign in to comment.