/** * 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); }
/** * 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)); $results['relationship_types'] = $relTypes['values']; $results['phone_types'] = CRM_Core_OptionGroup::values("phone_type", FALSE, FALSE, TRUE); $results['defaults'] = array('profile' => civicrm_api3('UFGroup', 'getvalue', array("name" => "volunteer_sign_up", "return" => "id")), 'relationships' => _volunteerGetProjectRelationshipDefaults()); } 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")); 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); }