mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-11-17 15:59:06 +01:00
- Ajout du support des images (LSattr_html / LSformElement / LSformRule)
- Ajout du principe de relations entre type d'objets (LSrelation) Exemple : Utilisateur appartenant à un groupe - Ajout du LSformElement_select_object : Sélection d'un objet à travers une interface plus conviviale qu'une liste déroulante.
This commit is contained in:
parent
bcebcb311c
commit
1e2316d76f
69 changed files with 2917 additions and 749 deletions
|
@ -1,4 +0,0 @@
|
|||
Start.
|
||||
--This line, and those below, will be ignored--
|
||||
|
||||
A .
|
|
@ -80,7 +80,7 @@ $GLOBALS['LSobjects']['LSeegroup'] = array (
|
|||
'uniqueMember' => array (
|
||||
'label' => _('Membres'),
|
||||
'ldap_type' => 'ascii',
|
||||
'html_type' => 'select_list',
|
||||
'html_type' => 'select_object',
|
||||
'required' => 0,
|
||||
'multiple' => 1,
|
||||
'validation' => array (
|
||||
|
@ -97,6 +97,14 @@ $GLOBALS['LSobjects']['LSeegroup'] = array (
|
|||
'modify' => 1,
|
||||
'create' => 1
|
||||
),
|
||||
'selectable_object' => array(
|
||||
'object_type' => 'LSeepeople', // Nom de l'objet à lister
|
||||
'display_attribute' => '%{cn} (%{uidNumber})', // Spécifie le attributs à lister pour le choix,
|
||||
// si non définie => utilisation du 'select_display_attrs'
|
||||
// de la définition de l'objet
|
||||
|
||||
'value_attribute' => '%{dn}', // Spécifie le attributs dont la valeur sera retournée par
|
||||
),
|
||||
'possible_values' => array(
|
||||
'OTHER_OBJECT' => array(
|
||||
'object_type' => 'LSeepeople', // Nom de l'objet à lister
|
||||
|
|
|
@ -33,6 +33,19 @@ $GLOBALS['LSobjects']['LSeepeople'] = array (
|
|||
'after_save' => 'valid',
|
||||
'select_display_attrs' => '%{cn}',
|
||||
'label' => _('Utilisateurs'),
|
||||
'relations' => array(
|
||||
'groups' => array(
|
||||
'label' => _('Appartient aux groupes...'),
|
||||
'LSobject' => 'LSeegroup',
|
||||
'list_function' => 'listUserGroups',
|
||||
'update_function' => 'updateUserGroups',
|
||||
'remove_function' => 'removeMember',
|
||||
'rights' => array(
|
||||
'self' => 'r',
|
||||
'admin' => 'w'
|
||||
)
|
||||
)
|
||||
),
|
||||
// Attributes
|
||||
'attrs' => array (
|
||||
'uid' => array (
|
||||
|
@ -426,6 +439,38 @@ $GLOBALS['LSobjects']['LSeepeople'] = array (
|
|||
'form' => array (
|
||||
'modify' => 0
|
||||
)
|
||||
),
|
||||
'jpegPhoto' => array (
|
||||
'label' => _('Photo'),
|
||||
'ldap_type' => 'image',
|
||||
'html_type' => 'image',
|
||||
'required' => 0,
|
||||
'view' => 0,
|
||||
'check_data' => array (
|
||||
'imagesize' => array(
|
||||
'msg' => _("La taille de l'image n'est pas valide."),
|
||||
'param' => array(
|
||||
'maxWidth' => 2000
|
||||
)
|
||||
),
|
||||
'imagefilesize' => array(
|
||||
'msg' => _("La taille du fichier image n'est pas valide."),
|
||||
'param' => array(
|
||||
'maxSize' => 3000000 // taille du fichier en octets
|
||||
)
|
||||
),
|
||||
'imagefile' => array(
|
||||
'msg' => _("Le type du fichier n'est pas valide.")
|
||||
)
|
||||
),
|
||||
'form' => array (
|
||||
'modify' => 1
|
||||
),
|
||||
'rights' => array(
|
||||
'self' => 'w',
|
||||
'user' => 'r',
|
||||
'admin' => 'w'
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
|
|
@ -246,6 +246,18 @@ $GLOBALS['LSerror_code'] = array (
|
|||
1012 => array (
|
||||
'msg' => _("LSsession : Des informations sont manquantes pour l'affichage de cette page."),
|
||||
'level' => 'c'
|
||||
),
|
||||
1013 => array (
|
||||
'msg' => _("LSrelations : La fonction de listage pour la relation %{relation} est inconnu."),
|
||||
'level' => 'c'
|
||||
),
|
||||
1014 => array (
|
||||
'msg' => _("LSrelations : La fonction de mise à jour pour la relation %{relation} est inconnu."),
|
||||
'level' => 'c'
|
||||
),
|
||||
1015 => array (
|
||||
'msg' => _("LSrelations : Une erreur s'est produite durant la mise a jour de la relation %{relation}."),
|
||||
'level' => 'c'
|
||||
)
|
||||
|
||||
);
|
||||
|
|
|
@ -80,6 +80,10 @@ $GLOBALS['LSconfig'] = array(
|
|||
//Debug
|
||||
$GLOBALS['LSdebug']['active'] = true;
|
||||
|
||||
define('NB_LSOBJECT_LIST',2);
|
||||
|
||||
define('MAX_SEND_FILE_SIZE',2000000);
|
||||
|
||||
// Définitions des locales
|
||||
$textdomain = 'ldapsaisie';
|
||||
bindtextdomain($textdomain, '/var/www/ldapsaisie/trunk/l10n');
|
||||
|
@ -93,12 +97,21 @@ define('LS_CLASS_DIR', LS_INCLUDE_DIR .'class/');
|
|||
define('LS_LIB_DIR', LS_INCLUDE_DIR .'libs/');
|
||||
define('LS_ADDONS_DIR', LS_INCLUDE_DIR .'addons/');
|
||||
define('LS_JS_DIR', LS_INCLUDE_DIR .'js/');
|
||||
define('LS_TMP_DIR', 'tmp/');
|
||||
|
||||
// Javascript
|
||||
$GLOBALS['defaultJSscipts']=array(
|
||||
'mootools.js',
|
||||
'LSdefault.js',
|
||||
'Debugger.js'
|
||||
'LSdefault.js'
|
||||
);
|
||||
|
||||
if ($GLOBALS['LSdebug']['active']) {
|
||||
$GLOBALS['defaultJSscipts'][]='Debugger.js';
|
||||
}
|
||||
|
||||
// PHP values
|
||||
ini_set( 'magic_quotes_gpc', 'off' );
|
||||
ini_set( 'magic_quotes_sybase', 'off' );
|
||||
ini_set( 'magic_quotes_runtime', 'off' );
|
||||
|
||||
?>
|
||||
|
|
|
@ -80,6 +80,17 @@ class LSattr_html {
|
|||
function addToForm (&$form,$idForm,$data=NULL) {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(101,$this -> name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Effectue les tâches nécéssaires au moment du rafraichissement du formulaire
|
||||
*
|
||||
* @param[in] $data mixed La valeur de l'attribut
|
||||
*
|
||||
* @retval mixed La valeur formatée de l'attribut
|
||||
**/
|
||||
function refreshForm($data) {
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
53
trunk/includes/class/class.LSattr_html_image.php
Normal file
53
trunk/includes/class/class.LSattr_html_image.php
Normal 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 image
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*/
|
||||
class LSattr_html_image 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('image', $this -> name, $this -> config['label'],$this -> config);
|
||||
if(!$element) {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(206,$this -> name);
|
||||
return;
|
||||
}
|
||||
if ($data) {
|
||||
$element -> setValue($data);
|
||||
}
|
||||
return $element;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
|
@ -27,38 +27,38 @@
|
|||
*/
|
||||
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é
|
||||
*/
|
||||
/**
|
||||
* 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;
|
||||
$this -> config['text_possible_values'] = $possible_values;
|
||||
$element=$form -> addElement('select', $this -> name, $this -> config['label'],$this -> config);
|
||||
if(!$element) {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(206,$this -> name);
|
||||
return;
|
||||
}
|
||||
if ($data) {
|
||||
$element -> setValue($data);
|
||||
}
|
||||
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,'/').'$';
|
||||
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']);
|
||||
|
@ -74,7 +74,7 @@ class LSattr_html_select_list extends LSattr_html{
|
|||
*
|
||||
* @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'])) {
|
||||
|
@ -104,8 +104,8 @@ class LSattr_html_select_list extends LSattr_html{
|
|||
}
|
||||
}
|
||||
else {
|
||||
$val_name=$this->attribute->ldapObject->getFData($val_name);
|
||||
$val=$this->attribute->ldapObject->getFData($val);
|
||||
$val_name=$this->attribute->ldapObject->getFData($val_name);
|
||||
$val=$this->attribute->ldapObject->getFData($val);
|
||||
$retInfos[$val_name]=$val;
|
||||
}
|
||||
}
|
||||
|
|
166
trunk/includes/class/class.LSattr_html_select_object.php
Normal file
166
trunk/includes/class/class.LSattr_html_select_object.php
Normal file
|
@ -0,0 +1,166 @@
|
|||
<?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_object
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*/
|
||||
class LSattr_html_select_object 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) {
|
||||
$this -> config['attrObject'] = $this;
|
||||
$element=$form -> addElement('select_object', $this -> name, $this -> config['label'],$this -> config,$this);
|
||||
if(!$element) {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(206,$this -> name);
|
||||
return;
|
||||
}
|
||||
if ($data) {
|
||||
$values=$this -> getValues($data);
|
||||
if ($values) {
|
||||
$element -> setValue($values);
|
||||
}
|
||||
}
|
||||
$element -> setSelectableObject($this -> config['selectable_object']['object_type']);
|
||||
return $element;
|
||||
}
|
||||
|
||||
function refreshForm($data) {
|
||||
return $this -> getValues($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne un tableau des valeurs possibles de la liste
|
||||
*
|
||||
* @param[in] mixed Tableau des valeurs de l'attribut
|
||||
*
|
||||
* @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 getValues($values=NULL) {
|
||||
$retInfos = array();
|
||||
if (isset($this -> config['selectable_object'])) {
|
||||
$conf=$this -> config['selectable_object'];
|
||||
if (!isset($conf['object_type'])) {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(102,$this -> name);
|
||||
break;
|
||||
}
|
||||
|
||||
if (is_array($values)) {
|
||||
if(($conf['value_attribute']=='dn')||($conf['value_attribute']=='%{dn}')) {
|
||||
$list=array();
|
||||
foreach($values as $dn) {
|
||||
$obj=new $conf['object_type']();
|
||||
if ($obj -> loadData($dn)) {
|
||||
$list[]=$obj;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$filter='(|';
|
||||
foreach($values as $val) {
|
||||
$filter.='('.$conf['value_attribute'].'='.$val.')';
|
||||
}
|
||||
$filter.=')';
|
||||
debug($filter);
|
||||
$obj = new $conf['object_type']();
|
||||
$list = $obj -> listObjects($filter);
|
||||
}
|
||||
if(($conf['value_attribute']=='dn')||($conf['value_attribute']=='%{dn}')) {
|
||||
for($i=0;$i<count($list);$i++) {
|
||||
$retInfos[$list[$i] -> dn]=$list[$i] -> getDisplayValue($conf['display_attribute']);
|
||||
$DNs[]=$list[$i] -> dn;
|
||||
}
|
||||
}
|
||||
else {
|
||||
for($i=0;$i<count($list);$i++) {
|
||||
$retInfos[$list[$i] -> attrs[$val['value_attribute']] -> getValue()]=$list[$i] -> getDisplayValue($conf['display_attribute']);
|
||||
$DNs[]=$list[$i] -> dn;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
debug($values);
|
||||
return false;
|
||||
}
|
||||
$_SESSION['LSselect'][$conf['object_type']]=$DNs;
|
||||
return $retInfos;
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retourne un tableau des valeurs de l'attribut à partir de la variable session
|
||||
*
|
||||
* @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 getValuesFromSession() {
|
||||
$retInfos = array();
|
||||
if (isset($this -> config['selectable_object'])) {
|
||||
$conf=$this -> config['selectable_object'];
|
||||
if (!isset($conf['object_type'])) {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(102,$this -> name);
|
||||
break;
|
||||
}
|
||||
|
||||
if(is_array($_SESSION['LSselect'][$conf['object_type']])) {
|
||||
foreach($_SESSION['LSselect'][$conf['object_type']] as $dn) {
|
||||
$obj = new $conf['object_type']();
|
||||
if ($obj->loadData($dn)) {
|
||||
if(($conf['value_attribute']=='dn')||($conf['value_attribute']=='%{dn}')) {
|
||||
$retInfos[$obj -> dn]=$obj -> getDisplayValue($conf['display_attribute']);
|
||||
}
|
||||
else {
|
||||
$retInfos[$obj -> attrs[$val['value_attribute']] -> getValue()]=$obj -> getDisplayValue($conf['display_attribute']);
|
||||
}
|
||||
$DNs[]=$dn;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
$_SESSION['LSselect'][$conf['object_type']]=$DNs;
|
||||
return $retInfos;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
|
@ -68,18 +68,9 @@ class LSattr_ldap {
|
|||
*
|
||||
* @retval mixed La valeur d'affichage de l'attribut
|
||||
*/
|
||||
|
||||
function getDisplayValue($data) {
|
||||
return $data;
|
||||
}
|
||||
|
||||
function __sleep() {
|
||||
return ( array_keys( get_object_vars( &$this ) ) );
|
||||
}
|
||||
|
||||
function __wakeup() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
32
trunk/includes/class/class.LSattr_ldap_image.php
Normal file
32
trunk/includes/class/class.LSattr_ldap_image.php
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?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 Ldap image
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*/
|
||||
class LSattr_ldap_image extends LSattr_ldap {
|
||||
// \\
|
||||
}
|
||||
|
||||
?>
|
|
@ -316,7 +316,8 @@ class LSattribute {
|
|||
function refreshForm(&$form,$idForm) {
|
||||
if(isset($this -> config['form'][$idForm])) {
|
||||
$form_element = &$form -> getElement($this -> name);
|
||||
return $form_element -> setValue($this -> getFormVal());
|
||||
$values = $this -> html -> refreshForm($this -> getFormVal());
|
||||
return $form_element -> setValue($values);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ class LSerror {
|
|||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @retval void
|
||||
*/
|
||||
*/
|
||||
function LSerror() {
|
||||
$errors = array();
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ class LSerror {
|
|||
* dans le fichier 'error_code.php'.
|
||||
*
|
||||
* @retval void
|
||||
*/
|
||||
*/
|
||||
function addErrorCode($code=-1,$msg='') {
|
||||
$this -> errors[]=array($code,$msg);
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ class LSerror {
|
|||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @retval void
|
||||
*/
|
||||
*/
|
||||
function stop(){
|
||||
$this -> display();
|
||||
exit(1);
|
||||
|
@ -78,11 +78,11 @@ class LSerror {
|
|||
* @retval void
|
||||
*/
|
||||
function display() {
|
||||
$errors = $this -> getErrors();
|
||||
if ($errors) {
|
||||
$GLOBALS['Smarty'] -> assign('LSerrors',$errors);
|
||||
}
|
||||
/*if(!empty($this -> errors)) {
|
||||
$errors = $this -> getErrors();
|
||||
if ($errors) {
|
||||
$GLOBALS['Smarty'] -> assign('LSerrors',$errors);
|
||||
}
|
||||
/*if(!empty($this -> errors)) {
|
||||
print "<h3>"._('Erreurs')."</h3>\n";
|
||||
foreach ($this -> errors as $error) {
|
||||
echo "(Code ".$error[0].") ".getFData($GLOBALS['LSerror_code'][$error[0]]['msg'],$error[1])."<br />\n";
|
||||
|
@ -92,20 +92,31 @@ class LSerror {
|
|||
|
||||
/**
|
||||
* Retourne le texte des erreurs
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @retvat string Le texte des erreurs
|
||||
*/
|
||||
function getErrors() {
|
||||
if(!empty($this -> errors)) {
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @retvat string Le texte des erreurs
|
||||
*/
|
||||
function getErrors() {
|
||||
if(!empty($this -> errors)) {
|
||||
foreach ($this -> errors as $error) {
|
||||
$txt.="(Code ".$error[0].") ".getFData($GLOBALS['LSerror_code'][$error[0]]['msg'],$error[1])."<br />\n";
|
||||
}
|
||||
return $txt;
|
||||
}
|
||||
return;
|
||||
}
|
||||
return $txt;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Définir si il y a des erreurs
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @retvat boolean
|
||||
*/
|
||||
function errorsDefined() {
|
||||
return !empty($this -> errors);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -42,6 +42,8 @@ class LSform {
|
|||
var $_isValidate = false;
|
||||
|
||||
var $_notUpdate = array();
|
||||
|
||||
var $maxFileSize = NULL;
|
||||
|
||||
/**
|
||||
* Constructeur
|
||||
|
@ -81,8 +83,9 @@ class LSform {
|
|||
$LSform_header = "\t<input type='hidden' name='validate' value='LSform'/>\n
|
||||
\t<input type='hidden' name='idForm' id='LSform_idform' value='".$this -> idForm."'/>\n
|
||||
\t<input type='hidden' name='LSform_objecttype' id='LSform_objecttype' value='".$this -> ldapObject -> getType()."'/>\n
|
||||
\t<input type='hidden' name='LSform_objectdn' id='LSform_objectdn' value='".$this -> ldapObject -> getValue('dn')."'/>";
|
||||
$GLOBALS['Smarty'] -> assign('LSform_header',$LSform_header);
|
||||
\t<input type='hidden' name='LSform_objectdn' id='LSform_objectdn' value='".$this -> ldapObject -> getValue('dn')."'/>\n";
|
||||
|
||||
|
||||
$LSform_object = array(
|
||||
'type' => $this -> ldapObject -> getType(),
|
||||
'dn' => $this -> ldapObject -> getValue('dn')
|
||||
|
@ -97,6 +100,12 @@ class LSform {
|
|||
}
|
||||
$fields[] = $field;
|
||||
}
|
||||
|
||||
if ($this -> maxFileSize) {
|
||||
$LSform_header.="\t<input type='hidden' name='MAX_FILE_SIZE' value='".$this -> maxFileSize."'/>\n";
|
||||
}
|
||||
$GLOBALS['Smarty'] -> assign('LSform_header',$LSform_header);
|
||||
|
||||
$GLOBALS['Smarty'] -> assign('LSform_fields',$fields);
|
||||
if($this -> can_validate) {
|
||||
$GLOBALS['Smarty'] -> assign('LSform_submittxt',$this -> submit);
|
||||
|
@ -147,6 +156,19 @@ class LSform {
|
|||
$this -> _elementsErrors[$attr->name][]=$msg_error;
|
||||
}
|
||||
|
||||
/**
|
||||
* Savoir si des erreurs son définie pour un élement du formulaire
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @param[in] $element [<b>required</b>] string Le nom de l'élement
|
||||
*
|
||||
* @retval boolean
|
||||
*/
|
||||
function definedError($element) {
|
||||
return isset($this -> _elementsErrors[$element]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifie si le formulaire a été validé et que les données sont valides.
|
||||
*
|
||||
|
@ -204,7 +226,7 @@ class LSform {
|
|||
foreach($this -> _rules[$element] as $rule) {
|
||||
$ruleType="LSformRule_".$rule['name'];
|
||||
$GLOBALS['LSsession'] -> loadLSclass($ruleType);
|
||||
if (! call_user_func(array( $ruleType,'validate') , $value, $rule['options'])) {
|
||||
if (! call_user_func(array( $ruleType,'validate') , $value, $rule['options'], $this -> getElement($element))) {
|
||||
$retval=false;
|
||||
$this -> setElementError($this -> elements[$element],$rule['options']['msg']);
|
||||
}
|
||||
|
@ -273,14 +295,14 @@ class LSform {
|
|||
*
|
||||
* @retval LSformElement
|
||||
*/
|
||||
function addElement($type,$name,$label,$params=array()) {
|
||||
function addElement($type,$name,$label,$params=array(),&$attr_html=NULL) {
|
||||
$elementType='LSformElement_'.$type;
|
||||
$GLOBALS['LSsession'] -> loadLSclass($elementType);
|
||||
if (!class_exists($elementType)) {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(205,array('type' => $type));
|
||||
return;
|
||||
}
|
||||
$element=$this -> elements[$name] = new $elementType($this,$name,$label,$params);
|
||||
$element=$this -> elements[$name] = new $elementType($this,$name,$label,$params,$attr_html);
|
||||
if ($element) {
|
||||
return $element;
|
||||
}
|
||||
|
@ -412,6 +434,17 @@ class LSform {
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Défini la taille maximal pour les fichiers envoyés par le formualaire
|
||||
*
|
||||
* @param[in] $size La taille maximal en octets
|
||||
*
|
||||
* @retval void
|
||||
**/
|
||||
function setMaxFileSize($size) {
|
||||
$this -> maxFileSize = $size;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -37,6 +37,7 @@ class LSformElement {
|
|||
var $values = array();
|
||||
var $_required = false;
|
||||
var $_freeze = false;
|
||||
var $attr_html;
|
||||
|
||||
/**
|
||||
* Constructeur
|
||||
|
@ -52,11 +53,12 @@ class LSformElement {
|
|||
*
|
||||
* @retval true
|
||||
*/
|
||||
function LSformElement (&$form, $name, $label, $params){
|
||||
function LSformElement (&$form, $name, $label, $params,&$attr_html){
|
||||
$this -> name = $name;
|
||||
$this -> label = $label;
|
||||
$this -> params = $params;
|
||||
$this -> form = $form;
|
||||
$this -> attr_html = $attr_html;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
106
trunk/includes/class/class.LSformElement_image.php
Normal file
106
trunk/includes/class/class.LSformElement_image.php
Normal file
|
@ -0,0 +1,106 @@
|
|||
<?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 texte 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_image extends LSformElement {
|
||||
|
||||
var $postImage = NULL;
|
||||
var $tmp_file = array();
|
||||
|
||||
/*
|
||||
* 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 = true;
|
||||
if (!$this -> isFreeze()) {
|
||||
$id=$this -> name.'_'.rand();
|
||||
$return = $this -> getLabelInfos();
|
||||
$return['html'] = "<input type='file' name='".$this -> name."' class='LSform' id='$id' />\n";
|
||||
$this -> form -> setMaxFileSize(MAX_SEND_FILE_SIZE);
|
||||
}
|
||||
|
||||
if (!empty($this -> values[0])) {
|
||||
$img_path = $GLOBALS['LSsession'] -> getTmpFile($this -> values[0]);
|
||||
$GLOBALS['Smarty'] -> assign('LSform_image',array(
|
||||
'img' => $img_path,
|
||||
'id' => $id,
|
||||
));
|
||||
if (!$this -> isFreeze()) {
|
||||
$GLOBALS['Smarty'] -> assign('LSform_image_actions','delete');
|
||||
}
|
||||
|
||||
if ($this -> form -> definedError($this -> name)) {
|
||||
$GLOBALS['Smarty'] -> assign('LSform_image_errors',true);
|
||||
}
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Recupère la valeur de l'élement passée en POST
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* @param[] array Pointeur sur le tableau qui recupèrera la valeur.
|
||||
*
|
||||
* @retval boolean true si la valeur est présente en POST, false sinon
|
||||
*/
|
||||
function getPostData(&$return) {
|
||||
if($this -> isFreeze()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (is_uploaded_file($_FILES[$this -> name]['tmp_name'])) {
|
||||
debug($_FILES[$this -> name]['tmp_name']);
|
||||
$fp = fopen($_FILES[$this -> name]['tmp_name'], "r");
|
||||
$buf = fread($fp, filesize($_FILES[$this -> name]['tmp_name']));
|
||||
fclose($fp);
|
||||
$tmp_file = LS_TMP_DIR.$this -> name.'_'.rand().'.tmp';
|
||||
if (move_uploaded_file($_FILES[$this -> name]['tmp_name'],$tmp_file)) {
|
||||
$GLOBALS['LSsession'] -> addTmpFile($buf,$tmp_file);
|
||||
}
|
||||
$return[$this -> name][0] = $buf;
|
||||
}
|
||||
else {
|
||||
if (isset($_POST[$this -> name.'_delete'])) {
|
||||
$return[$this -> name][0]='';
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
95
trunk/includes/class/class.LSformElement_select_object.php
Normal file
95
trunk/includes/class/class.LSformElement_select_object.php
Normal file
|
@ -0,0 +1,95 @@
|
|||
<?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 select d'un formulaire pour LdapSaisie
|
||||
*
|
||||
* Cette classe définis les éléments select des formulaires.
|
||||
* Elle étant la classe basic LSformElement.
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*/
|
||||
|
||||
class LSformElement_select_object extends LSformElement {
|
||||
|
||||
/*
|
||||
* Retourn les infos d'affichage de l'élément
|
||||
*
|
||||
* Cette méthode retourne les informations d'affichage de l'élement
|
||||
*
|
||||
* @retval array
|
||||
*/
|
||||
function getDisplay($refresh=NULL){
|
||||
if ($refresh) {
|
||||
$this -> values = $this -> attr_html -> getValuesFromSession();
|
||||
}
|
||||
$return = $this -> getLabelInfos();
|
||||
// value
|
||||
$id=rand();
|
||||
|
||||
|
||||
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
|
||||
<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'/>";
|
||||
$class='LSformElement_select_object';
|
||||
}
|
||||
else {
|
||||
$class='';
|
||||
$delete='';
|
||||
$addBtn='';
|
||||
}
|
||||
|
||||
$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>";
|
||||
}
|
||||
$return['html'].="</ul>\n";
|
||||
if (!$this -> isFreeze()) {
|
||||
$GLOBALS['LSsession'] -> addJSscript('LSform.js');
|
||||
$GLOBALS['LSsession'] -> addJSscript('LSselect.js');
|
||||
$GLOBALS['LSsession'] -> addJSscript('LSsmoothbox.js');
|
||||
$GLOBALS['LSsession'] -> addCssFile('LSsmoothbox.css');
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Défini le type d'objet sélectionnable
|
||||
*
|
||||
* @param[in] $object string Le type d'object
|
||||
*
|
||||
* @retval void
|
||||
**/
|
||||
function setSelectableObject($object) {
|
||||
$this -> selectableObject = $object;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
|
@ -29,22 +29,23 @@ class LSformRule {
|
|||
|
||||
/**
|
||||
* Constructeur
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>*
|
||||
*/
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>*
|
||||
*/
|
||||
function LSformRule () {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validation de données
|
||||
*
|
||||
* @param mixed $value Données à valider
|
||||
* @param array $options Options de validation
|
||||
*
|
||||
* @return boolean True si les données sont valide, False sinon.
|
||||
*/
|
||||
function validate($value,$options=NULL) {
|
||||
*
|
||||
* @param mixed $value Données à valider
|
||||
* @param array $options Options de validation
|
||||
* @param object $formElement L'objet formElement attaché
|
||||
*
|
||||
* @return boolean True si les données sont valide, False sinon.
|
||||
*/
|
||||
function validate($value,$options=NULL,$formElement) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,16 +29,17 @@ class LSformRule_alphanumeric extends LSformRule {
|
|||
|
||||
/**
|
||||
* Vérification de la valeur.
|
||||
*
|
||||
* @param string $value Value à vérifier
|
||||
* @param array $options Options de validation (inutile ici)
|
||||
*
|
||||
* @return boolean true si la valeur est valide, false sinon
|
||||
*/
|
||||
function validate ($value,$options=array()) {
|
||||
*
|
||||
* @param string $value Value à vérifier
|
||||
* @param array $options Options de validation (inutile ici)
|
||||
* @param object $formElement L'objet formElement attaché
|
||||
*
|
||||
* @return boolean true si la valeur est valide, false sinon
|
||||
*/
|
||||
function validate ($value,$options=array(),$formElement) {
|
||||
$regex = '/^[a-zA-Z0-9]+$/';
|
||||
$GLOBALS['LSsession'] -> loadLSclass('LSformRule_regex');
|
||||
return LSformRule_regex :: validate($value,$regex);
|
||||
$GLOBALS['LSsession'] -> loadLSclass('LSformRule_regex');
|
||||
return LSformRule_regex :: validate($value,$regex,$formElement);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ class LSformRule_compare extends LSformRule {
|
|||
*/
|
||||
function _findOperator($operator_name) {
|
||||
|
||||
$_operators = array(
|
||||
$_operators = array(
|
||||
'eq' => '==',
|
||||
'neq' => '!=',
|
||||
'gt' => '>',
|
||||
|
@ -57,20 +57,21 @@ class LSformRule_compare extends LSformRule {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Vérification des valeurs.
|
||||
*
|
||||
* @param string $values Valeurs à vérifier
|
||||
* @param array $options Options de validation :
|
||||
* - Operateur : $options['params']['operator']
|
||||
*
|
||||
* @return boolean true si la valeur est valide, false sinon
|
||||
*/
|
||||
function validate ($values,$options=array()) {
|
||||
if (!isset($options['params']['operator'])) {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(303);
|
||||
return;
|
||||
}
|
||||
*
|
||||
* @param string $values Valeurs à vérifier
|
||||
* @param array $options Options de validation :
|
||||
* - Operateur : $options['params']['operator']
|
||||
* @param object $formElement L'objet formElement attaché
|
||||
*
|
||||
* @return boolean true si la valeur est valide, false sinon
|
||||
*/
|
||||
function validate ($values,$options=array(),$formElement) {
|
||||
if (!isset($options['params']['operator'])) {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(303);
|
||||
return;
|
||||
}
|
||||
$operator = LSformRule_compare :: _findOperator($options['params']['operator']);
|
||||
if ('==' != $operator && '!=' != $operator) {
|
||||
$compareFn = create_function('$a, $b', 'return floatval($a) ' . $operator . ' floatval($b);');
|
||||
|
|
|
@ -29,28 +29,29 @@ class LSformRule_email extends LSformRule {
|
|||
|
||||
/**
|
||||
* Vérification de la valeur.
|
||||
*
|
||||
* @param string $value Valeur à vérifier
|
||||
* @param array $options Options de validation :
|
||||
* - Check domain : $option['params']['checkDomain']
|
||||
*
|
||||
* @return boolean true si la valeur est valide, false sinon
|
||||
*/
|
||||
function validate($value,$option=array()) {
|
||||
$regex = '/^((\"[^\"\f\n\r\t\v\b]+\")|([\w\!\#\$\%\&\'\*\+\-\~\/\^\`\|\{\}]+(\.[\w\!\#\$\%\&\'\*\+\-\~\/\^\`\|\{\}]+)*))@((\[(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))\])|(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))|((([A-Za-z0-9\-])+\.)+[A-Za-z\-]+))$/';
|
||||
*
|
||||
* @param string $value Valeur à vérifier
|
||||
* @param array $options Options de validation :
|
||||
* - Check domain : $option['params']['checkDomain']
|
||||
* @param object $formElement L'objet formElement attaché
|
||||
*
|
||||
* @return boolean true si la valeur est valide, false sinon
|
||||
*/
|
||||
function validate($value,$option=array(),$formElement) {
|
||||
$regex = '/^((\"[^\"\f\n\r\t\v\b]+\")|([\w\!\#\$\%\&\'\*\+\-\~\/\^\`\|\{\}]+(\.[\w\!\#\$\%\&\'\*\+\-\~\/\^\`\|\{\}]+)*))@((\[(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))\])|(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))|((([A-Za-z0-9\-])+\.)+[A-Za-z\-]+))$/';
|
||||
|
||||
if (!preg_match($regex, $value)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if ($option['params']['checkDomain'] && function_exists('checkdnsrr')) {
|
||||
$tokens = explode('@', $email);
|
||||
if (!(checkdnsrr($tokens[1], 'MX') || checkdnsrr($tokens[1], 'A'))) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
68
trunk/includes/class/class.LSformRule_imagefile.php
Normal file
68
trunk/includes/class/class.LSformRule_imagefile.php
Normal file
|
@ -0,0 +1,68 @@
|
|||
<?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.
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
* Règle de validation : fichier de type image
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*/
|
||||
class LSformRule_imagefile extends LSformRule {
|
||||
|
||||
/**
|
||||
* Vérification de la valeur.
|
||||
*
|
||||
* @param string $values Valeur à vérifier
|
||||
* @param array $options Options de validation :
|
||||
* - Type MIME : $options['param']['mimeType']
|
||||
* - Type MIME (regex) : $options['param']['mimeTypeRegEx']
|
||||
* @param object $formElement L'objet formElement attaché
|
||||
*
|
||||
* @return boolean true si la valeur est valide, false sinon
|
||||
*/
|
||||
function validate ($value,$options,$formElement) {
|
||||
$file = $GLOBALS['LSsession'] -> getTmpFile($value);
|
||||
|
||||
$mimetype = mime_content_type($file);
|
||||
|
||||
if (isset($options['param']['mimeType'])) {
|
||||
if ($mimetype != $options['param']['mimeType']) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (isset($options['param']['mimeTypeRegEx'])) {
|
||||
$regex = $options['param']['mimeTypeRegEx'];
|
||||
}
|
||||
else {
|
||||
$regex = '/image\/.*/';
|
||||
}
|
||||
if (!preg_match($regex, $mimetype)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
63
trunk/includes/class/class.LSformRule_imagefilesize.php
Normal file
63
trunk/includes/class/class.LSformRule_imagefilesize.php
Normal file
|
@ -0,0 +1,63 @@
|
|||
<?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.
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
* Règle de validation : taille d'un fichier image
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*/
|
||||
class LSformRule_imagefilesize extends LSformRule {
|
||||
|
||||
/**
|
||||
* Vérification de la valeur.
|
||||
*
|
||||
* @param string $values Valeur à vérifier
|
||||
* @param array $options Options de validation :
|
||||
* - Taille max (en octet) : $options['param']['maxSize']
|
||||
* - Taille min (en octet) : $options['param']['minSize']
|
||||
* @param object $formElement L'objet formElement attaché
|
||||
*
|
||||
* @return boolean true si la valeur est valide, false sinon
|
||||
*/
|
||||
function validate ($value,$options,$formElement) {
|
||||
$file = $GLOBALS['LSsession'] -> getTmpFile($value);
|
||||
|
||||
$size = filesize($file);
|
||||
|
||||
if (is_int($options['param']['maxSize'])) {
|
||||
if ($size > $options['param']['maxSize']) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (is_int($options['param']['minSize'])) {
|
||||
if ($size < $options['param']['minSize']) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
74
trunk/includes/class/class.LSformRule_imagesize.php
Normal file
74
trunk/includes/class/class.LSformRule_imagesize.php
Normal file
|
@ -0,0 +1,74 @@
|
|||
<?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.
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
* Règle de validation : taille d'une image
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*/
|
||||
class LSformRule_imagesize extends LSformRule {
|
||||
|
||||
/**
|
||||
* Vérification de la valeur.
|
||||
*
|
||||
* @param string $values Valeur à vérifier
|
||||
* @param array $options Options de validation :
|
||||
* - Largeur max : $options['param']['maxWidth']
|
||||
* - Largeur min : $options['param']['minWidth']
|
||||
* - Hauteur max : $options['param']['maxHeight']
|
||||
* - Hauteur min : $options['param']['minHeight']
|
||||
* @param object $formElement L'objet formElement attaché
|
||||
*
|
||||
* @return boolean true si la valeur est valide, false sinon
|
||||
*/
|
||||
function validate ($value,$options,$formElement) {
|
||||
$file = $GLOBALS['LSsession'] -> getTmpFile($value);
|
||||
debug('Verify : '.$file.' - Options : '.print_r($options,true));
|
||||
list($width, $height, $type, $attr) = getimagesize($file);
|
||||
|
||||
if (is_int($options['param']['maxWidth'])) {
|
||||
if ($width > $options['param']['maxWidth']) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (is_int($options['param']['minWidth'])) {
|
||||
if ($width < $options['param']['minWidth']) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (is_int($options['param']['maxHeight'])) {
|
||||
if ($height > $options['param']['maxHeight']) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (is_int($options['param']['minHeight'])) {
|
||||
if ($height < $options['param']['minHeight']) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
|
@ -29,16 +29,17 @@ class LSformRule_lettersonly extends LSformRule {
|
|||
|
||||
/**
|
||||
* Vérification de la valeur.
|
||||
*
|
||||
* @param string $value Value à vérifier
|
||||
* @param array $options Options de validation (inutile ici)
|
||||
*
|
||||
* @return boolean true si la valeur est valide, false sinon
|
||||
*/
|
||||
function validate ($value,$options=array()) {
|
||||
*
|
||||
* @param string $value Value à vérifier
|
||||
* @param array $options Options de validation (inutile ici)
|
||||
* @param object $formElement L'objet formElement attaché
|
||||
*
|
||||
* @return boolean true si la valeur est valide, false sinon
|
||||
*/
|
||||
function validate ($value,$options=array(),$formElement) {
|
||||
$regex = '/^[a-zA-Z]+$/';
|
||||
$GLOBALS['LSsession'] -> loadLSclass('LSformRule_regex');
|
||||
return LSformRule_regex :: validate($value,$regex);
|
||||
$GLOBALS['LSsession'] -> loadLSclass('LSformRule_regex');
|
||||
return LSformRule_regex :: validate($value,$regex,$formElement);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,20 +27,21 @@
|
|||
*/
|
||||
class LSformRule_maxlength extends LSformRule {
|
||||
|
||||
/**
|
||||
/**
|
||||
* Vérification de la valeur.
|
||||
*
|
||||
* @param string $values Valeur à vérifier
|
||||
* @param array $options Options de validation :
|
||||
* - Longueur max : $options['params']['limit']
|
||||
*
|
||||
* @return boolean true si la valeur est valide, false sinon
|
||||
*/
|
||||
function validate ($value,$options) {
|
||||
if(!isset($options['params']['limit'])) {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(302);
|
||||
return;
|
||||
}
|
||||
*
|
||||
* @param string $values Valeur à vérifier
|
||||
* @param array $options Options de validation :
|
||||
* - Longueur max : $options['params']['limit']
|
||||
* @param object $formElement L'objet formElement attaché
|
||||
*
|
||||
* @return boolean true si la valeur est valide, false sinon
|
||||
*/
|
||||
function validate ($value,$options,$formElement) {
|
||||
if(!isset($options['params']['limit'])) {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(302);
|
||||
return;
|
||||
}
|
||||
return (strlen($value)<=$options['params']['limit']);
|
||||
}
|
||||
|
||||
|
|
|
@ -27,20 +27,21 @@
|
|||
*/
|
||||
class LSformRule_minlength extends LSformRule {
|
||||
|
||||
/**
|
||||
/**
|
||||
* Vérification de la valeur.
|
||||
*
|
||||
* @param string $values Valeur à vérifier
|
||||
* @param array $options Options de validation :
|
||||
* - Longueur min : $options['params']['limit']
|
||||
*
|
||||
* @return boolean true si la valeur est valide, false sinon
|
||||
*/
|
||||
function validate ($value,$options) {
|
||||
if(!isset($options['params']['limit'])) {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(302);
|
||||
return;
|
||||
}
|
||||
*
|
||||
* @param string $values Valeur à vérifier
|
||||
* @param array $options Options de validation :
|
||||
* - Longueur min : $options['params']['limit']
|
||||
* @param object $formElement L'objet formElement attaché
|
||||
*
|
||||
* @return boolean true si la valeur est valide, false sinon
|
||||
*/
|
||||
function validate ($value,$options,$formElement) {
|
||||
if(!isset($options['params']['limit'])) {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(302);
|
||||
return;
|
||||
}
|
||||
return (strlen($value)>=$options['params']['limit']);
|
||||
}
|
||||
|
||||
|
|
|
@ -27,18 +27,19 @@
|
|||
*/
|
||||
class LSformRule_nonzero extends LSformRule {
|
||||
|
||||
/**
|
||||
/**
|
||||
* Vérification de la valeur.
|
||||
*
|
||||
* @param string $values Valeur à vérifier
|
||||
* @param array $options Options de validation (inutile ici)
|
||||
*
|
||||
* @return boolean true si la valeur est valide, false sinon
|
||||
*/
|
||||
function validate ($value,$options) {
|
||||
*
|
||||
* @param string $values Valeur à vérifier
|
||||
* @param array $options Options de validation (inutile ici)
|
||||
* @param object $formElement L'objet formElement attaché
|
||||
*
|
||||
* @return boolean true si la valeur est valide, false sinon
|
||||
*/
|
||||
function validate ($value,$options,$formElement) {
|
||||
$regex = '/^-?[1-9][0-9]*/';
|
||||
$GLOBALS['LSsession'] -> loadLSclass('LSformRule_regex');
|
||||
return LSformRule_regex :: validate($value,$regex);
|
||||
$GLOBALS['LSsession'] -> loadLSclass('LSformRule_regex');
|
||||
return LSformRule_regex :: validate($value,$regex,$formElement);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,18 +27,19 @@
|
|||
*/
|
||||
class LSformRule_nopunctuation extends LSformRule {
|
||||
|
||||
/**
|
||||
/**
|
||||
* Vérification de la valeur.
|
||||
*
|
||||
* @param string $values Valeur à vérifier
|
||||
* @param array $options Options de validation (inutile ici)
|
||||
*
|
||||
* @return boolean true si la valeur est valide, false sinon
|
||||
*/
|
||||
function validate ($value,$options=array()) {
|
||||
*
|
||||
* @param string $values Valeur à vérifier
|
||||
* @param array $options Options de validation (inutile ici)
|
||||
* @param object $formElement L'objet formElement attaché
|
||||
*
|
||||
* @return boolean true si la valeur est valide, false sinon
|
||||
*/
|
||||
function validate ($value,$options=array(),$formElement) {
|
||||
$regex = '/^[^().\/\*\^\?#!@$%+=,\"\'><~\[\]{}]+$/';
|
||||
$GLOBALS['LSsession'] -> loadLSclass('LSformRule_regex');
|
||||
return LSformRule_regex :: validate($value,$regex);
|
||||
$GLOBALS['LSsession'] -> loadLSclass('LSformRule_regex');
|
||||
return LSformRule_regex :: validate($value,$regex,$formElement);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,18 +27,19 @@
|
|||
*/
|
||||
class LSformRule_numeric extends LSformRule{
|
||||
|
||||
/**
|
||||
/**
|
||||
* Vérification de la valeur.
|
||||
*
|
||||
* @param string $values Valeur à vérifier
|
||||
* @param array $options Options de validation (inutile ici)
|
||||
*
|
||||
* @return boolean true si la valeur est valide, false sinon
|
||||
*/
|
||||
function validate ($value,$options=array()) {
|
||||
*
|
||||
* @param string $values Valeur à vérifier
|
||||
* @param array $options Options de validation (inutile ici)
|
||||
* @param object $formElement L'objet formElement attaché
|
||||
*
|
||||
* @return boolean true si la valeur est valide, false sinon
|
||||
*/
|
||||
function validate ($value,$options=array(),$formElement) {
|
||||
$regex = '/(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/';
|
||||
$GLOBALS['LSsession'] -> loadLSclass('LSformRule_regex');
|
||||
return LSformRule_regex :: validate($value,$regex);
|
||||
$GLOBALS['LSsession'] -> loadLSclass('LSformRule_regex');
|
||||
return LSformRule_regex :: validate($value,$regex,$formElement);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,21 +27,22 @@
|
|||
*/
|
||||
class LSformRule_rangelength extends LSformRule {
|
||||
|
||||
/**
|
||||
/**
|
||||
* Vérification de la valeur.
|
||||
*
|
||||
* @param string $values Valeur à vérifier
|
||||
* @param array $options Options de validation :
|
||||
* - Longueur min : $options['params']['limits'][0]
|
||||
* - Longueur max : $options['params']['limits'][1]
|
||||
*
|
||||
* @return boolean true si la valeur est valide, false sinon
|
||||
*/
|
||||
function validate ($value,$options=array()) {
|
||||
if(!isset($options['params']['limits'])) {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(302);
|
||||
return;
|
||||
}
|
||||
*
|
||||
* @param string $values Valeur à vérifier
|
||||
* @param array $options Options de validation :
|
||||
* - Longueur min : $options['params']['limits'][0]
|
||||
* - Longueur max : $options['params']['limits'][1]
|
||||
* @param object $formElement L'objet formElement attaché
|
||||
*
|
||||
* @return boolean true si la valeur est valide, false sinon
|
||||
*/
|
||||
function validate ($value,$options=array(),$formElement) {
|
||||
if(!isset($options['params']['limits'])) {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(302);
|
||||
return;
|
||||
}
|
||||
$len=strlen($value);
|
||||
return ($len >= $$options['params']['limits'][0] && $len <= $$options['params']['limits'][1]);
|
||||
}
|
||||
|
|
|
@ -27,32 +27,33 @@
|
|||
*/
|
||||
class LSformRule_regex extends LSformRule {
|
||||
|
||||
/**
|
||||
/**
|
||||
* Vérification de la valeur.
|
||||
*
|
||||
* @param string $values Valeur à vérifier
|
||||
* @param array $options Options de validation :
|
||||
* - Regex : $option['params']['regex'] ou $option
|
||||
*
|
||||
* @return boolean true si la valeur est valide, false sinon
|
||||
*/
|
||||
function validate($value,$option) {
|
||||
if (is_array($option)) {
|
||||
if (isset($option['params']['regex'])) {
|
||||
$regex=$option['params']['regex'];
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(301);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$regex=$option;
|
||||
}
|
||||
*
|
||||
* @param string $values Valeur à vérifier
|
||||
* @param array $options Options de validation :
|
||||
* - Regex : $option['params']['regex'] ou $option
|
||||
* @param object $formElement L'objet formElement attaché
|
||||
*
|
||||
* @return boolean true si la valeur est valide, false sinon
|
||||
*/
|
||||
function validate($value,$option,$formElement) {
|
||||
if (is_array($option)) {
|
||||
if (isset($option['params']['regex'])) {
|
||||
$regex=$option['params']['regex'];
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(301);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$regex=$option;
|
||||
}
|
||||
if (!preg_match($regex, $value)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,15 +27,16 @@
|
|||
*/
|
||||
class LSformRule_required extends LSformRule {
|
||||
|
||||
/**
|
||||
/**
|
||||
* Vérification de la valeur.
|
||||
*
|
||||
* @param string $value Value à vérifier
|
||||
* @param array $options Options de validation (inutile ici)
|
||||
*
|
||||
* @return boolean true si la valeur est valide, false sinon
|
||||
*/
|
||||
function validate ($value,$option=NULL) {
|
||||
*
|
||||
* @param string $value Value à vérifier
|
||||
* @param array $options Options de validation (inutile ici)
|
||||
* @param object $formElement L'objet formElement attaché
|
||||
*
|
||||
* @return boolean true si la valeur est valide, false sinon
|
||||
*/
|
||||
function validate ($value,$option=NULL,$formElement) {
|
||||
return ((string)$value != '');
|
||||
}
|
||||
|
||||
|
|
|
@ -202,6 +202,8 @@ class LSldap {
|
|||
|
||||
/**
|
||||
* Met à jour une entrée dans l'annuaire
|
||||
*
|
||||
* Remarque : Supprime les valeurs vides de attributs et les attributs sans valeur.
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
|
@ -213,8 +215,30 @@ class LSldap {
|
|||
*/
|
||||
function update($object_type,$dn,$change) {
|
||||
debug($change);
|
||||
$dropAttr=array();
|
||||
if($entry=$this -> getEntry($object_type,$dn)) {
|
||||
$entry -> replace($change);
|
||||
foreach($change as $attrName => $attrVal) {
|
||||
$drop = true;
|
||||
if (is_array($attrVal)) {
|
||||
foreach($attrVal as $val) {
|
||||
if (!empty($val)) {
|
||||
$drop = false;
|
||||
$changeData[$attrName][]=$val;
|
||||
}
|
||||
}
|
||||
}
|
||||
if($drop) {
|
||||
$dropAttr[] = $attrName;
|
||||
}
|
||||
}
|
||||
$entry -> replace($changeData);
|
||||
debug('change : '.print_r($changeData,true));
|
||||
debug('drop : '.print_r($dropAttr,true));
|
||||
if (!empty($dropAttr)) {
|
||||
foreach($dropAttr as $attr) {
|
||||
$entry -> delete($attr);
|
||||
}
|
||||
}
|
||||
$ret = $entry -> update();
|
||||
if (Net_Ldap::isError($ret)) {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(5,$dn);
|
||||
|
|
|
@ -268,7 +268,7 @@ class LSldapObject {
|
|||
if(isset($this -> forms[$idForm]))
|
||||
$LSform = $this -> forms[$idForm][0];
|
||||
else {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(22,$this -> type_name);
|
||||
$GLOBALS['LSerror'] -> addErrorCode(22,$this -> getType());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -281,7 +281,7 @@ class LSldapObject {
|
|||
$LSform = $LSform[0];
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(23,$this -> type_name);
|
||||
$GLOBALS['LSerror'] -> addErrorCode(23,$this -> getType());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -452,12 +452,12 @@ class LSldapObject {
|
|||
}
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(24,array('attr' => $attr->name,'obj' => $this->type_name,'func' => $test['function']));
|
||||
$GLOBALS['LSerror'] -> addErrorCode(24,array('attr' => $attr->name,'obj' => $this->getType(),'func' => $test['function']));
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(25,array('attr' => $attr->name,'obj' => $this->type_name));
|
||||
$GLOBALS['LSerror'] -> addErrorCode(25,array('attr' => $attr->name,'obj' => $this->getType()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -510,7 +510,7 @@ class LSldapObject {
|
|||
if($dn) {
|
||||
$this -> dn=$dn;
|
||||
debug($submitData);
|
||||
return $GLOBALS['LSldap'] -> update($this -> type_name,$dn, $submitData);
|
||||
return $GLOBALS['LSldap'] -> update($this -> getType(),$dn, $submitData);
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(33);
|
||||
|
@ -867,7 +867,7 @@ class LSldapObject {
|
|||
}
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(31,$this -> type_name);
|
||||
$GLOBALS['LSerror'] -> addErrorCode(31,$this -> getType());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,12 +37,158 @@ class LSeegroup extends LSldapObject {
|
|||
* @param[in] $config array La configuration de l'objet
|
||||
*
|
||||
* @retval boolean true si l'objet a été construit, false sinon.
|
||||
*
|
||||
* @see LSldapObject::LSldapObject()
|
||||
*
|
||||
* @see LSldapObject::LSldapObject()
|
||||
*/
|
||||
function LSeegroup ($config='auto') {
|
||||
$this -> LSldapObject('LSeegroup',$config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne la liste des groupes d'un utilisateur
|
||||
*
|
||||
* Retourne un tableau de LSeegroup correspondant aux groupes
|
||||
* auxquels appartient un utilisateur
|
||||
*
|
||||
* @param[in] $userObject Un object LSeepeople
|
||||
*
|
||||
* @retval Array of LSeegroup Les groupes de l'utilisateur
|
||||
**/
|
||||
function listUserGroups($userObject) {
|
||||
$dn = $userObject -> getDn();
|
||||
$filter = $this -> getObjectFilter();
|
||||
$filter = '(&'.$filter.'(uniqueMember='.$dn.'))';
|
||||
return $this -> listObjects($filter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajoute un utilisateur au groupe
|
||||
*
|
||||
* @param[in] $object Un object LSeepeople : l'utilisateur à ajouter
|
||||
*
|
||||
* @retval boolean true si l'utilisateur à été ajouté, False sinon
|
||||
**/
|
||||
function addOneMember($object) {
|
||||
if ($object instanceof LSeepeople) {
|
||||
if ($this -> attrs['uniqueMember'] instanceof LSattribute) {
|
||||
$dn = $object -> getDn();
|
||||
$values = $this -> attrs['uniqueMember'] -> getValue();
|
||||
if (!is_array($values)) {
|
||||
$updateData = array($dn);
|
||||
}
|
||||
else if (!in_array($dn,$values)) {
|
||||
$values[]=$dn;
|
||||
$updateData = $values;
|
||||
}
|
||||
if (isset($updateData)) {
|
||||
return $GLOBALS['LSldap'] -> update($this -> getType(),$this -> getDn(), array('uniqueMember' => $updateData));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Supprime un utilisateur du groupe
|
||||
*
|
||||
* @param[in] $object Un object LSeepeople : l'utilisateur à supprimer
|
||||
*
|
||||
* @retval boolean true si l'utilisateur à été supprimé, False sinon
|
||||
**/
|
||||
function deleteOneMember($object) {
|
||||
if ($object instanceof LSeepeople) {
|
||||
if ($this -> attrs['uniqueMember'] instanceof LSattribute) {
|
||||
$dn = $object -> getDn();
|
||||
$values = $this -> attrs['uniqueMember'] -> getValue();
|
||||
if ((!is_array($values)) && (!empty($values))) {
|
||||
$values = array($values);
|
||||
}
|
||||
if (is_array($values)) {
|
||||
$updateData=array();
|
||||
foreach($values as $value) {
|
||||
if ($value!=$dn) {
|
||||
$updateData[]=$value;
|
||||
}
|
||||
}
|
||||
return $GLOBALS['LSldap'] -> update($this -> getType(),$this -> getDn(), array('uniqueMember' => $updateData));
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Met à jour les groupes d'un utilisateur
|
||||
*
|
||||
* @param[in] $userObject LSeepeople Un object LSeepeople : l'utilisateur
|
||||
* @param[in] $listDns Array(string) Un tableau des DNs des groupes de l'utilisateur
|
||||
*
|
||||
* @retval boolean true si tout c'est bien passé, False sinon
|
||||
**/
|
||||
function updateUserGroups($userObject,$listDns) {
|
||||
$currentGroups = $this -> listUserGroups($userObject);
|
||||
$type=$this -> getType();
|
||||
if(is_array($currentGroups)) {
|
||||
if (is_array($listDns)) {
|
||||
$dontDelete=array();
|
||||
$dontAdd=array();
|
||||
for ($i=0;$i<count($currentGroups);$i++) {
|
||||
$dn = $currentGroups[$i] -> getDn();
|
||||
if (in_array($dn, $listDns)) {
|
||||
$dontDelete[$i]=true;
|
||||
$dontAdd[]=$dn;
|
||||
}
|
||||
}
|
||||
|
||||
for($i=0;$i<count($currentGroups);$i++) {
|
||||
if ($dontDelete[$i]) {
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
if (!$currentGroups[$i] -> deleteOneMember($userObject)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach($listDns as $dn) {
|
||||
if (in_array($dn,$dontAdd)) {
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
$object = new $type();
|
||||
if ($object -> loadData($dn)) {
|
||||
if (!$object -> addOneMember($userObject)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(!is_array($listDns)) {
|
||||
return true;
|
||||
}
|
||||
foreach($listDns as $dn) {
|
||||
$object = new $type();
|
||||
if ($object -> loadData($dn)) {
|
||||
if (!$object -> addOneMember($userObject)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -45,6 +45,7 @@ class LSsession {
|
|||
'topDn_admin' => array ()
|
||||
);
|
||||
var $LSaccess = array();
|
||||
var $tmp_file = array();
|
||||
|
||||
/**
|
||||
* Constructeur
|
||||
|
@ -217,21 +218,27 @@ class LSsession {
|
|||
// Déconnexion
|
||||
if (isset($_GET['LSsession_logout'])) {
|
||||
session_destroy();
|
||||
|
||||
if (is_array($_SESSION['LSsession']['tmp_file'])) {
|
||||
$this -> tmp_file = $_SESSION['LSsession']['tmp_file'];
|
||||
}
|
||||
$this -> deleteTmpFile();
|
||||
unset($_SESSION['LSsession']);
|
||||
}
|
||||
|
||||
|
||||
if(isset($_SESSION['LSsession'])) {
|
||||
// Session existante
|
||||
$this -> confDir = $_SESSION['LSsession'] -> confDir;
|
||||
$this -> topDn = $_SESSION['LSsession'] -> topDn;
|
||||
//$this -> LSuserObject = $_SESSION['LSsession'] -> LSuserObject;
|
||||
$this -> dn = $_SESSION['LSsession'] -> dn;
|
||||
$this -> rdn = $_SESSION['LSsession'] -> rdn;
|
||||
$this -> ldapServerId = $_SESSION['LSsession'] -> ldapServerId;
|
||||
$this -> confDir = $_SESSION['LSsession']['confDir'];
|
||||
$this -> topDn = $_SESSION['LSsession']['topDn'];
|
||||
$this -> dn = $_SESSION['LSsession']['dn'];
|
||||
$this -> rdn = $_SESSION['LSsession']['rdn'];
|
||||
$this -> ldapServerId = $_SESSION['LSsession']['ldapServerId'];
|
||||
$this -> tmp_file = $_SESSION['LSsession']['tmp_file'];
|
||||
if ( ($GLOBALS['LSconfig']['cacheLSrights']) || ($this -> ldapServer['cacheLSrights']) ) {
|
||||
$this -> ldapServer = $_SESSION['LSsession'] -> ldapServer;
|
||||
$this -> LSrights = $_SESSION['LSsession'] -> LSrights;
|
||||
$this -> LSaccess = $_SESSION['LSsession'] -> LSaccess;
|
||||
$this -> ldapServer = $_SESSION['LSsession']['ldapServer'];
|
||||
$this -> LSrights = $_SESSION['LSsession']['LSrights'];
|
||||
$this -> LSaccess = $_SESSION['LSsession']['LSaccess'];
|
||||
if (!$this -> LSldapConnect())
|
||||
return;
|
||||
}
|
||||
|
@ -291,7 +298,7 @@ class LSsession {
|
|||
$this -> loadLSrights();
|
||||
$this -> loadLSaccess();
|
||||
$GLOBALS['Smarty'] -> assign('LSsession_username',$this -> LSuserObject -> getDisplayValue());
|
||||
$_SESSION['LSsession']=$this;
|
||||
$_SESSION['LSsession']=get_object_vars($this);
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
|
@ -357,7 +364,11 @@ class LSsession {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Retourne les sous-dns du serveur Ldap courant
|
||||
*
|
||||
* @retval mixed Tableau des subDn, false si une erreur est survenue.
|
||||
*/
|
||||
function getSubDnLdapServer() {
|
||||
if ( isset($this ->ldapServer['subdnobject']) ) {
|
||||
if( $this -> loadLSobject($this ->ldapServer['subdnobject']) ) {
|
||||
|
@ -485,6 +496,8 @@ class LSsession {
|
|||
* @retval void
|
||||
*/
|
||||
function addJSscript($script) {
|
||||
if (in_array($script, $this -> JSscripts))
|
||||
return;
|
||||
$this -> JSscripts[]=$script;
|
||||
}
|
||||
|
||||
|
@ -514,15 +527,25 @@ class LSsession {
|
|||
foreach ($GLOBALS['defaultJSscipts'] as $script) {
|
||||
$JSscript_txt.="<script src='".LS_JS_DIR.$script."' type='text/javascript'></script>\n";
|
||||
}
|
||||
|
||||
foreach ($this -> JSscripts as $script) {
|
||||
$JSscript_txt.="<script src='".LS_JS_DIR.$script."' type='text/javascript'></script>\n";
|
||||
}
|
||||
|
||||
if ($GLOBALS['LSdebug']['active']) {
|
||||
$JSscript_txt.="<script type='text/javascript'>LSdebug_active = 1;</script>\n";
|
||||
}
|
||||
else {
|
||||
$JSscript_txt.="<script type='text/javascript'>LSdebug_active = 0;</script>\n";
|
||||
}
|
||||
|
||||
$GLOBALS['Smarty'] -> assign('LSsession_js',$JSscript_txt);
|
||||
|
||||
// Css
|
||||
$Css_txt="<link rel='stylesheet' type='text/css' href='templates/css/LSdefault.css' media='screen' />\n";
|
||||
$Css_txt="<link rel='stylesheet' type='text/css' href='templates/css/LSdefault.css' />\n";
|
||||
$Css_txt="<link rel='stylesheet' type='text/css' href='templates/css/LSdefault.css' />\n";
|
||||
foreach ($this -> CssFiles as $file) {
|
||||
$Css_txt.="<link rel='stylesheet' type='text/css' href='templates/css/$file' media='screen' />\n";
|
||||
$Css_txt.="<link rel='stylesheet' type='text/css' href='templates/css/$file' />\n";
|
||||
}
|
||||
$GLOBALS['Smarty'] -> assign('LSsession_css',$Css_txt);
|
||||
|
||||
|
@ -581,7 +604,6 @@ class LSsession {
|
|||
}
|
||||
}
|
||||
}
|
||||
debug($this -> LSrights['topDn_admin']);
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
|
@ -754,6 +776,127 @@ class LSsession {
|
|||
function canCreate($LSobject) {
|
||||
return $this -> canAccess($LSobject,NULL,'w','rdn');
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne le droit de l'utilisateur à gérer la relation d'objet
|
||||
*
|
||||
* @param[in] string $dn Le DN de l'objet (le container_dn du type de l'objet par défaut)
|
||||
* @param[in] string $relationName Le nom de la relation avec l'objet
|
||||
* @param[in] string $right Le type de droit a vérifier ('r' ou 'w')
|
||||
*
|
||||
* @retval boolean True si l'utilisateur a accès, false sinon
|
||||
*/
|
||||
function relationCanAccess($dn,$relationName,$right=NULL) {
|
||||
$LSobject=$this -> LSuserObject -> getType();
|
||||
if (!isset($GLOBALS['LSobjects'][$LSobject]['relations'][$relationName]))
|
||||
return;
|
||||
$whoami = $this -> whoami($dn);
|
||||
|
||||
if (($right=='w') || ($right=='r')) {
|
||||
if ($GLOBALS['LSobjects'][$LSobject]['relations'][$relationName]['rights'][$whoami] == $right) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (($GLOBALS['LSobjects'][$LSobject]['relations'][$relationName]['rights'][$whoami] == 'w') || ($GLOBALS['LSobjects'][$LSobject]['relations'][$relationName]['rights'][$whoami] == 'r')) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne le droit de l'utilisateur à modifier la relation d'objet
|
||||
*
|
||||
* @param[in] string $dn Le DN de l'objet (le container_dn du type de l'objet par défaut)
|
||||
* @param[in] string $relationName Le nom de la relation avec l'objet
|
||||
*
|
||||
* @retval boolean True si l'utilisateur a accès, false sinon
|
||||
*/
|
||||
function relationCanEdit($dn,$relationName) {
|
||||
return $this -> relationCanAccess($dn,$relationName,'w');
|
||||
}
|
||||
|
||||
/*
|
||||
* Ajoute un fichier temporaire
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @retval void
|
||||
**/
|
||||
function addTmpFile($value,$filePath) {
|
||||
$hash = mhash(MHASH_MD5,$value);
|
||||
$this -> tmp_file[$filePath] = $hash;
|
||||
$_SESSION['LSsession']['tmp_file'][$filePath] = $hash;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne le chemin du fichier temporaire si l'existe
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @param[in] $value La valeur du fichier
|
||||
*
|
||||
* @retval mixed
|
||||
**/
|
||||
function tmpFileExist($value) {
|
||||
$hash = mhash(MHASH_MD5,$value);
|
||||
foreach($this -> tmp_file as $filePath => $contentHash) {
|
||||
if ($hash == $contentHash) {
|
||||
return $filePath;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne le chemin du fichier temporaire
|
||||
*
|
||||
* Retourne le chemin du fichier temporaire qu'il créera à partir de la valeur
|
||||
* s'il n'existe pas déjà.
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @param[in] $value La valeur du fichier
|
||||
*
|
||||
* @retval mixed
|
||||
**/
|
||||
function getTmpFile($value) {
|
||||
$exist = $this -> tmpFileExist($value);
|
||||
if (!$exist) {
|
||||
$img_path = LS_TMP_DIR .rand().'.tmp';
|
||||
$fp = fopen($img_path, "w");
|
||||
fwrite($fp, $value);
|
||||
fclose($fp);
|
||||
$this -> addTmpFile($value,$img_path);
|
||||
return $img_path;
|
||||
}
|
||||
else {
|
||||
return $exist;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Supprime les fichiers temporaires
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @retval void
|
||||
**/
|
||||
function deleteTmpFile($filePath=NULL) {
|
||||
if ($filePath) {
|
||||
@unlink($filePath);
|
||||
unset($this -> tmp_file[$filePath]);
|
||||
unset($_SESSION['LSsession']['tmp_file'][$filePath]);
|
||||
}
|
||||
else {
|
||||
foreach($this -> tmp_file as $file => $content) {
|
||||
@unlink($file);
|
||||
}
|
||||
$this -> tmp_file = array();
|
||||
$_SESSION['LSsession']['tmp_file'] = array();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
var LSdefault = new Class({
|
||||
initialize: function(){
|
||||
LSdebug('toto');
|
||||
this.LSdebug = $('LSdebug');
|
||||
this.LSdebugInfos = $('LSdebug_infos');
|
||||
this.LSdebug.setOpacity(0);
|
||||
|
@ -15,6 +14,10 @@ var LSdefault = new Class({
|
|||
if (this.LSerror.innerHTML != '') {
|
||||
this.displayLSerror();
|
||||
}
|
||||
|
||||
this.loading_img=[];
|
||||
LSdebug(this.loading_img);
|
||||
this.loading_img_id=-1;
|
||||
},
|
||||
|
||||
onLSdebugHiddenClick: function(event){
|
||||
|
@ -23,6 +26,7 @@ var LSdefault = new Class({
|
|||
},
|
||||
|
||||
displayDebugBox: function() {
|
||||
this.LSdebug.setStyle('top',getScrollTop()+10);
|
||||
new Fx.Style(this.LSdebug,'opacity',{duration:500}).start(0,0.8);
|
||||
},
|
||||
|
||||
|
@ -33,18 +37,36 @@ var LSdefault = new Class({
|
|||
},
|
||||
|
||||
displayLSerror: function() {
|
||||
this.LSerror.setStyle('top',getScrollTop()+10);
|
||||
new Fx.Style(this.LSerror,'opacity',{duration:500}).start(0,0.8);
|
||||
(function(){new Fx.Style(this.LSerror,'opacity',{duration:500}).start(0.8,0);}).delay(5000, this);
|
||||
},
|
||||
|
||||
loadingImgDisplay: function(el) {
|
||||
this.loading_img = new Element('img');
|
||||
this.loading_img.src='templates/images/ajax-loader.gif';
|
||||
this.loading_img.injectAfter(el);
|
||||
loadingImgDisplay: function(el,position) {
|
||||
this.loading_img_id++;
|
||||
this.loading_img[this.loading_img_id] = new Element('img');
|
||||
this.loading_img[this.loading_img_id].src='templates/images/ajax-loader.gif';
|
||||
if (position=='inside') {
|
||||
this.loading_img[this.loading_img_id].injectInside(el);
|
||||
}
|
||||
else {
|
||||
this.loading_img[this.loading_img_id].injectAfter(el);
|
||||
}
|
||||
LSdebug(this.loading_img_id);
|
||||
return this.loading_img_id;
|
||||
},
|
||||
|
||||
loadingImgHide: function() {
|
||||
this.loading_img.remove();
|
||||
loadingImgHide: function(id) {
|
||||
if (isNaN(id)) {
|
||||
this.loading_img.each(function(el) {
|
||||
if (typeof(el) != 'undefined')
|
||||
el.remove();
|
||||
},this);
|
||||
this.loading_img_id=-1;
|
||||
}
|
||||
else {
|
||||
this.loading_img[id].remove();
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
@ -52,7 +74,7 @@ window.addEvent(window.ie ? 'load' : 'domready', function() {
|
|||
varLSdefault = new LSdefault();
|
||||
});
|
||||
|
||||
LSdebug_active = 1;
|
||||
LSdebug_active = 0;
|
||||
|
||||
function LSdebug() {
|
||||
if (LSdebug_active != 1) return;
|
||||
|
|
|
@ -7,6 +7,39 @@ var LSform = new Class({
|
|||
$$('img.LSform-remove-field-btn').each(function(el) {
|
||||
el.addEvent('click',this.onRemoveFieldBtnClick.bind(this,el));
|
||||
}, this);
|
||||
|
||||
$$('div.LSform_image').each(function(el) {
|
||||
el.addEvent('mouseenter',this.onMouseEnterImage.bind(this));
|
||||
}, this);
|
||||
|
||||
$$('div.LSform_image').each(function(el) {
|
||||
el.addEvent('mouseleave',this.onMouseLeaveImage.bind(this));
|
||||
}, this);
|
||||
|
||||
$$('img.LSform_image_action_zoom').each(function(el) {
|
||||
el.addEvent('click',this.zoomImg.bindWithEvent(this,el.getParent().getParent().getNext().src));
|
||||
}, this);
|
||||
|
||||
$$('img.LSform_image_action_delete').each(function(el) {
|
||||
el.addEvent('click',this.onImageDeleteBtnClick.bind(this,el));
|
||||
}, this);
|
||||
|
||||
this.initialiseLSformElement_select_object();
|
||||
},
|
||||
|
||||
initialiseLSformElement_select_object: function() {
|
||||
$$('a.LSformElement_select_object_addBtn').each(function(el) {
|
||||
el.addEvent('click',this.onLSformElement_select_object_addBtnClick.bindWithEvent(this,el));
|
||||
}, this);
|
||||
|
||||
$$('img.LSformElement_select_object_deleteBtn').each(function(el) {
|
||||
el.addEvent('click',this.LSformElement_select_object_deleteBtn.bind(this,el));
|
||||
}, this);
|
||||
},
|
||||
|
||||
zoomImg: function(event, src) {
|
||||
new Event(event).stop();
|
||||
varLSsmoothbox.openImg(src);
|
||||
},
|
||||
|
||||
onAddFieldBtnClick: function(img){
|
||||
|
@ -20,7 +53,7 @@ var LSform = new Class({
|
|||
action: 'onAddFieldBtnClick',
|
||||
attribute: attrName,
|
||||
objecttype: $('LSform_objecttype').value,
|
||||
objectdn: $('LSform_objectdn').value,
|
||||
objectdn: $('LSform_objectdn').value,
|
||||
idform: $('LSform_idform').value,
|
||||
img: img.id
|
||||
};
|
||||
|
@ -60,6 +93,109 @@ var LSform = new Class({
|
|||
else {
|
||||
img.getParent().remove();
|
||||
}
|
||||
},
|
||||
|
||||
onMouseEnterImage: function() {
|
||||
$$('ul.LSform_image_actions').each(function(el) {
|
||||
el.setStyle('visibility','visible');
|
||||
}, this);
|
||||
},
|
||||
|
||||
onMouseLeaveImage: function() {
|
||||
$$('ul.LSform_image_actions').each(function(el) {
|
||||
el.setStyle('visibility','hidden');
|
||||
}, this);
|
||||
},
|
||||
|
||||
onImageDeleteBtnClick: function(img) {
|
||||
$$('form.LSform').each(function(el) {
|
||||
var input = new Element('input');
|
||||
input.type = 'hidden';
|
||||
var getInputId = /LSform_image_action_delete_(.*)/
|
||||
input.name = $(getInputId.exec(img.id)[1]).name + '_delete';
|
||||
input.value='delete';
|
||||
input.injectInside(el);
|
||||
},this);
|
||||
img.getParent().getParent().getParent().remove();
|
||||
},
|
||||
|
||||
onLSformElement_select_object_addBtnClick: function(event,a) {
|
||||
new Event(event).stop();
|
||||
var getFieldId = /a_(.*)/
|
||||
var fieldId = getFieldId.exec(a.id)[1];
|
||||
var getId = /a_LSformElement_select_object_.*_([0-9]*)$/
|
||||
var Id = getId.exec(a.id)[1];
|
||||
|
||||
values = new Array();
|
||||
$$('input.LSformElement_select_object').each(function(el) {
|
||||
values.push(el.getProperty('value'));
|
||||
}, this);
|
||||
|
||||
var data = {
|
||||
template: 'LSselect',
|
||||
action: 'refreshSession',
|
||||
objecttype: $('LSformElement_select_object_objecttype_'+Id).value,
|
||||
values: Json.toString(values),
|
||||
href: a.href
|
||||
};
|
||||
|
||||
LSdebug(data);
|
||||
|
||||
data.imgload=varLSdefault.loadingImgDisplay(a,'inside');
|
||||
this.refreshFields=fieldId;
|
||||
new Ajax('index_ajax.php', {data: data, onComplete: this.onLSformElement_select_object_addBtnClickComplete.bind(this)}).request();
|
||||
},
|
||||
|
||||
onLSformElement_select_object_addBtnClickComplete: function(responseText, responseXML) {
|
||||
var data = Json.evaluate(responseText);
|
||||
LSdebug(data);
|
||||
if ( data ) {
|
||||
if ( typeof(data.LSerror) != "undefined" ) {
|
||||
varLSdefault.displayError(data.LSerror);
|
||||
return;
|
||||
}
|
||||
else {
|
||||
varLSdefault.loadingImgHide(data.imgload);
|
||||
varLSsmoothbox.openURL(data.href,this);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
refresh: function() {
|
||||
var getAttrName = /LSformElement_select_object_(.*)_[0-9]*/
|
||||
var attrName = getAttrName.exec(this.refreshFields)[1];
|
||||
var data = {
|
||||
template: 'LSform',
|
||||
action: 'refreshField',
|
||||
attribute: attrName,
|
||||
objecttype: $('LSform_objecttype').value,
|
||||
objectdn: $('LSform_objectdn').value,
|
||||
idform: $('LSform_idform').value,
|
||||
ul: this.refreshFields
|
||||
};
|
||||
LSdebug(data);
|
||||
data.imgload=varLSdefault.loadingImgDisplay($('a_' + this.refreshFields));
|
||||
new Ajax('index_ajax.php', {data: data, onComplete: this.onRefreshComplete.bind(this)}).request();
|
||||
},
|
||||
|
||||
onRefreshComplete: function(responseText, responseXML) {
|
||||
var data = Json.evaluate(responseText);
|
||||
if ( data ) {
|
||||
if ( typeof(data.LSerror) != "undefined" ) {
|
||||
varLSdefault.loadingImgHide();
|
||||
varLSdefault.displayError(data.LSerror);
|
||||
return;
|
||||
}
|
||||
else {
|
||||
varLSdefault.loadingImgHide(data.imgload);
|
||||
$(this.refreshFields).getParent().setHTML(data.html);
|
||||
this.initialiseLSformElement_select_object();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
LSformElement_select_object_deleteBtn: function(img) {
|
||||
img.getParent().remove();
|
||||
}
|
||||
|
||||
});
|
||||
|
|
152
trunk/includes/js/LSrelation.js
Normal file
152
trunk/includes/js/LSrelation.js
Normal file
|
@ -0,0 +1,152 @@
|
|||
var LSrelation = new Class({
|
||||
initialize: function(){
|
||||
this.edit = 0;
|
||||
this.deleteBtn = [];
|
||||
this.deleteBtnId = 0;
|
||||
this.refreshRelation=0;
|
||||
$$('a.LSrelation_modify').each(function(el) {
|
||||
this.edit=1;
|
||||
el.addEvent('click',this.onLSrelationModifyBtnClick.bindWithEvent(this,el));
|
||||
}, this);
|
||||
if (this.edit) {
|
||||
this.initializeBtn();
|
||||
}
|
||||
},
|
||||
|
||||
initializeBtn: function() {
|
||||
$$('img.LSrelation-btn').each(function(el) {
|
||||
el.remove();
|
||||
}, this);
|
||||
this.deleteBtnId = 0;
|
||||
$$('li.LSrelation').each(function(li) {
|
||||
this.deleteBtn[this.deleteBtnId] = new Element('img');
|
||||
this.deleteBtn[this.deleteBtnId].src = 'templates/images/delete.png';
|
||||
this.deleteBtn[this.deleteBtnId].setStyle('cursor','pointer');
|
||||
this.deleteBtn[this.deleteBtnId].addClass('LSrelation-btn');
|
||||
this.deleteBtn[this.deleteBtnId].addEvent('click',this.onDeleteBtnClick.bind(this,this.deleteBtn[this.deleteBtnId]));
|
||||
this.deleteBtn[this.deleteBtnId].injectInside(li);
|
||||
li.id=this.deleteBtnId;
|
||||
this.deleteBtnId++;
|
||||
}, this);
|
||||
},
|
||||
|
||||
onDeleteBtnClick: function(img) {
|
||||
li = img.getParent();
|
||||
ul = li.getParent();
|
||||
img.remove();
|
||||
LSdebug(ul.id);
|
||||
var getId = /LSrelation_ul_([0-9]*)/
|
||||
var id = getId.exec(ul.id)[1];
|
||||
|
||||
var data = {
|
||||
template: 'LSrelation',
|
||||
action: 'deleteByDisplayValue',
|
||||
id: id,
|
||||
value: li.innerHTML
|
||||
};
|
||||
this.deleteLi = li;
|
||||
data.imgload=varLSdefault.loadingImgDisplay(li.id,'inside');
|
||||
LSdebug(data);
|
||||
new Ajax('index_ajax.php', {data: data, onComplete: this.onDeleteBtnClickComplete.bind(this)}).request();
|
||||
},
|
||||
|
||||
onDeleteBtnClickComplete: function(responseText, responseXML) {
|
||||
var data = Json.evaluate(responseText);
|
||||
LSdebug(data);
|
||||
if ( data ) {
|
||||
if ( typeof(data.LSerror) != "undefined" ) {
|
||||
if (data.imgload!='') {
|
||||
varLSdefault.loadingImgHide(data.imgload);
|
||||
}
|
||||
else {
|
||||
varLSdefault.loadingImgHide();
|
||||
}
|
||||
varLSdefault.displayError(data.LSerror);
|
||||
return;
|
||||
}
|
||||
else {
|
||||
varLSdefault.loadingImgHide(data.imgload);
|
||||
this.deleteLi.remove();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
onLSrelationModifyBtnClick: function(event,a) {
|
||||
new Event(event).stop();
|
||||
|
||||
var data = {
|
||||
template: 'LSrelation',
|
||||
action: 'refreshSession',
|
||||
id: a.id,
|
||||
href: a.href
|
||||
};
|
||||
|
||||
LSdebug(data);
|
||||
this.refreshRelation=a.id;
|
||||
data.imgload=varLSdefault.loadingImgDisplay('LSrelation_title_'+a.id,'inside');
|
||||
new Ajax('index_ajax.php', {data: data, onComplete: this.onLSrelationModifyBtnClickComplete.bind(this)}).request();
|
||||
},
|
||||
|
||||
onLSrelationModifyBtnClickComplete: function(responseText, responseXML) {
|
||||
var data = Json.evaluate(responseText);
|
||||
LSdebug(data);
|
||||
if ( data ) {
|
||||
if ( typeof(data.LSerror) != "undefined" ) {
|
||||
if (data.imgload!='') {
|
||||
varLSdefault.loadingImgHide(data.imgload);
|
||||
}
|
||||
else {
|
||||
varLSdefault.loadingImgHide();
|
||||
}
|
||||
varLSdefault.displayError(data.LSerror);
|
||||
return;
|
||||
}
|
||||
else {
|
||||
varLSdefault.loadingImgHide(data.imgload);
|
||||
varLSsmoothbox.openURL(data.href,this);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
refresh: function() {
|
||||
var data = {
|
||||
template: 'LSrelation',
|
||||
action: 'refreshList',
|
||||
id: this.refreshRelation
|
||||
};
|
||||
|
||||
LSdebug(data);
|
||||
data.imgload=varLSdefault.loadingImgDisplay('LSrelation_title_'+this.refreshRelation,'inside');
|
||||
new Ajax('index_ajax.php', {data: data, onComplete: this.onRrefreshComplete.bind(this)}).request();
|
||||
},
|
||||
|
||||
onRrefreshComplete: function(responseText, responseXML) {
|
||||
var data = Json.evaluate(responseText);
|
||||
LSdebug(data);
|
||||
if ( data ) {
|
||||
if ( typeof(data.LSerror) != "undefined" ) {
|
||||
if (data.imgload!='') {
|
||||
varLSdefault.loadingImgHide(data.imgload);
|
||||
}
|
||||
else {
|
||||
varLSdefault.loadingImgHide();
|
||||
}
|
||||
varLSdefault.displayError(data.LSerror);
|
||||
return;
|
||||
}
|
||||
else {
|
||||
varLSdefault.loadingImgHide(data.imgload);
|
||||
$('LSrelation_ul_'+this.refreshRelation).setHTML(data.html);
|
||||
this.initializeBtn();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
});
|
||||
|
||||
window.addEvent(window.ie ? 'load' : 'domready', function() {
|
||||
varLSrelation = new LSrelation();
|
||||
});
|
||||
|
||||
LSdebug('titi');
|
92
trunk/includes/js/LSselect.js
Normal file
92
trunk/includes/js/LSselect.js
Normal file
|
@ -0,0 +1,92 @@
|
|||
var LSselect = new Class({
|
||||
initialize: function(){
|
||||
this.initializeContent();
|
||||
|
||||
$$('form.LSselect_search').each(function(el) {
|
||||
var input = new Element('input');
|
||||
input.setProperty('name','ajax');
|
||||
input.setProperty('type','hidden');
|
||||
input.injectInside(el);
|
||||
el.addEvent('submit',this.onSubmitSearchForm.bindWithEvent(this,el));
|
||||
}, this);
|
||||
|
||||
},
|
||||
|
||||
initializeContent: function() {
|
||||
$$('input.LSobject-select').each(function(el) {
|
||||
el.addEvent('click',this.oncheckboxChange.bind(this,el));
|
||||
}, this);
|
||||
|
||||
$$('a.LSobject-list-page').each(function(el) {
|
||||
el.addEvent('click',this.onChangePageClick.bindWithEvent(this,el));
|
||||
}, this);
|
||||
},
|
||||
|
||||
oncheckboxChange: function(checkbox){
|
||||
if (checkbox.checked) {
|
||||
var data = {
|
||||
template: 'LSselect',
|
||||
action: 'addLSselectobject-item',
|
||||
objectdn: checkbox.value,
|
||||
objecttype: $('LSselect-object').getProperties('caption').caption
|
||||
};
|
||||
LSdebug('plus');
|
||||
}
|
||||
else {
|
||||
LSdebug('mois');
|
||||
var data = {
|
||||
template: 'LSselect',
|
||||
action: 'dropLSselectobject-item',
|
||||
objectdn: checkbox.value,
|
||||
objecttype: $('LSselect-object').getProperties('caption').caption
|
||||
};
|
||||
}
|
||||
LSdebug(data);
|
||||
data.imgload=varLSdefault.loadingImgDisplay(checkbox.getParent().getNext(),'inside');
|
||||
new Ajax('index_ajax.php', {data: data, onComplete: this.oncheckboxChangeComplete.bind(this)}).request();
|
||||
},
|
||||
|
||||
oncheckboxChangeComplete: function(responseText, responseXML) {
|
||||
var data = Json.evaluate(responseText);
|
||||
varLSdefault.loadingImgHide(data);
|
||||
},
|
||||
|
||||
onChangePageClick: function(event, a) {
|
||||
new Event(event).stop();
|
||||
var data = {
|
||||
ajax: true
|
||||
};
|
||||
this.searchImgload = varLSdefault.loadingImgDisplay($('title'),'inside');
|
||||
new Ajax(a.href, {data: data, onComplete: this.onChangePageClickComplete.bind(this)}).request();
|
||||
},
|
||||
|
||||
onChangePageClickComplete: function(responseText, responseXML) {
|
||||
varLSdefault.loadingImgHide(this.searchImgload);
|
||||
$('content').setHTML(responseText);
|
||||
this.initializeContent();
|
||||
},
|
||||
|
||||
onSubmitSearchForm: function(event, form) {
|
||||
new Event(event).stop();
|
||||
var imgload = varLSdefault.loadingImgDisplay($('title'),'inside');
|
||||
form.send({
|
||||
update: $('content'),
|
||||
onComplete: this.onSubmitSearchFormComplete.bind(this,imgload)
|
||||
});
|
||||
},
|
||||
|
||||
onSubmitSearchFormComplete: function(imgload) {
|
||||
varLSdefault.loadingImgHide(imgload);
|
||||
this.initializeContent();
|
||||
},
|
||||
|
||||
submit: function() {
|
||||
var values = new Array();
|
||||
$('content').getElements('input[name^=LSobjects_selected]').each(function(el) {
|
||||
values.push(el.value);
|
||||
},this);
|
||||
return values;
|
||||
}
|
||||
|
||||
|
||||
});
|
|
@ -1,47 +1,48 @@
|
|||
var LSsession_login = new Class({
|
||||
initialize: function(){
|
||||
this.select_ldapserver = $('LSsession_ldapserver');
|
||||
if ( ! this.select_ldapserver )
|
||||
return;
|
||||
this.select_ldapserver.addEvent('change',this.onLdapServerChanged.bind(this));
|
||||
this.select_ldapserver = $('LSsession_ldapserver');
|
||||
if ( ! this.select_ldapserver )
|
||||
return;
|
||||
this.select_ldapserver.addEvent('change',this.onLdapServerChanged.bind(this));
|
||||
},
|
||||
|
||||
onLdapServerChanged: function(){
|
||||
varLSdefault.loadingImgDisplay(this.select_ldapserver);
|
||||
var server = this.select_ldapserver.value;
|
||||
var data = {
|
||||
template: 'login',
|
||||
action: 'onLdapServerChanged',
|
||||
server: server
|
||||
};
|
||||
new Ajax('index_ajax.php', {data: data, onComplete: this.onLdapServerChangedComplete.bind(this)}).request();
|
||||
},
|
||||
onLdapServerChanged: function(){
|
||||
var imgload = varLSdefault.loadingImgDisplay(this.select_ldapserver);
|
||||
var server = this.select_ldapserver.value;
|
||||
var data = {
|
||||
template: 'login',
|
||||
action: 'onLdapServerChanged',
|
||||
server: server,
|
||||
imgload: imgload
|
||||
};
|
||||
new Ajax('index_ajax.php', {data: data, onComplete: this.onLdapServerChangedComplete.bind(this)}).request();
|
||||
},
|
||||
|
||||
onLdapServerChangedComplete: function(responseText, responseXML){
|
||||
varLSdefault.loadingImgHide();
|
||||
var data = Json.evaluate(responseText);
|
||||
LSdebug(data);
|
||||
if ( data ) {
|
||||
if (data.LSerror) {
|
||||
varLSdefault.displayError(data.LSerror);
|
||||
return;
|
||||
}
|
||||
else {
|
||||
$('LSsession_topDn').getParent().setHTML(data.list_topDn);
|
||||
LSdebug($('LSsession_topDn').innerHTML);
|
||||
$$('.loginform-level').each(function(el) {
|
||||
el.setStyle('display','block');
|
||||
});
|
||||
}
|
||||
}
|
||||
else {
|
||||
$$('.loginform-level').each(function(el) {
|
||||
el.setStyle('display','none');
|
||||
});
|
||||
$('LSsession_topDn').empty();
|
||||
}
|
||||
}
|
||||
onLdapServerChangedComplete: function(responseText, responseXML){
|
||||
varLSdefault.loadingImgHide();
|
||||
var data = Json.evaluate(responseText);
|
||||
LSdebug(data);
|
||||
if ( data ) {
|
||||
if (data.LSerror) {
|
||||
varLSdefault.displayError(data.LSerror);
|
||||
return;
|
||||
}
|
||||
else {
|
||||
$('LSsession_topDn').getParent().setHTML(data.list_topDn);
|
||||
LSdebug($('LSsession_topDn').innerHTML);
|
||||
$$('.loginform-level').each(function(el) {
|
||||
el.setStyle('display','block');
|
||||
});
|
||||
}
|
||||
}
|
||||
else {
|
||||
$$('.loginform-level').each(function(el) {
|
||||
el.setStyle('display','none');
|
||||
});
|
||||
$('LSsession_topDn').empty();
|
||||
}
|
||||
}
|
||||
});
|
||||
window.addEvent(window.ie ? 'load' : 'domready', function() {
|
||||
varLSsession_login = new LSsession_login();
|
||||
varLSsession_login = new LSsession_login();
|
||||
});
|
||||
|
|
180
trunk/includes/js/LSsmoothbox.js
Normal file
180
trunk/includes/js/LSsmoothbox.js
Normal file
|
@ -0,0 +1,180 @@
|
|||
var LSsmoothbox = new Class({
|
||||
initialize: function(options) {
|
||||
this.over = new Element('div');
|
||||
this.over.setProperty('id','over-LSsmoothbox');
|
||||
this.over.setStyles({
|
||||
width: '100%',
|
||||
height: '100%',
|
||||
opacity: '0.5',
|
||||
position: 'absolute',
|
||||
top: Window.getScrollTop(),
|
||||
visibility: 'hidden'
|
||||
});
|
||||
this.over.injectInside(document.body);
|
||||
|
||||
this.win = new Element('div');
|
||||
this.win.setProperty('id','win-LSsmoothbox');
|
||||
this.win.injectInside(document.body);
|
||||
|
||||
this.frame = new Element('div');
|
||||
this.frame.setProperty('id','frame-LSsmoothbox');
|
||||
|
||||
this.pnav = new Element('p');
|
||||
this.pnav.setProperty('id','pnav-LSsmoothbox');
|
||||
|
||||
this.pnav.injectInside(this.win);
|
||||
this.frame.injectInside(this.win);
|
||||
|
||||
$$('a.LSsmoothbox').each(function(el) {
|
||||
el.addEvent('click',this.clickA.bindWithEvent(this,el));
|
||||
},this);
|
||||
|
||||
$$('img.LSsmoothbox').each(function(el) {
|
||||
el.addEvent('click',this.clickImg.bindWithEvent(this,el));
|
||||
el.setStyle('cursor','pointer');
|
||||
},this);
|
||||
this.fx = {
|
||||
over: this.over.effect('opacity', {duration: 300}).hide(),
|
||||
win: this.win.effect('opacity', {duration: 300}).hide()
|
||||
};
|
||||
},
|
||||
|
||||
clickA: function(event,a) {
|
||||
new Event(event).stop();
|
||||
this.openURL(a.href);
|
||||
},
|
||||
|
||||
clickImg: function(event,img) {
|
||||
new Event(event).stop();
|
||||
this.openImg(img.src);
|
||||
},
|
||||
|
||||
display: function() {
|
||||
this.fx.over.start(0.5);
|
||||
this.fx.win.start(1);
|
||||
},
|
||||
|
||||
openURL: function(href,el) {
|
||||
this.refreshElement = el;
|
||||
|
||||
this.over.setStyle('top',Window.getScrollTop());
|
||||
|
||||
var winTop = Window.getScrollTop() + ((window.getHeight() - (window.getHeight()*0.8)) /2);
|
||||
this.win.setStyles({
|
||||
width: '80%',
|
||||
height: '80%',
|
||||
position: 'absolute',
|
||||
top: winTop,
|
||||
left: '10%',
|
||||
visibility: 'hidden'
|
||||
});
|
||||
|
||||
this.frame.setStyles({
|
||||
postion: 'absolute',
|
||||
width: '100%',
|
||||
height: '95%',
|
||||
border: 'none'
|
||||
});
|
||||
|
||||
this.pnav.setStyles({
|
||||
width: '100%',
|
||||
height: '5%',
|
||||
cursor: 'pointer'
|
||||
});
|
||||
|
||||
this.pnav.empty();
|
||||
this.cancelBtn = new Element('span');
|
||||
this.cancelBtn.setHTML('Annuler');
|
||||
this.cancelBtn.addEvent('click',this.close.bindWithEvent(this,false));
|
||||
this.cancelBtn.injectInside(this.pnav);
|
||||
|
||||
this.closeBtn = new Element('span');
|
||||
this.closeBtn.setHTML('Valider');
|
||||
this.closeBtn.addEvent('click',this.close.bindWithEvent(this,true));
|
||||
this.closeBtn.injectInside(this.pnav);
|
||||
|
||||
var options = {
|
||||
method: 'post',
|
||||
update: this.frame,
|
||||
evalScripts: true
|
||||
};
|
||||
|
||||
new Ajax(href, options).request();
|
||||
this.display();
|
||||
},
|
||||
|
||||
openImg: function(src) {
|
||||
var margin = 25
|
||||
this.img = new Element('img');
|
||||
this.img.setProperty('src',src);
|
||||
if (((this.img.height+margin) > window.getHeight())||(this.img.width>window.getWidth())) {
|
||||
var rH = window.getHeight() / (this.img.height+margin);
|
||||
var rW = window.getWidth() / (this.img.width);
|
||||
if (rH > rW) {
|
||||
// W
|
||||
this.img.height = Math.floor(this.img.height*window.getWidth()/this.img.width);
|
||||
this.img.width = window.getWidth();
|
||||
}
|
||||
else {
|
||||
// H
|
||||
this.img.width = Math.floor(this.img.width*(window.getHeight()-margin)/this.img.height);
|
||||
this.img.height = window.getHeight() - margin;
|
||||
}
|
||||
}
|
||||
|
||||
var winTop = Window.getScrollTop() + ((window.getHeight() - (this.img.height+margin)) /2);
|
||||
var winLeft = (window.getWidth() - this.img.width) /2;
|
||||
this.win.setStyles({
|
||||
width: this.img.width,
|
||||
height: this.img.height+margin-5,
|
||||
position: 'absolute',
|
||||
top: winTop,
|
||||
left: winLeft,
|
||||
visibility: 'hidden'
|
||||
});
|
||||
|
||||
this.frame.setStyles({
|
||||
postion: 'absolute',
|
||||
width: '100%',
|
||||
height: this.img.height,
|
||||
border: 'none'
|
||||
});
|
||||
|
||||
this.pnav.setStyles({
|
||||
width: '100%',
|
||||
height: margin-5,
|
||||
cursor: 'pointer'
|
||||
});
|
||||
|
||||
|
||||
this.frame.empty();
|
||||
this.img.injectInside(this.frame);
|
||||
|
||||
this.pnav.empty();
|
||||
this.closeBtn = new Element('span');
|
||||
this.closeBtn.setHTML('Fermer');
|
||||
this.closeBtn.addEvent('click',this.close.bindWithEvent(this,false));
|
||||
this.closeBtn.injectInside(this.pnav);
|
||||
|
||||
this.display();
|
||||
},
|
||||
|
||||
close: function(event,refresh) {
|
||||
new Event(event).stop();
|
||||
this.fx.win.start(0);
|
||||
this.fx.over.start(0);
|
||||
if (refresh) {
|
||||
try {
|
||||
this.refreshElement.refresh();
|
||||
}
|
||||
catch (e){
|
||||
console.log('rater');
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
});
|
||||
window.addEvent(window.ie ? 'load' : 'domready', function() {
|
||||
varLSsmoothbox = new LSsmoothbox();
|
||||
});
|
|
@ -11,6 +11,7 @@ if ($_REQUEST['template'] != 'login') {
|
|||
echo json_encode(array('LSerror' => 'LSsession : Impossible d\'initialiser la LSsession.' ));
|
||||
}
|
||||
}
|
||||
$data=NULL;
|
||||
switch($_REQUEST['template']) {
|
||||
case 'login':
|
||||
switch($_REQUEST['action']) {
|
||||
|
@ -21,7 +22,7 @@ switch($_REQUEST['template']) {
|
|||
$list = $GLOBALS['LSsession'] -> getSubDnLdapServerOptions();
|
||||
if (is_string($list)) {
|
||||
$list="<select name='LSsession_topDn' id='LSsession_topDn'>".$list."</select>";
|
||||
$data = array('list_topDn' => $list);
|
||||
$data = array('list_topDn' => $list, 'imgload' => $_REQUEST['imgload']);
|
||||
}
|
||||
else if (is_array($list)){
|
||||
$data = array('LSerror' => $GLOBALS['LSerror']->getErrors());
|
||||
|
@ -34,9 +35,6 @@ switch($_REQUEST['template']) {
|
|||
$data = array('LSerror' => $GLOBALS['LSerror']->getErrors());
|
||||
}
|
||||
}
|
||||
else {
|
||||
$data=NULL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
@ -58,13 +56,249 @@ switch($_REQUEST['template']) {
|
|||
$data = array('LSerror' => $GLOBALS['LSerror']->getErrors());
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'refreshField':
|
||||
if ((isset($_REQUEST['attribute'])) && (isset($_REQUEST['objecttype'])) && (isset($_REQUEST['objectdn'])) && (isset($_REQUEST['idform'])) && (isset($_REQUEST['imgload'])) ) {
|
||||
$object = new $_REQUEST['objecttype']();
|
||||
//$object -> loadData($_REQUEST['objectdn']);
|
||||
$form = $object -> getForm($_REQUEST['idform']);
|
||||
$field=$form -> getElement($_REQUEST['attribute']);
|
||||
$val = $field -> getDisplay(true);
|
||||
if ( $val ) {
|
||||
$data = array(
|
||||
'html' => $val['html'],
|
||||
'imgload' => $_REQUEST['imgload']
|
||||
);
|
||||
}
|
||||
else {
|
||||
$data = array(
|
||||
'LSerror' => $GLOBALS['LSerror']->getErrors(),
|
||||
'imgload' => $_REQUEST['imgload']
|
||||
);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'LSrelation':
|
||||
switch($_REQUEST['action']) {
|
||||
case 'refreshSession':
|
||||
if ((isset($_REQUEST['id'])) && (isset($_REQUEST['href'])) && (isset($_REQUEST['imgload']))) {
|
||||
if (isset($_SESSION['LSrelation'][$_REQUEST['id']])) {
|
||||
$conf = $_SESSION['LSrelation'][$_REQUEST['id']];
|
||||
if ($GLOBALS['LSsession']->loadLSobject($conf['objectType'])) {
|
||||
$object = new $conf['objectType']();
|
||||
if (($object -> loadData($conf['objectDn'])) && (isset($object->config['relations'][$conf['relationName']]))) {
|
||||
$relationConf = $object->config['relations'][$conf['relationName']];
|
||||
if ($GLOBALS['LSsession'] -> relationCanEdit($object -> getValue('dn'),$conf['relationName'])) {
|
||||
if (method_exists($relationConf['LSobject'],$relationConf['list_function'])) {
|
||||
$objRel = new $relationConf['LSobject']();
|
||||
$list = $objRel -> $relationConf['list_function']($object);
|
||||
$_SESSION['LSselect'][$relationConf['LSobject']]=array();
|
||||
if (is_array($list)) {
|
||||
foreach($list as $o) {
|
||||
$_SESSION['LSselect'][$relationConf['LSobject']][] = $o -> getDn();
|
||||
}
|
||||
}
|
||||
$data = array(
|
||||
'href' => $_REQUEST['href'],
|
||||
'id' => $_REQUEST['id']
|
||||
);
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(1013,$relationName);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(1011);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(1012);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(1012);
|
||||
}
|
||||
$data['imgload'] = $_REQUEST['imgload'];
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(1012);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'refreshList':
|
||||
if ((isset($_REQUEST['id'])) && (isset($_REQUEST['imgload']))) {
|
||||
if (isset($_SESSION['LSrelation'][$_REQUEST['id']])) {
|
||||
$conf = $_SESSION['LSrelation'][$_REQUEST['id']];
|
||||
if ($GLOBALS['LSsession']->loadLSobject($conf['objectType'])) {
|
||||
$object = new $conf['objectType']();
|
||||
if (($object -> loadData($conf['objectDn'])) && (isset($object->config['relations'][$conf['relationName']]))) {
|
||||
$relationConf = $object->config['relations'][$conf['relationName']];
|
||||
if ($GLOBALS['LSsession'] -> relationCanEdit($object -> getValue('dn'),$conf['relationName'])) {
|
||||
if (is_array($_SESSION['LSselect'][$relationConf['LSobject']])) {
|
||||
if (method_exists($relationConf['LSobject'],$relationConf['update_function'])) {
|
||||
$objRel = new $relationConf['LSobject']();
|
||||
if($objRel -> $relationConf['update_function']($object,$_SESSION['LSselect'][$relationConf['LSobject']])) {
|
||||
if (method_exists($relationConf['LSobject'],$relationConf['list_function'])) {
|
||||
$list = $objRel -> $relationConf['list_function']($object);
|
||||
if (is_array($list)) {
|
||||
foreach($list as $o) {
|
||||
$data['html'].= "<li class='LSrelation'>".$o -> getDisplayValue()."</li>\n";
|
||||
}
|
||||
}
|
||||
else {
|
||||
$data['html'] = "<li>"._('Liste vide.')."</li>\n";
|
||||
}
|
||||
$data['id'] = $_REQUEST['id'];
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(1013,$relationName);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(1015,$relationName);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(1014,$relationName);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(1011);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(1012);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(1012);
|
||||
}
|
||||
$data['imgload'] = $_REQUEST['imgload'];
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(1012);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'deleteByDisplayValue':
|
||||
if ((isset($_REQUEST['id'])) && (isset($_REQUEST['value'])) && (isset($_REQUEST['imgload']))) {
|
||||
if (isset($_SESSION['LSrelation'][$_REQUEST['id']])) {
|
||||
$conf = $_SESSION['LSrelation'][$_REQUEST['id']];
|
||||
if ($GLOBALS['LSsession']->loadLSobject($conf['objectType'])) {
|
||||
$object = new $conf['objectType']();
|
||||
if (($object -> loadData($conf['objectDn'])) && (isset($object->config['relations'][$conf['relationName']]))) {
|
||||
$relationConf = $object->config['relations'][$conf['relationName']];
|
||||
if ($GLOBALS['LSsession'] -> relationCanEdit($object -> getValue('dn'),$conf['relationName'])) {
|
||||
if (method_exists($relationConf['LSobject'],$relationConf['list_function'])) {
|
||||
$objRel = new $relationConf['LSobject']();
|
||||
$list = $objRel -> $relationConf['list_function']($object);
|
||||
if (is_array($list)) {
|
||||
$ok=false;
|
||||
foreach($list as $o) {
|
||||
if($o -> getDisplayValue() == $_REQUEST['value']) {
|
||||
if (!$o -> deleteOneMember($object)) {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(1015,$conf['relationName']);
|
||||
}
|
||||
else {
|
||||
$ok = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!$ok) {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(1015,$conf['relationName']);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(1015,$conf['relationName']);
|
||||
$GLOBALS['LSerror'] -> addErrorCode(1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(1013,$conf['relationName']);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(1011);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(1012);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(1012);
|
||||
}
|
||||
$data['imgload'] = $_REQUEST['imgload'];
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(1012);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'LSselect':
|
||||
switch($_REQUEST['action']) {
|
||||
case 'addLSselectobject-item':
|
||||
if ((isset($_REQUEST['objecttype'])) && (isset($_REQUEST['objectdn']))) {
|
||||
if (is_array($_SESSION['LSselect'][$_REQUEST['objecttype']])) {
|
||||
if (!in_array($_REQUEST['objectdn'],$_SESSION['LSselect'][$_REQUEST['objecttype']])) {
|
||||
$_SESSION['LSselect'][$_REQUEST['objecttype']][]=$_REQUEST['objectdn'];
|
||||
}
|
||||
}
|
||||
else {
|
||||
$_SESSION['LSselect'][$_REQUEST['objecttype']][]=$_REQUEST['objectdn'];
|
||||
}
|
||||
}
|
||||
$data=$_REQUEST['imgload'];
|
||||
break;
|
||||
case 'dropLSselectobject-item':
|
||||
if ((isset($_REQUEST['objecttype'])) && (isset($_REQUEST['objectdn']))) {
|
||||
if (is_array($_SESSION['LSselect'][$_REQUEST['objecttype']])) {
|
||||
$result=array();
|
||||
foreach ($_SESSION['LSselect'][$_REQUEST['objecttype']] as $val) {
|
||||
if ($val!=$_REQUEST['objectdn']) {
|
||||
$result[]=$val;
|
||||
}
|
||||
}
|
||||
$_SESSION['LSselect'][$_REQUEST['objecttype']]=$result;
|
||||
}
|
||||
}
|
||||
$data=$_REQUEST['imgload'];
|
||||
break;
|
||||
case 'refreshSession':
|
||||
if ((isset($_REQUEST['objecttype'])) && (isset($_REQUEST['values'])) && (isset($_REQUEST['imgload'])) && (isset($_REQUEST['href'])) ) {
|
||||
$_SESSION['LSselect'][$_REQUEST['objecttype']]=array();
|
||||
$values=json_decode($_REQUEST['values'],false);
|
||||
if (is_array($values)) {
|
||||
foreach($values as $val) {
|
||||
$_SESSION['LSselect'][$_REQUEST['objecttype']][]=$val;
|
||||
}
|
||||
}
|
||||
$data=array(
|
||||
'imgload' => $_REQUEST['imgload'],
|
||||
'href' => $_REQUEST['href'],
|
||||
'values' => $values
|
||||
);
|
||||
}
|
||||
else {
|
||||
$data=NULL;
|
||||
$GLOBALS['LSerror'] -> addErrorCode(1012);
|
||||
$data = array(
|
||||
'LSerror' => $GLOBALS['LSerror']->getErrors(),
|
||||
'imgload' => $_REQUEST['imgload']
|
||||
);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if ($GLOBALS['LSerror']->errorsDefined()) {
|
||||
$data['LSerror'] = $GLOBALS['LSerror']->getErrors();
|
||||
}
|
||||
|
||||
echo json_encode($data);
|
||||
?>
|
||||
|
|
|
@ -68,9 +68,15 @@ if($LSsession -> startLSsession()) {
|
|||
if ($form->validate()) {
|
||||
// MàJ des données de l'objet LDAP
|
||||
if ($object -> updateData('modify')) {
|
||||
header('Location: view.php?LSobject='.$LSobject.'&dn='.$object -> getDn());
|
||||
debug('ok');
|
||||
//header('Location: view.php?LSobject='.$LSobject.'&dn='.$object -> getDn());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
$GLOBALS['LSsession'] -> addJSscript('LSsmoothbox.js');
|
||||
$GLOBALS['LSsession'] -> addCssFile('LSsmoothbox.css');
|
||||
$GLOBALS['Smarty'] -> assign('LSview_actions',$LSview_actions);
|
||||
$GLOBALS['LSsession'] -> setTemplate('modify.tpl');
|
||||
$form -> display();
|
||||
|
|
148
trunk/select.php
Normal file
148
trunk/select.php
Normal file
|
@ -0,0 +1,148 @@
|
|||
<?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.
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
require_once 'includes/functions.php';
|
||||
require_once 'includes/class/class.LSsession.php';
|
||||
|
||||
$GLOBALS['LSsession'] = new LSsession();
|
||||
|
||||
if($LSsession -> startLSsession()) {
|
||||
if (isset($_REQUEST['LSobject'])) {
|
||||
$LSobject = $_REQUEST['LSobject'];
|
||||
|
||||
if ( $GLOBALS['LSsession'] -> loadLSobject($_REQUEST['LSobject']) ) {
|
||||
$objectList=array();
|
||||
$object = new $_REQUEST['LSobject']();
|
||||
|
||||
|
||||
if ( $_REQUEST['LSview_pattern']!='' ) {
|
||||
$filter='(|';
|
||||
if ( isset($_REQUEST['LSview_approx']) ) {
|
||||
foreach ($object -> attrs as $attr_name => $attr_val) {
|
||||
$filter.='('.$attr_name.'~='.$_REQUEST['LSview_pattern'].')';
|
||||
}
|
||||
}
|
||||
else {
|
||||
foreach ($object -> attrs as $attr_name => $attr_val) {
|
||||
$filter.='('.$attr_name.'=*'.$_REQUEST['LSview_pattern'].'*)';
|
||||
}
|
||||
}
|
||||
$filter.=')';
|
||||
$GLOBALS['Smarty']->assign('LSobject_list_filter','filter='.urlencode($filter));
|
||||
}
|
||||
else if ($_REQUEST['filter']) {
|
||||
$filter=urldecode($_REQUEST['filter']);
|
||||
$GLOBALS['Smarty']->assign('LSobject_list_filter','filter='.$_REQUEST['filter']);
|
||||
}
|
||||
else {
|
||||
$filter=NULL;
|
||||
$GLOBALS['Smarty']->assign('LSobject_list_filter','');
|
||||
}
|
||||
|
||||
$list=$object -> listObjects($filter);
|
||||
$nbObjects=count($list);
|
||||
|
||||
if ($nbObjects > NB_LSOBJECT_LIST) {
|
||||
if (isset($_GET['page'])) {
|
||||
$list = array_slice($list, ($_GET['page']) * NB_LSOBJECT_LIST, NB_LSOBJECT_LIST);
|
||||
$GLOBALS['Smarty']->assign('LSobject_list_currentpage',$_GET['page']);
|
||||
$GLOBALS['Smarty']->assign('LSobject_list_nbpage',ceil($nbObjects / NB_LSOBJECT_LIST));
|
||||
}
|
||||
else {
|
||||
$list = array_slice($list, 0, NB_LSOBJECT_LIST);
|
||||
$GLOBALS['Smarty']->assign('LSobject_list_currentpage',0);
|
||||
$GLOBALS['Smarty']->assign('LSobject_list_nbpage',ceil($nbObjects / NB_LSOBJECT_LIST));
|
||||
}
|
||||
}
|
||||
$c=0;
|
||||
foreach($list as $thisObject) {
|
||||
$c++;
|
||||
unset($actions);
|
||||
if ($GLOBALS['LSsession'] -> canAccess($_REQUEST['LSobject'],$thisObject->getValue('dn'))) {
|
||||
if ($c%2==0) {
|
||||
$tr='bis';
|
||||
}
|
||||
else {
|
||||
$tr='';
|
||||
}
|
||||
|
||||
if (is_array($_SESSION['LSselect'][$_REQUEST['LSobject']])) {
|
||||
if(in_array($thisObject -> getValue('dn'),$_SESSION['LSselect'][$_REQUEST['LSobject']])) {
|
||||
$select = true;
|
||||
}
|
||||
else {
|
||||
$select = false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$select = false;
|
||||
}
|
||||
|
||||
$objectList[]=array(
|
||||
'dn' => $thisObject->getValue('dn'),
|
||||
'displayValue' => $thisObject->getDisplayValue(),
|
||||
'actions' => $actions,
|
||||
'tr' => $tr,
|
||||
'select' => $select
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$GLOBALS['LSsession'] -> addJSscript('LSview.js');
|
||||
//$GLOBALS['LSsession'] -> addJSscript('LSselect.js');
|
||||
|
||||
$GLOBALS['Smarty']->assign('LSview_search',array(
|
||||
'action' => $_SERVER['PHP_SELF'],
|
||||
'submit' => _('Rechercher'),
|
||||
'LSobject' => $_REQUEST['LSobject']
|
||||
));
|
||||
|
||||
$GLOBALS['Smarty']->assign('pagetitle',$object -> getLabel());
|
||||
$GLOBALS['Smarty']->assign('LSobject_list_objectname',$object -> getLabel());
|
||||
$GLOBALS['Smarty']->assign('LSobject_list_nbresult',$nbObjects);
|
||||
$GLOBALS['Smarty']->assign('LSobject_list',$objectList);
|
||||
$GLOBALS['Smarty']->assign('LSobject_list_objecttype',$_REQUEST['LSobject']);
|
||||
if (isset($_REQUEST['ajax'])) {
|
||||
$GLOBALS['LSsession'] -> setTemplate('select_table.tpl');
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSsession'] -> setTemplate('select.tpl');
|
||||
}
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(1004,$_REQUEST['LSobject']);
|
||||
$GLOBALS['LSsession'] -> setTemplate('blank.tpl');
|
||||
}
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(1012);
|
||||
$GLOBALS['LSsession'] -> setTemplate('blank.tpl');
|
||||
}
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSsession'] -> setTemplate('login.tpl');
|
||||
}
|
||||
|
||||
// Affichage des retours d'erreurs
|
||||
$GLOBALS['LSsession'] -> displayTemplate();
|
||||
?>
|
13
trunk/templates/LSrelations.tpl
Normal file
13
trunk/templates/LSrelations.tpl
Normal file
|
@ -0,0 +1,13 @@
|
|||
<h1 id='LSrelation_title_{$item.id}'>{$item.label}</h1>
|
||||
{if $item.actions!=''}
|
||||
<p class='LSview-actions'>
|
||||
{foreach from=$item.actions item=action}
|
||||
<a href='{$action.url}' class='LSview-actions LSrelation_modify' id='{$item.id}'><img src='templates/images/{$action.action}.png' alt='{$action.label}' title='{$action.label}' /> {$action.label}</a>
|
||||
{/foreach}
|
||||
</p>
|
||||
{/if}
|
||||
<ul id='LSrelation_ul_{$item.id}' class='LSrelation'>
|
||||
{foreach from=$item.objectList item=object}
|
||||
<li class='LSrelation'>{$object}</li>
|
||||
{/foreach}
|
||||
</ul>
|
|
@ -1,39 +1,3 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>LdapSaisie{if $pagetitle != ''} - {$pagetitle}{/if}</title>
|
||||
<link rel="stylesheet" type="text/css" href="templates/css/base.css" media="screen" title="Normal" />
|
||||
{$LSsession_css}
|
||||
{$LSsession_js}
|
||||
</head>
|
||||
<body>
|
||||
<div id='LSerror'>
|
||||
{$LSerrors}
|
||||
</div>
|
||||
<div id='LSdebug'>
|
||||
<a href='#' id='LSdebug_hidden'>X</a>
|
||||
<div id='LSdebug_infos'>{if $LSdebug != ''}{$LSdebug}{/if}</div>
|
||||
</div>
|
||||
|
||||
<div id='main'>
|
||||
|
||||
<div id='left'>
|
||||
<img src='templates/images/logo.png' alt='Logo' id='logo'/>
|
||||
<ul class='menu'>
|
||||
{foreach from=$LSaccess item=item key=LSobject}
|
||||
<li class='menu'><a href='view.php?LSobject={$LSobject}' class='menu'>{$item.label}</a></li>
|
||||
{/foreach}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div id='right'>
|
||||
<p id='status'>Connecté en tant que <span id='user_name'>{$LSsession_username}</span></b> <a href='index.php?LSsession_logout'><img src='templates/images/logout.png' alt='Logout' title='Logout' /></a></p>
|
||||
|
||||
{if $pagetitle != ''}<h1>{$pagetitle}</h1>{/if}
|
||||
|
||||
</div>
|
||||
<hr class='spacer' />
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
{include file='top.tpl'}
|
||||
<h1>{$pagetitle}</h1>
|
||||
{include file='bottom.tpl'}
|
||||
|
|
|
@ -1,49 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>LdapSaisie{if $pagetitle != ''} - {$pagetitle}{/if}</title>
|
||||
<link rel="stylesheet" type="text/css" href="templates/css/base.css" media="screen" title="Normal" />
|
||||
{$LSsession_css}
|
||||
{$LSsession_js}
|
||||
</head>
|
||||
<body>
|
||||
<div id='LSerror'>
|
||||
{$LSerrors}
|
||||
</div>
|
||||
<div id='LSdebug'>
|
||||
<a href='#' id='LSdebug_hidden'>X</a>
|
||||
<div id='LSdebug_infos'>{if $LSdebug != ''}{$LSdebug}{/if}</div>
|
||||
</div>
|
||||
|
||||
<div id='main'>
|
||||
<div id='left'>
|
||||
<img src='templates/images/logo.png' alt='Logo' id='logo'/>
|
||||
<ul class='menu'>
|
||||
{foreach from=$LSaccess item=item key=LSobject}
|
||||
<li class='menu'><a href='view.php?LSobject={$LSobject}' class='menu'>{$item.label}</a></li>
|
||||
{/foreach}
|
||||
</ul>
|
||||
</div>
|
||||
<div id='right'>
|
||||
<p id='status'>Connecté en tant que <span id='user_name'>{$LSsession_username}</span></b> <a href='index.php?LSsession_logout'><img src='templates/images/logout.png' alt='Logout' title='Logout' /></a></p>
|
||||
{if $pagetitle != ''}<h1>{$pagetitle}</h1>{/if}
|
||||
<form action='{$LSform_action}' method='post' class='LSform'>
|
||||
{$LSform_header}
|
||||
<dl class='LSform'>
|
||||
{foreach from=$LSform_fields item=field}
|
||||
<dt class='LSform'>{$field.label}</dt>
|
||||
<dd class='LSform'>{$field.html}{if $field.add != ''} <span class='LSform-addfield'>+ Ajouter un champ</span>{/if}</dd>
|
||||
{if $field.errors != ''}
|
||||
{foreach from=$field.errors item=error}
|
||||
<dd class='LSform LSform-errors'>{$error}</dd>
|
||||
{/foreach}
|
||||
{/if}
|
||||
{/foreach}
|
||||
<dd class='LSform'><input type='submit' value='{$LSform_submittxt}' class='LSform' /></dd>
|
||||
</dl>
|
||||
</div>
|
||||
<hr class='spacer' />
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
20
trunk/templates/blank.tpl
Normal file
20
trunk/templates/blank.tpl
Normal file
|
@ -0,0 +1,20 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>LdapSaisie{if $pagetitle != ''} - {$pagetitle}{/if}</title>
|
||||
<link rel="stylesheet" type="text/css" href="templates/css/base.css" title="Normal" />
|
||||
<link rel="stylesheet" type="text/css" href="templates/css/base_print.css" media='print' title="Normal" />
|
||||
{$LSsession_css}
|
||||
{$LSsession_js}
|
||||
</head>
|
||||
<body>
|
||||
<div id='LSerror'>
|
||||
{$LSerrors}
|
||||
</div>
|
||||
<div id='LSdebug'>
|
||||
<a href='#' id='LSdebug_hidden'>X</a>
|
||||
<div id='LSdebug_infos'>{if $LSdebug != ''}{$LSdebug}{/if}</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
5
trunk/templates/bottom.tpl
Normal file
5
trunk/templates/bottom.tpl
Normal file
|
@ -0,0 +1,5 @@
|
|||
</div>
|
||||
<hr class='spacer' />
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -1,33 +1,4 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>LdapSaisie{if $pagetitle != ''} - {$pagetitle}{/if}</title>
|
||||
<link rel="stylesheet" type="text/css" href="templates/css/base.css" media="screen" title="Normal" />
|
||||
{$LSsession_css}
|
||||
{$LSsession_js}
|
||||
</head>
|
||||
<body>
|
||||
<div id='LSerror'>
|
||||
{$LSerrors}
|
||||
</div>
|
||||
<div id='LSdebug'>
|
||||
<a href='#' id='LSdebug_hidden'>X</a>
|
||||
<div id='LSdebug_infos'>{if $LSdebug != ''}{$LSdebug}{/if}</div>
|
||||
</div>
|
||||
|
||||
<div id='main'>
|
||||
<div id='left'>
|
||||
<img src='templates/images/logo.png' alt='Logo' id='logo'/>
|
||||
<ul class='menu'>
|
||||
{foreach from=$LSaccess item=item key=LSobject}
|
||||
<li class='menu'><a href='view.php?LSobject={$LSobject}' class='menu'>{$item.label}</a></li>
|
||||
{/foreach}
|
||||
</ul>
|
||||
</div>
|
||||
<div id='right'>
|
||||
<p id='status'>Connecté en tant que <span id='user_name'>{$LSsession_username}</span></b> <a href='index.php?LSsession_logout'><img src='templates/images/logout.png' alt='Logout' title='Logout' /></a></p>
|
||||
|
||||
{include file='top.tpl'}
|
||||
{if $pagetitle != ''}<h1>{$pagetitle}</h1>{/if}
|
||||
|
||||
<form action='{$LSform_action}' method='post' class='LSform'>
|
||||
|
@ -45,8 +16,4 @@
|
|||
<dd class='LSform'><input type='submit' value='{$LSform_submittxt}' class='LSform' /></dd>
|
||||
</dl>
|
||||
</form>
|
||||
</div>
|
||||
<hr class='spacer' />
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
{include file='bottom.tpl'}
|
||||
|
|
|
@ -21,7 +21,7 @@ dd.LSform {
|
|||
|
||||
.LSform input, .LSform select, .LSform textarea {
|
||||
border: 1px inset #ccc;
|
||||
width: 20em;
|
||||
width: 300px;
|
||||
background-color: #b5e4f6;
|
||||
}
|
||||
|
||||
|
@ -46,3 +46,30 @@ ul.LSform {
|
|||
img.LSform-add-field-btn, img.LSform-remove-field-btn {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
a.LSformElement_select_object_addBtn {
|
||||
text-decoration: none;
|
||||
color: #000;
|
||||
font-weight: normal;
|
||||
|
||||
}
|
||||
|
||||
ul.LSformElement_select_object {
|
||||
border: 1px solid #b5e4f6;
|
||||
border-bottom: none;
|
||||
width: 300px;
|
||||
}
|
||||
|
||||
li.LSformElement_select_object {
|
||||
padding: 0.1em;
|
||||
border-bottom: 1px solid #b5e4f6;
|
||||
}
|
||||
|
||||
li.LSformElement_select_object_addBtn {
|
||||
background-color: #b5e4f6;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
img.LSformElement_select_object_deleteBtn {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
|
28
trunk/templates/css/LSsmoothbox.css
Normal file
28
trunk/templates/css/LSsmoothbox.css
Normal file
|
@ -0,0 +1,28 @@
|
|||
#over-LSsmoothbox {
|
||||
background-color: #000;
|
||||
border: 1px solid #000;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
#win-LSsmoothbox {
|
||||
background-color: #fff;
|
||||
border: 3px solid #000;
|
||||
margin: auto;
|
||||
}
|
||||
|
||||
#pnav-LSsmoothbox {
|
||||
text-align: right;
|
||||
font-family: sans-serif;
|
||||
font-weight: bold;
|
||||
background-color: #777;
|
||||
margin: 0;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
#pnav-LSsmoothbox span {
|
||||
color: #fff;
|
||||
margin: 1em;
|
||||
margin-bottom: 0;
|
||||
font-size: 100%;
|
||||
}
|
|
@ -14,8 +14,10 @@ a:hover {
|
|||
|
||||
h1 {
|
||||
margin: 0.5em;
|
||||
margin-bottom: 0em;
|
||||
border-bottom: 1px solid #0072b8;
|
||||
color: #0072b8;
|
||||
clear: left;
|
||||
}
|
||||
|
||||
a img {
|
||||
|
@ -33,6 +35,7 @@ hr {
|
|||
margin: auto;
|
||||
border: 1px solid #52bce5;
|
||||
background: #fff url(../images/fd_menu.png) repeat-y scroll left top;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
#left {
|
||||
|
@ -81,9 +84,11 @@ a.menu {
|
|||
|
||||
table.LSobject-list {
|
||||
margin-left: 1em;
|
||||
margin-top: 0.5em;
|
||||
border: 1px solid #52bce5;
|
||||
width: 30em;
|
||||
width: 805px;
|
||||
border-collapse: collapse;
|
||||
clear: both;
|
||||
}
|
||||
|
||||
td.LSobject-list {
|
||||
|
@ -96,6 +101,10 @@ th.LSobject-list {
|
|||
color: #fff;
|
||||
}
|
||||
|
||||
tr.LSobject-list-bis {
|
||||
background-color: #ecf8fd;
|
||||
}
|
||||
|
||||
a.LSobject-list {
|
||||
color: #000;
|
||||
text-decoration: none;
|
||||
|
@ -138,11 +147,22 @@ strong.LSobject-list-page {
|
|||
}
|
||||
|
||||
p.LSview-actions {
|
||||
text-align: right;
|
||||
font-size: 0.8em;
|
||||
margin: 0.2em;
|
||||
margin-right: 3em;
|
||||
color: #0072b8;
|
||||
clear: both;
|
||||
text-align: right;
|
||||
font-size: 0.8em;
|
||||
margin: 0;
|
||||
margin-top: 0.3em;
|
||||
margin-right: 3em;
|
||||
margin-bottom: 0.8em;
|
||||
color: #0072b8;
|
||||
}
|
||||
|
||||
a.LSview-actions {
|
||||
text-decoration: none;
|
||||
color: #000;
|
||||
border: 1px solid #0072b8;
|
||||
border-top: 0;
|
||||
padding: 0.4em;
|
||||
}
|
||||
|
||||
p.question {
|
||||
|
@ -154,3 +174,78 @@ a.question {
|
|||
margin-top: 3em;
|
||||
color: #0072b8;
|
||||
}
|
||||
|
||||
div.LSform_image {
|
||||
float: right;
|
||||
clear: both;
|
||||
margin: 2em;
|
||||
background-color: #52bce5;
|
||||
width: 160px;
|
||||
padding: 5px;
|
||||
text-align: center;
|
||||
-moz-border-radius: 1em;
|
||||
}
|
||||
|
||||
div.LSform_image_errors {
|
||||
background-color: #f59a67;
|
||||
}
|
||||
|
||||
img.LSform_image {
|
||||
width: 150px;
|
||||
border: 1px solid #fff;
|
||||
margin: 5px;
|
||||
}
|
||||
|
||||
ul.LSform_image_actions {
|
||||
list-style-type: none;
|
||||
position: absolute;
|
||||
margin-top: 8px;
|
||||
margin-left: 135px;
|
||||
padding: 0;
|
||||
visibility: hidden;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
form.LSview_search {
|
||||
float: right;
|
||||
margin: 0;
|
||||
margin-top: 0.5em;
|
||||
margin-right: 2em;
|
||||
}
|
||||
|
||||
label.LSview_search {
|
||||
font-size: 0.6em;
|
||||
display: block;
|
||||
}
|
||||
|
||||
input[type='text'].LSview_search {
|
||||
border: 1px solid #0072b8;
|
||||
width: 12em;
|
||||
}
|
||||
|
||||
input[type='submit'].LSview_search {
|
||||
border: 1px solid #0072b8;
|
||||
width: 8em;
|
||||
background-color: #52bce5;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
div.LSobject-select {
|
||||
width: 600px;
|
||||
}
|
||||
|
||||
#LSselect-object {
|
||||
width: 570px;
|
||||
}
|
||||
|
||||
.LSobject-select-check {
|
||||
width: 10px;
|
||||
}
|
||||
|
||||
form.LSselect_search {
|
||||
margin-top: 0.5em;
|
||||
}
|
||||
|
||||
img.LSrelation-btn {
|
||||
margin-left: 0.5em;
|
||||
}
|
||||
|
|
15
trunk/templates/css/base_print.css
Normal file
15
trunk/templates/css/base_print.css
Normal file
|
@ -0,0 +1,15 @@
|
|||
#main {
|
||||
width: 840px;
|
||||
}
|
||||
|
||||
#left {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#status {
|
||||
display: none;
|
||||
}
|
||||
|
||||
p.LSview-actions {
|
||||
display: none;
|
||||
}
|
|
@ -1,34 +1,2 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>LdapSaisie{if $pagetitle != ''} - {$pagetitle}{/if}</title>
|
||||
<link rel="stylesheet" type="text/css" href="templates/css/base.css" media="screen" title="Normal" />
|
||||
{$LSsession_css}
|
||||
{$LSsession_js}
|
||||
</head>
|
||||
<body>
|
||||
<div id='LSerror'>
|
||||
{$LSerrors}
|
||||
</div>
|
||||
<div id='LSdebug'>
|
||||
<a href='#' id='LSdebug_hidden'>X</a>
|
||||
<div id='LSdebug_infos'>{if $LSdebug != ''}{$LSdebug}{/if}</div>
|
||||
</div>
|
||||
|
||||
<div id='main'>
|
||||
<div id='left'>
|
||||
<img src='templates/images/logo.png' alt='Logo' id='logo'/>
|
||||
<ul class='menu'>
|
||||
{foreach from=$LSaccess item=item key=LSobject}
|
||||
<li class='menu'><a href='view.php?LSobject={$LSobject}' class='menu'>{$item.label}</a></li>
|
||||
{/foreach}
|
||||
</ul>
|
||||
</div>
|
||||
<div id='right'>
|
||||
<p id='status'>Connecté en tant que <span id='user_name'>{$LSsession_username}</span></b> <a href='index.php?LSsession_logout'><img src='templates/images/logout.png' alt='Logout' title='Logout' /></a></p>
|
||||
</div>
|
||||
<hr class='spacer' />
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
{include file='top.tpl'}
|
||||
{include file='bottom.tpl'}
|
||||
|
|
BIN
trunk/templates/images/imgbroken.png
Normal file
BIN
trunk/templates/images/imgbroken.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 15 KiB |
BIN
trunk/templates/images/loading.gif
Normal file
BIN
trunk/templates/images/loading.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 8 KiB |
BIN
trunk/templates/images/person.png
Executable file
BIN
trunk/templates/images/person.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 22 KiB |
BIN
trunk/templates/images/zoom.png
Normal file
BIN
trunk/templates/images/zoom.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 935 B |
|
@ -1,43 +1,28 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>LdapSaisie{if $pagetitle != ''} - {$pagetitle}{/if}</title>
|
||||
<link rel="stylesheet" type="text/css" href="templates/css/base.css" media="screen" title="Normal" />
|
||||
{$LSsession_css}
|
||||
{$LSsession_js}
|
||||
</head>
|
||||
<body>
|
||||
<div id='LSerror'>
|
||||
{$LSerrors}
|
||||
</div>
|
||||
<div id='LSdebug'>
|
||||
<a href='#' id='LSdebug_hidden'>X</a>
|
||||
<div id='LSdebug_infos'>{if $LSdebug != ''}{$LSdebug}{/if}</div>
|
||||
</div>
|
||||
|
||||
<div id='main'>
|
||||
<div id='left'>
|
||||
<img src='templates/images/logo.png' alt='Logo' id='logo'/>
|
||||
<ul class='menu'>
|
||||
{foreach from=$LSaccess item=item key=LSobject}
|
||||
<li class='menu'><a href='view.php?LSobject={$LSobject}' class='menu'>{$item.label}</a></li>
|
||||
{/foreach}
|
||||
</ul>
|
||||
</div>
|
||||
<div id='right'>
|
||||
<p id='status'>Connecté en tant que <span id='user_name'>{$LSsession_username}</span></b> <a href='index.php?LSsession_logout'><img src='templates/images/logout.png' alt='Logout' title='Logout' /></a></p>
|
||||
|
||||
{include file='top.tpl'}
|
||||
{if $pagetitle != ''}<h1>{$pagetitle}</h1>{/if}
|
||||
{if $LSview_actions != ''}
|
||||
<p class='LSview-actions'>
|
||||
{foreach from=$LSview_actions item=item}
|
||||
<a href='{$item.url}' class='LSview-actions'><img src='templates/images/{$item.action}.png' alt='{$item.label}' title='{$item.label}' /></a>
|
||||
<a href='{$item.url}' class='LSview-actions'><img src='templates/images/{$item.action}.png' alt='{$item.label}' title='{$item.label}' /> {$item.label}</a>
|
||||
{/foreach}
|
||||
</p>
|
||||
{/if}
|
||||
|
||||
<form action='{$LSform_action}' method='post' class='LSform'>
|
||||
{if $LSform_image!=''}
|
||||
<div class='LSform_image{if $LSform_image_errors} LSform_image_errors{/if}'>
|
||||
{if $LSform_image_actions!='' && !$LSform_image_errors}
|
||||
<ul class='LSform_image_actions'>
|
||||
<li><img src='templates/images/zoom.png' class='LSform_image_actions LSform_image_action_zoom' id='LSform_image_action_zoom_{$LSform_image.id}' /></li>
|
||||
{foreach from=$LSform_image_actions item=item}
|
||||
<li><img src='templates/images/{$item}.png' class='LSform_image_actions LSform_image_action_{$item}' id='LSform_image_action_{$item}_{$LSform_image.id}' /></li>
|
||||
{/foreach}
|
||||
</ul>
|
||||
{/if}
|
||||
<img src='{$LSform_image.img}' class='LSform_image LSsmoothbox' />
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<form action='{$LSform_action}' method='post' enctype="multipart/form-data" class='LSform'>
|
||||
{$LSform_header}
|
||||
<dl class='LSform'>
|
||||
{foreach from=$LSform_fields item=field}
|
||||
|
@ -52,8 +37,4 @@
|
|||
<dd class='LSform'><input type='submit' value='{$LSform_submittxt}' class='LSform' /></dd>
|
||||
</dl>
|
||||
</form>
|
||||
</div>
|
||||
<hr class='spacer' />
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
{include file='bottom.tpl'}
|
||||
|
|
|
@ -1,32 +1,4 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>LdapSaisie{if $pagetitle != ''} - {$pagetitle}{/if}</title>
|
||||
<link rel="stylesheet" type="text/css" href="templates/css/base.css" media="screen" title="Normal" />
|
||||
{$LSsession_css}
|
||||
{$LSsession_js}
|
||||
</head>
|
||||
<body>
|
||||
<div id='LSerror'>
|
||||
{$LSerrors}
|
||||
</div>
|
||||
<div id='LSdebug'>
|
||||
<a href='#' id='LSdebug_hidden'>X</a>
|
||||
<div id='LSdebug_infos'>{if $LSdebug != ''}{$LSdebug}{/if}</div>
|
||||
</div>
|
||||
|
||||
<div id='main'>
|
||||
<div id='left'>
|
||||
<img src='templates/images/logo.png' alt='Logo' id='logo'/>
|
||||
<ul class='menu'>
|
||||
{foreach from=$LSaccess item=item key=LSobject_type}
|
||||
<li class='menu'><a href='view.php?LSobject={$LSobject_type}' class='menu'>{$item.label}</a></li>
|
||||
{/foreach}
|
||||
</ul>
|
||||
</div>
|
||||
<div id='right'>
|
||||
<p id='status'>Connecté en tant que <span id='user_name'>{$LSsession_username}</span></b> <a href='index.php?LSsession_logout'><img src='templates/images/logout.png' alt='Logout' title='Logout' /></a></p>
|
||||
{include file='top.tpl'}
|
||||
{if $pagetitle != ''}<h1>{$pagetitle}</h1>{/if}
|
||||
{if $LSview_actions != ''}
|
||||
<p class='LSview-actions'>
|
||||
|
@ -38,8 +10,4 @@
|
|||
|
||||
<p class='question'>{$question}</p>
|
||||
{if $validation_txt!=''}<a href='{$validation_url}' class='question'>Valider</a>{/if}
|
||||
</div>
|
||||
<hr class='spacer' />
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
{include file='bottom.tpl'}
|
||||
|
|
17
trunk/templates/select.tpl
Normal file
17
trunk/templates/select.tpl
Normal file
|
@ -0,0 +1,17 @@
|
|||
<div class='LSobject-select'>
|
||||
<form action='{$LSview_search.action}' method='post' class='LSview_search LSselect_search'>
|
||||
<input type='hidden' name='LSobject' value='{$LSview_search.LSobject}' />
|
||||
<input type='text' name='LSview_pattern' class='LSview_search' />
|
||||
<input type='submit' value='{$LSview_search.submit}' class='LSview_search' />
|
||||
<label class='LSview_search'>Recherche approximative : <input type='checkbox' name='LSview_approx' class='LSview_search' /></label>
|
||||
</form>
|
||||
<h1 id='title'>
|
||||
{$pagetitle}
|
||||
</h1>
|
||||
<div id='content'>
|
||||
{include file='select_table.tpl'}
|
||||
</div>
|
||||
</div>
|
||||
<script type='text/javascript'>
|
||||
varLSselect = new LSselect();
|
||||
</script>
|
23
trunk/templates/select_table.tpl
Normal file
23
trunk/templates/select_table.tpl
Normal file
|
@ -0,0 +1,23 @@
|
|||
<table class='LSobject-list' id='LSselect-object' caption='{$LSobject_list_objecttype}'>
|
||||
<tr class='LSobject-list'>
|
||||
<th class='LSobject-list LSobject-select-check'></th>
|
||||
<th class='LSobject-list'>{$LSobject_list_objectname}</th>
|
||||
</tr>
|
||||
{foreach from=$LSobject_list item=object}
|
||||
<tr class='LSobject-list{if $object.tr=='bis'} LSobject-list-bis{/if}'>
|
||||
<td class='LSobject-list LSobject-select-check'><input type='checkbox' name='LSobjects_selected[]' value='{$object.dn}' {if $object.select}checked{/if} class='LSobject-select' /></td>
|
||||
<td class='LSobject-list LSobject-select-names'>{$object.displayValue}</td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
</table>
|
||||
{if $LSobject_list_nbpage}
|
||||
<p class='LSobject-list-page'>
|
||||
{section name=listpage loop=$LSobject_list_nbpage step=1}
|
||||
{if $LSobject_list_currentpage == $smarty.section.listpage.index}
|
||||
<strong class='LSobject-list-page'>{$LSobject_list_currentpage+1}</strong>
|
||||
{else}
|
||||
<a href='select.php?LSobject={$LSobject_list_objecttype}&page={$smarty.section.listpage.index}&{$LSobject_list_filter}' class='LSobject-list-page'>{$smarty.section.listpage.index+1}</a>
|
||||
{/if}
|
||||
{/section}
|
||||
</p>
|
||||
{/if}
|
30
trunk/templates/top.tpl
Normal file
30
trunk/templates/top.tpl
Normal file
|
@ -0,0 +1,30 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>LdapSaisie{if $pagetitle != ''} - {$pagetitle}{/if}</title>
|
||||
<link rel="stylesheet" type="text/css" href="templates/css/base.css" title="Normal" />
|
||||
<link rel="stylesheet" type="text/css" href="templates/css/base_print.css" media='print' title="Normal" />
|
||||
{$LSsession_css}
|
||||
{$LSsession_js}
|
||||
</head>
|
||||
<body>
|
||||
<div id='LSerror'>
|
||||
{$LSerrors}
|
||||
</div>
|
||||
<div id='LSdebug'>
|
||||
<a href='#' id='LSdebug_hidden'>X</a>
|
||||
<div id='LSdebug_infos'>{if $LSdebug != ''}{$LSdebug}{/if}</div>
|
||||
</div>
|
||||
|
||||
<div id='main'>
|
||||
<div id='left'>
|
||||
<img src='templates/images/logo.png' alt='Logo' id='logo'/>
|
||||
<ul class='menu'>
|
||||
{foreach from=$LSaccess item=item key=LSobject_type}
|
||||
<li class='menu'><a href='view.php?LSobject={$LSobject_type}' class='menu'>{$item.label}</a></li>
|
||||
{/foreach}
|
||||
</ul>
|
||||
</div>
|
||||
<div id='right'>
|
||||
<p id='status'>Connecté en tant que <span id='user_name'>{$LSsession_username}</span></b> <a href='index.php?LSsession_logout'><img src='templates/images/logout.png' alt='Logout' title='Logout' /></a></p>
|
|
@ -1,49 +1,27 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>LdapSaisie{if $pagetitle != ''} - {$pagetitle}{/if}</title>
|
||||
<link rel="stylesheet" type="text/css" href="templates/css/base.css" media="screen" title="Normal" />
|
||||
{$LSsession_css}
|
||||
{$LSsession_js}
|
||||
</head>
|
||||
<body>
|
||||
<div id='LSerror'>
|
||||
{$LSerrors}
|
||||
</div>
|
||||
<div id='LSdebug'>
|
||||
<a href='#' id='LSdebug_hidden'>X</a>
|
||||
<div id='LSdebug_infos'>{if $LSdebug != ''}{$LSdebug}{/if}</div>
|
||||
</div>
|
||||
|
||||
<div id='main'>
|
||||
<div id='left'>
|
||||
<img src='templates/images/logo.png' alt='Logo' id='logo'/>
|
||||
<ul class='menu'>
|
||||
{foreach from=$LSaccess item=item key=LSobject_type}
|
||||
<li class='menu'><a href='view.php?LSobject={$LSobject_type}' class='menu'>{$item.label}</a></li>
|
||||
{/foreach}
|
||||
</ul>
|
||||
</div>
|
||||
<div id='right'>
|
||||
<p id='status'>Connecté en tant que <span id='user_name'>{$LSsession_username}</span></b> <a href='index.php?LSsession_logout'><img src='templates/images/logout.png' alt='Logout' title='Logout' /></a></p>
|
||||
{include file='top.tpl'}
|
||||
{if $pagetitle != ''}<h1>{$pagetitle}</h1>{/if}
|
||||
{if $LSview_actions != ''}
|
||||
<p class='LSview-actions'>
|
||||
{foreach from=$LSview_actions item=item}
|
||||
<a href='{$item.url}' class='LSview-actions'><img src='templates/images/{$item.action}.png' alt='{$item.label}' title='{$item.label}' /></a>
|
||||
<a href='{$item.url}' class='LSview-actions'><img src='templates/images/{$item.action}.png' alt='{$item.label}' title='{$item.label}' /> {$item.label}</a>
|
||||
{/foreach}
|
||||
</p>
|
||||
{/if}
|
||||
|
||||
{if $LSform_image!=''}
|
||||
<div class='LSform_image'>
|
||||
<a href='{$LSform_image.img}'><img src='{$LSform_image.img}' class='LSform_image LSsmoothbox' /></a>
|
||||
</div>
|
||||
{/if}
|
||||
<dl class='LSform'>
|
||||
{foreach from=$LSform_fields item=field}
|
||||
<dt class='LSform'>{$field.label}</dt>
|
||||
<dd class='LSform'>{$field.html}</dd>
|
||||
{/foreach}
|
||||
</dl>
|
||||
</div>
|
||||
<hr class='spacer' />
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
{if $LSrelations!=''}
|
||||
{foreach from=$LSrelations item=item}
|
||||
{include file='LSrelations.tpl'}
|
||||
{/foreach}
|
||||
{/if}
|
||||
{include file='bottom.tpl'}
|
||||
|
|
|
@ -1,38 +1,18 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>LdapSaisie{if $pagetitle != ''} - {$pagetitle}{/if}</title>
|
||||
<link rel="stylesheet" type="text/css" href="templates/css/base.css" media="screen" title="Normal" />
|
||||
{$LSsession_css}
|
||||
{$LSsession_js}
|
||||
</head>
|
||||
<body>
|
||||
<div id='LSerror'>
|
||||
{$LSerrors}
|
||||
</div>
|
||||
<div id='LSdebug'>
|
||||
<a href='#' id='LSdebug_hidden'>X</a>
|
||||
<div id='LSdebug_infos'>{if $LSdebug != ''}{$LSdebug}{/if}</div>
|
||||
</div>
|
||||
|
||||
<div id='main'>
|
||||
<div id='left'>
|
||||
<img src='templates/images/logo.png' alt='Logo' id='logo'/>
|
||||
<ul class='menu'>
|
||||
{foreach from=$LSaccess item=item key=LSobject_type}
|
||||
<li class='menu'><a href='view.php?LSobject={$LSobject_type}' class='menu'>{$item.label}</a></li>
|
||||
{/foreach}
|
||||
</ul>
|
||||
</div>
|
||||
<div id='right'>
|
||||
<p id='status'>Connecté en tant que <span id='user_name'>{$LSsession_username}</span></b> <a href='index.php?LSsession_logout'><img src='templates/images/logout.png' alt='Logout' title='Logout' /></a></p>
|
||||
{if $pagetitle != ''}<h1>{$pagetitle}</h1>{/if}
|
||||
{include file='top.tpl'}
|
||||
<form action='{$LSview_search.action}' method='post' class='LSview_search'>
|
||||
<input type='hidden' name='LSobject' value='{$LSview_search.LSobject}' />
|
||||
<input type='text' name='LSview_pattern' class='LSview_search' />
|
||||
<input type='submit' value='{$LSview_search.submit}' class='LSview_search' />
|
||||
<label class='LSview_search'>Recherche approximative : <input type='checkbox' name='LSview_approx' class='LSview_search' /></label>
|
||||
</form>
|
||||
<h1>
|
||||
{$pagetitle}
|
||||
</h1>
|
||||
|
||||
{if $LSview_actions != ''}
|
||||
<p class='LSview-actions'>
|
||||
{foreach from=$LSview_actions item=item}
|
||||
<a href='{$item.url}' class='LSview-actions'><img src='templates/images/{$item.action}.png' alt='{$item.label}' title='{$item.label}' /></a>
|
||||
<a href='{$item.url}' class='LSview-actions'><img src='templates/images/{$item.action}.png' alt='{$item.label}' title='{$item.label}' /> {$item.label}</a>
|
||||
{/foreach}
|
||||
</p>
|
||||
{/if}
|
||||
|
@ -42,7 +22,7 @@
|
|||
<th class='LSobject-list'>{$_Actions}</th>
|
||||
</tr>
|
||||
{foreach from=$LSobject_list item=object}
|
||||
<tr class='LSobject-list'>
|
||||
<tr class='LSobject-list{if $object.tr=='bis'} LSobject-list-bis{/if}'>
|
||||
<td class='LSobject-list LSobject-list-names'><a href='view.php?LSobject={$LSobject_list_objecttype}&dn={$object.dn}' class='LSobject-list'>{$object.displayValue}</a> </td>
|
||||
<td class='LSobject-list LSobject-list-actions'>
|
||||
{if $object.actions!=''}
|
||||
|
@ -58,15 +38,11 @@
|
|||
<p class='LSobject-list-page'>
|
||||
{section name=listpage loop=$LSobject_list_nbpage step=1}
|
||||
{if $LSobject_list_currentpage == $smarty.section.listpage.index}
|
||||
<strong class='LSobject-list-page'>{$LSobject_list_currentpage}</strong>
|
||||
<strong class='LSobject-list-page'>{$LSobject_list_currentpage+1}</strong>
|
||||
{else}
|
||||
<a href='view.php?LSobject={$LSobject_list_objecttype}&page={$smarty.section.listpage.index}' class='LSobject-list-page'>{$smarty.section.listpage.index}</a>
|
||||
<a href='view.php?LSobject={$LSobject_list_objecttype}&page={$smarty.section.listpage.index}&{$LSobject_list_filter}' class='LSobject-list-page'>{$smarty.section.listpage.index+1}</a>
|
||||
{/if}
|
||||
{/section}
|
||||
</p>
|
||||
{/if}
|
||||
</div>
|
||||
<hr class='spacer' />
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
{include file='bottom.tpl'}
|
||||
|
|
345
trunk/view.php
345
trunk/view.php
|
@ -20,179 +20,244 @@
|
|||
|
||||
******************************************************************************/
|
||||
|
||||
define('NB_LSOBJECT_LIST',20);
|
||||
|
||||
require_once 'includes/functions.php';
|
||||
require_once 'includes/class/class.LSsession.php';
|
||||
|
||||
$GLOBALS['LSsession'] = new LSsession();
|
||||
|
||||
if($LSsession -> startLSsession()) {
|
||||
if (isset($_GET['LSobject'])) {
|
||||
$LSobject = $_GET['LSobject'];
|
||||
if (isset($_REQUEST['LSobject'])) {
|
||||
$LSobject = $_REQUEST['LSobject'];
|
||||
|
||||
if ( $LSobject == 'SELF' ) {
|
||||
if ($GLOBALS['LSsession'] -> canAccess($GLOBALS['LSsession']-> LSuserObject -> getType(),$GLOBALS['LSsession']-> LSuserObject -> getValue('dn'))) {
|
||||
if ( $GLOBALS['LSsession'] -> canEdit($GLOBALS['LSsession']-> LSuserObject -> getType(),$GLOBALS['LSsession']-> LSuserObject -> getValue('dn')) ) {
|
||||
$LSview_actions[] = array (
|
||||
'label' => _('Modifier'),
|
||||
'url' => 'modify.php?LSobject='.$GLOBALS['LSsession']-> LSuserObject -> getType().'&dn='.$GLOBALS['LSsession']-> LSuserObject -> getValue('dn'),
|
||||
'action' => 'modify'
|
||||
);
|
||||
$_REQUEST['LSobject'] = $GLOBALS['LSsession']-> LSuserObject -> getType();
|
||||
$_REQUEST['dn'] = $GLOBALS['LSsession']-> LSuserObject -> getValue('dn');
|
||||
}
|
||||
if ( $GLOBALS['LSsession'] -> loadLSobject($_REQUEST['LSobject']) ) {
|
||||
if ( isset($_REQUEST['dn']) ) {
|
||||
if ($GLOBALS['LSsession'] -> canAccess($_REQUEST['LSobject'],$_REQUEST['dn'])) {
|
||||
if ( $GLOBALS['LSsession'] -> canEdit($_REQUEST['LSobject'],$_REQUEST['dn']) ) {
|
||||
$LSview_actions[] = array(
|
||||
'label' => _('Modifier'),
|
||||
'url' =>'modify.php?LSobject='.$_REQUEST['LSobject'].'&dn='.$_REQUEST['dn'],
|
||||
'action' => 'modify'
|
||||
);
|
||||
}
|
||||
|
||||
if ($GLOBALS['LSsession'] -> canCreate($_REQUEST['LSobject'])) {
|
||||
$LSview_actions[] = array(
|
||||
'label' => _('Copier'),
|
||||
'url' =>'create.php?LSobject='.$_REQUEST['LSobject'].'&load='.$_REQUEST['dn'],
|
||||
'action' => 'copy'
|
||||
);
|
||||
}
|
||||
|
||||
if ($GLOBALS['LSsession'] -> canRemove($_REQUEST['LSobject'],$_REQUEST['dn'])) {
|
||||
$LSview_actions[] = array(
|
||||
'label' => _('Supprimer'),
|
||||
'url' => 'remove.php?LSobject='.$_REQUEST['LSobject'].'&dn='.$_REQUEST['dn'],
|
||||
'action' => 'delete'
|
||||
);
|
||||
}
|
||||
|
||||
if ($GLOBALS['LSsession']-> LSuserObject -> getValue('dn') != $_REQUEST['dn']) {
|
||||
$object = new $_REQUEST['LSobject']();
|
||||
$object -> loadData($_REQUEST['dn']);
|
||||
$GLOBALS['Smarty'] -> assign('pagetitle',$object -> getDisplayValue());
|
||||
}
|
||||
else {
|
||||
$object = &$GLOBALS['LSsession']-> LSuserObject;
|
||||
$GLOBALS['Smarty'] -> assign('pagetitle',_('Mon compte'));
|
||||
}
|
||||
|
||||
$view = $object -> getView();
|
||||
$view -> displayView();
|
||||
|
||||
// Relations
|
||||
if (is_array($object -> config['relations'])) {
|
||||
$LSrelations=array();
|
||||
foreach($object -> config['relations'] as $relationName => $relationConf) {
|
||||
if ($GLOBALS['LSsession'] -> relationCanAccess($object -> getValue('dn'),$relationName)) {
|
||||
$return=array('label' => $relationConf['label']);
|
||||
|
||||
$id=rand();
|
||||
$return['id']=$id;
|
||||
$_SESSION['LSrelation'][$id] = array(
|
||||
'relationName' => $relationName,
|
||||
'objectType' => $object -> getType(),
|
||||
'objectDn' => $object -> getDn(),
|
||||
);
|
||||
if ($GLOBALS['LSsession'] -> relationCanEdit($object -> getValue('dn'),$relationName)) {
|
||||
$return['actions'][] = array(
|
||||
'label' => _('Modifier'),
|
||||
'url' => 'select.php?LSobject='.$relationConf['LSobject'],
|
||||
'action' => 'modify'
|
||||
);
|
||||
}
|
||||
|
||||
$GLOBALS['LSsession'] -> addJSscript('LSselect.js');
|
||||
$GLOBALS['LSsession'] -> addJSscript('LSsmoothbox.js');
|
||||
$GLOBALS['LSsession'] -> addCssFile('LSsmoothbox.css');
|
||||
$GLOBALS['LSsession'] -> addJSscript('LSrelation.js');
|
||||
|
||||
if (method_exists($relationConf['LSobject'],$relationConf['list_function'])) {
|
||||
$objRel = new $relationConf['LSobject']();
|
||||
$list = $objRel -> $relationConf['list_function']($object);
|
||||
if (is_array($list)) {
|
||||
foreach($list as $o) {
|
||||
$return['objectList'][] = $o -> getDisplayValue();
|
||||
}
|
||||
}
|
||||
else {
|
||||
$return['objectList']=array();
|
||||
}
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(1013,$relationName);
|
||||
}
|
||||
$LSrelations[]=$return;
|
||||
}
|
||||
}
|
||||
$GLOBALS['Smarty'] -> assign('LSrelations',$LSrelations);
|
||||
}
|
||||
|
||||
$GLOBALS['Smarty'] -> assign('LSview_actions',$LSview_actions);
|
||||
$GLOBALS['LSsession'] -> addJSscript('LSsmoothbox.js');
|
||||
$GLOBALS['LSsession'] -> addCssFile('LSsmoothbox.css');
|
||||
$GLOBALS['LSsession'] -> setTemplate('view.tpl');
|
||||
}
|
||||
|
||||
if ($GLOBALS['LSsession'] -> canCreate($GLOBALS['LSsession']-> LSuserObject -> getType())) {
|
||||
$LSview_actions[] = array(
|
||||
'label' => _('Copier'),
|
||||
'url' =>'create.php?LSobject='.$GLOBALS['LSsession']-> LSuserObject -> getType().'&load='.$GLOBALS['LSsession']-> LSuserObject -> getValue('dn'),
|
||||
'action' => 'copy'
|
||||
);
|
||||
else {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(1011);
|
||||
}
|
||||
|
||||
if ($GLOBALS['LSsession'] -> canRemove($GLOBALS['LSsession']-> LSuserObject -> getType(),$GLOBALS['LSsession']-> LSuserObject -> getValue('dn'))) {
|
||||
$LSview_actions[] = array (
|
||||
'label' => _('Supprimer'),
|
||||
'url' => 'remove.php?LSobject='.$GLOBALS['LSsession']-> LSuserObject -> getType().'&dn='.$GLOBALS['LSsession']-> LSuserObject -> getValue('dn'),
|
||||
'action' => 'delete'
|
||||
);
|
||||
}
|
||||
|
||||
$GLOBALS['Smarty'] -> assign('pagetitle',_('Mon compte'));
|
||||
$GLOBALS['Smarty'] -> assign('LSview_actions',$LSview_actions);
|
||||
$form = $GLOBALS['LSsession']-> LSuserObject -> getView();
|
||||
$form -> displayView();
|
||||
$GLOBALS['LSsession'] -> setTemplate('view.tpl');
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(1004,$_GET['LSobject']);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ( $GLOBALS['LSsession'] -> loadLSobject($_GET['LSobject']) ) {
|
||||
if ( isset($_GET['dn']) ) {
|
||||
if ($GLOBALS['LSsession'] -> canAccess($_GET['LSobject'],$_GET['dn'])) {
|
||||
if ( $GLOBALS['LSsession'] -> canEdit($_GET['LSobject'],$_GET['dn']) ) {
|
||||
$LSview_actions[] = array(
|
||||
$objectList=array();
|
||||
$object = new $_REQUEST['LSobject']();
|
||||
$GLOBALS['Smarty']->assign('pagetitle',$object -> getLabel());
|
||||
$GLOBALS['Smarty']->assign('LSobject_list_objectname',$object -> getLabel());
|
||||
|
||||
if ($GLOBALS['LSsession'] -> canCreate($_REQUEST['LSobject'])) {
|
||||
$LSview_actions[] = array (
|
||||
'label' => _('Nouveau'),
|
||||
'url' => 'create.php?LSobject='.$_REQUEST['LSobject'],
|
||||
'action' => 'create'
|
||||
);
|
||||
$canCopy=true;
|
||||
}
|
||||
|
||||
if ( $_REQUEST['LSview_pattern']!='' ) {
|
||||
$filter='(|';
|
||||
if ( isset($_REQUEST['LSview_approx']) ) {
|
||||
foreach ($object -> attrs as $attr_name => $attr_val) {
|
||||
$filter.='('.$attr_name.'~='.$_REQUEST['LSview_pattern'].')';
|
||||
}
|
||||
}
|
||||
else {
|
||||
foreach ($object -> attrs as $attr_name => $attr_val) {
|
||||
$filter.='('.$attr_name.'=*'.$_REQUEST['LSview_pattern'].'*)';
|
||||
}
|
||||
}
|
||||
$filter.=')';
|
||||
$GLOBALS['Smarty']->assign('LSobject_list_filter','filter='.urlencode($filter));
|
||||
}
|
||||
else if ($_REQUEST['filter']) {
|
||||
$filter=urldecode($_REQUEST['filter']);
|
||||
$GLOBALS['Smarty']->assign('LSobject_list_filter','filter='.$_REQUEST['filter']);
|
||||
}
|
||||
else {
|
||||
$filter=NULL;
|
||||
$GLOBALS['Smarty']->assign('LSobject_list_filter','');
|
||||
}
|
||||
|
||||
$list=$object -> listObjects($filter);
|
||||
$nbObjects=count($list);
|
||||
$GLOBALS['Smarty']->assign('LSobject_list_nbresult',$nbObjects);
|
||||
if ($nbObjects > NB_LSOBJECT_LIST) {
|
||||
if (isset($_REQUEST['page'])) {
|
||||
$list = array_slice($list, ($_REQUEST['page']) * NB_LSOBJECT_LIST, NB_LSOBJECT_LIST);
|
||||
$GLOBALS['Smarty']->assign('LSobject_list_currentpage',$_REQUEST['page']);
|
||||
$GLOBALS['Smarty']->assign('LSobject_list_nbpage',ceil($nbObjects / NB_LSOBJECT_LIST));
|
||||
}
|
||||
else {
|
||||
$list = array_slice($list, 0, NB_LSOBJECT_LIST);
|
||||
$GLOBALS['Smarty']->assign('LSobject_list_currentpage',0);
|
||||
$GLOBALS['Smarty']->assign('LSobject_list_nbpage',ceil($nbObjects / NB_LSOBJECT_LIST));
|
||||
}
|
||||
}
|
||||
$c=0;
|
||||
foreach($list as $thisObject) {
|
||||
$c++;
|
||||
unset($actions);
|
||||
if ($GLOBALS['LSsession'] -> canAccess($_REQUEST['LSobject'],$thisObject->getValue('dn'))) {
|
||||
$actions[] = array(
|
||||
'label' => _('Voir'),
|
||||
'url' =>'view.php?LSobject='.$_REQUEST['LSobject'].'&dn='.$thisObject -> getValue('dn'),
|
||||
'action' => 'view'
|
||||
);
|
||||
|
||||
if ($GLOBALS['LSsession'] -> canEdit($_REQUEST['LSobject'],$thisObject->getValue('dn'))) {
|
||||
$actions[]=array(
|
||||
'label' => _('Modifier'),
|
||||
'url' =>'modify.php?LSobject='.$_GET['LSobject'].'&dn='.$_GET['dn'],
|
||||
'url' => 'modify.php?LSobject='.$_REQUEST['LSobject'].'&dn='.$thisObject->getValue('dn'),
|
||||
'action' => 'modify'
|
||||
);
|
||||
}
|
||||
|
||||
if ($GLOBALS['LSsession'] -> canCreate($_GET['LSobject'])) {
|
||||
$LSview_actions[] = array(
|
||||
if ($canCopy) {
|
||||
$actions[] = array(
|
||||
'label' => _('Copier'),
|
||||
'url' =>'create.php?LSobject='.$_GET['LSobject'].'&load='.$_GET['dn'],
|
||||
'url' =>'create.php?LSobject='.$_REQUEST['LSobject'].'&load='.$thisObject -> getValue('dn'),
|
||||
'action' => 'copy'
|
||||
);
|
||||
}
|
||||
|
||||
if ($GLOBALS['LSsession'] -> canRemove($_GET['LSobject'],$_GET['dn'])) {
|
||||
$LSview_actions[] = array(
|
||||
if ($GLOBALS['LSsession'] -> canRemove($thisObject -> getType(),$GLOBALS['LSsession']-> LSuserObject -> getValue('dn'))) {
|
||||
$actions[] = array (
|
||||
'label' => _('Supprimer'),
|
||||
'url' => 'remove.php?LSobject='.$_GET['LSobject'].'&dn='.$_GET['dn'],
|
||||
'url' => 'remove.php?LSobject='.$_REQUEST['LSobject'].'&dn='.$thisObject -> getValue('dn'),
|
||||
'action' => 'delete'
|
||||
);
|
||||
}
|
||||
|
||||
$object = new $_GET['LSobject']();
|
||||
$object -> loadData($_GET['dn']);
|
||||
$view = $object -> getView();
|
||||
$view -> displayView();
|
||||
$GLOBALS['Smarty'] -> assign('pagetitle',$object -> getDisplayValue());
|
||||
$GLOBALS['Smarty'] -> assign('LSview_actions',$LSview_actions);
|
||||
$GLOBALS['LSsession'] -> setTemplate('view.tpl');
|
||||
if ($c%2==0) {
|
||||
$tr='bis';
|
||||
}
|
||||
else {
|
||||
$tr='';
|
||||
}
|
||||
|
||||
$objectList[]=array(
|
||||
'dn' => $thisObject->getValue('dn'),
|
||||
'displayValue' => $thisObject->getDisplayValue(),
|
||||
'actions' => $actions,
|
||||
'tr' => $tr
|
||||
);
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(1011);
|
||||
debug($thisObject->getValue('dn'));
|
||||
}
|
||||
}
|
||||
else {
|
||||
$objectList=array();
|
||||
$object = new $_GET['LSobject']();
|
||||
$GLOBALS['Smarty']->assign('pagetitle',$object -> getLabel());
|
||||
$GLOBALS['Smarty']->assign('LSobject_list_objectname',$object -> getLabel());
|
||||
|
||||
if ($GLOBALS['LSsession'] -> canCreate($_GET['LSobject'])) {
|
||||
$LSview_actions[] = array (
|
||||
'label' => _('Nouveau'),
|
||||
'url' => 'create.php?LSobject='.$_GET['LSobject'],
|
||||
'action' => 'create'
|
||||
);
|
||||
$canCopy=true;
|
||||
}
|
||||
|
||||
$list=$object -> listObjects();
|
||||
$nbObjects=count($list);
|
||||
if ($nbObjects > NB_LSOBJECT_LIST) {
|
||||
if (isset($_GET['page'])) {
|
||||
$list = array_slice($list, ($_GET['page']) * NB_LSOBJECT_LIST, NB_LSOBJECT_LIST);
|
||||
$GLOBALS['Smarty']->assign('LSobject_list_currentpage',$_GET['page']);
|
||||
$GLOBALS['Smarty']->assign('LSobject_list_nbpage',ceil($nbObjects / NB_LSOBJECT_LIST));
|
||||
}
|
||||
else {
|
||||
$list = array_slice($list, 0, NB_LSOBJECT_LIST);
|
||||
$GLOBALS['Smarty']->assign('LSobject_list_currentpage',0);
|
||||
$GLOBALS['Smarty']->assign('LSobject_list_nbpage',ceil($nbObjects / NB_LSOBJECT_LIST));
|
||||
}
|
||||
}
|
||||
foreach($list as $thisObject) {
|
||||
unset($actions);
|
||||
if ($GLOBALS['LSsession'] -> canAccess($_GET['LSobject'],$thisObject->getValue('dn'))) {
|
||||
$actions[] = array(
|
||||
'label' => _('Voir'),
|
||||
'url' =>'view.php?LSobject='.$_GET['LSobject'].'&dn='.$thisObject -> getValue('dn'),
|
||||
'action' => 'view'
|
||||
);
|
||||
|
||||
if ($GLOBALS['LSsession'] -> canEdit($_GET['LSobject'],$thisObject->getValue('dn'))) {
|
||||
$actions[]=array(
|
||||
'label' => _('Modifier'),
|
||||
'url' => 'modify.php?LSobject='.$_GET['LSobject'].'&dn='.$thisObject->getValue('dn'),
|
||||
'action' => 'modify'
|
||||
);
|
||||
}
|
||||
|
||||
if ($canCopy) {
|
||||
$actions[] = array(
|
||||
'label' => _('Copier'),
|
||||
'url' =>'create.php?LSobject='.$_GET['LSobject'].'&load='.$thisObject -> getValue('dn'),
|
||||
'action' => 'copy'
|
||||
);
|
||||
}
|
||||
|
||||
if ($GLOBALS['LSsession'] -> canRemove($thisObject -> getType(),$GLOBALS['LSsession']-> LSuserObject -> getValue('dn'))) {
|
||||
$actions[] = array (
|
||||
'label' => _('Supprimer'),
|
||||
'url' => 'remove.php?LSobject='.$_GET['LSobject'].'&dn='.$thisObject -> getValue('dn'),
|
||||
'action' => 'delete'
|
||||
);
|
||||
}
|
||||
|
||||
$objectList[]=array(
|
||||
'dn' => $thisObject->getValue('dn'),
|
||||
'displayValue' => $thisObject->getDisplayValue(),
|
||||
'actions' => $actions
|
||||
);
|
||||
}
|
||||
else {
|
||||
debug($thisObject->getValue('dn'));
|
||||
}
|
||||
}
|
||||
$GLOBALS['LSsession'] -> addJSscript('LSview.js');
|
||||
|
||||
$GLOBALS['Smarty']->assign('_Actions',_('Actions'));
|
||||
$GLOBALS['Smarty']->assign('_Modifier',_('Modifier'));
|
||||
$GLOBALS['Smarty']->assign('LSobject_list',$objectList);
|
||||
$GLOBALS['Smarty']->assign('LSobject_list_objecttype',$_GET['LSobject']);
|
||||
$GLOBALS['Smarty'] -> assign('LSview_actions',$LSview_actions);
|
||||
$GLOBALS['LSsession'] -> setTemplate('viewList.tpl');
|
||||
}
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(1004,$_GET['LSobject']);
|
||||
$GLOBALS['LSsession'] -> addJSscript('LSview.js');
|
||||
|
||||
|
||||
$GLOBALS['Smarty']->assign('LSview_search',array(
|
||||
'action' => $_SERVER['PHP_SELF'],
|
||||
'submit' => _('Rechercher'),
|
||||
'LSobject' => $_REQUEST['LSobject']
|
||||
));
|
||||
|
||||
|
||||
$GLOBALS['Smarty']->assign('_Actions',_('Actions'));
|
||||
$GLOBALS['Smarty']->assign('_Modifier',_('Modifier'));
|
||||
$GLOBALS['Smarty']->assign('LSobject_list',$objectList);
|
||||
$GLOBALS['Smarty']->assign('LSobject_list_objecttype',$_REQUEST['LSobject']);
|
||||
$GLOBALS['Smarty'] -> assign('LSview_actions',$LSview_actions);
|
||||
$GLOBALS['LSsession'] -> setTemplate('viewList.tpl');
|
||||
}
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(1004,$_REQUEST['LSobject']);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(1012);
|
||||
|
|
Loading…
Reference in a new issue