iId = $_iId ; $this->zEmail = "" ; $this->zLogin = "" ; $this->zPassword = "" ; $this->zHashCode = "" ; $this->zLanguageCode = "" ; $this->zCivilite = "" ; $this->zNom = "" ; $this->zPrenom = "" ; $this->zDateNaissance = "" ; $this->zAdresse1 = "" ; $this->zAdresse2 = "" ; $this->zVille = "" ; $this->zCodePostal = 0 ; $this->iInscritNewLetter = 0 ; $this->zEan128 = "" ; $this->toFields = array () ; $this->toFieldsConfig = array () ; $this->toServices = array () ; } /** * Liste les champs dynamiques d?finis par cet utilisateur * * @return array Liste des codes des champs d?finis par l'utilisateur */ public function getDynamicFieldsList () { if ( isset ($this->toFields) ) { return array_keys ($this->toFields) ; } else { return 0 ; } } /** * Ajoute un nouveau champ dans l'utilisateur * * @param string $_zFieldCode Code du champ * @param int $_iFieldType Type du champ * @param string $_zFieldPattern Motif de v?rification du champ * @param string $_zFieldValue Valeur du champ */ public function addField ($_zFieldCode, $_iFieldType = FIELDTYPE_TEXT, $_zFieldPattern = "", $_zFieldValue = "") { $oNewField = new CPCUserField ($_zFieldCode, $_iFieldType, $_zFieldPattern, $_zFieldValue) ; $this->toFields[$_zFieldCode] = $oNewField ; } /** * Ajoute un nouveau champ dans l'utilisateur * * @param string $_zFieldCode Code du champ * @param string $_zFieldValue Valeur du champ */ public function setField ($_zFieldCode, $_zFieldValue = 0) { if (!array_key_exists ($_zFieldCode, $this->toFields)) { $this->addField ($_zFieldCode) ; } $this->toFields[$_zFieldCode]->zValue = $_zFieldValue ; } /** * R�cup�re la valeur d'un champ dynamique utilisateur * * @param string $_zFieldCode Code du champ * @return string Valeur du champ ou FALSE si champ inexsitant */ public function getField ($_zFieldCode) { $zRet = false ; if (array_key_exists ($_zFieldCode, $this->toFields)) { $zRet = $this->toFields[$_zFieldCode]->zValue ; } else { return null ; } return $zRet ; } /** * V?rificaion de la conformit? interne du champs * * @return bool R?sultat de la v?rification de conformit? */ public function check () { $bRet = true ; if (!$this->checkEmailFormat ($this->zEmail)) { $bRet = false ; throw new Exception ("Format d'Email invalide : [" . $this->zEmail . "]") ; } try { $this->checkEmailOnMX ($this->zEmail) ; } catch (Exception $_eInvalideMail) { $bRet = false ; } if ($bRet) { foreach ($this->toFields as $oField) { try { $bRet = $bRet && $oField->check(); } catch (Exception $_oException) { $bRet = false ; throw new Exception ($_oException->getMessage ()) ; } } } return $bRet ; } /** * Fonction de v?rification d'un email * * @param string $_zInputEmail l'Adresse email ? v?rifier * @return bool R?sultat de la v?rification du format */ public function checkEmailOnMX ($_zInputEmail, $_zLocalUser = "root", $_zLocalHost = "localhost") { $bRes = true ; /* if (isset ($_zInputEmail)) { $oEmailValidator = new email_validation_class () ; $oEmailValidator->timeout = 5 ; $oEmailValidator->data_timeout = 0 ; $oEmailValidator->localuser = $_zLocalUser ; $oEmailValidator->localhost = $_zLocalHost ; $oEmailValidator->debug = 0 ; $oEmailValidator->html_debug = 0 ; $oEmailValidator->exclude_address = "" ; if (!$oEmailValidator->ValidateEmailBox ($_zInputEmail)) { $bRes = false ; throw new Exception ("Email non reconnu par le serveur : [" . $_zInputEmail . "]") ; } } */ return $bRes ; } /** * Fonction de v?rification du format d'un email * * @param string $_zInputEmail l'Adresse email ? v?rifier * @return bool R?sultat de la v?rification du format */ public function checkEmailFormat ($_zInputEmail) { $zPattern2 = "/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,})$/i" ; $bRet = (preg_match ($zPattern2, $_zInputEmail)) ; return $bRet ; } /** * Liste les champs dynamiques d�finis par la configuration de l'utilisateur * * @return array Liste des codes des champs par la configuration de l'utilisateur */ public function getFieldsConfig () { if (isset ($this->toFieldsConfig)) { $toResults = array_keys ($this->toFieldsConfig) ; if (count ($toResults) > 0) { return $toResults ; } else { return null ; } } else { return null ; } } /** * Liste des services correspondant � l'utilisateur * * @return array Liste des services */ public function getAllServicesCorresponding () { if (isset ($this->toServices)) { $toResults = $this->toServices ; if (count ($toResults) > 0) { return $toResults ; } else { return null ; } } else { return null ; } } /** * Fonction d'ajout d'une configuration de champs * * @param string $_zFieldCode * @param CPlatosFieldConfig $_oFieldConfig ; */ public function addFieldConfig ($_zFieldCode, $_oFieldConfig) { $oNewFieldConfig = new CPCFieldConfig () ; $oNewFieldConfig->zFieldId = $_oFieldConfig->zFieldId ; $oNewFieldConfig->iFieldType = $_oFieldConfig->iFieldType ; $oNewFieldConfig->zLabel = $_oFieldConfig->zLabel ; foreach ($_oFieldConfig->toAttributes as $oAttr) { $oNewAttr = new CPCFieldAttribute () ; $oNewAttr->iId = $oAttr->iId ; $oNewAttr->zLabel = $oAttr->zLabel ; array_push ($oNewFieldConfig->toAttributes, $oNewAttr) ; } $this->toFieldsConfig[$_zFieldCode] = $oNewFieldConfig ; } /** * R�cup�ration du lib�ll� d'un champ * * @param string $_zFieldCode * @return string|null Type du champ */ public function getFieldLabel ($_zFieldCode) { if (array_key_exists ($_zFieldCode, $this->toFieldsConfig)) { return $this->toFieldsConfig[$_zFieldCode]->zLabel ; } else { return null ; } } /** * R�cup�ration du type d'un champ * * @param string $_zFieldCode * @return int|null Type du champ */ public function getFieldType ($_zFieldCode) { if (array_key_exists ($_zFieldCode, $this->toFieldsConfig)) { return $this->toFieldsConfig[$_zFieldCode]->iFieldType ; } else { return null ; } } /** * R�cup�ration du type d'un champ * * @param string $_zFieldCode * @return array|null Type du champ */ public function getFieldAttributes ($_zFieldCode) { if (array_key_exists ($_zFieldCode, $this->toFieldsConfig)) { $tzResults = array () ; foreach ($this->toFieldsConfig[$_zFieldCode]->toAttributes as $oAttr) { $tzResults[$oAttr->iId] = $oAttr->zLabel ; } return $tzResults ; } else { return null ; } } /** * Fonction d'ajout des services correspondants * * @param CPlatosServices $_oServices */ public function addServiceCorresponding ($_oServices) { $oServices = new CPCServices () ; $oServices->iServiceId = $_oServices->iServiceId ; $oServices->zServiceName = $_oServices->zServiceName ; array_push ($this->toServices, $oServices) ; } /** * Recuperation des champs * @return array Liste des champs */ public function getFields () { return $this->toFields ; } } /** * Classe faisant d'une valeur autoris� pour un champs */ class CPCFieldAttribute { public $iId ; public $zLabel ; } /** * Classe faisant abstraction d'une liste de valeur autoris� pour un champs (Type liste) */ class CPCFieldConfig { public $zFieldId ; public $iFieldType ; public $zLabel ; public $zPattern ; public $toAttributes = array () ; } /** * Classe faisant abstraction d'un service */ class CPCServices { public $iServiceId ; public $zServiceName ; } ?>