diff --git a/include/class_objects.inc b/include/class_objects.inc index 66ee6d23f82b2c5272ab8ee7d8749867f5c57806..fb71279636852ea403bb48403ffa0ebea2a0218d 100644 --- a/include/class_objects.inc +++ b/include/class_objects.inc @@ -400,6 +400,12 @@ class objects return static::open('new', $type); } + static function delete (string $dn, string $type, bool $checkAcl = TRUE) + { + $tabObject = static::open($dn, $type); + $tabObject->delete($checkAcl); + } + static function createTemplate (string $type): simpleTabs { $infos = static::infos($type); diff --git a/include/management/class_management.inc b/include/management/class_management.inc index 505d217a6615470c1567a6b63d3315c24f198fd3..72dfcdc96a1c88c2bb15b924b85309e0b83c2d93 100644 --- a/include/management/class_management.inc +++ b/include/management/class_management.inc @@ -1020,7 +1020,8 @@ class management implements FusionDirectoryDialog // Delete the object $this->currentDn = $dn; $this->openTabObject(objects::open($this->currentDn, $entry->getTemplatedType())); - $this->tabObject->delete(); + $errors = $this->tabObject->delete(); + msg_dialog::displayChecks($errors); // Remove the lock for the current object. del_lock($this->currentDn); diff --git a/include/simpleplugin/class_simplePlugin.inc b/include/simpleplugin/class_simplePlugin.inc index 0dad01175f887ad744086f468894c3714b7e9bf7..09ca1bbb59cfdc329ec59d38755b0fb34972a07b 100644 --- a/include/simpleplugin/class_simplePlugin.inc +++ b/include/simpleplugin/class_simplePlugin.inc @@ -203,7 +203,7 @@ class simplePlugin implements SimpleTab if (empty($this->acl_category) && isset($plInfo['plCategory'])) { $c = key($plInfo['plCategory']); if (is_numeric($c)) { - $c = $plInfo['plCategory'][0]; + $c = $plInfo['plCategory'][$c]; } $this->acl_category = $c.'/'; } diff --git a/include/simpleplugin/class_simpleTabs.inc b/include/simpleplugin/class_simpleTabs.inc index 8807cef7bc826e57a512fbac8c94643bfb573f7a..ac2555b169a9d85fe20ffa5b3f690ac2e2e075b1 100644 --- a/include/simpleplugin/class_simpleTabs.inc +++ b/include/simpleplugin/class_simpleTabs.inc @@ -346,24 +346,24 @@ class simpleTabs implements FusionDirectoryDialog /*! * \brief Remove object from LDAP + * + * Returns errors */ - function delete () + public function delete (bool $checkAcl = TRUE): array { - if (!$this->getBaseObject()->acl_is_removeable()) { - $error = new SimplePluginPermissionError($this, msgPool::permDelete($this->getBaseObject()->dn)); - $error->display(); - return FALSE; + if ($checkAcl && !$this->getBaseObject()->acl_is_removeable()) { + return [new SimplePluginPermissionError($this, msgPool::permDelete($this->getBaseObject()->dn))]; } /* Delete all tabs in reverse order */ foreach (array_reverse($this->by_object) as $obj) { $errors = $obj->remove(TRUE); if (!empty($errors)) { - msg_dialog::displayChecks($errors); - return FALSE; + return $errors; } } - return TRUE; + + return []; } /*!