iPédiatre
 Tout Classes Fichiers Fonctions Variables
url.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 if ($http->hasPostVariable('CancelButton')) {
17 
18  $Module->redirectTo($user->contentObject()->mainNode()->urlAlias());
19 
20 } elseif ($http->hasPostVariable('SendButton')) {
21 
22  $mail = new ezcMail();
23 
24  if($http->postVariable('email')) {
25 
26  $subject = ezpI18n::tr('ipediatre/contact', 'You pediatrician wants to share his URL with you');
27  $to = new ezcMailAddress( $http->postVariable('email') );
28 
29  }
30 
31  if ($http->hasPostVariable('content')) {
32 
33  $mail->from = new ezcMailAddress( $user->attribute('email'), $user->contentObject()->name(), 'utf-8' );
34  $mail->subject = $subject;
35  $mail->body = new ezcMailText($http->postVariable('content'). " ",'utf-8');
36  $mail->to = array( $to );
37  $mail->subjectCharset = 'utf-8';
38 
39  $transport = new iPMailTransport($ini);
40 
41  try {
42  $transport->send( $mail );
43  $tpl->setVariable( 'success', true );
44  $Module->redirectTo($user->contentObject()->mainNode()->urlAlias());
45  }
46  catch(Exception $e)
47  {
48  eZDebug::writeError("Le module de partage d'url a tenté d'envoyer un email à `{$to}` mais l'envoi a échoué: ".$e->getMessage());
49  }
50 
51  } else {
52  eZDebug::writeError("Le module de partage d'url a tenté d'envoyer un email mais le sujet était vide");
53  }
54 }
55 
56 $uri = eZURI::instance( eZSys::requestURI() );
57 $viewParameters = $uri->UserParameters();
58 $tpl->setVariable( 'view_parameters', $viewParameters );
59 $tpl->setVariable('login', 'nutrition');
60 $tpl->setVariable('password', 'nutrition');
61 $tpl->setVariable('url', 'http://' . $_SERVER["HTTP_HOST"] . '/' . $user->contentObject()->mainNode()->urlAlias());
62 $tpl->setVariable('name', $user->contentObject()->name());
63 
64 $Result['content'] = $tpl->fetch('design:share/url.tpl');