- LSerror : Déclaration des messages d'erreurs avec la méthode statique

defineError() plutôt que l'utilisation d'une variable globale
- LSldap : Transformation de la classe pour que les appels soient statiques
This commit is contained in:
Benjamin Renard 2009-01-25 14:37:03 +00:00
parent 03c375d827
commit da46c1ae00
19 changed files with 347 additions and 348 deletions

View file

@ -23,42 +23,34 @@
// Messages d'erreur // Messages d'erreur
// Support // Support
$GLOBALS['LSerror_code']['FTP_SUPPORT_01']= array ( LSerror :: defineError('FTP_SUPPORT_01',
'msg' => _("FTP Support : Pear::Net_FTP est introuvable."), _("FTP Support : Pear::Net_FTP est introuvable.")
'level' => 'c'
); );
$GLOBALS['LSerror_code']['FTP_SUPPORT_02']= array ( LSerror :: defineError('FTP_SUPPORT_02',
'msg' => _("FTP Support : La constante %{const} n'est pas défini."), _("FTP Support : La constante %{const} n'est pas défini.")
'level' => 'c'
); );
// Autres erreurs // Autres erreurs
$GLOBALS['LSerror_code']['FTP_00']= array ( LSerror :: defineError('FTP_00',
'msg' => _("Net_FTP Error : %{msg}"), _("Net_FTP Error : %{msg}")
'level' => 'c'
); );
$GLOBALS['LSerror_code']['FTP_01']= array ( LSerror :: defineError('FTP_01',
'msg' => _("FTP Support : Impossible de se connecter au serveur FTP (Etape : %{etape})."), _("FTP Support : Impossible de se connecter au serveur FTP (Etape : %{etape}).")
'level' => 'c'
); );
$GLOBALS['LSerror_code']['FTP_02']= array ( LSerror :: defineError('FTP_02',
'msg' => _("FTP Support : Impossible de créer le dossier %{dir} sur le serveur distant."), _("FTP Support : Impossible de créer le dossier %{dir} sur le serveur distant.")
'level' => 'c'
); );
$GLOBALS['LSerror_code']['FTP_03']= array ( LSerror :: defineError('FTP_03',
'msg' => _("FTP Support : Impossible de supprimer le dossier %{dir} sur le serveur distant."), _("FTP Support : Impossible de supprimer le dossier %{dir} sur le serveur distant.")
'level' => 'c'
); );
$GLOBALS['LSerror_code']['FTP_04']= array ( LSerror :: defineError('FTP_04',
'msg' => _("FTP Support : Impossible de modifier les droits du dossier %{dir} sur le serveur distant."), _("FTP Support : Impossible de modifier les droits du dossier %{dir} sur le serveur distant.")
'level' => 'c'
); );
$GLOBALS['LSerror_code']['FTP_05']= array ( LSerror :: defineError('FTP_05',
'msg' => _("FTP Support : Impossible de renomer le dossier %{old} en %{new} sur le serveur distant."), _("FTP Support : Impossible de renomer le dossier %{old} en %{new} sur le serveur distant.")
'level' => 'c'
); );
/** /**

View file

@ -23,20 +23,17 @@
// Messages d'erreur // Messages d'erreur
// Support // Support
$GLOBALS['LSerror_code']['MAIL_SUPPORT_01']= array ( LSerror :: defineError('MAIL_SUPPORT_01',
'msg' => _("MAIL Support : Pear::MAIL est introuvable."), _("MAIL Support : Pear::MAIL est introuvable.")
'level' => 'c'
); );
// Autres erreurs // Autres erreurs
$GLOBALS['LSerror_code']['MAIL_00']= array ( LSerror :: defineError('MAIL_00',
'msg' => _("MAIL Error : %{msg}"), _("MAIL Error : %{msg}")
'level' => 'c'
); );
$GLOBALS['LSerror_code']['MAIL_01']= array ( LSerror :: defineError('MAIL_01',
'msg' => _("MAIL : Problème durant l'envoie de votre mail"), _("MAIL : Problème durant l'envoie de votre mail")
'level' => 'c'
); );
/** /**

View file

@ -23,25 +23,25 @@
// Messages d'erreur // Messages d'erreur
// Support // Support
$GLOBALS['LSerror_code']['MAILDIR_SUPPORT_01']= array ( LSerror :: defineError('MAILDIR_SUPPORT_01',
'msg' => _("MAILDIR Support : Impossible de charger LSaddons::FTP.") _("MAILDIR Support : Impossible de charger LSaddons::FTP.")
); );
$GLOBALS['LSerror_code']['MAILDIR_SUPPORT_02']= array ( LSerror :: defineError('MAILDIR_SUPPORT_02',
'msg' => _("MAILDIR Support : La constante %{const} n'est pas définie.") _("MAILDIR Support : La constante %{const} n'est pas définie.")
); );
// Autres erreurs // Autres erreurs
$GLOBALS['LSerror_code']['MAILDIR_01']= array ( LSerror :: defineError('MAILDIR_01',
'msg' => _("MAILDIR : Erreur durant la création de la maildir sur le serveur distant.") _("MAILDIR : Erreur durant la création de la maildir sur le serveur distant.")
); );
$GLOBALS['LSerror_code']['MAILDIR_02']= array ( LSerror :: defineError('MAILDIR_02',
'msg' => _("MAILDIR : Erreur durant la suppression de la maildir sur le serveur distant.") _("MAILDIR : Erreur durant la suppression de la maildir sur le serveur distant.")
); );
$GLOBALS['LSerror_code']['MAILDIR_03']= array ( LSerror :: defineError('MAILDIR_03',
'msg' => _("MAILDIR : Erreur durant le renomage de la maildir sur le serveur distant.") _("MAILDIR : Erreur durant le renomage de la maildir sur le serveur distant.")
); );
$GLOBALS['LSerror_code']['MAILDIR_04']= array ( LSerror :: defineError('MAILDIR_04',
'msg' => _("MAILDIR : Erreur durant la récupération du chemin distant de la maildir.") _("MAILDIR : Erreur durant la récupération du chemin distant de la maildir.")
); );
/** /**

View file

@ -23,20 +23,17 @@
// Messages d'erreur // Messages d'erreur
// Support // Support
$GLOBALS['LSerror_code']['POSIX_SUPPORT_01']= array ( LSerror :: defineError('POSIX_SUPPORT_01',
'msg' => _("POSIX Support : La constante %{const} n'est pas définie."), _("POSIX Support : La constante %{const} n'est pas définie.")
'level' => 'c'
); );
$GLOBALS['LSerror_code']['POSIX_SUPPORT_02']= array ( LSerror :: defineError('POSIX_SUPPORT_02',
'msg' => _("POSIX Support : Impossible de charger LSaddons::FTP."), _("POSIX Support : Impossible de charger LSaddons::FTP.")
'level' => 'c'
); );
// Autres erreurs // Autres erreurs
$GLOBALS['LSerror_code']['POSIX_01']= array ( LSerror :: defineError('POSIX_01',
'msg' => _("POSIX : L'attribut %{dependency} est introuvable. Impossible de générer l'attribut %{attr}."), _("POSIX : L'attribut %{dependency} est introuvable. Impossible de générer l'attribut %{attr}.")
'level' => 'c'
); );
/** /**
@ -93,7 +90,7 @@ $GLOBALS['LSerror_code']['POSIX_01']= array (
*/ */
function generate_uidNumber($ldapObject) { function generate_uidNumber($ldapObject) {
$objects = $GLOBALS['LSldap'] -> search (LS_POSIX_UIDNUMBER_ATTR.'=*'); $objects = LSldap :: search (LS_POSIX_UIDNUMBER_ATTR.'=*');
$uidNumber = LS_POSIX_UIDNUMBER_MIN_VAL; $uidNumber = LS_POSIX_UIDNUMBER_MIN_VAL;
if (!is_array($objects)) if (!is_array($objects))
@ -120,7 +117,7 @@ $GLOBALS['LSerror_code']['POSIX_01']= array (
*/ */
function generate_gidNumber($ldapObject) { function generate_gidNumber($ldapObject) {
$objects = $GLOBALS['LSldap'] -> search (LS_POSIX_GIDNUMBER_ATTR.'=*'); $objects = LSldap :: search (LS_POSIX_GIDNUMBER_ATTR.'=*');
$gidNumber = LS_POSIX_GIDNUMBER_MIN_VAL; $gidNumber = LS_POSIX_GIDNUMBER_MIN_VAL;
if (!is_array($objects)) if (!is_array($objects))

View file

@ -23,24 +23,20 @@
// Messages d'erreur // Messages d'erreur
// Support // Support
$GLOBALS['LSerror_code']['SAMBA_SUPPORT_01']= array ( LSerror :: defineError('SAMBA_SUPPORT_01',
'msg' => _("SAMBA Support : la classe smHash ne peut pas être chargée."), _("SAMBA Support : la classe smHash ne peut pas être chargée.")
'level' => 'c'
); );
$GLOBALS['LSerror_code']['SAMBA_SUPPORT_02']= array ( LSerror :: defineError('SAMBA_SUPPORT_02',
'msg' => _("SAMBA Support : La constante %{const} n'est pas définie."), _("SAMBA Support : La constante %{const} n'est pas définie.")
'level' => 'c'
); );
$GLOBALS['LSerror_code']['SAMBA_SUPPORT_03']= array ( LSerror :: defineError('SAMBA_SUPPORT_03',
'msg' => _("SAMBA Support : Les constantes LS_SAMBA_SID_BASE_USER et LS_SAMBA_SID_BASE_GROUP ne doivent pas avoir la même parité pour l'unicité des sambaSID."), _("SAMBA Support : Les constantes LS_SAMBA_SID_BASE_USER et LS_SAMBA_SID_BASE_GROUP ne doivent pas avoir la même parité pour l'unicité des sambaSID.")
'level' => 'c'
); );
// Autres erreurs // Autres erreurs
$GLOBALS['LSerror_code']['SAMBA_01']= array ( LSerror :: defineError('SAMBA_01',
'msg' => _("SAMBA Support : L'attribut %{dependency} est introuvable. Impossible de générer l'attribut %{attr}."), _("SAMBA Support : L'attribut %{dependency} est introuvable. Impossible de générer l'attribut %{attr}.")
'level' => 'c'
); );
/** /**

View file

@ -23,15 +23,13 @@
// Messages d'erreur // Messages d'erreur
// Support // Support
$GLOBALS['LSerror_code']['SUPANN_SUPPORT_01']= array ( LSerror :: defineError('SUPANN_SUPPORT_01',
'msg' => _("SUPANN Support : La constante %{const} n'est pas définie."), _("SUPANN Support : La constante %{const} n'est pas définie.")
'level' => 'c'
); );
// Autres erreurs // Autres erreurs
$GLOBALS['LSerror_code']['SUPANN_01']= array ( LSerror :: defineError('SUPANN_01',
'msg' => _("SUPANN Support : L'attribut %{dependency} est introuvable. Impossible de générer l'attribut %{attr}."), _("SUPANN Support : L'attribut %{dependency} est introuvable. Impossible de générer l'attribut %{attr}.")
'level' => 'c'
); );
/** /**

View file

@ -109,12 +109,12 @@ class LSattr_html {
/* /*
* Error Codes * Error Codes
*/ */
$GLOBALS['LSerror_code']['LSattr_html_01'] = array ( LSerror :: defineError('LSattr_html_01',
'msg' => _("LSattr_html : The method addToForm() of the HTML type of the attribute %{attr} is not defined.") _("LSattr_html : The method addToForm() of the HTML type of the attribute %{attr} is not defined.")
); );
// 02 : not yet used // 02 : not yet used
$GLOBALS['LSerror_code']['LSattr_html_03'] = array ( LSerror :: defineError('LSattr_html_03',
'msg' => _("LSattr_html_%{type} : The multiple data are not supported for this field type.") _("LSattr_html_%{type} : The multiple data are not supported for this field type.")
); );
?> ?>

View file

@ -127,7 +127,7 @@ class LSattr_html_select_list extends LSattr_html{
/* /*
* Error Codes * Error Codes
*/ */
$GLOBALS['LSerror_code']['LSattr_html_select_list_01'] = array ( LSerror :: defineError('LSattr_html_select_list_01',
'msg' => _("LSattr_html_select_list : Configuration data are missing to generate the select list of the attribute %{attr}.") _("LSattr_html_select_list : Configuration data are missing to generate the select list of the attribute %{attr}.")
); );
?> ?>

View file

@ -195,8 +195,8 @@ class LSattr_html_select_object extends LSattr_html{
/* /*
* Error Codes * Error Codes
*/ */
$GLOBALS['LSerror_code']['LSattr_html_select_object_01'] = array ( LSerror :: defineError('LSattr_html_select_object_01',
'msg' => _("LSattr_html_select_object : LSobject type is undefined (attribute : %{attr}).") _("LSattr_html_select_object : LSobject type is undefined (attribute : %{attr}).")
); );
?> ?>

View file

@ -65,7 +65,7 @@ class LSattr_ldap_password extends LSattr_ldap {
break; break;
case 'ext_des': case 'ext_des':
if ( ! defined( 'CRYPT_EXT_DES' ) || CRYPT_EXT_DES == 0 ) { if ( ! defined( 'CRYPT_EXT_DES' ) || CRYPT_EXT_DES == 0 ) {
LSerror :: addErrorCode(1023,'ext_des'); LSerror :: addErrorCode('LSattr_ldap_password_01','ext_des');
} }
else { else {
return '{CRYPT}' . crypt( $this -> clearPassword, '_' . $this -> getSalt(8) ); return '{CRYPT}' . crypt( $this -> clearPassword, '_' . $this -> getSalt(8) );
@ -73,7 +73,7 @@ class LSattr_ldap_password extends LSattr_ldap {
break; break;
case 'blowfish': case 'blowfish':
if( ! defined( 'CRYPT_BLOWFISH' ) || CRYPT_BLOWFISH == 0 ) { if( ! defined( 'CRYPT_BLOWFISH' ) || CRYPT_BLOWFISH == 0 ) {
LSerror :: addErrorCode(1023,'blowfish'); LSerror :: addErrorCode('LSattr_ldap_password_01','blowfish');
} }
else { else {
return '{CRYPT}' . crypt( $this -> clearPassword, '$2a$12$' . $this -> getSalt(13) ); return '{CRYPT}' . crypt( $this -> clearPassword, '$2a$12$' . $this -> getSalt(13) );
@ -86,7 +86,7 @@ class LSattr_ldap_password extends LSattr_ldap {
elseif( function_exists( 'mhash' ) ) { elseif( function_exists( 'mhash' ) ) {
return '{SHA}' . base64_encode( mhash( MHASH_SHA1, $this -> clearPassword ) ); return '{SHA}' . base64_encode( mhash( MHASH_SHA1, $this -> clearPassword ) );
} else { } else {
LSerror :: addErrorCode(1023,'sha'); LSerror :: addErrorCode('LSattr_ldap_password_01','sha');
} }
break; break;
case 'ssha': case 'ssha':
@ -96,7 +96,7 @@ class LSattr_ldap_password extends LSattr_ldap {
return "{SSHA}".base64_encode( mhash( MHASH_SHA1, $this -> clearPassword.$salt ).$salt ); return "{SSHA}".base64_encode( mhash( MHASH_SHA1, $this -> clearPassword.$salt ).$salt );
} }
else { else {
LSerror :: addErrorCode(1023,'ssha'); LSerror :: addErrorCode('LSattr_ldap_password_01','ssha');
} }
break; break;
case 'smd5': case 'smd5':
@ -106,7 +106,7 @@ class LSattr_ldap_password extends LSattr_ldap {
return "{SMD5}".base64_encode( mhash( MHASH_MD5, $password_clear.$salt ).$salt ); return "{SMD5}".base64_encode( mhash( MHASH_MD5, $password_clear.$salt ).$salt );
} }
else { else {
LSerror :: addErrorCode(1023,'smd5'); LSerror :: addErrorCode('LSattr_ldap_password_01','smd5');
} }
break; break;
case 'md5': case 'md5':
@ -114,7 +114,7 @@ class LSattr_ldap_password extends LSattr_ldap {
break; break;
case 'md5crypt': case 'md5crypt':
if( ! defined( 'CRYPT_MD5' ) || CRYPT_MD5 == 0 ) { if( ! defined( 'CRYPT_MD5' ) || CRYPT_MD5 == 0 ) {
LSerror :: addErrorCode(1023,'md5crypt'); LSerror :: addErrorCode('LSattr_ldap_password_01','md5crypt');
} }
else { else {
return '{CRYPT}'.crypt($this -> clearPassword,'$1$'.$this -> getSalt().'$'); return '{CRYPT}'.crypt($this -> clearPassword,'$1$'.$this -> getSalt().'$');
@ -154,7 +154,7 @@ class LSattr_ldap_password extends LSattr_ldap {
/** /**
* Error Codes * Error Codes
**/ **/
$GLOBALS['LSerror_code'][1023] = array( LSerror :: defineError('LSattr_ldap_password_01',
'msg' => _("LSattr_ldap_password : Encoding type %{type} is not supported. This password will be stocked in clear text.") _("LSattr_ldap_password : Encoding type %{type} is not supported. This password will be stocked in clear text.")
); );
?> ?>

View file

@ -686,32 +686,32 @@ class LSattribute {
/** /**
* Error Codes * Error Codes
**/ **/
$GLOBALS['LSerror_code']['LSattribute_01'] = array ( LSerror :: defineError('LSattribute_01',
'msg' => _("LSattribute : Attribute %{attr} : LDAP or HTML types unknow (LDAP = %{ldap} & HTML = %{html}).") _("LSattribute : Attribute %{attr} : LDAP or HTML types unknow (LDAP = %{ldap} & HTML = %{html}).")
); );
$GLOBALS['LSerror_code']['LSattribute_02'] = array ( LSerror :: defineError('LSattribute_02',
'msg' => _("LSattribute : The function %{func} to display the attribute %{attr} is unknow.") _("LSattribute : The function %{func} to display the attribute %{attr} is unknow.")
); );
$GLOBALS['LSerror_code']['LSattribute_03'] = array ( LSerror :: defineError('LSattribute_03',
'msg' => _("LSattribute : The rule %{rule} to validate the attribute %{attr} is unknow.") _("LSattribute : The rule %{rule} to validate the attribute %{attr} is unknow.")
); );
$GLOBALS['LSerror_code']['LSattribute_04'] = array ( LSerror :: defineError('LSattribute_04',
'msg' => _("LSattribute : Configuration data to verify the attribute %{attr} are incorrect.") _("LSattribute : Configuration data to verify the attribute %{attr} are incorrect.")
); );
$GLOBALS['LSerror_code']['LSattribute_05'] = array ( LSerror :: defineError('LSattribute_05',
'msg' => _("LSattribute : The function %{func} to save the attribute %{attr} is unknow.") _("LSattribute : The function %{func} to save the attribute %{attr} is unknow.")
); );
$GLOBALS['LSerror_code']['LSattribute_06'] = array ( LSerror :: defineError('LSattribute_06',
'msg' => _("LSattribute : The value of the attribute %{attr} can't be generated.") _("LSattribute : The value of the attribute %{attr} can't be generated.")
); );
$GLOBALS['LSerror_code']['LSattribute_07'] = array ( LSerror :: defineError('LSattribute_07',
'msg' => _("LSattribute : Generation of the attribute %{attr} failed.") _("LSattribute : Generation of the attribute %{attr} failed.")
); );
$GLOBALS['LSerror_code']['LSattribute_08'] = array ( LSerror :: defineError('LSattribute_08',
'msg' => _("LSattribute : Generation of the attribute %{attr} did not return a correct value.") _("LSattribute : Generation of the attribute %{attr} did not return a correct value.")
); );
$GLOBALS['LSerror_code']['LSattribute_09'] = array ( LSerror :: defineError('LSattribute_09',
'msg' => _("LSattribute : The attr_%{type} of the attribute %{name} is not yet defined.") _("LSattribute : The attr_%{type} of the attribute %{name} is not yet defined.")
); );
?> ?>

View file

@ -29,6 +29,26 @@
*/ */
class LSerror { class LSerror {
private static $_errorCodes = array(
'0' => array('msg' => "%{msg}")
);
/**
* Défini une erreur
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*
* @param[in] $code numeric Le code de l'erreur
* @param[in] $msg LSformat Le format paramètrable du message de l'erreur
*
* @retval void
*/
public static function defineError($code=-1,$msg='') {
self :: $_errorCodes[$code] = array(
'msg' => $msg
);
}
/** /**
* Ajoute une erreur * Ajoute une erreur
* *
@ -42,7 +62,7 @@ class LSerror {
* *
* @retval void * @retval void
*/ */
static function addErrorCode($code=-1,$msg='') { public static function addErrorCode($code=-1,$msg='') {
$_SESSION['LSerror'][] = array($code,$msg); $_SESSION['LSerror'][] = array($code,$msg);
} }
@ -55,7 +75,7 @@ class LSerror {
* *
* @retval void * @retval void
*/ */
static function display($return=False) { public static function display($return=False) {
$errors = self::getErrors(); $errors = self::getErrors();
if ($errors) { if ($errors) {
if ($return) { if ($return) {
@ -75,7 +95,7 @@ class LSerror {
* *
* @retval void * @retval void
*/ */
static function stop($code=-1,$msg='') { public static function stop($code=-1,$msg='') {
if(!empty($_SESSION['LSerror'])) { if(!empty($_SESSION['LSerror'])) {
print "<h1>"._('Errors')."</h1>\n"; print "<h1>"._('Errors')."</h1>\n";
print self::display(true); print self::display(true);
@ -91,7 +111,7 @@ class LSerror {
* *
* @retvat string Le texte des erreurs * @retvat string Le texte des erreurs
*/ */
static function getErrors() { public static function getErrors() {
if(!empty($_SESSION['LSerror'])) { if(!empty($_SESSION['LSerror'])) {
foreach ($_SESSION['LSerror'] as $error) { foreach ($_SESSION['LSerror'] as $error) {
$txt.=self::getError($error); $txt.=self::getError($error);
@ -109,8 +129,8 @@ class LSerror {
* *
* @retvat string Le texte des erreurs * @retvat string Le texte des erreurs
*/ */
static function getError($error) { private static function getError($error) {
return "(Code ".$error[0].") ".getFData($GLOBALS['LSerror_code'][$error[0]]['msg'],$error[1])."<br />\n"; return "(Code ".$error[0].") ".getFData(self :: $_errorCodes[$error[0]]['msg'],$error[1])."<br />\n";
} }
/** /**
@ -120,7 +140,7 @@ class LSerror {
* *
* @retvat boolean * @retvat boolean
*/ */
static function errorsDefined() { public static function errorsDefined() {
return !empty($_SESSION['LSerror']); return !empty($_SESSION['LSerror']);
} }
@ -131,7 +151,7 @@ class LSerror {
* *
* @retvat void * @retvat void
*/ */
static function resetError() { private static function resetError() {
unset ($_SESSION['LSerror']); unset ($_SESSION['LSerror']);
} }
} }
@ -139,11 +159,6 @@ class LSerror {
/* /*
* Error Codes * Error Codes
*/ */
$GLOBALS['LSerror_code']['-1'] = array ( LSerror :: defineError(-1,_("Unknow error!"));
'msg' => _("Unknow error!")
);
$GLOBALS['LSerror_code'][0] = array (
'msg' => "%{msg}"
);
?> ?>

View file

@ -522,28 +522,28 @@ class LSform {
/** /**
* Error Codes * Error Codes
*/ */
$GLOBALS['LSerror_code']['LSform_01'] = array( LSerror :: defineError('LSform_01',
'msg' => _("LSform : Error during the recovery of the values of the form.") _("LSform : Error during the recovery of the values of the form.")
); );
$GLOBALS['LSerror_code']['LSform_02'] = array( LSerror :: defineError('LSform_02',
'msg' => _("LSform : Error durring the recovery of the value of the field '%{element}'.") _("LSform : Error durring the recovery of the value of the field '%{element}'.")
); );
// No longer used // No longer used
/*$GLOBALS['LSerror_code'][203] = array( /*LSerror :: defineError(203,
'msg' => _("LSform : Data of the field %{element} are not validate.") _("LSform : Data of the field %{element} are not validate.")
);*/ );*/
$GLOBALS['LSerror_code']['LSform_04'] = array( LSerror :: defineError('LSform_04',
'msg' => _("LSform : The field %{element} doesn't exist.") _("LSform : The field %{element} doesn't exist.")
); );
$GLOBALS['LSerror_code']['LSform_05'] = array( LSerror :: defineError('LSform_05',
'msg' => _("LSfom : Field type unknow (%{type}).") _("LSfom : Field type unknow (%{type}).")
); );
$GLOBALS['LSerror_code']['LSform_06'] = array( LSerror :: defineError('LSform_06',
'msg' => _("LSform : Error during the creation of the element '%{element}'.") _("LSform : Error during the creation of the element '%{element}'.")
); );
// No longer used // No longer used
/*$GLOBALS['LSerror_code'][207] = array( /*LSerror :: defineError(207,
'msg' => _("LSform : No value has been entered into the field '%{element}'.") _("LSform : No value has been entered into the field '%{element}'.")
);*/ );*/
?> ?>

View file

@ -53,7 +53,7 @@ class LSformRule {
/** /**
* Error Codes * Error Codes
**/ **/
$GLOBALS['LSerror_code']['LSformRule_01'] = array ( LSerror :: defineError('LSformRule_01',
'msg' => _("LSformRule_%{type} : Parameter %{param} is not found.") _("LSformRule_%{type} : Parameter %{param} is not found.")
); );
?> ?>

View file

@ -61,8 +61,8 @@ class LSformRule_regex extends LSformRule {
/* /*
* Error Codes * Error Codes
*/ */
$GLOBALS['LSerror_code']['LSformRule_regex_01'] = array( LSerror :: defineError('LSformRule_regex_01',
'msg' => _("LSformRule_regex : Regex has not been configured to validate data.") _("LSformRule_regex : Regex has not been configured to validate data.")
); );
?> ?>

View file

@ -29,26 +29,22 @@
*/ */
class LSldap { class LSldap {
var $config; private static $config;
var $cnx = NULL; private static $cnx = NULL;
/** /**
* Constructeur * Défini la configuration
* *
* Cette methode définis la configuration de l'accès à l'annuaire * Cette methode définis la configuration de l'accès à l'annuaire
* et établie la connexion.
* *
* @author Benjamin Renard <brenard@easter-eggs.com> * @author Benjamin Renard <brenard@easter-eggs.com>
* *
* @param[in] $config array Tableau de configuration au formar Net_LDAP2 * @param[in] $config array Tableau de configuration au formar Net_LDAP2
* *
* @retval void * @retval void
*
* @see Net_LDAP2::connect()
*/ */
function LSldap ($config) { function setConfig ($config) {
$this -> config = $config; self :: $config = $config;
$this -> connect();
} }
/** /**
@ -57,14 +53,19 @@ class LSldap {
* Cette methode établie la connexion à l'annuaire Ldap * Cette methode établie la connexion à l'annuaire Ldap
* *
* @author Benjamin Renard <brenard@easter-eggs.com> * @author Benjamin Renard <brenard@easter-eggs.com>
*
* @param[in] $config array Tableau de configuration au formar Net_LDAP2
* *
* @retval boolean true si la connection est établie, false sinon * @retval boolean true si la connection est établie, false sinon
*/ */
function connect() { public static function connect($config = null) {
$this -> cnx = Net_LDAP2::connect($this -> config); if ($config) {
if (Net_LDAP2::isError($this -> cnx)) { self :: setConfig($config);
LSerror :: addErrorCode('LSldap_01',$this -> cnx -> getMessage()); }
$this -> cnx = NULL; self :: $cnx = Net_LDAP2::connect(self :: $config);
if (Net_LDAP2::isError(self :: $cnx)) {
LSerror :: addErrorCode('LSldap_01',self :: $cnx -> getMessage());
self :: $cnx = NULL;
return; return;
} }
return true; return true;
@ -79,8 +80,8 @@ class LSldap {
* *
* @retval void * @retval void
*/ */
function close() { public static function close() {
$this -> cnx -> done(); self :: $cnx -> done();
} }
/** /**
@ -102,8 +103,8 @@ class LSldap {
* - ['attrs'] : tableau associatif contenant les attributs (clé) * - ['attrs'] : tableau associatif contenant les attributs (clé)
* et leur valeur (valeur). * et leur valeur (valeur).
*/ */
function search ($filter,$basedn=NULL,$params = array()) { public static function search ($filter,$basedn=NULL,$params = array()) {
$ret = $this -> cnx -> search($basedn,$filter,$params); $ret = self :: $cnx -> search($basedn,$filter,$params);
if (Net_LDAP2::isError($ret)) { if (Net_LDAP2::isError($ret)) {
LSerror :: addErrorCode('LSldap_02',$ret -> getMessage()); LSerror :: addErrorCode('LSldap_02',$ret -> getMessage());
return; return;
@ -131,10 +132,10 @@ class LSldap {
* *
* @retval numeric Le nombre d'entré trouvées * @retval numeric Le nombre d'entré trouvées
*/ */
function getNumberResult ($filter,$basedn=NULL,$params = array() ) { public static function getNumberResult ($filter,$basedn=NULL,$params = array() ) {
if (empty($filter)) if (empty($filter))
$filter=NULL; $filter=NULL;
$ret = $this -> cnx -> search($basedn,$filter,$params); $ret = self :: $cnx -> search($basedn,$filter,$params);
if (Net_LDAP2::isError($ret)) { if (Net_LDAP2::isError($ret)) {
LSerror :: addErrorCode('LSldap_02',$ret -> getMessage()); LSerror :: addErrorCode('LSldap_02',$ret -> getMessage());
return; return;
@ -154,7 +155,7 @@ class LSldap {
* *
* @retval array Tableau associatif des valeurs des attributs avec en clef, le nom de l'attribut. * @retval array Tableau associatif des valeurs des attributs avec en clef, le nom de l'attribut.
*/ */
function getAttrs($dn) { public static function getAttrs($dn) {
$infos = ldap_explode_dn($dn,0); $infos = ldap_explode_dn($dn,0);
if((!$infos)||($infos['count']==0)) if((!$infos)||($infos['count']==0))
return; return;
@ -163,7 +164,7 @@ class LSldap {
$sep=($basedn=='')?'':','; $sep=($basedn=='')?'':',';
$basedn.=$sep.$infos[$i]; $basedn.=$sep.$infos[$i];
} }
$return=$this -> search($infos[0],$basedn); $return=self :: search($infos[0],$basedn);
return $return[0]['attrs']; return $return[0]['attrs'];
} }
@ -182,12 +183,12 @@ class LSldap {
* 'new' => true * 'new' => true
* ) * )
*/ */
function getEntry($object_type,$dn) { public static function getEntry($object_type,$dn) {
if(isset($GLOBALS['LSobjects'][$object_type])){ if(isset($GLOBALS['LSobjects'][$object_type])){
$obj_conf=$GLOBALS['LSobjects'][$object_type]; $obj_conf=$GLOBALS['LSobjects'][$object_type];
$entry = $this -> cnx -> getEntry($dn); $entry = self :: $cnx -> getEntry($dn);
if (Net_LDAP2::isError($entry)) { if (Net_LDAP2::isError($entry)) {
//$newentry = new Net_LDAP2_Entry(&$this -> cnx); //$newentry = new Net_LDAP2_Entry(&self :: $cnx);
//$newentry -> dn($dn); //$newentry -> dn($dn);
//$newentry -> add(array('objectclass' => $obj_conf['objectclass'])); //$newentry -> add(array('objectclass' => $obj_conf['objectclass']));
//foreach($obj_conf['attrs'] as $attr_name => $attr_conf) { //foreach($obj_conf['attrs'] as $attr_name => $attr_conf) {
@ -200,7 +201,7 @@ class LSldap {
} }
} }
$newentry = $this -> getNewEntry($dn,$obj_conf['objectclass'],$attributes); $newentry = self :: getNewEntry($dn,$obj_conf['objectclass'],$attributes);
if (!$newentry) { if (!$newentry) {
return; return;
@ -226,13 +227,13 @@ class LSldap {
* *
* @retval mixed Le nouvelle objet en cas de succès, false sinon * @retval mixed Le nouvelle objet en cas de succès, false sinon
*/ */
function getNewEntry($dn,$objectClass,$attrs,$add=false) { public static function getNewEntry($dn,$objectClass,$attrs,$add=false) {
$newentry = Net_LDAP2_Entry::createFresh($dn,array_merge(array('objectclass' =>$objectClass),(array)$attrs)); $newentry = Net_LDAP2_Entry::createFresh($dn,array_merge(array('objectclass' =>$objectClass),(array)$attrs));
if(Net_LDAP2::isError($newentry)) { if(Net_LDAP2::isError($newentry)) {
return false; return false;
} }
if($add) { if($add) {
if(!$this -> cnx -> add($newentry)) { if(!self :: $cnx -> add($newentry)) {
return; return;
} }
} }
@ -252,10 +253,10 @@ class LSldap {
* *
* @retval boolean true si l'objet a bien été mis à jour, false sinon * @retval boolean true si l'objet a bien été mis à jour, false sinon
*/ */
function update($object_type,$dn,$change) { public static function update($object_type,$dn,$change) {
LSdebug($change); LSdebug($change);
$dropAttr=array(); $dropAttr=array();
$entry=$this -> getEntry($object_type,$dn); $entry=self :: getEntry($object_type,$dn);
if (is_array($entry)) { if (is_array($entry)) {
$new = $entry['new']; $new = $entry['new'];
$entry = $entry['entry']; $entry = $entry['entry'];
@ -291,7 +292,7 @@ class LSldap {
if ($new) { if ($new) {
LSdebug('LSldap :: add()'); LSdebug('LSldap :: add()');
$ret = $this -> cnx -> add($entry); $ret = self :: $cnx -> add($entry);
} }
else { else {
LSdebug('LSldap :: update()'); LSdebug('LSldap :: update()');
@ -339,8 +340,8 @@ class LSldap {
* *
* @retval boolean true si la connection à réussi, false sinon * @retval boolean true si la connection à réussi, false sinon
*/ */
function checkBind($dn,$pwd) { public static function checkBind($dn,$pwd) {
$config = $this -> config; $config = self :: $config;
$config['binddn'] = $dn; $config['binddn'] = $dn;
$config['bindpw'] = $pwd; $config['bindpw'] = $pwd;
$cnx = Net_LDAP2::connect($config); $cnx = Net_LDAP2::connect($config);
@ -355,8 +356,8 @@ class LSldap {
* *
* @retval boolean True si le serveur est connecté, false sinon. * @retval boolean True si le serveur est connecté, false sinon.
*/ */
function isConnected() { public static function isConnected() {
return ($this -> cnx == NULL)?false:true; return (self :: $cnx == NULL)?false:true;
} }
/** /**
@ -366,8 +367,8 @@ class LSldap {
* *
* @retval boolean True si l'objet à été supprimé, false sinon * @retval boolean True si l'objet à été supprimé, false sinon
*/ */
function remove($dn) { public static function remove($dn) {
$ret = $this -> cnx -> delete($dn,array('recursive' => true)); $ret = self :: $cnx -> delete($dn,array('recursive' => true));
if (Net_LDAP2::isError($ret)) { if (Net_LDAP2::isError($ret)) {
LSerror :: addErrorCode(0,'NetLdap-Error : '.$ret->getMessage()); LSerror :: addErrorCode(0,'NetLdap-Error : '.$ret->getMessage());
return; return;
@ -383,8 +384,8 @@ class LSldap {
* *
* @retval boolean True si l'objet a été déplacé, false sinon * @retval boolean True si l'objet a été déplacé, false sinon
*/ */
function move($old,$new) { public static function move($old,$new) {
$ret = $this -> cnx -> move($old,$new); $ret = self :: $cnx -> move($old,$new);
if (Net_LDAP2::isError($ret)) { if (Net_LDAP2::isError($ret)) {
LSerror :: addErrorCode('LSldap_07'); LSerror :: addErrorCode('LSldap_07');
LSerror :: addErrorCode(0,'NetLdap-Error : '.$ret->getMessage()); LSerror :: addErrorCode(0,'NetLdap-Error : '.$ret->getMessage());
@ -397,25 +398,25 @@ class LSldap {
/* /*
* Error Codes * Error Codes
*/ */
$GLOBALS['LSerror_code']['LSldap_01'] = array ( LSerror :: defineError('LSldap_01',
'msg' => _("LSldap : Error during the LDAP server connection (%{msg}).") _("LSldap : Error during the LDAP server connection (%{msg}).")
); );
$GLOBALS['LSerror_code']['LSldap_02'] = array ( LSerror :: defineError('LSldap_02',
'msg' => _("LSldap : Error during the LDAP search (%{msg}).") _("LSldap : Error during the LDAP search (%{msg}).")
); );
$GLOBALS['LSerror_code']['LSldap_03'] = array ( LSerror :: defineError('LSldap_03',
'msg' => _("LSldap : Object type unkown.") _("LSldap : Object type unkown.")
); );
$GLOBALS['LSerror_code']['LSldap_04'] = array ( LSerror :: defineError('LSldap_04',
'msg' => _("LSldap : Error during fecthing the LDAP entry.") _("LSldap : Error during fecthing the LDAP entry.")
); );
$GLOBALS['LSerror_code']['LSldap_05'] = array ( LSerror :: defineError('LSldap_05',
'msg' => _("LSldap : Error during changing the LDAP entry (DN : %{dn}).") _("LSldap : Error during changing the LDAP entry (DN : %{dn}).")
); );
$GLOBALS['LSerror_code']['LSldap_06'] = array ( LSerror :: defineError('LSldap_06',
'msg' => _("LSldap : Error during deleting the empty attributes.") _("LSldap : Error during deleting the empty attributes.")
); );
$GLOBALS['LSerror_code']['LSldap_07'] = array ( LSerror :: defineError('LSldap_07',
'msg' => _("LSldap : Error during changing the DN of the object.") _("LSldap : Error during changing the DN of the object.")
); );
?> ?>

View file

@ -90,7 +90,7 @@ class LSldapObject {
*/ */
function loadData($dn) { function loadData($dn) {
$this -> dn = $dn; $this -> dn = $dn;
$data = $GLOBALS['LSldap'] -> getAttrs($dn); $data = LSldap :: getAttrs($dn);
if(!empty($data)) { if(!empty($data)) {
foreach($this -> attrs as $attr_name => $attr) { foreach($this -> attrs as $attr_name => $attr) {
if(!$this -> attrs[$attr_name] -> loadData($data[$attr_name])) if(!$this -> attrs[$attr_name] -> loadData($data[$attr_name]))
@ -109,7 +109,7 @@ class LSldapObject {
* @retval boolean true si la rechargement a réussi, false sinon. * @retval boolean true si la rechargement a réussi, false sinon.
*/ */
function reloadData() { function reloadData() {
$data = $GLOBALS['LSldap'] -> getAttrs($this -> dn); $data = LSldap :: getAttrs($this -> dn);
foreach($this -> attrs as $attr_name => $attr) { foreach($this -> attrs as $attr_name => $attr) {
if(!$this -> attrs[$attr_name] -> reloadData($data[$attr_name])) if(!$this -> attrs[$attr_name] -> reloadData($data[$attr_name]))
return; return;
@ -453,7 +453,7 @@ class LSldapObject {
$sfilter=$sfilter_user; $sfilter=$sfilter_user;
} }
$sbasedn=(isset($test['basedn']))?getFData($test['basedn'],$this,'getValue'):NULL; $sbasedn=(isset($test['basedn']))?getFData($test['basedn'],$this,'getValue'):NULL;
$ret=$GLOBALS['LSldap'] -> getNumberResult ($sfilter,$sbasedn,$sparams); $ret=LSldap :: getNumberResult ($sfilter,$sbasedn,$sparams);
if($test['result']==0) { if($test['result']==0) {
if($ret!=0) { if($ret!=0) {
$LSform -> setElementError($attr,$msg_error); $LSform -> setElementError($attr,$msg_error);
@ -538,7 +538,7 @@ class LSldapObject {
$this -> dn = false; $this -> dn = false;
$newDn = $this -> getDn(); $newDn = $this -> getDn();
if ($newDn) { if ($newDn) {
if (!$GLOBALS['LSldap'] -> move($oldDn,$newDn)) { if (!LSldap :: move($oldDn,$newDn)) {
return; return;
} }
$this -> dn = $newDn; $this -> dn = $newDn;
@ -561,7 +561,7 @@ class LSldapObject {
if($dn) { if($dn) {
$this -> dn=$dn; $this -> dn=$dn;
LSdebug($submitData); LSdebug($submitData);
if (!$GLOBALS['LSldap'] -> update($this -> getType(),$dn, $submitData)) { if (!LSldap :: update($this -> getType(),$dn, $submitData)) {
return; return;
} }
if ($new) { if ($new) {
@ -758,7 +758,7 @@ class LSldapObject {
} }
// Execution de la recherche // Execution de la recherche
$ret=$GLOBALS['LSldap'] -> search ($sfilter_for,$sbasedn,$sparams); $ret=LSldap :: search ($sfilter_for,$sbasedn,$sparams);
// Si il y un retour // Si il y un retour
if(isset($ret[0])) { if(isset($ret[0])) {
@ -815,7 +815,7 @@ class LSldapObject {
} }
// Lancement de la recherche // Lancement de la recherche
$ret=$GLOBALS['LSldap'] -> search ($sfilter,$sbasedn,$sparams); $ret=LSldap :: search ($sfilter,$sbasedn,$sparams);
//Si filtre multiple => on recupère une liste d'attributs //Si filtre multiple => on recupère une liste d'attributs
if(isset($filter[$i]['attr'])) { if(isset($filter[$i]['attr'])) {
@ -1060,7 +1060,7 @@ class LSldapObject {
*/ */
function remove() { function remove() {
if ($this -> beforeDelete()) { if ($this -> beforeDelete()) {
if ($GLOBALS['LSldap'] -> remove($this -> getDn())) { if (LSldap :: remove($this -> getDn())) {
if ($this -> afterDelete()) { if ($this -> afterDelete()) {
return true; return true;
} }
@ -1313,7 +1313,7 @@ class LSldapObject {
if (LSsession :: loadLSobject($type)) { if (LSsession :: loadLSobject($type)) {
if (isset($GLOBALS['LSobjects'][$type]['container_auto_create'])&&isset($GLOBALS['LSobjects'][$type]['container_dn'])) { if (isset($GLOBALS['LSobjects'][$type]['container_auto_create'])&&isset($GLOBALS['LSobjects'][$type]['container_dn'])) {
$dn = $GLOBALS['LSobjects'][$type]['container_dn'].','.$this -> getDn(); $dn = $GLOBALS['LSobjects'][$type]['container_dn'].','.$this -> getDn();
if(!$GLOBALS['LSldap'] -> getNewEntry($dn,$GLOBALS['LSobjects'][$type]['container_auto_create']['objectclass'],$GLOBALS['LSobjects'][$type]['container_auto_create']['attrs'],true)) { if(!LSldap :: getNewEntry($dn,$GLOBALS['LSobjects'][$type]['container_auto_create']['objectclass'],$GLOBALS['LSobjects'][$type]['container_auto_create']['attrs'],true)) {
LSdebug("Impossible de créer l'entrée fille : ".print_r( LSdebug("Impossible de créer l'entrée fille : ".print_r(
array( array(
'dn' => $dn, 'dn' => $dn,
@ -1463,7 +1463,7 @@ class LSldapObject {
} }
} }
if (isset($updateData)) { if (isset($updateData)) {
return $GLOBALS['LSldap'] -> update($this -> getType(),$this -> getDn(), array($attr => $updateData)); return LSldap :: update($this -> getType(),$this -> getDn(), array($attr => $updateData));
} }
return true; return true;
} }
@ -1508,7 +1508,7 @@ class LSldapObject {
$updateData[]=$value; $updateData[]=$value;
} }
} }
return $GLOBALS['LSldap'] -> update($this -> getType(),$this -> getDn(), array($attr => $updateData)); return LSldap :: update($this -> getType(),$this -> getDn(), array($attr => $updateData));
} }
} }
} }
@ -1556,7 +1556,7 @@ class LSldapObject {
$updateData[] = $val; $updateData[] = $val;
} }
} }
return $GLOBALS['LSldap'] -> update($this -> getType(),$this -> getDn(), array($attr => $updateData)); return LSldap :: update($this -> getType(),$this -> getDn(), array($attr => $updateData));
} }
} }
} }
@ -1670,93 +1670,93 @@ class LSldapObject {
/** /**
* Error Codes * Error Codes
**/ **/
$GLOBALS['LSerror_code']['LSldapObject_01'] = array ( LSerror :: defineError('LSldapObject_01',
'msg' => _("LSldapObject : Object type unknow.") _("LSldapObject : Object type unknow.")
); );
$GLOBALS['LSerror_code']['LSldapObject_02'] = array ( LSerror :: defineError('LSldapObject_02',
'msg' => _("LSldapObject : Update form is not defined for the object %{obj}.") _("LSldapObject : Update form is not defined for the object %{obj}.")
); );
$GLOBALS['LSerror_code']['LSldapObject_03'] = array ( LSerror :: defineError('LSldapObject_03',
'msg' => _("LSldapObject : No form exist for the object %{obj}.") _("LSldapObject : No form exist for the object %{obj}.")
); );
$GLOBALS['LSerror_code']['LSldapObject_04'] = array ( LSerror :: defineError('LSldapObject_04',
'msg' => _("LSldapObject : The function %{func} to validate the attribute %{attr} the object %{obj} is unknow.") _("LSldapObject : The function %{func} to validate the attribute %{attr} the object %{obj} is unknow.")
); );
$GLOBALS['LSerror_code']['LSldapObject_05'] = array ( LSerror :: defineError('LSldapObject_05',
'msg' => _("LSldapObject : Configuration data are missing to validate the attribute %{attr} of the object %{obj}.") _("LSldapObject : Configuration data are missing to validate the attribute %{attr} of the object %{obj}.")
); );
/* No longer used /* No longer used
$GLOBALS['LSerror_code'][26] = array ( LSerror :: defineError(26,
'msg' => _("LSldapObject : Configuration error : The object %{obj} doesn't had attribute %{attr}.") _("LSldapObject : Configuration error : The object %{obj} doesn't had attribute %{attr}.")
); );
*/ */
$GLOBALS['LSerror_code']['LSldapObject_07'] = array ( LSerror :: defineError('LSldapObject_07',
'msg' => _("LSldapObject : The function %{func} to be executed before changing the object doesn't exist.") _("LSldapObject : The function %{func} to be executed before changing the object doesn't exist.")
); );
$GLOBALS['LSerror_code']['LSldapObject_08'] = array ( LSerror :: defineError('LSldapObject_08',
'msg' => _("LSldapObject : The execution of the function %{func} to be executed before changing the object failed.") _("LSldapObject : The execution of the function %{func} to be executed before changing the object failed.")
); );
$GLOBALS['LSerror_code']['LSldapObject_09'] = array ( LSerror :: defineError('LSldapObject_09',
'msg' => _("LSldapObject : The function %{func} to be executed after changing the object doesn't exist.") _("LSldapObject : The function %{func} to be executed after changing the object doesn't exist.")
); );
$GLOBALS['LSerror_code']['LSldapObject_10'] = array ( LSerror :: defineError('LSldapObject_10',
'msg' => _("LSldapObject : The execution of the function %{func} to be executed after changing the object failed.") _("LSldapObject : The execution of the function %{func} to be executed after changing the object failed.")
); );
$GLOBALS['LSerror_code']['LSldapObject_11'] = array ( LSerror :: defineError('LSldapObject_11',
'msg' => _("LSldapObject : Some configuration data of the object type %{obj} are missing to generate the DN of the new object.") _("LSldapObject : Some configuration data of the object type %{obj} are missing to generate the DN of the new object.")
); );
$GLOBALS['LSerror_code']['LSldapObject_12'] = array ( LSerror :: defineError('LSldapObject_12',
'msg' => _("LSldapObject : The attibute %{attr} of the object is not yet defined. Impossible to generate DN.") _("LSldapObject : The attibute %{attr} of the object is not yet defined. Impossible to generate DN.")
); );
$GLOBALS['LSerror_code']['LSldapObject_13'] = array ( LSerror :: defineError('LSldapObject_13',
'msg' => _("LSldapObject : Without DN, the object could not be changed.") _("LSldapObject : Without DN, the object could not be changed.")
); );
$GLOBALS['LSerror_code']['LSldapObject_14'] = array ( LSerror :: defineError('LSldapObject_14',
'msg' => _("LSldapObject : The attribute %{attr_depend} depending on the attribute %{attr} doesn't exist.") _("LSldapObject : The attribute %{attr_depend} depending on the attribute %{attr} doesn't exist.")
); );
$GLOBALS['LSerror_code']['LSldapObject_15'] = array ( LSerror :: defineError('LSldapObject_15',
'msg' => _("LSldapObject : Error during deleting the object %{objectname}.") _("LSldapObject : Error during deleting the object %{objectname}.")
); );
$GLOBALS['LSerror_code']['LSldapObject_16'] = array ( LSerror :: defineError('LSldapObject_16',
'msg' => _("LSldapObject : Error during actions to be executed before renaming the objet.") _("LSldapObject : Error during actions to be executed before renaming the objet.")
); );
$GLOBALS['LSerror_code']['LSldapObject_17'] = array ( LSerror :: defineError('LSldapObject_17',
'msg' => _("LSldapObject : Error during actions to be executed after renaming the objet.") _("LSldapObject : Error during actions to be executed after renaming the objet.")
); );
$GLOBALS['LSerror_code']['LSldapObject_18'] = array ( LSerror :: defineError('LSldapObject_18',
'msg' => _("LSldapObject : Error during actions to be executed before deleting the objet.") _("LSldapObject : Error during actions to be executed before deleting the objet.")
); );
$GLOBALS['LSerror_code']['LSldapObject_19'] = array ( LSerror :: defineError('LSldapObject_19',
'msg' => _("LSldapObject : Error during actions to be executed after deleting the objet.") _("LSldapObject : Error during actions to be executed after deleting the objet.")
); );
// 20 : not used // 20 : not used
$GLOBALS['LSerror_code']['LSldapObject_21'] = array ( LSerror :: defineError('LSldapObject_21',
'msg' => _("LSldapObject : Error during the actions to be executed after creating the object. It was created anyway.") _("LSldapObject : Error during the actions to be executed after creating the object. It was created anyway.")
); );
$GLOBALS['LSerror_code']['LSldapObject_22'] = array ( LSerror :: defineError('LSldapObject_22',
'msg' => _("LSldapObject : The function %{func} to be generated before creating the object doesn't exist.") _("LSldapObject : The function %{func} to be generated before creating the object doesn't exist.")
); );
$GLOBALS['LSerror_code']['LSldapObject_23'] = array ( LSerror :: defineError('LSldapObject_23',
'msg' => _("LSldapObject : Error during the execution of the function %{func} to be generated after deleting the object.") _("LSldapObject : Error during the execution of the function %{func} to be generated after deleting the object.")
); );
$GLOBALS['LSerror_code']['LSldapObject_24'] = array ( LSerror :: defineError('LSldapObject_24',
'msg' => _("LSldapObject : The function %{func} to be generated after deleting the object doesn't exist.") _("LSldapObject : The function %{func} to be generated after deleting the object doesn't exist.")
); );
$GLOBALS['LSerror_code']['LSldapObject_25'] = array ( LSerror :: defineError('LSldapObject_25',
'msg' => _("LSldapObject : Error during the execution of the function %{func} to be generated after creating the object.") _("LSldapObject : Error during the execution of the function %{func} to be generated after creating the object.")
); );
/* Not yet used /* Not yet used
$GLOBALS['LSerror_code'][306] = array ( LSerror :: defineError(306,
'msg' => _("LSldapObject : The function %{func} to be executed after changing the attribute %{attr} is unknow.") _("LSldapObject : The function %{func} to be executed after changing the attribute %{attr} is unknow.")
); );
$GLOBALS['LSerror_code'][307] = array ( LSerror :: defineError(307,
'msg' => _("LSldapObject : The execution of the function %{func} to be executed after changing the attribute %{attr} failed.") _("LSldapObject : The execution of the function %{func} to be executed after changing the attribute %{attr} failed.")
); );
$GLOBALS['LSerror_code'][308] = array ( LSerror :: defineError(308,
'msg' => _("LSldapObject : The function %{func} to be executed before changing the attribute %{attr} is unknow.") _("LSldapObject : The function %{func} to be executed before changing the attribute %{attr} is unknow.")
); );
$GLOBALS['LSerror_code'][309] = array ( LSerror :: defineError(309,
'msg' => _("LSldapObject : The execution of the function %{func} to be executed before changing the attribute %{attr} failed.") _("LSldapObject : The execution of the function %{func} to be executed before changing the attribute %{attr} failed.")
); );
*/ */
?> ?>

View file

@ -123,7 +123,7 @@ class LSsession {
return true; return true;
} }
else { else {
die($GLOBALS['LSerror_code']['LSsession_08']['msg']); die("ERROR : Can't load configuration file.");
return; return;
} }
return true; return true;
@ -151,6 +151,7 @@ class LSsession {
if(!self :: loadLSclass('LSerror')) { if(!self :: loadLSclass('LSerror')) {
return; return;
} }
self :: defineLSerrors();
return true; return true;
} }
@ -674,8 +675,8 @@ class LSsession {
if (!self :: loadLSclass('LSldap')) { if (!self :: loadLSclass('LSldap')) {
return; return;
} }
$GLOBALS['LSldap'] = @new LSldap(self :: $ldapServer['ldap_config']); LSldap :: connect(self :: $ldapServer['ldap_config']);
if ($GLOBALS['LSldap'] -> isConnected()) { if (LSldap :: isConnected()) {
return true; return true;
} }
else { else {
@ -825,7 +826,7 @@ class LSsession {
* @retval boolean True si l'authentification à réussi, false sinon. * @retval boolean True si l'authentification à réussi, false sinon.
*/ */
public static function checkUserPwd($object,$pwd) { public static function checkUserPwd($object,$pwd) {
return $GLOBALS['LSldap'] -> checkBind($object -> getValue('dn'),$pwd); return LSldap :: checkBind($object -> getValue('dn'),$pwd);
} }
/** /**
@ -1779,81 +1780,89 @@ class LSsession {
} }
} }
} }
/**
* Défini les codes erreur relative à la classe LSsession
*
* @retval void
*/
private static function defineLSerrors() {
/*
* Error Codes
*/
LSerror :: defineError('LSsession_01',
_("LSsession : The constant %{const} is not defined.")
);
LSerror :: defineError('LSsession_02',
_("LSsession : The %{addon} support is uncertain. Verify system compatibility and the add-on configuration.")
);
LSerror :: defineError('LSsession_03',
_("LSsession : LDAP server's configuration data are invalid. Impossible d'établir une connexion.")
);
LSerror :: defineError('LSsession_04',
_("LSsession : Failed to load LSobject type %{type} : unknon type.")
);
// no longer used
/*LSerror :: defineError(1005,
_("LSsession : Object type use for authentication is unknow (%{type}).")
);*/
LSerror :: defineError('LSsession_06',
_("LSsession : Login or password incorrect.")
);
LSerror :: defineError('LSsession_07',
_("LSsession : Impossible to identify you : Duplication of identities.")
);
LSerror :: defineError('LSsession_08',
_("LSsession : Can't load Smarty template engine.")
);
LSerror :: defineError('LSsession_09',
_("LSsession : Can't connect to LDAP server.")
);
LSerror :: defineError('LSsession_10',
_("LSsession : Impossible to load authentification objects's class.")
);
LSerror :: defineError('LSsession_11',
_("LSsession : Your are not authorized to do this action.")
);
LSerror :: defineError('LSsession_12',
_("LSsession : Some informations are missing to display this page.")
);
// 13 -> 16 : not yet used
LSerror :: defineError('LSsession_17',
_("LSsession : Error during creation of list of levels. Contact administrators. (Code : %{code})")
);
LSerror :: defineError('LSsession_18',
_("LSsession : The password recovery is disabled for this LDAP server.")
);
LSerror :: defineError('LSsession_19',
_("LSsession : Some informations are missing to recover your password. Contact administrators.")
);
LSerror :: defineError('LSsession_20',
_("LSsession : Error during password recovery. Contact administrators.(Step : %{step})")
);
// 21 : not yet used
LSerror :: defineError('LSsession_22',
_("LSsession : problem during initialisation.")
);
// LSrelations
LSerror :: defineError('LSrelations_01',
_("LSrelations : The listing function for the relation %{relation} is unknow.")
);
LSerror :: defineError('LSrelations_02',
_("LSrelations : The update function of the relation %{relation} is unknow.")
);
LSerror :: defineError('LSrelations_03',
_("LSrelations : Error during relation update of the relation %{relation}.")
);
LSerror :: defineError('LSrelations_04',
_("LSrelations : Object type %{LSobject} unknow (Relation : %{relation}).")
);
LSerror :: defineError('LSrelations_05',
_("LSrelation : Some parameters are missing in the invocation of the methods of handling relations standard (Methode : %{meth}).")
);
}
} }
/*
* Error Codes
*/
$GLOBALS['LSerror_code']['LSsession_01'] = array (
'msg' => _("LSsession : The constant %{const} is not defined.")
);
$GLOBALS['LSerror_code']['LSsession_02'] = array (
'msg' => _("LSsession : The %{addon} support is uncertain. Verify system compatibility and the add-on configuration.")
);
$GLOBALS['LSerror_code']['LSsession_03'] = array (
'msg' => _("LSsession : LDAP server's configuration data are invalid. Impossible d'établir une connexion.")
);
$GLOBALS['LSerror_code']['LSsession_04'] = array (
'msg' => _("LSsession : Failed to load LSobject type %{type} : unknon type.")
);
// no longer used
/*$GLOBALS['LSerror_code'][1005] = array (
'msg' => _("LSsession : Object type use for authentication is unknow (%{type}).")
);*/
$GLOBALS['LSerror_code']['LSsession_06'] = array (
'msg' => _("LSsession : Login or password incorrect.")
);
$GLOBALS['LSerror_code']['LSsession_07'] = array (
'msg' => _("LSsession : Impossible to identify you : Duplication of identities.")
);
$GLOBALS['LSerror_code']['LSsession_08'] = array (
'msg' => _("LSsession : Can't load Smarty template engine.")
);
$GLOBALS['LSerror_code']['LSsession_09'] = array (
'msg' => _("LSsession : Can't connect to LDAP server.")
);
$GLOBALS['LSerror_code']['LSsession_10'] = array (
'msg' => _("LSsession : Impossible to load authentification objects's class.")
);
$GLOBALS['LSerror_code']['LSsession_11'] = array (
'msg' => _("LSsession : Your are not authorized to do this action.")
);
$GLOBALS['LSerror_code']['LSsession_12'] = array (
'msg' => _("LSsession : Some informations are missing to display this page.")
);
// 13 -> 16 : not yet used
$GLOBALS['LSerror_code']['LSsession_17'] = array (
'msg' => _("LSsession : Error during creation of list of levels. Contact administrators. (Code : %{code})")
);
$GLOBALS['LSerror_code']['LSsession_18'] = array (
'msg' => _("LSsession : The password recovery is disabled for this LDAP server.")
);
$GLOBALS['LSerror_code']['LSsession_19'] = array (
'msg' => _("LSsession : Some informations are missing to recover your password. Contact administrators.")
);
$GLOBALS['LSerror_code']['LSsession_20'] = array (
'msg' => _("LSsession : Error during password recovery. Contact administrators.(Step : %{step})")
);
// 21 : not yet used
$GLOBALS['LSerror_code']['LSsession_22'] = array(
'msg' => _("LSsession : problem during initialisation.")
);
// LSrelations
$GLOBALS['LSerror_code']['LSrelations_01'] = array (
'msg' => _("LSrelations : The listing function for the relation %{relation} is unknow.")
);
$GLOBALS['LSerror_code']['LSrelations_02'] = array (
'msg' => _("LSrelations : The update function of the relation %{relation} is unknow.")
);
$GLOBALS['LSerror_code']['LSrelations_03'] = array (
'msg' => _("LSrelations : Error during relation update of the relation %{relation}.")
);
$GLOBALS['LSerror_code']['LSrelations_04'] = array (
'msg' => _("LSrelations : Object type %{LSobject} unknow (Relation : %{relation}).")
);
$GLOBALS['LSerror_code']['LSrelations_05'] = array (
'msg' => _("LSrelation : Some parameters are missing in the invocation of the methods of handling relations standard (Methode : %{meth}).")
);
?> ?>

View file

@ -136,7 +136,7 @@ function getFData($format,$data,$meth=NULL) {
$format[$i]=ereg_replace($ch[0],$value,$format[$i]); $format[$i]=ereg_replace($ch[0],$value,$format[$i]);
} }
else { else {
LSerror :: addErrorCode('fct_getFData_01',array('meth' => $meth,'obj' => get_class($data))); LSerror :: addErrorCode(0,getFData(_("Function 'getFData' : The method %{meth} of the object %{obj} doesn't exist."),array('meth' => $meth,'obj' => get_class($data))));
break; break;
} }
} }
@ -148,12 +148,6 @@ function getFData($format,$data,$meth=NULL) {
} }
return $format; return $format;
} }
/*
* Error Codes
*/
$GLOBALS['LSerror_code']['fct_getFData_01'] = array (
'msg' => _("Function 'getFData' : The method %{meth} of the object %{obj} doesn't exist.")
);
function getFieldInFormat($format) { function getFieldInFormat($format) {
$fields=array(); $fields=array();