Subversion Repositories eFlore/Applications.eflore-consultation

Rev

Rev 507 | Rev 529 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

<?php
// declare(encoding='UTF-8');
/**
 * Affiche un formulaire de contact d'utilisateur.
 *
 * @category    php 5.2
 * @package             eFlore-consultation
 * @author              Jean-Pascal MILCENT <jpm@tela-botanica.org>
 * @copyright   Copyright (c) 2012, Tela Botanica (accueil@tela-botanica.org)
 * @license             http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
 * @license             http://www.gnu.org/licenses/gpl.html Licence GNU-GPL
 * @version             $Id$
 */

class PopupContact extends aControleur {

        private $conteneur = null;
        private $imagesApi = null;
        private $utilisateur = null;
        private $appUrls = null;
        private $id_destinataire = '';
        private $id_image = '';

        public function initialiser() {
                $this->capturerParametres();
                $this->conteneur = new Conteneur();
                $this->imagesApi = $this->conteneur->getApiImages();
                $this->utilisateur = $this->conteneur->getUtilisateur();
                $this->appUrls = $this->conteneur->getAppUrls();
        }

        private function capturerParametres() {
                if (isset($_GET['id_destinataire'])) {
                        $this->id_destinataire = $_GET['id_destinataire'];
                }
                if (isset($_GET['id_img'])) {
                        $this->id_image = $_GET['id_img'];
                }
        }

        public function executerActionParDefaut() {
                $this->executerForm();
        }

        public function executerForm() {
                if ($this->utilisateur->etreIdentifie()) {
                        $this->afficherFormContact();
                } else {
                        $this->afficherFormIdentification();
                }
        }

        private function afficherFormContact() {
                $entete = array();
                $entete['formType'] = 'contact';
                $this->setSortie(self::ENTETE, $this->getVue('contact_entete', $entete));

                $infos = array();
                $infos['idDestinataire'] = $this->id_destinataire;
                $infos['idImage'] = $this->id_image;
                $infos['utilisateurCourriel'] = $this->utilisateur->getCourriel();
                $infos['urlPopUp'] = $this->appUrls->obtenirUrlPopUpContact($this->id_destinataire, $this->id_image);

                $this->imagesApi->setProjet('cel');
                $imageInfos = $this->imagesApi->getInfosImageParIdImage($this->id_image);
                $idObs = $imageInfos['observation.id'];
                $nomSci = $imageInfos['determination.nom_sci'];
                $date = $imageInfos['date'];
                $lieu = $imageInfos['station.libelle'];

                $infos['sujet'] = "Observation #$idObs de $nomSci";
                $infos['message'] = "\n\n\n\n\n\n\n\n--\nConcerne l'observation de $nomSci du $date au lieu $lieu";

                $this->setSortie(self::RENDU_CORPS, $this->getVue('form_contact', $infos));
        }

        private function afficherFormIdentification() {
                $entete = array();
                $entete['formType'] = 'identification';
                $this->setSortie(self::ENTETE, $this->getVue('contact_entete', $entete));

                $infos = array();
                $infos['urlPopUp'] = $this->appUrls->obtenirUrlPopUpContact($this->id_destinataire, $this->id_image);
                $this->setSortie(self::RENDU_CORPS, $this->getVue('form_identification', $infos));
        }
}
?>