Templates: "noleaf" element ignored => children always (wrongly) allowed
Maybe I'm misunderstanding the whole meaning (no doc found here and https://phpldapadmin.sourceforge.net/ looks down): XML templates declaring a noleaf element
<noleaf>1</noleaf>
are intended to prevent creating child objects (i.e., nesting) at creation time. However, this behavior is not honored.
Steps to reproduce
- Log into your PLA instance
- Go to whatever position in your tree view
- Click on 'Create new entry here'
- Select a template without a noleaf element, e.g. "Generic: Posix Group"
- Create the new object.
- Click on the newly created object in the tree view: on the right pane, the 'Create a child entry' is shown when it shouldn't.
Expected behavior
When an XML template is declared as noleaf, PLA should prevent nesting such objects by not showing the 'Create a child entry'. Indeed, lib/TemplateRender.php covers correctly the noleaf case, however, lib/Template.php never sets $noleaf which by default is false.
LDAP Server details (please complete the following information):
- OS: GNU/Linux Debian 12
- Server Name: OpenLDAP (slapd v2.5.13+dfsg-5)
- PLA Version: 1.2.6.3-0.3
Client system:
- Device: PC
- OS: GNU/Luinux
- Browser: Firefox 116.0.3
BTW, the formulation of the noleaf mechanism is hard to crack for my brain ;-) I suggest to rename it to nochild or, even better as it follows:
- In
lib/Template.php:- rename the private attr
noleaf=>leaf, meaning "I am a leaf template" - implement/review the leaf setter/getter
- rewrite the method
isNoLeaf()asisLeaf()
- rename the private attr
- In
lib/TemplateRender.php: change the'childcreate'test inif (.. && ! $this->template->isLeaf()) - Document it ;-)