Merge branch 'master' of ssh://git.labs.libre-entreprise.org/gitroot/ldapsaisie

This commit is contained in:
Benjamin Renard 2010-03-09 14:58:33 +01:00
commit 0fcd8993f6
4 changed files with 145 additions and 60 deletions

View file

@ -25,6 +25,8 @@
... ...
), ),
'rdn' => 'attr1', 'rdn' => 'attr1',
'LSaddons' => [LSaddon(s)],
'container_dn' => 'ou=people', 'container_dn' => 'ou=people',
'container_auto_create' => array( 'container_auto_create' => array(
@ -81,6 +83,15 @@
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term>LSaddons</term>
<listitem>
<simpara>LSaddon(s) dont le type d'objet dépend. Ce peut être un tableau de chaînes de
caractères ou une simpe chaîne de caractères correspondant au(x) nom(s) du/des LSaddon(s)
en dépendance.</simpara>
</listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term>container_dn</term> <term>container_dn</term>
<listitem> <listitem>

View file

@ -190,7 +190,7 @@ class LSformElement {
} }
$return['label'] = $this -> getLabel(); $return['label'] = $this -> getLabel();
if (isset($this -> params['help_info'])) { if (isset($this -> params['help_info'])) {
$return['help_info']=$this -> params['help_info']; $return['help_info']=__($this -> params['help_info']);
} }
return $return; return $return;
} }

View file

@ -241,6 +241,20 @@ class LSsession {
if (!LSconfig :: set("LSobjects.$object",$GLOBALS['LSobjects'][$object])) { if (!LSconfig :: set("LSobjects.$object",$GLOBALS['LSobjects'][$object])) {
$error = 1; $error = 1;
} }
else if (isset($GLOBALS['LSobjects'][$object]['LSaddons'])){
if (is_array($GLOBALS['LSobjects'][$object]['LSaddons'])) {
foreach ($GLOBALS['LSobjects'][$object]['LSaddons'] as $addon) {
if (!self :: loadLSaddon($addon)) {
$error = 1;
}
}
}
else {
if (!self :: loadLSaddon($GLOBALS['LSobjects'][$object]['LSaddons'])) {
$error = 1;
}
}
}
} }
if ($error) { if ($error) {
LSerror :: addErrorCode('LSsession_04',$object); LSerror :: addErrorCode('LSsession_04',$object);

View file

@ -39,7 +39,7 @@
*/ */
function getFData($format,$data,$meth=NULL) { function getFData($format,$data,$meth=NULL) {
$unique=false; $unique=false;
$expr="%{([A-Za-z0-9]+)(\:(-?[0-9])+)?(\:(-?[0-9])+)?}"; $expr="%{([A-Za-z0-9]+)(\:(-?[0-9])+)?(\:(-?[0-9]+))?(-)?(\!|\_)?(~)?}";
if(!is_array($format)) { if(!is_array($format)) {
$format=array($format); $format=array($format);
$unique=true; $unique=true;
@ -54,17 +54,7 @@ function getFData($format,$data,$meth=NULL) {
else { else {
$val = $data[$ch[1]]; $val = $data[$ch[1]];
} }
if($ch[3]) { $val=_getFData_extractAndModify($val,$ch);
if ($ch[5]) {
$s=$ch[3];
$l=$ch[5];
}
else {
$s=0;
$l=$ch[3];
}
$val=substr((string)$val,$s,$l);
}
$format[$i]=ereg_replace($ch[0],$val,$format[$i]); $format[$i]=ereg_replace($ch[0],$val,$format[$i]);
} }
} }
@ -75,17 +65,7 @@ function getFData($format,$data,$meth=NULL) {
if (is_array($value)) { if (is_array($value)) {
$value = $value[0]; $value = $value[0];
} }
if($ch[3]) { $value=_getFData_extractAndModify($value,$ch);
if ($ch[5]) {
$s=$ch[3];
$l=$ch[5];
}
else {
$s=0;
$l=$ch[3];
}
$value=substr((string)$value,$s,$l);
}
$format[$i]=ereg_replace($ch[0],$value,$format[$i]); $format[$i]=ereg_replace($ch[0],$value,$format[$i]);
} }
else { else {
@ -102,17 +82,7 @@ function getFData($format,$data,$meth=NULL) {
if (is_array($value)) { if (is_array($value)) {
$value = $value[0]; $value = $value[0];
} }
if($ch[3]) { $value=_getFData_extractAndModify($value,$ch);
if ($ch[5]) {
$s=$ch[3];
$l=$ch[5];
}
else {
$s=0;
$l=$ch[3];
}
$value=substr((string)$value,$s,$l);
}
$format[$i]=ereg_replace($ch[0],$value,$format[$i]); $format[$i]=ereg_replace($ch[0],$value,$format[$i]);
} }
} }
@ -123,17 +93,7 @@ function getFData($format,$data,$meth=NULL) {
if (is_array($value)) { if (is_array($value)) {
$value = $value[0]; $value = $value[0];
} }
if($ch[3]) { $value=_getFData_extractAndModify($value,$ch);
if ($ch[5]) {
$s=$ch[3];
$l=$ch[5];
}
else {
$s=0;
$l=$ch[3];
}
$value=substr((string)$value,$s,$l);
}
$format[$i]=ereg_replace($ch[0],$value,$format[$i]); $format[$i]=ereg_replace($ch[0],$value,$format[$i]);
} }
else { else {
@ -145,20 +105,7 @@ function getFData($format,$data,$meth=NULL) {
} }
else { else {
while (ereg($expr,$format[$i],$ch)) { while (ereg($expr,$format[$i],$ch)) {
if($ch[3]) { $val=_getFData_extractAndModify($data,$ch);
if ($ch[5]) {
$s=$ch[3];
$l=$ch[5];
}
else {
$s=0;
$l=$ch[3];
}
$val=substr((string)$data,$s,$l);
}
else {
$val=$data;
}
$format[$i]=ereg_replace($ch[0],$val,$format[$i]); $format[$i]=ereg_replace($ch[0],$val,$format[$i]);
} }
} }
@ -169,6 +116,54 @@ function getFData($format,$data,$meth=NULL) {
return $format; return $format;
} }
function _getFData_extractAndModify($data,$ch) {
if($ch[3]) {
if ($ch[5]) {
if ($ch[6]) {
if ($ch[3]<0) {
$s=strlen($data)-(-1*$ch[3])-$ch[5];
$l=$ch[5];
}
else {
$s=$ch[3]-$ch[5];
$l=$ch[5];
if ($s<0) {
$l=$l-(-1*$s);
$s=0;
}
}
}
else {
$s=$ch[3];
$l=$ch[5];
}
}
else {
$s=0;
$l=$ch[3];
}
$val=substr((string)$data,$s,$l);
}
else {
$val=$data;
}
# Without Accent
if ($ch[8]) {
$val = withoutAccents($val);
}
# Upper / Lower case
if ($ch[7]=="!") {
$val=strtoupper($val);
}
elseif ($ch[7]=='_') {
$val=strtolower($val);
}
return $val;
}
function getFieldInFormat($format) { function getFieldInFormat($format) {
$fields=array(); $fields=array();
$expr="%{([A-Za-z0-9]+)(\:(-?[0-9])+)?(\:(-?[0-9])+)?}"; $expr="%{([A-Za-z0-9]+)(\:(-?[0-9])+)?(\:(-?[0-9])+)?}";
@ -470,4 +465,69 @@ function LSdebugDefined() {
} }
} }
} }
/**
* Supprime les accents d'une chaine
*
* @param[in] $string La chaine originale
*
* @retval string La chaine sans les accents
*/
function withoutAccents($string){
$replaceAccent = Array(
"à" => "a",
"á" => "a",
"â" => "a",
"ã" => "a",
"ä" => "a",
"ç" => "c",
"è" => "e",
"é" => "e",
"ê" => "e",
"ë" => "e",
"ì" => "i",
"í" => "i",
"î" => "i",
"ï" => "i",
"ñ" => "n",
"ò" => "o",
"ó" => "o",
"ô" => "o",
"õ" => "o",
"ö" => "o",
"ù" => "u",
"ú" => "u",
"û" => "u",
"ü" => "u",
"ý" => "y",
"ÿ" => "y",
"À" => "A",
"Á" => "A",
"Â" => "A",
"Ã" => "A",
"Ä" => "A",
"Ç" => "C",
"È" => "E",
"É" => "E",
"Ê" => "E",
"Ë" => "E",
"Ì" => "I",
"Í" => "I",
"Î" => "I",
"Ï" => "I",
"Ñ" => "N",
"Ò" => "O",
"Ó" => "O",
"Ô" => "O",
"Õ" => "O",
"Ö" => "O",
"Ù" => "U",
"Ú" => "U",
"Û" => "U",
"Ü" => "U",
"Ý" => "Y"
);
return strtr($string, $replaceAccent);
}
?> ?>