| 258 |
david |
1 |
<?php
|
| 291 |
jpm |
2 |
// declare(encoding='UTF-8');
|
|
|
3 |
/**
|
|
|
4 |
* Service d'envoie de courriel.
|
|
|
5 |
*
|
|
|
6 |
* @category php 5.2
|
|
|
7 |
* @package Annuaire::Services
|
|
|
8 |
* @author Aurélien PERONNET <aurelien@tela-botanica.org>
|
|
|
9 |
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org>
|
|
|
10 |
* @copyright Copyright (c) 2010, Tela Botanica (accueil@tela-botanica.org)
|
|
|
11 |
* @license http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
|
|
|
12 |
* @license http://www.gnu.org/licenses/gpl.html Licence GNU-GPL
|
|
|
13 |
* @version $Id$
|
|
|
14 |
*/
|
|
|
15 |
class EnvoiMessage extends JRestService {
|
| 258 |
david |
16 |
|
|
|
17 |
public function getElement($uid){
|
| 291 |
jpm |
18 |
$identificateur = new IdentificationControleur();
|
|
|
19 |
$login = $identificateur->obtenirLoginUtilisateurParCookie();
|
| 434 |
jpm |
20 |
|
| 291 |
jpm |
21 |
$identification = $login;
|
| 434 |
jpm |
22 |
|
| 291 |
jpm |
23 |
if (!$identification || trim($identification) == '') {
|
|
|
24 |
print 'false';
|
| 434 |
jpm |
25 |
} else {
|
|
|
26 |
$id_annuaire = Config::get('annuaire_defaut');
|
|
|
27 |
$contenu_message = $_GET['contenu_message'];
|
|
|
28 |
$sujet_message = $_GET['sujet_message'];
|
|
|
29 |
$destinataire = $_GET['destinataire'];
|
|
|
30 |
$redirect = $_GET['redirect'];
|
|
|
31 |
|
|
|
32 |
$messagerie = new MessageControleur();
|
|
|
33 |
// Remplacement les identifiants par leurs destinataires
|
|
|
34 |
$destinataire_mail = $messagerie->obtenirMailParTableauId($id_annuaire, array($destinataire));
|
|
|
35 |
if (empty($destinataire_mail)) {
|
|
|
36 |
print 'false';
|
|
|
37 |
} else {
|
|
|
38 |
$destinataire_mail = $destinataire_mail[0];
|
|
|
39 |
|
|
|
40 |
$retour = $messagerie->envoyerMail($identification, $destinataire_mail, $sujet_message, $contenu_message);
|
|
|
41 |
if ($retour) {
|
|
|
42 |
if ($redirect != null && $redirect != '') {
|
|
|
43 |
header('Location: '.'http://'.$redirect);
|
|
|
44 |
exit;
|
|
|
45 |
} else {
|
|
|
46 |
print 'OK';
|
|
|
47 |
}
|
|
|
48 |
} else {
|
|
|
49 |
print 'false';
|
|
|
50 |
}
|
|
|
51 |
}
|
| 291 |
jpm |
52 |
}
|
| 258 |
david |
53 |
}
|
|
|
54 |
}
|
| 291 |
jpm |
55 |
?>
|