Subversion Repositories Applications.projet

Rev

Rev 363 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
431 mathias 1
<?php
2
/**
3
* PHP Version 5
4
*
5
* @category  PHP
6
* @package   projet_bp
7
* @author    aurelien <aurelien@tela-botanica.org>
8
* @copyright 2010 Tela-Botanica
9
* @license   http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
10
* @version   SVN: <svn_id>
11
* @link      /doc/projet_bp/
12
*/
13
 
14
 
15
class Modification extends ProjetService {
16
 
17
	public function getElement($uid){
18
 
19
		$id_utilisateur = (isset($_GET['id_utilisateur'])) ? $_GET['id_utilisateur'] : false;
20
		$mail = (isset($_GET['mail'])) ? $_GET['mail'] : false;
21
		$nouveau_mail = (isset($_GET['nouveau_mail'])) ? $_GET['nouveau_mail'] : false;
22
 
23
		if(!$mail || !$id_utilisateur) {
24
			$this->envoyer("false");
25
		}
26
 
27
		$ancien_mail = $mail;
28
		$nouveau_mail = $nouveau_mail;
29
 
30
		// si le mail n'a pas changé, on ne change rien
31
		if($ancien_mail == $nouveau_mail) {
32
			$this->envoyer("OK");
33
			return;
34
		}
35
 
36
		$projets = $this->obtenirProjetsPourParticipant($id_utilisateur);
37
 
38
		// si pas de projets, rien à faire
39
		if(count($projets) <= 0) {
40
			$this->envoyer("OK");
41
			return;
42
		}
43
 
44
		// sinon on récupère la liste associée à chaque projet
45
		foreach($projets as $projet) {
46
 
47
			$id_projet = $projet['p_id'];
48
			$listes = $this->obtenirListesAssocieesAuProjet($id_projet);
49
 
50
			// si pas de liste, rien à faire
51
			if(count($listes) <= 0) {
52
				continue;
53
			}
54
 
55
			$nom_liste = $listes[0]['pl_nom_liste'];
56
 
57
			// on modifie l'abonnement
58
			if($this->estAbonneAListe($nom_liste, $mail)) {
59
				if(!$this->modifierMailPourListe($nom_liste, $ancien_mail, $nouveau_mail)) {
60
					$this->envoyer("false");
61
				}
62
			}
63
		}
64
 
65
		$this->envoyer("OK");
66
		return;
67
	}
68
}
69
?>