Subversion Repositories Applications.projet

Rev

Rev 363 | Rev 374 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 363 Rev 370
1
<?php
1
<?php
2
/**
2
/**
3
* PHP Version 5
3
* PHP Version 5
4
*
4
*
5
* @category  PHP
5
* @category  PHP
6
* @package   projet_bp
6
* @package   projet_bp
7
* @author    aurelien <aurelien@tela-botanica.org>
7
* @author    aurelien <aurelien@tela-botanica.org>
8
* @copyright 2010 Tela-Botanica
8
* @copyright 2010 Tela-Botanica
9
* @license   http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
9
* @license   http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
10
* @version   SVN: <svn_id>
10
* @version   SVN: <svn_id>
11
* @link      /doc/projet_bp/
11
* @link      /doc/projet_bp/
12
*/
12
*/
13
 
13
 
-
 
14
class ProjetService extends JRestService {
-
 
15
	
-
 
16
	public function __construct($config, $demarrer_session= true) {
-
 
17
		parent::__construct($config, $demarrer_session);
14
abstract class ProjetService extends JRestService {
18
	}
15
 
19
 
16
	protected function obtenirProjetsPourParticipant($id_utilisateur) {
20
	protected function obtenirProjetsPourParticipant($id_utilisateur) {
17
 
21
 
18
		// on selectionne la liste des projets auxquel on est inscrit
22
		// on selectionne la liste des projets auxquel on est inscrit
19
		$requete_projets = 	'SELECT DISTINCT *'.
23
		$requete_projets = 	'SELECT DISTINCT *'.
20
						   	' FROM projet'.
24
						   	' FROM projet'.
21
						   	' WHERE p_id'.
25
						   	' WHERE p_id'.
22
							' IN '.
26
							' IN '.
23
							'(SELECT psu_id_projet FROM projet_statut_utilisateurs'.
27
							'(SELECT psu_id_projet FROM projet_statut_utilisateurs'.
24
							' WHERE psu_id_utilisateur = '.$id_utilisateur.')'.
28
							' WHERE psu_id_utilisateur = '.$id_utilisateur.')'.
25
							' GROUP BY p_id';
29
							' GROUP BY p_id';
26
 
30
 
27
		try {
31
		try {
28
			$projets = $this->bdd->query($requete_projets)->fetchAll(PDO::FETCH_ASSOC);
32
			$projets = $this->bdd->query($requete_projets)->fetchAll(PDO::FETCH_ASSOC);
29
		} catch (PDOException $e) {
33
		} catch (PDOException $e) {
30
			Log::getInstance()->ajouterEntree('projet','Fichier: '.$e->getFile().' Ligne: '.$e->getLine().' '.$e->getMessage());
34
			Log::getInstance()->ajouterEntree('projet','Fichier: '.$e->getFile().' Ligne: '.$e->getLine().' '.$e->getMessage());
31
			return array();
35
			return array();
32
		}
36
		}
33
 
37
 
34
		// pas de projets ? alors c'est fait !
38
		// pas de projets ? alors c'est fait !
35
		if(!$projets || count($projets) <= 0) {
39
		if(!$projets || count($projets) <= 0) {
36
			return array();
40
			return array();
37
		}
41
		}
38
 
42
 
39
		return $projets;
43
		return $projets;
40
	}
44
	}
-
 
45
	
-
 
46
	protected function obtenirInformationsProjet($id_projet) {
-
 
47
		
-
 
48
		$requete_informations_projet = 'SELECT DISTINCT *'.
-
 
49
						   	' FROM projet'.
-
 
50
						   	' WHERE p_id = '.$id_projet ;
-
 
51
		
-
 
52
		try {
-
 
53
			$projet = $this->bdd->query($requete_informations_projet)->fetchAll(PDO::FETCH_ASSOC);
-
 
54
		} catch (PDOException $e) {
-
 
55
			Log::getInstance()->ajouterEntree('projet','Fichier: '.$e->getFile().' Ligne: '.$e->getLine().' '.$e->getMessage());
-
 
56
			return false;
-
 
57
		}
-
 
58
 
-
 
59
		// pas de projets ? alors c'est fait !
-
 
60
		if(!$projet) {
-
 
61
			return false;
-
 
62
		}
-
 
63
 
-
 
64
		return $projet;
-
 
65
	}
41
 
66
 
42
	protected function obtenirListesAssocieesAuProjet($id_projet) {
67
	protected function obtenirListesAssocieesAuProjet($id_projet) {
43
 
68
 
44
		$requete_liste_projets = 'SELECT * FROM projet_liste '.
69
		$requete_liste_projets = 'SELECT * FROM projet_liste '.
45
								 'WHERE pl_id_liste IN '.
70
								 'WHERE pl_id_liste IN '.
46
								 '(SELECT pl_id_liste from projet_lien_liste '.
71
								 '(SELECT pl_id_liste from projet_lien_liste '.
47
								 		'WHERE pl_id_projet='.$id_projet.')' ;
72
								 		'WHERE pl_id_projet='.$id_projet.')' ;
48
 
73
 
49
		try {
74
		try {
50
			$listes_projets = $this->bdd->query($requete_liste_projets)->fetchAll(PDO::FETCH_ASSOC);
75
			$listes_projets = $this->bdd->query($requete_liste_projets)->fetchAll(PDO::FETCH_ASSOC);
51
		} catch (PDOException $e) {
76
		} catch (PDOException $e) {
52
			Log::getInstance()->ajouterEntree('projet','Fichier: '.$e->getFile().' Ligne: '.$e->getLine().' '.$e->getMessage());
77
			Log::getInstance()->ajouterEntree('projet','Fichier: '.$e->getFile().' Ligne: '.$e->getLine().' '.$e->getMessage());
53
			return array();
78
			return array();
54
		}
79
		}
55
 
80
 
56
 
81
 
57
		if(!$listes_projets || count($listes_projets) <= 0) {
82
		if(!$listes_projets || count($listes_projets) <= 0) {
58
			return array();
83
			return array();
59
		}
84
		}
60
 
85
 
61
		return $listes_projets;
86
		return $listes_projets;
62
	}
87
	}
-
 
88
	
-
 
89
	protected function supprimerInscriptionAListeProjet($id_utilisateur, $id_liste) {
-
 
90
	
-
 
91
		$requete_suppression_liste = 'DELETE FROM projet_inscription_liste '.
-
 
92
											   'WHERE pil_id_utilisateur='.$id_utilisateur.' and pil_id_liste='.$id_liste ;
-
 
93
 
-
 
94
		try {
-
 
95
			$requete_suppression_liste = $this->bdd->query($requete_suppression_liste);
-
 
96
		} catch (PDOException $e) {
-
 
97
			Log::getInstance()->ajouterEntree('projet','Fichier: '.$e->getFile().' Ligne: '.$e->getLine().' '.$e->getMessage().' '.$requete_suppression_liste);
-
 
98
			return false;
-
 
99
		}
-
 
100
	
-
 
101
	}
63
 
102
 
64
	protected function supprimerParticipantAProjet($id_utilisateur, $id_projet) {
103
	protected function supprimerParticipantAProjet($id_utilisateur, $id_projet) {
65
		$requete_suppression_projets = 'DELETE FROM projet_statut_utilisateurs '.
104
		$requete_suppression_projets = 'DELETE FROM projet_statut_utilisateurs '.
66
											   'WHERE psu_id_utilisateur='.$id_utilisateur.' and psu_id_projet='.$id_projet ;
105
											   'WHERE psu_id_utilisateur='.$id_utilisateur.' and psu_id_projet='.$id_projet ;
67
 
106
 
68
		try {
107
		try {
69
			$requete_suppression_projets = $this->bdd->query($requete_suppression_projets);
108
			$requete_suppression_projets = $this->bdd->query($requete_suppression_projets);
70
		} catch (PDOException $e) {
109
		} catch (PDOException $e) {
71
			Log::getInstance()->ajouterEntree('projet','Fichier: '.$e->getFile().' Ligne: '.$e->getLine().' '.$e->getMessage().' '.$requete_suppression_projets);
110
			Log::getInstance()->ajouterEntree('projet','Fichier: '.$e->getFile().' Ligne: '.$e->getLine().' '.$e->getMessage().' '.$requete_suppression_projets);
72
			return false;
111
			return false;
73
		}
112
		}
74
 
113
		
75
		return true;
114
		return true;
76
	}
115
	}
77
 
116
 
78
	protected function estAbonneAListe($nom_liste, $mail) {
117
	protected function estAbonneAListe($nom_liste, $mail) {
79
 
118
 
80
		try {
119
		try {
81
			$est_abonne = '0' ;
120
			$est_abonne = '0' ;
82
			//$xml_abonne = new SimpleXMLElement(file_get_contents('http://vpopmail.tela-botanica.org/est_abonne.php?domaine=tela-botanica.org&liste='.$nom_liste.'&mail='.$mail)) ;
121
			$xml_abonne = new SimpleXMLElement(file_get_contents('http://vpopmail.tela-botanica.org/est_abonne.php?domaine=tela-botanica.org&liste='.$nom_liste.'&mail='.$mail)) ;
83
			$est_abonne = 1;//$xml_abonne[0] ;
122
			$est_abonne = $xml_abonne[0] ;
84
 
-
 
85
			Log::getInstance()->ajouterEntree('projet','appel de http://vpopmail.tela-botanica.org/est_abonne.php?domaine=tela-botanica.org&liste='.$nom_liste.'&mail='.$mail);
-
 
86
 
123
 
87
			if($est_abonne == '1') {
124
			if($est_abonne == '1') {
88
				return true;
125
				return true;
89
			} else {
126
			} else {
90
				return false;
127
				return false;
91
			}
128
			}
92
		}
129
		}
93
		catch(Exception $e) {
130
		catch(Exception $e) {
94
			trigger_error($e->getMessage()) ;
131
			trigger_error($e->getMessage()) ;
95
			return false;
132
			return false;
96
		}
133
		}
97
 
134
 
98
	}
135
	}
99
 
136
 
100
	protected function modifierMailPourListe($nom_liste, $ancien_mail, $nouveau_mail) {
137
	protected function modifierMailPourListe($nom_liste, $ancien_mail, $nouveau_mail) {
101
		return ($this->desinscriptionListe($nom_liste, $ancien_mail) && $this->inscriptionListe($nom_liste, $nouveau_mail));
138
		return ($this->desinscriptionListe($nom_liste, $ancien_mail) && $this->inscriptionListe($nom_liste, $nouveau_mail));
102
	}
139
	}
103
 
140
 
104
	protected function inscriptionListe($nom_liste, $mail) {
141
	protected function inscriptionListe($nom_liste, $mail) {
105
 
-
 
106
		Log::getInstance()->ajouterEntree('projet','appel de http://vpopmail.tela-botanica.org/ajout_abonne.php?domaine=tela-botanica.org&liste='.$nom_liste.'&mail='.$mail);
-
 
107
		return true;
-
 
108
		//return $inscription_abonne = file_get_contents('http://vpopmail.tela-botanica.org/ajout_abonne.php?domaine=tela-botanica.org&liste='.$nom_liste.'&mail='.$mail) ;
142
		return $inscription_abonne = file_get_contents('http://vpopmail.tela-botanica.org/ajout_abonne.php?domaine=tela-botanica.org&liste='.$nom_liste.'&mail='.$mail) ;
109
	}
143
	}
110
 
144
 
111
	protected function desinscriptionListe($nom_liste, $mail) {
145
	protected function desinscriptionListe($nom_liste, $mail) {
112
		Log::getInstance()->ajouterEntree('projet','appel de http://vpopmail.tela-botanica.org/suppression_abonne.php?domaine=tela-botanica.org&liste='.$nom_liste.'&mail='.$mail);
-
 
113
		return true;
-
 
114
		//return $suppression_abonne = file_get_contents('http://vpopmail.tela-botanica.org/suppression_abonne.php?domaine=tela-botanica.org&liste='.$nom_liste.'&mail='.mail) ;
146
		return $suppression_abonne = file_get_contents('http://vpopmail.tela-botanica.org/suppression_abonne.php?domaine=tela-botanica.org&liste='.$nom_liste.'&mail='.$mail) ;
115
	}
147
	}
116
}
148
}
117
?>
149
?>