my17560 / dokuwiki-template-readthedokus

"Read the Docs" flavored DokuWiki template
MIT License
14 stars 11 forks source link

Show "Edit this page" only if user is allowed to edit #15

Closed fthommen closed 2 years ago

fthommen commented 2 years ago

hi,

the link "Edit this page" is always shown in the header even if the user is not allowed to edit the page, eg. by ACL.

I've fixed this on our site by adding an additional condition $INFO["editable"] to the relevant section in tpl_parts/tpl_pageheader.html. This changes

        <!-- Edit this page -->
        <?php if ($ACT == "show" && $INFO["userinfo"]) { ?>
            <a style="margin-left:auto" href="<?php echo wl($ID,array('do'=>'edit'),true,'&'); ?>">
                <i class="fas fa-pencil-alt"></i>
                <span> Edit this page</span>
            </a>
        <?php } ?>

to

                <!-- Edit this page -->
                <?php if ($ACT == "show" && $INFO["userinfo"] && $INFO["editable"]) { ?>
                        <a style="margin-left:auto" href="<?php echo wl($ID,array('do'=>'edit'),true,'&'); ?>">
                                <i class="fas fa-pencil-alt"></i>
                                <span> Edit this page</span>
                        </a>
                <?php } ?>

I'm not sure if this is the official way to do it for DokuWiki, but if it is, then I suggest to add this to the template.

my17560 commented 2 years ago

I confirmed the bug and your fix just worked fine. I'll add your fix to the next release. Thanks!