eZ Platform Discussions

Policies - Read content in draft


#1

Hi.

I have a problem with the configuration of my users’ rights.

My user has the following rights:

Policy Limitations
Content / Read : Location : /content
Content / Read : Subtree : /content/site1
Content / Versionread : Subtree : /content/site1

I’m trying to read content that has an object relationship and one of the objects in the relationship is in the trash.

As the user is not allowed to read this content I have an error: User does not have access to ‘read’ ‘content’ with: contentId ‘159’’

What right should I add to it?


#2

Your read template should ignore elements in the trash, maybe you could check if the target object is trashed.

Look at this legacy code: https://github.com/ezsystems/ezpublish-legacy/blob/master/design/standard/templates/content/datatype/view/ezobjectrelationlist.tpl

Multiples ckeck are done directly on the template, I don’t know how to do that but maybe you could try to care about that.


#3

Look a this:

{% block ezobjectrelationlist_field %}
    {% spaceless %}
        {% if not ez_is_field_empty( content, field ) %}
        <ul {{ block( 'field_attributes' ) }}>
            {% for contentId in field.value.destinationContentIds if parameters.available[contentId] %}
            {{ fos_httpcache_tag('relation-' ~ contentId) }}
            <li>
                {{ render( controller( "ez_content:viewAction", {'contentId': contentId, 'viewType': 'embed', 'layout': false} ) ) }}
            </li>
            {% endfor %}
        </ul>
        {% endif %}
    {% endspaceless %}
{% endblock %}

Here maybe something can help you:

{% for contentId in field.value.destinationContentIds if parameters.available[contentId] %}


#4

Thanks for your help, @skrosoft,

I’d already handled that in front. And I forgot to mention that my problem was in the Admin.

    public function headerMenuAction()
    {
        $siteSettings = $this->getSiteSettings(); // Content

        /** @var \eZ\Publish\Core\FieldType\RelationList\Value $v */
        $v = $siteSettings->getFieldValue('header_menu');

        $items = [];

        foreach($v->destinationContentIds as $destinationContentId) {
            $c = $this->getRepository()->getContentService()->loadContent($destinationContentId);
            if ($c && $c->contentInfo && $c->contentInfo->mainLocationId) {
                $l = $this->getRepository()->getLocationService()->loadLocation($c->contentInfo->mainLocationId);
                if ($l && !$l->invisible) {
                    $items[] = $destinationContentId;
                }
            }
        }

        return  $this->render('MyBundle:parts:header_menu_items.html.twig', array(
            'items' => $items,
        ));
    }