From d75a8823c2568a288a2c10ba3821f26cab2ddc77 Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Thu, 25 Sep 2008 15:15:33 +0000 Subject: [PATCH] =?UTF-8?q?-=20LSview=20:=20ajout=20de=20input=20hidden=20?= =?UTF-8?q?pour=20contenir=20les=20informations=20du=20type=20et=20du=20?= =?UTF-8?q?=20=20DN=20de=20l'objet=20affich=C3=A9.=20-=20LSmail=20:=20Ajou?= =?UTF-8?q?t=20d'une=20fonctionalit=C3=A9=20d'envoie=20de=20mail=20depuis?= =?UTF-8?q?=20l'interface.=20=20=20->=20Modification=20de=20LSformElement?= =?UTF-8?q?=5Fmail=20pour=20utiliser=20cette=20fonctionalit=C3=A9=20=20=20?= =?UTF-8?q?->=20Agr=C3=A9mentation=20du=20fichier=20index=5Fajax.php=20=20?= =?UTF-8?q?=20->=20Ajout=20d'un=20LSaddons=20::=20mail=20-=20LSsession=20:?= =?UTF-8?q?=20=20=20->=20Ajout=20d'une=20m=C3=A9thode=20getEmailSender()?= =?UTF-8?q?=20=20=20->=20Utilisation=20de=20la=20m=C3=A9thode=20getEmailSe?= =?UTF-8?q?nder()=20pour=20la=20partie=20de=20r=C3=A9cup=C3=A9ration=20=20?= =?UTF-8?q?=20=20=20=20de=20mot=20de=20passe=20=20=20->=20Revue=20des=20m?= =?UTF-8?q?=C3=A9thodes=20loadLSaddon()=20et=20loadLSaddons()=20-=20LSconf?= =?UTF-8?q?irmBox=20:=20=20=20->=20Ajout=20de=20binding=20onClose()=20et?= =?UTF-8?q?=20onCancel()=20-=20LSsmoothbox=20:=20=20=20->=20D=C3=A9port=20?= =?UTF-8?q?de=20la=20creation=20de=20la=20structure=20dans=20la=20m=C3=A9t?= =?UTF-8?q?hode=20build()=20=20=20->=20Suppression=20du=20principe=20de=20?= =?UTF-8?q?refreshElement=20au=20profit=20de=20binding=20sur=20les=20=20?= =?UTF-8?q?=20=20=20=20=C3=A9venements=20onClose,=20onValid=20et=20onCance?= =?UTF-8?q?l=20=20=20=20=20=20=20->=20Ajout=20des=20m=C3=A9thodes=20addEve?= =?UTF-8?q?nt()=20et=20fireEvent()=20=20=20=20=20=20=20->=20Suppression=20?= =?UTF-8?q?de=20la=20m=C3=A9thode=20setRefreshElement()=20=20=20->=20Ajout?= =?UTF-8?q?=20de=20la=20m=C3=A9thode=20asNew()=20pour=20remettre=20l'objet?= =?UTF-8?q?=20dans=20son=20=C3=A9tat=20d'origine=20=20=20=20=20=20pour=20l?= =?UTF-8?q?'utilisation=20simultan=C3=A9=20de=20l'objet=20par=20plusieurs?= =?UTF-8?q?=20autres=20=20=20->=20V=C3=A9rification=20lors=20du=20clique?= =?UTF-8?q?=20sur=20le=20closeBtn=20qu'une=20pr=C3=A9c=C3=A9dente=20confir?= =?UTF-8?q?mBox=20=20=20=20=20=20n'est=20pas=20d=C3=A9j=C3=A0=20ouvert=20?= =?UTF-8?q?=20=20->=20La=20m=C3=A9thode=20close()=20ne=20fait=20plus=20que?= =?UTF-8?q?=20fermer=20la=20LSsmoothbox=20et=20les=20m=C3=A9thodes=20=20?= =?UTF-8?q?=20=20=20=20valid()=20et=20cancel()=20g=C3=A8re=20les=20cas=20d?= =?UTF-8?q?e=20fermeture=20et=20lance=20la=20m=C3=A9thode=20close()=20=20?= =?UTF-8?q?=20->=20Ajout=20de=20la=20m=C3=A9thode=20openHTML()=20pour=20l'?= =?UTF-8?q?ouverture=20de=20la=20LSsmoothbox=20avec=20un=20=20=20=20=20=20?= =?UTF-8?q?code=20HTML=20pass=C3=A9=20en=20param=C3=A8tre=20=20=20->=20Ajo?= =?UTF-8?q?ut=20de=20la=20m=C3=A9thode=20setOption()=20-=20LSrelation=20&?= =?UTF-8?q?=20LSformElement=5Fselect=5Fobject=20:=20=20=20->=20Utilisation?= =?UTF-8?q?=20du=20principe=20d'=C3=A9venement=20de=20la=20LSsmoothbox=20p?= =?UTF-8?q?lut=C3=B4t=20que=20du=20=20=20=20=20=20refreshElement=20=20=20-?= =?UTF-8?q?>=20Utilisation=20de=20la=20m=C3=A9thode=20asNew()=20pour=20evi?= =?UTF-8?q?ter=20tout=20probl=C3=A8me=20de=20concurence=20-=20LSdefault=20?= =?UTF-8?q?:=20Ajout=20de=20la=20m=C3=A9thode=20displayInfos()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- trunk/includes/addons/LSaddons.mail.php | 159 ++++++++++++++++++ .../class/class.LSformElement_mail.php | 8 +- trunk/includes/class/class.LSsession.php | 25 ++- trunk/includes/js/LSconfirmBox.js | 6 + trunk/includes/js/LSdefault.js | 7 +- trunk/includes/js/LSformElement_mail.js | 33 +++- .../js/LSformElement_select_object.js | 9 +- trunk/includes/js/LSmail.js | 127 ++++++++++++++ trunk/includes/js/LSrelation.js | 9 +- trunk/includes/js/LSsmoothbox.js | 143 +++++++++++----- trunk/index_ajax.php | 51 ++++++ trunk/templates/LSmail.tpl | 20 +++ trunk/templates/css/LSmail.css | 1 + trunk/templates/view.tpl | 2 + 14 files changed, 533 insertions(+), 67 deletions(-) create mode 100644 trunk/includes/addons/LSaddons.mail.php create mode 100644 trunk/includes/js/LSmail.js create mode 100644 trunk/templates/LSmail.tpl create mode 100644 trunk/templates/css/LSmail.css diff --git a/trunk/includes/addons/LSaddons.mail.php b/trunk/includes/addons/LSaddons.mail.php new file mode 100644 index 00000000..cc0e1acf --- /dev/null +++ b/trunk/includes/addons/LSaddons.mail.php @@ -0,0 +1,159 @@ + "text/plain", + "charset" => "UTF-8", + "format" => "flowed" + ); + + // Message d'erreur + + $GLOBALS['LSerror_code']['FTP_SUPPORT_01']= array ( + 'msg' => _("MAIL Support : Pear::MAIL est introuvable."), + 'level' => 'c' + ); + + $GLOBALS['LSerror_code']['MAIL_00']= array ( + 'msg' => _("MAIL Error : %{msg}"), + 'level' => 'c' + ); + + $GLOBALS['LSerror_code']['MAIL_01']= array ( + 'msg' => _("MAIL : Problème durant l'envoie de votre mail"), + 'level' => 'c' + ); + + /** + * Fin des données de configuration + */ + + + /** + * Verification du support MAIL par ldapSaisie + * + * @author Benjamin Renard + * + * @retval boolean true si MAIL est pleinement supporté, false sinon + */ + function LSaddon_mail_support() { + $retval=true; + + // Dependance de librairie + if (!class_exists('Mail')) { + if(!@include(PEAR_MAIL)) { + $GLOBALS['LSerror'] -> addErrorCode('MAIL_SUPPORT_01'); + $retval=false; + } + } + + return $retval; + } + + /** + * Envoie d'un mail + * + * @author Benjamin Renard + * + * @retval boolean true si MAIL est pleinement supporté, false sinon + */ + function sendMail($to,$subject,$msg) { + $mail_obj = & Mail::factory(MAIL_SEND_METHOD, $MAIL_SEND_PARAMS); + + if(is_array($MAIL_HEARDERS)) { + $headers = $MAIL_HEARDERS; + } + else { + $headers = array(); + } + $headers["Subject"] = $subject; + if (!isset($headers['From']) && ($GLOBALS['LSsession'] -> getEmailSender() != "")) { + $headers['From'] = $GLOBALS['LSsession'] -> getEmailSender(); + } + + $ret = $mail_obj -> send($to,$headers,$msg); + + if ($ret instanceof PEAR_Error) { + $GLOBALS['LSerror'] -> addErrorCode('MAIL_01'); + $GLOBALS['LSerror'] -> addErrorCode('MAIL_00',$ret -> getMessage()); + return; + } + return true; + } + + + + diff --git a/trunk/includes/class/class.LSformElement_mail.php b/trunk/includes/class/class.LSformElement_mail.php index 7bf7848a..29b05e09 100644 --- a/trunk/includes/class/class.LSformElement_mail.php +++ b/trunk/includes/class/class.LSformElement_mail.php @@ -55,7 +55,6 @@ class LSformElement_mail extends LSformElement { } } $return['html'] .= "\n"; - $GLOBALS['LSsession'] -> addJSscript('LSformElement_mail.js'); } else { $return['html'] = "
    \n"; @@ -65,11 +64,16 @@ class LSformElement_mail extends LSformElement { else { foreach ($this -> values as $value) { $return['html'] .= "
  • ".$value.""._(
  • \n"; - $GLOBALS['LSsession'] -> addJSscript('LSformElement_mail.js'); } } $return['html'] .= "
\n"; } + $GLOBALS['LSsession'] -> addJSscript('LSmail.js'); + $GLOBALS['LSsession'] -> addJSscript('LSsmoothbox.js'); + $GLOBALS['LSsession'] -> addCssFile('LSsmoothbox.css'); + $GLOBALS['LSsession'] -> addJSscript('LSconfirmBox.js'); + $GLOBALS['LSsession'] -> addCssFile('LSconfirmBox.css'); + $GLOBALS['LSsession'] -> addJSscript('LSformElement_mail.js'); return $return; } diff --git a/trunk/includes/class/class.LSsession.php b/trunk/includes/class/class.LSsession.php index 5a6a3464..9650c96e 100644 --- a/trunk/includes/class/class.LSsession.php +++ b/trunk/includes/class/class.LSsession.php @@ -155,7 +155,14 @@ class LSsession { * @retval boolean true si le chargement a réussi, false sinon. */ function loadLSaddon($addon) { - return require_once LS_ADDONS_DIR .'LSaddons.'.$addon.'.php'; + if(require_once LS_ADDONS_DIR .'LSaddons.'.$addon.'.php') { + if (!call_user_func('LSaddon_'. $addon .'_support')) { + $GLOBALS['LSerror'] -> addErrorCode(1002,$addon); + return; + } + return true; + } + return; } /** @@ -174,9 +181,6 @@ class LSsession { foreach ($GLOBALS['LSaddons']['loads'] as $addon) { $this -> loadLSaddon($addon); - if (!call_user_func('LSaddon_'. $addon .'_support')) { - $GLOBALS['LSerror'] -> addErrorCode(1002,$addon); - } } return true; } @@ -328,8 +332,8 @@ class LSsession { if ($this -> ldapServer['recoverPassword']['recoveryEmailSender']) { $headers.="\nFrom: ".$this -> ldapServer['recoverPassword']['recoveryEmailSender']; } - else if($this -> ldapServer['emailSender']) { - $headers.="\nFrom: ".$this -> ldapServer['emailSender']; + else if($this -> getEmailSender()) { + $headers.="\nFrom: ".$this -> getEmailSender(); } if (checkEmail($emailAddress)) { @@ -1482,6 +1486,15 @@ class LSsession { exit(); } } + + /** + * Retourne l'adresse mail d'emission configurée pour le serveur courant + * + * @retval string Adresse mail d'emission + */ + function getEmailSender() { + return $this -> ldapServer['emailSender']; + } } ?> diff --git a/trunk/includes/js/LSconfirmBox.js b/trunk/includes/js/LSconfirmBox.js index 28241029..26d69cf6 100644 --- a/trunk/includes/js/LSconfirmBox.js +++ b/trunk/includes/js/LSconfirmBox.js @@ -97,6 +97,9 @@ var LSconfirmBox = new Class({ onClose: function() { this.box.setStyle('display','none'); this.purge(); + if (this._options.onClose) { + $try(this._options.onClose); + } }, purge: function() { @@ -162,5 +165,8 @@ var LSconfirmBox = new Class({ cancel: function() { this.hide(); + if (this._options.onCancel) { + $try(this._options.onCancel); + } } }); diff --git a/trunk/includes/js/LSdefault.js b/trunk/includes/js/LSdefault.js index 07ce0c4d..8c54f94d 100644 --- a/trunk/includes/js/LSdefault.js +++ b/trunk/includes/js/LSdefault.js @@ -92,7 +92,12 @@ var LSdefault = new Class({ this.LSdebugInfos.set('html',html); this.displayDebugBox(); }, - + + displayInfos: function(html) { + this.LSinfos.set('html',html); + this.displayInfosBox(); + }, + displayErrorBox: function() { this.LSerror.setStyle('top',getScrollTop()+10); this.fx.LSerror.start(0,0.8); diff --git a/trunk/includes/js/LSformElement_mail.js b/trunk/includes/js/LSformElement_mail.js index 79f8c24f..e0f3607e 100644 --- a/trunk/includes/js/LSformElement_mail.js +++ b/trunk/includes/js/LSformElement_mail.js @@ -4,6 +4,7 @@ var LSformElement_mail = new Class({ if (typeof(varLSform) != "undefined") { varLSform.addModule("LSformElement_mail",this); } + this.LSmail_open = 0; }, initialiseLSformElement_mail: function(el) { @@ -20,13 +21,33 @@ var LSformElement_mail = new Class({ }, onBtnClick: function(btn) { - var href = btn.getParent().getFirst().href; - if (typeof(href)=="undefined") { - href = 'mailto:'+btn.getParent().getFirst().value; - } - if ((href!="")&&(href!="mailto:")) { - location.href = href; + if (this.LSmail_open==0) { + var mail = btn.getParent().getFirst().innerHTML; + if ((typeof(mail)!='string')||(mail=='')) { + mail = btn.getParent().getFirst().value; + } + if(!$type(this.LSmail)) { + this.LSmail = new LSmail(); + this.LSmail.addEvent('close',this.onLSmailClose.bind(this)); + this.LSmail.addEvent('valid',this.onLSmailValid.bind(this)); + } + if ((mail!="")) { + this.LSmail_open = 1; + this.LSmail.setMails([mail]); + this.LSmail.setObject($('LSform_objecttype').value,$('LSform_objectdn').value); + this.LSmail.open(btn); + } } + }, + + onLSmailClose: function(LSmail) { + LSdebug('LSformElement_mail : close LSmail'); + this.LSmail_open = 0; + }, + + onLSmailValid: function(LSmail) { + LSdebug('LSformElement_mail : valid LSmail'); + LSmail.send(); } }); window.addEvent(window.ie ? 'load' : 'domready', function() { diff --git a/trunk/includes/js/LSformElement_select_object.js b/trunk/includes/js/LSformElement_select_object.js index 98cb5037..3e8c24de 100644 --- a/trunk/includes/js/LSformElement_select_object.js +++ b/trunk/includes/js/LSformElement_select_object.js @@ -41,13 +41,14 @@ var LSformElement_select_object = new Class({ onLSformElement_select_object_addBtnClickComplete: 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.displayValidBtn(); varLSsmoothbox.openURL(data.href,{width: 615}); } }, - refresh: function() { + onLSsmoothboxValid: function() { var getAttrName = /LSformElement_select_object_(.*)_[0-9]*/ var attrName = getAttrName.exec(this.refreshFields)[1]; var data = { @@ -60,10 +61,10 @@ var LSformElement_select_object = new Class({ ul: this.refreshFields }; data.imgload=varLSdefault.loadingImgDisplay($('a_' + this.refreshFields)); - new Request({url: 'index_ajax.php', data: data, onSuccess: this.onRefreshComplete.bind(this)}).send(); + new Request({url: 'index_ajax.php', data: data, onSuccess: this.onLSsmoothboxValidComplete.bind(this)}).send(); }, - onRefreshComplete: function(responseText, responseXML) { + onLSsmoothboxValidComplete: function(responseText, responseXML) { var data = JSON.decode(responseText); if ( varLSdefault.checkAjaxReturn(data) ) { $(this.refreshFields).getParent().set('html',data.html); diff --git a/trunk/includes/js/LSmail.js b/trunk/includes/js/LSmail.js new file mode 100644 index 00000000..4a5e55d1 --- /dev/null +++ b/trunk/includes/js/LSmail.js @@ -0,0 +1,127 @@ +var LSmail = new Class({ + initialize: function(mails,msg){ + this.href = "LSmail.php"; + this.setMails(mails); + this.setMsg(msg); + this.object = {}; + this.opened = 0; + this.listeners = { + close: new Array(), + valid: new Array() + }; + }, + + setMails: function(mails) { + if ($type(mails)) { + this.mails = mails; + } + else { + this.mails = new Array(); + } + }, + + setMsg: function(msg) { + if ($type(msg)) { + this.msg = msg; + } + else { + this.msg = ""; + } + }, + + setObject: function(type,dn) { + this.object = { + type: type, + dn: dn + }; + }, + + open: function(startElement) { + if (this.opened==0) { + var data = { + template: 'LSmail', + action: 'display', + object: this.object, + mails: this.mails, + msg: this.msg + }; + + if ($type(startElement)) { + this.startElement = startElement; + data.imgload=varLSdefault.loadingImgDisplay(startElement,'inside'); + } + new Request({url: 'index_ajax.php', data: data, onSuccess: this.onOpenGetHtmlComplete.bind(this)}).send(); + } + }, + + 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)); + varLSsmoothbox.openHTML(data.html,{startElement: this.startElement, width: 580, height: 150}); + } + }, + + onLSsmoothboxValid: function(LSsmoothbox) { + if($type(LSsmoothbox.frame)) { + this.sendInfos = { + mail: LSsmoothbox.frame.getElementById('LSmail_mail').value, + subject: LSsmoothbox.frame.getElementById('LSmail_subject').value, + msg: LSsmoothbox.frame.getElementById('LSmail_msg').value + }; + } + this.fireEvent.bind(this)('valid'); + }, + + onLSsmoothboxClose: function(LSsmoothbox) { + this.opened=0; + this.fireEvent.bind(this)('close'); + }, + + send: function() { + if ($type(this.sendInfos)) { + var data = { + template: 'LSmail', + action: 'send', + infos: this.sendInfos + }; + LSdebug(data); + data.imgload=varLSdefault.loadingImgDisplay(this.startElement,'inside'); + new Request({url: 'index_ajax.php', data: data, onSuccess: this.onSendComplete.bind(this)}).send(); + } + }, + + onSendComplete: function(responseText, responseXML) { + var data = JSON.decode(responseText); + if ( varLSdefault.checkAjaxReturn(data) ) { + if ($type(data.msgok)) { + varLSdefault.displayInfos(data.msgok); + } + } + }, + + addEvent: function(event,fnct) { + if ($type(this.listeners[event])) { + if ($type(fnct)=="function") { + this.listeners[event].include(fnct); + } + } + }, + + fireEvent: function(event) { + LSdebug('LSmail :: fireEvent('+event+')'); + if ($type(this.listeners[event])) { + this.listeners[event].each(function(fnct) { + try { + fnct(this); + } + catch(e) { + LSdebug('LSmail :: '+event+'() -> rater'); + } + },this); + } + } +}); diff --git a/trunk/includes/js/LSrelation.js b/trunk/includes/js/LSrelation.js index db31fd29..55f1af8a 100644 --- a/trunk/includes/js/LSrelation.js +++ b/trunk/includes/js/LSrelation.js @@ -96,12 +96,13 @@ var LSrelation = new Class({ onLSrelationModifyBtnClickComplete: 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.openURL(data.href,{startElement: $(data.id), width: 615}); } }, - refresh: function() { + onLSsmoothboxValid: function() { var data = { template: 'LSrelation', action: 'refreshList', @@ -110,10 +111,10 @@ var LSrelation = new Class({ LSdebug(data); data.imgload=varLSdefault.loadingImgDisplay('LSrelation_title_'+this.refreshRelation,'inside'); - new Request({url: 'index_ajax.php', data: data, onSuccess: this.onRrefreshComplete.bind(this)}).send(); + new Request({url: 'index_ajax.php', data: data, onSuccess: this.onLSsmoothboxValidComplete.bind(this)}).send(); }, - onRrefreshComplete: function(responseText, responseXML) { + onLSsmoothboxValidComplete: function(responseText, responseXML) { var data = JSON.decode(responseText); if ( varLSdefault.checkAjaxReturn(data) ) { $('LSrelation_ul_'+this.refreshRelation).set('html',data.html); diff --git a/trunk/includes/js/LSsmoothbox.js b/trunk/includes/js/LSsmoothbox.js index 720c3c62..9a8ad326 100644 --- a/trunk/includes/js/LSsmoothbox.js +++ b/trunk/includes/js/LSsmoothbox.js @@ -1,5 +1,32 @@ var LSsmoothbox = new Class({ initialize: function(options) { + + this.build(); + + // Events + $$('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); + + // Fx + this.fx = { + over: new Fx.Tween(this.over, {property: 'opacity', duration: 300}), + winOpen: new Fx.Morph(this.win, {duration: 500, transition: Fx.Transitions.Sine.easeOut, onStart: this.hideContent.bind(this), onComplete: this.displayContent.bind(this)}), + winClose: new Fx.Morph(this.win, {duration: 500, transition: Fx.Transitions.Sine.easeOut, onStart: this.hideContent.bind(this), onComplete: this.resetWin.bind(this)}) + }; + + this.asNew(options); + + window.addEvent('resize', this.position.bind(this)); + window.addEvent('scroll', this.positionWhenScrolling.bind(this)); + }, + + build: function() { this.over = new Element('div'); this.over.setProperty('id','over-LSsmoothbox'); this.over.setStyles({ @@ -23,8 +50,6 @@ var LSsmoothbox = new Class({ this.frame.injectInside(this.win); - this._closeConfirm = true; - this.closeBtn = new Element('span'); this.closeBtn.setProperty('id','closeBtn-LSsmoothbox'); this.closeBtn.injectInside(this.win); @@ -35,26 +60,24 @@ var LSsmoothbox = new Class({ this.validBtn.setProperty('id','validBtn-LSsmoothbox'); this.validBtn.set('html','Valider'); this.validBtn.injectInside(this.win); - this.validBtn.addEvent('click',this.close.bindWithEvent(this,true)); + this.validBtn.addEvent('click',this.valid.bindWithEvent(this,true)); + }, + + asNew: function(options) { + this._options = ($type(options))?option:{}; - $$('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: new Fx.Tween(this.over, {property: 'opacity', duration: 300}), - winOpen: new Fx.Morph(this.win, {duration: 500, transition: Fx.Transitions.Sine.easeOut, onStart: this.hideContent.bind(this), onComplete: this.displayContent.bind(this)}), - winClose: new Fx.Morph(this.win, {duration: 500, transition: Fx.Transitions.Sine.easeOut, onStart: this.hideContent.bind(this), onComplete: this.resetWin.bind(this)}) + // Listeners + this.listeners = { + close: new Array(), + valid: new Array(), + cancel: new Array() }; + + this._closeConfirm = true; + this._closeConfirmOpened = 0; this._open=0; this._scrolling=0; - window.addEvent('resize', this.position.bind(this)); - window.addEvent('scroll', this.positionWhenScrolling.bind(this)); }, position: function(){ @@ -178,27 +201,34 @@ var LSsmoothbox = new Class({ this.closeBtn.setStyle('visibility','visible'); }, - closeConfirm: function(refresh) { + closeConfirm: function() { if (this._closeConfirm && this._displayValidBtn) { - this.confirmBox = new LSconfirmBox({ - text: 'Etês-vous sur de vouloir fermer cette fênetre et perdre toute les modifications apportées ?', - startElement: this.closeBtn, - onConfirm: this.close.bind(this) - }); + if (!this._closeConfirmOpened) { + this._closeConfirmOpened = 1; + this.confirmBox = new LSconfirmBox({ + text: 'Etês-vous sur de vouloir fermer cette fênetre et perdre toute les modifications apportées ?', + startElement: this.closeBtn, + onConfirm: this.cancel.bind(this), + onClose: (function(){this._closeConfirmOpened=0;}).bind(this) + }); + } } else { - this.close(); + this.cancel(); } }, - close: function(refresh) { - if (typeof(refresh)=='undefined') { - refresh=false; - } - else { - refresh=true; - } - + valid: function() { + this.close(); + this.fireEvent('valid'); + }, + + cancel: function() { + this.close(); + this.fireEvent('cancel'); + }, + + close: function() { if (this._closeConfirm) { delete this.confirmBox; } @@ -214,17 +244,13 @@ var LSsmoothbox = new Class({ opacity: [1, 0] }); this._open=0; + [this.validBtn,this.closeBtn,this.frame].each(function(el){ el.setStyle('display','none'); },this); - if (refresh) { - try { - this.refreshElement.refresh(); - } - catch (e){ - console.log('rater'); - } - } + + this.fireEvent('close'); + }, resetWin: function() { @@ -300,10 +326,6 @@ var LSsmoothbox = new Class({ this.img.injectInside(this.frame); }, - setRefreshElement: function(el) { - this.refreshElement = el; - }, - displayValidBtn: function() { this._displayValidBtn = true; }, @@ -324,6 +346,39 @@ var LSsmoothbox = new Class({ new Request.HTML(options).send(); this.openOptions = openOptions; this.open(); + }, + + openHTML: function(html,openOptions) { + this.displayValidBtn(); + this.frame.set('html',html); + this.openOptions = openOptions; + this.open(); + }, + + setOption: function(name,value) { + this._options[name]=value; + }, + + addEvent: function(event,fnct) { + if ($type(this.listeners[event])) { + if ($type(fnct)=="function") { + this.listeners[event].include(fnct); + } + } + }, + + fireEvent: function(event) { + LSdebug('LSsmoothbox :: fireEvent('+event+')'); + if ($type(this.listeners[event])) { + this.listeners[event].each(function(fnct) { + try { + fnct(this); + } + catch(e) { + LSdebug('LSsmoothbox :: '+event+'() -> rater'); + } + },this); + } } }); window.addEvent(window.ie ? 'load' : 'domready', function() { diff --git a/trunk/index_ajax.php b/trunk/index_ajax.php index 1642af1f..197e6fb7 100644 --- a/trunk/index_ajax.php +++ b/trunk/index_ajax.php @@ -338,6 +338,57 @@ if (!isset($_ERRORS)) { break; } break; + 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']); + } + } + else { + $msg = $_REQUEST['msg']; + } + $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); + } + break; + case 'send': + if (isset($_REQUEST['infos'])) { + if ($GLOBALS['LSsession'] -> loadLSaddon('mail')) { + if(sendMail($_REQUEST['infos']['mail'],$_REQUEST['infos']['subject'],$_REQUEST['infos']['msg'])) { + $data = array( + 'msgok' => _("Votre message a bien été envoyé.") + ); + } + } + } + else { + $GLOBALS['LSerror'] -> addErrorCode(1012); + } + } + break; } } diff --git a/trunk/templates/LSmail.tpl b/trunk/templates/LSmail.tpl new file mode 100644 index 00000000..b2daad2f --- /dev/null +++ b/trunk/templates/LSmail.tpl @@ -0,0 +1,20 @@ +
+
{$LSmail_mail_label}
+
+ {if $LSmail_mails != ""} + + {else} + + {/if} +
+
{$LSmail_subject_label}
+
+ +
+
{$LSmail_msg_label}
+
+ +
+
diff --git a/trunk/templates/css/LSmail.css b/trunk/templates/css/LSmail.css new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/trunk/templates/css/LSmail.css @@ -0,0 +1 @@ + diff --git a/trunk/templates/view.tpl b/trunk/templates/view.tpl index cb8e9e65..6ee9ee05 100644 --- a/trunk/templates/view.tpl +++ b/trunk/templates/view.tpl @@ -12,6 +12,8 @@ {/if} + +
{foreach from=$LSform_fields item=field}
{$field.label}