Permalink
Browse files

Changed block display, move global settings to per-node settings instead

* Use node teaser instead of node body on block display.
* Add donate configurations in each node, instead global one.
* Add cleanup variables and block settings which come from this module,
  when user choose uninstall it.
  • Loading branch information...
aimakun committed Mar 15, 2011
1 parent a602061 commit e42267606006ad20e9fb782a8b5637f0468ab677
Showing with 58 additions and 40 deletions.
  1. +26 −5 README
  2. +5 −1 paypal_donate.install
  3. +24 −31 paypal_donate.module
  4. +3 −3 paypal_form.tpl.php
View
31 README
@@ -1,5 +1,26 @@
-Features:
-- Global settings:
- * create dropdown selection for item name.
- * configurable currency. (Default: USD)
-- Update Paypal form based on today's button factory.
+Improved features:
+===========================================================
+- Dropdown selection for item name.
+- Configurable currency. (Default: USD)
+- Block integrations (with node teaser)
+
+
+Fix issues:
+===========================================================
+- Update PayPal form based on today's button factory, now you could try out this module with PayPal Sandbox too. (Edit paypal_form.tpl.php by replace domain "www.paypal.com" with "www.sandbox.paypal.com" overall file).
+- Compatiblility with wysiwyg module.
+
+
+Unicode input support:
+===========================================================
+It depend on your PayPal account profiles, follow these steps:
+
+1. Log into your PayPal account at https://www.paypal.com
+2. Click the Profile link
+3. Click the 'Language Encoding' link under the Selling Preferences column
+4. Click the grey 'More Options' button
+5. Choose "UTF-8" from the Encoding drop down menu
+6. Select "Yes"' for "Do you want to use the same encoding for data sent from
+PayPal to you (e.g., IPN, downloadable logs, emails)?"
+7. Click "Save"
+
View
@@ -55,10 +55,14 @@ function paypal_donate_schema() {
function paypal_donate_uninstall() {
drupal_uninstall_schema('paypal_donate');
+ // Clear per-node variables & blocks.
+ db_query("DELETE FROM {variable} WHERE name LIKE 'paypal_donate_%'");
+ db_query("DELETE FROM {blocks} WHERE module = 'paypal_donate'");
+
/**
* As in version 1.1 i leave the 'paypal_donate_version' in the database because
* it might happen that a user would like to decide to update a newer version of the
* module on a later date. At least then we know that we had an older version installed
* previously.
*/
-}
+}
View
@@ -26,38 +26,8 @@ function paypal_donate_node_info() {
}
/**
- * Implementation of hook_menu()
+ * Implementation of hook_block()
*/
-function paypal_donate_menu() {
- return array(
- 'admin/settings/paypal_donate' => array(
- 'title' => t('Paypal donate global settings'),
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('paypal_donate_settings'),
- 'access arguments' => array('administer nodes'),
- 'type' => MENU_NORMAL_ITEM,
- ),
- );
-}
-
-function paypal_donate_settings() {
- $form['paypal_donate_options'] = array(
- '#type' => 'textarea',
- '#default_value' => variable_get('paypal_donate_options', ''),
- '#title' => t('Global options'),
- '#description' => t('One item per line, this would appear dropdown selection in Paypal form.'),
- );
-
- $form['paypal_donate_currency'] = array(
- '#type' => 'textfield',
- '#default_value' => variable_get('paypal_donate_currency', ''),
- '#title' => t('Global currency code'),
- '#description' => t('See currency code in !link, default: USD', array('!link' => l('Paypal Currency Codes', 'https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_nvp_currency_codes', array('attributes' => array('target' => '_blank'))))),
- );
-
- return system_settings_form($form);
-}
-
function paypal_donate_block($op = 'list', $delta = 0, $edit = array()) {
switch ($op) {
case 'list':
@@ -76,6 +46,7 @@ function paypal_donate_block($op = 'list', $delta = 0, $edit = array()) {
$nodes = variable_get('paypal_donate_block', array());
if (isset($nodes[$delta])) {
$node = node_load($delta);
+ $node->block = TRUE;
drupal_add_css(drupal_get_path('module', 'paypal_donate') . '/paypal_form.css');
return array(
'subject' => $node->title,
@@ -196,6 +167,20 @@ function paypal_donate_form(&$node) {
'#weight' => 2
);
+ $form['donate_options'] = array(
+ '#type' => 'textarea',
+ '#default_value' => variable_get('paypal_donate_options_' . $node->nid, ''),
+ '#title' => t('Global options'),
+ '#description' => t('One item per line, this would appear dropdown selection in Paypal form.'),
+ );
+
+ $form['donate_currency'] = array(
+ '#type' => 'textfield',
+ '#default_value' => variable_get('paypal_donate_currency_' . $node->nid, 'USD'),
+ '#title' => t('Global currency code'),
+ '#description' => t('See currency code in !link, default: USD', array('!link' => l('Paypal Currency Codes', 'https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_nvp_currency_codes', array('attributes' => array('target' => '_blank'))))),
+ );
+
// Get array of block variable.
$blocks = variable_get('paypal_donate_block', array());
$donate_block = isset($blocks[$node->nid]) ? 1 : 0;
@@ -278,4 +263,12 @@ function paypal_donate_block_update($node) {
}
variable_set('paypal_donate_block', $blocks);
}
+
+ if (isset($node->donate_options)) {
+ variable_set('paypal_donate_options_' . $node->nid, $node->donate_options);
+ }
+
+ if (isset($node->donate_currency)) {
+ variable_set('paypal_donate_currency_' . $node->nid, $node->donate_currency);
+ }
}
View
@@ -2,7 +2,7 @@
// $Id: paypal_form.tpl.php,v 1.1 2010/07/15 13:09:27 johnnymast Exp $
?>
<div class="node_<?php print $node->nid?>">
- <?php print $node->body ?>
+ <?php print isset($node->block) ? $node->teaser : $node->body ?>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" id="paypal_donate_form">
<input type="hidden" name="cmd" value="_donations">
@@ -12,13 +12,13 @@
<input type="hidden" name="no_shipping" value="2">
<input type="hidden" id="item_name" name="item_name" value="Donation">
<?php
-$currency = variable_get('paypal_donate_currency', 'USD');
+$currency = variable_get('paypal_donate_currency_' . $node->nid, 'USD');
if (!empty($currency)):
?>
<input type="hidden" name="currency_code" value="<?php print $currency; ?>">
<?php endif; ?>
<?php
- $options = variable_get('paypal_donate_options', '');
+ $options = variable_get('paypal_donate_options_' . $node->nid, '');
if (!empty($options)):
$options = explode("\r\n", $options);
?>

0 comments on commit e422676

Please sign in to comment.