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 = '';
|
1507 |
mathias |
25 |
protected $urlConnexionSite = '';
|
507 |
jpm |
26 |
|
|
|
27 |
public function initialiser() {
|
|
|
28 |
$this->capturerParametres();
|
|
|
29 |
$this->conteneur = new Conteneur();
|
|
|
30 |
$this->imagesApi = $this->conteneur->getApiImages();
|
528 |
jpm |
31 |
$this->utilisateur = $this->conteneur->getUtilisateur();
|
|
|
32 |
$this->appUrls = $this->conteneur->getAppUrls();
|
529 |
jpm |
33 |
$this->urlWsAnnuaireUtilisateurTpl = $this->conteneur->getParametre('baseUrlServicesAnnuaireTpl');
|
974 |
aurelien |
34 |
$this->urlWsCelTpl = $this->conteneur->getParametre('baseUrlServicesCelTpl');
|
1507 |
mathias |
35 |
$this->urlConnexionSite = $this->conteneur->getParametre('auth.baseUrlConnexionSite');
|
507 |
jpm |
36 |
}
|
|
|
37 |
|
|
|
38 |
private function capturerParametres() {
|
|
|
39 |
if (isset($_GET['id_destinataire'])) {
|
|
|
40 |
$this->id_destinataire = $_GET['id_destinataire'];
|
|
|
41 |
}
|
1507 |
mathias |
42 |
if (isset($_GET['id_img'])) {
|
|
|
43 |
$this->id_image = $_GET['id_img'];
|
507 |
jpm |
44 |
}
|
|
|
45 |
}
|
|
|
46 |
|
|
|
47 |
public function executerActionParDefaut() {
|
|
|
48 |
$this->executerForm();
|
|
|
49 |
}
|
|
|
50 |
|
528 |
jpm |
51 |
public function executerForm() {
|
1507 |
mathias |
52 |
if ($this->utilisateur->estIdentifie()) {
|
528 |
jpm |
53 |
$this->afficherFormContact();
|
|
|
54 |
} else {
|
|
|
55 |
$this->afficherFormIdentification();
|
|
|
56 |
}
|
|
|
57 |
}
|
|
|
58 |
|
|
|
59 |
private function afficherFormContact() {
|
533 |
jpm |
60 |
$this->setSortie(self::META_TITRE, 'Contactez un membre du réseau');
|
528 |
jpm |
61 |
$entete = array();
|
529 |
jpm |
62 |
$entete['formType'] = 'contact';
|
974 |
aurelien |
63 |
$entete['urlWsMessageCel'] = sprintf($this->urlWsCelTpl, 'celMessage/image');
|
|
|
64 |
$entete['urlWsUtilisateur'] = sprintf($this->urlWsAnnuaireUtilisateurTpl, 'utilisateur');
|
1507 |
mathias |
65 |
|
528 |
jpm |
66 |
$this->setSortie(self::ENTETE, $this->getVue('contact_entete', $entete));
|
|
|
67 |
|
974 |
aurelien |
68 |
$infos = array();
|
|
|
69 |
// cas d'une obs saisie par une personne non inscrite
|
|
|
70 |
// le message doit être envoyé au cel qui fournira le courriel de l'auteur
|
1507 |
mathias |
71 |
if(trim($this->id_destinataire) == "" || trim($this->id_destinataire) == "null") {
|
974 |
aurelien |
72 |
$infos['idDestinataire'] = $this->id_image;
|
|
|
73 |
$infos['typeEnvoi'] = 'non-inscrit';
|
|
|
74 |
} else {
|
|
|
75 |
$infos['idDestinataire'] = $this->id_destinataire;
|
|
|
76 |
$infos['typeEnvoi'] = 'inscrit';
|
1507 |
mathias |
77 |
}
|
507 |
jpm |
78 |
$infos['idImage'] = $this->id_image;
|
1507 |
mathias |
79 |
$infos['utilisateurCourriel'] = $this->utilisateur->getCourriel();
|
528 |
jpm |
80 |
$infos['urlPopUp'] = $this->appUrls->obtenirUrlPopUpContact($this->id_destinataire, $this->id_image);
|
1507 |
mathias |
81 |
|
1191 |
aurelien |
82 |
$this->imagesApi->setProjet('cel');
|
|
|
83 |
// prêt à passer à API_DEL
|
|
|
84 |
// TODO: voir pourquoi la forme service:del:images/#id_image ne fonctionne pas
|
1507 |
mathias |
85 |
// et s'il est vraiment utile d'appeler DEL ici
|
|
|
86 |
$imageInfos = $this->imagesApi->setApi(Eflore::API_EFLORE)->getInfosImageParIdImage($this->id_image);
|
|
|
87 |
$idObs = $imageInfos['observation.id'];
|
|
|
88 |
$nomSci = $imageInfos['determination.nom_sci'];
|
|
|
89 |
$date = $imageInfos['date'];
|
|
|
90 |
$lieu = $imageInfos['station.libelle'];
|
|
|
91 |
|
|
|
92 |
$infos['sujet'] = "Observation #$idObs de $nomSci";
|
|
|
93 |
$infos['message'] = "\n\n\n\n\n\n\n\n--\nConcerne l'observation de $nomSci du $date au lieu $lieu";
|
|
|
94 |
|
528 |
jpm |
95 |
$this->setSortie(self::RENDU_CORPS, $this->getVue('form_contact', $infos));
|
|
|
96 |
}
|
507 |
jpm |
97 |
|
528 |
jpm |
98 |
private function afficherFormIdentification() {
|
533 |
jpm |
99 |
$this->setSortie(self::META_TITRE, 'Identification');
|
528 |
jpm |
100 |
$entete = array();
|
529 |
jpm |
101 |
$entete['formType'] = 'identification';
|
1507 |
mathias |
102 |
$entete['urlWsUtilisateur'] = sprintf($this->urlWsAnnuaireUtilisateurTpl, 'utilisateur');
|
528 |
jpm |
103 |
$this->setSortie(self::ENTETE, $this->getVue('contact_entete', $entete));
|
|
|
104 |
|
1507 |
mathias |
105 |
|
528 |
jpm |
106 |
$infos = array();
|
1507 |
mathias |
107 |
$currentUrl = ((@$_SERVER["HTTPS"] == "on") ? "https://" : "http://")
|
|
|
108 |
. $_SERVER["SERVER_NAME"]
|
|
|
109 |
. $_SERVER['REQUEST_URI'];
|
|
|
110 |
|
|
|
111 |
var_dump($currentUrl); echo "<br/>";
|
|
|
112 |
var_dump(urlencode($currentUrl)); echo "<br/>";
|
|
|
113 |
|
|
|
114 |
$infos['urlPopUp'] = $this->urlConnexionSite . '?redirect_to=' . urlencode($currentUrl);
|
528 |
jpm |
115 |
$this->setSortie(self::RENDU_CORPS, $this->getVue('form_identification', $infos));
|
1507 |
mathias |
116 |
$this->setSortie(self::RENDU_CORPS, $this->getVue('form_identification', $infos));
|
507 |
jpm |
117 |
}
|
|
|
118 |
}
|
|
|
119 |
?>
|