mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-11-22 09:59:06 +01:00
Add support for supannMailPrive, supannAdressePostalePrivee and supannTelephonePrive attributes
This commit is contained in:
parent
077a44fdf9
commit
0ac0a7e068
13 changed files with 637 additions and 209 deletions
|
@ -92,22 +92,46 @@ $GLOBALS['LS_SUPANN_CIVILITES'] = array (
|
|||
* ),
|
||||
* );
|
||||
*
|
||||
* [ETIQUETTE] : l'étiquette de la valeur
|
||||
* [ETIQUETTE] : l'étiquette de la valeur (correspondant le plus souvent ou mainteneur de la nomenclature)
|
||||
* [table] : le nom de la table :
|
||||
* - roleGenerique : les rôles génériques
|
||||
* - typeEntite : les types d'entités
|
||||
* - empCorps : les corps d'appartenances des personnels
|
||||
* - codeEtablissement : les codes d'établissement
|
||||
* - etuRegimeInscription : les régimes d'inscription étudiant
|
||||
* - etuSecteurDisciplinaire : les secteurs disciplinaires de dîplomes ou d'enseignements
|
||||
* - etuTypeDiplome : les types de diplôme
|
||||
* - etuDiplome : les diplômes
|
||||
* - etuEtape : les étapes des enseignements
|
||||
* - etuElementPedagogique : les éléments pédagogiques
|
||||
* - mailPriveLabel: le label des mails privés des personnes (supannMailPrive)
|
||||
* - adressePostalePriveeLabel: le label des adresses privées des personnes (supannAdressePostalePrivee)
|
||||
* - telephonePriveLabel: le label des télépgones privés des personnes (supannTelephonePrive)
|
||||
* - roleGenerique : les rôles génériques (supannRoleGenerique)
|
||||
* - typeEntite : les types d'entités (supannTypeEntite)
|
||||
* - empCorps : les corps d'appartenances des personnels (supannEmpCorps)
|
||||
* - codeEtablissement : les codes d'établissement (supannEtablissement)
|
||||
* - etuRegimeInscription : les régimes d'inscription étudiant (supannEtuRegimeInscription)
|
||||
* - etuSecteurDisciplinaire : les secteurs disciplinaires de dîplomes ou d'enseignements (supannEtuSecteurDisciplinaire)
|
||||
* - etuTypeDiplome : les types de diplôme (supannEtuTypeDiplome)
|
||||
* - etuDiplome : les diplômes (supannEtuDiplome)
|
||||
* - etuEtape : les étapes des enseignements (supannEtuEtape)
|
||||
* - etuElementPedagogique : les éléments pédagogiques (supannEtuElementPedagogique)
|
||||
*
|
||||
*/
|
||||
$GLOBALS['supannNomenclatures'] = array (
|
||||
'SUPANN' => array (
|
||||
'mailPriveLabel' => array (
|
||||
'SECOURS' => ___('Backup'),
|
||||
'PERSO' => ___('Personal'),
|
||||
'PARENTS' => ___('Parents'),
|
||||
'PRO' => ___('Professional'),
|
||||
),
|
||||
'adressePostalePriveeLabel' => array (
|
||||
'TEMP' => ___('Temporary'),
|
||||
'PERSO' => ___('Personal'),
|
||||
'PARENTS' => ___('Parents'),
|
||||
'PRO' => ___('Professional'),
|
||||
),
|
||||
'telephonePriveLabel' => array (
|
||||
'MOBPERSO' => ___('Personal mobile'),
|
||||
'FIXEPERSO' => ___('Personal landline'),
|
||||
'FIXEPARENTS' => ___('Parents landline'),
|
||||
'MOBPARENTS' => ___('Parents mobile'),
|
||||
'MOBPRO' => ___('Professional mobile'),
|
||||
'FIXEPRO' => ___('Professional landline'),
|
||||
'SECOURS' => ___('Backup'),
|
||||
),
|
||||
'roleGenerique' => array (
|
||||
"D00" => "MINISTRE",
|
||||
"D01" => "DIRECTEUR DU CABINET",
|
||||
|
|
|
@ -22,3 +22,25 @@ div.supannLabeledValue_possibleValues li:hover {
|
|||
background-color: #CCC;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
pre.LSformElement_supannLabeledValue_value {
|
||||
display: inline-block;
|
||||
font-family: 'Lucida Grande', Verdana, Arial, Sans-Serif;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
@media (min-width: 401px) {
|
||||
select.LSformElement_supannLabeledValue_label, input.LSformElement_supannLabeledValue_label, span.LSformElement_supannLabeledValue_label {
|
||||
width: 50px;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
input.LSformElement_supannLabeledValue_value, textarea.LSformElement_supannLabeledValue_value {
|
||||
scrollbar-width: thin;
|
||||
width: calc(150px - 1em);
|
||||
}
|
||||
|
||||
textarea.LSformElement_supannLabeledValue_value {
|
||||
height: 5em;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -198,7 +198,7 @@ td.LSobject-list, tr.LSobject-list, table.LStable tbody td, table.LStable th {
|
|||
padding: 2px;
|
||||
}
|
||||
|
||||
.LSform input[type=text], .LSform input[type=password], .LSform select, .LSform textarea, ul.LSformElement_text_autocomplete, ul.LSformElement_select_object_edit, div.LSformElement_wysiwyg_container, ul.LSformElement_jsonCompositeAttribute:not(.LSformElement_jsonCompositeAttribute_fullWidth), dd.LSform-errors {
|
||||
.LSform input[type=text], .LSform input[type=password], .LSform select, .LSform textarea, ul.LSformElement_text_autocomplete, ul.LSformElement_select_object_edit, div.LSformElement_wysiwyg_container, ul.LSformElement_jsonCompositeAttribute:not(.LSformElement_jsonCompositeAttribute_fullWidth), dd.LSform-errors, input.LSformElement_supannLabeledValue_search {
|
||||
width: 32vw;
|
||||
}
|
||||
|
||||
|
@ -234,6 +234,14 @@ td.LSobject-list, tr.LSobject-list, table.LStable tbody td, table.LStable th {
|
|||
width: calc(32vw - 8em);
|
||||
}
|
||||
|
||||
.LSform select.LSformElement_supannLabeledValue_label, .LSform input.LSformElement_supannLabeledValue_label {
|
||||
width: 6em;
|
||||
}
|
||||
|
||||
.LSform input.LSformElement_supannLabeledValue_value, textarea.LSformElement_supannLabeledValue_value {
|
||||
width: calc(32vw - 14rem);
|
||||
}
|
||||
|
||||
input.LSformElement_select_object_searchAdd, ul.LSformElement_select_object_searchAdd {
|
||||
width: 17vw!important;
|
||||
box-sizing: border-box;
|
||||
|
|
|
@ -381,19 +381,40 @@ LSerror :: defineError('SUPANN_03',
|
|||
* Vérifie si une valeur et son étiquette sont valide pour une table donnée
|
||||
*
|
||||
* @param[in] $table La table de nomenclature
|
||||
* @param[in] $label L'étiquette de la valeur
|
||||
* @param[in] $label L'étiquette de la valeur (optionnel)
|
||||
* @param[in] $value La valeur
|
||||
*
|
||||
* @retval booleab True si valide, False sinon
|
||||
**/
|
||||
function supannValidateNomenclatureValue($table,$label,$value) {
|
||||
$label=strtoupper($label);
|
||||
if (isset($GLOBALS['supannNomenclatures'][$label]) &&
|
||||
isset($GLOBALS['supannNomenclatures'][$label][$table]) &&
|
||||
isset($GLOBALS['supannNomenclatures'][$label][$table][$value])) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
function supannValidateNomenclatureValue($table, $label, $value) {
|
||||
if ($label) {
|
||||
$label = strtoupper($label);
|
||||
if (
|
||||
isset($GLOBALS['supannNomenclatures'][$label]) &&
|
||||
isset($GLOBALS['supannNomenclatures'][$label][$table]) &&
|
||||
isset($GLOBALS['supannNomenclatures'][$label][$table][$value])
|
||||
) {
|
||||
return array(
|
||||
'table' => $table,
|
||||
'label' => $label,
|
||||
'value' => $value,
|
||||
'translated' => $GLOBALS['supannNomenclatures'][$label][$table][$value],
|
||||
);
|
||||
}
|
||||
}
|
||||
else {
|
||||
foreach($GLOBALS['supannNomenclatures'] as $label => $tables) {
|
||||
if (!array_key_exists($table, $tables) || !array_key_exists($value, $tables[$table]))
|
||||
continue;
|
||||
return array(
|
||||
'table' => $table,
|
||||
'label' => $label,
|
||||
'value' => $value,
|
||||
'translated' => $tables[$table][$value],
|
||||
);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -401,33 +422,57 @@ LSerror :: defineError('SUPANN_03',
|
|||
* et de l'étiquette de la valeur.
|
||||
*
|
||||
* @param[in] $table La table de nomenclature
|
||||
* @param[in] $label L'étiquette de la valeur
|
||||
* @param[in] $label L'étiquette de la valeur (optionnel)
|
||||
* @param[in] $value La valeur
|
||||
*
|
||||
* @retval array Le label de la valeur. En cas de valeur nor-reconnue, retourne
|
||||
* la valeur en spécifiant qu'elle n'est pas reconnue.
|
||||
**/
|
||||
function supannGetNomenclatureLabel($table,$label,$value) {
|
||||
if (supannValidateNomenclatureValue($table,$label,$value)) {
|
||||
$label=strtoupper($label);
|
||||
return $GLOBALS['supannNomenclatures'][$label][$table][$value];
|
||||
}
|
||||
return getFData(__("%{value} (unrecognized value)"),$value);
|
||||
function supannGetNomenclatureLabel($table, $label, $value) {
|
||||
$translated = supannValidateNomenclatureValue($table, $label, $value);
|
||||
if ($translated)
|
||||
return $translated['translated'];
|
||||
return getFData(__("%{value} (unrecognized value)"), $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne les valeurs possibles d'une table de nomenclature pour chaque fournisseur
|
||||
*
|
||||
* @param[in] $table La table de nomenclature
|
||||
*
|
||||
* @retval array Tableau contenant pour chaque fournisseur, les valeurs possibles de
|
||||
* la table de nomenclature
|
||||
**/
|
||||
function supannGetNomenclatureTable($table) {
|
||||
$retval=array();
|
||||
foreach(array_keys($GLOBALS['supannNomenclatures']) as $provider) {
|
||||
if (isset($GLOBALS['supannNomenclatures'][$provider][$table])) {
|
||||
$retval[$provider] = $GLOBALS['supannNomenclatures'][$provider][$table];
|
||||
}
|
||||
}
|
||||
return $retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne les valeurs possibles d'une table de nomenclature
|
||||
*
|
||||
* @param[in] $table La table de nomenclature
|
||||
* @param[in] $add_provider_label Booléen définissant si le fournisseur de la valeur
|
||||
* doit être ajouté en tant qu'étiquette de la valeur
|
||||
* (optinel, par défaut: vrai)
|
||||
*
|
||||
* @retval array Tableau contenant les valeurs possibles de la table
|
||||
* de nomenclature
|
||||
**/
|
||||
function supannGetNomenclatureTable($table) {
|
||||
$retval=array();
|
||||
foreach($GLOBALS['supannNomenclatures'] as $label => $tables) {
|
||||
if (isset($GLOBALS['supannNomenclatures'][$label][$table])) {
|
||||
$retval[$label]=$GLOBALS['supannNomenclatures'][$label][$table];
|
||||
function supannGetNomenclaturePossibleValues($table, $add_provider_label=True) {
|
||||
$retval = array();
|
||||
foreach(array_keys($GLOBALS['supannNomenclatures']) as $provider) {
|
||||
if (isset($GLOBALS['supannNomenclatures'][$provider][$table])) {
|
||||
foreach($GLOBALS['supannNomenclatures'][$provider][$table] as $value => $label) {
|
||||
if ($add_provider_label)
|
||||
$value = "{$provider}$value";
|
||||
$retval[$value] = __($label);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $retval;
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
/*******************************************************************************
|
||||
* Copyright (C) 2021 Easter-eggs
|
||||
* https://ldapsaisie.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 supannAdressePostalePrivee
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*/
|
||||
class LSattr_html_supannAdressePostalePrivee extends LSattr_html {
|
||||
|
||||
var $LSformElement_type = 'supannAdressePostalePrivee';
|
||||
|
||||
}
|
32
src/includes/class/class.LSattr_html_supannMailPrive.php
Normal file
32
src/includes/class/class.LSattr_html_supannMailPrive.php
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
/*******************************************************************************
|
||||
* Copyright (C) 2021 Easter-eggs
|
||||
* https://ldapsaisie.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 supannMailPrive
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*/
|
||||
class LSattr_html_supannMailPrive extends LSattr_html {
|
||||
|
||||
var $LSformElement_type = 'supannMailPrive';
|
||||
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
/*******************************************************************************
|
||||
* Copyright (C) 2021 Easter-eggs
|
||||
* https://ldapsaisie.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 supannTelephonePrive
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*/
|
||||
class LSattr_html_supannTelephonePrive extends LSattr_html {
|
||||
|
||||
var $LSformElement_type = 'supannTelephonePrive';
|
||||
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
<?php
|
||||
/*******************************************************************************
|
||||
* Copyright (C) 2021 Easter-eggs
|
||||
* https://ldapsaisie.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.
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
LSsession :: loadLSclass('LSformElement_supannLabeledValue');
|
||||
LSsession :: loadLSaddon('supann');
|
||||
|
||||
/**
|
||||
* Element supannAdressePostalePrivee d'un formulaire pour LdapSaisie
|
||||
*
|
||||
* Cette classe définis les éléments supannAdressePostalePrivee des formulaires.
|
||||
* Elle etant la classe basic LSformElement_supannLabeledValue.
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*/
|
||||
|
||||
class LSformElement_supannAdressePostalePrivee extends LSformElement_supannLabeledValue {
|
||||
|
||||
var $supannLabelNomenclatureTable = 'adressePostalePriveeLabel';
|
||||
var $valueFieldType = 'textarea';
|
||||
|
||||
|
||||
/**
|
||||
* Parse une valeur
|
||||
*
|
||||
* @param[in] $value La valeur
|
||||
*
|
||||
* @retval array Un tableau cle->valeur contenant value, translated et label
|
||||
**/
|
||||
public function parseValue($value) {
|
||||
$retval = parent :: parseValue($value);
|
||||
$retval['value'] = str_replace('$', "\n", $retval['value']);
|
||||
$retval['translated'] = str_replace('$', "\n", $retval['translated']);
|
||||
return $retval;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Recupère la valeur de l'élement passée en POST
|
||||
*
|
||||
* Cette méthode s'occupe de remplacer les retour à la ligne dans les valeur de l'attribut
|
||||
* pas des caractères '$'.
|
||||
|
||||
* @see LSformElement::getPostData()
|
||||
* @retval boolean true si la valeur est présente en POST, false sinon
|
||||
*/
|
||||
public function getPostData(&$return, $onlyIfPresent=false) {
|
||||
$retval = parent :: getPostData($return, $onlyIfPresent);
|
||||
if (isset($return[$this -> name])) {
|
||||
$fixed_values = array();
|
||||
foreach($return[$this -> name] as $value)
|
||||
$fixed_values[] = str_replace("\n", "$", $value);
|
||||
$return[$this -> name] = $fixed_values;
|
||||
}
|
||||
return $retval;
|
||||
}
|
||||
|
||||
}
|
|
@ -38,6 +38,10 @@ class LSformElement_supannLabeledValue extends LSformElement {
|
|||
var $fieldTemplate = 'LSformElement_supannLabeledValue_field.tpl';
|
||||
|
||||
var $supannNomenclatureTable = null;
|
||||
var $supannLabelNomenclatureTable = null;
|
||||
|
||||
// HTML field type: text or textarea (only for field without nomenclature table)
|
||||
var $valueFieldType = 'text';
|
||||
|
||||
/**
|
||||
* Retourne les infos d'affichage de l'élément
|
||||
|
@ -53,12 +57,25 @@ class LSformElement_supannLabeledValue extends LSformElement {
|
|||
foreach($this -> values as $val) {
|
||||
$parseValues[]=$this -> parseValue($val);
|
||||
}
|
||||
$return['html'] = $this -> fetchTemplate(NULL,array('parseValues' => $parseValues));
|
||||
$possibleLabels = (
|
||||
$this -> supannLabelNomenclatureTable?
|
||||
supannGetNomenclaturePossibleValues($this -> supannLabelNomenclatureTable, false):
|
||||
null
|
||||
);
|
||||
$return['html'] = $this -> fetchTemplate(
|
||||
NULL, array(
|
||||
'parseValues' => $parseValues,
|
||||
'nomenclatureTable' => $this -> supannNomenclatureTable,
|
||||
'possibleLabels' => $possibleLabels,
|
||||
'valueFieldType' => $this -> valueFieldType,
|
||||
)
|
||||
);
|
||||
LStemplate :: addCssFile('LSformElement_supannLabeledValue.css');
|
||||
if (!$this -> isFreeze()) {
|
||||
LStemplate :: addJSconfigParam(
|
||||
$this -> name,
|
||||
array(
|
||||
'nomenclatureTable' => boolval($this -> supannNomenclatureTable),
|
||||
'searchBtn' => _('Modify'),
|
||||
'noValueLabel' => _('No set value'),
|
||||
'noResultLabel' => _('No result'),
|
||||
|
@ -80,13 +97,18 @@ class LSformElement_supannLabeledValue extends LSformElement {
|
|||
* @retval array Un tableau cle->valeur contenant value, translated et label
|
||||
**/
|
||||
public function parseValue($value) {
|
||||
$retval=array(
|
||||
$retval = array(
|
||||
'value' => $value,
|
||||
);
|
||||
$pv=supannParseLabeledValue($value);
|
||||
$pv = supannParseLabeledValue($value);
|
||||
if ($pv) {
|
||||
$retval['label'] = $pv['label'];
|
||||
$retval['translated'] = supannGetNomenclatureLabel($this -> supannNomenclatureTable,$pv['label'],$pv['value']);
|
||||
if ($this -> supannLabelNomenclatureTable)
|
||||
$retval['translated_label'] = supannGetNomenclatureLabel($this -> supannLabelNomenclatureTable, null, $pv['label']);
|
||||
if ($this -> supannNomenclatureTable)
|
||||
$retval['translated'] = supannGetNomenclatureLabel($this -> supannNomenclatureTable,$pv['label'],$pv['value']);
|
||||
else
|
||||
$retval['translated'] = $pv['value'];
|
||||
}
|
||||
else {
|
||||
$retval['label'] = 'no';
|
||||
|
@ -101,26 +123,38 @@ class LSformElement_supannLabeledValue extends LSformElement {
|
|||
*
|
||||
* @param[in] $data The address to the array of data witch will be return by the ajax request
|
||||
*
|
||||
* @retval void
|
||||
* @retval boolean True on success, False otherwise
|
||||
**/
|
||||
public static function ajax_searchPossibleValues(&$data) {
|
||||
if ((isset($_REQUEST['attribute'])) && (isset($_REQUEST['objecttype'])) && (isset($_REQUEST['pattern'])) && (isset($_REQUEST['idform'])) ) {
|
||||
if (LSsession ::loadLSobject($_REQUEST['objecttype'])) {
|
||||
$object = new $_REQUEST['objecttype']();
|
||||
$form = $object -> getForm($_REQUEST['idform']);
|
||||
$field=$form -> getElement($_REQUEST['attribute']);
|
||||
$data['possibleValues'] = $field -> searchPossibleValues($_REQUEST['pattern']);
|
||||
}
|
||||
}
|
||||
// Check all parameters is provided
|
||||
foreach(array('attribute', 'objecttype', 'pattern', 'idform') as $parameter)
|
||||
if (!isset($_REQUEST[$parameter]))
|
||||
return;
|
||||
if (!LSsession ::loadLSobject($_REQUEST['objecttype']))
|
||||
return;
|
||||
$object = new $_REQUEST['objecttype']();
|
||||
$form = $object -> getForm($_REQUEST['idform']);
|
||||
$field = $form -> getElement($_REQUEST['attribute']);
|
||||
$data['possibleValues'] = $field -> searchPossibleValues($_REQUEST['pattern']);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Real private method to search possible values from pattern.
|
||||
*
|
||||
* @param[in] $pattern The search pattern
|
||||
*
|
||||
* @retval boolean|array Array of possible values, or False is case of error
|
||||
**/
|
||||
private function searchPossibleValues($pattern) {
|
||||
$pattern=strtolower($pattern);
|
||||
if (!$this -> supannNomenclatureTable)
|
||||
return false;
|
||||
$pattern=withoutAccents(strtolower($pattern));
|
||||
$retval=array();
|
||||
$table=supannGetNomenclatureTable($this -> supannNomenclatureTable);
|
||||
foreach($table as $label => $values) {
|
||||
foreach($values as $v => $txt) {
|
||||
if (strpos(strtolower($txt),$pattern)!==false) {
|
||||
if (strpos(withoutAccents(strtolower($txt)),$pattern)!==false) {
|
||||
$retval[]=array(
|
||||
'label' => $label,
|
||||
'value' => "{".$label."}".$v,
|
||||
|
|
39
src/includes/class/class.LSformElement_supannMailPrive.php
Normal file
39
src/includes/class/class.LSformElement_supannMailPrive.php
Normal file
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
/*******************************************************************************
|
||||
* Copyright (C) 2021 Easter-eggs
|
||||
* https://ldapsaisie.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.
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
LSsession :: loadLSclass('LSformElement_supannLabeledValue');
|
||||
LSsession :: loadLSaddon('supann');
|
||||
|
||||
/**
|
||||
* Element supannMailPrive d'un formulaire pour LdapSaisie
|
||||
*
|
||||
* Cette classe définis les éléments supannMailPrive des formulaires.
|
||||
* Elle etant la classe basic LSformElement_supannLabeledValue.
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*/
|
||||
|
||||
class LSformElement_supannMailPrive extends LSformElement_supannLabeledValue {
|
||||
|
||||
var $supannLabelNomenclatureTable = 'mailPriveLabel';
|
||||
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
/*******************************************************************************
|
||||
* Copyright (C) 2021 Easter-eggs
|
||||
* https://ldapsaisie.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.
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
LSsession :: loadLSclass('LSformElement_supannLabeledValue');
|
||||
LSsession :: loadLSaddon('supann');
|
||||
|
||||
/**
|
||||
* Element supannTelephonePrive d'un formulaire pour LdapSaisie
|
||||
*
|
||||
* Cette classe définis les éléments supannTelephonePrive des formulaires.
|
||||
* Elle etant la classe basic LSformElement_supannLabeledValue.
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*/
|
||||
|
||||
class LSformElement_supannTelephonePrive extends LSformElement_supannLabeledValue {
|
||||
|
||||
var $supannLabelNomenclatureTable = 'telephonePriveLabel';
|
||||
|
||||
}
|
|
@ -1,171 +1,191 @@
|
|||
var LSformElement_supannLabeledValue_field_value = new Class({
|
||||
initialize: function(li,name,field_type){
|
||||
this.li=li;
|
||||
this.name = name;
|
||||
this.field_type = field_type;
|
||||
this.params = varLSdefault.LSjsConfig[this.name];
|
||||
initialize: function(li,name,field_type){
|
||||
this.li=li;
|
||||
this.name = name;
|
||||
this.field_type = field_type;
|
||||
this.params = varLSdefault.LSjsConfig[this.name];
|
||||
|
||||
this.input = this.li.getElement('input');
|
||||
this.img = this.li.getElement('img.LSformElement_supannLabeledValue_label');
|
||||
this.span = this.li.getElement('span');
|
||||
this.inputRawValue = this.li.getElement('input');
|
||||
if (this.params.nomenclatureTable) {
|
||||
this.img = this.li.getElement('img.LSformElement_supannLabeledValue_label');
|
||||
this.span = this.li.getElement('span');
|
||||
|
||||
this.inputSearch=new Element(
|
||||
'input',
|
||||
{
|
||||
'class': 'LSformElement_supannLabeledValue_search',
|
||||
'styles': {
|
||||
'display': 'none'
|
||||
}
|
||||
}
|
||||
);
|
||||
this.inputSearch.addEvent('keydown',this.onKeyUpInputSearch.bindWithEvent(this));
|
||||
this.inputSearch.injectInside(this.li);
|
||||
|
||||
this.searchBtn=new Element(
|
||||
'img',
|
||||
{
|
||||
'src': varLSdefault.imagePath('modify'),
|
||||
'alt': this.params.searchBtn,
|
||||
'title': this.params.searchBtn,
|
||||
}
|
||||
);
|
||||
this.searchBtn.addEvent('click',this.toggleInputSearch.bind(this));
|
||||
this.searchBtn.injectAfter(this.span);
|
||||
|
||||
this._lastSearch=null;
|
||||
this._possibleValues=null;
|
||||
},
|
||||
|
||||
toggleInputSearch: function() {
|
||||
if (this.inputSearch.getStyle('display')=='none') {
|
||||
this.inputSearch.setStyle('display','block');
|
||||
this.inputSearch.focus();
|
||||
}
|
||||
else {
|
||||
this.hidePossibleValues();
|
||||
this.inputSearch.setStyle('display','none');
|
||||
this.inputSearch.set('value','');
|
||||
}
|
||||
},
|
||||
|
||||
onKeyUpInputSearch: function(event) {
|
||||
event = new Event(event);
|
||||
|
||||
if ((event.key=='enter')||(event.key=='tab')) {
|
||||
event.stop();
|
||||
if (this.inputSearch.value!="") {
|
||||
this.launchSearch();
|
||||
this.inputSearch=new Element(
|
||||
'input',
|
||||
{
|
||||
'class': 'LSformElement_supannLabeledValue_search',
|
||||
'styles': {
|
||||
'display': 'none'
|
||||
}
|
||||
}
|
||||
);
|
||||
this.inputSearch.addEvent('keydown',this.onKeyUpInputSearch.bindWithEvent(this));
|
||||
this.inputSearch.injectInside(this.li);
|
||||
|
||||
if (event.key=='esc') {
|
||||
this.toggleInputSearch();
|
||||
this.searchBtn=new Element(
|
||||
'img',
|
||||
{
|
||||
'src': varLSdefault.imagePath('modify'),
|
||||
'alt': this.params.searchBtn,
|
||||
'title': this.params.searchBtn,
|
||||
}
|
||||
);
|
||||
this.searchBtn.addEvent('click',this.toggleInputSearch.bind(this));
|
||||
this.searchBtn.injectAfter(this.span);
|
||||
|
||||
this._lastSearch=null;
|
||||
this._possibleValues=null;
|
||||
}
|
||||
else {
|
||||
this.inputLabel = this.li.getElement('select.LSformElement_supannLabeledValue_label');
|
||||
if (!this.inputLabel)
|
||||
this.inputLabel = this.li.getElement('input.LSformElement_supannLabeledValue_label');
|
||||
this.inputValue = this.li.getElement('input.LSformElement_supannLabeledValue_value');
|
||||
if (!this.inputValue)
|
||||
this.inputValue = this.li.getElement('textarea.LSformElement_supannLabeledValue_value');
|
||||
if (!this.inputLabel || !this.inputValue) {
|
||||
alert('toto');
|
||||
return;
|
||||
}
|
||||
},
|
||||
this.inputLabel.addEvent('change', this.updateRawValue.bind(this));
|
||||
this.inputValue.addEvent('change', this.updateRawValue.bind(this));
|
||||
}
|
||||
},
|
||||
|
||||
launchSearch: function() {
|
||||
this.hidePossibleValues();
|
||||
this._lastSearch=this.inputSearch.value;
|
||||
var data = {
|
||||
attribute: this.name,
|
||||
objecttype: varLSform.objecttype,
|
||||
idform: varLSform.idform,
|
||||
pattern: this.inputSearch.value
|
||||
};
|
||||
data.imgload=varLSdefault.loadingImgDisplay(this.inputSearch);
|
||||
new Request({url: 'ajax/class/LSformElement_supannLabeledValue/searchPossibleValues', data: data, onSuccess: this.onSearchComplete.bind(this)}).send();
|
||||
toggleInputSearch: function() {
|
||||
if (this.inputSearch.getStyle('display')=='none') {
|
||||
this.inputSearch.setStyle('display','block');
|
||||
this.inputSearch.focus();
|
||||
}
|
||||
else {
|
||||
this.hidePossibleValues();
|
||||
this.inputSearch.setStyle('display','none');
|
||||
this.inputSearch.set('value','');
|
||||
}
|
||||
},
|
||||
|
||||
onKeyUpInputSearch: function(event) {
|
||||
event = new Event(event);
|
||||
|
||||
if ((event.key=='enter')||(event.key=='tab')) {
|
||||
event.stop();
|
||||
if (this.inputSearch.value!="") {
|
||||
this.launchSearch();
|
||||
}
|
||||
}
|
||||
|
||||
if (event.key=='esc') {
|
||||
this.toggleInputSearch();
|
||||
}
|
||||
},
|
||||
|
||||
launchSearch: function() {
|
||||
this.hidePossibleValues();
|
||||
this._lastSearch=this.inputSearch.value;
|
||||
var data = {
|
||||
attribute: this.name,
|
||||
objecttype: varLSform.objecttype,
|
||||
idform: varLSform.idform,
|
||||
pattern: this.inputSearch.value
|
||||
};
|
||||
data.imgload=varLSdefault.loadingImgDisplay(this.inputSearch);
|
||||
new Request({url: 'ajax/class/LSformElement_supannLabeledValue/searchPossibleValues', data: data, onSuccess: this.onSearchComplete.bind(this)}).send();
|
||||
},
|
||||
|
||||
onSearchComplete: function(responseText, responseXML) {
|
||||
var data = JSON.decode(responseText);
|
||||
if ( varLSdefault.checkAjaxReturn(data) ) {
|
||||
this.displayPossibleValues(data.possibleValues);
|
||||
}
|
||||
},
|
||||
var data = JSON.decode(responseText);
|
||||
if ( varLSdefault.checkAjaxReturn(data) ) {
|
||||
this.displayPossibleValues(data.possibleValues);
|
||||
}
|
||||
},
|
||||
|
||||
displayPossibleValues: function(possibleValues) {
|
||||
if (this._possibleValues==null) {
|
||||
this._possibleValues=new Element(
|
||||
'div',
|
||||
{
|
||||
'class': 'supannLabeledValue_possibleValues',
|
||||
}
|
||||
);
|
||||
this._possibleValues.injectInside(this.li);
|
||||
}
|
||||
displayPossibleValues: function(possibleValues) {
|
||||
if (this._possibleValues==null) {
|
||||
this._possibleValues=new Element(
|
||||
'div',
|
||||
{
|
||||
'class': 'supannLabeledValue_possibleValues',
|
||||
}
|
||||
);
|
||||
this._possibleValues.injectInside(this.li);
|
||||
}
|
||||
|
||||
|
||||
var ul=new Element('ul');
|
||||
possibleValues.each(function(v) {
|
||||
var li=new Element(
|
||||
'li',
|
||||
{
|
||||
'data-value': v.value,
|
||||
'data-label': v.label,
|
||||
'data-translated': v.translated,
|
||||
}
|
||||
);
|
||||
if (v.label!='no') {
|
||||
li.set('html',"<img src='"+varLSdefault.imagePath('supann_label_'+v.label)+"' alt='["+v.label+"]'/> "+v.translated);
|
||||
}
|
||||
else {
|
||||
li.set('html',v.translated);
|
||||
}
|
||||
li.injectInside(this);
|
||||
}, ul);
|
||||
if (ul.getElements('li').length==0) {
|
||||
new Element(
|
||||
'li',
|
||||
{
|
||||
'html': this.params.noResultLabel
|
||||
}
|
||||
).injectInside(ul);
|
||||
}
|
||||
else {
|
||||
ul.getElements('li').each(function(li) {
|
||||
li.addEvent('click',this.onClickPossibleValue.bindWithEvent(this));
|
||||
}, this);
|
||||
}
|
||||
ul.injectInside(this._possibleValues);
|
||||
this._possibleValues.setStyle('display', 'block');
|
||||
},
|
||||
var ul=new Element('ul');
|
||||
possibleValues.each(function(v) {
|
||||
var li=new Element(
|
||||
'li',
|
||||
{
|
||||
'data-value': v.value,
|
||||
'data-label': v.label,
|
||||
'data-translated': v.translated,
|
||||
}
|
||||
);
|
||||
if (v.label!='no') {
|
||||
li.set('html',"<img src='"+varLSdefault.imagePath('supann_label_'+v.label)+"' alt='["+v.label+"]'/> "+v.translated);
|
||||
}
|
||||
else {
|
||||
li.set('html',v.translated);
|
||||
}
|
||||
li.injectInside(this);
|
||||
}, ul);
|
||||
if (ul.getElements('li').length==0) {
|
||||
new Element(
|
||||
'li',
|
||||
{
|
||||
'html': this.params.noResultLabel
|
||||
}
|
||||
).injectInside(ul);
|
||||
}
|
||||
else {
|
||||
ul.getElements('li').each(function(li) {
|
||||
li.addEvent('click',this.onClickPossibleValue.bindWithEvent(this));
|
||||
}, this);
|
||||
}
|
||||
ul.injectInside(this._possibleValues);
|
||||
this._possibleValues.setStyle('display', 'block');
|
||||
},
|
||||
|
||||
hidePossibleValues: function() {
|
||||
if (this._possibleValues!=null) {
|
||||
this._possibleValues.setStyle('display', 'none');
|
||||
this._possibleValues.empty();
|
||||
}
|
||||
},
|
||||
hidePossibleValues: function() {
|
||||
if (this._possibleValues!=null) {
|
||||
this._possibleValues.setStyle('display', 'none');
|
||||
this._possibleValues.empty();
|
||||
}
|
||||
},
|
||||
|
||||
onClickPossibleValue: function(event) {
|
||||
this.hidePossibleValues();
|
||||
event = new Event(event);
|
||||
var li=$(event.target);
|
||||
if (event.target.tagName=='IMG') {
|
||||
li=li.getParent();
|
||||
}
|
||||
this.input.set('value',li.get('data-value'));
|
||||
if (li.get('data-label')!='no') {
|
||||
if (this.img==null) {
|
||||
this.img=new Element('img',{'class': 'LSformElement_supannLabeledValue_label'});
|
||||
this.img.injectBefore(this.span);
|
||||
}
|
||||
this.img.set('src',varLSdefault.imagePath('supann_label_'+li.get('data-label')));
|
||||
}
|
||||
this.span.set('html',li.get('data-translated'));
|
||||
this.span.set('title',li.get('data-value'));
|
||||
this.toggleInputSearch();
|
||||
},
|
||||
onClickPossibleValue: function(event) {
|
||||
this.hidePossibleValues();
|
||||
event = new Event(event);
|
||||
var li=$(event.target);
|
||||
if (event.target.tagName=='IMG') {
|
||||
li=li.getParent();
|
||||
}
|
||||
this.inputRawValue.set('value',li.get('data-value'));
|
||||
if (li.get('data-label')!='no') {
|
||||
if (this.img==null) {
|
||||
this.img=new Element('img',{'class': 'LSformElement_supannLabeledValue_label'});
|
||||
this.img.injectBefore(this.span);
|
||||
}
|
||||
this.img.set('src',varLSdefault.imagePath('supann_label_'+li.get('data-label')));
|
||||
}
|
||||
this.span.set('html',li.get('data-translated'));
|
||||
this.span.set('title',li.get('data-value'));
|
||||
this.toggleInputSearch();
|
||||
},
|
||||
|
||||
clear: function() {
|
||||
if (this.img) {
|
||||
this.img.dispose();
|
||||
this.img=null;
|
||||
}
|
||||
this.input.set('value','');
|
||||
if (this.span) {
|
||||
this.span.set('html',this.params.noValueLabel);
|
||||
}
|
||||
},
|
||||
updateRawValue: function(event) {
|
||||
this.inputRawValue.set('value', '{'+this.inputLabel.value+'}'+this.inputValue.value);
|
||||
},
|
||||
|
||||
clear: function() {
|
||||
if (this.img) {
|
||||
this.img.dispose();
|
||||
this.img=null;
|
||||
}
|
||||
this.inputRawValue.set('value','');
|
||||
if (this.span) {
|
||||
this.span.set('html',this.params.noValueLabel);
|
||||
}
|
||||
},
|
||||
|
||||
});
|
||||
|
|
|
@ -1,22 +1,47 @@
|
|||
{if $freeze}
|
||||
{if isset($parseValue)}
|
||||
{if !empty($parseValue.label) and $parseValue.label!='no'}
|
||||
{if isset($parseValue.translated_label)}
|
||||
<span class='LSformElement_supannLabeledValue_label'>{tr msg=$parseValue.translated_label} :</span>
|
||||
{elseif !empty($parseValue.label) and $parseValue.label!='no'}
|
||||
{assign var=clabel value=$parseValue.label}
|
||||
<img src='{img name="supann_label_$clabel"}' alt='[{$clabel|escape:"htmlall"}]' title='{$clabel|escape:"htmlall"}'/>
|
||||
{/if}
|
||||
<span title='{$parseValue.value|escape:"htmlall"}'>{$parseValue.translated|escape:"htmlall"}</span>
|
||||
{if $valueFieldType == 'textarea'}
|
||||
<pre class='LSformElement_supannLabeledValue_value' {if $nomenclatureTable}title='{$parseValue.value|escape:"htmlall"}'{/if}>{$parseValue.translated|escape:"htmlall"}</pre>
|
||||
{else}
|
||||
<span {if $nomenclatureTable}title='{$parseValue.value|escape:"htmlall"}'{/if}>{$parseValue.translated|escape:"htmlall"}</span>
|
||||
{/if}
|
||||
{else}
|
||||
{$noValueTxt|escape:"htmlall"}
|
||||
{/if}
|
||||
{else}
|
||||
<input type='hidden' name='{$attr_name|escape:"htmlall"}[]' value='{if $parseValue}{$parseValue.value|escape:"htmlall"}{/if}'/>
|
||||
{if $parseValue and !empty($parseValue.label) and $parseValue.label!='no'}
|
||||
{assign var=clabel value=$parseValue.label}
|
||||
<img class='LSformElement_supannLabeledValue_label' src='{img name="supann_label_$clabel"}' alt='[{$clabel|escape:"htmlall"}]' title='{$clabel|escape:"htmlall"}'/>
|
||||
{/if}
|
||||
{if $parseValue}
|
||||
<span title='{$parseValue.value|escape:"htmlall"}'>{$parseValue.translated|escape:"htmlall"}</span>
|
||||
{if $nomenclatureTable}
|
||||
{if $parseValue and !empty($parseValue.label) and $parseValue.label!='no'}
|
||||
{assign var=clabel value=$parseValue.label}
|
||||
<img class='LSformElement_supannLabeledValue_label' src='{img name="supann_label_$clabel"}' alt='[{$clabel|escape:"htmlall"}]' title='{$clabel|escape:"htmlall"}'/>
|
||||
{/if}
|
||||
{if $parseValue}
|
||||
<span title='{$parseValue.value|escape:"htmlall"}'>{$parseValue.translated|escape:"htmlall"}</span>
|
||||
{else}
|
||||
<span>{$noValueTxt|escape:"htmlall"}</span>
|
||||
{/if}
|
||||
{else}
|
||||
<span>{$noValueTxt|escape:"htmlall"}</span>
|
||||
{if $possibleLabels}
|
||||
<select class='LSformElement_supannLabeledValue_label'>
|
||||
{if $parseValue}
|
||||
{html_options options=$possibleLabels selected=$parseValue.label}
|
||||
{else}
|
||||
{html_options options=$possibleLabels}
|
||||
{/if}
|
||||
</select>
|
||||
{else}
|
||||
<input type='text' class='LSformElement_supannLabeledValue_label'{if $parseValue} value='{$parseValue.label|escape:"htmlall"}'{/if}/>
|
||||
{/if}
|
||||
{if $valueFieldType == 'textarea'}
|
||||
<textarea class='LSformElement_supannLabeledValue_value'>{if $parseValue}{$parseValue.translated|escape:"htmlall"}{/if}</textarea>
|
||||
{else}
|
||||
<input type='text' class='LSformElement_supannLabeledValue_value'{if $parseValue} value='{$parseValue.translated|escape:"htmlall"}'{/if}/>
|
||||
{/if}
|
||||
{/if}
|
||||
{/if}
|
||||
|
|
Loading…
Reference in a new issue