From fc1227efba2971cfcca9fe113b98fe94c197ee89 Mon Sep 17 00:00:00 2001 From: =?utf8?q?St=C3=A9phane=20Jacob?= Date: Mon, 9 May 2011 11:26:59 +0200 Subject: [PATCH] Properly formats name and comment field in paiements (Closes #1485). MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Jacob --- ChangeLog | 3 +++ classes/user.php | 8 ++++++++ modules/payment/money/bplccyberplus.inc.php | 9 +++++++-- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index b8f8025..b7e1777 100644 --- a/ChangeLog +++ b/ChangeLog @@ -30,6 +30,9 @@ Bug/Wish: * Newsletter: - #1394: Links nl unsubscribtions to the issues that caused them -JAC + * Paiement: + - #1485: Properly formats name and comment field in paiements -JAC + * Profile: - #1445: Add job entry year -JAC - #1478: Uses user's visibility limitations to display vcards -JAC diff --git a/classes/user.php b/classes/user.php index ab554bc..a0daff6 100644 --- a/classes/user.php +++ b/classes/user.php @@ -292,6 +292,14 @@ class User extends PlUser return $this->profile()->fullName($with_promo); } + public function shortName($with_promo = false) + { + if (!$this->hasProfile()) { + return $this->full_name; + } + return $this->profile()->shortName($with_promo); + } + public function directoryName() { if (!$this->hasProfile()) { diff --git a/modules/payment/money/bplccyberplus.inc.php b/modules/payment/money/bplccyberplus.inc.php index 061d3ce..8c6145d 100644 --- a/modules/payment/money/bplccyberplus.inc.php +++ b/modules/payment/money/bplccyberplus.inc.php @@ -55,6 +55,11 @@ class BPLCCyberPlus // }}} // {{{ function form() + private static function replaceNonAlpha($string) + { + return trim(preg_replace('/\s\s+/', ' ', preg_replace('/[^a-zA-Z0-9]/', ' ', $string))); + } + function prepareform($pay) { global $globals, $platal; @@ -76,7 +81,7 @@ class BPLCCyberPlus $this->infos['client'] = Array( 'vads_cust_email' => S::user()->bestEmail(), 'vads_cust_id' => S::v('uid'), - 'vads_cust_name' => replace_accent(S::user()->fullName())); + 'vads_cust_name' => substr(self::replaceNonAlpha(replace_accent(S::user()->shortName())), 0, 127); $this->infos['commande'] = Array( 'vads_amount' => $this->val, 'vads_currency' => '978', # Euro @@ -84,7 +89,7 @@ class BPLCCyberPlus 'vads_trans_date' => $trans_date, 'vads_trans_id' => $trans_id, 'vads_order_id' => $fullref, - 'vads_order_info' => Env::v('comment')); + 'vads_order_info' => substr(self::replaceNonAlpha(replace_accent(Env::v('comment'))), 0, 255); $this->infos['divers'] = Array( 'vads_version' => 'V2', 'vads_ctx_mode' => $globals->money->cyperplus_prod, -- 2.1.4