*/ class LSformElement_password extends LSformElement { var $fieldTemplate = 'LSformElement_password_field.tpl'; var $template = 'LSformElement_password.tpl'; /** * Recupère la valeur de l'élement passée en POST * * Cette méthode vérifie la présence en POST de la valeur de l'élément et la récupère * pour la mettre dans le tableau passer en paramètre avec en clef le nom de l'élément * * @param[] array Pointeur sur le tableau qui recupèrera la valeur. * * @retval boolean true si la valeur est présente en POST, false sinon */ function getPostData(&$return) { // Récupère la valeur dans _POST, et les vérifie avec la fonction générale $retval = parent :: getPostData($return); // Si une valeur est recupérée if ($retval) { $val = $this -> form -> ldapObject -> attrs[$this -> name] -> getValue(); if( (empty($return[$this -> name][0]) ) && ( ! empty( $val ) ) ) { unset($return[$this -> name]); $this -> form -> _notUpdate[$this -> name] == true; return true; } } return $retval; } /** * Retourne les infos d'affichage de l'élément * * Cette méthode retourne les informations d'affichage de l'élement * * @retval array */ function getDisplay(){ $GLOBALS['LSsession'] -> addCssFile('LSformElement_password.css'); $return = $this -> getLabelInfos(); $pwd = ""; if (!$this -> isFreeze()) { if (($this -> params['html_options']['generationTool'])&&($this -> params['html_options']['autoGenerate'])&&(empty($this -> values))) { $pwd=$this->generatePassword(); } $params = array( 'generate' => ($this -> params['html_options']['generationTool']==True), 'verify' => (!$this -> attr_html -> attribute -> ldapObject-> isNew()) ); $GLOBALS['LSsession'] -> addJSconfigParam($this -> name,$params); $GLOBALS['LSsession'] -> addJSscript('LSformElement_password_field.js'); $GLOBALS['LSsession'] -> addJSscript('LSformElement_password.js'); } $return['html'] = $this -> fetchTemplate(NULL,array('pwd' => $pwd)); return $return; } function generatePassword() { return generatePassword($this -> params['html_options']['chars'],$this -> params['html_options']['lenght']); } function verifyPassword($pwd) { if ($this -> attr_html -> attribute -> ldapObject -> isNew()) { return false; } return $GLOBALS['LSsession'] -> checkUserPwd($this -> attr_html -> attribute -> ldapObject,$pwd); } } ?>