leenooks / phpLDAPadmin

phpLDAPadmin - Web based LDAP administration tool
www.phpldapadmin.org
GNU General Public License v2.0
548 stars 170 forks source link

Templates: "noleaf" element ignored => children always (wrongly) allowed #234

Open sphakka opened 1 year ago

sphakka commented 1 year ago

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

  1. Log into your PLA instance
  2. Go to whatever position in your tree view
  3. Click on 'Create new entry here'
  4. Select a template without a noleaf element, e.g. "Generic: Posix Group"
  5. Create the new object.
  6. 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):

Client system:

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:

  1. 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() as isLeaf()
  2. In lib/TemplateRender.php: change the 'childcreate' test in if (.. && ! $this->template->isLeaf())
  3. Document it ;-)