From afe35d65c63fbb2ff7613c22cca003bb3fdc1a0b Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Wed, 1 Apr 2015 02:03:48 +0200 Subject: [PATCH] =?UTF-8?q?Bloque=20la=20suppression=20d'entit=C3=A9=20ou?= =?UTF-8?q?=20d'organisation=20ayant=20des=20filles?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LSobjects/config.LSobjects.LSsupannEntite.php | 12 ++++++++++++ .../conf/LSobjects/config.LSobjects.LSsupannOrg.php | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/local/conf/LSobjects/config.LSobjects.LSsupannEntite.php b/local/conf/LSobjects/config.LSobjects.LSsupannEntite.php index dee33bc..4467ceb 100644 --- a/local/conf/LSobjects/config.LSobjects.LSsupannEntite.php +++ b/local/conf/LSobjects/config.LSobjects.LSsupannEntite.php @@ -20,6 +20,15 @@ ******************************************************************************/ +function before_delete_entite($object) { + $entite = new LSsupannEntite(); + if ($entite->listChildren($object)) { + LSerror::addErrorCode('Cette entité a des entités filles, vous ne pouvez pas la supprimer'); + return false; + } + return $false; +} + $GLOBALS['LSobjects']['LSsupannEntite'] = array ( 'objectclass' => array( 'supannEntite', @@ -31,6 +40,9 @@ $GLOBALS['LSobjects']['LSsupannEntite'] = array ( 'label' => 'Entités', 'displayAttrName' => true, + // triggers + 'before_delete' => 'before_delete_entite', + // LSform 'LSform' => array ( 'ajaxSubmit' => 1, diff --git a/local/conf/LSobjects/config.LSobjects.LSsupannOrg.php b/local/conf/LSobjects/config.LSobjects.LSsupannOrg.php index 169d256..d7a8498 100644 --- a/local/conf/LSobjects/config.LSobjects.LSsupannOrg.php +++ b/local/conf/LSobjects/config.LSobjects.LSsupannOrg.php @@ -20,6 +20,15 @@ ******************************************************************************/ +function before_delete_organization($object) { + $org = new LSsupannEntite(); + if ($org->listChildren($object)) { + LSerror::addErrorCode('Cette organisation a des entités filles, vous ne pouvez pas la supprimer'); + return false; + } + return $false; +} + $GLOBALS['LSobjects']['LSsupannOrg'] = array ( 'objectclass' => array( 'organization', @@ -33,6 +42,9 @@ $GLOBALS['LSobjects']['LSsupannOrg'] = array ( 'label' => 'Organisations', 'displayAttrName' => true, + // triggers + 'before_delete' => 'before_delete_organization', + // LSform 'LSform' => array ( 'ajaxSubmit' => 1,