/[drupal]/contributions/modules/donation/donation.module
ViewVC logotype

Diff of /contributions/modules/donation/donation.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.3, Sat Mar 14 21:00:35 2009 UTC revision 1.3.2.1, Sat Jul 18 21:55:21 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id$  // $Id: donation.module,v 1.3 2009/03/14 21:00:35 kbahey Exp $
3    
4  /**  /**
5   * @file   * @file
# Line 33  define ('DONATION_MEMO_DEFAULT_TEXT', Line 33  define ('DONATION_MEMO_DEFAULT_TEXT',
33  define ('DONATION_PAGE_TITLE',            'donation_page_title');  define ('DONATION_PAGE_TITLE',            'donation_page_title');
34  define ('DONATION_DEFAULT_PAGE_TITLE',    t('Donate'));  define ('DONATION_DEFAULT_PAGE_TITLE',    t('Donate'));
35  define ('DONATION_DEFAULT_EMAIL',         t('webmaster@localhost'));  define ('DONATION_DEFAULT_EMAIL',         t('webmaster@localhost'));
36    define ('DONATION_UPDATE_DONATIONS_THERMOMETER', 'donation_update_donations_thermometer');
37    
38  /**  /**
39   * Implementation of hook_perm().   * Implementation of hook_perm().
# Line 230  function donation_settings() { Line 231  function donation_settings() {
231      '#description' => t('This text will be displayed to the user after they come back from Paypal.'),      '#description' => t('This text will be displayed to the user after they come back from Paypal.'),
232    );    );
233    
234      $form['integration'] = array(
235        '#type' => 'fieldset',
236        '#title' => t('Integration'),
237        '#collapsible' => TRUE,
238        '#collapsed' => FALSE,
239      );
240    
241      $form['integration'][DONATION_UPDATE_DONATIONS_THERMOMETER] = array('#type' => 'checkbox',
242        '#title' => t('Update Donations Thermometer Amount'),
243        '#default_value' => variable_get(DONATION_UPDATE_DONATIONS_THERMOMETER, 0),
244        '#disabled' => !module_exists('donations_thermometer') ? TRUE : FALSE,
245        '#description' => t('When enabled the Donations Thermometer Amount is automatically updated with the total of donations.'),
246      );
247    
248    return system_settings_form($form);    return system_settings_form($form);
249  }  }
250    
# Line 356  function donation_edit_submit($form, &$f Line 371  function donation_edit_submit($form, &$f
371          $form_state['values']['currency'],          $form_state['values']['currency'],
372          $form_state['values']['status']);          $form_state['values']['status']);
373        drupal_set_message(t('The donation has been added.'));        drupal_set_message(t('The donation has been added.'));
374          donation_update_donation_thermometer_amount();
375        break;        break;
376    
377      case 'edit':      case 'edit':
# Line 371  function donation_edit_submit($form, &$f Line 387  function donation_edit_submit($form, &$f
387            $form_state['values']['status'],            $form_state['values']['status'],
388            $form_state['values']['did']);            $form_state['values']['did']);
389          drupal_set_message(t('The donation has been updated.'));          drupal_set_message(t('The donation has been updated.'));
390            donation_update_donation_thermometer_amount();
391        }        }
392        break;        break;
393    
# Line 378  function donation_edit_submit($form, &$f Line 395  function donation_edit_submit($form, &$f
395        if ($form_state['values']['did']) {        if ($form_state['values']['did']) {
396          db_query("DELETE FROM {donations} WHERE did = %d", $form_state['values']['did']);          db_query("DELETE FROM {donations} WHERE did = %d", $form_state['values']['did']);
397          drupal_set_message(t('The donation has been deleted.'));          drupal_set_message(t('The donation has been deleted.'));
398            donation_update_donation_thermometer_amount();
399        }        }
400        break;        break;
401    }    }
# Line 437  function donation_import_submit($form, & Line 455  function donation_import_submit($form, &
455    }    }
456    
457    drupal_set_message(t('The donations have been imported.'));    drupal_set_message(t('The donations have been imported.'));
458      donation_update_donation_thermometer_amount();
459    drupal_goto('admin/build/donations');    drupal_goto('admin/build/donations');
460  }  }
461    
# Line 538  function donation_ipn() { Line 557  function donation_ipn() {
557      $amount,      $amount,
558      $currency,      $currency,
559      variable_get(DONATION_STATE, DONATION_PUBLIC));      variable_get(DONATION_STATE, DONATION_PUBLIC));
560      donation_update_donation_thermometer_amount();
561    watchdog('donation', 'Donation from @name (@mail) amount of @amount @currency.', array(    watchdog('donation', 'Donation from @name (@mail) amount of @amount @currency.', array(
562      '@name'     => $name,      '@name'     => $name,
563      '@mail'     => $payer_email,      '@mail'     => $payer_email,
# Line 614  function donation_form_build() { Line 634  function donation_form_build() {
634    return $form;    return $form;
635  }  }
636    
637    /**
638     * Return the total amount of the donations
639     */
640    
641    function donation_total() {
642      $sql = 'SELECT SUM(d.Amount) FROM {donations} d WHERE d.status=1';
643      $result = db_result(db_query($sql));
644      $result = check_plain(sprintf('%.2f',$result));
645      return $result;
646    }
647    
648    /**
649     * If enabled update the donations_thermometer_amount
650     */
651    
652    function donation_update_donation_thermometer_amount() {
653      if (variable_get(DONATION_UPDATE_DONATIONS_THERMOMETER, 0) == 1) {
654        variable_set('donations_thermometer_amount', donation_total());
655      }
656    }

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.3.2.1

  ViewVC Help
Powered by ViewVC 1.1.2