From 21a676137147c4ce88b1eb5fcbd1bfef7a49d53a Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Tue, 9 Mar 2010 19:16:50 +0100 Subject: [PATCH] LSaddon/supann : Added functions generate_eduPersonOrgDN(), generate_eduPersonPrimaryOrgUnitDN() and generate_eduPersonOrgUnitDN() --- .../conf/LSaddons/config.LSaddons.supann.php | 10 +++ .../includes/addons/LSaddons.supann.php | 79 ++++++++++++++++++- 2 files changed, 88 insertions(+), 1 deletion(-) diff --git a/public_html/conf/LSaddons/config.LSaddons.supann.php b/public_html/conf/LSaddons/config.LSaddons.supann.php index 7c85fb54..03d19ee0 100644 --- a/public_html/conf/LSaddons/config.LSaddons.supann.php +++ b/public_html/conf/LSaddons/config.LSaddons.supann.php @@ -32,4 +32,14 @@ define('LS_SUPANN_LASTNAME_ATTR','sn'); // Nom de l'attribut LDAP prenom define('LS_SUPANN_FIRSTNAME_ATTR','givenName'); +// Type de LSobject correspondant aux entites SUPANN +define('LS_SUPANN_LSOBJECT_ENTITE_TYPE','LSsupannEntite'); + +// DN de l'entite SUPANN correspondant à l'etablissement +define('LS_SUPANN_ETABLISSEMENT_DN','supannCodeEntite=XXX,ou=structures,dc=univ,dc=fr'); + +// Type de LSobject correspondant aux entites SUPANN +// Exemple : 0753742K +define('LS_SUPANN_ETABLISSEMENT_UAI','0753742K'); + ?> diff --git a/public_html/includes/addons/LSaddons.supann.php b/public_html/includes/addons/LSaddons.supann.php index dda0aacf..76a600e4 100644 --- a/public_html/includes/addons/LSaddons.supann.php +++ b/public_html/includes/addons/LSaddons.supann.php @@ -26,11 +26,18 @@ LSerror :: defineError('SUPANN_SUPPORT_01', _("SUPANN Support : The constant %{const} is not defined.") ); +LSerror :: defineError('SUPANN_SUPPORT_02', + _("SUPANN Support : The LSobject type %{type} does not exist. Can't work with entities..") +); + // Autres erreurs LSerror :: defineError('SUPANN_01', _("SUPANN Support : The attribute %{dependency} is missing. Unable to forge the attribute %{attr}.") ); +LSerror :: defineError('SUPANN_02', + _("SUPANN Support : Can't get the basedn of entities. Unable to forge the attribute %{attr}.") +); /** * Verification du support SUPANN par ldapSaisie @@ -44,7 +51,10 @@ LSerror :: defineError('SUPANN_01', $MUST_DEFINE_CONST= array( 'LS_SUPANN_LASTNAME_ATTR', - 'LS_SUPANN_FIRSTNAME_ATTR' + 'LS_SUPANN_FIRSTNAME_ATTR', + 'LS_SUPANN_LSOBJECT_ENTITE_TYPE', + 'LS_SUPANN_ETABLISSEMENT_UAI', + 'LS_SUPANN_ETABLISSEMENT_DN' ); foreach($MUST_DEFINE_CONST as $const) { @@ -53,6 +63,12 @@ LSerror :: defineError('SUPANN_01', $retval=false; } } + + if ( defined('LS_SUPANN_LSOBJECT_ENTITE_TYPE') ) { + if ( ! LSsession :: loadLSobject( LS_SUPANN_LSOBJECT_ENTITE_TYPE ) ) { + LSerror :: addErrorCode('SUPANN_SUPPORT_02', LS_SUPANN_LSOBJECT_ENTITE_TYPE); + } + } return $retval; } @@ -171,4 +187,65 @@ LSerror :: defineError('SUPANN_01', ); return strtr($string, $replaceAccent); } + + function generate_eduPersonOrgUnitDN($ldapObject) { + if ( get_class($ldapObject -> attrs[ 'supannEntiteAffectation' ]) != 'LSattribute' ) { + LSerror :: addErrorCode('SUPANN_01',array('dependency' => 'supannEntiteAffectation', 'attr' => 'eduPersonOrgUnitDN')); + return; + } + + $affectations = $ldapObject -> attrs[ 'supannEntiteAffectation' ] -> getUpdateData(); + + $basedn=LSconfig :: get('LSobjects.'.LS_SUPANN_LSOBJECT_ENTITE_TYPE.'.container_dn').','.LSsession::getTopDn(); + if ($basedn=="") { + LSerror :: addErrorCode('SUPANN_02','eduPersonOrgUnitDN'); + return; + } + + $retval=array(); + foreach ($affectations as $aff) { + $retval[]="supannCodeEntite=".$aff.",$basedn"; + } + + return $retval; + } + + function generate_eduPersonPrimaryOrgUnitDN($ldapObject) { + if ( get_class($ldapObject -> attrs[ 'supannEntiteAffectationPrincipale' ]) != 'LSattribute' ) { + LSerror :: addErrorCode('SUPANN_01',array('dependency' => 'supannEntiteAffectationPrincipale', 'attr' => 'eduPersonPrimaryOrgUnitDN')); + return; + } + + $affectations = $ldapObject -> attrs[ 'supannEntiteAffectationPrincipale' ] -> getUpdateData(); + + $basedn=LSconfig :: get('LSobjects.'.LS_SUPANN_LSOBJECT_ENTITE_TYPE.'.container_dn').','.LSsession::getTopDn(); + if ($basedn=="") { + LSerror :: addErrorCode('SUPANN_02','eduPersonPrimaryOrgUnitDN'); + return; + } + + $retval=array(); + foreach ($affectations as $aff) { + $retval[]="supannCodeEntite=".$aff.",$basedn"; + } + + return $retval; + } + + function generate_eduPersonOrgDN($ldapObject) { + if ( get_class($ldapObject -> attrs[ 'supannEtablissement' ]) != 'LSattribute' ) { + LSerror :: addErrorCode('SUPANN_01',array('dependency' => 'supannEtablissement', 'attr' => 'eduPersonOrgDN')); + return; + } + + $eta = $ldapObject -> attrs[ 'supannEtablissement' ] -> getUpdateData(); + + $retval=array(); + if ($eta[0] == '{UAI}'.LS_SUPANN_ETABLISSEMENT_UAI) { + $retval[] = LS_SUPANN_ETABLISSEMENT_DN; + } + + return $retval; + } + ?>