diff --git a/trunk/includes/addons/LSaddons.ftp.php b/trunk/includes/addons/LSaddons.ftp.php index b101e577..fe9c5c49 100644 --- a/trunk/includes/addons/LSaddons.ftp.php +++ b/trunk/includes/addons/LSaddons.ftp.php @@ -23,42 +23,34 @@ // Messages d'erreur // Support -$GLOBALS['LSerror_code']['FTP_SUPPORT_01']= array ( - 'msg' => _("FTP Support : Pear::Net_FTP est introuvable."), - 'level' => 'c' +LSerror :: defineError('FTP_SUPPORT_01', + _("FTP Support : Pear::Net_FTP est introuvable.") ); -$GLOBALS['LSerror_code']['FTP_SUPPORT_02']= array ( - 'msg' => _("FTP Support : La constante %{const} n'est pas défini."), - 'level' => 'c' +LSerror :: defineError('FTP_SUPPORT_02', + _("FTP Support : La constante %{const} n'est pas défini.") ); // Autres erreurs -$GLOBALS['LSerror_code']['FTP_00']= array ( - 'msg' => _("Net_FTP Error : %{msg}"), - 'level' => 'c' +LSerror :: defineError('FTP_00', + _("Net_FTP Error : %{msg}") ); -$GLOBALS['LSerror_code']['FTP_01']= array ( - 'msg' => _("FTP Support : Impossible de se connecter au serveur FTP (Etape : %{etape})."), - 'level' => 'c' +LSerror :: defineError('FTP_01', + _("FTP Support : Impossible de se connecter au serveur FTP (Etape : %{etape}).") ); -$GLOBALS['LSerror_code']['FTP_02']= array ( - 'msg' => _("FTP Support : Impossible de créer le dossier %{dir} sur le serveur distant."), - 'level' => 'c' +LSerror :: defineError('FTP_02', + _("FTP Support : Impossible de créer le dossier %{dir} sur le serveur distant.") ); -$GLOBALS['LSerror_code']['FTP_03']= array ( - 'msg' => _("FTP Support : Impossible de supprimer le dossier %{dir} sur le serveur distant."), - 'level' => 'c' +LSerror :: defineError('FTP_03', + _("FTP Support : Impossible de supprimer le dossier %{dir} sur le serveur distant.") ); -$GLOBALS['LSerror_code']['FTP_04']= array ( - 'msg' => _("FTP Support : Impossible de modifier les droits du dossier %{dir} sur le serveur distant."), - 'level' => 'c' +LSerror :: defineError('FTP_04', + _("FTP Support : Impossible de modifier les droits du dossier %{dir} sur le serveur distant.") ); -$GLOBALS['LSerror_code']['FTP_05']= array ( - 'msg' => _("FTP Support : Impossible de renomer le dossier %{old} en %{new} sur le serveur distant."), - 'level' => 'c' +LSerror :: defineError('FTP_05', + _("FTP Support : Impossible de renomer le dossier %{old} en %{new} sur le serveur distant.") ); /** diff --git a/trunk/includes/addons/LSaddons.mail.php b/trunk/includes/addons/LSaddons.mail.php index 0f1eb1af..ea247b60 100644 --- a/trunk/includes/addons/LSaddons.mail.php +++ b/trunk/includes/addons/LSaddons.mail.php @@ -23,20 +23,17 @@ // Messages d'erreur // Support -$GLOBALS['LSerror_code']['MAIL_SUPPORT_01']= array ( - 'msg' => _("MAIL Support : Pear::MAIL est introuvable."), - 'level' => 'c' +LSerror :: defineError('MAIL_SUPPORT_01', + _("MAIL Support : Pear::MAIL est introuvable.") ); // Autres erreurs -$GLOBALS['LSerror_code']['MAIL_00']= array ( - 'msg' => _("MAIL Error : %{msg}"), - 'level' => 'c' +LSerror :: defineError('MAIL_00', + _("MAIL Error : %{msg}") ); -$GLOBALS['LSerror_code']['MAIL_01']= array ( - 'msg' => _("MAIL : Problème durant l'envoie de votre mail"), - 'level' => 'c' +LSerror :: defineError('MAIL_01', + _("MAIL : Problème durant l'envoie de votre mail") ); /** diff --git a/trunk/includes/addons/LSaddons.maildir.php b/trunk/includes/addons/LSaddons.maildir.php index 1f97d6e3..4c8c98aa 100644 --- a/trunk/includes/addons/LSaddons.maildir.php +++ b/trunk/includes/addons/LSaddons.maildir.php @@ -23,25 +23,25 @@ // Messages d'erreur // Support -$GLOBALS['LSerror_code']['MAILDIR_SUPPORT_01']= array ( - 'msg' => _("MAILDIR Support : Impossible de charger LSaddons::FTP.") +LSerror :: defineError('MAILDIR_SUPPORT_01', + _("MAILDIR Support : Impossible de charger LSaddons::FTP.") ); -$GLOBALS['LSerror_code']['MAILDIR_SUPPORT_02']= array ( - 'msg' => _("MAILDIR Support : La constante %{const} n'est pas définie.") +LSerror :: defineError('MAILDIR_SUPPORT_02', + _("MAILDIR Support : La constante %{const} n'est pas définie.") ); // Autres erreurs -$GLOBALS['LSerror_code']['MAILDIR_01']= array ( - 'msg' => _("MAILDIR : Erreur durant la création de la maildir sur le serveur distant.") +LSerror :: defineError('MAILDIR_01', + _("MAILDIR : Erreur durant la création de la maildir sur le serveur distant.") ); -$GLOBALS['LSerror_code']['MAILDIR_02']= array ( - 'msg' => _("MAILDIR : Erreur durant la suppression de la maildir sur le serveur distant.") +LSerror :: defineError('MAILDIR_02', + _("MAILDIR : Erreur durant la suppression de la maildir sur le serveur distant.") ); -$GLOBALS['LSerror_code']['MAILDIR_03']= array ( - 'msg' => _("MAILDIR : Erreur durant le renomage de la maildir sur le serveur distant.") +LSerror :: defineError('MAILDIR_03', + _("MAILDIR : Erreur durant le renomage de la maildir sur le serveur distant.") ); -$GLOBALS['LSerror_code']['MAILDIR_04']= array ( - 'msg' => _("MAILDIR : Erreur durant la récupération du chemin distant de la maildir.") +LSerror :: defineError('MAILDIR_04', + _("MAILDIR : Erreur durant la récupération du chemin distant de la maildir.") ); /** diff --git a/trunk/includes/addons/LSaddons.posix.php b/trunk/includes/addons/LSaddons.posix.php index 34b7208c..74e04680 100644 --- a/trunk/includes/addons/LSaddons.posix.php +++ b/trunk/includes/addons/LSaddons.posix.php @@ -23,20 +23,17 @@ // Messages d'erreur // Support -$GLOBALS['LSerror_code']['POSIX_SUPPORT_01']= array ( - 'msg' => _("POSIX Support : La constante %{const} n'est pas définie."), - 'level' => 'c' +LSerror :: defineError('POSIX_SUPPORT_01', + _("POSIX Support : La constante %{const} n'est pas définie.") ); -$GLOBALS['LSerror_code']['POSIX_SUPPORT_02']= array ( - 'msg' => _("POSIX Support : Impossible de charger LSaddons::FTP."), - 'level' => 'c' +LSerror :: defineError('POSIX_SUPPORT_02', + _("POSIX Support : Impossible de charger LSaddons::FTP.") ); // Autres erreurs -$GLOBALS['LSerror_code']['POSIX_01']= array ( - 'msg' => _("POSIX : L'attribut %{dependency} est introuvable. Impossible de générer l'attribut %{attr}."), - 'level' => 'c' +LSerror :: defineError('POSIX_01', + _("POSIX : L'attribut %{dependency} est introuvable. Impossible de générer l'attribut %{attr}.") ); /** @@ -93,7 +90,7 @@ $GLOBALS['LSerror_code']['POSIX_01']= array ( */ 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; if (!is_array($objects)) @@ -120,7 +117,7 @@ $GLOBALS['LSerror_code']['POSIX_01']= array ( */ 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; if (!is_array($objects)) diff --git a/trunk/includes/addons/LSaddons.samba.php b/trunk/includes/addons/LSaddons.samba.php index 61bed19a..fb4ce89e 100644 --- a/trunk/includes/addons/LSaddons.samba.php +++ b/trunk/includes/addons/LSaddons.samba.php @@ -23,24 +23,20 @@ // Messages d'erreur // Support -$GLOBALS['LSerror_code']['SAMBA_SUPPORT_01']= array ( - 'msg' => _("SAMBA Support : la classe smHash ne peut pas être chargée."), - 'level' => 'c' +LSerror :: defineError('SAMBA_SUPPORT_01', + _("SAMBA Support : la classe smHash ne peut pas être chargée.") ); -$GLOBALS['LSerror_code']['SAMBA_SUPPORT_02']= array ( - 'msg' => _("SAMBA Support : La constante %{const} n'est pas définie."), - 'level' => 'c' +LSerror :: defineError('SAMBA_SUPPORT_02', + _("SAMBA Support : La constante %{const} n'est pas définie.") ); -$GLOBALS['LSerror_code']['SAMBA_SUPPORT_03']= array ( - '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."), - 'level' => 'c' +LSerror :: defineError('SAMBA_SUPPORT_03', + _("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.") ); // Autres erreurs -$GLOBALS['LSerror_code']['SAMBA_01']= array ( - 'msg' => _("SAMBA Support : L'attribut %{dependency} est introuvable. Impossible de générer l'attribut %{attr}."), - 'level' => 'c' +LSerror :: defineError('SAMBA_01', + _("SAMBA Support : L'attribut %{dependency} est introuvable. Impossible de générer l'attribut %{attr}.") ); /** diff --git a/trunk/includes/addons/LSaddons.supann.php b/trunk/includes/addons/LSaddons.supann.php index 14326de3..038bcc84 100644 --- a/trunk/includes/addons/LSaddons.supann.php +++ b/trunk/includes/addons/LSaddons.supann.php @@ -23,15 +23,13 @@ // Messages d'erreur // Support -$GLOBALS['LSerror_code']['SUPANN_SUPPORT_01']= array ( - 'msg' => _("SUPANN Support : La constante %{const} n'est pas définie."), - 'level' => 'c' +LSerror :: defineError('SUPANN_SUPPORT_01', + _("SUPANN Support : La constante %{const} n'est pas définie.") ); // Autres erreurs -$GLOBALS['LSerror_code']['SUPANN_01']= array ( - 'msg' => _("SUPANN Support : L'attribut %{dependency} est introuvable. Impossible de générer l'attribut %{attr}."), - 'level' => 'c' +LSerror :: defineError('SUPANN_01', + _("SUPANN Support : L'attribut %{dependency} est introuvable. Impossible de générer l'attribut %{attr}.") ); /** diff --git a/trunk/includes/class/class.LSattr_html.php b/trunk/includes/class/class.LSattr_html.php index 919d7be2..af701aa3 100644 --- a/trunk/includes/class/class.LSattr_html.php +++ b/trunk/includes/class/class.LSattr_html.php @@ -109,12 +109,12 @@ class LSattr_html { /* * Error Codes */ -$GLOBALS['LSerror_code']['LSattr_html_01'] = array ( - 'msg' => _("LSattr_html : The method addToForm() of the HTML type of the attribute %{attr} is not defined.") +LSerror :: defineError('LSattr_html_01', +_("LSattr_html : The method addToForm() of the HTML type of the attribute %{attr} is not defined.") ); // 02 : not yet used -$GLOBALS['LSerror_code']['LSattr_html_03'] = array ( - 'msg' => _("LSattr_html_%{type} : The multiple data are not supported for this field type.") +LSerror :: defineError('LSattr_html_03', +_("LSattr_html_%{type} : The multiple data are not supported for this field type.") ); ?> diff --git a/trunk/includes/class/class.LSattr_html_select_list.php b/trunk/includes/class/class.LSattr_html_select_list.php index 326e9b1b..b2e9ee8c 100644 --- a/trunk/includes/class/class.LSattr_html_select_list.php +++ b/trunk/includes/class/class.LSattr_html_select_list.php @@ -127,7 +127,7 @@ class LSattr_html_select_list extends LSattr_html{ /* * Error Codes */ -$GLOBALS['LSerror_code']['LSattr_html_select_list_01'] = array ( - 'msg' => _("LSattr_html_select_list : Configuration data are missing to generate the select list of the attribute %{attr}.") +LSerror :: defineError('LSattr_html_select_list_01', +_("LSattr_html_select_list : Configuration data are missing to generate the select list of the attribute %{attr}.") ); ?> diff --git a/trunk/includes/class/class.LSattr_html_select_object.php b/trunk/includes/class/class.LSattr_html_select_object.php index f1796cf7..cce3e480 100644 --- a/trunk/includes/class/class.LSattr_html_select_object.php +++ b/trunk/includes/class/class.LSattr_html_select_object.php @@ -195,8 +195,8 @@ class LSattr_html_select_object extends LSattr_html{ /* * Error Codes */ -$GLOBALS['LSerror_code']['LSattr_html_select_object_01'] = array ( - 'msg' => _("LSattr_html_select_object : LSobject type is undefined (attribute : %{attr}).") +LSerror :: defineError('LSattr_html_select_object_01', +_("LSattr_html_select_object : LSobject type is undefined (attribute : %{attr}).") ); ?> diff --git a/trunk/includes/class/class.LSattr_ldap_password.php b/trunk/includes/class/class.LSattr_ldap_password.php index a75df2a7..7f65f997 100644 --- a/trunk/includes/class/class.LSattr_ldap_password.php +++ b/trunk/includes/class/class.LSattr_ldap_password.php @@ -65,7 +65,7 @@ class LSattr_ldap_password extends LSattr_ldap { break; case 'ext_des': if ( ! defined( 'CRYPT_EXT_DES' ) || CRYPT_EXT_DES == 0 ) { - LSerror :: addErrorCode(1023,'ext_des'); + LSerror :: addErrorCode('LSattr_ldap_password_01','ext_des'); } else { return '{CRYPT}' . crypt( $this -> clearPassword, '_' . $this -> getSalt(8) ); @@ -73,7 +73,7 @@ class LSattr_ldap_password extends LSattr_ldap { break; case 'blowfish': if( ! defined( 'CRYPT_BLOWFISH' ) || CRYPT_BLOWFISH == 0 ) { - LSerror :: addErrorCode(1023,'blowfish'); + LSerror :: addErrorCode('LSattr_ldap_password_01','blowfish'); } else { 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' ) ) { return '{SHA}' . base64_encode( mhash( MHASH_SHA1, $this -> clearPassword ) ); } else { - LSerror :: addErrorCode(1023,'sha'); + LSerror :: addErrorCode('LSattr_ldap_password_01','sha'); } break; case 'ssha': @@ -96,7 +96,7 @@ class LSattr_ldap_password extends LSattr_ldap { return "{SSHA}".base64_encode( mhash( MHASH_SHA1, $this -> clearPassword.$salt ).$salt ); } else { - LSerror :: addErrorCode(1023,'ssha'); + LSerror :: addErrorCode('LSattr_ldap_password_01','ssha'); } break; case 'smd5': @@ -106,7 +106,7 @@ class LSattr_ldap_password extends LSattr_ldap { return "{SMD5}".base64_encode( mhash( MHASH_MD5, $password_clear.$salt ).$salt ); } else { - LSerror :: addErrorCode(1023,'smd5'); + LSerror :: addErrorCode('LSattr_ldap_password_01','smd5'); } break; case 'md5': @@ -114,7 +114,7 @@ class LSattr_ldap_password extends LSattr_ldap { break; case 'md5crypt': if( ! defined( 'CRYPT_MD5' ) || CRYPT_MD5 == 0 ) { - LSerror :: addErrorCode(1023,'md5crypt'); + LSerror :: addErrorCode('LSattr_ldap_password_01','md5crypt'); } else { return '{CRYPT}'.crypt($this -> clearPassword,'$1$'.$this -> getSalt().'$'); @@ -154,7 +154,7 @@ class LSattr_ldap_password extends LSattr_ldap { /** * Error Codes **/ -$GLOBALS['LSerror_code'][1023] = array( - 'msg' => _("LSattr_ldap_password : Encoding type %{type} is not supported. This password will be stocked in clear text.") +LSerror :: defineError('LSattr_ldap_password_01', +_("LSattr_ldap_password : Encoding type %{type} is not supported. This password will be stocked in clear text.") ); ?> diff --git a/trunk/includes/class/class.LSattribute.php b/trunk/includes/class/class.LSattribute.php index 7581563e..cee09aad 100644 --- a/trunk/includes/class/class.LSattribute.php +++ b/trunk/includes/class/class.LSattribute.php @@ -686,32 +686,32 @@ class LSattribute { /** * Error Codes **/ -$GLOBALS['LSerror_code']['LSattribute_01'] = array ( - 'msg' => _("LSattribute : Attribute %{attr} : LDAP or HTML types unknow (LDAP = %{ldap} & HTML = %{html}).") +LSerror :: defineError('LSattribute_01', + _("LSattribute : Attribute %{attr} : LDAP or HTML types unknow (LDAP = %{ldap} & HTML = %{html}).") ); -$GLOBALS['LSerror_code']['LSattribute_02'] = array ( - 'msg' => _("LSattribute : The function %{func} to display the attribute %{attr} is unknow.") +LSerror :: defineError('LSattribute_02', + _("LSattribute : The function %{func} to display the attribute %{attr} is unknow.") ); -$GLOBALS['LSerror_code']['LSattribute_03'] = array ( - 'msg' => _("LSattribute : The rule %{rule} to validate the attribute %{attr} is unknow.") +LSerror :: defineError('LSattribute_03', + _("LSattribute : The rule %{rule} to validate the attribute %{attr} is unknow.") ); -$GLOBALS['LSerror_code']['LSattribute_04'] = array ( - 'msg' => _("LSattribute : Configuration data to verify the attribute %{attr} are incorrect.") +LSerror :: defineError('LSattribute_04', + _("LSattribute : Configuration data to verify the attribute %{attr} are incorrect.") ); -$GLOBALS['LSerror_code']['LSattribute_05'] = array ( - 'msg' => _("LSattribute : The function %{func} to save the attribute %{attr} is unknow.") +LSerror :: defineError('LSattribute_05', + _("LSattribute : The function %{func} to save the attribute %{attr} is unknow.") ); -$GLOBALS['LSerror_code']['LSattribute_06'] = array ( - 'msg' => _("LSattribute : The value of the attribute %{attr} can't be generated.") +LSerror :: defineError('LSattribute_06', + _("LSattribute : The value of the attribute %{attr} can't be generated.") ); -$GLOBALS['LSerror_code']['LSattribute_07'] = array ( - 'msg' => _("LSattribute : Generation of the attribute %{attr} failed.") +LSerror :: defineError('LSattribute_07', + _("LSattribute : Generation of the attribute %{attr} failed.") ); -$GLOBALS['LSerror_code']['LSattribute_08'] = array ( - 'msg' => _("LSattribute : Generation of the attribute %{attr} did not return a correct value.") +LSerror :: defineError('LSattribute_08', + _("LSattribute : Generation of the attribute %{attr} did not return a correct value.") ); -$GLOBALS['LSerror_code']['LSattribute_09'] = array ( - 'msg' => _("LSattribute : The attr_%{type} of the attribute %{name} is not yet defined.") +LSerror :: defineError('LSattribute_09', + _("LSattribute : The attr_%{type} of the attribute %{name} is not yet defined.") ); ?> diff --git a/trunk/includes/class/class.LSerror.php b/trunk/includes/class/class.LSerror.php index 18ed313c..0ea4728c 100644 --- a/trunk/includes/class/class.LSerror.php +++ b/trunk/includes/class/class.LSerror.php @@ -29,6 +29,26 @@ */ class LSerror { + private static $_errorCodes = array( + '0' => array('msg' => "%{msg}") + ); + + /** + * Défini une erreur + * + * @author Benjamin Renard + * + * @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 * @@ -42,7 +62,7 @@ class LSerror { * * @retval void */ - static function addErrorCode($code=-1,$msg='') { + public static function addErrorCode($code=-1,$msg='') { $_SESSION['LSerror'][] = array($code,$msg); } @@ -55,7 +75,7 @@ class LSerror { * * @retval void */ - static function display($return=False) { + public static function display($return=False) { $errors = self::getErrors(); if ($errors) { if ($return) { @@ -75,7 +95,7 @@ class LSerror { * * @retval void */ - static function stop($code=-1,$msg='') { + public static function stop($code=-1,$msg='') { if(!empty($_SESSION['LSerror'])) { print "

"._('Errors')."

\n"; print self::display(true); @@ -91,7 +111,7 @@ class LSerror { * * @retvat string Le texte des erreurs */ - static function getErrors() { + public static function getErrors() { if(!empty($_SESSION['LSerror'])) { foreach ($_SESSION['LSerror'] as $error) { $txt.=self::getError($error); @@ -109,8 +129,8 @@ class LSerror { * * @retvat string Le texte des erreurs */ - static function getError($error) { - return "(Code ".$error[0].") ".getFData($GLOBALS['LSerror_code'][$error[0]]['msg'],$error[1])."
\n"; + private static function getError($error) { + return "(Code ".$error[0].") ".getFData(self :: $_errorCodes[$error[0]]['msg'],$error[1])."
\n"; } /** @@ -120,7 +140,7 @@ class LSerror { * * @retvat boolean */ - static function errorsDefined() { + public static function errorsDefined() { return !empty($_SESSION['LSerror']); } @@ -131,7 +151,7 @@ class LSerror { * * @retvat void */ - static function resetError() { + private static function resetError() { unset ($_SESSION['LSerror']); } } @@ -139,11 +159,6 @@ class LSerror { /* * Error Codes */ -$GLOBALS['LSerror_code']['-1'] = array ( - 'msg' => _("Unknow error!") -); -$GLOBALS['LSerror_code'][0] = array ( - 'msg' => "%{msg}" -); +LSerror :: defineError(-1,_("Unknow error!")); ?> diff --git a/trunk/includes/class/class.LSform.php b/trunk/includes/class/class.LSform.php index 18a0d5bd..f3e6fcc1 100644 --- a/trunk/includes/class/class.LSform.php +++ b/trunk/includes/class/class.LSform.php @@ -522,28 +522,28 @@ class LSform { /** * Error Codes */ -$GLOBALS['LSerror_code']['LSform_01'] = array( - 'msg' => _("LSform : Error during the recovery of the values of the form.") +LSerror :: defineError('LSform_01', +_("LSform : Error during the recovery of the values of the form.") ); -$GLOBALS['LSerror_code']['LSform_02'] = array( - 'msg' => _("LSform : Error durring the recovery of the value of the field '%{element}'.") +LSerror :: defineError('LSform_02', +_("LSform : Error durring the recovery of the value of the field '%{element}'.") ); // No longer used -/*$GLOBALS['LSerror_code'][203] = array( - 'msg' => _("LSform : Data of the field %{element} are not validate.") +/*LSerror :: defineError(203, +_("LSform : Data of the field %{element} are not validate.") );*/ -$GLOBALS['LSerror_code']['LSform_04'] = array( - 'msg' => _("LSform : The field %{element} doesn't exist.") +LSerror :: defineError('LSform_04', +_("LSform : The field %{element} doesn't exist.") ); -$GLOBALS['LSerror_code']['LSform_05'] = array( - 'msg' => _("LSfom : Field type unknow (%{type}).") +LSerror :: defineError('LSform_05', +_("LSfom : Field type unknow (%{type}).") ); -$GLOBALS['LSerror_code']['LSform_06'] = array( - 'msg' => _("LSform : Error during the creation of the element '%{element}'.") +LSerror :: defineError('LSform_06', +_("LSform : Error during the creation of the element '%{element}'.") ); // No longer used -/*$GLOBALS['LSerror_code'][207] = array( - 'msg' => _("LSform : No value has been entered into the field '%{element}'.") +/*LSerror :: defineError(207, +_("LSform : No value has been entered into the field '%{element}'.") );*/ ?> diff --git a/trunk/includes/class/class.LSformRule.php b/trunk/includes/class/class.LSformRule.php index 40544e98..98aae557 100644 --- a/trunk/includes/class/class.LSformRule.php +++ b/trunk/includes/class/class.LSformRule.php @@ -53,7 +53,7 @@ class LSformRule { /** * Error Codes **/ -$GLOBALS['LSerror_code']['LSformRule_01'] = array ( - 'msg' => _("LSformRule_%{type} : Parameter %{param} is not found.") +LSerror :: defineError('LSformRule_01', +_("LSformRule_%{type} : Parameter %{param} is not found.") ); ?> diff --git a/trunk/includes/class/class.LSformRule_regex.php b/trunk/includes/class/class.LSformRule_regex.php index f554c076..7854aa80 100644 --- a/trunk/includes/class/class.LSformRule_regex.php +++ b/trunk/includes/class/class.LSformRule_regex.php @@ -61,8 +61,8 @@ class LSformRule_regex extends LSformRule { /* * Error Codes */ -$GLOBALS['LSerror_code']['LSformRule_regex_01'] = array( - 'msg' => _("LSformRule_regex : Regex has not been configured to validate data.") +LSerror :: defineError('LSformRule_regex_01', +_("LSformRule_regex : Regex has not been configured to validate data.") ); ?> diff --git a/trunk/includes/class/class.LSldap.php b/trunk/includes/class/class.LSldap.php index fe47383d..6b6c7333 100644 --- a/trunk/includes/class/class.LSldap.php +++ b/trunk/includes/class/class.LSldap.php @@ -29,26 +29,22 @@ */ class LSldap { - var $config; - var $cnx = NULL; - + private static $config; + private static $cnx = NULL; + /** - * Constructeur + * Défini la configuration * * Cette methode définis la configuration de l'accès à l'annuaire - * et établie la connexion. * * @author Benjamin Renard * * @param[in] $config array Tableau de configuration au formar Net_LDAP2 * * @retval void - * - * @see Net_LDAP2::connect() */ - function LSldap ($config) { - $this -> config = $config; - $this -> connect(); + function setConfig ($config) { + self :: $config = $config; } /** @@ -57,14 +53,19 @@ class LSldap { * Cette methode établie la connexion à l'annuaire Ldap * * @author Benjamin Renard + * + * @param[in] $config array Tableau de configuration au formar Net_LDAP2 * * @retval boolean true si la connection est établie, false sinon */ - function connect() { - $this -> cnx = Net_LDAP2::connect($this -> config); - if (Net_LDAP2::isError($this -> cnx)) { - LSerror :: addErrorCode('LSldap_01',$this -> cnx -> getMessage()); - $this -> cnx = NULL; + public static function connect($config = null) { + if ($config) { + self :: setConfig($config); + } + 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 true; @@ -79,8 +80,8 @@ class LSldap { * * @retval void */ - function close() { - $this -> cnx -> done(); + public static function close() { + self :: $cnx -> done(); } /** @@ -102,8 +103,8 @@ class LSldap { * - ['attrs'] : tableau associatif contenant les attributs (clé) * et leur valeur (valeur). */ - function search ($filter,$basedn=NULL,$params = array()) { - $ret = $this -> cnx -> search($basedn,$filter,$params); + public static function search ($filter,$basedn=NULL,$params = array()) { + $ret = self :: $cnx -> search($basedn,$filter,$params); if (Net_LDAP2::isError($ret)) { LSerror :: addErrorCode('LSldap_02',$ret -> getMessage()); return; @@ -131,10 +132,10 @@ class LSldap { * * @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)) $filter=NULL; - $ret = $this -> cnx -> search($basedn,$filter,$params); + $ret = self :: $cnx -> search($basedn,$filter,$params); if (Net_LDAP2::isError($ret)) { LSerror :: addErrorCode('LSldap_02',$ret -> getMessage()); return; @@ -154,7 +155,7 @@ class LSldap { * * @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); if((!$infos)||($infos['count']==0)) return; @@ -163,7 +164,7 @@ class LSldap { $sep=($basedn=='')?'':','; $basedn.=$sep.$infos[$i]; } - $return=$this -> search($infos[0],$basedn); + $return=self :: search($infos[0],$basedn); return $return[0]['attrs']; } @@ -182,12 +183,12 @@ class LSldap { * 'new' => true * ) */ - function getEntry($object_type,$dn) { + public static function getEntry($object_type,$dn) { if(isset($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)) { - //$newentry = new Net_LDAP2_Entry(&$this -> cnx); + //$newentry = new Net_LDAP2_Entry(&self :: $cnx); //$newentry -> dn($dn); //$newentry -> add(array('objectclass' => $obj_conf['objectclass'])); //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) { return; @@ -226,13 +227,13 @@ class LSldap { * * @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)); if(Net_LDAP2::isError($newentry)) { return false; } if($add) { - if(!$this -> cnx -> add($newentry)) { + if(!self :: $cnx -> add($newentry)) { return; } } @@ -252,10 +253,10 @@ class LSldap { * * @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); $dropAttr=array(); - $entry=$this -> getEntry($object_type,$dn); + $entry=self :: getEntry($object_type,$dn); if (is_array($entry)) { $new = $entry['new']; $entry = $entry['entry']; @@ -291,7 +292,7 @@ class LSldap { if ($new) { LSdebug('LSldap :: add()'); - $ret = $this -> cnx -> add($entry); + $ret = self :: $cnx -> add($entry); } else { LSdebug('LSldap :: update()'); @@ -339,8 +340,8 @@ class LSldap { * * @retval boolean true si la connection à réussi, false sinon */ - function checkBind($dn,$pwd) { - $config = $this -> config; + public static function checkBind($dn,$pwd) { + $config = self :: $config; $config['binddn'] = $dn; $config['bindpw'] = $pwd; $cnx = Net_LDAP2::connect($config); @@ -355,8 +356,8 @@ class LSldap { * * @retval boolean True si le serveur est connecté, false sinon. */ - function isConnected() { - return ($this -> cnx == NULL)?false:true; + public static function isConnected() { + return (self :: $cnx == NULL)?false:true; } /** @@ -366,8 +367,8 @@ class LSldap { * * @retval boolean True si l'objet à été supprimé, false sinon */ - function remove($dn) { - $ret = $this -> cnx -> delete($dn,array('recursive' => true)); + public static function remove($dn) { + $ret = self :: $cnx -> delete($dn,array('recursive' => true)); if (Net_LDAP2::isError($ret)) { LSerror :: addErrorCode(0,'NetLdap-Error : '.$ret->getMessage()); return; @@ -383,8 +384,8 @@ class LSldap { * * @retval boolean True si l'objet a été déplacé, false sinon */ - function move($old,$new) { - $ret = $this -> cnx -> move($old,$new); + public static function move($old,$new) { + $ret = self :: $cnx -> move($old,$new); if (Net_LDAP2::isError($ret)) { LSerror :: addErrorCode('LSldap_07'); LSerror :: addErrorCode(0,'NetLdap-Error : '.$ret->getMessage()); @@ -397,25 +398,25 @@ class LSldap { /* * Error Codes */ -$GLOBALS['LSerror_code']['LSldap_01'] = array ( - 'msg' => _("LSldap : Error during the LDAP server connection (%{msg}).") +LSerror :: defineError('LSldap_01', + _("LSldap : Error during the LDAP server connection (%{msg}).") ); -$GLOBALS['LSerror_code']['LSldap_02'] = array ( - 'msg' => _("LSldap : Error during the LDAP search (%{msg}).") +LSerror :: defineError('LSldap_02', + _("LSldap : Error during the LDAP search (%{msg}).") ); -$GLOBALS['LSerror_code']['LSldap_03'] = array ( - 'msg' => _("LSldap : Object type unkown.") +LSerror :: defineError('LSldap_03', + _("LSldap : Object type unkown.") ); -$GLOBALS['LSerror_code']['LSldap_04'] = array ( - 'msg' => _("LSldap : Error during fecthing the LDAP entry.") +LSerror :: defineError('LSldap_04', + _("LSldap : Error during fecthing the LDAP entry.") ); -$GLOBALS['LSerror_code']['LSldap_05'] = array ( - 'msg' => _("LSldap : Error during changing the LDAP entry (DN : %{dn}).") +LSerror :: defineError('LSldap_05', + _("LSldap : Error during changing the LDAP entry (DN : %{dn}).") ); -$GLOBALS['LSerror_code']['LSldap_06'] = array ( - 'msg' => _("LSldap : Error during deleting the empty attributes.") +LSerror :: defineError('LSldap_06', + _("LSldap : Error during deleting the empty attributes.") ); -$GLOBALS['LSerror_code']['LSldap_07'] = array ( - 'msg' => _("LSldap : Error during changing the DN of the object.") +LSerror :: defineError('LSldap_07', + _("LSldap : Error during changing the DN of the object.") ); ?> diff --git a/trunk/includes/class/class.LSldapObject.php b/trunk/includes/class/class.LSldapObject.php index a307f447..50665a93 100644 --- a/trunk/includes/class/class.LSldapObject.php +++ b/trunk/includes/class/class.LSldapObject.php @@ -90,7 +90,7 @@ class LSldapObject { */ function loadData($dn) { $this -> dn = $dn; - $data = $GLOBALS['LSldap'] -> getAttrs($dn); + $data = LSldap :: getAttrs($dn); if(!empty($data)) { foreach($this -> attrs as $attr_name => $attr) { 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. */ function reloadData() { - $data = $GLOBALS['LSldap'] -> getAttrs($this -> dn); + $data = LSldap :: getAttrs($this -> dn); foreach($this -> attrs as $attr_name => $attr) { if(!$this -> attrs[$attr_name] -> reloadData($data[$attr_name])) return; @@ -453,7 +453,7 @@ class LSldapObject { $sfilter=$sfilter_user; } $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($ret!=0) { $LSform -> setElementError($attr,$msg_error); @@ -538,7 +538,7 @@ class LSldapObject { $this -> dn = false; $newDn = $this -> getDn(); if ($newDn) { - if (!$GLOBALS['LSldap'] -> move($oldDn,$newDn)) { + if (!LSldap :: move($oldDn,$newDn)) { return; } $this -> dn = $newDn; @@ -561,7 +561,7 @@ class LSldapObject { if($dn) { $this -> dn=$dn; LSdebug($submitData); - if (!$GLOBALS['LSldap'] -> update($this -> getType(),$dn, $submitData)) { + if (!LSldap :: update($this -> getType(),$dn, $submitData)) { return; } if ($new) { @@ -758,7 +758,7 @@ class LSldapObject { } // Execution de la recherche - $ret=$GLOBALS['LSldap'] -> search ($sfilter_for,$sbasedn,$sparams); + $ret=LSldap :: search ($sfilter_for,$sbasedn,$sparams); // Si il y un retour if(isset($ret[0])) { @@ -815,7 +815,7 @@ class LSldapObject { } // 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 if(isset($filter[$i]['attr'])) { @@ -1060,7 +1060,7 @@ class LSldapObject { */ function remove() { if ($this -> beforeDelete()) { - if ($GLOBALS['LSldap'] -> remove($this -> getDn())) { + if (LSldap :: remove($this -> getDn())) { if ($this -> afterDelete()) { return true; } @@ -1313,7 +1313,7 @@ class LSldapObject { if (LSsession :: loadLSobject($type)) { if (isset($GLOBALS['LSobjects'][$type]['container_auto_create'])&&isset($GLOBALS['LSobjects'][$type]['container_dn'])) { $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( array( 'dn' => $dn, @@ -1463,7 +1463,7 @@ class LSldapObject { } } 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; } @@ -1508,7 +1508,7 @@ class LSldapObject { $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; } } - 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 **/ -$GLOBALS['LSerror_code']['LSldapObject_01'] = array ( - 'msg' => _("LSldapObject : Object type unknow.") +LSerror :: defineError('LSldapObject_01', +_("LSldapObject : Object type unknow.") ); -$GLOBALS['LSerror_code']['LSldapObject_02'] = array ( - 'msg' => _("LSldapObject : Update form is not defined for the object %{obj}.") +LSerror :: defineError('LSldapObject_02', +_("LSldapObject : Update form is not defined for the object %{obj}.") ); -$GLOBALS['LSerror_code']['LSldapObject_03'] = array ( - 'msg' => _("LSldapObject : No form exist for the object %{obj}.") +LSerror :: defineError('LSldapObject_03', +_("LSldapObject : No form exist for the object %{obj}.") ); -$GLOBALS['LSerror_code']['LSldapObject_04'] = array ( - 'msg' => _("LSldapObject : The function %{func} to validate the attribute %{attr} the object %{obj} is unknow.") +LSerror :: defineError('LSldapObject_04', +_("LSldapObject : The function %{func} to validate the attribute %{attr} the object %{obj} is unknow.") ); -$GLOBALS['LSerror_code']['LSldapObject_05'] = array ( - 'msg' => _("LSldapObject : Configuration data are missing to validate the attribute %{attr} of the object %{obj}.") +LSerror :: defineError('LSldapObject_05', +_("LSldapObject : Configuration data are missing to validate the attribute %{attr} of the object %{obj}.") ); /* No longer used -$GLOBALS['LSerror_code'][26] = array ( - 'msg' => _("LSldapObject : Configuration error : The object %{obj} doesn't had attribute %{attr}.") +LSerror :: defineError(26, +_("LSldapObject : Configuration error : The object %{obj} doesn't had attribute %{attr}.") ); */ -$GLOBALS['LSerror_code']['LSldapObject_07'] = array ( - 'msg' => _("LSldapObject : The function %{func} to be executed before changing the object doesn't exist.") +LSerror :: defineError('LSldapObject_07', +_("LSldapObject : The function %{func} to be executed before changing the object doesn't exist.") ); -$GLOBALS['LSerror_code']['LSldapObject_08'] = array ( - 'msg' => _("LSldapObject : The execution of the function %{func} to be executed before changing the object failed.") +LSerror :: defineError('LSldapObject_08', +_("LSldapObject : The execution of the function %{func} to be executed before changing the object failed.") ); -$GLOBALS['LSerror_code']['LSldapObject_09'] = array ( - 'msg' => _("LSldapObject : The function %{func} to be executed after changing the object doesn't exist.") +LSerror :: defineError('LSldapObject_09', +_("LSldapObject : The function %{func} to be executed after changing the object doesn't exist.") ); -$GLOBALS['LSerror_code']['LSldapObject_10'] = array ( - 'msg' => _("LSldapObject : The execution of the function %{func} to be executed after changing the object failed.") +LSerror :: defineError('LSldapObject_10', +_("LSldapObject : The execution of the function %{func} to be executed after changing the object failed.") ); -$GLOBALS['LSerror_code']['LSldapObject_11'] = array ( - 'msg' => _("LSldapObject : Some configuration data of the object type %{obj} are missing to generate the DN of the new object.") +LSerror :: defineError('LSldapObject_11', +_("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 ( - 'msg' => _("LSldapObject : The attibute %{attr} of the object is not yet defined. Impossible to generate DN.") +LSerror :: defineError('LSldapObject_12', +_("LSldapObject : The attibute %{attr} of the object is not yet defined. Impossible to generate DN.") ); -$GLOBALS['LSerror_code']['LSldapObject_13'] = array ( - 'msg' => _("LSldapObject : Without DN, the object could not be changed.") +LSerror :: defineError('LSldapObject_13', +_("LSldapObject : Without DN, the object could not be changed.") ); -$GLOBALS['LSerror_code']['LSldapObject_14'] = array ( - 'msg' => _("LSldapObject : The attribute %{attr_depend} depending on the attribute %{attr} doesn't exist.") +LSerror :: defineError('LSldapObject_14', +_("LSldapObject : The attribute %{attr_depend} depending on the attribute %{attr} doesn't exist.") ); -$GLOBALS['LSerror_code']['LSldapObject_15'] = array ( - 'msg' => _("LSldapObject : Error during deleting the object %{objectname}.") +LSerror :: defineError('LSldapObject_15', +_("LSldapObject : Error during deleting the object %{objectname}.") ); -$GLOBALS['LSerror_code']['LSldapObject_16'] = array ( - 'msg' => _("LSldapObject : Error during actions to be executed before renaming the objet.") +LSerror :: defineError('LSldapObject_16', +_("LSldapObject : Error during actions to be executed before renaming the objet.") ); -$GLOBALS['LSerror_code']['LSldapObject_17'] = array ( - 'msg' => _("LSldapObject : Error during actions to be executed after renaming the objet.") +LSerror :: defineError('LSldapObject_17', +_("LSldapObject : Error during actions to be executed after renaming the objet.") ); -$GLOBALS['LSerror_code']['LSldapObject_18'] = array ( - 'msg' => _("LSldapObject : Error during actions to be executed before deleting the objet.") +LSerror :: defineError('LSldapObject_18', +_("LSldapObject : Error during actions to be executed before deleting the objet.") ); -$GLOBALS['LSerror_code']['LSldapObject_19'] = array ( - 'msg' => _("LSldapObject : Error during actions to be executed after deleting the objet.") +LSerror :: defineError('LSldapObject_19', +_("LSldapObject : Error during actions to be executed after deleting the objet.") ); // 20 : not used -$GLOBALS['LSerror_code']['LSldapObject_21'] = array ( - 'msg' => _("LSldapObject : Error during the actions to be executed after creating the object. It was created anyway.") +LSerror :: defineError('LSldapObject_21', +_("LSldapObject : Error during the actions to be executed after creating the object. It was created anyway.") ); -$GLOBALS['LSerror_code']['LSldapObject_22'] = array ( - 'msg' => _("LSldapObject : The function %{func} to be generated before creating the object doesn't exist.") +LSerror :: defineError('LSldapObject_22', +_("LSldapObject : The function %{func} to be generated before creating the object doesn't exist.") ); -$GLOBALS['LSerror_code']['LSldapObject_23'] = array ( - 'msg' => _("LSldapObject : Error during the execution of the function %{func} to be generated after deleting the object.") +LSerror :: defineError('LSldapObject_23', +_("LSldapObject : Error during the execution of the function %{func} to be generated after deleting the object.") ); -$GLOBALS['LSerror_code']['LSldapObject_24'] = array ( - 'msg' => _("LSldapObject : The function %{func} to be generated after deleting the object doesn't exist.") +LSerror :: defineError('LSldapObject_24', +_("LSldapObject : The function %{func} to be generated after deleting the object doesn't exist.") ); -$GLOBALS['LSerror_code']['LSldapObject_25'] = array ( - 'msg' => _("LSldapObject : Error during the execution of the function %{func} to be generated after creating the object.") +LSerror :: defineError('LSldapObject_25', +_("LSldapObject : Error during the execution of the function %{func} to be generated after creating the object.") ); /* Not yet used -$GLOBALS['LSerror_code'][306] = array ( - 'msg' => _("LSldapObject : The function %{func} to be executed after changing the attribute %{attr} is unknow.") +LSerror :: defineError(306, +_("LSldapObject : The function %{func} to be executed after changing the attribute %{attr} is unknow.") ); -$GLOBALS['LSerror_code'][307] = array ( - 'msg' => _("LSldapObject : The execution of the function %{func} to be executed after changing the attribute %{attr} failed.") +LSerror :: defineError(307, +_("LSldapObject : The execution of the function %{func} to be executed after changing the attribute %{attr} failed.") ); -$GLOBALS['LSerror_code'][308] = array ( - 'msg' => _("LSldapObject : The function %{func} to be executed before changing the attribute %{attr} is unknow.") +LSerror :: defineError(308, +_("LSldapObject : The function %{func} to be executed before changing the attribute %{attr} is unknow.") ); -$GLOBALS['LSerror_code'][309] = array ( - 'msg' => _("LSldapObject : The execution of the function %{func} to be executed before changing the attribute %{attr} failed.") +LSerror :: defineError(309, +_("LSldapObject : The execution of the function %{func} to be executed before changing the attribute %{attr} failed.") ); */ ?> diff --git a/trunk/includes/class/class.LSsession.php b/trunk/includes/class/class.LSsession.php index 194f04a7..b0363f83 100644 --- a/trunk/includes/class/class.LSsession.php +++ b/trunk/includes/class/class.LSsession.php @@ -123,7 +123,7 @@ class LSsession { return true; } else { - die($GLOBALS['LSerror_code']['LSsession_08']['msg']); + die("ERROR : Can't load configuration file."); return; } return true; @@ -151,6 +151,7 @@ class LSsession { if(!self :: loadLSclass('LSerror')) { return; } + self :: defineLSerrors(); return true; } @@ -674,8 +675,8 @@ class LSsession { if (!self :: loadLSclass('LSldap')) { return; } - $GLOBALS['LSldap'] = @new LSldap(self :: $ldapServer['ldap_config']); - if ($GLOBALS['LSldap'] -> isConnected()) { + LSldap :: connect(self :: $ldapServer['ldap_config']); + if (LSldap :: isConnected()) { return true; } else { @@ -825,7 +826,7 @@ class LSsession { * @retval boolean True si l'authentification à réussi, false sinon. */ 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}).") -); ?> diff --git a/trunk/includes/functions.php b/trunk/includes/functions.php index d022a2aa..19847293 100644 --- a/trunk/includes/functions.php +++ b/trunk/includes/functions.php @@ -136,7 +136,7 @@ function getFData($format,$data,$meth=NULL) { $format[$i]=ereg_replace($ch[0],$value,$format[$i]); } 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; } } @@ -148,12 +148,6 @@ function getFData($format,$data,$meth=NULL) { } 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) { $fields=array();