Merge branch 'w51_MDL-7537_m25_paypalcur' of git://github.com/skodak/moodle
authorDan Poltawski <dan@moodle.com>
Tue, 8 Jan 2013 08:49:47 +0000 (16:49 +0800)
committerDan Poltawski <dan@moodle.com>
Tue, 8 Jan 2013 08:49:47 +0000 (16:49 +0800)
enrol/paypal/edit_form.php
enrol/paypal/lib.php
enrol/paypal/settings.php

index e2121d5..50c1646 100644 (file)
@@ -48,13 +48,7 @@ class enrol_paypal_edit_form extends moodleform {
         $mform->addElement('text', 'cost', get_string('cost', 'enrol_paypal'), array('size'=>4));
         $mform->setDefault('cost', $plugin->get_config('cost'));
 
-        $paypalcurrencies = array('USD' => 'US Dollars',
-                                  'EUR' => 'Euros',
-                                  'JPY' => 'Japanese Yen',
-                                  'GBP' => 'British Pounds',
-                                  'CAD' => 'Canadian Dollars',
-                                  'AUD' => 'Australian Dollars'
-                                 );
+        $paypalcurrencies = $plugin->get_currencies();
         $mform->addElement('select', 'currency', get_string('currency', 'enrol_paypal'), $paypalcurrencies);
         $mform->setDefault('currency', $plugin->get_config('currency'));
 
index 1f354c1..b162f7b 100644 (file)
@@ -34,6 +34,20 @@ defined('MOODLE_INTERNAL') || die();
  */
 class enrol_paypal_plugin extends enrol_plugin {
 
+    public function get_currencies() {
+        // See https://www.paypal.com/cgi-bin/webscr?cmd=p/sell/mc/mc_intro-outside,
+        // 3-character ISO-4217: https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_currency_codes
+        $codes = array(
+            'AUD', 'BRL', 'CAD', 'CHF', 'CZK', 'DKK', 'EUR', 'GBP', 'HKD', 'HUF', 'ILS', 'JPY',
+            'MXN', 'MYR', 'NOK', 'NZD', 'PHP', 'PLN', 'SEK', 'SGD', 'THB', 'TRY', 'TWD', 'USD');
+        $currencies = array();
+        foreach ($codes as $c) {
+            $currencies[$c] = new lang_string($c, 'core_currencies');
+        }
+
+        return $currencies;
+    }
+
     /**
      * Returns optional enrolment information icons.
      *
index 6e3acfb..9b3c14d 100644 (file)
@@ -51,13 +51,7 @@ if ($ADMIN->fulltree) {
 
     $settings->add(new admin_setting_configtext('enrol_paypal/cost', get_string('cost', 'enrol_paypal'), '', 0, PARAM_FLOAT, 4));
 
-    $paypalcurrencies = array('USD' => 'US Dollars',
-                              'EUR' => 'Euros',
-                              'JPY' => 'Japanese Yen',
-                              'GBP' => 'British Pounds',
-                              'CAD' => 'Canadian Dollars',
-                              'AUD' => 'Australian Dollars'
-                             );
+    $paypalcurrencies = enrol_get_plugin('paypal')->get_currencies();
     $settings->add(new admin_setting_configselect('enrol_paypal/currency', get_string('currency', 'enrol_paypal'), '', 'USD', $paypalcurrencies));
 
     if (!during_initial_install()) {