function postProcess() { $values = $this->exportValues(); //Compose the profiles before we save tem. $profiles = array(); foreach (CRM_Volunteer_BAO_Project::getProjectProfileAudienceTypes() as $audience) { $profiles[$audience['type']] = CRM_Utils_Array::value('volunteer_project_default_profiles_' . $audience['type'], $values); } civicrm_api3('Setting', 'create', array("volunteer_project_default_profiles" => $profiles)); civicrm_api3('Setting', 'create', array("volunteer_project_default_campaign" => CRM_Utils_Array::value('volunteer_project_default_campaign', $values))); civicrm_api3('Setting', 'create', array("volunteer_project_default_locblock" => CRM_Utils_Array::value('volunteer_project_default_locblock', $values))); civicrm_api3('Setting', 'create', array("volunteer_project_default_is_active" => CRM_Utils_Array::value('volunteer_project_default_is_active', $values, 0))); // Todo: Create Composite data structure like we do for profiles civicrm_api3('Setting', 'create', array("volunteer_project_default_contacts" => CRM_Utils_Array::value('volunteer_project_default_contacts', $values))); //Whitelist/Blacklist settings civicrm_api3('Setting', 'create', array("volunteer_general_campaign_filter_type" => CRM_Utils_Array::value('volunteer_general_campaign_filter_type', $values))); civicrm_api3('Setting', 'create', array("volunteer_general_campaign_filter_list" => CRM_Utils_Array::value('volunteer_general_campaign_filter_list', $values, array()))); CRM_Core_Session::setStatus(ts("Changes Saved", array('domain' => 'org.civicrm.volunteer')), "Saved", "success"); parent::postProcess(); }
/** * This function returns supporting data for various JavaScript-driven interfaces. * * The purpose of this API is to provide limited access to general-use APIs to * facilitate building user interfaces without having to grant users access to * APIs they otherwise shouldn't be able to access. * * @param array $params * @see _civicrm_api3_volunteer_util_getsupportingdata_spec() * @return array */ function civicrm_api3_volunteer_util_getsupportingdata($params) { $results = array(); $controller = CRM_Utils_Array::value('controller', $params); if ($controller === 'VolunteerProject') { $relTypes = civicrm_api3('OptionValue', 'get', array('option_group_id' => CRM_Volunteer_BAO_ProjectContact::RELATIONSHIP_OPTION_GROUP, 'options' => array('limit' => 0))); $results['relationship_types'] = $relTypes['values']; $results['phone_types'] = CRM_Core_OptionGroup::values("phone_type", FALSE, FALSE, TRUE); //Fetch the Defaults from saved settings. $defaults = CRM_Volunteer_BAO_Project::composeDefaultSettingsArray(); //StopGap because the interface for contacts didn't fit into scope if (!array_key_exists("relationships", $defaults)) { $defaults['relationships'] = _volunteerGetProjectRelationshipDefaults(); } //Allow other extensions to modify the defaults CRM_Volunteer_Hook::projectDefaultSettings($defaults); $results['defaults'] = $defaults; } if ($controller === 'VolOppsCtrl') { $results['roles'] = CRM_Core_OptionGroup::values('volunteer_role', FALSE, FALSE, TRUE); } $results['use_profile_editor'] = CRM_Volunteer_Permission::check(array("access CiviCRM", "profile listings and forms")); $results['profile_audience_types'] = CRM_Volunteer_BAO_Project::getProjectProfileAudienceTypes(); if (!$results['use_profile_editor']) { $profiles = civicrm_api3('UFGroup', 'get', array("return" => "title", "sequential" => 1, 'options' => array('limit' => 0))); $results['profile_list'] = $profiles['values']; } return civicrm_api3_create_success($results, "VolunteerUtil", "getsupportingdata", $params); }