mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 08:26:37 +02:00
Now text sent to PayPal can be 'sanitised' to avoid
some diacritics (spanish for now) break the enrol process. Only German and French diacritics are supported for now by PayPal. Functionality can be easily expanded to other characters. It make the sanitity when $CFG->sanitise_for_paypal is enabled. Merged from MOODLE_14_STABLE
This commit is contained in:
parent
559027a76c
commit
04ad0d91e8
2 changed files with 46 additions and 7 deletions
|
@ -8,11 +8,11 @@
|
|||
|
||||
<input type="hidden" name="cmd" value="_xclick">
|
||||
<input type="hidden" name="business" value="<?php p($CFG->enrol_paypalbusiness)?>">
|
||||
<input type="hidden" name="item_name" value="<?php p($course->fullname) ?>">
|
||||
<input type="hidden" name="item_number" value="<?php p($course->shortname) ?>">
|
||||
<input type="hidden" name="item_name" value="<?php p($coursefullname) ?>">
|
||||
<input type="hidden" name="item_number" value="<?php p($courseshortname) ?>">
|
||||
<input type="hidden" name="quantity" value="1">
|
||||
<input type="hidden" name="on0" value="<?php print_string("user") ?>">
|
||||
<input type="hidden" name="os0" value="<?php echo fullname($USER) ?>">
|
||||
<input type="hidden" name="os0" value="<?php p($userfullname) ?>">
|
||||
<input type="hidden" name="custom" value="<?php echo "$USER->id-$course->id" ?>">
|
||||
|
||||
<input type="hidden" name="currency_code" value="<?php p($CFG->enrol_currency) ?>">
|
||||
|
@ -26,10 +26,10 @@
|
|||
<input type="hidden" name="rm" value="2">
|
||||
<input type="hidden" name="cbt" value="<?php print_string("continuetocourse") ?>">
|
||||
|
||||
<input type="hidden" name="first_name" value="<?php p($USER->firstname) ?>">
|
||||
<input type="hidden" name="last_name" value="<?php p($USER->lastname) ?>">
|
||||
<input type="hidden" name="address" value="<?php p($USER->address) ?>">
|
||||
<input type="hidden" name="city" value="<?php p($USER->city) ?>">
|
||||
<input type="hidden" name="first_name" value="<?php p($userfirstname) ?>">
|
||||
<input type="hidden" name="last_name" value="<?php p($userlastname) ?>">
|
||||
<input type="hidden" name="address" value="<?php p($useraddress) ?>">
|
||||
<input type="hidden" name="city" value="<?php p($usercity) ?>">
|
||||
<input type="hidden" name="email" value="<?php p($USER->email) ?>">
|
||||
<input type="hidden" name="country" value="<?php p($USER->country) ?>">
|
||||
|
||||
|
|
|
@ -39,6 +39,14 @@ function print_entry($course) {
|
|||
print_course($course, "80%");
|
||||
print_simple_box_start("center");
|
||||
|
||||
//Sanitise some fields before building the PayPal form
|
||||
$coursefullname = $this->sanitise_for_paypal($course->fullname);
|
||||
$courseshortname = $this->sanitise_for_paypal($course->shortname);
|
||||
$userfullname = $this->sanitise_for_paypal(fullname($USER));
|
||||
$userfirstname = $this->sanitise_for_paypal($USER->firstname);
|
||||
$userlastname = $this->sanitise_for_paypal($USER->lastname);
|
||||
$useraddress = $this->sanitise_for_paypal($USER->address);
|
||||
$usercity = $this->sanitise_for_paypal($USER->city);
|
||||
|
||||
include("$CFG->dirroot/enrol/paypal/enrol.html");
|
||||
|
||||
|
@ -142,6 +150,37 @@ function process_config($config) {
|
|||
|
||||
}
|
||||
|
||||
//To avoid wrong (for PayPal) characters in sent data
|
||||
function sanitise_for_paypal($text) {
|
||||
global $CFG;
|
||||
|
||||
if (!empty($CFG->sanitise_for_paypal)) {
|
||||
//Array of characters to replace (not allowed by PayPal)
|
||||
//Can be expanded as necessary to add other diacritics
|
||||
$replace = array('á' => 'a', //Spanish characters
|
||||
'é' => 'e',
|
||||
'í' => 'i',
|
||||
'ó' => 'o',
|
||||
'ú' => 'u',
|
||||
'Á' => 'A',
|
||||
'É' => 'E',
|
||||
'Í' => 'I',
|
||||
'Ó' => 'O',
|
||||
'Ú' => 'U',
|
||||
'ñ' => 'n',
|
||||
'Ñ' => 'N',
|
||||
'ü' => 'u',
|
||||
'Ü' => 'U');
|
||||
$text = strtr($text, $replace);
|
||||
|
||||
//Make here other sanities if necessary
|
||||
|
||||
}
|
||||
|
||||
return $text;
|
||||
|
||||
}
|
||||
|
||||
|
||||
} // end of class definition
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue