X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fpayment%2Fmoney%2Fpaypal.inc.php;h=3ea2c63e075a1aec1458164fd579f900b230723f;hb=d71cf889a597a64abd6351f9a0097ec9bf9da42c;hp=f0985b5ea1d6f0afa12cd554674bd997fc8f1a7b;hpb=b2d6af6a27a18dad7e9926a96fa69ff09812cc18;p=platal.git diff --git a/modules/payment/money/paypal.inc.php b/modules/payment/money/paypal.inc.php index f0985b5..3ea2c63 100644 --- a/modules/payment/money/paypal.inc.php +++ b/modules/payment/money/paypal.inc.php @@ -1,6 +1,6 @@ val_number = $val; } - function prepareform(&$pay) + function prepareform($pay, $user) { // Documentation: // https://www.paypal.com/developer @@ -43,11 +43,10 @@ class PayPal global $globals, $platal; $this->urlform = 'https://' . $globals->money->paypal_site . '/cgi-bin/webscr'; - $user = S::user(); $roboturl = str_replace("https://","http://",$globals->baseurl) . '/' . $platal->ns . "payment/paypal_return/" . S::v('uid') - . "?comment=" . urlencode(Env::v('comment')); + . "?comment=" . urlencode(Env::v('comment')) . '&display=' . Post::i('display'); $this->infos = array( 'commercant' => array( @@ -66,22 +65,30 @@ class PayPal 'email' => $user->bestEmail() ); - $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']); + if ($user->hasProfile()) { + $res = XDB::query("SELECT pa.text, GROUP_CONCAT(pace2.short_name) AS city, + GROUP_CONCAT(pace3.short_name) AS zip, GROUP_CONCAT(pace1.short_name) 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 profile_addresses_components AS pc ON (pa.pid = pc.pid AND pa.jobid = pc.jobid AND pa.groupid = pc.groupid + AND pa.type = pc.type AND pa.id = pc.id) + LEFT JOIN profile_addresses_components_enum AS pace1 ON (FIND_IN_SET('country', pace1.types) AND pace1.id = pc.component_id) + LEFT JOIN profile_addresses_components_enum AS pace2 ON (FIND_IN_SET('locality', pace2.types) AND pace2.id = pc.component_id) + LEFT JOIN profile_addresses_components_enum AS pace3 ON (FIND_IN_SET('postal_code', pace3.types) AND pace3.id = pc.component_id) + WHERE pa.pid = {?} AND FIND_IN_SET('current', pa.flags) + GROUP BY pa.pid, pa.jobid, pa.groupid, pa.id, pa.type + 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();