function postProcess() { $values = $this->controller->exportValues($this->_name); // Combine all fields into on active_fields array for easier processing. $active_fields = array(); if (array_key_exists('active_fundraising_fields', $values)) { $active_fields = $active_fields + $values['active_fundraising_fields']; } if (array_key_exists('active_membership_fields', $values)) { $active_fields = $active_fields + $values['active_membership_fields']; } if (array_key_exists('active_event_standard_fields', $values)) { $active_fields = $active_fields + $values['active_event_standard_fields']; } if (array_key_exists('active_event_turnout_fields', $values)) { $active_fields = $active_fields + $values['active_event_turnout_fields']; } if (count($active_fields) > 0) { $current_active_fields = sumfields_get_setting('active_fields', array()); $new_active_fields = $this->options_to_array($active_fields); if ($current_active_fields != $new_active_fields) { // Setting 'new_active_fields' will alert the system that we have // field changes to be applied. sumfields_save_setting('new_active_fields', $new_active_fields); } } if (array_key_exists('financial_type_ids', $values)) { sumfields_save_setting('financial_type_ids', $this->options_to_array($values['financial_type_ids'])); } if (array_key_exists('membership_financial_type_ids', $values)) { sumfields_save_setting('membership_financial_type_ids', $this->options_to_array($values['membership_financial_type_ids'])); } if (array_key_exists('event_type_ids', $values)) { sumfields_save_setting('event_type_ids', $this->options_to_array($values['event_type_ids'])); } if (array_key_exists('participant_status_ids', $values)) { sumfields_save_setting('participant_status_ids', $this->options_to_array($values['participant_status_ids'])); } if (array_key_exists('participant_noshow_status_ids', $values)) { sumfields_save_setting('participant_noshow_status_ids', $this->options_to_array($values['participant_noshow_status_ids'])); } $session = CRM_Core_Session::singleton(); sumfields_save_setting('generate_schema_and_data', 'scheduled:' . date('Y-m-d H:i:s')); if ($values['when_to_apply_change'] == 'on_submit') { $returnValues = array(); if (!sumfields_gen_data($returnValues)) { $msg = ts("There was an error applying your changes.", array('domain' => 'net.ourpowerbase.sumfields')); } else { $msg = ts("Changes were applied successfully.", array('domain' => 'net.ourpowerbase.sumfields')); } } else { $session->setStatus(ts("Your summary fields will begin being generated on the next scheduled job. It may take up to an hour to complete.", array('domain' => 'net.ourpowerbase.sumfields'))); } $session->replaceUserContext(CRM_Utils_System::url('civicrm/admin/setting/sumfields')); }
/** * Implementation of hook_civicrm_batch. * * Don't create a conflict over summary fields. When batch merging you * will always have conflicts if each record has a different number of * contributions. We should not hold up the merge because these summaries * are different. */ function sumfields_civicrm_merge($type, &$data, $mainId = NULL, $otherId = NULL, $tables = NULL) { if ($type == 'batch') { $custom_field_parameters = _sumfields_get_custom_field_parameters(); $active_fields = sumfields_get_setting('active_fields', array()); while (list($key, $field) = each($custom_field_parameters)) { // Skip fields not active (they should not have been created so // should not exist. if (!in_array($key, $active_fields)) { continue; } $check_key = 'move_custom_' . $field['id']; // Unset summary fields if (array_key_exists($check_key, $data['fields_in_conflict'])) { unset($data['fields_in_conflict'][$check_key]); } } } }