- LSrelation :

-> 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é
This commit is contained in:
Benjamin Renard 2008-07-31 09:16:25 +00:00
parent c857c680a4
commit af0fef7119
23 changed files with 402 additions and 23 deletions

View file

@ -256,7 +256,7 @@ $GLOBALS['LSobjects']['LSeepeople'] = array (
'mail' => array (
'label' => _('Adresse e-mail'),
'ldap_type' => 'ascii',
'html_type' => 'text',
'html_type' => 'mail',
'html_options' => array(
'generate_value_format' => '%{uid}@ls.com',
'autoGenerateOnModify' => true

View file

@ -163,8 +163,9 @@
$GLOBALS['LSerror'] -> addErrorCode('SAMBA_02',array('dependency' => LS_SAMBA_GIDNUMBER_ATTR, 'attr' => 'sambaPrimaryGroupSID'));
return;
}
$gidNumber = $ldapObject -> attrs[ LS_SAMBA_GIDNUMBER_ATTR ] -> getValue() * 2 + LS_SAMBA_SID_BASE_GROUP;
$gidNumber = $ldapObject -> attrs[ LS_SAMBA_GIDNUMBER_ATTR ] -> getValue();
$gidNumber = $gidNumber[0] * 2 + LS_SAMBA_SID_BASE_GROUP;
$sambaPrimaryGroupSID = LS_SAMBA_DOMAIN_SID . '-' . $gidNumber;
return ($sambaPrimaryGroupSID);

View file

@ -0,0 +1,53 @@
<?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 mail
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*/
class LSattr_html_mail 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) {
$element=$form -> addElement('mail', $this -> name, $this -> config['label'],$this -> config, $this);
if(!$element) {
$GLOBALS['LSerror'] -> addErrorCode(206,$this -> name);
return;
}
if ($data) {
$element -> setValue($data);
}
return $element;
}
}
?>

View file

@ -103,7 +103,8 @@ class LSattr_html_select_list extends LSattr_html{
}
else {
for($i=0;$i<count($list);$i++) {
$retInfos[$list[$i] -> attrs[$val['value_attribute']] -> getValue()]=$list[$i] -> getDisplayValue($val['display_attribute']);
$key = $list[$i] -> attrs[$val['value_attribute']] -> getValue();
$retInfos[$key[0]]=$list[$i] -> getDisplayValue($val['display_attribute']);
}
}
}

View file

@ -114,7 +114,9 @@ class LSattr_html_select_object extends LSattr_html{
}
else {
for($i=0;$i<count($list);$i++) {
$retInfos[$list[$i] -> attrs[$val['value_attribute']] -> getValue()]=$list[$i] -> getDisplayValue($conf['display_attribute']);
$key = $val['value_attribute'] -> getValue();
$key = $key[0];
$retInfos[$list[$i] -> attrs[$key]]=$list[$i] -> getDisplayValue($conf['display_attribute']);
$DNs[]=$list[$i] -> dn;
}
}
@ -156,7 +158,9 @@ class LSattr_html_select_object extends LSattr_html{
$retInfos[$obj -> dn]=$obj -> getDisplayValue($conf['display_attribute']);
}
else {
$retInfos[$obj -> attrs[$val['value_attribute']] -> getValue()]=$obj -> getDisplayValue($conf['display_attribute']);
$key = $val['value_attribute'] -> getValue();
$key = $key[0];
$retInfos[$obj -> attrs[$key]]=$obj -> getDisplayValue($conf['display_attribute']);
}
$DNs[]=$dn;
}

View file

@ -0,0 +1,53 @@
<?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 xmpp
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*/
class LSattr_html_xmpp 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) {
$element=$form -> addElement('xmpp', $this -> name, $this -> config['label'],$this -> config, $this);
if(!$element) {
$GLOBALS['LSerror'] -> addErrorCode(206,$this -> name);
return;
}
if ($data) {
$element -> setValue($data);
}
return $element;
}
}
?>

View file

@ -34,12 +34,17 @@ class LSattr_ldap_date extends LSattr_ldap {
* @retval mixed La valeur d'affichage de l'attribut
*/
function getDisplayValue($data) {
$date = strptime($data,$this -> getFormat());
if (is_array($date)) {
return mktime($date['tm_hour'],$date['tm_min'],$date['tm_sec'],$date['tm_mon']+1,$date['tm_mday'],$date['tm_year']+1900);
if(!is_array($data)) {
$data=array($data);
}
else
return;
$retval=array();
foreach($data as $val) {
$date = strptime($val,$this -> getFormat());
if (is_array($date)) {
$retval[] = mktime($date['tm_hour'],$date['tm_min'],$date['tm_sec'],$date['tm_mon']+1,$date['tm_mday'],$date['tm_year']+1900);
}
}
return $retval;
}
/**

View file

@ -100,6 +100,9 @@ class LSattribute {
* @retval boolean true
*/
function loadData($attr_data) {
if ((!is_array($attr_data))&&(!empty($attr_data))) {
$attr_data = array($attr_data);
}
$this -> data = $attr_data;
return true;
}
@ -112,6 +115,9 @@ class LSattribute {
* @retval boolean true
*/
function reloadData($attr_data) {
if ((!is_array($attr_data))&&(!empty($attr_data))) {
$attr_data = array($attr_data);
}
$this -> data = $attr_data;
$this -> updateData=false;
$this -> is_validate=false;
@ -315,7 +321,7 @@ class LSattribute {
* @retval boolean true si la valeur a été rafraichie ou que ce n'est pas nécessaire, false sinon
*/
function refreshForm(&$form,$idForm) {
if(isset($this -> config['form'][$idForm]) && ($this -> myRights()=='w')) {
if(isset($this -> config['form'][$idForm])) {
$form_element = $form -> getElement($this -> name);
$values = $this -> html -> refreshForm($this -> getFormVal());
return $form_element -> setValue($values);

View file

@ -149,7 +149,6 @@ class LSformElement_date extends LSformElement {
$GLOBALS['LSsession'] -> addJSscript('calendar-en.js',LS_LIB_DIR.'jscalendar/lang/');
$codeLang = strtolower($GLOBALS['LSconfig']['lang'][0].$GLOBALS['LSconfig']['lang'][1]);
$GLOBALS['LSsession'] -> addJSscript('calendar-'.$codeLang.'.js',LS_LIB_DIR.'jscalendar/lang/');
//$GLOBALS['LSsession'] -> addJSscript('calendar-setup.js',LS_LIB_DIR.'jscalendar/');
$GLOBALS['LSsession'] -> addJSscript('LSformElement_date_field.js');
$GLOBALS['LSsession'] -> addJSscript('LSformElement_date.js');
}

View file

@ -0,0 +1,87 @@
<?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 mail d'un formulaire pour LdapSaisie
*
* Cette classe définis les éléments textes des formulaires.
* Elle étant la classe basic LSformElement.
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*/
class LSformElement_mail extends LSformElement {
/**
* Retourne les infos d'affichage de l'élément
*
* Cette méthode retourne les informations d'affichage de l'élement
*
* @retval array
*/
function getDisplay(){
$return = $this -> getLabelInfos();
// value
if (!$this -> isFreeze()) {
$return['html'] = "<ul class='LSform'>\n";
if (empty($this -> values)) {
$return['html'] .= "<li>".$this -> getEmptyField()."</li>\n";
}
else {
foreach ($this -> values as $value) {
$multiple = $this -> getMultipleData();
$id = "LSform_".$this -> name."_".rand();
$return['html'] .= "<li><input type='text' name='".$this -> name."[]' value=\"".$value."\" id='".$id."'><img src='templates/images/mail.png' class='LSformElement_mail_btn btn' alt='"._('Envoyer un mail.')."' title='"._('Envoyer un mail.')."'/>".$multiple."</li>\n";
}
}
$return['html'] .= "</ul>\n";
$GLOBALS['LSsession'] -> addJSscript('LSformElement_mail.js');
}
else {
$return['html'] = "<ul class='LSform'>\n";
if (empty($this -> values)) {
$return['html'] .= "<li>"._('Aucune valeur definie')."</li>\n";
}
else {
foreach ($this -> values as $value) {
$return['html'] .= "<li><a href='mailto:".$value."'>".$value."</a><img src='templates/images/mail.png' alt='"._('Envoyer un mail.')."' title='"._('Envoyer un mail.')."' class='LSformElement_mail_btn btn'></li>\n";
$GLOBALS['LSsession'] -> addJSscript('LSformElement_mail.js');
}
}
$return['html'] .= "</ul>\n";
}
return $return;
}
/**
* Retourne le code HTML d'un champ vide
*
* @retval string Code HTML d'un champ vide.
*/
function getEmptyField() {
$multiple = $this -> getMultipleData();
return "<input type='text' name='".$this -> name."[]' id='LSform_".$this -> name."_".rand()."'><img src='templates/images/go.png' class='LSformElement_mail_btn btn' alt='"._('Envoyer un mail.')."' title='"._('Envoyer un mail.')."'/>".$multiple;
}
}
?>

View file

@ -50,7 +50,7 @@ class LSformElement_select_object extends LSformElement {
if (!$this -> isFreeze()) {
$addBtn="<li class='LSform LSformElement_select_object_addBtn'>
<a href='select.php?LSobject=".$this -> selectableObject."' class='LSformElement_select_object_addBtn' id='a_LSformElement_select_object_".$this -> name."_$id'>"._('Modifier')."</a>\n
<a href='select.php?LSobject=".$this -> selectableObject."' class='LSformElement_select_object LSformElement_select_object_addBtn' id='a_LSformElement_select_object_".$this -> name."_$id'>"._('Modifier')."</a>\n
<input type='hidden' name='LSformElement_select_object_objecttype' id='LSformElement_select_object_objecttype_$id' value='".$this -> selectableObject."' />\n
</li>\n";
$delete=" <img src='templates/images/delete.png' alt='"._('Supprimer')."' class='LSformElement_select_object_deleteBtn'/>";
@ -65,7 +65,7 @@ class LSformElement_select_object extends LSformElement {
$return['html']="<ul class='LSform ".$class."' id='LSformElement_select_object_".$this -> name."_$id'>\n";
$return['html'].=$addBtn;
foreach ($this -> values as $value => $txt) {
$return['html'].="<li class='LSform ".$class."'>".$txt."<input type='hidden' class='LSformElement_select_object' name='".$this -> name."[]' value='".$value."' />$delete</li>\n";
$return['html'].="<li class='LSform ".$class."'><a href='view.php?LSobject=".$this -> selectableObject."&amp;dn=".$value."' title='"._('Voir')." ' class='LSformElement_select_object'>".$txt."</a><input type='hidden' class='LSformElement_select_object' name='".$this -> name."[]' value='".$value."' />$delete</li>\n";
}
$return['html'].="</ul>\n";
if (!$this -> isFreeze()) {

View file

@ -0,0 +1,87 @@
<?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 xmpp d'un formulaire pour LdapSaisie
*
* Cette classe définis les éléments textes des formulaires.
* Elle étant la classe basic LSformElement.
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*/
class LSformElement_xmpp extends LSformElement {
/**
* Retourne les infos d'affichage de l'élément
*
* Cette méthode retourne les informations d'affichage de l'élement
*
* @retval array
*/
function getDisplay(){
$return = $this -> getLabelInfos();
// value
if (!$this -> isFreeze()) {
$return['html'] = "<ul class='LSform'>\n";
if (empty($this -> values)) {
$return['html'] .= "<li>".$this -> getEmptyField()."</li>\n";
}
else {
foreach ($this -> values as $value) {
$multiple = $this -> getMultipleData();
$id = "LSform_".$this -> name."_".rand();
$return['html'] .= "<li><input type='text' name='".$this -> name."[]' value=\"".$value."\" id='".$id."'><img src='templates/images/xmpp.png' class='LSformElement_xmpp_btn btn' alt='"._('Dialoguer')."' title='"._('Dialoguer')."'/>".$multiple."</li>\n";
}
}
$return['html'] .= "</ul>\n";
$GLOBALS['LSsession'] -> addJSscript('LSformElement_xmpp.js');
}
else {
$return['html'] = "<ul class='LSform'>\n";
if (empty($this -> values)) {
$return['html'] .= "<li>"._('Aucune valeur definie')."</li>\n";
}
else {
foreach ($this -> values as $value) {
$return['html'] .= "<li><a href='xmpp:".$value."'>".$value."</a><img src='templates/images/xmpp.png' alt='"._('Dialoguer')."' title='"._('Dialoguer')."' class='LSformElement_xmpp_btn btn'></li>\n";
$GLOBALS['LSsession'] -> addJSscript('LSformElement_xmpp.js');
}
}
$return['html'] .= "</ul>\n";
}
return $return;
}
/**
* Retourne le code HTML d'un champ vide
*
* @retval string Code HTML d'un champ vide.
*/
function getEmptyField() {
$multiple = $this -> getMultipleData();
return "<input type='text' name='".$this -> name."[]' id='LSform_".$this -> name."_".rand()."'><img src='templates/images/go.png' class='LSformElement_xmpp_btn btn' alt='"._('Dialoguer')."' title='"._('Dialoguer')."'/>".$multiple;
}
}
?>

View file

@ -356,13 +356,14 @@ class LSldapObject {
function validateAttrsData($idForm) {
$LSform=$this -> forms[$idForm][0];
foreach($this -> attrs as $attr) {
$attr_values = $attr -> getValue();
if (!$attr -> isValidate()) {
if($attr -> isUpdate()) {
if (!$this -> validateAttrData($LSform, $attr)) {
return;
}
}
else if( ($attr -> getValue() == '') && ($attr -> isRequired()) ) {
else if( (empty($attr_values)) && ($attr -> isRequired()) ) {
if ( $attr -> canBeGenerated()) {
if ($attr -> generateValue()) {
if (!$this -> validateAttrData($LSform, $attr)) {

View file

@ -295,7 +295,9 @@ class LSsession {
$result = $authobject -> listObjects($filter,$this -> topDn);
$nbresult=count($result);
if ($nbresult==1) {
$_POST['LSsession_user'] = $result[0] -> getValue('rdn');
$rdn = $result[0] -> getValue('rdn');
$rdn = $rdn[0];
$_POST['LSsession_user'] = $rdn;
$find=false;
}
}
@ -319,6 +321,7 @@ class LSsession {
debug('Récupération active');
$user=$result[0];
$emailAddress = $user -> getValue($this -> ldapServer['recoverPassword']['mailAttr']);
$emailAddress = $emailAddress[0];
// Header des mails
$headers="Content-Type: text/plain; charset=UTF-8; format=flowed";
@ -335,7 +338,9 @@ class LSsession {
// 1ère étape : envoie du recoveryHash
if (!isset($_GET['recoveryHash'])) {
// Generer un hash
$recovery_hash = md5($user -> getValue('rdn') . strval(time()) . strval(rand()));
$rdn=$user -> getValue('rdn');
$rdn = $rdn[0];
$recovery_hash = md5($rdn . strval(time()) . strval(rand()));
$lostPasswdForm = $user -> getForm('lostPassword');
$lostPasswdForm -> setPostData(
@ -453,7 +458,7 @@ class LSsession {
$this -> rdn = $_POST['LSsession_user'];
$this -> loadLSrights();
$this -> loadLSaccess();
$GLOBALS['Smarty'] -> assign('LSsession_username',$this -> LSuserObject -> getValue('rdn'));
$GLOBALS['Smarty'] -> assign('LSsession_username',$this -> LSuserObject -> getDisplayValue());
$_SESSION['LSsession']=get_object_vars($this);
return true;
}

View file

@ -0,0 +1,34 @@
var LSformElement_mail = new Class({
initialize: function(){
this.initialiseLSformElement_mail();
if (typeof(varLSform) != "undefined") {
varLSform.addModule("LSformElement_mail",this);
}
},
initialiseLSformElement_mail: function(el) {
if (typeof(el) == 'undefined') {
el = document;
}
el.getElements('img.LSformElement_mail_btn').each(function(btn) {
btn.addEvent('click',this.onBtnClick.bind(this,btn));
}, this);
},
reinitialize: function(el) {
this.initialiseLSformElement_mail(el);
},
onBtnClick: function(btn) {
var href = btn.getParent().getFirst().href;
if (typeof(href)=="undefined") {
href = 'mailto:'+btn.getParent().getFirst().value;
}
if (href!="") {
location.href = href;
}
}
});
window.addEvent(window.ie ? 'load' : 'domready', function() {
varLSformElement_mail = new LSformElement_mail();
});

View file

@ -0,0 +1,34 @@
var LSformElement_xmpp = new Class({
initialize: function(){
this.initialiseLSformElement_xmpp();
if (typeof(varLSform) != "undefined") {
varLSform.addModule("LSformElement_xmpp",this);
}
},
initialiseLSformElement_xmpp: function(el) {
if (typeof(el) == 'undefined') {
el = document;
}
el.getElements('img.LSformElement_xmpp_btn').each(function(btn) {
btn.addEvent('click',this.onBtnClick.bind(this,btn));
}, this);
},
reinitialize: function(el) {
this.initialiseLSformElement_xmpp(el);
},
onBtnClick: function(btn) {
var href = btn.getParent().getFirst().href;
if (typeof(href)=="undefined") {
href = 'xmpp:'+btn.getParent().getFirst().value;
}
if (href!="") {
location.href = href;
}
}
});
window.addEvent(window.ie ? 'load' : 'domready', function() {
varLSformElement_xmpp = new LSformElement_xmpp();
});

View file

@ -182,7 +182,7 @@ if (!isset($_ERRORS)) {
$list = $objRel -> $relationConf['list_function']($object);
if (is_array($list)) {
foreach($list as $o) {
$data['html'].= "<li class='LSrelation'><span id='".$o -> getDn()."'>".$o -> getDisplayValue(NULL,true)."</span></li>\n";
$data['html'].= "<li class='LSrelation'><a href='view.php?LSobject=".$relationConf['LSobject']."&amp;dn=".$o -> getDn()."' class='LSrelation'><span id='".$o -> getDn()."'>".$o -> getDisplayValue(NULL,true)."</span></li>\n";
}
}
else {

View file

@ -8,6 +8,6 @@
{/if}
<ul id='LSrelation_ul_{$item.id}' class='LSrelation'>
{foreach from=$item.objectList item=object}
<li class='LSrelation'><span id='{$object.dn}'>{$object.text}</span></li>
<li class='LSrelation'><a href='view.php?LSobject={$item.LSobject}&amp;dn={$object.dn}' class='LSrelation'><span id='{$object.dn}'>{$object.text}</span></a></li>
{/foreach}
</ul>

View file

@ -73,7 +73,7 @@ img.LSform-add-field-btn, img.LSform-remove-field-btn {
/*
* LSformElement_select_object
*/
a.LSformElement_select_object_addBtn {
a.LSformElement_select_object {
text-decoration: none;
color: #000;
font-weight: normal;

View file

@ -6,3 +6,9 @@
img.LSrelation-btn {
margin-left: 0.5em;
}
a.LSrelation {
text-decoration: none;
color: #000;
font-weight: normal;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 641 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 743 B

View file

@ -83,7 +83,10 @@ if($LSsession -> startLSsession()) {
$LSrelations=array();
foreach($object -> config['relations'] as $relationName => $relationConf) {
if ($GLOBALS['LSsession'] -> relationCanAccess($object -> getValue('dn'),$relationName)) {
$return=array('label' => $relationConf['label']);
$return=array(
'label' => $relationConf['label'],
'LSobject' => $relationConf['LSobject']
);
$id=rand();
$return['id']=$id;