diff --git a/svn-commit.tmp b/svn-commit.tmp deleted file mode 100644 index e9a71ee3..00000000 --- a/svn-commit.tmp +++ /dev/null @@ -1,4 +0,0 @@ -Start. ---This line, and those below, will be ignored-- - -A . diff --git a/trunk/conf/LSobjects/config.LSobjects.LSeegroup.php b/trunk/conf/LSobjects/config.LSobjects.LSeegroup.php index d49eecf0..a91e9205 100644 --- a/trunk/conf/LSobjects/config.LSobjects.LSeegroup.php +++ b/trunk/conf/LSobjects/config.LSobjects.LSeegroup.php @@ -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 diff --git a/trunk/conf/LSobjects/config.LSobjects.LSeepeople.php b/trunk/conf/LSobjects/config.LSobjects.LSeepeople.php index 5d0b329c..af94fb06 100644 --- a/trunk/conf/LSobjects/config.LSobjects.LSeepeople.php +++ b/trunk/conf/LSobjects/config.LSobjects.LSeepeople.php @@ -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' + ) ) ) ); diff --git a/trunk/conf/config.error_code.php b/trunk/conf/config.error_code.php index d34348ff..cba009f3 100644 --- a/trunk/conf/config.error_code.php +++ b/trunk/conf/config.error_code.php @@ -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' ) ); diff --git a/trunk/conf/config.inc.php b/trunk/conf/config.inc.php index c866b6b6..31d81fe3 100644 --- a/trunk/conf/config.inc.php +++ b/trunk/conf/config.inc.php @@ -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' ); + ?> diff --git a/trunk/includes/class/class.LSattr_html.php b/trunk/includes/class/class.LSattr_html.php index 17cafeb2..832257b4 100644 --- a/trunk/includes/class/class.LSattr_html.php +++ b/trunk/includes/class/class.LSattr_html.php @@ -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; + } } ?> diff --git a/trunk/includes/class/class.LSattr_html_image.php b/trunk/includes/class/class.LSattr_html_image.php new file mode 100644 index 00000000..018f3770 --- /dev/null +++ b/trunk/includes/class/class.LSattr_html_image.php @@ -0,0 +1,53 @@ + + */ +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; + } + +} + +?> diff --git a/trunk/includes/class/class.LSattr_html_select_list.php b/trunk/includes/class/class.LSattr_html_select_list.php index a06392ba..a4a1f1e2 100644 --- a/trunk/includes/class/class.LSattr_html_select_list.php +++ b/trunk/includes/class/class.LSattr_html_select_list.php @@ -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." >
",$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; } } diff --git a/trunk/includes/class/class.LSattr_html_select_object.php b/trunk/includes/class/class.LSattr_html_select_object.php new file mode 100644 index 00000000..54d0cac9 --- /dev/null +++ b/trunk/includes/class/class.LSattr_html_select_object.php @@ -0,0 +1,166 @@ + + */ +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 + * + * @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 dn]=$list[$i] -> getDisplayValue($conf['display_attribute']); + $DNs[]=$list[$i] -> dn; + } + } + else { + for($i=0;$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 + * + * @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; + } + +} + +?> diff --git a/trunk/includes/class/class.LSattr_ldap.php b/trunk/includes/class/class.LSattr_ldap.php index fa19e846..93745220 100644 --- a/trunk/includes/class/class.LSattr_ldap.php +++ b/trunk/includes/class/class.LSattr_ldap.php @@ -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; - } } ?> diff --git a/trunk/includes/class/class.LSattr_ldap_image.php b/trunk/includes/class/class.LSattr_ldap_image.php new file mode 100644 index 00000000..297ab3e9 --- /dev/null +++ b/trunk/includes/class/class.LSattr_ldap_image.php @@ -0,0 +1,32 @@ + + */ +class LSattr_ldap_image extends LSattr_ldap { + // \\ +} + +?> diff --git a/trunk/includes/class/class.LSattribute.php b/trunk/includes/class/class.LSattribute.php index 4aaf5785..b7b8aed1 100644 --- a/trunk/includes/class/class.LSattribute.php +++ b/trunk/includes/class/class.LSattribute.php @@ -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; } diff --git a/trunk/includes/class/class.LSerror.php b/trunk/includes/class/class.LSerror.php index be5f063b..b8c7dc34 100644 --- a/trunk/includes/class/class.LSerror.php +++ b/trunk/includes/class/class.LSerror.php @@ -36,7 +36,7 @@ class LSerror { * @author Benjamin Renard * * @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 * * @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 "

"._('Erreurs')."

\n"; foreach ($this -> errors as $error) { echo "(Code ".$error[0].") ".getFData($GLOBALS['LSerror_code'][$error[0]]['msg'],$error[1])."
\n"; @@ -92,20 +92,31 @@ class LSerror { /** * Retourne le texte des erreurs - * - * @author Benjamin Renard - * - * @retvat string Le texte des erreurs - */ - function getErrors() { - if(!empty($this -> errors)) { + * + * @author Benjamin Renard + * + * @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])."
\n"; } - return $txt; - } - return; - } + return $txt; + } + return; + } + + /** + * Définir si il y a des erreurs + * + * @author Benjamin Renard + * + * @retvat boolean + */ + function errorsDefined() { + return !empty($this -> errors); + } } ?> diff --git a/trunk/includes/class/class.LSform.php b/trunk/includes/class/class.LSform.php index 5713f781..c7dd1626 100644 --- a/trunk/includes/class/class.LSform.php +++ b/trunk/includes/class/class.LSform.php @@ -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\n \t\n \t\n - \t"; - $GLOBALS['Smarty'] -> assign('LSform_header',$LSform_header); + \t\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\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 + * + * @param[in] $element [required] 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; + } } diff --git a/trunk/includes/class/class.LSformElement.php b/trunk/includes/class/class.LSformElement.php index 6ddcc885..dd6bb968 100644 --- a/trunk/includes/class/class.LSformElement.php +++ b/trunk/includes/class/class.LSformElement.php @@ -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; } diff --git a/trunk/includes/class/class.LSformElement_image.php b/trunk/includes/class/class.LSformElement_image.php new file mode 100644 index 00000000..1fbe7293 --- /dev/null +++ b/trunk/includes/class/class.LSformElement_image.php @@ -0,0 +1,106 @@ + + */ + +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'] = "\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; + } +} + +?> diff --git a/trunk/includes/class/class.LSformElement_select_object.php b/trunk/includes/class/class.LSformElement_select_object.php new file mode 100644 index 00000000..f4954f9d --- /dev/null +++ b/trunk/includes/class/class.LSformElement_select_object.php @@ -0,0 +1,95 @@ + + */ + +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="
  • + "._('Modifier')."\n + \n +
  • \n"; + $delete=" "._("; + $class='LSformElement_select_object'; + } + else { + $class=''; + $delete=''; + $addBtn=''; + } + + $return['html']="
      \n"; + $return['html'].=$addBtn; + foreach ($this -> values as $value => $txt) { + $return['html'].="
    • ".$txt."$delete
    • "; + } + $return['html'].="
    \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; + } + + + +} + +?> diff --git a/trunk/includes/class/class.LSformRule.php b/trunk/includes/class/class.LSformRule.php index dbcaff32..c129740d 100644 --- a/trunk/includes/class/class.LSformRule.php +++ b/trunk/includes/class/class.LSformRule.php @@ -29,22 +29,23 @@ class LSformRule { /** * Constructeur - * - * @author Benjamin Renard * - */ + * + * @author Benjamin Renard * + */ 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; } } diff --git a/trunk/includes/class/class.LSformRule_alphanumeric.php b/trunk/includes/class/class.LSformRule_alphanumeric.php index 7ec64f50..cb584fc3 100644 --- a/trunk/includes/class/class.LSformRule_alphanumeric.php +++ b/trunk/includes/class/class.LSformRule_alphanumeric.php @@ -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); } } diff --git a/trunk/includes/class/class.LSformRule_compare.php b/trunk/includes/class/class.LSformRule_compare.php index 7b847e33..3037fdbc 100644 --- a/trunk/includes/class/class.LSformRule_compare.php +++ b/trunk/includes/class/class.LSformRule_compare.php @@ -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);'); diff --git a/trunk/includes/class/class.LSformRule_email.php b/trunk/includes/class/class.LSformRule_email.php index 1e581e6c..c8219840 100644 --- a/trunk/includes/class/class.LSformRule_email.php +++ b/trunk/includes/class/class.LSformRule_email.php @@ -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; } } diff --git a/trunk/includes/class/class.LSformRule_imagefile.php b/trunk/includes/class/class.LSformRule_imagefile.php new file mode 100644 index 00000000..8d715f83 --- /dev/null +++ b/trunk/includes/class/class.LSformRule_imagefile.php @@ -0,0 +1,68 @@ + + */ +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; + } + +} + +?> diff --git a/trunk/includes/class/class.LSformRule_imagefilesize.php b/trunk/includes/class/class.LSformRule_imagefilesize.php new file mode 100644 index 00000000..6b0b0b81 --- /dev/null +++ b/trunk/includes/class/class.LSformRule_imagefilesize.php @@ -0,0 +1,63 @@ + + */ +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; + } + +} + +?> diff --git a/trunk/includes/class/class.LSformRule_imagesize.php b/trunk/includes/class/class.LSformRule_imagesize.php new file mode 100644 index 00000000..bf08363d --- /dev/null +++ b/trunk/includes/class/class.LSformRule_imagesize.php @@ -0,0 +1,74 @@ + + */ +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; + } + +} + +?> diff --git a/trunk/includes/class/class.LSformRule_lettersonly.php b/trunk/includes/class/class.LSformRule_lettersonly.php index 17b3826b..ca5edccd 100644 --- a/trunk/includes/class/class.LSformRule_lettersonly.php +++ b/trunk/includes/class/class.LSformRule_lettersonly.php @@ -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); } } diff --git a/trunk/includes/class/class.LSformRule_maxlength.php b/trunk/includes/class/class.LSformRule_maxlength.php index ec525938..09e6f057 100644 --- a/trunk/includes/class/class.LSformRule_maxlength.php +++ b/trunk/includes/class/class.LSformRule_maxlength.php @@ -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']); } diff --git a/trunk/includes/class/class.LSformRule_minlength.php b/trunk/includes/class/class.LSformRule_minlength.php index a50be3c9..ff665917 100644 --- a/trunk/includes/class/class.LSformRule_minlength.php +++ b/trunk/includes/class/class.LSformRule_minlength.php @@ -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']); } diff --git a/trunk/includes/class/class.LSformRule_nonzero.php b/trunk/includes/class/class.LSformRule_nonzero.php index 53cb07e3..49525343 100644 --- a/trunk/includes/class/class.LSformRule_nonzero.php +++ b/trunk/includes/class/class.LSformRule_nonzero.php @@ -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); } } diff --git a/trunk/includes/class/class.LSformRule_nopunctuation.php b/trunk/includes/class/class.LSformRule_nopunctuation.php index 94d50a5c..7a5e868b 100644 --- a/trunk/includes/class/class.LSformRule_nopunctuation.php +++ b/trunk/includes/class/class.LSformRule_nopunctuation.php @@ -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); } } diff --git a/trunk/includes/class/class.LSformRule_numeric.php b/trunk/includes/class/class.LSformRule_numeric.php index 13618c2d..47ae637d 100644 --- a/trunk/includes/class/class.LSformRule_numeric.php +++ b/trunk/includes/class/class.LSformRule_numeric.php @@ -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); } } diff --git a/trunk/includes/class/class.LSformRule_rangelength.php b/trunk/includes/class/class.LSformRule_rangelength.php index db71f53a..4332a492 100644 --- a/trunk/includes/class/class.LSformRule_rangelength.php +++ b/trunk/includes/class/class.LSformRule_rangelength.php @@ -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]); } diff --git a/trunk/includes/class/class.LSformRule_regex.php b/trunk/includes/class/class.LSformRule_regex.php index cd88466c..b93d18f3 100644 --- a/trunk/includes/class/class.LSformRule_regex.php +++ b/trunk/includes/class/class.LSformRule_regex.php @@ -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; } } diff --git a/trunk/includes/class/class.LSformRule_required.php b/trunk/includes/class/class.LSformRule_required.php index 61d5ab39..d5da57db 100644 --- a/trunk/includes/class/class.LSformRule_required.php +++ b/trunk/includes/class/class.LSformRule_required.php @@ -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 != ''); } diff --git a/trunk/includes/class/class.LSldap.php b/trunk/includes/class/class.LSldap.php index 767fc05d..5d6b92c9 100644 --- a/trunk/includes/class/class.LSldap.php +++ b/trunk/includes/class/class.LSldap.php @@ -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 * @@ -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); diff --git a/trunk/includes/class/class.LSldapObject.php b/trunk/includes/class/class.LSldapObject.php index 4b8089af..1b8d7a78 100644 --- a/trunk/includes/class/class.LSldapObject.php +++ b/trunk/includes/class/class.LSldapObject.php @@ -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; } } diff --git a/trunk/includes/class/class.LSobjects.LSeegroup.php b/trunk/includes/class/class.LSobjects.LSeegroup.php index c5beb67c..e9faf4e8 100644 --- a/trunk/includes/class/class.LSobjects.LSeegroup.php +++ b/trunk/includes/class/class.LSobjects.LSeegroup.php @@ -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 getDn(); + if (in_array($dn, $listDns)) { + $dontDelete[$i]=true; + $dontAdd[]=$dn; + } + } + + for($i=0;$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; + } + } + } + } } ?> diff --git a/trunk/includes/class/class.LSsession.php b/trunk/includes/class/class.LSsession.php index cafe86cd..965a4a2c 100644 --- a/trunk/includes/class/class.LSsession.php +++ b/trunk/includes/class/class.LSsession.php @@ -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.="\n"; } + foreach ($this -> JSscripts as $script) { $JSscript_txt.="\n"; } + + if ($GLOBALS['LSdebug']['active']) { + $JSscript_txt.="\n"; + } + else { + $JSscript_txt.="\n"; + } + $GLOBALS['Smarty'] -> assign('LSsession_js',$JSscript_txt); // Css - $Css_txt="\n"; + $Css_txt="\n"; + $Css_txt="\n"; foreach ($this -> CssFiles as $file) { - $Css_txt.="\n"; + $Css_txt.="\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 + * + * @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 + * + * @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 + * + * @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 + * + * @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(); + } + } } diff --git a/trunk/includes/js/LSdefault.js b/trunk/includes/js/LSdefault.js index cb6531ec..96e68aa6 100644 --- a/trunk/includes/js/LSdefault.js +++ b/trunk/includes/js/LSdefault.js @@ -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; diff --git a/trunk/includes/js/LSform.js b/trunk/includes/js/LSform.js index b6690391..a63ab31c 100644 --- a/trunk/includes/js/LSform.js +++ b/trunk/includes/js/LSform.js @@ -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(); } }); diff --git a/trunk/includes/js/LSrelation.js b/trunk/includes/js/LSrelation.js new file mode 100644 index 00000000..fcb60419 --- /dev/null +++ b/trunk/includes/js/LSrelation.js @@ -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'); diff --git a/trunk/includes/js/LSselect.js b/trunk/includes/js/LSselect.js new file mode 100644 index 00000000..e89e571a --- /dev/null +++ b/trunk/includes/js/LSselect.js @@ -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; + } + + +}); diff --git a/trunk/includes/js/LSsession_login.js b/trunk/includes/js/LSsession_login.js index 44d41418..22fe52d9 100644 --- a/trunk/includes/js/LSsession_login.js +++ b/trunk/includes/js/LSsession_login.js @@ -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(); }); diff --git a/trunk/includes/js/LSsmoothbox.js b/trunk/includes/js/LSsmoothbox.js new file mode 100644 index 00000000..2cfdac8b --- /dev/null +++ b/trunk/includes/js/LSsmoothbox.js @@ -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(); +}); diff --git a/trunk/index_ajax.php b/trunk/index_ajax.php index 53f1ea9f..a055adb8 100644 --- a/trunk/index_ajax.php +++ b/trunk/index_ajax.php @@ -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=""; - $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'].= "
  • ".$o -> getDisplayValue()."
  • \n"; + } + } + else { + $data['html'] = "
  • "._('Liste vide.')."
  • \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); ?> diff --git a/trunk/modify.php b/trunk/modify.php index ff00e9f7..814d810c 100644 --- a/trunk/modify.php +++ b/trunk/modify.php @@ -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(); diff --git a/trunk/select.php b/trunk/select.php new file mode 100644 index 00000000..592bd4b5 --- /dev/null +++ b/trunk/select.php @@ -0,0 +1,148 @@ + 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(); +?> diff --git a/trunk/templates/LSrelations.tpl b/trunk/templates/LSrelations.tpl new file mode 100644 index 00000000..b494a677 --- /dev/null +++ b/trunk/templates/LSrelations.tpl @@ -0,0 +1,13 @@ +

    {$item.label}

    +{if $item.actions!=''} +

    + {foreach from=$item.actions item=action} + {$action.label} {$action.label} + {/foreach} +

    +{/if} +
      +{foreach from=$item.objectList item=object} +
    • {$object}
    • +{/foreach} +
    diff --git a/trunk/templates/accueil.tpl b/trunk/templates/accueil.tpl index 258cbbc0..069bcac4 100644 --- a/trunk/templates/accueil.tpl +++ b/trunk/templates/accueil.tpl @@ -1,39 +1,3 @@ - - - - LdapSaisie{if $pagetitle != ''} - {$pagetitle}{/if} - - {$LSsession_css} - {$LSsession_js} - - -
    -{$LSerrors} -
    -
    - X -
    {if $LSdebug != ''}{$LSdebug}{/if}
    -
    - -
    - -
    - - -
    - - -
    -
    - - +{include file='top.tpl'} +

    {$pagetitle}

    +{include file='bottom.tpl'} diff --git a/trunk/templates/base.tpl b/trunk/templates/base.tpl deleted file mode 100644 index 8dbeeb0b..00000000 --- a/trunk/templates/base.tpl +++ /dev/null @@ -1,49 +0,0 @@ - - - - LdapSaisie{if $pagetitle != ''} - {$pagetitle}{/if} - - {$LSsession_css} - {$LSsession_js} - - -
    -{$LSerrors} -
    -
    - X -
    {if $LSdebug != ''}{$LSdebug}{/if}
    -
    - -
    -
    - - -
    - -
    -
    - - diff --git a/trunk/templates/blank.tpl b/trunk/templates/blank.tpl new file mode 100644 index 00000000..f12a80f9 --- /dev/null +++ b/trunk/templates/blank.tpl @@ -0,0 +1,20 @@ + + + + LdapSaisie{if $pagetitle != ''} - {$pagetitle}{/if} + + + {$LSsession_css} + {$LSsession_js} + + +
    +{$LSerrors} +
    +
    + X +
    {if $LSdebug != ''}{$LSdebug}{/if}
    +
    + + diff --git a/trunk/templates/bottom.tpl b/trunk/templates/bottom.tpl new file mode 100644 index 00000000..f23e12ff --- /dev/null +++ b/trunk/templates/bottom.tpl @@ -0,0 +1,5 @@ + +
    + + + diff --git a/trunk/templates/create.tpl b/trunk/templates/create.tpl index 32132a6a..2882c6e9 100644 --- a/trunk/templates/create.tpl +++ b/trunk/templates/create.tpl @@ -1,33 +1,4 @@ - - - - LdapSaisie{if $pagetitle != ''} - {$pagetitle}{/if} - - {$LSsession_css} - {$LSsession_js} - - -
    -{$LSerrors} -
    -
    - X -
    {if $LSdebug != ''}{$LSdebug}{/if}
    -
    - -
    -
    - - -
    - -
    -
    - - +{include file='bottom.tpl'} diff --git a/trunk/templates/css/LSform.css b/trunk/templates/css/LSform.css index b766001b..69374d13 100644 --- a/trunk/templates/css/LSform.css +++ b/trunk/templates/css/LSform.css @@ -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; +} diff --git a/trunk/templates/css/LSsmoothbox.css b/trunk/templates/css/LSsmoothbox.css new file mode 100644 index 00000000..15487c81 --- /dev/null +++ b/trunk/templates/css/LSsmoothbox.css @@ -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%; +} diff --git a/trunk/templates/css/base.css b/trunk/templates/css/base.css index 2d34e454..52f9f406 100644 --- a/trunk/templates/css/base.css +++ b/trunk/templates/css/base.css @@ -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; +} diff --git a/trunk/templates/css/base_print.css b/trunk/templates/css/base_print.css new file mode 100644 index 00000000..f5e52374 --- /dev/null +++ b/trunk/templates/css/base_print.css @@ -0,0 +1,15 @@ +#main { + width: 840px; +} + +#left { + display: none; +} + +#status { + display: none; +} + +p.LSview-actions { + display: none; +} diff --git a/trunk/templates/empty.tpl b/trunk/templates/empty.tpl index 5d6e0d7b..70430570 100644 --- a/trunk/templates/empty.tpl +++ b/trunk/templates/empty.tpl @@ -1,34 +1,2 @@ - - - - LdapSaisie{if $pagetitle != ''} - {$pagetitle}{/if} - - {$LSsession_css} - {$LSsession_js} - - -
    -{$LSerrors} -
    -
    - X -
    {if $LSdebug != ''}{$LSdebug}{/if}
    -
    - -
    -
    - - -
    - -
    -
    - - +{include file='top.tpl'} +{include file='bottom.tpl'} diff --git a/trunk/templates/images/imgbroken.png b/trunk/templates/images/imgbroken.png new file mode 100644 index 00000000..adeb879e Binary files /dev/null and b/trunk/templates/images/imgbroken.png differ diff --git a/trunk/templates/images/loading.gif b/trunk/templates/images/loading.gif new file mode 100644 index 00000000..cc70a7a8 Binary files /dev/null and b/trunk/templates/images/loading.gif differ diff --git a/trunk/templates/images/person.png b/trunk/templates/images/person.png new file mode 100755 index 00000000..71038ed7 Binary files /dev/null and b/trunk/templates/images/person.png differ diff --git a/trunk/templates/images/zoom.png b/trunk/templates/images/zoom.png new file mode 100644 index 00000000..fd7f0b07 Binary files /dev/null and b/trunk/templates/images/zoom.png differ diff --git a/trunk/templates/modify.tpl b/trunk/templates/modify.tpl index dcaf0634..b641961b 100644 --- a/trunk/templates/modify.tpl +++ b/trunk/templates/modify.tpl @@ -1,43 +1,28 @@ - - - - LdapSaisie{if $pagetitle != ''} - {$pagetitle}{/if} - - {$LSsession_css} - {$LSsession_js} - - -
    -{$LSerrors} -
    -
    - X -
    {if $LSdebug != ''}{$LSdebug}{/if}
    -
    - -
    -
    - - -
    - -
    -
    - - +{include file='bottom.tpl'} diff --git a/trunk/templates/question.tpl b/trunk/templates/question.tpl index 1dddb5ee..1fd13cf7 100644 --- a/trunk/templates/question.tpl +++ b/trunk/templates/question.tpl @@ -1,32 +1,4 @@ - - - - LdapSaisie{if $pagetitle != ''} - {$pagetitle}{/if} - - {$LSsession_css} - {$LSsession_js} - - -
    -{$LSerrors} -
    -
    - X -
    {if $LSdebug != ''}{$LSdebug}{/if}
    -
    - -
    -
    - - -
    - -
    -
    - - +{include file='bottom.tpl'} diff --git a/trunk/templates/select.tpl b/trunk/templates/select.tpl new file mode 100644 index 00000000..c231ddb7 --- /dev/null +++ b/trunk/templates/select.tpl @@ -0,0 +1,17 @@ +
    + +

    + {$pagetitle} +

    +
    + {include file='select_table.tpl'} +
    +
    + diff --git a/trunk/templates/select_table.tpl b/trunk/templates/select_table.tpl new file mode 100644 index 00000000..29b21d9f --- /dev/null +++ b/trunk/templates/select_table.tpl @@ -0,0 +1,23 @@ + + + + + +{foreach from=$LSobject_list item=object} + + + + +{/foreach} +
    {$LSobject_list_objectname}
    {$object.displayValue}
    +{if $LSobject_list_nbpage} +

    + {section name=listpage loop=$LSobject_list_nbpage step=1} + {if $LSobject_list_currentpage == $smarty.section.listpage.index} + {$LSobject_list_currentpage+1} + {else} + {$smarty.section.listpage.index+1} + {/if} + {/section} +

    +{/if} diff --git a/trunk/templates/top.tpl b/trunk/templates/top.tpl new file mode 100644 index 00000000..88eb1c69 --- /dev/null +++ b/trunk/templates/top.tpl @@ -0,0 +1,30 @@ + + + + LdapSaisie{if $pagetitle != ''} - {$pagetitle}{/if} + + + {$LSsession_css} + {$LSsession_js} + + +
    +{$LSerrors} +
    +
    + X +
    {if $LSdebug != ''}{$LSdebug}{/if}
    +
    + +
    +
    + + +
    +