iPédiatre
 Tout Classes Fichiers Fonctions Variables
contact.php
Aller à la documentation de ce fichier.
1 <?php
10 $Module = $Params['Module'];
11 $tpl = eZTemplate::factory();
12 $http = eZHTTPTool::instance();
13 $user = eZUser::currentUser();
14 $ini = eZINI::instance();
15 
16 
17 if ($http->hasPostVariable('CancelButton')) {
18 
19  $Module->redirectTo($user->contentObject()->mainNode()->urlAlias());
20 
21 } elseif ($http->hasPostVariable('SendButton')) {
22 
23  $mail = new ezcMail();
24  $adminEmail = $ini->variable('MailSettings', 'AdminEmail');
25  $mail->addBcc(new ezcMailAddress( "joel.vicente@publicislifebrands.fr", "Joel Vicente" ));
26  $mail->addBcc(new ezcMailAddress( "yoann.martoglio@publicislifebrands.fr", "Yoann Martoglio" ));
27  $mail->addBcc(new ezcMailAddress( "cc@synap.fr", "Charles-Edouard Coste" ));
28 $adminEmail = 'joel.vicente@publicislifebrands.fr';
29  switch($http->postVariable('subject')) {
30 
31  case '1':
32  $subject = ezpI18n::tr('ipediatre/contact','Get assistance on my website');
33  $to = new ezcMailAddress( $adminEmail );
34  break;
35 
36  case '2':
37  $subject = ezpI18n::tr('ipediatre/contact','Submit a recommendation or a bug concerning the website');
38  $to = new ezcMailAddress( $adminEmail );
39  break;
40 
41  case '3':
42  $tmp = $user->contentObject()->dataMap();
43  $tmp = $tmp['delegate_relation']->content()->dataMap();
44  $email = $tmp['user_account']->content()->attribute('email');
45  $name = $tmp['first_name']->content().' '.$tmp['last_name']->content();
46  unset($tmp);
47 
48  $subject = ezpI18n::tr('ipediatre/contact','Get a meeting with my delegate');
49  $to = new ezcMailAddress( $email, $name, 'utf-8');
50  break;
51 
52  default:
53  $subject = false;
54  }
55 
56  if ($subject and $http->hasPostVariable('content')) {
57 
58  $mail->from = new ezcMailAddress( $user->attribute('email'), $user->contentObject()->name(), 'utf-8' );
59  $mail->subject = $subject;
60  $mail->body = new ezcMailText($http->postVariable('content').ezpI18n::tr("\n-- \nThis email has been sent through the iPediatrician contact form"),'utf-8'); ; //plante si plainText est vide
61  $mail->to = array( $to );
62  $mail->subjectCharset = 'utf-8';
63 
64  $transport = new iPMailTransport($ini);
65 
66  try {
67  $transport->send( $mail );
68  $tpl->setVariable( 'success', true );
69  eZDebug::writeDebug("Le module de contact a tenté d'envoyer un email à `{$to}`");
70  }
71  catch(Exception $e)
72  {
73  eZDebug::writeError("Le module de contact a tenté d'envoyer un email à `{$to}` mais l'envoi a échoué: ".$e->getMessage());
74  }
75 
76  } else {
77  eZDebug::writeError("Le module de contact a tenté d'envoyer un email mais le sujet était vide");
78  }
79 }
80 
81 $uri = eZURI::instance( eZSys::requestURI() );
82 $viewParameters = $uri->UserParameters();
83 $tpl->setVariable( 'view_parameters', $viewParameters );
84 
85 $Result['content'] = $tpl->fetch('design:ip/contact.tpl');