コード例 #1
0
/**
 * SumFields.Gendata API
 *
 * @param array $params
 * @return array API result descriptor
 * @see civicrm_api3_create_success
 * @see civicrm_api3_create_error
 * @throws API_Exception
 */
function civicrm_api3_sum_fields_gendata($params)
{
    $returnValues = array();
    $exception = sumfields_gen_data($returnValues);
    if (!$exception) {
        // Spec: civicrm_api3_create_success($values = 1, $params = array(), $entity = NULL, $action = NULL)
        return civicrm_api3_create_success($returnValues, $params, 'SumFields', 'gendata');
    } else {
        throw new API_Exception('Generating data returned an error.', 1234);
    }
}
コード例 #2
0
 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'));
 }