/[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.2, Tue Jul 24 23:21:29 2007 UTC revision 1.3, Sat Mar 14 21:00:35 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2    // $Id$
3    
4  /**  /**
5   * Originally by Dries Butyaert.  Work in progress. Not released until further notice.   * @file
6   * Maintained by Khalid Baheyeldin http://2bits.com   * A simple donation module.
7     * Originally by Dries Butyaert. Maintained by Khalid Baheyeldin http://2bits.com
8   */   */
9    
10  define('DONATION_HIDDEN',              0);  define('DONATION_HIDDEN',                 0);
11  define('DONATION_PUBLIC',              1);  define('DONATION_PUBLIC',                 1);
12    
13  define('DONATION_PAGER',               25);  define('DONATION_PAGER',                  25);
14    
15  define('DONATION_EMAIL',               'donation_email');  define('DONATION_EMAIL',                  'donation_email');
16  define('DONATION_STATE',               'donation_state');  define('DONATION_STATE',                  'donation_state');
17  define('DONATION_THANKS_TEXT',         'donation_thanks_text');  define('DONATION_THANKS_TITLE',           'donation_thanks_title');
18  define('DONATION_THANKS_DEFAULT_TEXT', t('Thank you for your donation.'));  define('DONATION_THANKS_DEFAULT_TITLE',   t('Thank You'));
19  define('DONATION_DONORS_TEXT',         'donation_donors_text');  define('DONATION_THANKS_TEXT',            'donation_thanks_text');
20  define('DONATION_DONORS_DEFAULT_TEXT', t('<ul><li><a href="/donate">Donate now</a> or <a href="/about/donations">learn about donating.</a></li><li><p>This page lists all donors. Donation amounts exclude transaction fees charged by Paypal.</li><li>If you wish to edit your donor name, you may do so from your <a href="/user">profile page</a>.</p></li></ul>'));  define('DONATION_THANKS_DEFAULT_TEXT',    t('Thank you for your donation.'));
21    define('DONATION_DONORS_TEXT',            'donation_donors_text');
22    define('DONATION_DONORS_DEFAULT_TEXT',    t('<ul><li><a href="/donate">Donate now</a>.</li><li><p>This page lists all donors.</li></ul>'));
23    define ('DONATION_DONATE_MESSAGE',        'donation_donate_message');
24    define ('DONATION_DONATE_MESSAGE_DEFAULT_TEXT', t('Please make a donation.'));
25    define ('DONATION_CURRENCY_TEXT',         'donation_currency_text');
26    define ('DONATION_CURRENCY_DEFAULT_TEXT', t('We accept payments in these currencies.'));
27    define ('DONATION_AMOUNT_TEXT',           'donation_amount_text');
28    define ('DONATION_AMOUNT_DEFAULT_TEXT',   t('Enter the amount you wish to donate.'));
29    define ('DONATION_SUBMIT_TEXT',           'donation_submit_text');
30    define ('DONATION_SUBMIT_DEFAULT_TEXT',   t('Proceed to paypal.com for payment'));
31    define ('DONATION_MEMO_TEXT',             'donation_memo_text');
32    define ('DONATION_MEMO_DEFAULT_TEXT',     t('Website Donation'));
33    define ('DONATION_PAGE_TITLE',            'donation_page_title');
34    define ('DONATION_DEFAULT_PAGE_TITLE',    t('Donate'));
35    define ('DONATION_DEFAULT_EMAIL',         t('webmaster@localhost'));
36    
37    /**
38     * Implementation of hook_perm().
39     */
40  function donation_perm() {  function donation_perm() {
41    return array('administer donations');    return array('administer donations');
42  }  }
43    
44  function donation_menu($may_cache) {  /**
45     * Implementation of hook_menu().
46     */
47    function donation_menu() {
48    $items = array();    $items = array();
49    
50    if ($may_cache) {      $access = array('administer site configuration');
     $access = user_access('administer site configuration');  
51    
52      $items[] = array(      $items['ipn/donation'] = array(
53        'path'     => 'ipn/donation',        'page callback' => 'donation_ipn',
       'callback' => 'donation_ipn',  
       'access'   => TRUE,  
54        'type'     => MENU_CALLBACK,        'type'     => MENU_CALLBACK,
55          'access callback' => TRUE,
56      );      );
57      $items[] = array(      $items['donation/thanks'] = array(
58        'path'     => 'donation/thanks',        'title' => variable_get(DONATION_THANKS_TITLE, DONATION_THANKS_DEFAULT_TITLE),
59        'title'    => t('Thank you'),        'page callback' => 'donation_thanks',
       'callback' => 'donation_thanks',  
       'access'   => TRUE,  
60        'type'     => MENU_CALLBACK,        'type'     => MENU_CALLBACK,
61          'access callback' => TRUE,
62      );      );
63      $items[] = array(      $items['admin/settings/donations'] = array(
64        'path' => 'admin/settings/donations',        'title' => 'Donations',
65        'title' => t('Donations'),        'page callback' => 'drupal_get_form',
66        'callback' => 'drupal_get_form',        'page arguments' => array('donation_settings'),
67        'callback arguments' => array('donation_settings'),        'description' => 'Administer donations',
68        'description' => t('Administer donations'),        'access arguments' => $access,
69        'access' => $access,      );
70      );      $items['admin/build/donations'] = array(
71      $items[] = array(        'title' => 'Donations',
72        'path' => 'admin/build/donations',        'access arguments' => $access,
73        'title' => t('Donations'),        'page callback' => 'donation_admin',
74        'access' => $access,        'description' => 'Manages donations to your site via Paypal',
75        'callback' => 'donation_admin',      );
76        'description' => t('Manages donations to your site via Paypal'),      $items['admin/build/donations/list'] = array(
77      );        'title' => 'List',
78      $items[] = array(        'access arguments' => $access,
       'path' => 'admin/build/donations/list',  
       'title' => t('List'),  
       'access' => $access,  
79        'type' => MENU_DEFAULT_LOCAL_TASK,        'type' => MENU_DEFAULT_LOCAL_TASK,
80        'weight' => -10,        'weight' => -10,
81      );      );
82      $items[] = array(      $items['admin/build/donations/add'] = array(
83        'path' => 'admin/build/donations/add',        'title' => 'Add donation',
84        'title' => t('Add donation'),        'access arguments' => $access,
85        'access' => $access,        'page callback' => 'drupal_get_form',
86        'callback' => 'drupal_get_form',        'page arguments' => array('donation_edit', 'add'),
       'callback arguments' => array('donation_edit', 'add'),  
87        'type' => MENU_LOCAL_TASK,        'type' => MENU_LOCAL_TASK,
88      );      );
89      $items[] = array(      $items['admin/build/donations/edit'] = array(
90        'path' => 'admin/build/donations/edit',        'title' => 'Edit donation',
91        'title' => t('Edit donation'),        'access arguments' => $access,
92        'access' => $access,        'page callback' => 'drupal_get_form',
93        'callback' => 'drupal_get_form',        'page arguments' => array('donation_edit', 'edit'),
       'callback arguments' => array('donation_edit', 'edit'),  
94        'type' => MENU_CALLBACK,        'type' => MENU_CALLBACK,
95      );      );
96      $items[] = array(      $items['admin/build/donations/delete'] = array(
97        'path' => 'admin/build/donations/delete',        'title' => 'Delete donation',
98        'title' => t('Delete donation'),        'access arguments' => $access,
99        'access' => $access,        'page callback' => 'drupal_get_form',
100        'callback' => 'drupal_get_form',        'page arguments' => array('donation_edit', 'delete'),
       'callback arguments' => array('donation_edit', 'delete'),  
101        'type' => MENU_CALLBACK,        'type' => MENU_CALLBACK,
102      );      );
103      $items[] = array(      $items['admin/build/donations/import'] = array(
104        'path' => 'admin/build/donations/import',        'title' => 'Import',
105        'title' => t('Import'),        'access arguments' => $access,
106        'access' => $access,        'page callback' => 'drupal_get_form',
107        'callback' => 'drupal_get_form',        'page arguments' => array('donation_import'),
108        'callback arguments' => array('donation_import'),        'type' => MENU_CALLBACK,
       'type' => MENU_LOCAL_TASK,  
109      );      );
110      $items[] = array(      $items['donate'] = array(
111        'path' => 'donate',        'title' => variable_get(DONATION_PAGE_TITLE, DONATION_DEFAULT_PAGE_TITLE),
112        'title' => t('Donate'),        'page callback' => 'drupal_get_form',
113        'access' => TRUE,        'page arguments' => array('donation_form_build'),
       'callback' => 'drupal_get_form',  
       'callback arguments' => array('donation_form_build'),  
114        'type' => MENU_CALLBACK,        'type' => MENU_CALLBACK,
115          'access callback' => TRUE,
116      );      );
117      $items[] = array(      $items['hiddendonations'] = array(
118        'path' => 'donations',        'title' => 'Donations',
119        'title' => t('Donations'),        'page callback' => 'donation_public_page',
       'access' => TRUE,  
       'callback' => 'donation_public_page',  
120        'type' => MENU_CALLBACK,        'type' => MENU_CALLBACK,
121          'access callback' => TRUE,
122      );      );
   }  
123    return $items;    return $items;
124  }  }
125    
126    /**
127     * Implementation of hook_settings().
128     */
129  function donation_settings() {  function donation_settings() {
130    $form[DONATION_EMAIL] = array(    $form['general'] = array(
131        '#type' => 'fieldset',
132        '#title' => t('General Settings'),
133        '#collapsible' => TRUE,
134        '#collapsed' => FALSE,
135      );
136      $form['general'][DONATION_EMAIL] = array(
137      '#type' => 'textfield',      '#type' => 'textfield',
138      '#title' => t('Donations email address'),      '#title' => t('Donations email address'),
139      '#default_value' => variable_get(DONATION_EMAIL, 'donations@drupal.org'),      '#default_value' => variable_get(DONATION_EMAIL, DONATION_DEFAULT_EMAIL),
140      '#description' => t('Only donations to this email address are considered by this module.'),      '#description' => t('Only donations to this email address are considered by this module.'),
141    );    );
142    
143    $form[DONATION_STATE] = array(    $form['general'][DONATION_STATE] = array(
144      '#type'           => 'select',      '#type'           => 'select',
145      '#title'          => t('Default donation state'),      '#title'          => t('Default donation state'),
146      '#default_value'  => variable_get(DONATION_STATE, DONATION_PUBLIC),      '#default_value'  => variable_get(DONATION_STATE, DONATION_PUBLIC),
# Line 132  function donation_settings() { Line 151  function donation_settings() {
151      '#description' => t('Select whether donations will be public or private for this site.'),      '#description' => t('Select whether donations will be public or private for this site.'),
152      );      );
153    
154    $form[DONATION_DONORS_TEXT] = array(    $form['general'][DONATION_MEMO_TEXT] = array(
155        '#type' => 'textfield',
156        '#title' => t('Text for the PayPal memo field'),
157        '#default_value' => variable_get(DONATION_MEMO_TEXT, DONATION_MEMO_DEFAULT_TEXT),
158        '#description' => t('This text will be sent to PayPal in the memo field.'),
159        '#collapsible' => TRUE,
160        '#collapsed' => FALSE,
161      );
162    
163      $form['donate_page'] = array(
164        '#type' => 'fieldset',
165        '#title' => t('Donate Page'),
166        '#collapsible' => TRUE,
167        '#collapsed' => FALSE,
168      );
169    
170      $form['donate_page'][DONATION_PAGE_TITLE] = array(
171        '#type' => 'textfield',
172        '#title' => t('Title for the donate page'),
173        '#default_value' => variable_get(DONATION_PAGE_TITLE, DONATION_DEFAULT_PAGE_TITLE),
174        '#description' => t('This text will be used as the Title for the donate page.'),
175      );
176    
177      $form['donate_page'][DONATION_DONATE_MESSAGE] = array(
178        '#type' => 'textarea',
179        '#title' => t('Introductory text for the donate page'),
180        '#default_value' => variable_get(DONATION_DONATE_MESSAGE, DONATION_DONATE_MESSAGE_DEFAULT_TEXT),
181        '#description' => t('This text will be displayed to the user after they come back from Paypal.'),
182      );
183    
184      $form['donate_page'][DONATION_CURRENCY_TEXT] = array(
185        '#type' => 'textfield',
186        '#title' => t('Description text for the currency field'),
187        '#default_value' => variable_get(DONATION_CURRENCY_TEXT, DONATION_CURRENCY_DEFAULT_TEXT),
188        '#description' => t('This text will be displayed as the description for the currency field on the donate page.'),
189      );
190    
191      $form['donate_page'][DONATION_AMOUNT_TEXT] = array(
192        '#type' => 'textfield',
193        '#title' => t('Description text for the amount field'),
194        '#default_value' => variable_get(DONATION_AMOUNT_TEXT, DONATION_AMOUNT_DEFAULT_TEXT),
195        '#description' => t('This text will be displayed as the description for the amount field on the donate page.'),
196      );
197    
198      $form['donate_page'][DONATION_SUBMIT_TEXT] = array(
199        '#type' => 'textfield',
200        '#title' => t('Text for the Submit button'),
201        '#default_value' => variable_get(DONATION_SUBMIT_TEXT, DONATION_SUBMIT_DEFAULT_TEXT),
202        '#description' => t('This text will be displayed on the Submit button of the donate page.'),
203      );
204    
205      $form['misc'] = array(
206        '#type' => 'fieldset',
207        '#title' => t('Miscellaneous'),
208        '#collapsible' => TRUE,
209        '#collapsed' => FALSE,
210      );
211    
212      $form['misc'][DONATION_DONORS_TEXT] = array(
213      '#type' => 'textarea',      '#type' => 'textarea',
214      '#title' => t('Text for the donors list page'),      '#title' => t('Text for the donors list page'),
215      '#default_value' => variable_get(DONATION_DONORS_TEXT, DONATION_DONORS_DEFAULT_TEXT),      '#default_value' => variable_get(DONATION_DONORS_TEXT, DONATION_DONORS_DEFAULT_TEXT),
216      '#description' => t('This text will be displayed at the top of the donors list page.'),      '#description' => t('This text will be displayed at the top of the donors list page.'),
217    );    );
218    
219    $form[DONATION_THANKS_TEXT] = array(    $form['misc'][DONATION_THANKS_TITLE] = array(
220        '#type' => 'textfield',
221        '#title' => t('Title for the donations thank you page'),
222        '#default_value' => variable_get(DONATION_THANKS_TITLE, DONATION_THANKS_DEFAULT_TITLE),
223        '#description' => t('This text will be the Title of the page the user sees after they come back from Paypal.'),
224      );
225    
226      $form['misc'][DONATION_THANKS_TEXT] = array(
227      '#type' => 'textarea',      '#type' => 'textarea',
228      '#title' => t('Text for the donations thank you page'),      '#title' => t('Text for the donations thank you page'),
229      '#default_value' => variable_get(DONATION_THANKS_TEXT, DONATION_THANKS_DEFAULT_TEXT),      '#default_value' => variable_get(DONATION_THANKS_TEXT, DONATION_THANKS_DEFAULT_TEXT),
# Line 149  function donation_settings() { Line 233  function donation_settings() {
233    return system_settings_form($form);    return system_settings_form($form);
234  }  }
235    
236  function donation_edit($mode) {  /**
237     * FAPI definition for the donation edit form.
238     *
239     * @ingroup forms
240     * @see donation_edit_submit()
241     */
242    function donation_edit(&$form_state, $mode) {
243    $timestamp = format_date(time(), 'custom', 'Y-m-d H:i O');    $timestamp = format_date(time(), 'custom', 'Y-m-d H:i O');
244    
245    switch($mode) {    switch ($mode) {
246      case 'edit':      case 'edit':
247      case 'delete':      case 'delete':
248        $did = (int)arg(4);        $did = (int)arg(4);
# Line 241  function donation_edit($mode) { Line 331  function donation_edit($mode) {
331        '#value' => $did,        '#value' => $did,
332      );      );
333    
334      return($form);      return ($form);
335    }    }
336    
337  function donation_edit_submit($form_id, $form = NULL) {  /**
338    $mode = $form['mode'];   * Submit handler for donation edit form
339     */
340    function donation_edit_submit($form, &$form_state) {
341      $mode = $form_state['values']['mode'];
342    
343    if ($form['delete'] == t('Delete')) {    if ($form_state['values']['delete'] == t('Delete')) {
344      $mode = 'delete';      $mode = 'delete';
345    }    }
346    
347    switch($mode) {    switch ($mode) {
348      case 'add':      case 'add':
349        db_query("INSERT INTO {donations} (timestamp, uid, name, mail, amount, currency, status) VALUES        db_query("INSERT INTO {donations} (timestamp, uid, name, mail, amount, currency, status) VALUES
350          (%d, %d, '%s', '%s', '%s', '%s', %d)",          (%d, %d, '%s', '%s', '%s', '%s', %d)",
351          strtotime($form['timestamp']),          strtotime($form_state['values']['timestamp']),
352          $form['uid'],          $form_state['values']['uid'],
353          $form['name'],          $form_state['values']['name'],
354          $form['mail'],          $form_state['values']['mail'],
355          $form['amount'],          $form_state['values']['amount'],
356          $form['currency'],          $form_state['values']['currency'],
357          $form['status']);          $form_state['values']['status']);
358        drupal_set_message(t('The donation has been added.'));        drupal_set_message(t('The donation has been added.'));
359        break;        break;
360    
361      case 'edit':      case 'edit':
362        if ($form['did']) {        if ($form_state['values']['did']) {
363          db_query("UPDATE {donations}          db_query("UPDATE {donations}
364            SET timestamp = %d, uid = %d, name = '%s', mail = '%s', amount = %f, currency = '%s', status = %d WHERE did = %d",            SET timestamp = %d, uid = %d, name = '%s', mail = '%s', amount = %f, currency = '%s', status = %d WHERE did = %d",
365            strtotime($form['timestamp']),            strtotime($form_state['values']['timestamp']),
366            $form['uid'],            $form_state['values']['uid'],
367            $form['name'],            $form_state['values']['name'],
368            $form['mail'],            $form_state['values']['mail'],
369            $form['amount'],            $form_state['values']['amount'],
370            $form['currency'],            $form_state['values']['currency'],
371            $form['status'],            $form_state['values']['status'],
372            $form['did']);            $form_state['values']['did']);
373          drupal_set_message(t('The donation has been updated.'));          drupal_set_message(t('The donation has been updated.'));
374        }        }
375        break;        break;
376    
377      case 'delete':      case 'delete':
378        if ($form['did']) {        if ($form_state['values']['did']) {
379          db_query("DELETE FROM {donations} WHERE did = %d", $form['did']);          db_query("DELETE FROM {donations} WHERE did = %d", $form_state['values']['did']);
380          drupal_set_message(t('The donation has been deleted.'));          drupal_set_message(t('The donation has been deleted.'));
381        }        }
382        break;        break;
# Line 292  function donation_edit_submit($form_id, Line 385  function donation_edit_submit($form_id,
385    drupal_goto('admin/build/donations');    drupal_goto('admin/build/donations');
386  }  }
387    
388    /**
389     * FAPI definition for the donation import form.
390     *
391     * @ingroup forms
392     * @see donate_form_edit_submit()
393     */
394  function donation_import($form = NULL) {  function donation_import($form = NULL) {
395    $form = array(    $form = array(
396      '#value' => t('Paypal lets you export your payment history to a CSV file.  Copy/paste the contents of the file (or parts thereof) in the form below to mass import your Paypal history into Drupal. Note that the import routine does not check for duplicate entries.'),      '#value' => t('Paypal lets you export your payment history to a CSV file.  Copy/paste the contents of the file (or parts thereof) in the form below to mass import your Paypal history into Drupal. Note that the import routine does not check for duplicate entries.'),
# Line 312  function donation_import($form = NULL) { Line 411  function donation_import($form = NULL) {
411    return $form;    return $form;
412  }  }
413    
414  function donation_import_submit($form_id, $form = NULL) {  function donation_import_submit($form, &$form_state) {
415    $lines = explode("\n", $form['data']);    $lines = explode("\n", $form_state['values']['data']);
416    foreach ($lines as $line) {    foreach ($lines as $line) {
417      list($date, $time, $timezone, $name, $type, $status, $currency, $gross, $fee, $net, $from_email,      list($date, $time, $timezone, $name, $type, $status, $currency, $gross, $fee, $net, $from_email,
418        $to_email, $tid, $cp_status, $shipping_address, $address_status, $item_title, $item_id, $sh_amount,        $to_email, $tid, $cp_status, $shipping_address, $address_status, $item_title, $item_id, $sh_amount,
419        $insurance_amount, $sales_tax, $opt_1_name, $opt_1_value, $opt_2_name, $opt_2_value, $auction_site,        $insurance_amount, $sales_tax, $opt_1_name, $opt_1_value, $opt_2_name, $opt_2_value, $auction_site,
420        $buyer_id, $item_url, $closing_date, $escrow_id, $invoice_id, $ref_txn_id, $invoice_number,        $buyer_id, $item_url, $closing_date, $escrow_id, $invoice_id, $ref_txn_id, $invoice_number,
421        $custom_number, $receipt_id, $contact_phone_number ) = explode('","', $line);        $custom_number, $receipt_id, $contact_phone_number ) = explode('","', $line);
422      if ($to_email == variable_get(DONATION_EMAIL, 'donations@drupal.org') && $name && $net) {      if ($to_email == variable_get(DONATION_EMAIL, DONATION_DEFAULT_EMAIL) && $name && $net) {
423        // We need to swap the day and month in Paypal's date format:        // We need to swap the day and month in Paypal's date format:
424        list($month, $day, $year) = explode('/', substr($date, 1), 3);        list($month, $day, $year) = explode('/', substr($date, 1), 3);
425    
# Line 355  function donation_admin() { Line 454  function donation_admin() {
454      array('data' => t('Operations'), 'colspan' => '2')      array('data' => t('Operations'), 'colspan' => '2')
455    );    );
456    
457    $sql = 'SELECT d.* FROM {donations} d' . tablesort_sql($header);    $sql = 'SELECT d.* FROM {donations} d'. tablesort_sql($header);
458    $result = pager_query($sql, DONATION_PAGER, 0, NULL);    $result = pager_query($sql, DONATION_PAGER, 0, NULL);
459    while ($donation = db_fetch_object($result)) {    while ($donation = db_fetch_object($result)) {
460      $rows[] = array(format_date($donation->timestamp, 'small'),      $rows[] = array(format_date($donation->timestamp, 'small'),
# Line 381  function donation_public_page() { Line 480  function donation_public_page() {
480      array('data' => t('Date'),   'field' => 'timestamp', 'sort' => 'desc'),      array('data' => t('Date'),   'field' => 'timestamp', 'sort' => 'desc'),
481      );      );
482    
483    $sql = 'SELECT d.* FROM {donations} d WHERE d.status = %d' . tablesort_sql($header);    $sql = 'SELECT d.* FROM {donations} d WHERE d.status = %d'. tablesort_sql($header);
484    $result = pager_query($sql, DONATION_PAGER, 0, NULL, DONATION_PUBLIC);    $result = pager_query($sql, DONATION_PAGER, 0, NULL, DONATION_PUBLIC);
485    
486    while ($donation = db_fetch_object($result)) {    while ($donation = db_fetch_object($result)) {
# Line 405  function donation_public_page() { Line 504  function donation_public_page() {
504    print theme('page', $output);    print theme('page', $output);
505  }  }
506    
507  function donation_thanks () {  function donation_thanks() {
508    print theme('page', variable_get(DONATION_THANKS_TEXT, DONATION_THANKS_DEFAULT_TEXT));    print theme('page', variable_get(DONATION_THANKS_TEXT, DONATION_THANKS_DEFAULT_TEXT));
509  }  }
510    
# Line 416  function donation_ipn() { Line 515  function donation_ipn() {
515      return;      return;
516    }    }
517    
518    if ($_POST['business'] != variable_get(DONATION_EMAIL, 'donations@drupal.org')) {    if ($_POST['business'] != variable_get(DONATION_EMAIL, DONATION_DEFAULT_EMAIL)) {
519      // Payment is not for the email address configured      // Payment is not for the email address configured
520      return;      return;
521    }    }
# Line 439  function donation_ipn() { Line 538  function donation_ipn() {
538      $amount,      $amount,
539      $currency,      $currency,
540      variable_get(DONATION_STATE, DONATION_PUBLIC));      variable_get(DONATION_STATE, DONATION_PUBLIC));
541    watchdog('donation', t('Donation from @name (@mail) amount of @amount @currency.', array(    watchdog('donation', 'Donation from @name (@mail) amount of @amount @currency.', array(
542      '@name'     => $name,      '@name'     => $name,
543      '@mail'     => $payer_email,      '@mail'     => $payer_email,
544      '@amount'   => $amount,      '@amount'   => $amount,
545      '@currency' => $currency,      '@currency' => $currency,
546      )));      ));
547  }  }
548    
549  /**  /**
# Line 456  function donation_form() { Line 555  function donation_form() {
555    
556  function donation_form_build() {  function donation_form_build() {
557    global $user;    global $user;
558    if (!$user->uid) {  
     $form['body'] = array(  
       '#value' => t('You do not need to register to donate. However, if you do, there will be a link to your user profile from the donors page. If you want that, then please <a href="!login">login</a> or <a href="!register">register</a> and then return back to this page.', array(  
         '!login'    => url('user/login', drupal_get_destination()),  
         '!register' => url('user/register', drupal_get_destination())  
         ))  
     );  
   }  
559    $form['#action'] = simple_paypal_get_url();    $form['#action'] = simple_paypal_get_url();
560    $form['pre'] = array(    $form['pre'] = array(
561      '#value' => '<p>Please complete the form below and then you will be directed through the Paypal donation process.</p>');      '#value' => variable_get(DONATION_DONATE_MESSAGE, DONATION_DONATE_MESSAGE_DEFAULT_TEXT));
562    $form['business'] = array(    $form['business'] = array(
563      '#type' => 'hidden',      '#type' => 'hidden',
564      '#name' => 'business',      '#name' => 'business',
565      '#value' => variable_get(DONATION_EMAIL, 'donations@drupal.org'));      '#value' => variable_get(DONATION_EMAIL, DONATION_DEFAULT_EMAIL));
566    $form['cmd'] = array(    $form['cmd'] = array(
567      '#type' => 'hidden',      '#type' => 'hidden',
568      '#value' => '_xclick',      '#value' => '_xclick',
569      '#name' => 'cmd');      '#name' => 'cmd');
570    $form['item_name'] = array(    $form['item_name'] = array(
571      '#type' => 'hidden',      '#type' => 'hidden',
572      '#value' => 'Donation to the Drupal Association',      '#value' => variable_get(DONATION_MEMO_TEXT, DONATION_MEMO_DEFAULT_TEXT),
573      '#name' => 'item_name');      '#name' => 'item_name');
574    $form['no_shipping'] = array(    $form['no_shipping'] = array(
575      '#type' => 'hidden',      '#type' => 'hidden',
# Line 485  function donation_form_build() { Line 577  function donation_form_build() {
577      '#name' => 'no_shipping');      '#name' => 'no_shipping');
578    $form['return'] = array(    $form['return'] = array(
579      '#type' => 'hidden',      '#type' => 'hidden',
580      '#value' => url('donation/thanks', NULL, NULL, TRUE),      '#value' => url('donation/thanks', array('absolute' => TRUE)),
581      '#name' => 'return');      '#name' => 'return');
582    $form['currency_code'] = array(    $form['currency_code'] = array(
583      '#type' => 'select',      '#type' => 'select',
584      '#title' => t('Currency'),      '#title' => t('Currency'),
585      '#options' => simple_paypal_get_currencies(),      '#options' => simple_paypal_get_currencies(),
586      '#name' => 'currency_code',      '#name' => 'currency_code',
587      '#description' => t('The Drupal Association accepts payments in these two currencies.'),      '#description' => variable_get(DONATION_CURRENCY_TEXT, DONATION_CURRENCY_DEFAULT_TEXT),
588    );    );
589    $form['amount'] = array(    $form['amount'] = array(
590      '#type' => 'textfield',      '#type' => 'textfield',
591      '#title' => t('Amount'),      '#title' => t('Amount'),
592      '#description' => t('Drupal loves you. Enter the amount you wish to donate.'),      '#description' => variable_get(DONATION_AMOUNT_TEXT, DONATION_AMOUNT_DEFAULT_TEXT),
593      '#size' => 40,      '#size' => 40,
594      '#required' => TRUE,      '#required' => TRUE,
595      '#maxlength' => 255,      '#maxlength' => 255,
# Line 505  function donation_form_build() { Line 597  function donation_form_build() {
597    );    );
598    $form['notify_url'] = array(    $form['notify_url'] = array(
599      '#type' => 'hidden',      '#type' => 'hidden',
600      '#value' => url('ipn/donation', NULL, NULL, TRUE),      '#value' => url('ipn/donation', array('absolute' => TRUE)),
601      '#name' => 'notify_url',      '#name' => 'notify_url',
602    );    );
603    $form['custom'] = array(    $form['custom'] = array(
# Line 515  function donation_form_build() { Line 607  function donation_form_build() {
607    );    );
608    $form['submit'] = array(    $form['submit'] = array(
609      '#type' => 'submit',      '#type' => 'submit',
610      '#value' => t('Proceed to paypal.com for payment'),      '#value' => variable_get(DONATION_SUBMIT_TEXT, DONATION_SUBMIT_DEFAULT_TEXT),
611      '#name' => 'submit',      '#name' => 'submit',
612    );    );
613    
614    return $form;    return $form;
615  }  }
616    

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

  ViewVC Help
Powered by ViewVC 1.1.2