2007-11-15 19:07:24 +01:00
|
|
|
<?php
|
|
|
|
/*******************************************************************************
|
|
|
|
* Copyright (C) 2007 Easter-eggs
|
|
|
|
* http://ldapsaisie.labs.libre-entreprise.org
|
|
|
|
*
|
|
|
|
* Author: See AUTHORS file in top-level directory.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License version 2
|
|
|
|
* as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Element password d'un formulaire pour LdapSaisie
|
|
|
|
*
|
2008-04-25 16:09:27 +02:00
|
|
|
* Cette classe définis les éléments password des formulaires.
|
|
|
|
* Elle étant la classe basic LSformElement.
|
2007-11-15 19:07:24 +01:00
|
|
|
*
|
|
|
|
* @author Benjamin Renard <brenard@easter-eggs.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
class LSformElement_password extends LSformElement {
|
2008-10-16 14:01:26 +02:00
|
|
|
|
|
|
|
var $fieldTemplate = 'LSformElement_password_field.tpl';
|
|
|
|
var $template = 'LSformElement_password.tpl';
|
2007-11-15 19:07:24 +01:00
|
|
|
|
2008-02-12 18:59:44 +01:00
|
|
|
/**
|
2008-04-25 16:09:27 +02:00
|
|
|
* Recupère la valeur de l'élement passée en POST
|
2007-11-15 19:07:24 +01:00
|
|
|
*
|
2008-04-25 16:09:27 +02:00
|
|
|
* 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
|
2007-11-15 19:07:24 +01:00
|
|
|
*
|
2008-04-25 16:09:27 +02:00
|
|
|
* @param[] array Pointeur sur le tableau qui recupèrera la valeur.
|
2007-11-15 19:07:24 +01:00
|
|
|
*
|
2008-04-25 16:09:27 +02:00
|
|
|
* @retval boolean true si la valeur est présente en POST, false sinon
|
2007-11-15 19:07:24 +01:00
|
|
|
*/
|
|
|
|
function getPostData(&$return) {
|
2008-04-25 16:09:27 +02:00
|
|
|
// Récupère la valeur dans _POST, et les vérifie avec la fonction générale
|
2008-02-12 18:59:44 +01:00
|
|
|
$retval = parent :: getPostData($return);
|
2008-04-25 16:09:27 +02:00
|
|
|
// Si une valeur est recupérée
|
2007-11-15 19:07:24 +01:00
|
|
|
if ($retval) {
|
2008-02-12 18:59:44 +01:00
|
|
|
$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;
|
|
|
|
}
|
|
|
|
}
|
2007-11-15 19:07:24 +01:00
|
|
|
return $retval;
|
|
|
|
}
|
|
|
|
|
2008-05-15 12:56:55 +02:00
|
|
|
/**
|
2008-04-25 16:09:27 +02:00
|
|
|
* Retourne les infos d'affichage de l'élément
|
2007-11-15 19:07:24 +01:00
|
|
|
*
|
2008-04-25 16:09:27 +02:00
|
|
|
* Cette méthode retourne les informations d'affichage de l'élement
|
2007-11-15 19:07:24 +01:00
|
|
|
*
|
2008-02-05 17:11:21 +01:00
|
|
|
* @retval array
|
2007-11-15 19:07:24 +01:00
|
|
|
*/
|
2008-02-12 18:59:44 +01:00
|
|
|
function getDisplay(){
|
2008-09-10 14:30:31 +02:00
|
|
|
$GLOBALS['LSsession'] -> addCssFile('LSformElement_password.css');
|
2008-02-12 18:59:44 +01:00
|
|
|
$return = $this -> getLabelInfos();
|
2008-10-16 14:01:26 +02:00
|
|
|
$pwd = "";
|
2008-02-12 18:59:44 +01:00
|
|
|
if (!$this -> isFreeze()) {
|
2008-10-16 14:01:26 +02:00
|
|
|
if (($this -> params['html_options']['generationTool'])&&($this -> params['html_options']['autoGenerate'])&&(empty($this -> values))) {
|
|
|
|
$pwd=$this->generatePassword();
|
2008-06-19 16:07:57 +02:00
|
|
|
}
|
2008-05-07 16:09:47 +02:00
|
|
|
|
2008-10-16 14:01:26 +02:00
|
|
|
$params = array(
|
|
|
|
'generate' => ($this -> params['html_options']['generationTool']==True),
|
|
|
|
'verify' => (!$this -> attr_html -> attribute -> ldapObject-> isNew())
|
|
|
|
);
|
|
|
|
$GLOBALS['LSsession'] -> addJSconfigParam($this -> name,$params);
|
2008-07-05 22:28:49 +02:00
|
|
|
|
2008-10-16 14:01:26 +02:00
|
|
|
$GLOBALS['LSsession'] -> addJSscript('LSformElement_password_field.js');
|
2008-07-05 22:28:49 +02:00
|
|
|
$GLOBALS['LSsession'] -> addJSscript('LSformElement_password.js');
|
2008-02-12 18:59:44 +01:00
|
|
|
}
|
2008-10-16 14:01:26 +02:00
|
|
|
$return['html'] = $this -> fetchTemplate(NULL,array('pwd' => $pwd));
|
2008-02-12 18:59:44 +01:00
|
|
|
return $return;
|
|
|
|
}
|
2008-05-07 16:09:47 +02:00
|
|
|
|
|
|
|
function generatePassword() {
|
2008-06-05 15:21:18 +02:00
|
|
|
return generatePassword($this -> params['html_options']['chars'],$this -> params['html_options']['lenght']);
|
2008-05-07 16:09:47 +02:00
|
|
|
}
|
2008-06-19 16:07:57 +02:00
|
|
|
|
|
|
|
function verifyPassword($pwd) {
|
|
|
|
if ($this -> attr_html -> attribute -> ldapObject -> isNew()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return $GLOBALS['LSsession'] -> checkUserPwd($this -> attr_html -> attribute -> ldapObject,$pwd);
|
|
|
|
}
|
2007-11-15 19:07:24 +01:00
|
|
|
}
|
2008-02-12 18:59:44 +01:00
|
|
|
|
2007-11-15 19:07:24 +01:00
|
|
|
?>
|