本文整理汇总了PHP中EE_Error::add_success方法的典型用法代码示例。如果您正苦于以下问题:PHP EE_Error::add_success方法的具体用法?PHP EE_Error::add_success怎么用?PHP EE_Error::add_success使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EE_Error
的用法示例。
在下文中一共展示了EE_Error::add_success方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update_espresso_config
/**
* update_espresso_config
*
* @access public
* @param bool $add_success
* @param bool $add_error
* @return bool
*/
public function update_espresso_config($add_success = false, $add_error = true)
{
// don't allow config updates during WP heartbeats
if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') {
return false;
}
// commented out the following re: https://events.codebasehq.com/projects/event-espresso/tickets/8197
//$clone = clone( self::$_instance );
//self::$_instance = NULL;
do_action('AHEE__EE_Config__update_espresso_config__begin', $this);
$this->_reset_espresso_addon_config();
// hook into update_option because that happens AFTER the ( $value === $old_value ) conditional
// but BEFORE the actual update occurs
add_action('update_option', array($this, 'double_check_config_comparison'), 1, 3);
// now update "ee_config"
$saved = update_option(EE_Config::OPTION_NAME, $this);
EE_Config::log(EE_Config::OPTION_NAME);
// if not saved... check if the hook we just added still exists;
// if it does, it means one of two things:
// that update_option bailed at the ( $value === $old_value ) conditional,
// or...
// the db update query returned 0 rows affected
// (probably because the data value was the same from it's perspective)
// so the existence of the hook means that a negative result from update_option is NOT an error,
// but just means no update occurred, so don't display an error to the user.
// BUT... if update_option returns FALSE, AND the hook is missing,
// then it means that something truly went wrong
$saved = !$saved ? has_action('update_option', array($this, 'double_check_config_comparison')) : $saved;
// remove our action since we don't want it in the system anymore
remove_action('update_option', array($this, 'double_check_config_comparison'), 1);
do_action('AHEE__EE_Config__update_espresso_config__end', $this, $saved);
//self::$_instance = $clone;
//unset( $clone );
// if config remains the same or was updated successfully
if ($saved) {
if ($add_success) {
EE_Error::add_success(__('The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
}
return true;
} else {
if ($add_error) {
EE_Error::add_error(__('The Event Espresso Configuration Settings were not updated.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
}
return false;
}
}
示例2: reset_data
/**
* @resets all non-default session vars
* @access public
* @param array $data_to_reset
* @param bool $show_all_notices
* @return TRUE on success, FALSE on fail
*/
public function reset_data($data_to_reset = array(), $show_all_notices = FALSE)
{
// if $data_to_reset is not in an array, then put it in one
if (!is_array($data_to_reset)) {
$data_to_reset = array($data_to_reset);
}
// nothing ??? go home!
if (empty($data_to_reset)) {
EE_Error::add_error(__('No session data could be reset, because no session var name was provided.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
return FALSE;
}
$return_value = TRUE;
// since $data_to_reset is an array, cycle through the values
foreach ($data_to_reset as $reset) {
// first check to make sure it is a valid session var
if (isset($this->_session_data[$reset])) {
// then check to make sure it is not a default var
if (!array_key_exists($reset, $this->_default_session_vars)) {
// remove session var
unset($this->_session_data[$reset]);
if ($show_all_notices) {
EE_Error::add_success(sprintf(__('The session variable %s was removed.', 'event_espresso'), $reset), __FILE__, __FUNCTION__, __LINE__);
}
$return_value = !isset($return_value) ? TRUE : $return_value;
} else {
// yeeeeeeeeerrrrrrrrrrr OUT !!!!
if ($show_all_notices) {
EE_Error::add_error(sprintf(__('Sorry! %s is a default session datum and can not be reset.', 'event_espresso'), $reset), __FILE__, __FUNCTION__, __LINE__);
}
$return_value = FALSE;
}
} else {
if ($show_all_notices) {
// oops! that session var does not exist!
EE_Error::add_error(sprintf(__('The session item provided, %s, is invalid or does not exist.', 'event_espresso'), $reset), __FILE__, __FUNCTION__, __LINE__);
$return_value = FALSE;
}
}
}
// end of foreach
return $return_value;
}
示例3: _insert_term
private function _insert_term($update = FALSE, $taxonomy = 'espresso_people_categories')
{
if ($taxonomy == 'espresso_people_categories') {
$term_id = $update ? $this->_req_data['PER_CAT_ID'] : '';
} else {
$term_id = $update ? $this->_req_data['PER_TYPE_ID'] : '';
}
$category_name = isset($this->_req_data['category_name']) ? $this->_req_data['category_name'] : '';
$category_desc = isset($this->_req_data['category_desc']) ? $this->_req_data['category_desc'] : '';
$category_parent = isset($this->_req_data['category_parent']) ? $this->_req_data['category_parent'] : 0;
$term_args = array('name' => $category_name, 'description' => $category_desc, 'parent' => $category_parent);
//was the category_identifier input disabled?
if (isset($this->_req_data['category_identifier'])) {
$term_args['slug'] = $this->_req_data['category_identifier'];
}
$insert_ids = $update ? wp_update_term($term_id, $taxonomy, $term_args) : wp_insert_term($category_name, $taxonomy, $term_args);
if (!is_array($insert_ids)) {
$msg = $taxonomy == 'espresso_people_categories' ? __('An error occurred and the category has not been saved to the database.', 'event_espresso') : __('An error occurred and the people type has not been saved to the database.', 'event_espresso');
EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
} else {
$term_id = $insert_ids['term_id'];
$msg = $taxonomy == 'espresso_people_categories' ? sprintf(__('The category %s was successfuly saved', 'event_espresso'), $category_name) : sprintf(__('The people type %s was successfuly saved', 'event_espresso'), $category_name);
EE_Error::add_success($msg);
}
return $term_id;
}
示例4: process_gateway_selection
/**
* process_gateway_selection()
* @access public
* @return mixed array on success or FALSE on fail
*/
public function process_gateway_selection()
{
do_action('AHEE_log', __FILE__, __FUNCTION__, '');
$msg = $this->_EEM_Gateways->display_name() . __(' gateway selected.', 'event_espresso');
EE_Error::add_success($msg, __FILE__, __FUNCTION__, __LINE__);
}
示例5: _duplicate_attendee
/**
* This duplicates the attendee object for the given incoming registration id and attendee_id.
* @return void
*/
protected function _duplicate_attendee()
{
$action = !empty($this->_req_data['return']) ? $this->_req_data['return'] : 'default';
//verify we have necessary info
if (empty($this->_req_data['_REG_ID'])) {
EE_Error::add_error(__('Unable to create the contact for the registration because the required paramaters are not present (_REG_ID )', 'event_espresso'), __FILE__, __LINE__, __FUNCTION__);
$query_args = array('action' => $action);
$this->_redirect_after_action('', '', '', $query_args, TRUE);
}
//okay necessary deets present... let's dupe the incoming attendee and attach to incoming registration.
$registration = EEM_Registration::instance()->get_one_by_ID($this->_req_data['_REG_ID']);
$attendee = $registration->attendee();
//remove relation of existing attendee on registration
$registration->_remove_relation_to($attendee, 'Attendee');
//new attendee
$new_attendee = clone $attendee;
$new_attendee->set('ATT_ID', 0);
$new_attendee->save();
//add new attendee to reg
$registration->_add_relation_to($new_attendee, 'Attendee');
EE_Error::add_success(__('New Contact record created. Now make any edits you wish to make for this contact.', 'event_espresso'));
//redirect to edit page for attendee
$query_args = array('post' => $new_attendee->ID(), 'action' => 'edit_attendee');
$this->_redirect_after_action('', '', '', $query_args, TRUE);
}
示例6: _reset_capabilities
protected function _reset_capabilities()
{
EE_Registry::instance()->CAP->init_caps(true);
EE_Error::add_success(__('Default Event Espresso capabilities have been restored for all current roles.', 'event_espresso'));
$this->_redirect_after_action(FALSE, '', '', array('action' => 'data_reset'), TRUE);
}
示例7: save_csv_to_db
//.........这里部分代码省略.........
//we're supposed to be inserting. But wait, will this thing
//be acceptable if inserted?
$conflicting = $model->get_one_conflicting($model_object_data);
if ($conflicting) {
//ok, this item would conflict if inserted. Just update the item that it conflicts with.
$do_insert = false;
//and if this model has a primary key, remember its mapping
if ($model->has_primary_key_field()) {
$old_db_to_new_db_mapping[$model_name][$id_in_csv] = $conflicting->ID();
$model_object_data[$model->primary_key_name()] = $conflicting->ID();
} else {
//we want to update this conflicting item, instead of inserting a conflicting item
//so we need to make sure they match entirely (its possible that they only conflicted on one field, but we need them to match on other fields
//for the WHERE conditions in the update). At the time of this comment, there were no models like this
foreach ($model->get_combined_primary_key_fields() as $key_field) {
$model_object_data[$key_field->get_name()] = $conflicting->get($key_field->get_name());
}
}
}
}
if ($do_insert) {
//remove the primary key, if there is one (we don't want it for inserts OR updates)
//we'll put it back in if we need it
if ($model->has_primary_key_field() && $model->get_primary_key_field()->is_auto_increment()) {
$effective_id = $model_object_data[$model->primary_key_name()];
unset($model_object_data[$model->primary_key_name()]);
}
//the model takes care of validating the CSV's input
try {
$new_id = $model->insert($model_object_data);
if ($new_id) {
$old_db_to_new_db_mapping[$model_name][$id_in_csv] = $new_id;
$total_inserts++;
EE_Error::add_success(sprintf(__("Successfully added new %s (with id %s) with csv data %s", "event_espresso"), $model_name, $new_id, implode(",", $model_object_data)));
} else {
$total_insert_errors++;
$model_object_data[$model->primary_key_name()] = $effective_id;
EE_Error::add_error(sprintf(__("Could not insert new %s with the csv data: %s", "event_espresso"), $model_name, http_build_query($model_object_data)), __FILE__, __FUNCTION__, __LINE__);
}
} catch (EE_Error $e) {
$total_insert_errors++;
if ($model->has_primary_key_field()) {
$model_object_data[$model->primary_key_name()] = $effective_id;
}
EE_Error::add_error(sprintf(__("Could not insert new %s with the csv data: %s because %s", "event_espresso"), $model_name, implode(",", $model_object_data), $e->getMessage()), __FILE__, __FUNCTION__, __LINE__);
}
} else {
//UPDATING
try {
if ($model->has_primary_key_field()) {
$conditions = array($model->primary_key_name() => $model_object_data[$model->primary_key_name()]);
unset($model_object_data[$model->primary_key_name()]);
} elseif ($model->get_combined_primary_key_fields() > 1) {
$conditions = array();
foreach ($model->get_combined_primary_key_fields() as $key_field) {
$conditions[$key_field->get_name()] = $model_object_data[$key_field->get_name()];
}
} else {
$model->primary_key_name();
//this shoudl just throw an exception, explaining that we dont have a primary key (or a combine dkey)
}
$success = $model->update($model_object_data, array($conditions));
if ($success) {
$total_updates++;
EE_Error::add_success(sprintf(__("Successfully updated %s with csv data %s", "event_espresso"), $model_name, implode(",", $model_object_data)));
} else {
示例8: apply_payments_or_refunds
/**
* registers a payment or refund made towards a transaction
* @access public
* @return void
*/
public function apply_payments_or_refunds()
{
$return_data = FALSE;
if (isset($this->_req_data['txn_admin_payment'])) {
$payment = $this->_req_data['txn_admin_payment'];
$payment['PAY_ID'] = $payment['PAY_ID'];
// payments have a type value of 1 and refunds have a type value of -1
$type = $payment['type'] < 0 ? -1 : 1;
// if this is a refund
if ($type == -1) {
// remove negative sign from amount if it exists
$payment['amount'] = abs($payment['amount']);
}
// so multiplying amount by type will give a positive value for payments, and negative values for refunds
$amount = $payment['amount'] * $type;
switch ($payment['method']) {
case 'PP':
$payment['gateway'] = 'PayPal';
break;
case 'CC':
$payment['gateway'] = 'Credit_Card';
break;
case 'CHQ':
$payment['gateway'] = 'Cheque';
break;
case 'CSH':
$payment['gateway'] = 'Cash';
$payment['txn_id_chq_nmbr'] = '';
break;
case 'DB':
$payment['gateway'] = 'Debit';
$payment['gateway_response'] = '';
break;
case 'BK':
$payment['gateway'] = 'Bank';
break;
case 'IV':
$payment['gateway'] = 'Invoice';
break;
case 'MO':
$payment['gateway'] = 'Money_Order';
}
$payment['gateway_response'] = '';
//savea the new payment
$payment = EE_Payment::new_instance(array('TXN_ID' => $payment['TXN_ID'], 'STS_ID' => $payment['status'], 'PAY_timestamp' => $payment['date'], 'PAY_method' => $payment['method'], 'PAY_amount' => $amount, 'PAY_gateway' => $payment['gateway'], 'PAY_gateway_response' => $payment['gateway_response'], 'PAY_txn_id_chq_nmbr' => $payment['txn_id_chq_nmbr'], 'PAY_po_number' => $payment['po_number'], 'PAY_extra_accntng' => $payment['accounting'], 'PAY_via_admin' => true, 'PAY_details' => $payment, 'PAY_ID' => $payment['PAY_ID']));
if (!$payment->save()) {
$msg = __('An error occurred. The payment has not been processed succesfully.', 'event_espresso');
EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
}
//update the transaction with this payment
if ($payment->apply_payment_to_transaction()) {
$msg = __('The payment has been processed succesfully.', 'event_espresso');
EE_Error::add_success($msg, __FILE__, __FUNCTION__, __LINE__);
} else {
$msg = __('An error occurred. The payment was processed succesfully but the amount paid for the transaction was not updated.', 'event_espresso');
EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
}
//prepare to render page
$transaction = $payment->transaction();
$this->_get_payment_status_array();
$return_data['amount'] = $payment->amount();
$return_data['total_paid'] = $transaction->paid();
$return_data['txn_status'] = $transaction->status_ID();
$return_data['pay_status'] = $payment->STS_ID();
$return_data['PAY_ID'] = $payment->ID();
$return_data['STS_ID'] = $payment->STS_ID();
$return_data['status'] = self::$_pay_status[$payment->STS_ID()];
$return_data['date'] = $payment->timestamp('Y-m-d', 'h:i a');
$return_data['method'] = strtoupper($payment->method());
$this->_get_active_gateways();
$return_data['gateway'] = isset($this->_template_args['active_gateways'][$payment->gateway()]) ? $this->_template_args['active_gateways'][$payment->gateway()] : $payment->gateway();
$return_data['gateway_response'] = $payment->gateway_response();
$return_data['txn_id_chq_nmbr'] = $payment->txn_id_chq_nmbr();
$return_data['po_number'] = $payment->po_number();
$return_data['extra_accntng'] = $payment->extra_accntng();
$this->_process_payment_notification($payment);
if (isset($this->_req_data['txn_reg_status_change'])) {
$this->_process_registration_status_change($transaction);
}
} else {
$msg = __('An error occurred. The payment form data could not be loaded.', 'event_espresso');
EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
}
$notices = EE_Error::get_notices(FALSE, FALSE, FALSE);
echo json_encode(array('return_data' => $return_data, 'success' => $notices['success'], 'errors' => $notices['errors']));
die;
}
示例9: save_settings
/**
* this handles saving the settings for a messenger or message type
* @return json success or fail message
*/
public function save_settings()
{
if (!isset($this->_req_data['type'])) {
EE_Error::add_error(__('Cannot save settings because type is unknown (messenger settings or messsage type settings?)', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
$this->_template_args['error'] = TRUE;
$this->_return_json();
}
if ($this->_req_data['type'] == 'messenger') {
$settings = $this->_req_data['messenger_settings'];
//this should be an array.
$messenger = $settings['messenger'];
//let's setup the settings data
foreach ($settings as $key => $value) {
switch ($key) {
case 'messenger':
unset($settings['messenger']);
break;
case 'message_types':
if (isset($this->_active_messengers[$messenger]['settings'][$messenger . '-message_types'])) {
foreach ($this->_active_messengers[$messenger]['settings'][$messenger . '-message_types'] as $mt => $v) {
if (isset($settings['message_types'][$mt])) {
$settings[$messenger . '-message_types'][$mt]['settings'] = isset($this->_active_messengers[$messenger]['settings'][$messenger . '-message_types'][$mt]) ? $this->_active_messengers[$messenger]['settings'][$messenger . '-message_types'][$mt] : array();
}
}
} else {
foreach ($value as $mt => $v) {
//let's see if this message type is already present and has settings.
$settings[$messenger . '-message_types'][$mt]['settings'] = array();
}
}
//k settings are set let's get rid of the message types index
unset($settings['message_types']);
break;
default:
$settings[$key] = $value;
break;
}
}
$this->_active_messengers[$messenger]['settings'] = $settings;
} else {
if ($this->_req_data['type'] == 'message_type') {
$settings = $this->_req_data['message_type_settings'];
$messenger = $settings['messenger'];
$message_type = $settings['message_type'];
foreach ($settings as $key => $value) {
switch ($key) {
case 'messenger':
unset($settings['messenger']);
break;
case 'message_type':
unset($settings['message_type']);
break;
default:
$settings['settings'][$key] = $value;
unset($settings[$key]);
break;
}
}
$this->_active_messengers[$messenger]['settings'][$messenger . '-message_types'][$message_type] = $settings;
}
}
//okay we should have the data all setup. Now we just update!
$success = EEH_MSG_Template::update_active_messengers_in_db($this->_active_messengers);
if ($success) {
EE_Error::add_success(__('Settings updated', 'event_espresso'));
} else {
EE_Error::add_error(__('Settings did not get updated', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
}
$this->_template_args['success'] = $success;
$this->_return_json();
}
示例10: process_gateway_selection
/**
* process_gateway_selection()
* @access public
* @return mixed array on success or FALSE on fail
*/
public function process_gateway_selection()
{
do_action('AHEE_log', __FILE__, __FUNCTION__, '');
// set billing inputs in the individual gateways plz
$reg_page_billing_inputs = array();
// allow others to edit post input array
$reg_page_billing_inputs = $this->espresso_reg_page_billing_inputs();
$reg_page_billing_inputs = apply_filters('FHEE__EE_Onsite_Gateway__process_gateway_selection__reg_page_billing_inputs', $reg_page_billing_inputs);
//printr( $reg_page_billing_inputs, '$reg_page_billing_inputs <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
// validate and sanitize post data
$reg_page_billing_inputs = EE_Registry::instance()->load_class('EE_Validate_and_Sanitize')->validate_and_sanitize_post_inputs($reg_page_billing_inputs);
if ($reg_page_billing_inputs) {
// add billing info to the session
if (EE_Registry::instance()->SSN->set_session_data(array('billing_info' => $reg_page_billing_inputs))) {
$msg = __('Billing information submitted successfully.', 'event_espresso');
EE_Error::add_success($msg, __FILE__, __FUNCTION__, __LINE__);
}
}
}
示例11: _reset_button_url
protected function _reset_button_url()
{
do_action('AHEE_log', __FILE__, __FUNCTION__, '');
$in_uploads = $this->_EEM_Gateways->is_in_uploads($this->_gateway_name);
if (is_array($in_uploads) && $in_uploads[$this->_gateway_name]) {
$button_url = EVENT_ESPRESSO_GATEWAY_URL . "/" . $this->_gateway_name . '/lib/' . $this->_button_base;
} else {
$button_url = $this->_btn_img;
}
$this->_payment_settings['button_url'] = $button_url;
// change windows style filepaths to Unix style filepaths
$this->_payment_settings['current_path'] = str_replace('\\', '/', $this->_path);
if ($this->_EEM_Gateways->update_payment_settings($this->_gateway_name, $this->_payment_settings)) {
$msg = sprintf(__('The %s button URL was reset.', 'event_espresso'), $this->_payment_settings['display_name']);
EE_Error::add_success($msg, __FILE__, __FUNCTION__, __LINE__);
} else {
$msg = sprintf(__('An error occurred. The %s button URL was not reset.', 'event_espresso'), $this->_payment_settings['display_name']);
EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
}
}
示例12: update_config
/**
* update_config'
*
* @access public
* @return boolean success
*/
public function update_config($add_success = FALSE, $add_error = TRUE)
{
do_action('AHEE__EE_Network_Config__update_config__begin', $this);
// compare existing settings with what's already saved'
$saved_config = $this->get_config();
// update
$saved = $saved_config == $this ? TRUE : update_site_option('ee_network_config', $this);
do_action('AHEE__EE_Network_Config__update_config__end', $this, $saved);
// if config remains the same or was updated successfully
if ($saved) {
if ($add_success) {
$msg = is_multisite() ? __('The Event Espresso Network Configuration Settings have been successfully updated.', 'event_espresso') : __('Extra Event Espresso Configuration settings were successfully updated.', 'event_espresso');
EE_Error::add_success($msg);
}
return TRUE;
} else {
if ($add_error) {
$msg = is_multisite() ? __('The Event Espresso Network Configuration Settings were not updated.', 'event_espresso') : __('Extra Event Espresso Network Configuration settings were not updated.', 'event_espresso');
EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
}
return FALSE;
}
}
示例13: _delete_checkin_row
/**
* Deletes a single EE_Checkin row
* @return void
*/
protected function _delete_checkin_row()
{
$query_args = array('action' => 'registration_checkins', 'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0, '_REGID' => isset($this->_req_data['_REGID']) ? $this->_req_data['_REGID'] : 0);
if (!empty($this->_req_data['CHK_ID'])) {
if (!EEM_Checkin::instance()->delete_by_ID($this->_req_data['CHK_ID'])) {
EE_Error::add_error(__('Something went wrong and this check-in record was not deleted', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
} else {
EE_Error::add_success(__('Check-In record successfully deleted', 'event_espresso'));
}
} else {
EE_Error::add_error(__('In order to delete a Check-in record, there must be a Check-In ID available. There is not. It is not your fault, there is just a gremlin living in the code', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
}
$this->_redirect_after_action(FALSE, '', '', $query_args, TRUE);
}
示例14: empty_event_cart
/**
* remove all events from the event cart
*
* @access public
* @return void
*/
public function empty_event_cart()
{
$this->init();
EED_Multi_Event_Registration::load_classes();
// remove all unwanted records from the db
if (EE_Registry::instance()->CART->delete_cart()) {
// and clear the session too
EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
// reset cached cart
EE_Registry::instance()->CART = EE_Cart::instance(null);
if (apply_filters('FHEE__EED_Multi_Event_Registration__display_success_messages', false)) {
EE_Error::add_success(sprintf(__('The %1$s was successfully emptied!', 'event_espresso'), EED_Multi_Event_Registration::$event_cart_name), __FILE__, __FUNCTION__, __LINE__);
}
} else {
EE_Error::add_error(sprintf(__('The %1$s could not be emptied!', 'event_espresso'), EED_Multi_Event_Registration::$event_cart_name), __FILE__, __FUNCTION__, __LINE__);
}
$this->send_ajax_response(true, apply_filters('FHEE__EED_Multi_Event_Registration__empty_event_cart__redirect_url', EE_EVENTS_LIST_URL));
}
示例15: delete_payment_and_update_transaction
/**
* delete_payment_and_update_transaction
* Before deleting the selected payment, we fetch it's transaction,
* then delete the payment, and update the transactions' amount paid.
*
* @param EE_Payment $payment
* @return boolean
* @throws \EE_Error
*/
public function delete_payment_and_update_transaction(EE_Payment $payment)
{
// verify payment
if (!$payment instanceof EE_Payment) {
EE_Error::add_error(__('A valid Payment object was not received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
return false;
}
if (!$this->delete_registration_payments_and_update_registrations($payment)) {
return false;
}
if (!$payment->delete()) {
EE_Error::add_error(__('The payment could not be deleted.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
return false;
}
$transaction = $payment->transaction();
$TXN_status = $transaction->status_ID();
if ($TXN_status === EEM_Transaction::abandoned_status_code || $TXN_status === EEM_Transaction::failed_status_code || $payment->amount() === 0) {
EE_Error::add_success(__('The Payment was successfully deleted.', 'event_espresso'));
return true;
}
//if this fails, that just means that the transaction didn't get its status changed and/or updated.
//however the payment was still deleted.
if (!$this->calculate_total_payments_and_update_status($transaction)) {
EE_Error::add_attention(__('It appears that the Payment was deleted but no change was recorded for the Transaction for an unknown reason. Please verify that all data for this Transaction looks correct..', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
return true;
}
EE_Error::add_success(__('The Payment was successfully deleted, and the Transaction has been updated accordingly.', 'event_espresso'));
return true;
}