From e340850741c7a96fc67e44180a60d6288dd17609 Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Fri, 31 Oct 2008 12:12:31 +0000 Subject: [PATCH] =?UTF-8?q?-=20config.inc.php=20:=20Changement=20du=20doma?= =?UTF-8?q?ine=20d'exemple.=20ls.com=20existe=20-=20LSmail=20:=20=20=20->?= =?UTF-8?q?=20Le=20sujet=20n'=C3=A9tait=20pas=20encore=20param=C3=A8trable?= =?UTF-8?q?=20d'avance=20:=20c'est=20fait.=20=20=20->=20Adpatation=20index?= =?UTF-8?q?=5Fajax.php=20=20=20->=20Ajout=20d'une=20m=C3=A9thode=20JS=20d'?= =?UTF-8?q?export=20des=20infos=20du=20mail=20saisie=20-=20LSformElement?= =?UTF-8?q?=5Fpassword=20:=20Ajout=20d'une=20possibilit=C3=A9=20d'envoie?= =?UTF-8?q?=20du=20mot=20de=20passe=20=20=20par=20mail=20lors=20de=20sa=20?= =?UTF-8?q?modification=20-=20LSattribute=20:=20Ajout=20d'un=20binding=20a?= =?UTF-8?q?pplicatif=20pour=20l'execution=20de=20fonction/=20=20=20m=C3=A9?= =?UTF-8?q?thode=20lors=20d'=C3=A9venement=20(a=20agr=C3=A9menter)=20-=20L?= =?UTF-8?q?SldapObject=20:=20Utilisation=20des=20evenements=20pour=20le=20?= =?UTF-8?q?binding=20onModify=20des=20=20=20attributs=20-=20LSaddons=20::?= =?UTF-8?q?=20Mail=20:=20Ajout=20d'un=20header=20'To:'=20syst=C3=A9matique?= =?UTF-8?q?ment.=20-=20LSform=20:=20Ajout=20de=20la=20m=C3=A9thode=20JS=20?= =?UTF-8?q?getValue()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LSobjects/config.LSobjects.LSeepeople.php | 34 ++++- trunk/conf/config.inc.php | 4 +- trunk/images/default/mail-edit.png | Bin 0 -> 623 bytes trunk/images/default/nomail.png | Bin 0 -> 756 bytes trunk/includes/addons/LSaddons.mail.php | 1 + trunk/includes/class/class.LSattribute.php | 129 ++++++++++++++++++ .../class/class.LSformElement_password.php | 72 ++++++++++ trunk/includes/class/class.LSldapObject.php | 42 +----- trunk/includes/js/LSform.js | 26 ++++ .../js/LSformElement_password_field.js | 83 +++++++++++ trunk/includes/js/LSmail.js | 20 ++- trunk/index_ajax.php | 53 ++++--- trunk/templates/default/LSmail.tpl | 2 +- 13 files changed, 392 insertions(+), 74 deletions(-) create mode 100644 trunk/images/default/mail-edit.png create mode 100644 trunk/images/default/nomail.png diff --git a/trunk/conf/LSobjects/config.LSobjects.LSeepeople.php b/trunk/conf/LSobjects/config.LSobjects.LSeepeople.php index 5116872e..f5ddf3b4 100644 --- a/trunk/conf/LSobjects/config.LSobjects.LSeepeople.php +++ b/trunk/conf/LSobjects/config.LSobjects.LSeepeople.php @@ -27,6 +27,7 @@ $GLOBALS['LSobjects']['LSeepeople'] = array ( 'posixAccount', 'sambaSamAccount', ), + 'orderby' => 'displayValue', // Valeurs possibles : 'displayValue' ou 'subDn' 'rdn' => 'uid', 'container_dn' => 'ou=people', 'container_auto_create' => array( @@ -66,6 +67,13 @@ $GLOBALS['LSobjects']['LSeepeople'] = array ( 'label' => _('Identifiant'), 'ldap_type' => 'ascii', 'html_type' => 'text', + 'html_options' => array( + 'generate_value_format' => '%{givenName:1}.%{sn}', + 'autoGenerateOnModify' => true, // default : false + 'withoutAccent' => 1, + 'replaceSpaces' => '.', + 'lowerCase' => 1 + ), 'required' => 1, 'check_data' => array ( 'alphanumeric' => array( @@ -340,7 +348,31 @@ $GLOBALS['LSobjects']['LSeepeople'] = array ( 'generationTool' => true, 'autoGenerate' => false, 'chars' => 'abcdefgh', - 'lenght' => 5 + 'lenght' => 5, + 'mail' => array( + 'send' => 1, + 'ask' => 1, + 'subject' => "LSexample : votre nouveau mot de passe", + 'msg' => "Votre mot de passe vient d'etre modifie.\nNouveau mot de passe : %{mdp}", + 'mail_attr' => 'mail' + ) + ), + 'check_data' => array( + 'password' => array( + 'msg' => 'Le mot de passe doit contenir entre 8 et 10 caractères.', + 'params' => array( + 'minLength' => 8, + 'maxLength' => 10, + 'prohibitedValues' => array( + 'azertyui', + '12345678' + ), + 'regex' => array( + '[a-z]+', + '[0-9]+' + ) + ) + ) ), 'required' => 1, 'rights' => array( diff --git a/trunk/conf/config.inc.php b/trunk/conf/config.inc.php index a4d3b94f..cadd1f10 100644 --- a/trunk/conf/config.inc.php +++ b/trunk/conf/config.inc.php @@ -65,7 +65,7 @@ $GLOBALS['LSconfig'] = array( 'recoverPassword' => array( 'mailAttr' => 'mail', 'recoveryHashAttr' => 'lsRecoveryHash', - 'recoveryEmailSender' => 'noreply-recover@lsexample.net', + 'recoveryEmailSender' => 'noreply-recover@ls.com', 'recoveryHashMail' => array( 'subject' => 'LSexample : Récupération de votre mot de passe.', 'msg' => "Pour poursuivre le processus de récupération de votre mot de passe,\nmerci de cliquer de vous rendre à l'adresse suivante :\n%{url}" @@ -75,7 +75,7 @@ $GLOBALS['LSconfig'] = array( 'msg' => "Votre nouveau mot de passe : %{mdp}" ) ), - 'emailSender' => 'noreply@lsexample.net', + 'emailSender' => 'noreply@ls.com', 'LSobjects' => array ( 'LSeepeople', 'LSeegroup' diff --git a/trunk/images/default/mail-edit.png b/trunk/images/default/mail-edit.png new file mode 100644 index 0000000000000000000000000000000000000000..a452d0b6ee352ded11f4cba504afd248d46f89f2 GIT binary patch literal 623 zcmV-#0+9WQP)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2iOV` z5E2cF&$Fih00HkwL_t(I%f*pTPg7A4#ecW=Y6~qGOiH1GXibc9A(gmL6BA7v?9R2H zz^$@&YeM`8>|MLXCZ-z`l*CnIgoH(nP)dQOrGH=h-W?aO6vT>4Z!)=OGC4D6=D`1c z>h;R!TxfLc?m@j5Zgkv$6|e}N6|4xJ2-f;}KLq9Vdac^Q&yB4u6P>s;`{LQnai=FL z6x6?WKZ}+Bw;flv9WVZT+3A?_k(=ncR=vxWSiCohI2G1DeZ&OLm+o2#Ohu<}n5N^Y z;DrEJrpL*CEweDw;riTF9^8Kj$lo^S%laC6x1mg{;{uSFil7A6H%lzU!CH^i)el4I znatAxHqDOb0}Y9Iglahmv;jz`Q~z|qG~2!crNHgET+}DB^ZEQxQZktwT-LN44*|Me zm%U1z=;cvxY5>Gyu|LStx7AM+ftKTnXNB@%o!RIZk&rp%pBjV+SnHET?4X-zR(1+b z*PXjHGom6R0aa{U4t)U>i^b!)hzKG+j>TdK(5aP6rrX&6k$Sm05gZGLO;D@JU|lUO zPG}Kfe*R9MD5s?R3KVd(yT50?yPx#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2iOV` z5CaIQd}KHP00MMLL_t(I%axN$NK|nY#()1if5$uO*o@RPWi_QG5fw?#O;k`p@7k0r zSAo0SBv@8Zw1}`xn~0!Yg;=<;#wLnWS=(?0Tm;7z zToD`*TvrGWc2l!ri`v-rR2c|aT__h;?l04Gg0mLZ9jGeJO^7lJJ%4XIUG((esck@Y zJA5Ifg}DDxMPNC}1l!vJqzl;GJ$^vf4{@UOXxNS(c? zbl>bHMmp!H!UBWxd8IsjA7dmn!Q4_sfd|a~UV@j-GZfgB`??$Ho;hw>U&oyd~^q8<#2sI zzHZ*nx1)`y@^TEZ(FHosvd-ij1h6cd(NA5hxp|qulQuk74%=(;ed|Gn>rYX&dO7K= z#b9EL*+D-dfGBh(XN%*CN_Kvxy7>hDjt2m^J|F2rHF%GoA-o`hi=d0V=#Za*c#`pe z55yIn{?#9~Vu{Gw<_5#;c$~k@IeY}~$tLD3UWme-lu!X^B0;|!9U8Ne@gD=)O2vCx z_SMg;`}o+L2EVD?AeRHXoJ7kYh8{#saWpkU9NV(SM~8pLyZd^le_Z~^c7etJ>yPOH mZ>PYg1OhWLn3}Pj|B2rZdUhc=6-}uC0000 getEmailSender() != "")) { $headers['From'] = $GLOBALS['LSsession'] -> getEmailSender(); } + $headers["To"] = $to; $ret = $mail_obj -> send($to,$headers,$msg); diff --git a/trunk/includes/class/class.LSattribute.php b/trunk/includes/class/class.LSattribute.php index 49136043..d7b24382 100644 --- a/trunk/includes/class/class.LSattribute.php +++ b/trunk/includes/class/class.LSattribute.php @@ -42,6 +42,8 @@ class LSattribute { var $is_validate=false; var $_finalUpdateData=false; var $_myRights=NULL; + var $_events=array(); + var $_objectEvents=array(); /** * Constructeur @@ -520,6 +522,133 @@ class LSattribute { return $this -> config['dependAttrs']; } + /** + * Ajouter une action lors d'un événement + * + * @param[in] $event string Le nom de l'événement + * @param[in] $fct string Le nom de la fonction à exectuer + * @param[in] $params mixed Paramètres pour le lancement de la fonction + * @param[in] $class Nom de la classe possèdant la méthode $fct à executer + * + * @retval void + */ + function addEvent($event,$fct,$params,$class=NULL) { + $this -> _events[$event][] = array( + 'function' => $fct, + 'params' => $params, + 'class' => $class + ); + } + + /** + * Ajouter une action sur un objet lors d'un événement + * + * @param[in] $event string Le nom de l'événement + * @param[in] $obj object L'objet dont la méthode doit être executé + * @param[in] $meth string Le nom de la méthode + * @param[in] $params mixed Paramètres d'execution de la méthode + * + * @retval void + */ + function addObjectEvent($event,&$obj,$meth,$params=NULL) { + $this -> _objectEvents[$event][] = array( + 'obj' => $obj, + 'meth' => $meth, + 'params' => $params + ); + } + + /** + * Lance les actions à executer lors d'un événement + * + * @param[in] $event string Le nom de l'événement + * + * @retval boolean True si tout c'est bien passé, false sinon + */ + function fireEvent($event) { + $return = true; + if(isset($this -> config[$event])) { + if (!is_array($this -> config[$event])) { + $funcs = array($this -> config[$event]); + } + else { + $funcs = $this -> config[$event]; + } + foreach($funcs as $func) { + if(function_exists($func)) { + if(!$func($this -> ldapObject)) { + $return = false; + } + } + else { + $return = false; + } + } + } + + if (is_array($this -> _events[$event])) { + foreach ($this -> _events[$event] as $e) { + if ($e['class']) { + if (class_exists($e['class'])) { + $obj = new $e['class'](); + if (method_exists($obj,$e['fct'])) { + try { + $obj -> $e['fct']($e['params']); + } + catch(Exception $er) { + $return = false; + LSdebug("Event ".$event." : Erreur durant l'execution de la méthode ".$e['fct']." de la classe ".$e['class']); + } + } + else { + LSdebug("Event ".$event." : La méthode ".$e['fct']." de la classe ".$e['class']." n'existe pas."); + $return = false; + } + } + else { + $return = false; + LSdebug("Event ".$event." : La classe ".$e['class']." n'existe pas"); + } + } + else { + if (function_exists($e['fct'])) { + try { + $e['fct']($e['params']); + } + catch(Exception $er) { + LSdebug("Event ".$event." : Erreur durant l'execution de la function ".$e['fct']); + $return = false; + } + } + else { + LSdebug("Event ".$event." : la function ".$e['fct']." n'existe pas"); + $return = false; + } + } + } + } + + if (is_array($this -> _objectEvents[$event])) { + foreach ($this -> _objectEvents[$event] as $e) { + if (method_exists($e['obj'],$e['meth'])) { + try { + $e['obj'] -> $e['meth']($e['params']); + } + catch(Exception $er) { + $return = false; + LSdebug("Event ".$event." : Erreur durant l'execution de la méthode ".$e['meth']." sur l'objet."); + } + } + else { + LSdebug("Event ".$event." : La méthode ".$e['meth']." de l'objet n'existe pas."); + $return = false; + } + } + } + + return $return; + } + } ?> diff --git a/trunk/includes/class/class.LSformElement_password.php b/trunk/includes/class/class.LSformElement_password.php index 4d710e88..3f3fcc80 100644 --- a/trunk/includes/class/class.LSformElement_password.php +++ b/trunk/includes/class/class.LSformElement_password.php @@ -34,6 +34,8 @@ class LSformElement_password extends LSformElement { var $fieldTemplate = 'LSformElement_password_field.tpl'; var $template = 'LSformElement_password.tpl'; + + var $sendMail = false; /** * Recupère la valeur de l'élement passée en POST @@ -56,6 +58,40 @@ class LSformElement_password extends LSformElement { $this -> form -> _notUpdate[$this -> name] == true; return true; } + + //Mail + if (isset($_POST['LSformElement_password_'.$this -> name.'_send'])) { + if ($_POST['LSformElement_password_'.$this -> name.'_send']==1) { + $this -> sendMail = true; + LSdebug ('send by form'); + } + } + else if ($this -> params['html_options']['mail']['send']==1) { + $this -> sendMail = true; + LSdebug ('send by config'); + } + if ($this -> sendMail && $GLOBALS['LSsession'] -> loadLSaddon('mail')) { + $msg = getFData($this -> params['html_options']['mail']['msg'],$return[$this -> name][0]); + $subject = $this -> params['html_options']['mail']['subject']; + if (isset($_POST['LSformElement_password_'.$this -> name.'_msg'])) { + $msgInfos = json_decode($_POST['LSformElement_password_'.$this -> name.'_msg']); + if ($msgInfos -> subject) { + $subject = $msgInfos -> subject; + } + if ($msgInfos -> msg) { + $msg = getFData($msgInfos -> msg,$return[$this -> name][0]); + } + if ($msgInfos -> mail) { + $mail = $msgInfos -> mail; + } + } + $this -> sendMail = array ( + 'subject' => $subject, + 'msg' => $msg, + 'mail' => $mail + ); + $this -> attr_html -> attribute -> addObjectEvent('after_modify',$this,'send'); + } } return $retval; } @@ -80,6 +116,9 @@ class LSformElement_password extends LSformElement { 'generate' => ($this -> params['html_options']['generationTool']==True), 'verify' => (!$this -> attr_html -> attribute -> ldapObject-> isNew()) ); + if (isset($this -> params['html_options']['mail'])) { + $params['mail'] = $this -> params['html_options']['mail']; + } $GLOBALS['LSsession'] -> addJSconfigParam($this -> name,$params); $GLOBALS['LSsession'] -> addJSscript('LSformElement_password_field.js'); @@ -99,6 +138,39 @@ class LSformElement_password extends LSformElement { } return $GLOBALS['LSsession'] -> checkUserPwd($this -> attr_html -> attribute -> ldapObject,$pwd); } + + function send($params) { + if (is_array($this -> sendMail)) { + $mail = (String)$this -> sendMail['mail']; + Lsdebug($mail); + if ($mail=="") { + $mail_attr = $this -> attr_html -> attribute -> ldapObject -> attrs[$this -> params['html_options']['mail']['mail_attr']]; + if ($mail_attr instanceOf LSattribute) { + $mail = $mail_attr -> getValue(); + $mail=$mail[0]; + } + else { + LSdebug("L'attribut $mail_attr pour l'envoie du nouveau mot de passe n'existe pas."); + return; + } + } + + if (checkEmail($mail,NULL,true)) { + if (sendMail( + $mail, + $this -> sendMail['subject'], + $this -> sendMail['msg'] + )) { + $GLOBALS['LSsession'] -> addInfo(_('Mail de changement de mot de passe envoyé.')); + } + } + else { + LSdebug('Adresse mail incorrect : '.$mail); + return; + } + } + return true; + } } ?> diff --git a/trunk/includes/class/class.LSldapObject.php b/trunk/includes/class/class.LSldapObject.php index bc3c30f8..bc88a610 100644 --- a/trunk/includes/class/class.LSldapObject.php +++ b/trunk/includes/class/class.LSldapObject.php @@ -318,26 +318,7 @@ class LSldapObject { } // $this -> attrs[*] => before_modify foreach($new_data as $attr_name => $attr_val) { - if(isset($this -> config['attrs'][$attr_name]['before_modify'])) { - if (!is_array($this -> config['attrs'][$attr_name]['before_modify'])) { - $funcs = array($this -> config['attrs'][$attr_name]['before_modify']); - } - else { - $funcs = $this -> config['attrs'][$attr_name]['before_modify']; - } - foreach($funcs as $func) { - if(function_exists($func)) { - if(!$func($this)) { - $GLOBALS['LSerror'] -> addErrorCode(309,array('func' => $func,'attr' => $attr_name)); - return; - } - } - else { - $GLOBALS['LSerror'] -> addErrorCode(308,array('func' => $func,'attr' => $attr_name)); - return; - } - } - } + $this -> attrs[$attr_name] -> fireEvent('before_modify'); } if ($this -> submitChange($idForm)) { @@ -364,26 +345,7 @@ class LSldapObject { // $this -> attrs[*] => After Modify foreach($new_data as $attr_name => $attr_val) { - if(isset($this -> config['attrs'][$attr_name]['after_modify'])) { - if (!is_array($this -> config['attrs'][$attr_name]['after_modify'])) { - $funcs = array($this -> config['attrs'][$attr_name]['after_modify']); - } - else { - $funcs = $this -> config['attrs'][$attr_name]['after_modify']; - } - foreach($funcs as $func) { - if(function_exists($func)) { - if(!$func($this)) { - $GLOBALS['LSerror'] -> addErrorCode(307,array('func' => $func,'attr' => $attr_name)); - return; - } - } - else { - $GLOBALS['LSerror'] -> addErrorCode(306,array('func' => $func,'attr' => $attr_name)); - return; - } - } - } + $this -> attrs[$attr_name] -> fireEvent('after_modify'); } return true; } diff --git a/trunk/includes/js/LSform.js b/trunk/includes/js/LSform.js index b557c371..f8de8572 100644 --- a/trunk/includes/js/LSform.js +++ b/trunk/includes/js/LSform.js @@ -33,6 +33,32 @@ var LSform = new Class({ LSdebug('Pas de reinitialise pour ' + fieldType); } } + }, + + getValue: function(fieldName) { + var retVal = Array(); + var ul = $(fieldName); + if ($type(ul)) { + var elements = ul.getElements('input'); + elements.combine(ul.getElements('textarea')); + elements.combine(ul.getElements('select')); + + var getName = new RegExp('([a-zA-Z0-9]*)(\[.*\])?'); + elements.each(function(el){ + var name = getName.exec(el.name); + LSdebug(name); + if (name) { + if (name[1]==fieldName) { + if ($type(el.value)) { + if (el.value!="") { + retVal.include(el.value); + } + } + } + } + },this); + } + return retVal; } }); window.addEvent(window.ie ? 'load' : 'domready', function() { diff --git a/trunk/includes/js/LSformElement_password_field.js b/trunk/includes/js/LSformElement_password_field.js index 528cd1de..7b8e1e25 100644 --- a/trunk/includes/js/LSformElement_password_field.js +++ b/trunk/includes/js/LSformElement_password_field.js @@ -8,6 +8,38 @@ var LSformElement_password_field = new Class({ }, initialiseLSformElement_password_field: function() { + // Mail + if (this.params['mail']) { + if ((this.params.mail['canEdit']==1)||(!$type(this.params.mail['canEdit']))) { + this.editMailBtn = new Element('img'); + this.editMailBtn.src = varLSdefault.imagePath('mail-edit.png'); + this.editMailBtn.addClass('btn'); + this.editMailBtn.addEvent('click',this.onEditMailBtnClick.bind(this)); + this.LSmail_open = 0; + this.editMailBtn.injectAfter(this.input); + } + if (this.params.mail['ask']) { + this.mailBtn = new Element('img'); + this.mailBtn.addClass('btn'); + this.mailBtn.addEvent('click',this.onMailBtnClick.bind(this)); + this.mailInput = new Element('input'); + this.mailInput.setProperties({ + name: 'LSformElement_password_' + this.name + '_send', + type: 'hidden' + }); + if (this.params.mail['send']) { + this.mailInput.value = 1; + this.mailBtn.src = varLSdefault.imagePath('nomail.png'); + } + else { + this.mailInput.value = 0; + this.mailBtn.src = varLSdefault.imagePath('mail.png'); + } + this.mailBtn.injectAfter(this.input); + this.mailInput.injectAfter(this.mailBtn); + } + } + // ViewBtn this.viewBtn = new Element('img'); this.viewBtn.src = varLSdefault.imagePath('view.png'); @@ -44,6 +76,57 @@ var LSformElement_password_field = new Class({ } }, + onMailBtnClick: function() { + if (this.mailInput.value==1) { + this.mailInput.value = 0; + this.mailBtn.src = varLSdefault.imagePath('mail.png'); + } + else { + this.mailInput.value = 1; + this.mailBtn.src = varLSdefault.imagePath('nomail.png'); + } + }, + + onEditMailBtnClick: function(btn) { + if(!$type(this.LSmail)) { + this.LSmail = new LSmail(); + this.LSmail.addEvent('close',this.onLSmailClose.bind(this)); + this.LSmail.addEvent('valid',this.onLSmailValid.bind(this)); + } + + var mail = varLSform.getValue(this.params.mail['mail_attr']); + + this.LSmail_open = 1; + this.LSmail.setMails(mail); + this.LSmail.setSubject(this.params.mail['subject']); + this.LSmail.setMsg(this.params.mail['msg']); + this.LSmail.open(this.editMailBtn); + }, + + onLSmailClose: function(LSmail) { + LSdebug('LSformElement_password : close LSmail'); + this.LSmail_open = 0; + }, + + onLSmailValid: function(LSmail) { + LSdebug('LSformElement_password : valid LSmail'); + this.setMail(LSmail.getMail()); + }, + + setMail: function(mail) { + if ($type(mail)) { + if (!$type(this.msgInput)) { + this.msgInput = new Element('input'); + this.msgInput.setProperties({ + name: 'LSformElement_password_' + this.name + '_msg', + type: 'hidden' + }); + this.msgInput.injectAfter(this.editMailBtn); + } + this.msgInput.value = JSON.encode(mail); + } + }, + onGenerateBtnClick: function() { var data = { template: 'LSform', diff --git a/trunk/includes/js/LSmail.js b/trunk/includes/js/LSmail.js index 4a5e55d1..66e7dd1e 100644 --- a/trunk/includes/js/LSmail.js +++ b/trunk/includes/js/LSmail.js @@ -1,8 +1,9 @@ var LSmail = new Class({ - initialize: function(mails,msg){ + initialize: function(mails,subject,msg){ this.href = "LSmail.php"; this.setMails(mails); this.setMsg(msg); + this.setSubject(subject); this.object = {}; this.opened = 0; this.listeners = { @@ -29,6 +30,15 @@ var LSmail = new Class({ } }, + setSubject: function(subject) { + if ($type(subject)) { + this.subject = subject; + } + else { + this.subject = ""; + } + }, + setObject: function(type,dn) { this.object = { type: type, @@ -43,7 +53,8 @@ var LSmail = new Class({ action: 'display', object: this.object, mails: this.mails, - msg: this.msg + msg: this.msg, + subject: this.subject }; if ($type(startElement)) { @@ -57,7 +68,6 @@ var LSmail = new Class({ onOpenGetHtmlComplete: function(responseText, responseXML) { var data = JSON.decode(responseText); if ( varLSdefault.checkAjaxReturn(data) ) { - //varLSsmoothbox.setRefreshElement(this); varLSsmoothbox.asNew(); varLSsmoothbox.addEvent('valid',this.onLSsmoothboxValid.bind(this)); varLSsmoothbox.addEvent('close',this.onLSsmoothboxClose.bind(this)); @@ -94,6 +104,10 @@ var LSmail = new Class({ } }, + getMail: function() { + return this.sendInfos; + }, + onSendComplete: function(responseText, responseXML) { var data = JSON.decode(responseText); if ( varLSdefault.checkAjaxReturn(data) ) { diff --git a/trunk/index_ajax.php b/trunk/index_ajax.php index 44f8557d..e1495c56 100644 --- a/trunk/index_ajax.php +++ b/trunk/index_ajax.php @@ -354,38 +354,37 @@ if (!isset($_ERRORS)) { case 'LSmail': switch($_REQUEST['action']) { case 'display': - if ((isset($_REQUEST['object'])) && (isset($_REQUEST['mails'])) && (isset($_REQUEST['msg'])) ) { - if (isset($_REQUEST['object']['type']) && isset($_REQUEST['object']['dn'])) { - if ($GLOBALS['LSsession']->loadLSobject($_REQUEST['object']['type'])) { - $obj = new $_REQUEST['object']['type'](); - $obj -> loadData($_REQUEST['object']['dn']); - $msg = $obj -> getFData($_REQUEST['msg']); - } - else { - $GLOBALS['LSerror'] -> addErrorCode(1004,$_REQUEST['object']['type']); - } + if (isset($_REQUEST['object']['type']) && isset($_REQUEST['object']['dn'])) { + if ($GLOBALS['LSsession']->loadLSobject($_REQUEST['object']['type'])) { + $obj = new $_REQUEST['object']['type'](); + $obj -> loadData($_REQUEST['object']['dn']); + $msg = $obj -> getFData($_REQUEST['msg']); + $subject = $obj -> getFData($_REQUEST['subject']); } else { - $msg = $_REQUEST['msg']; + $GLOBALS['LSerror'] -> addErrorCode(1004,$_REQUEST['object']['type']); } - $GLOBALS['Smarty'] -> assign('LSmail_msg',$msg); - if (is_array($_REQUEST['mails'])) { - $GLOBALS['Smarty'] -> assign('LSmail_mails',$_REQUEST['mails']); - } - else if(empty($_REQUEST['mails'])) { - $GLOBALS['Smarty'] -> assign('LSmail_mails',array($_REQUEST['mails'])); - } - $GLOBALS['Smarty'] -> assign('LSmail_mail_label',_('E-mail')); - $GLOBALS['Smarty'] -> assign('LSmail_subject_label',_('Sujet')); - $GLOBALS['Smarty'] -> assign('LSmail_msg_label',_('Message')); - - $data = array( - 'html' => $GLOBALS['Smarty'] -> fetch('LSmail.tpl') - ); } else { - $GLOBALS['LSerror'] -> addErrorCode(1012); - } + $msg = $_REQUEST['msg']; + $subject = $_REQUEST['subject']; + } + + $GLOBALS['Smarty'] -> assign('LSmail_msg',$msg); + $GLOBALS['Smarty'] -> assign('LSmail_subject',$subject); + if (is_array($_REQUEST['mails'])) { + $GLOBALS['Smarty'] -> assign('LSmail_mails',$_REQUEST['mails']); + } + else if(empty($_REQUEST['mails'])) { + $GLOBALS['Smarty'] -> assign('LSmail_mails',array($_REQUEST['mails'])); + } + $GLOBALS['Smarty'] -> assign('LSmail_mail_label',_('E-mail')); + $GLOBALS['Smarty'] -> assign('LSmail_subject_label',_('Sujet')); + $GLOBALS['Smarty'] -> assign('LSmail_msg_label',_('Message')); + + $data = array( + 'html' => $GLOBALS['Smarty'] -> fetch('LSmail.tpl') + ); break; case 'send': if (isset($_REQUEST['infos'])) { diff --git a/trunk/templates/default/LSmail.tpl b/trunk/templates/default/LSmail.tpl index b427f03f..5e8b1d79 100644 --- a/trunk/templates/default/LSmail.tpl +++ b/trunk/templates/default/LSmail.tpl @@ -15,7 +15,7 @@
{$LSmail_subject_label}
- +
{$LSmail_msg_label}