Merge commit 'origin/master' into fusionax
[platal.git] / modules / payment / money / paypal.inc.php
index 48e740f..13d1796 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2008 Polytechnique.org                              *
+ *  Copyright (C) 2003-2009 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -75,21 +75,21 @@ class PayPal
         $info_client = Array(
             'first_name' => S::v('prenom'),
             'last_name'  => $name,
-            'email'      => S::v('bestalias').'@' . $globals->mail->domain);
+            'email'      => S::user()->bestEmail());
 
         $res = XDB::query(
             "SELECT a.adr1 AS address1, a.adr2 AS address2,
                     a.city, a.postcode AS zip, a.country,
-                    IF(t.tel, t.tel, q.profile_mobile) AS night_phone_b
+                    IF(t1.display_tel != '', t1.display_tel, t2.display_tel) AS night_phone_b
                FROM auth_user_quick AS q
           LEFT JOIN adresses  AS a ON (q.user_id = a.uid AND FIND_IN_SET('active', a.statut))
-          LEFT JOIN tels        AS t ON (t.uid = a.uid AND t.adrid = a.adrid)
+          LEFT JOIN profile_phones AS t1 ON (t1.uid = a.uid AND t1.link_type = 'address' AND t1.link_id = a.adrid)
+          LEFT JOIN profile_phones AS t2 ON (t2.uid = a.uid AND t2.link_type = 'user' AND t2.link_id = 0)
               WHERE q.user_id = {?}
               LIMIT 1", S::v('uid'));
         $this->infos['client'] = array_map('replace_accent', array_merge($info_client, $res->fetchOneAssoc()));
 
         // on constuit la reference de la transaction
-        require_once 'xorg.misc.inc.php';
         $prefix = ($pay->flags->hasflag('unique')) ? str_pad("",15,"0") : rand_url_id();
         $fullref = substr("$prefix-xorg-{$pay->id}",-15);