X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fpayment%2Fmoney%2Fpaypal.inc.php;h=71de32358c60ed10fdfdc2d51209545924321688;hb=b46de52d000ee3dd77726bff9236d8f624160458;hp=231c86d42a58f7c6828ef5092045adda72c241ce;hpb=b00527ff4a4883f2bd8bdfcceb6d4123f19ef785;p=platal.git diff --git a/modules/payment/money/paypal.inc.php b/modules/payment/money/paypal.inc.php index 231c86d..71de323 100644 --- a/modules/payment/money/paypal.inc.php +++ b/modules/payment/money/paypal.inc.php @@ -1,6 +1,6 @@ urlform = 'https://' . $globals->money->paypal_site . '/cgi-bin/webscr'; $user = S::user(); - $name = $user->lastName(); $roboturl = str_replace("https://","http://",$globals->baseurl) . '/' . $platal->ns . "payment/paypal_return/" . S::v('uid') . "?comment=" . urlencode(Env::v('comment')); - $this->infos = array(); - - $this->infos['commercant'] = array( - 'business' => $globals->money->paypal_compte, - 'rm' => 2, - 'return' => $roboturl, - 'cn' => 'Commentaires', - 'no_shipping' => 1, - 'cbt' => empty($GLOBALS['IS_XNET_SITE']) ? - 'Revenir sur polytechnique.org.' : - 'Revenir sur polytechnique.net.' + $this->infos = array( + 'commercant' => array( + 'business' => $globals->money->paypal_compte, + 'rm' => 2, + 'return' => $roboturl, + 'cn' => 'Commentaires', + 'no_shipping' => 1, + 'cbt' => empty($GLOBALS['IS_XNET_SITE']) ? 'Revenir sur polytechnique.org.' : 'Revenir sur polytechnique.net.' + ) ); $info_client = array( - 'first_name' => S::v('prenom'), - 'last_name' => $name, - 'email' => S::user()->bestEmail() + 'first_name' => $user->firstName(), + 'last_name' => $user->lastName(), + 'email' => $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' - 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) - LEFT JOIN geoloc_localities AS l ON (l.id = a.localityId) - WHERE q.user_id = {?} - LIMIT 1", - S::v('uid')); - $this->infos['client'] = array_map('replace_accent', array_merge($info_client, $res->fetchOneAssoc())); - list($this->infos['client']['address1'], $this->infos['client']['address2']) = - explode("\n", Geocoder::getFirstLines($this->infos['client']['text'], - $this->infos['client']['zip'], 2)); - unset($this->infos['client']['text']); + if ($user->hasProfile() { + $res = XDB::query("SELECT pa.text, gl.name AS city, pa.postalCode AS zip, pa.countryId AS country, + IF(pp1.display_tel != '', pp1.display_tel, pp2.display_tel) AS night_phone_b + FROM profile_addresses AS pa + LEFT JOIN profile_phones AS pp1 ON (pp1.pid = pa.pid AND pp1.link_type = 'address' + AND pp1.link_id = pa.id) + LEFT JOIN profile_phones AS pp2 ON (pp2.pid = pa.pid AND pp2.link_type = 'user' + AND pp2.link_id = 0) + LEFT JOIN geoloc_localities AS gl ON (gl.id = pa.localityId) + WHERE pa.pid = {?} AND FIND_IN_SET('current', pa.flags) + LIMIT 1", + $user->profile()->id()); + $this->infos['client'] = array_map('replace_accent', array_merge($info_client, $res->fetchOneAssoc())); + list($this->infos['client']['address1'], $this->infos['client']['address2']) = + explode("\n", Geocoder::getFirstLines($this->infos['client']['text'], + $this->infos['client']['zip'], 2)); + unset($this->infos['client']['text']); + } else { + $this->infos['client'] = replace_accent($info_client); + } // We build the transaction's reference $prefix = ($pay->flags->hasflag('unique')) ? str_pad("", 15, "0") : rand_url_id();