Created
September 28, 2012 19:59
-
-
Save ryanmiglavs/3801814 to your computer and use it in GitHub Desktop.
PHP code that fools Espresso's syntax zones
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function sfapi_submit_cc_payment($donor=array(), $donation=array(), $cc_info=array(), $campaign_info=array()) { | |
| // First make sure we have all the necessary pieces of info, and log notices for any missing recommended info | |
| $required_info = array( | |
| 'donor' => array( | |
| 'first_name', | |
| 'last_name', | |
| 'email', | |
| 'street_address', | |
| 'city', | |
| 'state', | |
| 'zip', | |
| ), | |
| 'donation' => array( | |
| 'donation_amount', | |
| ), | |
| 'cc_info' => array( | |
| 'cc_number', | |
| 'cc_cvv', | |
| 'cc_exp_month', | |
| 'cc_exp_year', | |
| ), | |
| ); | |
| $recommended_info = array( | |
| 'campaign_info' => array( | |
| 'entity', | |
| 'community', | |
| 'fund', | |
| 'sf_campaign_name', | |
| ), | |
| ); | |
| // Log errors for missing required fields, and throw an exception to stop the transaction | |
| foreach ($required_info as $category => $fields) { | |
| foreach ($fields as $field) { | |
| if (!isset(${$category}[$field])) { | |
| watchdog('sfapi', t("Missing a required argument to sfapi_submit_cc_payment() : @argument", array('@argument' => $category . "['" . $field . "']",)), NULL, WATCHDOG_ERROR); | |
| throw new Exception(SFAPI_INTERNAL_CC_ERROR); | |
| } | |
| } | |
| } | |
| // Log warnings for missing recommended fields, but don't throw an exception | |
| foreach ($recommended_info as $category => $fields) { | |
| foreach ($fields as $field) { | |
| if (!isset(${$category}[$field])) { | |
| watchdog('sfapi', t("Missing a recommended argument to sfapi_submit_cc_payment() : @argument", array('@argument' => $category . "['" . $field . "']",)), NULL, WATCHDOG_WARNING); | |
| } | |
| } | |
| } | |
| *** SNIP *** | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment