Fix many uid fields in profile tables created by newdirectory.
[platal.git] / modules / payment / money / paypal.inc.php
index 08d83f4..45ad720 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2009 Polytechnique.org                              *
+ *  Copyright (C) 2003-2010 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -43,10 +43,8 @@ class PayPal
         global $globals, $platal;
 
         $this->urlform = 'https://' . $globals->money->paypal_site . '/cgi-bin/webscr';
-        $req = XDB::query("SELECT  IF(nom_usage!='', nom_usage, nom) AS nom
-                             FROM  auth_user_md5
-                            WHERE  user_id = {?}", S::v('uid'));
-        $name = $req->fetchOneCell();
+        $user = S::user();
+        $name = $user->lastName();
 
         $roboturl = str_replace("https://","http://",$globals->baseurl)
                   . '/' . $platal->ns . "payment/paypal_return/" . S::v('uid')
@@ -71,14 +69,15 @@ class PayPal
             'email'      => S::user()->bestEmail()
         );
 
+        // XXX: waiting for port of adresses.
         $res = XDB::query(
                 "SELECT  a.text, l.name AS city, a.postalCode AS zip, a.countryiId AS country,
                          IF(t1.display_tel != '', t1.display_tel, t2.display_tel) AS night_phone_b
                    FROM  auth_user_quick   AS q
               LEFT JOIN  profile_addresses AS a  ON (q.user_id = a.pid AND FIND_IN_SET('current', a.flags))
-              LEFT JOIN  profile_phones    AS t1 ON (t1.uid = a.uid AND t1.link_type = 'address'
+              LEFT JOIN  profile_phones    AS t1 ON (t1.pid = a.pid 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'
+              LEFT JOIN  profile_phones    AS t2 ON (t2.pid = a.pid AND t2.link_type = 'user'
                                                      AND t2.link_id = 0)
               LEFT JOIN  geoloc_localities AS l  ON (l.id = a.localityId)
                   WHERE  q.user_id = {?}