mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-11-19 16:49:06 +01:00
af0fef7119
-> Les noms des objets sont maintenant cliquable et nous emmènent sur la fiche de l'objet correspondant - LSformElement_select_object : -> Les noms des objets sont maintenant cliquable et nous emmènent sur la fiche de l'objet correspondant - LSformElement : -> Ajout de deux types d'élements de formulaire : -> LSformElement_mail : Adresse mail -> LSformElement_xmpp : Adresse xmpp - LSattribute : -> uniformisation des données des attributs (tous des array()) -> modifications des méthodes loadData() & reloadData() -> Correction des bugs induits par cette modification : - trunk/includes/class/class.LSattr_html_select_list.php - trunk/includes/class/class.LSldapObject.php - trunk/includes/class/class.LSattr_html_select_object.php - trunk/includes/class/class.LSattr_ldap_date.php - trunk/includes/class/class.LSsession.php - trunk/includes/addons/LSaddons.samba.php -> Correction d'un bug concernant le refresh des formulaires (#1695) -> modification de la méthode refreshForm() - LSsession : Correction d'un bug d'affichage du nom de l'utilisateur connecté
123 lines
4.5 KiB
PHP
123 lines
4.5 KiB
PHP
<?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.
|
|
|
|
******************************************************************************/
|
|
|
|
/**
|
|
* Type d'attribut HTML select_list
|
|
*
|
|
* @author Benjamin Renard <brenard@easter-eggs.com>
|
|
*/
|
|
class LSattr_html_select_list extends LSattr_html{
|
|
|
|
/**
|
|
* Ajoute l'attribut au formualaire passer en paramètre
|
|
*
|
|
* @param[in] &$form LSform Le formulaire
|
|
* @param[in] $idForm L'identifiant du formulaire
|
|
* @param[in] $data Valeur du champs du formulaire
|
|
*
|
|
* @retval LSformElement L'element du formulaire ajouté
|
|
*/
|
|
function addToForm (&$form,$idForm,$data=NULL) {
|
|
/*if (count($data)>1) {
|
|
$GLOBALS['LSerror'] -> addErrorCode(103,'select_list');
|
|
return;
|
|
}*/
|
|
$possible_values=$this -> getPossibleValues();
|
|
$this -> config['text_possible_values'] = $possible_values;
|
|
$element=$form -> addElement('select', $this -> name, $this -> config['label'],$this -> config, $this);
|
|
if(!$element) {
|
|
$GLOBALS['LSerror'] -> addErrorCode(206,$this -> name);
|
|
return;
|
|
}
|
|
if ($data) {
|
|
$element -> setValue($data);
|
|
}
|
|
|
|
// Mise en place de la regle de verification des donnees
|
|
$regex_check_data='/';
|
|
foreach ($possible_values as $val => $text) {
|
|
if($regex_check_data=='/')
|
|
$regex_check_data.='^'.preg_quote($val,'/').'$';
|
|
else
|
|
$regex_check_data.='|^'.preg_quote($val,'/').'$';
|
|
}
|
|
$regex_check_data.='/';
|
|
debug($this -> name.' : < '.$regex_check_data." ><br/>",$GLOBALS['debug_stat']);
|
|
$form -> addRule($this -> name, 'regex', array('msg'=> 'Valeur incorrect','params' => array('regex' => $regex_check_data)) );
|
|
// On retourne un pointeur vers l'element ajouter
|
|
return $element;
|
|
}
|
|
|
|
/**
|
|
* Retourne un tableau des valeurs possibles de la liste
|
|
*
|
|
* @author Benjamin Renard <brenard@easter-eggs.com>
|
|
*
|
|
* @retval array Tableau associatif des valeurs possible de la liste avec en clé
|
|
* la valeur des balises option et en valeur ce qui sera affiché.
|
|
*/
|
|
function getPossibleValues() {
|
|
$retInfos = array();
|
|
if (isset($this -> config['possible_values'])) {
|
|
foreach($this -> config['possible_values'] as $val_name => $val) {
|
|
if($val_name=='OTHER_OBJECT') {
|
|
if ((!isset($val['object_type'])) || (!isset($val['value_attribute']))) {
|
|
$GLOBALS['LSerror'] -> addErrorCode(102,$this -> name);
|
|
break;
|
|
}
|
|
if (!$GLOBALS['LSsession'] -> loadLSobject($val['object_type'])) {
|
|
$GLOBALS['LSerror'] -> addErrorCode(1004,$val['object_type']);
|
|
return;
|
|
}
|
|
$obj = new $val['object_type']();
|
|
if($val['scope']) {
|
|
$param=array('scope' => $this -> config['possible_values']['scope']);
|
|
}
|
|
else {
|
|
$param=array();
|
|
}
|
|
$list = $obj -> listObjects($val['filter'],$this -> config['possible_values']['basedn'],$param);
|
|
if(($val['value_attribute']=='dn')||($val['value_attribute']=='%{dn}')) {
|
|
for($i=0;$i<count($list);$i++) {
|
|
$retInfos[$list[$i] -> dn]=$list[$i] -> getDisplayValue($val['display_attribute']);
|
|
}
|
|
}
|
|
else {
|
|
for($i=0;$i<count($list);$i++) {
|
|
$key = $list[$i] -> attrs[$val['value_attribute']] -> getValue();
|
|
$retInfos[$key[0]]=$list[$i] -> getDisplayValue($val['display_attribute']);
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
$val_name=$this->attribute->ldapObject->getFData($val_name);
|
|
$val=$this->attribute->ldapObject->getFData($val);
|
|
$retInfos[$val_name]=$val;
|
|
}
|
|
}
|
|
}
|
|
return $retInfos;
|
|
}
|
|
|
|
}
|
|
|
|
?>
|