Index: uc_store.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/ubercart/uc_store/uc_store.module,v retrieving revision 1.13.2.10 diff -u -p -r1.13.2.10 uc_store.module --- uc_store.module 4 Jun 2008 20:33:22 -0000 1.13.2.10 +++ uc_store.module 10 Jul 2008 03:23:37 -0000 @@ -1321,7 +1321,7 @@ function uc_store_store_settings_overvie 'edit' => 'admin/store/settings/store/edit/format', 'title' => t('Format settings'), 'items' => array( - // t('Default currency: !code', array('!code' => variable_get('uc_currency_code', 'USD'))), + t('Default currency: !code', array('!code' => variable_get('uc_currency_code', 'USD'))), t('Currency format: !value', array('!value' => uc_currency_format(1234.56))), t('Weight format: !value', array('!value' => uc_weight_format(36))), t('Date format: !value', array('!value' => uc_date_format(8, 18, 2007))), @@ -1445,6 +1445,15 @@ function uc_store_format_settings_form() '#disabled' => TRUE, '#size' => 10, ); + $form['currency']['uc_currency_code'] = array( + '#type' => 'textfield', + '#title' => t('Default currency code'), + '#description' => t('Use the ISO 4217 3-letter code e.g. USD, CAD, EUR, etc. Use only capital letters.'), + '#default_value' => variable_get('uc_currency_code', 'USD'), + '#size' => 5, + '#maxlength' => 3, + '#validate' => array('uc_currency_code_validate' => array()), + ); $form['currency']['uc_currency_sign'] = uc_textfield(t('Currency Sign'), variable_get('uc_currency_sign', '$'), FALSE, NULL, 10, 10); $form['currency']['uc_sign_after_amount'] = array( '#type' => 'checkbox', @@ -2887,3 +2896,12 @@ function uc_store_send_report() { watchdog('uc_store', t('Reported the following version info to Ubercart.org:') .'
'. print_r($data, TRUE) .''); } +function uc_currency_code_validate($form) { + // valid ISO 4217 currency codes + $codes = array('AFN', 'AED', 'ALL', 'AMD', 'ANG', 'AOA', 'ARS', 'AUD', 'AWG', 'AZN', 'BAM', 'BBD', 'BDT', 'BGN', 'BHD', 'BIF', 'BMD', 'BND', 'BOB', 'BOV', 'BRL', 'BSD', 'BTN', 'BWP', 'BYR', 'BZD', 'CAD', 'CDF', 'CHE', 'CHF', 'CHW', 'CLF', 'CLP', 'CNY', 'COP', 'COU', 'CRC', 'CUP', 'CVE', 'CZK', 'DJF', 'DKK', 'DOP', 'DZD', 'EEK', 'EGP', 'ERN', 'ETB', 'EUR', 'FJD', 'FKP', 'GBP', 'GEL', 'GHS', 'GIP', 'GMD', 'GNF', 'GTQ', 'GWP', 'GYD', 'HKD', 'HNL', 'HRK', 'HTG', 'HUF', 'IDR', 'ILS', 'INR', 'IQD', 'IRR', 'ISK', 'JMD', 'JOD', 'JPY', 'KES', 'KGS', 'KHR', 'KMF', 'KPW', 'KRW', 'KWD', 'KYD', 'KZT', 'LAK', 'LBP', 'LKR', 'LRD', 'LSL', 'LTL', 'LVL', 'LYD', 'MAD', 'MDL', 'MGA', 'MKD', 'MMK', 'MNT', 'MOP', 'MRO', 'MUR', 'MVR', 'MWK', 'MXN', 'MXV', 'MYR', 'MZN', 'NAD', 'NGN', 'NIO', 'NOK', 'NPR', 'NZD', 'OMR', 'PAB', 'PEN', 'PGK', 'PHP', 'PKR', 'PLN', 'PYG', 'QAR', 'RON', 'RSD', 'RUB', 'RWF', 'SAR', 'SBD', 'SCR', 'SDG', 'SEK', 'SGD', 'SHP', 'SKK', 'SLL', 'SOS', 'SRD', 'STD', 'SVC', 'SYP', 'SZL', 'THB', 'TJS', 'TMM', 'TND', 'TOP', 'TRY', 'TTD', 'TWD', 'TZS', 'UAH', 'UGX', 'USD', 'USN', 'USS', 'UYI', 'UYU', 'UZS', 'VEF', 'VND', 'VUV', 'WST', 'XAF', 'XCD', 'XDR', 'XOF', 'XPF', 'YER', 'ZAR', 'ZMK', 'ZWD'); + + if (in_array($form['#value'], $codes)) { + return; + } + form_error($form, t('This is not a valid currency code. Make sure you are using capital letters and please check the official ISO 4217 list for the correct code.')); +} \ No newline at end of file