mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-11-22 18:09:06 +01:00
- LSview : ajout de input hidden pour contenir les informations du type et du
DN de l'objet affiché. - LSmail : Ajout d'une fonctionalité d'envoie de mail depuis l'interface. -> Modification de LSformElement_mail pour utiliser cette fonctionalité -> Agrémentation du fichier index_ajax.php -> Ajout d'un LSaddons :: mail - LSsession : -> Ajout d'une méthode getEmailSender() -> Utilisation de la méthode getEmailSender() pour la partie de récupération de mot de passe -> Revue des méthodes loadLSaddon() et loadLSaddons() - LSconfirmBox : -> Ajout de binding onClose() et onCancel() - LSsmoothbox : -> Déport de la creation de la structure dans la méthode build() -> Suppression du principe de refreshElement au profit de binding sur les évenements onClose, onValid et onCancel -> Ajout des méthodes addEvent() et fireEvent() -> Suppression de la méthode setRefreshElement() -> Ajout de la méthode asNew() pour remettre l'objet dans son état d'origine pour l'utilisation simultané de l'objet par plusieurs autres -> Vérification lors du clique sur le closeBtn qu'une précédente confirmBox n'est pas déjà ouvert -> La méthode close() ne fait plus que fermer la LSsmoothbox et les méthodes valid() et cancel() gère les cas de fermeture et lance la méthode close() -> Ajout de la méthode openHTML() pour l'ouverture de la LSsmoothbox avec un code HTML passé en paramètre -> Ajout de la méthode setOption() - LSrelation & LSformElement_select_object : -> Utilisation du principe d'évenement de la LSsmoothbox plutôt que du refreshElement -> Utilisation de la méthode asNew() pour eviter tout problème de concurence - LSdefault : Ajout de la méthode displayInfos()
This commit is contained in:
parent
0c28c1f921
commit
d75a8823c2
14 changed files with 533 additions and 67 deletions
159
trunk/includes/addons/LSaddons.mail.php
Normal file
159
trunk/includes/addons/LSaddons.mail.php
Normal file
|
@ -0,0 +1,159 @@
|
||||||
|
<?php
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (C) 2007 Easter-eggs
|
||||||
|
* http://ldapsaisie.labs.libre-entreprise.org
|
||||||
|
*
|
||||||
|
* Author: See AUTHORS file in top-level directory.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License version 2
|
||||||
|
* as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Données de configuration pour le support FTP
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Pear :: Mail
|
||||||
|
define('PEAR_MAIL','/usr/share/php/Mail.php');
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Méthode d'envoie :
|
||||||
|
* - mail : envoie avec la méthode PHP mail()
|
||||||
|
* - sendmail : envoie la commande sendmail du système
|
||||||
|
* - smtp : envoie en utilisant un serveur SMTP
|
||||||
|
*/
|
||||||
|
define('MAIL_SEND_METHOD','smtp');
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Paramètres d'envoie :
|
||||||
|
* Ces paramètres dépende de la méthode utilisé. Repporté vous à la documentation
|
||||||
|
* de PEAR :: Mail pour plus d'information.
|
||||||
|
* Lien : http://pear.php.net/manual/en/package.mail.mail.factory.php
|
||||||
|
* Infos :
|
||||||
|
* List of parameter for the backends
|
||||||
|
* mail
|
||||||
|
* o If safe mode is disabled, $params will be passed as the fifth
|
||||||
|
* argument to the PHP mail() function. If $params is an array,
|
||||||
|
* its elements will be joined as a space-delimited string.
|
||||||
|
* sendmail
|
||||||
|
* o $params["sendmail_path"] - The location of the sendmail program
|
||||||
|
* on the filesystem. Default is /usr/bin/sendmail.
|
||||||
|
* o $params["sendmail_args"] - Additional parameters to pass to the
|
||||||
|
* sendmail. Default is -i.
|
||||||
|
* smtp
|
||||||
|
* o $params["host"] - The server to connect. Default is localhost.
|
||||||
|
* o $params["port"] - The port to connect. Default is 25.
|
||||||
|
* o $params["auth"] - Whether or not to use SMTP authentication.
|
||||||
|
* Default is FALSE.
|
||||||
|
* o $params["username"] - The username to use for SMTP authentication.
|
||||||
|
* o $params["password"] - The password to use for SMTP authentication.
|
||||||
|
* o $params["localhost"] - The value to give when sending EHLO or HELO.
|
||||||
|
* Default is localhost
|
||||||
|
* o $params["timeout"] - The SMTP connection timeout.
|
||||||
|
* Default is NULL (no timeout).
|
||||||
|
* o $params["verp"] - Whether to use VERP or not. Default is FALSE.
|
||||||
|
* o $params["debug"] - Whether to enable SMTP debug mode or not.
|
||||||
|
* Default is FALSE.
|
||||||
|
* o $params["persist"] - Indicates whether or not the SMTP connection
|
||||||
|
* should persist over multiple calls to the send() method.
|
||||||
|
*/
|
||||||
|
$MAIL_SEND_PARAMS = NULL;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Headers :
|
||||||
|
*/
|
||||||
|
$MAIL_HEARDERS = array(
|
||||||
|
"Content-Type" => "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 <brenard@easter-eggs.com>
|
||||||
|
*
|
||||||
|
* @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 <brenard@easter-eggs.com>
|
||||||
|
*
|
||||||
|
* @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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,6 @@ class LSformElement_mail extends LSformElement {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$return['html'] .= "</ul>\n";
|
$return['html'] .= "</ul>\n";
|
||||||
$GLOBALS['LSsession'] -> addJSscript('LSformElement_mail.js');
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$return['html'] = "<ul class='LSform'>\n";
|
$return['html'] = "<ul class='LSform'>\n";
|
||||||
|
@ -65,11 +64,16 @@ class LSformElement_mail extends LSformElement {
|
||||||
else {
|
else {
|
||||||
foreach ($this -> values as $value) {
|
foreach ($this -> values as $value) {
|
||||||
$return['html'] .= "<li><a href='mailto:".$value."'>".$value."</a><img src='templates/images/mail.png' alt='"._('Envoyer un mail.')."' title='"._('Envoyer un mail.')."' class='LSformElement_mail_btn btn'></li>\n";
|
$return['html'] .= "<li><a href='mailto:".$value."'>".$value."</a><img src='templates/images/mail.png' alt='"._('Envoyer un mail.')."' title='"._('Envoyer un mail.')."' class='LSformElement_mail_btn btn'></li>\n";
|
||||||
$GLOBALS['LSsession'] -> addJSscript('LSformElement_mail.js');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$return['html'] .= "</ul>\n";
|
$return['html'] .= "</ul>\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;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -155,7 +155,14 @@ class LSsession {
|
||||||
* @retval boolean true si le chargement a réussi, false sinon.
|
* @retval boolean true si le chargement a réussi, false sinon.
|
||||||
*/
|
*/
|
||||||
function loadLSaddon($addon) {
|
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) {
|
foreach ($GLOBALS['LSaddons']['loads'] as $addon) {
|
||||||
$this -> loadLSaddon($addon);
|
$this -> loadLSaddon($addon);
|
||||||
if (!call_user_func('LSaddon_'. $addon .'_support')) {
|
|
||||||
$GLOBALS['LSerror'] -> addErrorCode(1002,$addon);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -328,8 +332,8 @@ class LSsession {
|
||||||
if ($this -> ldapServer['recoverPassword']['recoveryEmailSender']) {
|
if ($this -> ldapServer['recoverPassword']['recoveryEmailSender']) {
|
||||||
$headers.="\nFrom: ".$this -> ldapServer['recoverPassword']['recoveryEmailSender'];
|
$headers.="\nFrom: ".$this -> ldapServer['recoverPassword']['recoveryEmailSender'];
|
||||||
}
|
}
|
||||||
else if($this -> ldapServer['emailSender']) {
|
else if($this -> getEmailSender()) {
|
||||||
$headers.="\nFrom: ".$this -> ldapServer['emailSender'];
|
$headers.="\nFrom: ".$this -> getEmailSender();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (checkEmail($emailAddress)) {
|
if (checkEmail($emailAddress)) {
|
||||||
|
@ -1482,6 +1486,15 @@ class LSsession {
|
||||||
exit();
|
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'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -97,6 +97,9 @@ var LSconfirmBox = new Class({
|
||||||
onClose: function() {
|
onClose: function() {
|
||||||
this.box.setStyle('display','none');
|
this.box.setStyle('display','none');
|
||||||
this.purge();
|
this.purge();
|
||||||
|
if (this._options.onClose) {
|
||||||
|
$try(this._options.onClose);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
purge: function() {
|
purge: function() {
|
||||||
|
@ -162,5 +165,8 @@ var LSconfirmBox = new Class({
|
||||||
|
|
||||||
cancel: function() {
|
cancel: function() {
|
||||||
this.hide();
|
this.hide();
|
||||||
|
if (this._options.onCancel) {
|
||||||
|
$try(this._options.onCancel);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -92,7 +92,12 @@ var LSdefault = new Class({
|
||||||
this.LSdebugInfos.set('html',html);
|
this.LSdebugInfos.set('html',html);
|
||||||
this.displayDebugBox();
|
this.displayDebugBox();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
displayInfos: function(html) {
|
||||||
|
this.LSinfos.set('html',html);
|
||||||
|
this.displayInfosBox();
|
||||||
|
},
|
||||||
|
|
||||||
displayErrorBox: function() {
|
displayErrorBox: function() {
|
||||||
this.LSerror.setStyle('top',getScrollTop()+10);
|
this.LSerror.setStyle('top',getScrollTop()+10);
|
||||||
this.fx.LSerror.start(0,0.8);
|
this.fx.LSerror.start(0,0.8);
|
||||||
|
|
|
@ -4,6 +4,7 @@ var LSformElement_mail = new Class({
|
||||||
if (typeof(varLSform) != "undefined") {
|
if (typeof(varLSform) != "undefined") {
|
||||||
varLSform.addModule("LSformElement_mail",this);
|
varLSform.addModule("LSformElement_mail",this);
|
||||||
}
|
}
|
||||||
|
this.LSmail_open = 0;
|
||||||
},
|
},
|
||||||
|
|
||||||
initialiseLSformElement_mail: function(el) {
|
initialiseLSformElement_mail: function(el) {
|
||||||
|
@ -20,13 +21,33 @@ var LSformElement_mail = new Class({
|
||||||
},
|
},
|
||||||
|
|
||||||
onBtnClick: function(btn) {
|
onBtnClick: function(btn) {
|
||||||
var href = btn.getParent().getFirst().href;
|
if (this.LSmail_open==0) {
|
||||||
if (typeof(href)=="undefined") {
|
var mail = btn.getParent().getFirst().innerHTML;
|
||||||
href = 'mailto:'+btn.getParent().getFirst().value;
|
if ((typeof(mail)!='string')||(mail=='')) {
|
||||||
}
|
mail = btn.getParent().getFirst().value;
|
||||||
if ((href!="")&&(href!="mailto:")) {
|
}
|
||||||
location.href = href;
|
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() {
|
window.addEvent(window.ie ? 'load' : 'domready', function() {
|
||||||
|
|
|
@ -41,13 +41,14 @@ var LSformElement_select_object = new Class({
|
||||||
onLSformElement_select_object_addBtnClickComplete: function(responseText, responseXML) {
|
onLSformElement_select_object_addBtnClickComplete: function(responseText, responseXML) {
|
||||||
var data = JSON.decode(responseText);
|
var data = JSON.decode(responseText);
|
||||||
if ( varLSdefault.checkAjaxReturn(data) ) {
|
if ( varLSdefault.checkAjaxReturn(data) ) {
|
||||||
varLSsmoothbox.setRefreshElement(this);
|
varLSsmoothbox.asNew();
|
||||||
|
varLSsmoothbox.addEvent('valid',this.onLSsmoothboxValid.bind(this));
|
||||||
varLSsmoothbox.displayValidBtn();
|
varLSsmoothbox.displayValidBtn();
|
||||||
varLSsmoothbox.openURL(data.href,{width: 615});
|
varLSsmoothbox.openURL(data.href,{width: 615});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
refresh: function() {
|
onLSsmoothboxValid: function() {
|
||||||
var getAttrName = /LSformElement_select_object_(.*)_[0-9]*/
|
var getAttrName = /LSformElement_select_object_(.*)_[0-9]*/
|
||||||
var attrName = getAttrName.exec(this.refreshFields)[1];
|
var attrName = getAttrName.exec(this.refreshFields)[1];
|
||||||
var data = {
|
var data = {
|
||||||
|
@ -60,10 +61,10 @@ var LSformElement_select_object = new Class({
|
||||||
ul: this.refreshFields
|
ul: this.refreshFields
|
||||||
};
|
};
|
||||||
data.imgload=varLSdefault.loadingImgDisplay($('a_' + 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);
|
var data = JSON.decode(responseText);
|
||||||
if ( varLSdefault.checkAjaxReturn(data) ) {
|
if ( varLSdefault.checkAjaxReturn(data) ) {
|
||||||
$(this.refreshFields).getParent().set('html',data.html);
|
$(this.refreshFields).getParent().set('html',data.html);
|
||||||
|
|
127
trunk/includes/js/LSmail.js
Normal file
127
trunk/includes/js/LSmail.js
Normal file
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
|
@ -96,12 +96,13 @@ var LSrelation = new Class({
|
||||||
onLSrelationModifyBtnClickComplete: function(responseText, responseXML) {
|
onLSrelationModifyBtnClickComplete: function(responseText, responseXML) {
|
||||||
var data = JSON.decode(responseText);
|
var data = JSON.decode(responseText);
|
||||||
if ( varLSdefault.checkAjaxReturn(data) ) {
|
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});
|
varLSsmoothbox.openURL(data.href,{startElement: $(data.id), width: 615});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
refresh: function() {
|
onLSsmoothboxValid: function() {
|
||||||
var data = {
|
var data = {
|
||||||
template: 'LSrelation',
|
template: 'LSrelation',
|
||||||
action: 'refreshList',
|
action: 'refreshList',
|
||||||
|
@ -110,10 +111,10 @@ var LSrelation = new Class({
|
||||||
|
|
||||||
LSdebug(data);
|
LSdebug(data);
|
||||||
data.imgload=varLSdefault.loadingImgDisplay('LSrelation_title_'+this.refreshRelation,'inside');
|
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);
|
var data = JSON.decode(responseText);
|
||||||
if ( varLSdefault.checkAjaxReturn(data) ) {
|
if ( varLSdefault.checkAjaxReturn(data) ) {
|
||||||
$('LSrelation_ul_'+this.refreshRelation).set('html',data.html);
|
$('LSrelation_ul_'+this.refreshRelation).set('html',data.html);
|
||||||
|
|
|
@ -1,5 +1,32 @@
|
||||||
var LSsmoothbox = new Class({
|
var LSsmoothbox = new Class({
|
||||||
initialize: function(options) {
|
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 = new Element('div');
|
||||||
this.over.setProperty('id','over-LSsmoothbox');
|
this.over.setProperty('id','over-LSsmoothbox');
|
||||||
this.over.setStyles({
|
this.over.setStyles({
|
||||||
|
@ -23,8 +50,6 @@ var LSsmoothbox = new Class({
|
||||||
|
|
||||||
this.frame.injectInside(this.win);
|
this.frame.injectInside(this.win);
|
||||||
|
|
||||||
this._closeConfirm = true;
|
|
||||||
|
|
||||||
this.closeBtn = new Element('span');
|
this.closeBtn = new Element('span');
|
||||||
this.closeBtn.setProperty('id','closeBtn-LSsmoothbox');
|
this.closeBtn.setProperty('id','closeBtn-LSsmoothbox');
|
||||||
this.closeBtn.injectInside(this.win);
|
this.closeBtn.injectInside(this.win);
|
||||||
|
@ -35,26 +60,24 @@ var LSsmoothbox = new Class({
|
||||||
this.validBtn.setProperty('id','validBtn-LSsmoothbox');
|
this.validBtn.setProperty('id','validBtn-LSsmoothbox');
|
||||||
this.validBtn.set('html','Valider');
|
this.validBtn.set('html','Valider');
|
||||||
this.validBtn.injectInside(this.win);
|
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) {
|
// Listeners
|
||||||
el.addEvent('click',this.clickA.bindWithEvent(this,el));
|
this.listeners = {
|
||||||
},this);
|
close: new Array(),
|
||||||
|
valid: new Array(),
|
||||||
$$('img.LSsmoothbox').each(function(el) {
|
cancel: new Array()
|
||||||
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)})
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this._closeConfirm = true;
|
||||||
|
this._closeConfirmOpened = 0;
|
||||||
|
|
||||||
this._open=0;
|
this._open=0;
|
||||||
this._scrolling=0;
|
this._scrolling=0;
|
||||||
window.addEvent('resize', this.position.bind(this));
|
|
||||||
window.addEvent('scroll', this.positionWhenScrolling.bind(this));
|
|
||||||
},
|
},
|
||||||
|
|
||||||
position: function(){
|
position: function(){
|
||||||
|
@ -178,27 +201,34 @@ var LSsmoothbox = new Class({
|
||||||
this.closeBtn.setStyle('visibility','visible');
|
this.closeBtn.setStyle('visibility','visible');
|
||||||
},
|
},
|
||||||
|
|
||||||
closeConfirm: function(refresh) {
|
closeConfirm: function() {
|
||||||
if (this._closeConfirm && this._displayValidBtn) {
|
if (this._closeConfirm && this._displayValidBtn) {
|
||||||
this.confirmBox = new LSconfirmBox({
|
if (!this._closeConfirmOpened) {
|
||||||
text: 'Etês-vous sur de vouloir fermer cette fênetre et perdre toute les modifications apportées ?',
|
this._closeConfirmOpened = 1;
|
||||||
startElement: this.closeBtn,
|
this.confirmBox = new LSconfirmBox({
|
||||||
onConfirm: this.close.bind(this)
|
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 {
|
else {
|
||||||
this.close();
|
this.cancel();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
close: function(refresh) {
|
valid: function() {
|
||||||
if (typeof(refresh)=='undefined') {
|
this.close();
|
||||||
refresh=false;
|
this.fireEvent('valid');
|
||||||
}
|
},
|
||||||
else {
|
|
||||||
refresh=true;
|
cancel: function() {
|
||||||
}
|
this.close();
|
||||||
|
this.fireEvent('cancel');
|
||||||
|
},
|
||||||
|
|
||||||
|
close: function() {
|
||||||
if (this._closeConfirm) {
|
if (this._closeConfirm) {
|
||||||
delete this.confirmBox;
|
delete this.confirmBox;
|
||||||
}
|
}
|
||||||
|
@ -214,17 +244,13 @@ var LSsmoothbox = new Class({
|
||||||
opacity: [1, 0]
|
opacity: [1, 0]
|
||||||
});
|
});
|
||||||
this._open=0;
|
this._open=0;
|
||||||
|
|
||||||
[this.validBtn,this.closeBtn,this.frame].each(function(el){
|
[this.validBtn,this.closeBtn,this.frame].each(function(el){
|
||||||
el.setStyle('display','none');
|
el.setStyle('display','none');
|
||||||
},this);
|
},this);
|
||||||
if (refresh) {
|
|
||||||
try {
|
this.fireEvent('close');
|
||||||
this.refreshElement.refresh();
|
|
||||||
}
|
|
||||||
catch (e){
|
|
||||||
console.log('rater');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
resetWin: function() {
|
resetWin: function() {
|
||||||
|
@ -300,10 +326,6 @@ var LSsmoothbox = new Class({
|
||||||
this.img.injectInside(this.frame);
|
this.img.injectInside(this.frame);
|
||||||
},
|
},
|
||||||
|
|
||||||
setRefreshElement: function(el) {
|
|
||||||
this.refreshElement = el;
|
|
||||||
},
|
|
||||||
|
|
||||||
displayValidBtn: function() {
|
displayValidBtn: function() {
|
||||||
this._displayValidBtn = true;
|
this._displayValidBtn = true;
|
||||||
},
|
},
|
||||||
|
@ -324,6 +346,39 @@ var LSsmoothbox = new Class({
|
||||||
new Request.HTML(options).send();
|
new Request.HTML(options).send();
|
||||||
this.openOptions = openOptions;
|
this.openOptions = openOptions;
|
||||||
this.open();
|
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() {
|
window.addEvent(window.ie ? 'load' : 'domready', function() {
|
||||||
|
|
|
@ -338,6 +338,57 @@ if (!isset($_ERRORS)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
20
trunk/templates/LSmail.tpl
Normal file
20
trunk/templates/LSmail.tpl
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
<dl class='LSform'>
|
||||||
|
<dt class='LSform'>{$LSmail_mail_label}</dt>
|
||||||
|
<dd class='LSform'>
|
||||||
|
{if $LSmail_mails != ""}
|
||||||
|
<select name='LSmail_mail' id='LSmail_mail'>
|
||||||
|
{html_options values=$LSmail_mails output=$LSmail_mails}
|
||||||
|
</select>
|
||||||
|
{else}
|
||||||
|
<input type='text' name='LSmail_mail' id='LSmail_mail'/>
|
||||||
|
{/if}
|
||||||
|
</dd>
|
||||||
|
<dt class='LSform'>{$LSmail_subject_label}</dt>
|
||||||
|
<dd class='LSform'>
|
||||||
|
<input type='text' name='LSmail_subject' id='LSmail_subject'/>
|
||||||
|
</dd>
|
||||||
|
<dt class='LSform'>{$LSmail_msg_label}</dt>
|
||||||
|
<dd class='LSform'>
|
||||||
|
<textarea name='LSmail_msg' id='LSmail_msg'>{$LSmail_msg}</textarea>
|
||||||
|
</dd>
|
||||||
|
</dl>
|
1
trunk/templates/css/LSmail.css
Normal file
1
trunk/templates/css/LSmail.css
Normal file
|
@ -0,0 +1 @@
|
||||||
|
|
|
@ -12,6 +12,8 @@
|
||||||
<a href='{$LSformElement_image.img}.png' rel='rien ici' title='comment' class='mb'><img src='{$LSformElement_image.img}' class='LSformElement_image LSsmoothbox' id='LSformElement_image_{$LSformElement_image.id}' /></a>
|
<a href='{$LSformElement_image.img}.png' rel='rien ici' title='comment' class='mb'><img src='{$LSformElement_image.img}' class='LSformElement_image LSsmoothbox' id='LSformElement_image_{$LSformElement_image.id}' /></a>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
<input type='hidden' name='LSform_objecttype' id='LSform_objecttype' value='{$LSform_object.type}'/>
|
||||||
|
<input type='hidden' name='LSform_objectdn' id='LSform_objectdn' value='{$LSform_object.dn}'/>
|
||||||
<dl class='LSform'>
|
<dl class='LSform'>
|
||||||
{foreach from=$LSform_fields item=field}
|
{foreach from=$LSform_fields item=field}
|
||||||
<dt class='LSform'>{$field.label}</dt>
|
<dt class='LSform'>{$field.label}</dt>
|
||||||
|
|
Loading…
Reference in a new issue