Subversion Repositories Applications.annuaire

Rev

Rev 291 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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