LSaddon SUPANN: add supannCheckEntityCouldBeDeleted() function

This commit is contained in:
Benjamin Renard 2020-09-22 18:12:50 +02:00
parent 43cf5ccd7a
commit 85b74feb86
4 changed files with 58 additions and 17 deletions

View file

@ -35,10 +35,13 @@ LSerror :: defineError('SUPANN_SUPPORT_03',
// Autres erreurs // Autres erreurs
LSerror :: defineError('SUPANN_01', LSerror :: defineError('SUPANN_01',
___("SUPANN Support : The attribute %{dependency} is missing. Unable to forge the attribute %{attr}.") ___("SUPANN: The attribute %{dependency} is missing. Unable to forge the attribute %{attr}.")
); );
LSerror :: defineError('SUPANN_02', LSerror :: defineError('SUPANN_02',
___("SUPANN Support : Can't get the basedn of entities. Unable to forge the attribute %{attr}.") ___("SUPANN: Can't get the basedn of entities. Unable to forge the attribute %{attr}.")
);
LSerror :: defineError('SUPANN_03',
___("SUPANN: This entity have children entities and could be deleted.")
); );
/** /**
@ -539,3 +542,33 @@ function supannCheckEduPersonPrimaryAffiliation(&$ldapObject) {
function generate_eduPersonPrincipalName($ldapObject) { function generate_eduPersonPrincipalName($ldapObject) {
return $ldapObject -> getFData($GLOBALS['LS_SUPANN_EPPN_FORMAT']); return $ldapObject -> getFData($GLOBALS['LS_SUPANN_EPPN_FORMAT']);
} }
/**
* Vérifie si une entité SUPANN peux être suprimée.
*
* Cette fonction est prévue pour pouvoir être utilisé comme paramètre
* before_delete de la configuration du type d'objet correspondant aux
* entités SUPANN. Elle vérifie que l'entité n'a pas d'entité fille
* avant suppression. Si au moins une entité fille est trouvée, la
* suppression est bloquée et une message d'erreur est affiché.
*
* Note: Cette fonction peut également être utilisé pour le type d'objet
* correspond aux établissements.
*
* @param[in] &$ldapObject Une référence à l'object LSldapObject
*
* @retval boolean True si la valeur est valide, False sinon
**/
function supannCheckEntityCouldBeDeleted($ldapObject) {
$children = $ldapObject -> listObjectsInRelation(
$ldapObject,
'supannCodeEntiteParent',
$GLOBALS['LS_SUPANN_LSOBJECT_ENTITE_TYPE'],
'supannCodeEntite'
);
if ($children) {
LSerror :: addErrorCode('SUPANN_03');
return false;
}
return true;
}

View file

@ -8,7 +8,7 @@ msgstr ""
"Project-Id-Version: LdapSaisie\n" "Project-Id-Version: LdapSaisie\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: \n" "POT-Creation-Date: \n"
"PO-Revision-Date: 2020-09-22 16:20+0200\n" "PO-Revision-Date: 2020-09-22 18:12+0200\n"
"Last-Translator: Benjamin Renard <brenard@zionetrix.net>\n" "Last-Translator: Benjamin Renard <brenard@zionetrix.net>\n"
"Language-Team: LdapSaisie <ldapsaisie-users@lists.labs.libre-entreprise." "Language-Team: LdapSaisie <ldapsaisie-users@lists.labs.libre-entreprise."
"org>\n" "org>\n"
@ -194,25 +194,29 @@ msgstr "Support SUPPAN : Le tableau global %{array} n'est pas définie."
#: /home/brenard/dev/ldapsaisie_clean3/src/includes/addons/LSaddons.supann.php:38 #: /home/brenard/dev/ldapsaisie_clean3/src/includes/addons/LSaddons.supann.php:38
msgid "" msgid ""
"SUPANN Support : The attribute %{dependency} is missing. Unable to forge the " "SUPANN: The attribute %{dependency} is missing. Unable to forge the "
"attribute %{attr}." "attribute %{attr}."
msgstr "" msgstr ""
"Support SUPANN : L'attribut %{dependency} est manquant. Impossible de " "SUPANN : L'attribut %{dependency} est manquant. Impossible de générer "
"générer l'attribut %{attr}." "l'attribut %{attr}."
#: /home/brenard/dev/ldapsaisie_clean3/src/includes/addons/LSaddons.supann.php:41 #: /home/brenard/dev/ldapsaisie_clean3/src/includes/addons/LSaddons.supann.php:41
msgid "" msgid ""
"SUPANN Support : Can't get the basedn of entities. Unable to forge the " "SUPANN: Can't get the basedn of entities. Unable to forge the attribute "
"attribute %{attr}." "%{attr}."
msgstr "" msgstr ""
"Support SUPANN : Impossible de récupérer le basedn des entités. Impossible " "SUPANN : Impossible de récupérer le basedn des entités. Impossible de "
"de générer l'attribut %{attr}." "générer l'attribut %{attr}."
#: /home/brenard/dev/ldapsaisie_clean3/src/includes/addons/LSaddons.supann.php:316 #: /home/brenard/dev/ldapsaisie_clean3/src/includes/addons/LSaddons.supann.php:44
msgid "SUPANN: This entity have children entities and could be deleted."
msgstr "SUPANN : Cette entité a des entités filles et ne peut être supprimée."
#: /home/brenard/dev/ldapsaisie_clean3/src/includes/addons/LSaddons.supann.php:319
msgid "Entity %{id} (unrecognized)" msgid "Entity %{id} (unrecognized)"
msgstr "Entité %{id} (non-reconnue)" msgstr "Entité %{id} (non-reconnue)"
#: /home/brenard/dev/ldapsaisie_clean3/src/includes/addons/LSaddons.supann.php:411 #: /home/brenard/dev/ldapsaisie_clean3/src/includes/addons/LSaddons.supann.php:414
#: /home/brenard/dev/ldapsaisie_clean3/src/includes/class/class.LSformElement_select.php:58 #: /home/brenard/dev/ldapsaisie_clean3/src/includes/class/class.LSformElement_select.php:58
#: /home/brenard/dev/ldapsaisie_clean3/src/includes/class/class.LSformElement_select_object.php:102 #: /home/brenard/dev/ldapsaisie_clean3/src/includes/class/class.LSformElement_select_object.php:102
msgid "%{value} (unrecognized value)" msgid "%{value} (unrecognized value)"

View file

@ -147,21 +147,25 @@ msgstr ""
#: /home/brenard/dev/ldapsaisie_clean3/src/includes/addons/LSaddons.supann.php:38 #: /home/brenard/dev/ldapsaisie_clean3/src/includes/addons/LSaddons.supann.php:38
msgid "" msgid ""
"SUPANN Support : The attribute %{dependency} is missing. Unable to forge the " "SUPANN: The attribute %{dependency} is missing. Unable to forge the "
"attribute %{attr}." "attribute %{attr}."
msgstr "" msgstr ""
#: /home/brenard/dev/ldapsaisie_clean3/src/includes/addons/LSaddons.supann.php:41 #: /home/brenard/dev/ldapsaisie_clean3/src/includes/addons/LSaddons.supann.php:41
msgid "" msgid ""
"SUPANN Support : Can't get the basedn of entities. Unable to forge the " "SUPANN: Can't get the basedn of entities. Unable to forge the attribute "
"attribute %{attr}." "%{attr}."
msgstr "" msgstr ""
#: /home/brenard/dev/ldapsaisie_clean3/src/includes/addons/LSaddons.supann.php:316 #: /home/brenard/dev/ldapsaisie_clean3/src/includes/addons/LSaddons.supann.php:44
msgid "SUPANN: This entity have children entities and could be deleted."
msgstr ""
#: /home/brenard/dev/ldapsaisie_clean3/src/includes/addons/LSaddons.supann.php:319
msgid "Entity %{id} (unrecognized)" msgid "Entity %{id} (unrecognized)"
msgstr "" msgstr ""
#: /home/brenard/dev/ldapsaisie_clean3/src/includes/addons/LSaddons.supann.php:411 #: /home/brenard/dev/ldapsaisie_clean3/src/includes/addons/LSaddons.supann.php:414
#: /home/brenard/dev/ldapsaisie_clean3/src/includes/class/class.LSformElement_select.php:58 #: /home/brenard/dev/ldapsaisie_clean3/src/includes/class/class.LSformElement_select.php:58
#: /home/brenard/dev/ldapsaisie_clean3/src/includes/class/class.LSformElement_select_object.php:102 #: /home/brenard/dev/ldapsaisie_clean3/src/includes/class/class.LSformElement_select_object.php:102
msgid "%{value} (unrecognized value)" msgid "%{value} (unrecognized value)"