| 10 |
define('DONATION_PUBLIC', 1); |
define('DONATION_PUBLIC', 1); |
| 11 |
define('DONATION_PAGER', 25); |
define('DONATION_PAGER', 25); |
| 12 |
|
|
| 13 |
|
// Custom paths |
| 14 |
|
define('DONATION_FORM_PATH', 'donation_form_path'); |
| 15 |
|
define('DONATION_LIST_PATH', 'donation_list_path'); |
| 16 |
|
|
| 17 |
// Variable names |
// Variable names |
| 18 |
define('DONATION_FORCE_DEFAULT_CURRENCY', 'donation_force_default_currency'); |
define('DONATION_FORCE_DEFAULT_CURRENCY', 'donation_force_default_currency'); |
| 19 |
define('DONATION_DEFAULT_CURRENCY', 'donation_default_currency'); |
define('DONATION_DEFAULT_CURRENCY', 'donation_default_currency'); |
| 20 |
define('DONATION_EMAIL', 'donation_email'); |
define('DONATION_EMAIL', 'donation_email'); |
| 21 |
define('DONATION_STATE', 'donation_state'); |
define('DONATION_STATE', 'donation_state'); |
| 22 |
define('DONATION_THANKS_TEXT', 'donation_thanks_text'); |
define('DONATION_THANKS_TEXT', 'donation_thanks_text'); |
| 23 |
define('DONATION_CURRENCY_TEXT', 'donation_currency_text'); |
define('DONATION_CURRENCY_TEXT', 'donation_currency_text'); |
| 24 |
define('DONATION_LOVE_TEXT', 'donation_love_text'); |
define('DONATION_LOVE_TEXT', 'donation_love_text'); |
| 25 |
|
define('DONATION_CURRENCY_TEXT', 'donation_currency_text'); |
| 26 |
define('DONATION_DONORS_TEXT', 'donation_donors_text'); |
define('DONATION_DONORS_TEXT', 'donation_donors_text'); |
| 27 |
define('DONATION_CURRENCY_OPTIONS', 'donation_currency_options'); |
define('DONATION_CURRENCY_OPTIONS', 'donation_currency_options'); |
| 28 |
define('DONATION_DONOR_USER_TEXT', 'donation_donor_user_text'); |
define('DONATION_DONOR_USER_TEXT', 'donation_donor_user_text'); |
| 113 |
'type' => MENU_LOCAL_TASK, |
'type' => MENU_LOCAL_TASK, |
| 114 |
); |
); |
| 115 |
$items[] = array( |
$items[] = array( |
| 116 |
'path' => 'donate', |
'path' => variable_get(DONATION_FORM_PATH, 'donate'), |
| 117 |
'title' => t('Donate'), |
'title' => t('Donate'), |
| 118 |
'access' => TRUE, |
'access' => TRUE, |
| 119 |
'callback' => 'drupal_get_form', |
'callback' => 'drupal_get_form', |
| 121 |
'type' => MENU_CALLBACK, |
'type' => MENU_CALLBACK, |
| 122 |
); |
); |
| 123 |
$items[] = array( |
$items[] = array( |
| 124 |
'path' => 'donations', |
'path' => variable_get(DONATION_LIST_PATH, 'donations'), |
| 125 |
'title' => t('Donations'), |
'title' => t('Donations'), |
| 126 |
'access' => TRUE, |
'access' => TRUE, |
| 127 |
'callback' => 'donation_public_page', |
'callback' => 'donation_public_page', |
| 132 |
} |
} |
| 133 |
|
|
| 134 |
function donation_settings() { |
function donation_settings() { |
| 135 |
|
$form['path_settings'] = array( |
| 136 |
|
'#type' => 'fieldset', |
| 137 |
|
'#title' => t('Path Settings'), |
| 138 |
|
); |
| 139 |
|
|
| 140 |
|
$form['path_settings'][DONATION_FORM_PATH] = array( |
| 141 |
|
'#type' => 'textfield', |
| 142 |
|
'#title' => t('Path to donation form'), |
| 143 |
|
'#description' => t('The path to the donation form excluding the trailing |
| 144 |
|
slash. <b>Example</b>: donate'), |
| 145 |
|
'#default_value' => variable_get(DONATION_FORM_PATH, 'donate'), |
| 146 |
|
); |
| 147 |
|
|
| 148 |
|
$form['path_settings'][DONATION_LIST_PATH] = array( |
| 149 |
|
'#type' => 'textfield', |
| 150 |
|
'#title' => t('Path to list of donations'), |
| 151 |
|
'#description' => t('The path to the list of donations excluding the trailing |
| 152 |
|
slash. <b>Example</b>: donations'), |
| 153 |
|
'#default_value' => variable_get(DONATION_LIST_PATH, 'donations'), |
| 154 |
|
); |
| 155 |
|
|
| 156 |
$form['currency_settings'] = array( |
$form['currency_settings'] = array( |
| 157 |
'#type' => 'fieldset', |
'#type' => 'fieldset', |
| 158 |
'#title' => t('Currency Options'), |
'#title' => t('Currency Options'), |
| 159 |
); |
); |
| 160 |
$form['currency_settings']['currency_options'] = array( |
$form['currency_settings']['currency_options'] = array( |
| 161 |
'#type' => 'fieldset', |
'#type' => 'fieldset', |
| 162 |
'#title' => t('Choose which currencies to accept'), |
'#title' => t('Choose which currencies to accept'), |
| 163 |
'#collapsible' => TRUE, |
'#collapsible' => TRUE, |
| 164 |
'#collapsed' => TRUE, |
'#collapsed' => TRUE, |
| 165 |
); |
); |
| 166 |
$form['currency_settings']['currency_options'][DONATION_CURRENCY_OPTIONS] = array( |
$form['currency_settings']['currency_options'][DONATION_CURRENCY_OPTIONS] = array( |
| 167 |
'#type' => 'checkboxes', |
'#type' => 'checkboxes', |
| 168 |
'#options' => donation_get_currencies(), |
'#options' => donation_get_currencies(), |
| 169 |
'#default_value' => variable_get(DONATION_CURRENCY_OPTIONS, array('USD', 'GBP')), |
'#default_value' => variable_get(DONATION_CURRENCY_OPTIONS, array('USD', 'GBP')), |
| 170 |
); |
); |
| 171 |
|
|
| 172 |
$form['currency_settings'][DONATION_DEFAULT_CURRENCY] = array( |
$form['currency_settings'][DONATION_DEFAULT_CURRENCY] = array( |
| 173 |
'#type' => 'select', |
'#type' => 'select', |
| 174 |
'#title' => t('Default Currency'), |
'#title' => t('Default Currency'), |
| 175 |
'#options' => donation_get_currencies(), |
'#options' => donation_get_currencies(), |
| 176 |
'#default_value' => variable_get(DONATION_DEFAULT_CURRENCY, 'USD'), |
'#default_value' => variable_get(DONATION_DEFAULT_CURRENCY, 'USD'), |
| 177 |
'#description' => t('Be sure to confirm that you have enabled payment |
'#description' => t('Be sure to confirm that you have enabled payment |
| 178 |
with this currency above.'), |
with this currency above.'), |
| 179 |
); |
); |
| 180 |
|
|
| 181 |
$form['currency_settings'][DONATION_FORCE_DEFAULT_CURRENCY] = array( |
$form['currency_settings'][DONATION_FORCE_DEFAULT_CURRENCY] = array( |
| 182 |
'#type' => 'checkbox', |
'#type' => 'checkbox', |
| 183 |
'#title' => t('Hide currency field on donation form'), |
'#title' => t('Hide currency field on donation form'), |
| 184 |
'#return_value' => 1, |
'#return_value' => 1, |
| 185 |
'#default_value' => variable_get(DONATION_FORCE_DEFAULT_CURRENCY, 0), |
'#default_value' => variable_get(DONATION_FORCE_DEFAULT_CURRENCY, 0), |
| 186 |
); |
); |
| 187 |
|
|
| 188 |
$form[DONATION_EMAIL] = array( |
$form[DONATION_EMAIL] = array( |
| 189 |
'#type' => 'textfield', |
'#type' => 'textfield', |
| 190 |
'#title' => t('Donations email address'), |
'#title' => t('Donations email address'), |
| 191 |
'#default_value' => variable_get(DONATION_EMAIL, 'donations@drupal.org'), |
'#default_value' => variable_get(DONATION_EMAIL, 'donations@drupal.org'), |
| 589 |
|
|
| 590 |
|
|
| 591 |
if (variable_get(DONATION_FORCE_DEFAULT_CURRENCY, 0)) { |
if (variable_get(DONATION_FORCE_DEFAULT_CURRENCY, 0)) { |
| 592 |
$form['currency_code'] = array( |
$form['currency_code'] = array( |
| 593 |
'#type' => 'hidden', |
'#type' => 'hidden', |
| 594 |
'#value' => variable_get(DONATION_DEFAULT_CURRENCY, 'USD'), |
'#value' => variable_get(DONATION_DEFAULT_CURRENCY, 'USD'), |
| 595 |
); |
); |
| 596 |
} else { |
} else { |
| 597 |
$form['currency_code'] = array( |
$form['currency_code'] = array( |
| 598 |
'#type' => 'select', |
'#type' => 'select', |
| 599 |
'#title' => t('Currency'), |
'#title' => t('Currency'), |
| 600 |
'#options' => _donation_currency_options(), |
'#options' => _donation_currency_options(), |
| 601 |
'#default_value' => variable_get(DONATION_DEFAULT_CURRENCY, 'USD'), |
'#default_value' => variable_get(DONATION_DEFAULT_CURRENCY, 'USD'), |
| 602 |
'#name' => 'currency_code', |
'#name' => 'currency_code', |
| 603 |
'#description' => t('The Drupal Association accepts payments in these two currencies.'), |
'#description' => variable_get(DONATION_CURRENCY_TEXT, DONATION_CURRENCY_DEFAULT_TEXT), |
| 604 |
); |
); |
| 605 |
} |
} |
| 606 |
|
|
| 607 |
$form['amount'] = array( |
$form['amount'] = array( |
| 608 |
'#type' => 'textfield', |
'#type' => 'textfield', |
| 609 |
'#title' => t('Amount'), |
'#title' => t('Amount'), |
| 637 |
* |
* |
| 638 |
* @see https://www.paypal.com/cgi-bin/webscr?cmd=p/sell/mc/mc_wa-outside |
* @see https://www.paypal.com/cgi-bin/webscr?cmd=p/sell/mc/mc_wa-outside |
| 639 |
* @return array |
* @return array |
| 640 |
* Key value pairs where the key is the currency code |
* Key value pairs where the key is the currency code |
| 641 |
*/ |
*/ |
| 642 |
function donation_get_currencies() { |
function donation_get_currencies() { |
| 643 |
return array( |
return array( |
| 644 |
'AUD' => t('Austrailian Dollars'), |
'AUD' => t('Austrailian Dollars'), |
| 645 |
'CAD' => t('Canadian Dollars'), |
'CAD' => t('Canadian Dollars'), |
| 646 |
'EUR' => t('Euros'), |
'EUR' => t('Euros'), |
| 647 |
'GBP' => t('Pounds Sterling'), |
'GBP' => t('Pounds Sterling'), |
| 648 |
'JPY' => t('Yen'), |
'JPY' => t('Yen'), |
| 649 |
'USD' => t('U.S. Dollars'), |
'USD' => t('U.S. Dollars'), |
| 650 |
'NZD' => t('New Zealand Dollar'), |
'NZD' => t('New Zealand Dollar'), |
| 651 |
'CHF' => t('Swiss Franc'), |
'CHF' => t('Swiss Franc'), |
| 652 |
'HKD' => t('Hong Kong Dollar'), |
'HKD' => t('Hong Kong Dollar'), |
| 653 |
'SGD' => t('Singapore Dollar'), |
'SGD' => t('Singapore Dollar'), |
| 654 |
'SEK' => t('Swedish Krona'), |
'SEK' => t('Swedish Krona'), |
| 655 |
'DKK' => t('Danish Krone'), |
'DKK' => t('Danish Krone'), |
| 656 |
'PLN' => t('Polish Zloty'), |
'PLN' => t('Polish Zloty'), |
| 657 |
'NOK' => t('Norwegian Krone'), |
'NOK' => t('Norwegian Krone'), |
| 658 |
'HUF' => t('Hungarian Forint'), |
'HUF' => t('Hungarian Forint'), |
| 659 |
'CZK' => t('Czech Koruna'), |
'CZK' => t('Czech Koruna'), |
| 660 |
'ILS' => t('Israeli Shekel'), |
'ILS' => t('Israeli Shekel'), |
| 661 |
'MXN' => t('Mexican Peso'), |
'MXN' => t('Mexican Peso'), |
| 662 |
); |
); |
| 663 |
} |
} |
| 664 |
|
|
| 665 |
/** |
/** |
| 668 |
* Get approved currency codes, and include default. |
* Get approved currency codes, and include default. |
| 669 |
*/ |
*/ |
| 670 |
function _donation_currency_options() { |
function _donation_currency_options() { |
| 671 |
$default = variable_get(DONATION_DEFAULT_CURRENCY, 'USD'); |
$default = variable_get(DONATION_DEFAULT_CURRENCY, 'USD'); |
| 672 |
$approved = variable_get(DONATION_CURRENCY_OPTIONS, array()); |
$approved = variable_get(DONATION_CURRENCY_OPTIONS, array()); |
| 673 |
$all_currencies = donation_get_currencies(); |
$all_currencies = donation_get_currencies(); |
| 674 |
$options[$default] = $all_currencies[$default]; |
$options[$default] = $all_currencies[$default]; |
| 675 |
|
|
| 676 |
foreach ($approved as $code => $enabled) { |
foreach ($approved as $code => $enabled) { |
| 677 |
if ($enabled) { |
if ($enabled) { |
| 678 |
$options[$code] = $all_currencies[$code]; |
$options[$code] = $all_currencies[$code]; |
| 679 |
} |
} |
| 680 |
} |
} |
| 681 |
|
|
| 682 |
return $options; |
return $options; |
| 683 |
} |
} |