Subversion Repositories eFlore/Applications.eflore-consultation

Rev

Rev 1054 | Rev 1191 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
507 jpm 1
<?php
2
// declare(encoding='UTF-8');
3
/**
4
 * Affiche un formulaire de contact d'utilisateur.
5
 *
6
 * @category	php 5.2
7
 * @package		eFlore-consultation
8
 * @author		Jean-Pascal MILCENT <jpm@tela-botanica.org>
9
 * @copyright	Copyright (c) 2012, Tela Botanica (accueil@tela-botanica.org)
10
 * @license		http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
11
 * @license		http://www.gnu.org/licenses/gpl.html Licence GNU-GPL
12
 * @version		$Id$
13
 */
14
 
15
class PopupContact extends aControleur {
528 jpm 16
 
507 jpm 17
	private $conteneur = null;
18
	private $imagesApi = null;
528 jpm 19
	private $utilisateur = null;
20
	private $appUrls = null;
507 jpm 21
	private $id_destinataire = '';
22
	private $id_image = '';
974 aurelien 23
	private $urlWsCelTpl = '';
529 jpm 24
	private $urlWsAnnuaireUtilisateurTpl = '';
507 jpm 25
 
26
	public function initialiser() {
27
		$this->capturerParametres();
28
		$this->conteneur = new Conteneur();
29
		$this->imagesApi = $this->conteneur->getApiImages();
528 jpm 30
		$this->utilisateur = $this->conteneur->getUtilisateur();
31
		$this->appUrls = $this->conteneur->getAppUrls();
529 jpm 32
		$this->urlWsAnnuaireUtilisateurTpl = $this->conteneur->getParametre('baseUrlServicesAnnuaireTpl');
974 aurelien 33
		$this->urlWsCelTpl = $this->conteneur->getParametre('baseUrlServicesCelTpl');
507 jpm 34
	}
35
 
36
	private function capturerParametres() {
37
		if (isset($_GET['id_destinataire'])) {
38
			$this->id_destinataire = $_GET['id_destinataire'];
39
		}
40
		if (isset($_GET['id_img'])) {
41
			$this->id_image = $_GET['id_img'];
42
		}
43
	}
44
 
45
	public function executerActionParDefaut() {
46
		$this->executerForm();
47
	}
48
 
528 jpm 49
	public function executerForm() {
50
		if ($this->utilisateur->etreIdentifie()) {
51
			$this->afficherFormContact();
52
		} else {
53
			$this->afficherFormIdentification();
54
		}
55
	}
56
 
57
	private function afficherFormContact() {
533 jpm 58
		$this->setSortie(self::META_TITRE, 'Contactez un membre du réseau');
528 jpm 59
		$entete = array();
529 jpm 60
		$entete['formType'] = 'contact';
974 aurelien 61
		$entete['urlWsMessageCel'] = sprintf($this->urlWsCelTpl, 'celMessage/image');
62
		$entete['urlWsUtilisateur'] = sprintf($this->urlWsAnnuaireUtilisateurTpl, 'utilisateur');
63
 
528 jpm 64
		$this->setSortie(self::ENTETE, $this->getVue('contact_entete', $entete));
65
 
974 aurelien 66
		$infos = array();
67
		// cas d'une obs saisie par une personne non inscrite
68
		// le message doit être envoyé au cel qui fournira le courriel de l'auteur
69
		if(trim($this->id_destinataire) == "") {
70
			$infos['idDestinataire'] = $this->id_image;
71
			$infos['typeEnvoi'] = 'non-inscrit';
72
		} else {
73
			$infos['idDestinataire'] = $this->id_destinataire;
74
			$infos['typeEnvoi'] = 'inscrit';
75
		}
507 jpm 76
		$infos['idImage'] = $this->id_image;
528 jpm 77
		$infos['utilisateurCourriel'] = $this->utilisateur->getCourriel();
78
		$infos['urlPopUp'] = $this->appUrls->obtenirUrlPopUpContact($this->id_destinataire, $this->id_image);
79
 
507 jpm 80
		$this->imagesApi->setProjet('cel');
1115 mathias 81
		$imageInfos = $this->imagesApi->setApi(Eflore::API_DEL)->getInfosImageParIdImage($this->id_image); // prêt à passer à API_DEL
528 jpm 82
		$idObs = $imageInfos['observation.id'];
83
		$nomSci = $imageInfos['determination.nom_sci'];
84
		$date = $imageInfos['date'];
85
		$lieu = $imageInfos['station.libelle'];
86
 
87
		$infos['sujet'] = "Observation #$idObs de $nomSci";
88
		$infos['message'] = "\n\n\n\n\n\n\n\n--\nConcerne l'observation de $nomSci du $date au lieu $lieu";
89
 
90
		$this->setSortie(self::RENDU_CORPS, $this->getVue('form_contact', $infos));
91
	}
507 jpm 92
 
528 jpm 93
	private function afficherFormIdentification() {
533 jpm 94
		$this->setSortie(self::META_TITRE, 'Identification');
528 jpm 95
		$entete = array();
529 jpm 96
		$entete['formType'] = 'identification';
97
		$entete['urlWsUtilisateur'] = sprintf($this->urlWsAnnuaireUtilisateurTpl, 'utilisateur');
528 jpm 98
		$this->setSortie(self::ENTETE, $this->getVue('contact_entete', $entete));
99
 
100
		$infos = array();
101
		$infos['urlPopUp'] = $this->appUrls->obtenirUrlPopUpContact($this->id_destinataire, $this->id_image);
102
		$this->setSortie(self::RENDU_CORPS, $this->getVue('form_identification', $infos));
507 jpm 103
	}
104
}
105
?>